Esempio n. 1
0
        public void QueueMessenger_ReceiveOneShouldNotErrorWhenNoMessageIsAvailable()
        {
            // Arrange - Setup test data.
            _ = new StorageQueueMessenger(new ConnectionConfig
            {
                ConnectionString = _config.GetValue <string>("ConnectionString")
            });

            var messengerOne = GetMessengerClient("UpdateQueueOne10");

            var retrievedMessage = messengerOne.ReceiveOne <ExampleModel>();

            Assert.True(retrievedMessage == null);
        }
Esempio n. 2
0
        public void QueueMessenger_ReceiveOneUpdateReceiverUninitReceiver()
        {
            // Arrange - Setup test data.
            var testUpdateReciever = new StorageQueueMessenger(new ConnectionConfig
            {
                ConnectionString = _config.GetValue <string>("ConnectionString")
            });

            var messengerOne = GetMessengerClient("UpdateQueueOneA");
            var messengerTwo = GetMessengerClient("UpdateQueueTwoB");

            var messageOne = new ExampleModel()
            {
                PropA = "Yeo A", PropB = 1, PropC = true
            };
            var messageTwo = new ExampleModel()
            {
                PropA = "Baa A", PropB = 2, PropC = false
            };

            // Act - send and then receive the sent message.
            messengerOne.Send(messageOne).GetAwaiter().GetResult();
            messengerTwo.Send(messageTwo).GetAwaiter().GetResult();

            // Get the first message
            var firstRetrievedMessage = messengerOne.ReceiveOne <ExampleModel>();

            messengerOne.Complete(firstRetrievedMessage).GetAwaiter().GetResult();
            // Update the receiver to queue 2
            testUpdateReciever.UpdateReceiver("UpdateQueueTwoB").GetAwaiter().GetResult();

            // Get the second message
            var secondRetrievedMessage = testUpdateReciever.ReceiveOne <ExampleModel>();

            testUpdateReciever.Complete(secondRetrievedMessage).GetAwaiter().GetResult();
            // Assert - message received should be the same as the one sent.
            Assert.True(firstRetrievedMessage.PropA == "Yeo A");
            Assert.True(secondRetrievedMessage.PropA == "Baa A");
        }