public ADRFunctionTest()
        {
            var adrStrategy = new Mock <ILoRaADRStrategy>(MockBehavior.Strict);

            adrStrategy
            .Setup(x => x.ComputeResult(It.IsNotNull <string>(), It.IsNotNull <LoRaADRTable>(), It.IsAny <float>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns((string devEUI, LoRaADRTable table, float snr, int dr, int power, int maxDr) =>
            {
                return(table.Entries.Count >= LoRaADRTable.FrameCountCaptureCount
                    ? new LoRaADRResult()
                {
                    NumberOfFrames = table.Entries.Count
                }
                    : null);
            });

            adrStrategy.Setup(x => x.DefaultNbRep).Returns(1);
            adrStrategy.Setup(x => x.DefaultTxPower).Returns(0);
            adrStrategy.Setup(x => x.MinimumNumberOfResult).Returns(20);

            var strategyProvider = new Mock <ILoRaADRStrategyProvider>(MockBehavior.Strict);

            strategyProvider
            .Setup(x => x.GetStrategy())
            .Returns(adrStrategy.Object);

            this.adrManager       = new LoRaADRServerManager(new LoRaADRInMemoryStore(), strategyProvider.Object, new LoRaInMemoryDeviceStore());
            this.adrExecutionItem = new ADRExecutionItem(this.adrManager);
        }
示例#2
0
        public FunctionBundlerTest()
        {
            var strategy = new Mock <ILoRaADRStrategy>(MockBehavior.Strict);

            strategy.Setup(x => x.DefaultNbRep).Returns(1);
            strategy.Setup(x => x.DefaultTxPower).Returns(0);
            strategy.Setup(x => x.MinimumNumberOfResult).Returns(20);
            strategy
            .Setup(x => x.ComputeResult(It.IsAny <LoRaADRTable>(), It.IsAny <float>(), It.IsAny <DataRateIndex>(), It.IsAny <int>(), It.IsAny <DataRateIndex>()))
            .Returns((LoRaADRTable table, float snr, DataRateIndex upstreamDr, int minTxPower, DataRateIndex maxDr) =>
            {
                return(new LoRaADRResult
                {
                    CanConfirmToDevice = true,
                    DataRate = upstreamDr,
                    TxPower = 0
                });
            });

            var strategyProvider = new Mock <ILoRaADRStrategyProvider>(MockBehavior.Strict);

            strategyProvider
            .Setup(x => x.GetStrategy())
            .Returns(strategy.Object);

            // .Returns(new LoRaADRStandardStrategy());
            var cacheStore = new LoRaInMemoryDeviceStore();

            this.adrStore         = new LoRaADRInMemoryStore();
            this.adrManager       = new LoRaADRServerManager(this.adrStore, strategyProvider.Object, cacheStore, NullLogger <LoRaADRServerManager> .Instance);
            this.adrExecutionItem = new ADRExecutionItem(this.adrManager);

            var items = new IFunctionBundlerExecutionItem[]
            {
                new DeduplicationExecutionItem(cacheStore),
                this.adrExecutionItem,
                new NextFCntDownExecutionItem(new FCntCacheCheck(cacheStore)),
                new PreferredGatewayExecutionItem(cacheStore, new NullLogger <PreferredGatewayExecutionItem>(), null),
            };

            this.functionBundler = new FunctionBundlerFunction(items);
        }
        public FunctionBundlerTest()
        {
            var strategyProvider = new Mock <ILoRaADRStrategyProvider>(MockBehavior.Strict);

            strategyProvider
            .Setup(x => x.GetStrategy())
            .Returns(new LoRaADRStandardStrategy());

            var cacheStore = new LoRaInMemoryDeviceStore();

            this.adrManager       = new LoRaADRServerManager(new LoRaADRInMemoryStore(), strategyProvider.Object, cacheStore);
            this.adrExecutionItem = new ADRExecutionItem(this.adrManager);

            var items = new IFunctionBundlerExecutionItem[]
            {
                new DeduplicationExecutionItem(cacheStore),
                this.adrExecutionItem,
                new NextFCntDownExecutionItem(new FCntCacheCheck(cacheStore)),
                new PreferredGatewayExecutionItem(cacheStore, new NullLogger <PreferredGatewayExecutionItem>(), null),
            };

            this.functionBundler = new FunctionBundlerFunction(items);
        }