예제 #1
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);
        }
예제 #2
0
        public void Execution_Items_Should_Have_Correct_Priority()
        {
            var cacheStore = new LoRaInMemoryDeviceStore();

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

            var sorted = items.OrderBy(x => x.Priority);

            Assert.IsType <DeduplicationExecutionItem>(sorted.ElementAt(0));
            Assert.IsType <ADRExecutionItem>(sorted.ElementAt(1));
            Assert.IsType <NextFCntDownExecutionItem>(sorted.ElementAt(2));
            Assert.IsType <PreferredGatewayExecutionItem>(sorted.ElementAt(3));

            // Ensure no item has the same priority
            Assert.Empty(items.GroupBy(x => x.Priority).Where(x => x.Count() > 1));
        }
        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);
        }