Beispiel #1
0
        public void GetRoadsShouldReturnAllRoads()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "GetRoads_Roads_Database")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var roadsService = new RoadsService(dbContext, null, null, null, null, null);

            var roads = new List <Road> {
                new Road {
                    RoadName = "Road1"
                }, new Road {
                    RoadName = "Road2"
                }, new Road {
                    RoadName = "Road3"
                }
            };

            dbContext.Roads.AddRange(roads);
            dbContext.SaveChanges();

            var returnCollection = roadsService.GetRoads();

            Assert.Equal(returnCollection.Count, roads.Count);
        }
Beispiel #2
0
 public async Task <ActionResult <IEnumerable <Road> > > GetRoads()
 {
     return(await _roadsService.GetRoads());
 }