public void CreateNewOrganizationPostReturnsBadRequestForNullOrganization() { //arrange OrganizationEditModel viewmodel = null; var sut = new OrganizationController(MockMediatorCreateOrganization().Object); //act var result = sut.Create(viewmodel); //assert Assert.IsType<BadRequestResult>(result); }
public void CreateNewOrganizationInvalidModelReturnsCreateView() { //arrange var sut = new OrganizationController(MockMediatorCreateOrganization().Object); sut.ModelState.AddModelError("foo", "bar"); //act var result = sut.Create(_stubViewModel); //assert Assert.IsType<ViewResult>(result); Assert.Equal("Create", ((ViewResult) result).ViewName); }
public void CreateNewOrganizationRedirectsToOrganizationList() { //arrange var sut = new OrganizationController(MockMediatorCreateOrganization().Object); var expectedRouteValues = new {controller = "Organization", action = "Index"}; //act var result = sut.Create(_stubViewModel); //assert Assert.IsType<RedirectToRouteResult>(result); Assert.Equal("areaRoute", ((RedirectToRouteResult) result).RouteName); Assert.Equal("Organization", ((RedirectToRouteResult)result).RouteValues["controller"]); Assert.Equal("Index",((RedirectToRouteResult)result).RouteValues["action"]); }
public void CreateReturnsCorrectView() { var sut = new OrganizationController(null, null); var result = (ViewResult)sut.Create(); Assert.Equal("Edit", result.ViewName); }