public ConcentratorDeduplicationDataMessagesIntegrationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
        {
            this.cache = new MemoryCache(new MemoryCacheOptions());
            this.testOutputLoggerFactory = new TestOutputLoggerFactory(testOutputHelper);
            var concentratorDeduplication = new ConcentratorDeduplication(this.cache, this.testOutputLoggerFactory.CreateLogger <IConcentratorDeduplication>());

            this.frameCounterStrategyMock = new Mock <ILoRaDeviceFrameCounterUpdateStrategy>();
            this.frameCounterProviderMock = new Mock <ILoRaDeviceFrameCounterUpdateStrategyProvider>();

            this.dataRequestHandlerMock = new Mock <TestDefaultLoRaRequestHandler>(MockBehavior.Default,
                                                                                   ServerConfiguration,
                                                                                   this.frameCounterProviderMock.Object,
                                                                                   concentratorDeduplication,
                                                                                   PayloadDecoder,
                                                                                   new DeduplicationStrategyFactory(this.testOutputLoggerFactory, this.testOutputLoggerFactory.CreateLogger <DeduplicationStrategyFactory>()),
                                                                                   new LoRaADRStrategyProvider(this.testOutputLoggerFactory),
                                                                                   new LoRAADRManagerFactory(LoRaDeviceApi.Object, this.testOutputLoggerFactory),
                                                                                   new FunctionBundlerProvider(LoRaDeviceApi.Object, this.testOutputLoggerFactory, this.testOutputLoggerFactory.CreateLogger <FunctionBundlerProvider>()),
                                                                                   testOutputHelper)
            {
                CallBase = true
            };

            this.dataRequestHandlerMock
            .Setup(d => d.DownlinkMessageBuilderResponseAssert(It.IsAny <LoRaRequest>(),
                                                               It.IsAny <LoRaDevice>(),
                                                               It.IsAny <LoRaOperationTimeWatcher>(),
                                                               It.IsAny <LoRaADRResult>(),
                                                               It.IsAny <IReceivedLoRaCloudToDeviceMessage>(),
                                                               It.IsAny <uint?>(),
                                                               It.IsAny <bool>()))
            .Returns((LoRaRequest request, LoRaDevice device, LoRaOperationTimeWatcher _, LoRaADRResult _, IReceivedLoRaCloudToDeviceMessage _, uint?_, bool _) => new
                     DownlinkMessageBuilderResponse(new DownlinkMessage(((LoRaPayloadData)request.Payload).Serialize(device.AppSKey.Value, device.NwkSKey.Value), default, default, default, default, default, default, default, default),
        public async Task Should_fault_nicely()
        {
            var loggerFactory = new TestOutputLoggerFactory(true);

            LogContext.ConfigureCurrentLogContext(loggerFactory);

            DiagnosticListener.AllListeners.Subscribe(new DiagnosticListenerObserver());

            IBusControl busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                x.Host(new Uri("rabbitmq://unknownhost:32787"), h =>
                {
                    h.Username("whocares");
                    h.Password("Ohcrud");
                    h.RequestedConnectionTimeout(2000);
                });

                x.AutoStart = false;
            });

            Assert.That(async() =>
            {
                BusHandle handle = await busControl.StartAsync(new CancellationTokenSource(20000).Token);
                try
                {
                    TestContext.Out.WriteLine("Waiting for connection...");

                    await handle.Ready;
                }
                finally
                {
                    await handle.StopAsync();
                }
            }, Throws.TypeOf <RabbitMqConnectionException>());
        }
        public StatisticCollectorTest(ITestOutputHelper output)
        {
            _output    = output;
            _dataStubs = new DataStubs(
                accountCreatedAt: DateTime.Now.AddMonths(-6),
                dbLastBattleTime: DateTime.Now.AddHours(-2),
                dbAccessTokenExp: DateTime.Now.AddDays(1),
                wgLastBattleTime: DateTime.Now.AddHours(-1)
                );

            var containerBuilder = new ContainerBuilder();

            var loggerFactory = TestOutputLoggerFactory.CreateLoggerFactory(output);

            containerBuilder.SetupLogger(loggerFactory);
            containerBuilder.AddInMemoryDataBase(loggerFactory);
            containerBuilder.ConfigureBlitzStaticianLogic();
            containerBuilder.SetupWargamingApiMockDependencies(_dataStubs);

            _container = containerBuilder.Build();

            _statisticsCollectorFactory = _container.Resolve <IStatisticsCollectorFactory>();
            _statisticsCollectorEngine  = _container.Resolve <IStatisticsCollectorEngine>();
            _dbContext = _container.Resolve <BlitzStaticianDbContext>();
        }
        public async Task Should_not_be_allowed_twice()
        {
            var loggerFactory = new TestOutputLoggerFactory(true);

            LogContext.ConfigureCurrentLogContext(loggerFactory);

            DiagnosticListener.AllListeners.Subscribe(new DiagnosticListenerObserver());

            var secondHarness = new RabbitMqTestHarness();

            try
            {
                Assert.That(async() =>
                {
                    using (var token = new CancellationTokenSource(TimeSpan.FromSeconds(10)))
                    {
                        await secondHarness.Start(token.Token).OrCanceled(TestCancellationToken);

                        await secondHarness.Stop();
                    }
                }, Throws.TypeOf <RabbitMqConnectionException>());
            }
            finally
            {
                secondHarness.Dispose();
            }
        }
        public async Task Should_fault_nicely()
        {
            var loggerFactory = new TestOutputLoggerFactory(true);

            LogContext.ConfigureCurrentLogContext(loggerFactory);

            DiagnosticListener.AllListeners.Subscribe(new DiagnosticListenerObserver());

            var busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                x.Host(new Uri("rabbitmq://unknownhost:32787"), h =>
                {
                    h.Username("whocares");
                    h.Password("Ohcrud");
                    h.RequestedConnectionTimeout(2000);
                });

                x.AutoStart = true;
            });

            Assert.ThrowsAsync <RabbitMqConnectionException>(async() =>
            {
                BusHandle handle;
                using (var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(10)))
                {
                    handle = await busControl.StartAsync(timeout.Token);
                }

                await handle.StopAsync(CancellationToken.None);
            });
        }
        public async Task Should_startup_and_shut_down_cleanly()
        {
            var loggerFactory = new TestOutputLoggerFactory(true);

            LogContext.ConfigureCurrentLogContext(loggerFactory);

            DiagnosticListener.AllListeners.Subscribe(new DiagnosticListenerObserver());

            var busControl = Bus.Factory.CreateUsingRabbitMq();

            BusHandle handle;

            using (var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(30)))
            {
                handle = await busControl.StartAsync(timeout.Token);
            }

            try
            {
                await handle.Ready;
            }
            finally
            {
                await handle.StopAsync(CancellationToken.None);
            }
        }
