[InlineData("881bf243-d34d-49cb-b22b-cc3cd7a0fac5", 19, false, false)] // Unsuccessful Leave (User does not have security level 1) public void TestLeaveGroup(string userAspId, int groupId, bool userIsSecLevel1, bool expectingSuccess) { var controllerContextMock = new Mock <ControllerContext>() { CallBase = true }; var contextMock = new Mock <ApplicationDbContext>() { CallBase = true }; contextMock.Setup(c => c.SaveChanges()).Returns(1); controllerContextMock.Setup(c => c.HttpContext.User.IsInRole("SecurityLevel1")).Returns(userIsSecLevel1); var controller = new GroupsController { ControllerContext = controllerContextMock.Object, Context = contextMock.Object, GetUserId = () => userAspId }; var result = controller.Leave(groupId); if (expectingSuccess) { Assert.True(result is RedirectToRouteResult); } else { Assert.True(result is HttpNotFoundResult); } }