public void SearchMatchesShouldRenderCorrectPartialViewWhenPageIsNull() { var validPartialView = "_MatchesPartial"; this.matchesController .WithCallTo(x => x.SearchMatches(TestObjectFactoryViewModels.GetValidMatchesSearchViewModel(), null)) .ShouldRenderPartialView(validPartialView) .WithModel <MatchesSearchResultViewModel>() .AndNoModelErrors(); }
public void SearchMatchesShouldMapCorrectActionWhenPageIsNull() { var actionName = "SearchMatches"; var matchesSearchViewModel = TestObjectFactoryViewModels.GetValidMatchesSearchViewModel(); string jsonContent = JsonConvert.SerializeObject(matchesSearchViewModel); routeCollection.ShouldMap(ValidUrl + actionName) .WithJsonBody(jsonContent) .To <MatchesController>(x => x.SearchMatches(matchesSearchViewModel, null)); }
public void SearchMatchesShouldThrowExceptionWhenPageNumberIsNegative() { var actionName = "SearchMatches"; var matchesSearchViewModel = TestObjectFactoryViewModels.GetValidMatchesSearchViewModel(); var negativePageNumber = -1; string jsonContent = JsonConvert.SerializeObject(matchesSearchViewModel); routeCollection.ShouldMap(ValidUrl + actionName + "?page=" + negativePageNumber) .WithJsonBody(jsonContent) .To <MatchesController>(x => x.SearchMatches(matchesSearchViewModel, negativePageNumber)); }
public void SearchMatchesShouldThrowExceptionWhenExpectedPartialViewIsInvalid() { var validPage = 1; var invalidExpectedPartialView = "_Matches"; Assert.Throws( typeof(ActionResultAssertionException), () => this.matchesController .WithCallTo(x => x.SearchMatches(TestObjectFactoryViewModels.GetValidMatchesSearchViewModel(), validPage)) .ShouldRenderPartialView(invalidExpectedPartialView) .WithModel <MatchesSearchResultViewModel>() .AndNoModelErrors()); }
public void SearchMatchesShouldThrowExceptionWhenPageNumberIsInvalid() { var invalidPage = -1; var validPartialView = "_MatchesPartial"; Assert.Throws( typeof(ArgumentOutOfRangeException), () => this.matchesController .WithCallTo(x => x.SearchMatches(TestObjectFactoryViewModels.GetValidMatchesSearchViewModel(), invalidPage)) .ShouldRenderPartialView(validPartialView) .WithModel <MatchesSearchResultViewModel>() .AndNoModelErrors()); }
public void SearchMatchesShouldThrowExceptionWhenPageNumbersDoNotMatch() { var actionName = "SearchMatches"; var matchesSearchViewModel = TestObjectFactoryViewModels.GetValidMatchesSearchViewModel(); var firstPageNumber = 1; var secondPageNumber = 2; string jsonContent = JsonConvert.SerializeObject(matchesSearchViewModel); Assert.Throws( typeof(MvcRouteTester.Assertions.AssertionException), () => routeCollection.ShouldMap(ValidUrl + actionName + "?page=" + firstPageNumber) .WithJsonBody(jsonContent) .To <MatchesController>(x => x.SearchMatches(matchesSearchViewModel, secondPageNumber))); }