private async Task ReceiveDataFromAzure()
        {
#if IOTHUB
            while (_azureIoTHubClient != null)
            {
                var message = await _azureIoTHubClient.ReceiveAsync();

                if (message != null)
                {
                    try
                    {
                        var msg = new Models.ReceivedMessage(message.GetBytes());
                        msg.MessageId = message.MessageId;
                        msg.Topic     = message.To;
                        DispatcherServices.Invoke(() => ReceivedMessageList.Insert(0, msg));
                        // Received a new message, display it
                        // We received the message, indicate IoTHub we treated it
                        await _azureIoTHubClient.CompleteAsync(message);
                    }
                    catch
                    {
                        await _azureIoTHubClient.RejectAsync(message);
                    }
                }
            }
#else
            await Task.FromResult(default(object));
#endif
        }
Example #2
0
        public BusTestScenario(TimeSpan timeout, IBusControl busControl)
        {
            _timeout    = timeout;
            _busControl = busControl;

            Received   = new ReceivedMessageList(timeout);
            _skipped   = new ReceivedMessageList(timeout);
            _published = new PublishedMessageList(timeout);

            _tokenSource      = new CancellationTokenSource(timeout);
            CancellationToken = _tokenSource.Token;


            var testSendObserver = new TestSendObserver(timeout);

            Sent = testSendObserver.Messages;

            _subjectSendEndpoint = GetSendEndpoint(testSendObserver);

            var consumeObserver = new TestConsumeObserver(timeout);

            Received = consumeObserver.Messages;
            busControl.ConnectConsumeObserver(consumeObserver);

            _busHandle = _busControl.Start();
        }
Example #3
0
        public SagaTestSubject(ISagaRepository <TSaga> sagaRepository)
        {
            _sagaRepository = sagaRepository;

            _received = new ReceivedMessageList();
            _created  = new SagaList <TSaga>();
            _sagas    = new SagaList <TSaga>();
        }
Example #4
0
        public EndpointTestDecorator(IEndpoint endpoint, EndpointTestScenario scenario)
        {
            _endpoint = endpoint;
            _scenario = scenario;

            _sent     = new SentMessageList();
            _received = new ReceivedMessageList();
        }
Example #5
0
 public SagaRepositoryTestDecorator(ISagaRepository <TSaga> sagaRepository, ReceivedMessageList received, SagaListImpl <TSaga> created,
                                    SagaListImpl <TSaga> sagas)
 {
     _sagaRepository = sagaRepository;
     _received       = received;
     _created        = created;
     _sagas          = sagas;
 }
        private void _mqttClient_CommandReceived(object sender, MqttMsgPublishEventArgs e)
        {
            var msg = new Models.ReceivedMessage(e.Message);

            msg.Topic     = e.Topic;
            msg.MessageId = e.MessageId;
            DispatcherServices.Invoke(() => ReceivedMessageList.Insert(0, msg));
        }
Example #7
0
        public ITestScenarioBuilder <TScenario> Configure(ITestScenarioBuilder <TScenario> builder)
        {
            _received = new ReceivedMessageList <TSubject>(builder.Timeout);

            var scenarioBuilder = builder as IBusTestScenarioBuilder;

            scenarioBuilder?.ConfigureReceiveEndpoint(x => x.Handler <TSubject>(HandleMessage));

            return(builder);
        }
        public void Should_show_that_the_message_was_received_by_the_consumer()
        {
            var multiConsumer = new MultiConsumer();
            ReceivedMessageList <PingMessage> received = multiConsumer.Consume <PingMessage>();

            multiConsumer.Subscribe(LocalBus);

            LocalBus.Publish(new PingMessage());

            received.Any().ShouldBeTrue();
        }
Example #9
0
        public ITestScenarioBuilder <TScenario> Configure(ITestScenarioBuilder <TScenario> builder)
        {
            _received = new ReceivedMessageList(builder.Timeout);
            var decoratedConsumerFactory = new TestConsumerFactoryDecorator <TSubject>(_consumerFactory, _received);

            var scenarioBuilder = builder as IBusTestScenarioBuilder;

            scenarioBuilder?.ConfigureReceiveEndpoint(x => x.Consumer(decoratedConsumerFactory));

            return(builder);
        }
Example #10
0
        public void Should_show_that_the_message_was_received_by_the_consumer()
        {
            var multiConsumer = new MultiTestConsumer(TestTimeout);
            ReceivedMessageList <PingMessage> received = multiConsumer.Consume <PingMessage>();

            using (ConnectHandle handle = multiConsumer.Connect(Bus))
            {
                Bus.Publish(new PingMessage());

                received.Select().Any().ShouldBe(true);
            }
        }
