Example #1
0
        public void GetWeatherForecastsHandler()
        {
            GetWeatherForecastsHandler getWeatherForecastsHandler = ServiceProvider.GetService <GetWeatherForecastsHandler>();

            getWeatherForecastsHandler.ShouldNotBeNull();

            IRequestHandler <GetWeatherForecastsRequest, GetWeatherForecastsResponse> handler = ServiceProvider.GetService <IRequestHandler <GetWeatherForecastsRequest, GetWeatherForecastsResponse> >();

            handler.ShouldNotBeNull();
        }
Example #2
0
        public void TestException()
        {
            //Arrange
            GetWeatherForecasts command = null;
            var handler = new GetWeatherForecastsHandler();

            //Act
            Func <Task <IReadOnlyList <WeatherForecast> > > action = () => handler.Handle(command, CancellationToken.None);

            //Assert
            action.Should().ThrowExactly <NullReferenceException>();
        }
        public void ShouldGetServiceForMediator()
        {
            IMediator mediator = ServiceProvider.GetService <IMediator>();

            mediator.ShouldNotBeNull();

            GetWeatherForecastsHandler getWeatherForecastsHandler = ServiceProvider.GetService <GetWeatherForecastsHandler>();

            getWeatherForecastsHandler.ShouldNotBeNull();

            IRequestHandler <GetWeatherForecastsRequest, GetWeatherForecastsResponse> handler = ServiceProvider.GetService <IRequestHandler <GetWeatherForecastsRequest, GetWeatherForecastsResponse> >();

            handler.ShouldNotBeNull();

            // Something in preview 8 indirectly requires this interface.
            IConfiguration configuration = ServiceProvider.GetService <IConfiguration>();

            configuration.ShouldNotBeNull();
        }
Example #4
0
        public async Task TestMethod1()
        {
            //Arrange
            var command = new GetWeatherForecasts();
            var handler = new GetWeatherForecastsHandler();

            //Act
            var result = await handler.Handle(command, CancellationToken.None);

            this.TestContext.WriteLine(result.ToString());

            //Assert
            result.Should().NotBeNull();
            result.Count.Should().Be(5);

            foreach (var item in result)
            {
                item.Summary.Should().BeOneOf(Summaries);
                item.TemperatureC.Should().BeInRange(-20, 55);
            }
        }