示例#1
0
        public void TestWeatherForecastOK()
        {
            var tempForecast = new TemperatureForecast(30, DateTime.Now, DateTime.MaxValue);
            var forecast     = new WeatherForecast(new [] { tempForecast });

            Assert.AreEqual(tempForecast.ToString(), forecast.ToString());
        }
        private void registerWeatherForecastConsumers()
        {
            var channel = _objectPool.Get();

            channel.QueueBind(queue: "web-api",
                              exchange: "web-api.service",
                              routingKey: "webapi.weatherforecast.get");
            var consumer = new EventingBasicConsumer(channel);

            consumer.Received += (model, ea) =>
            {
                var             body = ea.Body;
                WeatherForecast wf   = JsonConvert.DeserializeObject <WeatherForecast>(Encoding.UTF8.GetString(body.ToArray()));
                _logger.LogInformation($"############# Received {wf.ToString()}");
            };
            channel.BasicConsume(queue: "web-api",
                                 autoAck: true,
                                 consumer: consumer);
        }
示例#3
0
 public virtual void OnWeatherInit(WeatherForecast forecast, string cityName)
 {
     Debug.LogWarning(cityName + ":" + forecast.ToString());
 }