Example #11
0
        public ITestScenarioBuilder <TScenario> Configure(ITestScenarioBuilder <TScenario> builder)
        {
            _received = new ReceivedMessageList(builder.Timeout);
            _created  = new SagaListImpl <TSaga>(builder.Timeout);
            _sagas    = new SagaListImpl <TSaga>(builder.Timeout);

            var decoratedSagaRepository = new SagaRepositoryTestDecorator <TSaga>(_sagaRepository, _received, _created, _sagas);

            var scenarioBuilder = builder as IBusTestScenarioBuilder;

            scenarioBuilder?.ConfigureReceiveEndpoint(x => x.Saga(decoratedSagaRepository));

            return(builder);
        }
Example #12
0
        public async Task Should_deliver_the_publish()
        {
            var multiConsumer = new MultiTestConsumer(TimeSpan.FromSeconds(8));
            ReceivedMessageList <PingMessage> received = multiConsumer.Consume <PingMessage>();

            var mediator = MassTransit.Bus.Factory.CreateMediator(cfg =>
            {
                multiConsumer.Configure(cfg);
            });

            await mediator.Publish(new PingMessage());

            Assert.That(received.Select().Any(), Is.True);
        }
        public async Task Should_show_that_the_message_was_received_by_the_consumer()
        {
            var multiConsumer = new MultiTestConsumer(TestTimeout);
            ReceivedMessageList <PingMessage> received = multiConsumer.Consume <PingMessage>();

            var handle = Bus.ConnectReceiveEndpoint("boring2", x => multiConsumer.Configure(x));
            await handle.Ready;

            try
            {
                await Bus.Publish(new PingMessage());

                Assert.IsTrue(received.Select().Any());
            }
            finally
            {
                await handle.StopAsync();
            }
        }
        public IConsumerTest <TScenario, TConsumer> Build()
        {
            // TODO pull from scenario
            _received = new ReceivedMessageList(TimeSpan.FromSeconds(8));

            AddScenarioConfigurator(new ConsumerScenarioSpecification(_consumerFactory, _received));

            TScenario scenario = BuildTestScenario();

            IConsumerTestBuilder <TScenario, TConsumer> builder = _testBuilderFactory(scenario);

            builder.SetConsumerFactory(_consumerFactory);

            builder = _testSpecifications.Aggregate(builder, (current, configurator) => configurator.Configure(current));

            BuildTestActions(builder);

            return(builder.Build());
        }
Example #15
0
        public SensorNetwork(string str1, string str2, string str3)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            this.numNodes=int.Parse(str1);
            this.xmissionRange=float.Parse(str2);
            this.simulationSpeed=int.Parse(str3);
            rnd   = new Random();
            myPen = new Pen(Color.Blue);
            myLine=new Pen(Color.Gray);
            this.totMsgs=0;
            this.headNode=new SensorNode(true,this.xmissionRange,0, this.simulationSpeed);
            this.headRMsg=new ReceivedMessageList();
            this.temp=this.headNode;
            this.tmpRMsg=this.headRMsg;
            this.headMsg=new MessageList();//dummy node got to be present at all times.
            this.tailMsg=new MessageList();//-do-
            this.headMsg.NEXT=this.tailMsg;
            this.numbers=new bool[this.numNodes];
            this.timerFlag=false;
            this.stopperFlag2=false;
            for(int i=0;i<this.numNodes;i++)
            {
                this.tailNode=new SensorNode(false,this.xmissionRange,i+1,this.simulationSpeed);
                this.temp.Next=this.tailNode;
                this.temp=this.temp.Next;
                this.tailRMsg=new ReceivedMessageList();
                this.tmpRMsg.Next=this.tailRMsg;
                this.tmpRMsg=this.tmpRMsg.Next;
            }
        }
Example #16
0
        protected EndpointTestScenario(IEndpointFactory endpointFactory)
        {
            _received  = new ReceivedMessageList();
            _sent      = new SentMessageList();
            _skipped   = new ReceivedMessageList();
            _published = new PublishedMessageList();

            _endpoints = new Dictionary <Uri, EndpointTestDecorator>();

            EndpointFactory = new EndpointFactoryTestDecorator(endpointFactory, this);

            _endpointCache = new EndpointCache(EndpointFactory);

            EndpointCache = new EndpointCacheProxy(_endpointCache);

            ServiceBusFactory.ConfigureDefaultSettings(x =>
            {
                x.SetEndpointCache(EndpointCache);
                x.SetConcurrentConsumerLimit(4);
                x.SetConcurrentReceiverLimit(1);
                x.SetReceiveTimeout(50.Milliseconds());
                x.EnableAutoStart();
            });
        }
