示例#1
0
        public void TestSwitchingOfUsers()
        {
            var user1 = UserMock.CreateUser("First User");
            var user2 = UserMock.CreateUser("Second User(Admin)");

            user1.DoAction((u) =>
            {
                Assert.AreEqual("First User", u.Identity.Name);
            });

            user2.DoAction((u) =>
            {
                Assert.AreEqual("Second User(Admin)", u.Identity.Name);
            });
        }
示例#2
0
        public void SecureArea()
        {
            // Arrange
            HomeController controller = new HomeController();
            var            user       = UserMock.CreateUser("Kevin");

            // Act
            user.DoAction((u) =>
            {
                ViewResult result = controller.SecureArea() as ViewResult;

                // Assert
                Assert.AreEqual("Kevin", result.ViewBag.UserName);
            });
        }
示例#3
0
 public void CreateUserShouldThrowAnErrorIfNoNameIsPassed()
 {
     UserMock.CreateUser(null);
 }
示例#4
0
 public void CreateUserShouldNotReturnNullEvenWithBlankName()
 {
     Assert.IsNotNull(UserMock.CreateUser(""));
 }
示例#5
0
 public void CreateUserShouldNotReturnNull()
 {
     Assert.IsNotNull(UserMock.CreateUser("Test name"));
 }