示例#1
0
        public void happy_path()
        {
            var assertion = new StatusCodeAssertion(304);

            AssertionRunner.Run(assertion, _ => _.StatusCode(304))
            .AssertAll();
        }
示例#2
0
        public void sad_path()
        {
            var assertion = new BodyContainsAssertion("Hey!");

            AssertionRunner.Run(assertion, env => env.Response.Write("Not the droids you are looking for"))
            .SingleMessageShouldBe("Expected text 'Hey!' was not found in the response body");
        }
示例#3
0
        public void sad_path()
        {
            var assertion = new StatusCodeAssertion(200);

            AssertionRunner.Run(assertion, _ => _.StatusCode(304))
            .SingleMessageShouldBe("Expected status code 200, but was 304");
        }
        public void sad_path()
        {
            var assertion = new BodyDoesNotContainAssertion("Hey!");

            AssertionRunner.Run(assertion, env => env.Response.Write("Hey! You!"))
            .SingleMessageShouldBe("Text 'Hey!' should not be found in the response body");
        }
示例#5
0
        public void sad_path_wrong_value()
        {
            var assertion = new HeaderValueAssertion("foo", "bar");

            AssertionRunner.Run(assertion, x => x.Response.Headers["foo"] = "baz")
            .SingleMessageShouldBe("Expected a single header value of 'foo'='bar', but the actual value was 'baz'");
        }
示例#6
0
        public void sad_path()
        {
            var assertion = new BodyTextAssertion("Hey!");

            AssertionRunner.Run(assertion, env => env.Response.Write("Hey! You!"))
            .Messages.Single().ShouldContain("Expected the content to be 'Hey!'");
        }
示例#7
0
        public void sad_path_no_values()
        {
            var assertion = new HasSingleHeaderValueAssertion("foo");

            AssertionRunner.Run(assertion, e => { })
            .SingleMessageShouldBe("Expected a single header value of 'foo', but no values were found on the response");
        }
示例#8
0
        public void happy_path()
        {
            var assertion = new HasSingleHeaderValueAssertion("foo");

            AssertionRunner.Run(assertion, x => x.Response.Headers["foo"] = "bar")
            .AssertAll();
        }
        public void sad_path_no_value()
        {
            var expected  = new[] { "one", "two" };
            var assertion = new HeaderMultiValueAssertion("foo", expected);

            AssertionRunner.Run(assertion, x => { })
            .SingleMessageShouldBe("Expected header values of 'foo'='one', 'two', but no values were found on the response.");
        }
示例#10
0
        public void happy_path_permanent()
        {
            var assertion = new RedirectAssertion("/to", true);

            AssertionRunner
            .Run(assertion, x => x.Response.As <StubHttpResponse>().Redirect("/to", true))
            .AssertAll();
        }
示例#11
0
        public void sad_path_permanent_wrong_value()
        {
            var assertion = new RedirectAssertion("/to", false);

            AssertionRunner
            .Run(assertion, x => x.Response.As <StubHttpResponse>().Redirect("/to", true))
            .SingleMessageShouldBe("Expected permanent redirect to be 'False' but it was not.");
        }
示例#12
0
        public void sad_path_wrong_value()
        {
            var assertion = new RedirectAssertion("/to", false);

            AssertionRunner
            .Run(assertion, x => x.Response.As <StubHttpResponse>().Redirect("/wrong"))
            .SingleMessageShouldBe("Expected to be redirected to '/to' but was '/wrong'.");
        }
示例#13
0
        public void sad_path_no_value()
        {
            var assertion = new RedirectAssertion("/to", false);

            AssertionRunner
            .Run(assertion, x => { })
            .SingleMessageShouldBe("Expected to be redirected to '/to' but was ''.");
        }
示例#14
0
 public void sad_path_too_many_values()
 {
     AssertionRunner.Run(_assertion, x =>
     {
         x.Response.Headers.Append("foo", "baz");
         x.Response.Headers.Append("foo", "bar");
     })
     .SingleMessageShouldBe("Expected a single header value of 'foo' matching '^b.?r$', but the actual values were 'baz', 'bar'");
 }
        public void happy_path_single_value()
        {
            var headers   = new[] { "one" };
            var assertion = new HeaderMultiValueAssertion("foo", headers);

            AssertionRunner.Run(
                assertion,
                x => x.Response.Headers.Append("foo", new StringValues(headers)))
            .AssertAll();
        }
示例#16
0
        public void sad_path_too_many_values()
        {
            var assertion = new HasSingleHeaderValueAssertion("foo");

            AssertionRunner.Run(assertion, x =>
            {
                x.Response.Headers.Append("foo", "baz");
                x.Response.Headers.Append("foo", "bar");
            })
            .SingleMessageShouldBe("Expected a single header value of 'foo', but found multiple values on the response: 'baz', 'bar'");
        }
        public void sad_path_wrong_value()
        {
            var expected  = new[] { "one", "two" };
            var actual    = new[] { "three", "four" };
            var assertion = new HeaderMultiValueAssertion("foo", expected);

            AssertionRunner.Run(
                assertion,
                x => x.Response.Headers.Append("foo", new StringValues(actual)))
            .SingleMessageShouldBe("Expected header values of 'foo'='one', 'two', but the actual values were 'three', 'four'.");
        }
示例#18
0
        public void sad_path_any_values()
        {
            var assertion = new NoHeaderValueAssertion("foo");

            AssertionRunner.Run(assertion, x =>
            {
                x.Response.Headers.Append("foo", "baz");
                x.Response.Headers.Append("foo", "bar");
            })
            .SingleMessageShouldBe("Expected no value for header 'foo', but found values 'baz', 'bar'");
        }
示例#19
0
        public void sad_path_too_many_values()
        {
            var assertion = new HeaderValueAssertion("foo", "bar");

            AssertionRunner.Run(assertion, x =>
            {
                x.Response.Headers.Append("foo", "baz");
                x.Response.Headers.Append("foo", "bar");
            })
            .SingleMessageShouldBe("Expected a single header value of 'foo'='bar', but the actual values were 'baz', 'bar'");
        }
示例#20
0
 public void sad_path_wrong_value()
 {
     AssertionRunner.Run(_assertion, x => x.Response.Headers["foo"] = "baz")
     .SingleMessageShouldBe("Expected a single header value of 'foo' matching '^b.?r$', but the actual value was 'baz'");
 }
示例#21
0
 public void sad_path_no_values()
 {
     AssertionRunner.Run(_assertion, e => { })
     .SingleMessageShouldBe("Expected a single header value of 'foo' matching '^b.?r$', but no values were found on the response");
 }
示例#22
0
 public void happy_path()
 {
     AssertionRunner.Run(_assertion, x => x.Response.Headers["foo"] = "bar")
     .AssertAll();
 }
示例#23
0
 public void happy_path()
 {
     AssertionRunner.Run(new BodyTextAssertion("Hey!"), env => env.Response.Write("Hey!"))
     .AssertAll();
 }
示例#24
0
        public void happy_path()
        {
            var assertion = new NoHeaderValueAssertion("foo");

            AssertionRunner.Run(assertion, e => {}).AssertAll();
        }
 public void happy_path()
 {
     AssertionRunner.Run(new BodyDoesNotContainAssertion("Hey!"), env => env.Response.Write("You!"))
     .AssertAll();
 }