public void DetailsTest() { // Arrange GenresController controller = new GenresController(); // Act var result = controller.Details(1); // Assert Assert.IsNotNull(result); }
public void DetailInValidId() { //Arrange FakeGenreBL fake = new FakeGenreBL(); GenresController controller = new GenresController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act ViewResult result = controller.Details(300) as ViewResult; // Assert Assert.AreEqual("Error", result.ViewName); }
public void DetailNull() { //Arrange FakeNullGenre fake = new FakeNullGenre(); GenresController controller = new GenresController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act ViewResult result = controller.Details(3) as ViewResult; // Assert //Assert.AreEqual("", result.ViewName); Assert.IsNotNull(result.ViewName); }
public void Edit_ReturnNotFound_WhenIdIsNull() { var options = new DbContextOptionsBuilder <GameDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new GameDbContext(options); var controller = new GenresController(context); var result = (NotFoundResult)controller.Details(null).Result; var contentResult = Assert.IsType <NotFoundResult>(result); Assert.Equal(result.StatusCode, contentResult.StatusCode); }