public void ItShouldReturnCorrectView() { var recipe = new Recipe { Id = 2, Author = new Author(), AuthorId = 1, CreatedOnUtc = DateTime.Now, Description = "d", Image = new Image(), ImageId = 1, Ingredients = new List <Ingredient>(), MealType = new MealType(), MealTypeId = 2, ModifiedOnUtc = DateTime.Now, Title = "d" }; _recipeRepositoryMock.Setup(r => r.GetById(2)).Returns(recipe).Verifiable(); var result = _controller.Details(2) as ViewResult; Assert.Equal("Details", result.ViewName); }
public async Task Details_Bad_Id() { var controller = new RecipesController(_service.Object); var result = await controller.Details(Guid.NewGuid()); Assert.IsType <NotFoundResult>(result); }
public async Task Details() { var controller = new RecipesController(_service.Object); var result = await controller.Details(_recipe.Id); var okObjectResult = Assert.IsType <OkObjectResult>(result); var model = Assert.IsAssignableFrom <Recipe>(okObjectResult.Value); Assert.Equal(_recipe.Id, model.Id); }
public void Details() { var mock = new Mock <IDbContext>(); mock.Setup(x => x.Set <Recipe>()) .Returns(new FakeDbSet <Recipe> { new Recipe { RecipeId = 1, Name = "Zupa pomidorowa", Description = "asfagaghahahadh", Difficulty = DifficultyEnum.easy, PublishDate = DateTime.Now } }); var controller = new RecipesController(mock.Object); var result = controller.Details(1) as ViewResult; Assert.AreEqual("Details", result.ViewName); }