public void DisplayFoodLogEntryWhenNullDetailsTest() { var foodLogRepoMock = new StubIFoodLogEntryRepository { GetNullableOfInt32 = (id) => null }; var controller = new FoodLogEntriesController(foodLogRepoMock); var result = controller.Details(32) as HttpNotFoundResult; // making sure not found happens when food log repo returns back null Assert.AreEqual(404, result.StatusCode); }
public void DisplayFoodLogEntryDetailsTest() { var foodLogRepoMock = new StubIFoodLogEntryRepository { GetNullableOfInt32 = (id) => new FoodLogEntry { Id = (int)id, Description = "Donut" } }; var controller = new FoodLogEntriesController(foodLogRepoMock); var result = controller.Details(32) as ViewResult; var viewModel = result.Model as FoodLogEntry; Assert.AreEqual("Donut", viewModel.Description); }