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

            AssertionRunner.Run(assertion, _ => _.StatusCode(304))
            .AssertAll();
        }
Example #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");
        }
Example #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");
        }
Example #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'");
        }
Example #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!'");
        }
Example #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");
        }
Example #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.");
        }
Example #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();
        }
Example #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.");
        }
Example #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'.");
        }
Example #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 ''.");
        }
Example #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();
        }
Example #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'.");
        }
        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'");
        }
Example #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'");
        }
Example #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'");
 }
Example #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");
 }
Example #22
0
 public void happy_path()
 {
     AssertionRunner.Run(_assertion, x => x.Response.Headers["foo"] = "bar")
     .AssertAll();
 }
Example #23
0
 public void happy_path()
 {
     AssertionRunner.Run(new BodyTextAssertion("Hey!"), env => env.Response.Write("Hey!"))
     .AssertAll();
 }
        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();
 }