PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
mockUdpSocket.h File Reference

GoogleMock implementation of IUdpSocket. More...

#include <gmock/gmock.h>
#include "profinet/IUdpSocket.h"
+ Include dependency graph for mockUdpSocket.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  MockUdpSocket
 GoogleMock implementation of IUdpSocket. More...
 

Detailed Description

GoogleMock implementation of IUdpSocket.

Provides a deterministic test double for IPv4 UDP datagram transport.

The mock allows protocol unit tests to:

  • Inject received UDP datagrams without using a network socket.
  • Control the sender address returned by RecvFrom().
  • Verify UDP acknowledgement payloads.
  • Verify the destination endpoint used for acknowledgements.
  • Verify receive-timeout configuration.

No network interface, bound UDP port, or operating-system socket is required.

Example:

StrictMock<MockUdpSocket> socket;
UdpEndpoint source{"127.0.0.1", 45000};
UdpDatagram datagram;
datagram.source = source;
EXPECT_CALL(socket, RecvFrom(::testing::_))
.WillOnce(::testing::Return(datagram));
EXPECT_CALL(socket, SendTo(::testing::_, source))
.Times(1);

Definition in file mockUdpSocket.h.