Exemple #1
0
        public void GetNoImage()
        {
            var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance();
            var fishController = new FishController(fishRepository);
            var result         = fishController.GetImage(1231231);

            Assert.AreEqual(null, result);
        }
Exemple #2
0
        public void GetImage()
        {
            var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance();
            var fishController = new FishController(fishRepository);
            var result         = fishController.GetImage(1);

            Assert.AreNotEqual(null, (FileContentResult)result);
        }
Exemple #3
0
        public void RemoveImage()
        {
            var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance();
            var fishController = new FishController(fishRepository);
            var result         = fishController.RemoveImage(1);
            var model          = (Fish)((ViewResult)result).Model;

            Assert.AreEqual(null, model.ImageData);
        }
Exemple #4
0
        public void Edit()
        {
            var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance();
            var fishController = new FishController(fishRepository);
            var result         = fishController.Edit(1);
            var model          = (Fish)result.Model;

            Assert.AreEqual(1, model.FishId);
            Assert.AreEqual("Lüfer", model.Name);
            Assert.AreEqual(15.90, model.Price);
        }
Exemple #5
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));
        }
Exemple #6
0
        public void IndexListNothing()
        {
            var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance();
            var fishController = new FishController(fishRepository)
            {
                ControllerContext = FakeControllerContext.GetContextWithMockedNullSession()
            };

            var result = fishController.Index();

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

            Assert.AreEqual(null, model.Fishes);
        }
Exemple #7
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);
        }