Beispiel #1
0
        public void CreateTourTestWithException()
        {
            ResetData();
            var         uow = new Mock <UnitOfWork>();
            TourService ts  = new TourService(uow.Object);

            ts.CreateTour(null);
        }
Beispiel #2
0
        public void FindByIdTest()
        {
            ResetData();
            var               uow = new Mock <UnitOfWork>();
            TourService       ts  = new TourService(uow.Object);
            OutputTourService ots = new OutputTourService(uow.Object);

            TourDTO tour = new TourDTO()
            {
                Country = "Ukraine", Region = "Kiev", Hotel = "Ukraine", EndDate = DateTime.Now, StartDate = DateTime.Now
            };

            ts.CreateTour(tour);

            List <TourDTO> tours = ots.GetAllFilteredTours(null, null, null, false);

            Assert.AreEqual(ts.FindById(tours[tours.Count - 1].TourId).Country, tour.Country);
        }
Beispiel #3
0
        public void CreateTourTest()
        {
            ResetData();
            var               uow   = new Mock <UnitOfWork>();
            TourService       ts    = new TourService(uow.Object);
            OutputTourService ots   = new OutputTourService(uow.Object);
            int               numEx = ots.GetAllFilteredTours(null, null, null, false).Count + 1;

            TourDTO tour = new TourDTO()
            {
                Country = "Test", Hotel = "Test", Region = "Test", EndDate = DateTime.Now, StartDate = DateTime.Now
            };

            ts.CreateTour(tour);
            int numAc = ots.GetAllFilteredTours(null, null, null, false).Count;

            Assert.AreEqual(numEx, numAc);
        }
Beispiel #4
0
        public void CreateOrderTest()
        {
            ResetData();
            var uow         = new Mock <UnitOfWork>();
            var identityUow = new Mock <IdentityUnitOfWork>();

            UserService       us  = new UserService();
            TourService       ts  = new TourService(uow.Object);
            OrderService      os  = new OrderService(uow.Object);
            OutputTourService ots = new OutputTourService(uow.Object);

            UserDTO user = new UserDTO()
            {
                Email = "123", Password = "******", Address = "Kiev", Name = "Andrey"
            };

            us.Create(user);
            us.Authenticate(user);

            TourDTO tour = new TourDTO()
            {
                Country = "Ukraine", Region = "Kiev", Hotel = "Ukraine", EndDate = DateTime.Now, StartDate = DateTime.Now
            };

            ts.CreateTour(tour);

            List <TourDTO> tours = ots.GetAllFilteredTours(null, null, null, false);
            OrderDTO       order = new OrderDTO()
            {
                Tour = tours[tours.Count - 1], TourId = tours[tours.Count - 1].TourId, ClientName = user.Email, Hotel = true, NumberOfPerson = 1, Transport = true
            };

            os.CreateOrder(order);

            Assert.AreEqual(os.GetAllOrders()[os.GetAllOrders().Count - 1].Tour.Country, tour.Country);
        }
Beispiel #5
0
        public void ExecutePostConnectionTask()
        {
            context = AzusaContext.GetInstance();

            int forbidUpload = context.ReadIniKey("gps", "forbidUpload", 1);

            if (forbidUpload == 1)
            {
                return;
            }

            DirectoryInfo tourDir = new DirectoryInfo("tours");

            if (!tourDir.Exists)
            {
                tourDir.Create();
                tourDir.Refresh();
            }
            foreach (FileInfo fi in tourDir.GetFiles("*.csv"))
            {
                if (IsStringNumeric(Path.GetFileNameWithoutExtension(fi.Name)))
                {
                    continue;
                }

                FileStream fs          = fi.OpenRead();
                ByteBuffer checkBuffer = new ByteBuffer(512);
                int        readResult  = fs.Read(checkBuffer.Data, 0, 512);
                fs.Close();
                if (readResult != 512)
                {
                    continue;
                }

                if (TourService.IsTourKnown(checkBuffer.Hash))
                {
                    fi.Delete();
                    ExecutePostConnectionTask();
                    return;
                }

                if (context.DatabaseDriver.TransactionSupported)
                {
                    context.DatabaseDriver.BeginTransaction();
                    StreamReader sr    = fi.OpenText();
                    string       magic = sr.ReadLine();
                    if (magic != "Azusa Warwalking Tour")
                    {
                        sr.Dispose();
                        continue;
                    }

                    DateTime recordingStarting     = new DateTime(Convert.ToInt64(sr.ReadLine()));
                    int      utimeRecordingStarted = recordingStarting.ToUnixTime();
                    int      tourId = TourService.CreateTour(checkBuffer.Hash, utimeRecordingStarted,
                                                             Path.GetFileNameWithoutExtension(fi.Name));
                    context.Splash.SetLabel(String.Format("Lade WarWalking Tour hoch: {0}", fi.Name));
                    ProcessTour(sr, tourId);
                    context.DatabaseDriver.EndTransaction(true);
                }
            }
        }