Exemplo n.º 1
0
        public void IsExistsReturnsFalseWhenRouteDoesNotExist()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new EfDeletableEntityRepository <Route>(new ApplicationDbContext(options.Options));

            repository.AddAsync(new Route {
                StartPoint = "София", EndPoint = "Пловдив", Distance = 225
            });
            repository.AddAsync(new Route {
                StartPoint = "София", EndPoint = "Хасково", Distance = 267
            });
            repository.SaveChangesAsync();
            var routesService = new RoutesService(repository);

            var exists = routesService.IsExists("Стара Загора", "София");

            Assert.False(exists);
        }
Exemplo n.º 2
0
        public void IsExistsReturnsTrueWhenRouteExists()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository = new EfDeletableEntityRepository <Route>(new ApplicationDbContext(options.Options));

            repository.AddAsync(new Route {
                StartPoint = "София", EndPoint = "Пловдив", Distance = 225
            });
            repository.AddAsync(new Route {
                StartPoint = "София", EndPoint = "Хасково", Distance = 267
            });
            repository.SaveChangesAsync();
            var routesService = new RoutesService(repository);

            var route  = repository.AllAsNoTracking().FirstOrDefault(r => r.StartPoint == "София" && r.EndPoint == "Пловдив");
            var exists = routesService.IsExists(route.StartPoint, route.EndPoint);

            Assert.True(exists);
        }