Example #7
0
        protected void ConfigureLogging(ILogger logger)
        {
            var loggerFactory = new TestOutputLoggerFactory(true, logger);

            LogContext.ConfigureCurrentLogContext(loggerFactory);
            Quartz.Logging.LogContext.SetCurrentLogProvider(loggerFactory);
        }
        public ConcentratorDeduplicationJoinRequestsIntegrationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
        {
            this.simulatedDevice = new SimulatedDevice(TestDeviceInfo.CreateOTAADevice(0));
            this.deviceMock      = new Mock <LoRaDevice>(MockBehavior.Default,
                                                         this.simulatedDevice.DevAddr,
                                                         this.simulatedDevice.DevEUI,
                                                         ConnectionManager)
            {
                CallBase = true
            };
            this.deviceMock.Object.AppKey      = this.simulatedDevice.AppKey;
            this.deviceMock.Object.AppEui      = this.simulatedDevice.AppEui;
            this.deviceMock.Object.IsOurDevice = true;
            this.testOutputLoggerFactory       = new TestOutputLoggerFactory(testOutputHelper);

            this.cache = new MemoryCache(new MemoryCacheOptions());
            var concentratorDeduplication = new ConcentratorDeduplication(this.cache, this.testOutputLoggerFactory.CreateLogger <IConcentratorDeduplication>());
            var deviceRegistryMock        = new Mock <ILoRaDeviceRegistry>();

            _ = deviceRegistryMock.Setup(x => x.GetDeviceForJoinRequestAsync(It.IsAny <DevEui>(), It.IsAny <DevNonce>()))
                .ReturnsAsync(this.deviceMock.Object);

            var clientMock = new Mock <ILoRaDeviceClient>();

            _ = clientMock.Setup(x => x.UpdateReportedPropertiesAsync(It.IsAny <TwinCollection>(), It.IsAny <CancellationToken>())).ReturnsAsync(true);
            ConnectionManager.Register(this.deviceMock.Object, clientMock.Object);

            this.joinRequestHandler = new JoinRequestMessageHandler(
                ServerConfiguration,
                concentratorDeduplication,
                deviceRegistryMock.Object,
                this.testOutputLoggerFactory.CreateLogger <JoinRequestMessageHandler>(),
                null);
        }
        public MessageProcessorMultipleGatewayBase(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
        {
            SecondServerConfiguration = new NetworkServerConfiguration
            {
                GatewayID    = SecondServerGatewayID,
                LogToConsole = true,
                LogLevel     = ((int)LogLevel.Debug).ToString(CultureInfo.InvariantCulture),
            };

            SecondDownstreamMessageSender            = new TestDownstreamMessageSender();
            SecondLoRaDeviceApi                      = new Mock <LoRaDeviceAPIServiceBase>(MockBehavior.Strict);
            SecondFrameCounterUpdateStrategyProvider = new LoRaDeviceFrameCounterUpdateStrategyProvider(SecondServerConfiguration, SecondLoRaDeviceApi.Object);
            this.cache = new MemoryCache(new MemoryCacheOptions()
            {
                ExpirationScanFrequency = TimeSpan.FromSeconds(5)
            });

            this.testOutputLoggerFactory = new TestOutputLoggerFactory(testOutputHelper);
            var deduplicationStrategyFactory = new DeduplicationStrategyFactory(this.testOutputLoggerFactory, this.testOutputLoggerFactory.CreateLogger <DeduplicationStrategyFactory>());
            var loRaAdrManagerFactory        = new LoRAADRManagerFactory(SecondLoRaDeviceApi.Object, this.testOutputLoggerFactory);
            var adrStrategyProvider          = new LoRaADRStrategyProvider(this.testOutputLoggerFactory);
            var functionBundlerProvider      = new FunctionBundlerProvider(SecondLoRaDeviceApi.Object, this.testOutputLoggerFactory, this.testOutputLoggerFactory.CreateLogger <FunctionBundlerProvider>());

            SecondConcentratorDeduplication = new ConcentratorDeduplication(this.cache, this.testOutputLoggerFactory.CreateLogger <IConcentratorDeduplication>());

            SecondRequestHandlerImplementation = new DefaultLoRaDataRequestHandler(SecondServerConfiguration,
                                                                                   SecondFrameCounterUpdateStrategyProvider,
                                                                                   SecondConcentratorDeduplication,
                                                                                   new LoRaPayloadDecoder(this.testOutputLoggerFactory.CreateLogger <LoRaPayloadDecoder>()),
                                                                                   deduplicationStrategyFactory,
                                                                                   adrStrategyProvider,
                                                                                   loRaAdrManagerFactory,
                                                                                   functionBundlerProvider,
                                                                                   this.testOutputLoggerFactory.CreateLogger <DefaultLoRaDataRequestHandler>(),
                                                                                   null);
            SecondLoRaDeviceClient = new Mock <ILoRaDeviceClient>(MockBehavior.Strict);
            this.cache             = new MemoryCache(new MemoryCacheOptions()
            {
                ExpirationScanFrequency = TimeSpan.FromSeconds(5)
            });

            var defaultRequestHandler = new DefaultLoRaDataRequestHandler(SecondServerConfiguration,
                                                                          SecondFrameCounterUpdateStrategyProvider,
                                                                          SecondConcentratorDeduplication,
                                                                          new LoRaPayloadDecoder(this.testOutputLoggerFactory.CreateLogger <LoRaPayloadDecoder>()),
                                                                          deduplicationStrategyFactory,
                                                                          adrStrategyProvider,
                                                                          loRaAdrManagerFactory,
                                                                          functionBundlerProvider,
                                                                          this.testOutputLoggerFactory.CreateLogger <DefaultLoRaDataRequestHandler>(),
                                                                          meter: null);

            SecondConnectionManager = new LoRaDeviceClientConnectionManager(this.cache, this.testOutputLoggerFactory.CreateLogger <LoRaDeviceClientConnectionManager>());
            SecondLoRaDeviceFactory = new TestLoRaDeviceFactory(SecondServerConfiguration, SecondLoRaDeviceClient.Object, SecondConnectionManager, DeviceCache, defaultRequestHandler);
        }
Example #10
0
        void ConfigureBus(IBusFactoryConfigurator configurator)
        {
            var loggerFactory = new TestOutputLoggerFactory(true);

            LogContext.ConfigureCurrentLogContext(loggerFactory);

            if (Interlocked.CompareExchange(ref _subscribedObserver, 1, 0) == 0)
            {
                DiagnosticListener.AllListeners.Subscribe(new DiagnosticListenerObserver());
            }
        }
        public async Task Test_Connect_BadPassword_ThrowsAuthenticationFailure()
        {
            // NCBC-3000: wrong password raises ServiceNotAvailable instead of AuthenticationFailure
            using var loggerFactory = new TestOutputLoggerFactory(_outputHelper);
            var clusterOptions = _fixture.GetOptionsFromConfig();

            clusterOptions.Password = "******";
            clusterOptions.WithLogging(loggerFactory);
            var t  = Couchbase.Cluster.ConnectAsync(clusterOptions);
            var ex = await Assert.ThrowsAsync <AuthenticationFailureException>(() => t);

            // ServiceNotAvailableException would be raised later, when a Query was attempted and no endpoints were bootstrapped.
        }
        public ClassCCloudToDeviceMessageSizeLimitTests(ITestOutputHelper testOutputHelper)
        {
            this.serverConfiguration = new NetworkServerConfiguration()
            {
                GatewayID = ServerGatewayID,
            };

            this.loRaRegion              = RegionManager.EU868;
            DownstreamMessageSender      = new TestDownstreamMessageSender();
            this.deviceApi               = new Mock <LoRaDeviceAPIServiceBase>(MockBehavior.Strict);
            this.deviceClient            = new Mock <ILoRaDeviceClient>(MockBehavior.Loose);
            this.testOutputLoggerFactory = new TestOutputLoggerFactory(testOutputHelper);

            this.cache             = new MemoryCache(new MemoryCacheOptions());
            this.connectionManager = new LoRaDeviceClientConnectionManager(this.cache, testOutputLoggerFactory.CreateLogger <LoRaDeviceClientConnectionManager>());
            this.loRaDeviceFactory = new TestLoRaDeviceFactory(this.deviceClient.Object, this.deviceCache, this.connectionManager);

            this.loRaDeviceRegistry           = new LoRaDeviceRegistry(this.serverConfiguration, this.cache, this.deviceApi.Object, this.loRaDeviceFactory, this.deviceCache);
            this.frameCounterStrategyProvider = new LoRaDeviceFrameCounterUpdateStrategyProvider(this.serverConfiguration, this.deviceApi.Object);
        }
Example #13
0
        static InMemoryReceiveEndpointContext Build()
        {
            var topologyConfiguration = new InMemoryTopologyConfiguration(InMemoryBus.MessageTopology);
            IInMemoryBusConfiguration busConfiguration = new InMemoryBusConfiguration(topologyConfiguration, null);

            var receiveEndpointConfiguration = busConfiguration.HostConfiguration.CreateReceiveEndpointConfiguration("input-queue");

            var hostTopology = new InMemoryHostTopology(busConfiguration.HostConfiguration, topologyConfiguration);
            var host         = new InMemoryHost(busConfiguration.HostConfiguration, hostTopology);

            var builder = new InMemoryReceiveEndpointBuilder(busConfiguration.HostConfiguration, receiveEndpointConfiguration);

            if (LogContext.Current == null)
            {
                var loggerFactory = new TestOutputLoggerFactory(true);

                LogContext.ConfigureCurrentLogContext(loggerFactory);
            }

            return(builder.CreateReceiveEndpointContext());
        }
Example #14
0
        public DwellTimeIntegrationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
        {
            this.testOutputLoggerFactory = new TestOutputLoggerFactory(testOutputHelper);
            this.dataRequestHandlerMock  = new Mock <TestDefaultLoRaRequestHandler>(MockBehavior.Default,
                                                                                    ServerConfiguration,
                                                                                    FrameCounterUpdateStrategyProvider,
                                                                                    ConcentratorDeduplication,
                                                                                    PayloadDecoder,
                                                                                    new DeduplicationStrategyFactory(this.testOutputLoggerFactory, this.testOutputLoggerFactory.CreateLogger <DeduplicationStrategyFactory>()),
                                                                                    new LoRaADRStrategyProvider(this.testOutputLoggerFactory),
                                                                                    new LoRAADRManagerFactory(LoRaDeviceApi.Object, this.testOutputLoggerFactory),
                                                                                    new FunctionBundlerProvider(LoRaDeviceApi.Object, this.testOutputLoggerFactory, this.testOutputLoggerFactory.CreateLogger <FunctionBundlerProvider>()),
                                                                                    testOutputHelper)
            {
                CallBase = true
            };

            this.simulatedDevice = new SimulatedDevice(TestDeviceInfo.CreateABPDevice(0));
            this.loRaDevice      = CreateLoRaDevice(this.simulatedDevice, registerConnection: false);

            LoRaDeviceApi.Setup(x => x.ABPFcntCacheResetAsync(It.IsAny <DevEui>(), It.IsAny <uint>(), It.IsNotNull <string>()))
            .ReturnsAsync(true);
        }
Example #15
0
 static BusTestFixture()
 {
     LoggerFactory = new TestOutputLoggerFactory(_enableLog);
 }
Example #16
0
 static BusTestFixture()
 {
     LoggerFactory = new TestOutputLoggerFactory(true);
 }
Example #17
0
 static TransportTest()
 {
     LoggerFactory = new TestOutputLoggerFactory(_enableLog);
 }