Пример #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);
        }
        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);
        }