public void LogOnWithValidUserTest() { // Arrange UserController target = new UserController(); var mock = new ContextMocks(target); // Act // We use the password in string format since our TestDatabaseHelper uses the encrypted value var actualResult = target.LogOn(user1.username, "*****@*****.**") as RedirectToRouteResult; var actualResultURI = actualResult.RouteValues["controller"] + "/" + actualResult.RouteValues["action"]; // Assertions Assert.AreEqual("Home/Index", actualResultURI); }
public Session(touch_for_foodEntities database, Controller target) { db = database; controller = target; ContextMocks mock = new ContextMocks(controller); }
public void CreateUserTest() { // Arrange db = new touch_for_foodEntities(); UserController target = new UserController(); var mock = new ContextMocks(target); int expectedUsers = db.users.ToList<user>().Count(); // Act var actualResult = target.Create(user2) as RedirectToRouteResult; var actualResultURI = actualResult.RouteValues["controller"] + "/" + actualResult.RouteValues["action"]; // Assertions db = new touch_for_foodEntities(); int actualUsers = db.users.ToList<user>().Count(); Assert.AreEqual((expectedUsers + 1), actualUsers); Assert.IsNotNull(actualResult, "Result obtained from actual result is null"); Assert.AreEqual("Home/Index", actualResultURI); }