public void BeContent_GivenContent_ShouldPass() { ActionResult result = new ContentResult(); result.Should() .BeContentResult(); }
public void WithContentEncoding_GivenExpected_ShouldPass() { ActionResult result = new ContentResult { ContentEncoding = Encoding.ASCII }; result.Should().BeContentResult().WithContentEncoding(Encoding.ASCII); }
public void WithContentType_GivenExpected_ShouldPass() { ActionResult result = new ContentResult { ContentType = "text/html" }; result.Should().BeContentResult().WithContentType("text/html"); }
public void WithContent_GivenExpected_ShouldPass() { ActionResult result = new ContentResult { Content = "content" }; result.Should().BeContentResult().WithContent("content"); }
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); }
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); }
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); }
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); }
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(); }