public void ExpenseGroupCreate() { ExpenseGroupVM ap = new ExpenseGroupVM() { Name = "Test" }; var result = (RedirectToRouteResult)_SystemUnderTest.CreateGroup(ap); //Assert Assert.AreEqual(true, _SystemUnderTest.ModelState.IsValid); _groupServiceMock.Verify(m => m.Create(It.IsAny <ExpenseGroup>()), Times.Once); }
public ActionResult CreateGroup(ExpenseGroupVM data) { if (!ModelState.IsValid) { return(View("AddGroup", data)); } var groupItem = new ExpenseGroup { Name = data.Name }; _groupService.Create(groupItem); return(RedirectToAction("Index")); }
public void InvalidGroupCreate() { //Arrange ExpenseGroupVM group = new ExpenseGroupVM() { Name = "Test" }; _SystemUnderTest.ModelState.AddModelError("Error", "Something went wrong"); //Act var result = (ViewResult)_SystemUnderTest.CreateGroup(group); //Assert Assert.AreEqual(false, _SystemUnderTest.ModelState.IsValid); _groupServiceMock.Verify(m => m.Create(It.IsAny <ExpenseGroup>()), Times.Never); Assert.AreEqual("AddGroup", result.ViewName); }