public void IndexReturnsRentals()
        {
            //act //
            var result = (List <Rental>)((ViewResult)controller.Index()).Model;

            //assert//
            CollectionAssert.AreEqual(rentals, result);
        }
        public void IndexLoadsView()
        {
            //arrange//
            RentalsController controller = new RentalsController();

            //act//
            ViewResult result = controller.Index() as ViewResult;

            //assert//
            Assert.AreEqual("Index", result.ViewName);
        }
Example #3
0
        public void Index()
        {
            // Arrange
            RentalsController controller = new RentalsController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Example #4
0
        public async Task IndexOnGet_WhenEntitiesExist_ReturnsViewResult()
        {
            //Arrange
            TestDbSeeder.Initialize(_db);
            TestDbSeeder.SeedBooks(_db);
            TestDbSeeder.SeedRentals(_db);

            //Act
            var result = await _controller.Index();

            //Assert
            var books = await _db.Books.Include(b => b.Rentals).ToListAsync();

            Assert.NotNull(books);
            Assert.Equal(TestDbSeeder.Books.Length, books.Count);

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <IEnumerable <BookViewModel> >(viewResult.Model);

            Assert.Equal(books.Count, model.Count());
        }