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); }
public async Task <HttpResponseMessage> SendValueAsync(Chisler value) { InitContinuerClient(); var response = await ContinuerClient.PostAsJsonAsync(ApiCaclulateMethod, value); return(response); }
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); }
public Chisler Calculate(Chisler chisler, CalcRequestEnum сalcRequest, Func <int, int, int> calculator) { return(Calculate(chisler.ThreadId, chisler.Value, сalcRequest, calculator)); }
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)); }
public async Task SendAsync(Chisler value) { throw new NotImplementedException(); }
public void Send(Chisler value) { _messageBusService.SendForThread(value.ThreadId, value); }
public async Task SendAsync(Chisler value) { await _apiService.SendValueAsync(value); }
public void Send(Chisler value) { _apiService.SendValueAsync(value); }