Beispiel #1
0
        public async Task a_failing_middleware_test_should()
        {
            var result = await Scenario.ForMiddleware(Middleware)
                         .When(() => new HttpRequestMessage(HttpMethod.Put, "/some-resource")
            {
                Content = new StringContent("stuff")
            })
                         .ThenShould(response => response.StatusCode == HttpStatusCode.Accepted)
                         .When(response => new HttpRequestMessage(HttpMethod.Get, response.Headers.Location))
                         .ThenShould(response => response.StatusCode == HttpStatusCode.OK);

            result.Print(new ConsolePrinter()).Wait();

            Assert.False(result.Passed);
        }
Beispiel #2
0
        public async Task a_passing_middleware_test_with_timeouts_should()
        {
            var inABit = DateTimeOffset.UtcNow.Add(TimeSpan.FromMilliseconds(200));

            var result = await Scenario.ForMiddleware(Middleware)
                         .When(() => new HttpRequestMessage(HttpMethod.Put, "/some-resource")
            {
                Content = new StringContent("stuff")
            })
                         .ThenShould(response => response.StatusCode == HttpStatusCode.Created)
                         .When(response => new HttpRequestMessage(HttpMethod.Get, response.Headers.Location)
            {
                Headers =
                {
                    IfModifiedSince = inABit
                }
            }, response => response.StatusCode != HttpStatusCode.NotModified)
                         .ThenShould(response => response.StatusCode == HttpStatusCode.OK);

            Assert.True(result.Passed);
        }