Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wazzamatazz committed May 28, 2021
1 parent e3ae8ca commit b3d56dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/NRuuviTag.Core.Tests/UtilitiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void ShouldParseValidRawV2Payload() {

// Expected values taken from https://docs.ruuvi.com/communication/bluetooth-advertisements/data-format-5-rawv2#case-valid-data

Assert.AreEqual(5, sample.DataFormat);
Assert.AreEqual((byte) 5, sample.DataFormat);
Assert.AreEqual(24.3, sample.Temperature);
Assert.AreEqual(1000.44, sample.Pressure);
Assert.AreEqual(53.49, sample.Humidity);
Expand Down
12 changes: 11 additions & 1 deletion test/NRuuviTag.Mqtt.Tests/MqttPublishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public async Task ShouldPublishSampleToMultipleTopics() {

var sample = RuuviTagUtilities.CreateSampleFromPayload(now, signalStrength, s_rawPayload);
var expectedTopicPrefix = bridge.GetTopicNameForSample(sample);
const int expectedMessageCount = 12;
const int expectedMessageCount = 13;

var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var receivedMessages = new List<MqttApplicationMessage>();
Expand Down Expand Up @@ -290,6 +290,9 @@ void OnMessageReceived(MqttApplicationMessageReceivedEventArgs args) {
case "/humidity":
sampleFromMqtt.Humidity = JsonSerializer.Deserialize<double>(json);
break;
case "/mac-address":
sampleFromMqtt.MacAddress = JsonSerializer.Deserialize<string>(json);
break;
case "/measurement-sequence":
sampleFromMqtt.MeasurementSequence = JsonSerializer.Deserialize<ushort>(json);
break;
Expand All @@ -311,6 +314,9 @@ void OnMessageReceived(MqttApplicationMessageReceivedEventArgs args) {
case "/tx-power":
sampleFromMqtt.TxPower = JsonSerializer.Deserialize<double>(json);
break;
default:
Assert.Fail("Unexpected field: " + fieldName);
break;
}
}

Expand Down Expand Up @@ -348,6 +354,7 @@ public async Task MultipleTopicPublishShouldExcludeSpecifiedMeasurements() {
},
PrepareForPublish = s => {
s.AccelerationX = null;
s.MacAddress = null;
}
}, new MqttFactory());

Expand Down Expand Up @@ -438,6 +445,9 @@ void OnMessageReceived(MqttApplicationMessageReceivedEventArgs args) {
case "/tx-power":
sampleFromMqtt.TxPower = JsonSerializer.Deserialize<double>(json);
break;
default:
Assert.Fail("Unexpected field: " + fieldName);
break;
}
}

Expand Down

0 comments on commit b3d56dc

Please sign in to comment.