示例#1
0
        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);
        }
示例#2
0
文件: Session.cs 项目: pmoda/TFFCode
 public Session(touch_for_foodEntities database, Controller target)
 {
     db = database;
     controller = target;
     ContextMocks mock = new ContextMocks(controller);
 }
示例#3
0
        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);
        }