public void AppController_ValidateEmptyTweet_ShouldThrowBadRequest() { var tweet = new Tweet(); var checker = Substitute.For<IVerbotenChecker>(); var controller = BuildController(checker); var ex = Assert.Catch<HttpResponseException>(() => controller.Post(tweet)); ex.Response.StatusCode.ShouldBe(HttpStatusCode.BadRequest); }
public void AppController_ValidateTweetWithGoodText_ShouldHaveResponseWithTruePassed() { var tweet = new Tweet() { Text = "test" }; var checker = Substitute.For<IVerbotenChecker>(); checker.ValidateText(Arg.Any<string>()) .ReturnsForAnyArgs(VerbotenCheckerResponse.GetHappyEmptyResponse()); var controller = BuildController(checker); var response = controller.Post(tweet); response.VerbotenCheckPassed.ShouldBe(true); }
public void AppController_ValidateTweetWithBadText_ShouldHaveResponseWithFalsePassed() { var tweet = new Tweet() { Text = "test" }; var checker = Substitute.For<IVerbotenChecker>(); var failedResponse = VerbotenCheckerResponse.GetHappyEmptyResponse(); failedResponse.FailItAndAddViolation("violation"); checker.ValidateText(Arg.Any<string>()) .ReturnsForAnyArgs(failedResponse); var controller = BuildController(checker); var response = controller.Post(tweet); response.VerbotenCheckPassed.ShouldBe(false); response.Violations[0].ShouldBe("violation"); }