public async Task When_Updating_Dwell_Time_Settings_Save_Success(bool acceptChanges) { // arrange var dwellTimeSetting = new DwellTimeSetting(true, false, 3); using var loRaDevice = CreateDefaultDevice(); TwinCollection actualReportedProperties = null; this.loRaDeviceClient.Setup(x => x.UpdateReportedPropertiesAsync(It.IsAny <TwinCollection>(), It.IsAny <CancellationToken>())) .Callback((TwinCollection t, CancellationToken _) => actualReportedProperties = t) .ReturnsAsync(true); // act loRaDevice.UpdateDwellTimeSetting(dwellTimeSetting, acceptChanges); await loRaDevice.SaveChangesAsync(); // assert Assert.Equal(dwellTimeSetting, loRaDevice.ReportedDwellTimeSetting); if (acceptChanges) { Assert.Null(actualReportedProperties); this.loRaDeviceClient.Verify(c => c.UpdateReportedPropertiesAsync(It.IsAny <TwinCollection>(), It.IsAny <CancellationToken>()), Times.Never); } else { Assert.NotNull(actualReportedProperties); Assert.Equal(dwellTimeSetting, JsonSerializer.Deserialize <DwellTimeSetting>(actualReportedProperties[TwinProperty.TxParam].ToString())); } }
public void Setting_And_Getting_DesiredDwellTimeSetting_Success() { var dwellTimeSetting = new DwellTimeSetting(true, false, 4); var subject = new DwellTimeLimitedTestRegion { DesiredDwellTimeSetting = dwellTimeSetting }; Assert.Equal(dwellTimeSetting, subject.DesiredDwellTimeSetting); }
public TxParamSetupRequest(DwellTimeSetting dwellTimeSetting) { this.dwellTimeSetting = dwellTimeSetting ?? throw new ArgumentNullException(nameof(dwellTimeSetting)); if (dwellTimeSetting.MaxEirp > 15) { throw new ArgumentException(null, nameof(dwellTimeSetting)); } Cid = Cid.TxParamSetupCmd; }
public void When_Updating_Dwell_Time_Settings_Should_Update(bool acceptChanges) { // arrange var dwellTimeSetting = new DwellTimeSetting(true, false, 3); using var loRaDevice = CreateDefaultDevice(); // act loRaDevice.UpdateDwellTimeSetting(dwellTimeSetting, acceptChanges); // assert Assert.Equal(dwellTimeSetting, loRaDevice.ReportedDwellTimeSetting); }
public async Task DwellTimeRegion_Success() { // arrange var expectedDesired = new DwellTimeSetting(true, false, 2); SetupDeviceKeyLookup(); SetupTwinResponse(LoRaRegionType.AS923, expectedDesired); // act var result = await this.sut.GetRegionAsync(this.stationEui, CancellationToken.None); // assert var region = Assert.IsType <RegionAS923>(result); Assert.Equal(expectedDesired, region.DesiredDwellTimeSetting); }
public async Task InitializeAsync_Should_Initialize_TxParams() { // arrange using var loRaDevice = CreateDefaultDevice(); var dwellTimeSetting = new DwellTimeSetting(true, false, 4); var twin = TestUtils.CreateTwin(GetEssentialDesiredProperties(), new Dictionary <string, object> { [TwinProperty.TxParam] = JsonSerializer.Serialize(dwellTimeSetting) }); this.loRaDeviceClient.Setup(x => x.GetTwinAsync(CancellationToken.None)) .ReturnsAsync(twin); // act _ = await loRaDevice.InitializeAsync(this.configuration); // assert Assert.Equal(dwellTimeSetting, loRaDevice.ReportedDwellTimeSetting); }
private static string GetTxParamsJson(DwellTimeSetting setting) { if (setting is null) { return("null"); }
public override void UseDwellTimeSetting(DwellTimeSetting dwellTimeSetting) => throw new NotImplementedException();