Esempio n. 1
0
        public void Account_WhenUserNoAuthorized_ActionResult()
        {
            Mock <IUserRepository> mockUser   = new Mock <IUserRepository>();
            HomeController         controller = new HomeController(mockUser.Object);

            var actual = controller.Account("");

            Assert.IsInstanceOfType(actual, typeof(ActionResult));
        }
Esempio n. 2
0
        public void Account_WhenUserAuthorized_ActionResult()
        {
            Mock <IUserRepository> mockUser = new Mock <IUserRepository>();

            mockUser.Setup(m => m.Users).Returns(new User[]
            {
                new User {
                    UserName = "******", Password = Crypto.Hash("123456789"), EmailID = "*****@*****.**", DateOfBirth = DateTime.Now.AddYears(-20), Gender = "Male", IsEmailVerified = true
                }
            }.AsQueryable());
            HomeController controller = new HomeController(mockUser.Object);

            var actual = controller.Account("*****@*****.**");

            Assert.IsInstanceOfType(actual, typeof(ActionResult));
        }
Esempio n. 3
0
        public void Account_View_Result_Two()
        {
            // Setup
            var expectedUserAccountId = 456;

            var mockUserAccountService = new Mock <IUserAccountService>();

            mockUserAccountService.Setup(x => x.Get(expectedUserAccountId))
            .Returns(GetTestUserAccountTwo());

            // Inject
            var homeController = new HomeController(mockUserAccountService.Object);

            // Act
            var result = homeController.Account(expectedUserAccountId);

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);

            var viewModel = Assert.IsAssignableFrom <UserAccountViewModel>(
                viewResult.ViewData.Model);

            Assert.Equal(expectedUserAccountId, viewModel.Id);
        }