ScaleTestMatzen: Use hard coded date instead of current time

This commit is contained in:
2024-02-21 12:06:50 +01:00
parent 583d5b4e3e
commit 7ff069d068

View File

@ -42,7 +42,7 @@ namespace Tests.WeighingTests {
if (moving && incr)
return ("<13>\r\n", false);
string data = $"00{(moving ? 1 : 0)}0{DateTime.Now:dd.MM.yyHH:mm}{(incr ? identNr : 0),4}1" +
string data = $"00{(moving ? 1 : 0)}0{new DateTime(2020, 10, 15, 12, 34, 0):dd.MM.yyHH:mm}{(incr ? identNr : 0),4}1" +
$"{weight,8}{0,8}{weight,8}{(unit ? "lb" : "kg")} {1,3}";
ushort checksum = Elwig.Helpers.Utils.CalcCrc16Modbus(data);
if (crc) checksum += 10;
@ -72,15 +72,15 @@ namespace Tests.WeighingTests {
public async Task Test_01_CurrentWeight() {
Mock!.Weight = 1234;
Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult {
Weight = 1234, Date = Utils.Today, Time = Utils.Time,
Weight = 1234, Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34),
}));
Mock!.Weight = 1235;
Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult {
Weight = 1235, Date = Utils.Today, Time = Utils.Time,
Weight = 1235, Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34),
}));
Mock!.Weight = 1236;
Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult {
Weight = 1236, Date = Utils.Today, Time = Utils.Time,
Weight = 1236, Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34),
}));
}
@ -89,20 +89,20 @@ namespace Tests.WeighingTests {
Mock!.Weight = 1234;
Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult {
Weight = 1234, WeighingId = "1",
FullWeighingId = $"{DateTime.Today:yyyy-MM-dd}/1",
Date = Utils.Today, Time = Utils.Time,
FullWeighingId = $"2020-10-15/1",
Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34),
}));
Mock!.Weight = 3333;
Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult {
Weight = 3333, WeighingId = "2",
FullWeighingId = $"{DateTime.Today:yyyy-MM-dd}/2",
Date = Utils.Today, Time = Utils.Time,
FullWeighingId = $"2020-10-15/2",
Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34),
}));
Mock!.Weight = 4321;
Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult {
Weight = 4321, WeighingId = "3",
FullWeighingId = $"{DateTime.Today:yyyy-MM-dd}/3",
Date = Utils.Today, Time = Utils.Time,
FullWeighingId = $"2020-10-15/3",
Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34),
}));
}