Exemplo n.º 1
0
        public void GetAllLocationNamesShould_ReturnAllNames()
        {
            var options = new DbContextOptionsBuilder <CarRentalDbContext>()
                          .UseInMemoryDatabase(databaseName: "CarRental_Database_AllLocationNames")
                          .Options;
            var dbContext = new CarRentalDbContext(options);

            var locationsService = new LocationsService(dbContext);

            var locationList = new List <Location>()
            {
                new Location
                {
                    Name = locationNameOne
                },
                new Location
                {
                    Name = locationNameTwo
                },
                new Location
                {
                    Name = locationNameThree
                },
            };

            dbContext.Locations.AddRange(locationList);
            dbContext.SaveChanges();

            var expected = new List <string> {
                locationNameOne, locationNameTwo, locationNameThree
            };
            var result = locationsService.GetAllLocationNames().ToList();

            Assert.Equal(expected, result);
        }