Пример #1
0
        public void SendMessageToApi()
        {
            var message = new Chisler {
                ThreadId = 1, Value = 5
            };
            IMessageBusService messageBus       = new EasyNetQService();
            ITransportService  continuerService = new ContinuerTransportService(messageBus);

            var responce = continuerService.SendAsync(message);

            //Необходимо указать настройку ContinuerApiUrl и запустить сервис
            Assert.IsNull(responce.Exception);
            Assert.IsTrue(responce.IsCompleted);

            Assert.ThrowsException <Exception>(() => continuerService.Get(message.ThreadId));

            IApiService       apiService     = new CalculationApiService();
            ITransportService starterService = new StarterTransportService(messageBus, apiService);

            var result = starterService.Get(message.ThreadId);

            Assert.IsNotNull(result);
            Assert.AreEqual(message.Value, result.Value);

            starterService.Close(message.ThreadId);
        }
Пример #2
0
        public void SendMessageToRabbit()
        {
            var message = new Chisler {
                ThreadId = 1, Value = 5
            };
            IMessageBusService messageBus       = new EasyNetQService();
            IApiService        apiService       = new CalculationApiService();
            ITransportService  transportService = new StarterTransportService(messageBus, apiService);

            transportService.Send(message);

            var result = transportService.Get(message.ThreadId);

            Assert.IsNotNull(result);
            Assert.AreEqual(message.Value, result.Value);

            transportService.Close(message.ThreadId);
        }