PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::device::ProfinetScannerTest Class Reference

Test fixture for ProfinetScanner. More...

+ Inheritance diagram for profinet::device::ProfinetScannerTest:
+ Collaboration diagram for profinet::device::ProfinetScannerTest:

Classes

struct  TestScanDevice
 Test description used to construct a synthetic DCP discovery response. More...
 

Protected Member Functions

void SetUp () override
 Creates the scanner with a mock DCP scanner.
 
void ConfigureScanResults (const dcp::ResponseMap &responses, double timeoutSec)
 Configure the mock DCP scanner to return the supplied responses.
 
dcp::ResponseMap CreateScanResponses (std::initializer_list< TestScanDevice > devices)
 Create synthetic DCP discovery responses for scanner tests.
 

Static Protected Member Functions

static double GetDeviceTimeout (const ProfinetDevice &device)
 

Protected Attributes

MockDcpScanner * mockDcpScanner = nullptr
 
std::unique_ptr< MockDcpScanner > scanner
 
MockMacAddressProvider * mockMacAddressProvider = nullptr
 
std::unique_ptr< MockMacAddressProvider > macAddressProvider
 

Static Protected Attributes

static constexpr MacAddress kMacA {0x02, 0x00, 0x00, 0x00, 0x00, 0x0A}
 

Detailed Description

Test fixture for ProfinetScanner.

Definition at line 253 of file test_device.cpp.

Member Function Documentation

◆ ConfigureScanResults()

void profinet::device::ProfinetScannerTest::ConfigureScanResults ( const dcp::ResponseMap &  responses,
double  timeoutSec 
)
inlineprotected

Configure the mock DCP scanner to return the supplied responses.

Parameters
responsesDCP discovery responses to return.
timeoutSecExpected discovery timeout.

Definition at line 269 of file test_device.cpp.

References mockDcpScanner, and profinet::device::Scan().

+ Here is the call graph for this function:

◆ CreateScanResponses()

dcp::ResponseMap profinet::device::ProfinetScannerTest::CreateScanResponses ( std::initializer_list< TestScanDevice >  devices)
inlineprotected

Create synthetic DCP discovery responses for scanner tests.

The generated response contains the DCP blocks required by DCPDeviceDescription to populate the device MAC address, station name, and IP address. This helper does not perform network communication.

Parameters
devicesDevice descriptions to include in the response.
Returns
Synthetic DCP discovery responses indexed by MAC address.

Definition at line 296 of file test_device.cpp.

References profinet::Device, profinet::Ip, profinet::Ip2String(), profinet::IpParameter, profinet::dcp::MakeBlockKey(), profinet::Name, and profinet::String2Mac().

+ Here is the call graph for this function:

◆ GetDeviceTimeout()

static double profinet::device::ProfinetScannerTest::GetDeviceTimeout ( const ProfinetDevice &  device)
inlinestaticprotected

Definition at line 315 of file test_device.cpp.

References profinet::device::ProfinetDevice::timeout.

◆ SetUp()

void profinet::device::ProfinetScannerTest::SetUp ( )
inlineoverrideprotected

Creates the scanner with a mock DCP scanner.

Definition at line 257 of file test_device.cpp.

References macAddressProvider, mockDcpScanner, mockMacAddressProvider, and scanner.

Member Data Documentation

◆ kMacA

constexpr MacAddress profinet::device::ProfinetScannerTest::kMacA {0x02, 0x00, 0x00, 0x00, 0x00, 0x0A}
staticconstexprprotected

Definition at line 325 of file test_device.cpp.

◆ macAddressProvider

std::unique_ptr<MockMacAddressProvider> profinet::device::ProfinetScannerTest::macAddressProvider
protected

Definition at line 324 of file test_device.cpp.

Referenced by SetUp().

◆ mockDcpScanner

MockDcpScanner* profinet::device::ProfinetScannerTest::mockDcpScanner = nullptr
protected

Definition at line 320 of file test_device.cpp.

Referenced by ConfigureScanResults(), and SetUp().

◆ mockMacAddressProvider

MockMacAddressProvider* profinet::device::ProfinetScannerTest::mockMacAddressProvider = nullptr
protected

Definition at line 323 of file test_device.cpp.

Referenced by SetUp().

◆ scanner

std::unique_ptr<MockDcpScanner> profinet::device::ProfinetScannerTest::scanner
protected

Definition at line 321 of file test_device.cpp.

Referenced by SetUp().


The documentation for this class was generated from the following file: