예제 #1
0
        public void BeContent_GivenContent_ShouldPass()
        {
            ActionResult result = new ContentResult();

            result.Should()
            .BeContentResult();
        }
예제 #2
0
        public void WithContentEncoding_GivenExpected_ShouldPass()
        {
            ActionResult result = new ContentResult {
                ContentEncoding = Encoding.ASCII
            };

            result.Should().BeContentResult().WithContentEncoding(Encoding.ASCII);
        }
예제 #3
0
        public void WithContentType_GivenExpected_ShouldPass()
        {
            ActionResult result = new ContentResult {
                ContentType = "text/html"
            };

            result.Should().BeContentResult().WithContentType("text/html");
        }
예제 #4
0
        public void WithContent_GivenExpected_ShouldPass()
        {
            ActionResult result = new ContentResult {
                Content = "content"
            };

            result.Should().BeContentResult().WithContent("content");
        }
예제 #5
0
        public void WithContentEncoding_GivenUnexpected_ShouldFail()
        {
            var          actualEncoding   = Encoding.ASCII;
            var          expectedEncoding = Encoding.Unicode;
            ActionResult result           = new ContentResult {
                ContentEncoding = actualEncoding
            };
            var failureMessage = String.Format(FailureMessages.CommonFailMessage, "ContentResult.ContentEncoding", expectedEncoding, actualEncoding);

            Action a = () => result.Should().BeContentResult().WithContentEncoding(expectedEncoding);

            a.ShouldThrow <Exception>()
            .WithMessage(failureMessage);
        }
예제 #6
0
        public void WithContentType_GivenUnexpected_ShouldFail()
        {
            var          actualContentType   = "text/html";
            var          expectedContentType = "xyz";
            ActionResult result = new ContentResult {
                ContentType = actualContentType
            };
            var failureMessage = String.Format(FailureMessages.CommonFailMessage, "ContentResult.ContentType", expectedContentType, actualContentType);

            Action a = () => result.Should().BeContentResult().WithContentType(expectedContentType);

            a.ShouldThrow <Exception>()
            .WithMessage(failureMessage);
        }
        public void WithContentType_GivenUnexpected_ShouldFail()
        {
            var          actualContentType   = "text/html";
            var          expectedContentType = "xyz";
            ActionResult result = new ContentResult {
                ContentType = actualContentType
            };
            var failureMessage = FailureMessageHelper.ExpectedContextToBeXButY("ContentResult.ContentType", expectedContentType, actualContentType);

            Action a = () => result.Should().BeContentResult().WithContentType(expectedContentType, Reason, ReasonArgs);

            a.Should().Throw <Exception>()
            .WithMessage(failureMessage);
        }
예제 #8
0
        public void WithContent_GivenUnexpected_ShouldFail()
        {
            var          actualContent   = "content";
            var          expectedContent = "xyz";
            ActionResult result          = new ContentResult {
                Content = actualContent
            };
            var failureMessage = String.Format(FailureMessages.CommonFailMessage, "ContentResult.Content", expectedContent, actualContent);

            Action a = () => result.Should().BeContentResult().WithContent(expectedContent);

            a.Should().Throw <Exception>()
            .WithMessage(failureMessage);
        }
예제 #9
0
        public void WithContentResult_ShouldFail()
        {
            ActionResult result = new ContentResult {
                Content = "{ \"name\" : \"WithJson_GivenExpected_ShouldPass\" }"
            };

            // this is a bit of a hack to build the expected message.  There must be a better way?
            var messageFormat = ActionResultAssertions.Constants.CommonFailMessage
                                .Replace("{reason}", "")
                                .Replace("{", "\"{")
                                .Replace("}", "}\"");
            var failureMessage = String.Format(messageFormat, typeof(JsonResult).Name, result.GetType().Name);

            System.Action act = () => result.Should().BeJsonResult();

            act.Should().Throw <System.Exception>().WithMessage(failureMessage);
        }
예제 #10
0
        private void ThenTemplateContentMatches(IActionResult result, string expectedResponse)
        {
            ContentResult contentResult = result as ContentResult;

            contentResult
            .Should()
            .NotBeNull();

            contentResult
            .Content
            .Should()
            .Be(expectedResponse);

            contentResult
            .ContentType
            .Should()
            .Be("application/json");
        }
 public void BeContent_GivenContent_ShouldPass()
 {
     ActionResult result = new ContentResult();
     result.Should()
             .BeContentResult();
 }