Skip to content

ConnectionTests

Namespace: UnitTests.MqttReceiver

Unit tests for the Connection class, verifying MQTT connection management and message processing functionality.

public class ConnectionTests

Inheritance ObjectConnectionTests

Constructors

ConnectionTests()

public ConnectionTests()

Methods

Constructor_ReadsConfigurationValues_Successfully()

Tests that the constructor properly reads configuration values.

public void Constructor_ReadsConfigurationValues_Successfully()

Constructor_WithNullConfiguration_ThrowsArgumentNullException()

Tests that the Connection constructor throws when configuration is null.

public void Constructor_WithNullConfiguration_ThrowsArgumentNullException()

Constructor_WithNullLogger_ThrowsArgumentNullException()

Tests that the Connection constructor throws when logger is null.

public void Constructor_WithNullLogger_ThrowsArgumentNullException()

Constructor_WithNullServiceProvider_ThrowsArgumentNullException()

Tests that the Connection constructor throws when service provider is null.

public void Constructor_WithNullServiceProvider_ThrowsArgumentNullException()

Constructor_WithValidDependencies_InitializesSuccessfully()

Tests that the Connection constructor properly initializes with valid dependencies.

public void Constructor_WithValidDependencies_InitializesSuccessfully()

JsonDeserialization_InvalidJson_ThrowsJsonException()

Tests deserialization of invalid JSON.

public void JsonDeserialization_InvalidJson_ThrowsJsonException()

JsonDeserialization_ValidSensorReading_DeserializesCorrectly()

Tests deserialization of valid sensor reading JSON.

public void JsonDeserialization_ValidSensorReading_DeserializesCorrectly()

JsonSerializerOptions_AreConfiguredCorrectly()

Tests that JSON serializer options are properly configured.

public void JsonSerializerOptions_AreConfiguredCorrectly()

ProcessBatchSensorReading_WithMetaData_ProcessesAllReadings()

Tests processing of batch sensor readings with meta data.

public Task ProcessBatchSensorReading_WithMetaData_ProcessesAllReadings()

Returns

Task

ProcessSensorReading_DatabaseError_HandlesGracefully()

Tests that database write errors are handled gracefully.

public Task ProcessSensorReading_DatabaseError_HandlesGracefully()

Returns

Task

ProcessSensorReading_EmptyValueArray_SkipsProcessing()

Tests processing of sensor reading with empty value array.

public Task ProcessSensorReading_EmptyValueArray_SkipsProcessing()

Returns

Task

ProcessSensorReading_NullValue_SkipsProcessing()

Tests processing of sensor reading with null value.

public Task ProcessSensorReading_NullValue_SkipsProcessing()

Returns

Task

ProcessSensorReading_ValidSingleReading_WritesToDatabase()

Tests processing of a valid single sensor reading message using reflection.

public Task ProcessSensorReading_ValidSingleReading_WritesToDatabase()

Returns

Task

Setup()

Sets up test fixtures and initializes mocks before each test execution.

public void Setup()