コード例 #1
0
        public async Task ShouldCreateEntry()
        {
            var mapPoint = new MapPoint("Test Point 1", -43.45554434, -110.04886744);

            using (var context = _contextFactory.CreateDbContext())
            {
                var mapRepository = new MapPointRepository(context);

                await mapRepository.AddAsync(mapPoint);

                await mapRepository.SaveChangesAsync();

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

            using (var context = _contextFactory.CreateDbContext())
            {
                var mapRepository = new MapPointRepository(context);

                var fetchedMapPoint = await mapRepository.GetByIdAsync(mapPoint.Id);

                Assert.Equal(mapPoint.Name, fetchedMapPoint.Name);
                Assert.Equal(mapPoint.Latitude, fetchedMapPoint.Latitude);
                Assert.Equal(mapPoint.Longitude, fetchedMapPoint.Longitude);

                _mapPointId = fetchedMapPoint.Id;
            }
        }
コード例 #2
0
        public RouteRepositoryTests()
        {
            _contextFactory = new ContextFactory <XptoContext>();

            using (var context = _contextFactory.CreateDbContext())
            {
                var mapPointRepository = new MapPointRepository(context);

                var mapPoint1 = new MapPoint("Test Point 1", -43.45554434, -110.04886744);
                var mapPoint2 = new MapPoint("Test Point 2", -43.45559877, -110.03486744);
                var mapPoint3 = new MapPoint("Test Point 3", -43.44599434, -110.12880004);

                var addPointTask1 = mapPointRepository.AddAsync(mapPoint1);
                var addPointTask2 = mapPointRepository.AddAsync(mapPoint1);
                var addPointTask3 = mapPointRepository.AddAsync(mapPoint1);
                Task.WaitAll(addPointTask1, addPointTask2, addPointTask3);
                Task.WaitAll(mapPointRepository.SaveChangesAsync());

                _mapPoint1Id = mapPoint1.Id;
                _mapPoint2Id = mapPoint2.Id;
                _mapPoint3Id = mapPoint3.Id;
            }
        }