示例#1
0
        public async Task ShouldCreateEntry()
        {
            var route = new Route(_mapPoint1Id, _mapPoint2Id, 10, 10);

            using (var context = _contextFactory.CreateDbContext())
            {
                var routeRepository = new RouteRepository(context);

                await routeRepository.AddAsync(route);

                await routeRepository.SaveChangesAsync();

                Assert.NotEqual(Guid.Empty, route.Id);
            }

            using (var context = _contextFactory.CreateDbContext())
            {
                var routeRepository = new RouteRepository(context);

                var fetchedRoute = await routeRepository.GetByIdAsync(route.Id);

                Assert.Equal(route.FromId, fetchedRoute.FromId);
                Assert.Equal(route.ToId, fetchedRoute.ToId);

                _routeId = fetchedRoute.Id;
            }
        }
示例#2
0
        public async Task ShouldDeleteEntry()
        {
            using (var context = _contextFactory.CreateDbContext())
            {
                var routeRepository = new RouteRepository(context);

                await routeRepository.DeleteByAsync(mp => mp.Id.Equals(_routeId));

                await routeRepository.SaveChangesAsync();
            }

            using (var context = _contextFactory.CreateDbContext())
            {
                var routeRepository = new RouteRepository(context);

                var route = await routeRepository.GetByIdAsync(_routeId);

                Assert.Null(route);
            }
        }