public void TravelDateRepositoryOperations()
        {
            IDataAccessor dataAccessor = new DataAccessor(false, "Data Source=TravelDateRepositoryTest.db");

            using (var dbContext = dataAccessor.GetNewDatabaseContext())
            {
                dbContext.Database.EnsureDeleted();
                dbContext.Database.EnsureCreated();
            }
            ITravelDateRepository travelDateRepository = new TravelDateRepository(dataAccessor);

            travelDateRepository.Add("Oda", new DateTime(2020, 11, 9));
            travelDateRepository.Add("Vissza", new DateTime(2020, 11, 9));
            var result  = travelDateRepository.Get(1);
            var results = travelDateRepository.GetAll();

            Assert.IsTrue(results.Count == 2);
            Assert.IsTrue(result.TravelName == "Oda");
            Assert.IsTrue(result.TravelerTravelDateReferences.Count == 0);

            travelDateRepository.Remove(1);
            travelDateRepository.Remove(2);
            results = travelDateRepository.GetAll();
            Assert.IsTrue(results.Count == 0);
        }
Beispiel #2
0
        public void TravelerTravelDateReferenceRepositoryOperations()
        {
            IDataAccessor dataAccessor = new DataAccessor(false, "Data Source=TravelerTravelDateRepositoryTest.db");

            using (var dbContext = dataAccessor.GetNewDatabaseContext())
            {
                dbContext.Database.EnsureDeleted();
                dbContext.Database.EnsureCreated();
            }
            ITravelerTravelDateReferenceRepository travelerTravelDateReferenceRepository = new TravelerTravelDateReferenceRepository(dataAccessor);
            ITravelerRepository   travelerRepository   = new TravelerRepository(dataAccessor);
            ITravelDateRepository travelDateRepository = new TravelDateRepository(dataAccessor);

            travelerRepository.Add("Zoltan", "Zoltan", "+3655555", "Ada", "Bregenz", true, 500);
            travelerRepository.Add("Zoltan", "Zoltan", "+3655555", "Ada", "Bregenz", true, 500);

            travelDateRepository.Add("Oda", new DateTime(2020, 11, 9));
            travelDateRepository.Add("Vissza", new DateTime(2020, 11, 9));

            travelerTravelDateReferenceRepository.Add(1, 1);
            travelerTravelDateReferenceRepository.Add(1, 2);
            travelerTravelDateReferenceRepository.Add(2, 1);
            travelerTravelDateReferenceRepository.Add(2, 2);
            var results1 = travelerTravelDateReferenceRepository.GetAll();

            Assert.IsTrue(results1.Count == 4);

            travelerTravelDateReferenceRepository.Remove(1, 1);
            var results2 = travelerTravelDateReferenceRepository.GetAll();

            Assert.IsTrue(results2.Count == 3);

            travelDateRepository.Remove(2);
            var results3 = travelerTravelDateReferenceRepository.GetAll();

            Assert.IsTrue(results3.Count == 1);

            travelerRepository.Remove(2);
            var results4 = travelerTravelDateReferenceRepository.GetAll();

            Assert.IsTrue(results4.Count == 0);
        }