示例#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);
        }
        private void ProcessСontinuerCalculations(Chisler starterChisler)
        {
            var newChisler = _calculationService.Calculate(starterChisler,
                                                           CalcRequestEnum.Continuer, FormulaHelper.SumIntCalculator());

            _transportService.Send(newChisler);
        }
示例#3
0
        public async Task <HttpResponseMessage> SendValueAsync(Chisler value)
        {
            InitContinuerClient();

            var response = await ContinuerClient.PostAsJsonAsync(ApiCaclulateMethod, value);

            return(response);
        }
示例#4
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);
        }
示例#5
0
 public Chisler Calculate(Chisler chisler, CalcRequestEnum сalcRequest, Func <int, int, int> calculator)
 {
     return(Calculate(chisler.ThreadId, chisler.Value, сalcRequest, calculator));
 }
示例#6
0
 public void Caclulate(Chisler value)
 {
     _threadingService.StartСontinuerThread(value);
 }
 /// <inheritdoc />
 /// <summary>
 /// Запустить вычисление Сontinuer
 /// </summary>
 /// <param name="value"></param>
 public void StartСontinuerThread(Chisler value)
 {
     Task.Factory.StartNew(() => ProcessСontinuerCalculations(value));
 }
示例#8
0
 public async Task SendAsync(Chisler value)
 {
     throw new NotImplementedException();
 }
示例#9
0
 public void Send(Chisler value)
 {
     _messageBusService.SendForThread(value.ThreadId, value);
 }
示例#10
0
 public async Task SendAsync(Chisler value)
 {
     await _apiService.SendValueAsync(value);
 }
示例#11
0
 public void Send(Chisler value)
 {
     _apiService.SendValueAsync(value);
 }