public void GetNoImage() { var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance(); var fishController = new FishController(fishRepository); var result = fishController.GetImage(1231231); Assert.AreEqual(null, result); }
public void GetImage() { var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance(); var fishController = new FishController(fishRepository); var result = fishController.GetImage(1); Assert.AreNotEqual(null, (FileContentResult)result); }
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); }
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); }
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)); }
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); }
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); }