public void Logout()
        {
            var userRepository = new UserRepositoryMock().GetUserRepoMockedInstance();
            var authProvider   = new Mock <FormsAuthProvider>();

            authProvider.Setup(m => m.SignOut());
            var accountController = new AccountController(authProvider.Object, userRepository)
            {
                ControllerContext = FakeControllerContext.GetContextWithMockedSession()
            };

            var result = accountController.LogOut();

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
        }
Exemplo n.º 2
0
        public void EditWithNoImage()
        {
            var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance();
            var fishController = new FishController(fishRepository)
            {
                ControllerContext = FakeControllerContext.GetContextWithMockedSession()
            };

            var fish = new Fish {
                FishId = 1, UserId = 1, Name = "Lüfer", Price = 15.90, ImageData = Encoding.UTF8.GetBytes("LüferFoto"), ImageMimeType = "image/png"
            };
            var result = fishController.Edit(fish, null);

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
        }
Exemplo n.º 3
0
        public void IndexListAllFishes()
        {
            var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance();
            var fishController = new FishController(fishRepository)
            {
                ControllerContext = FakeControllerContext.GetContextWithMockedSession()
            };

            var result = fishController.Index();

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            var model = (FishListViewModel)((ViewResult)result).Model;

            Assert.AreEqual(3, model.Fishes.Count());
            Assert.AreEqual("Lüfer", model.Fishes.ElementAt(0).Name);
            Assert.AreEqual("Palamut", model.Fishes.ElementAt(2).Name);
        }
        public void LoginSuccess()
        {
            var model = new LoginViewModel {
                Email = "*****@*****.**", Password = "******"
            };
            var userRepository = new UserRepositoryMock().GetUserRepoMockedInstance();
            var authProvider   = new Mock <FormsAuthProvider>();

            authProvider.Setup(m => m.Authenticate(model.Email, model.Password)).Returns(true);
            var accountController = new AccountController(authProvider.Object, userRepository)
            {
                ControllerContext = FakeControllerContext.GetContextWithMockedSession()
            };

            var result = accountController.Login(model, "/Fish/Index");

            Assert.IsInstanceOfType(result, typeof(RedirectResult));
        }