public void GetGenres_BLLReturnsSomeData() { // Arrange _mockGenre.Setup(a => a.GetAll(false)).Returns(new List <GenreDTO>()).Verifiable(); // Act var res = _controller.Index(); // Assert Assert.AreEqual(res.GetType(), typeof(ViewResult)); }
public void IndexTest() { // Arrange GenresController controller = new GenresController(); // Act var result = controller.Index(); // Assert Assert.IsNotNull(result); }
public void IndexTest() { //Arrange FakeGenreBL fake = new FakeGenreBL(); GenresController controller = new GenresController(fake); controller.testCase = true; //Act ViewResult result = controller.Index() as ViewResult; //Assert Assert.AreEqual(result.ViewName, "Index"); }
public void Index_ReturnAViewResult_WithAListOfGenres() { var options = new DbContextOptionsBuilder <GameDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new GameDbContext(options); SeedData(context); var controller = new GenresController(context); var result = (ViewResult)controller.Index().Result; var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <IEnumerable <Genre> >( viewResult.ViewData.Model); Assert.Equal(3, model.Count()); }
public void IndexTest() { var mockContext = new Mock <MusicContext>(); // Populate Customers "table" var genreDbSet = Genres.GetQueryableMockDbSet(); foreach (var Genre in Genres) { genreDbSet.Add(Genre); } mockContext.Setup(context => context.Genres).Returns(genreDbSet); var dbContext = mockContext.Object; //var mockRepository = new Mock<IAlbumRepository>(); //mockRepository.Setup(e => e.GetAll()).Returns(dbContext.Albums); //var AlbumRepository = mockRepository.Object; GenresController controller = new GenresController(dbContext); // Act ViewResult result = controller.Index() as ViewResult; var model = (List <Genre>)result.ViewData.Model; // Act // Assert Assert.IsNotNull(result); Assert.IsTrue(model.Count() == 20); }