Example #17
0
        public BusTestScenario(TimeSpan timeout, IBusControl busControl)
        {
            _timeout = timeout;
            _busControl = busControl;

            Received = new ReceivedMessageList(timeout);
            _skipped = new ReceivedMessageList(timeout);
            _published = new PublishedMessageList(timeout);

            _tokenSource = new CancellationTokenSource(timeout);
            CancellationToken = _tokenSource.Token;

            _subjectSendEndpoint = _busControl.GetSendEndpoint(new Uri("loopback://localhost/input_queue")).Result;

            var testSendObserver = new TestSendObserver(timeout);
            Sent = testSendObserver.Messages;
            _subjectSendEndpoint.ConnectSendObserver(testSendObserver);

            var consumeObserver = new TestConsumeObserver(timeout);
            Received = consumeObserver.Messages;
            busControl.ConnectConsumeObserver(consumeObserver);

            _busHandle = _busControl.Start();
        }
        public BusTestScenario(TimeSpan timeout, IBusControl busControl)
        {
            _timeout = timeout;
            _busControl = busControl;

            Received = new ReceivedMessageList(timeout);
            _skipped = new ReceivedMessageList(timeout);
            _published = new PublishedMessageList(timeout);

            _tokenSource = new CancellationTokenSource(timeout);
            CancellationToken = _tokenSource.Token;


            var testSendObserver = new TestSendObserver(timeout);
            Sent = testSendObserver.Messages;

            _subjectSendEndpoint = GetSendEndpoint(testSendObserver);

            var consumeObserver = new TestConsumeObserver(timeout);
            Received = consumeObserver.Messages;
            busControl.ConnectConsumeObserver(consumeObserver);

            _busHandle = _busControl.StartAsync();
        }
Example #19
0
 public TestConsumeObserver(TimeSpan timeout)
 {
     _messages = new ReceivedMessageList(timeout);
 }
Example #20
0
 public TestDecoratorPipe(ReceivedMessageList received, IPipe <ConsumerConsumeContext <TConsumer, TMessage> > next)
 {
     _received = received;
     _next     = next;
 }
Example #21
0
 public TestConsumerFactoryDecorator(IConsumerFactory <TConsumer> consumerFactory, ReceivedMessageList received)
 {
     _consumerFactory = consumerFactory;
     _received        = received;
 }
Example #22
0
 public InterceptPipe(SagaListImpl <TSaga> sagas, ReceivedMessageList received, IPipe <SagaConsumeContext <TSaga, TMessage> > pipe)
 {
     _sagas    = sagas;
     _received = received;
     _pipe     = pipe;
 }
Example #23
0
        public ConsumerTestSubject(IConsumerFactory <TSubject> consumerFactory)
        {
            _consumerFactory = consumerFactory;

            _received = new ReceivedMessageList();
        }
 public PingConsumer(TimeSpan timeout, CancellationToken testCompleted)
     : base(timeout, testCompleted)
 {
     _messages = Fault <PingMessage>();
     _faults   = Consume <Fault <PingMessage> >();
 }
 public BaseMessageConsumer(TimeSpan timeout, CancellationToken testCompleted)
     : base(timeout, testCompleted)
 {
     _faults = Consume <Fault <BaseMessageType> >();
 }
Example #26
0
 public BusTestConsumeObserver(TimeSpan timeout, CancellationToken testCompleted)
 {
     _messages = new ReceivedMessageList(timeout, testCompleted);
 }
 public TestConsumeObserver(TimeSpan timeout, CancellationToken inactivityToken)
 {
     _messages = new ReceivedMessageList(timeout, inactivityToken);
 }
Example #28
0
 public HandlerTestSubject(Action <IConsumeContext <TSubject>, TSubject> handler)
 {
     _handler  = handler;
     _received = new ReceivedMessageList <TSubject>();
 }
            public ConsumerScenarioSpecification(IConsumerFactory <TConsumer> consumerFactory, ReceivedMessageList received)
            {
                var decoratedConsumerFactory = new TestConsumerFactoryDecorator <TConsumer>(consumerFactory, received);

                _consumerFactory = decoratedConsumerFactory;
            }
Example #30
0
 public PingConsumer(TimeSpan timeout)
     : base(timeout)
 {
     _messages = Fault <PingMessage>();
     _faults   = Consume <Fault <PingMessage> >();
 }