コード例 #1
0
        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()));
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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;
 }
コード例 #4
0
        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);
        }
コード例 #5
0
            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);
            }
コード例 #6
0
        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);
        }
コード例 #7
0
 private static string GetTxParamsJson(DwellTimeSetting setting)
 {
     if (setting is null)
     {
         return("null");
     }
コード例 #8
0
 public override void UseDwellTimeSetting(DwellTimeSetting dwellTimeSetting) =>
 throw new NotImplementedException();