Beispiel #1
0
        public async void CheckForCourts()
        {
            Task <string> response              = repo.GetSquashCourst(viewModel.SelectedDate, viewModel.GodzinaOd, viewModel.GodzinaDo);
            var           freeCourts            = HastaHelper.GetFreeSquashCourts(await response, selectedCourts);
            var           availableReservations = HastaHelper.FilterByTimeRange(freeCourts, viewModel.GodzinaOd, viewModel.GodzinaDo, viewModel.Length - 1);

            if (availableReservations.Count > 0)
            {
                aTimer.Stop();
                Reservations   = availableReservations;
                TimeFontSize   = 46;
                TimeLeft       = "ZNALEZIONO KORT !!!";
                TimeForeground = "Red";
            }
            else
            {
                ResetTime();
                aTimer.Start();
            }

            //Reservations = new List<Court>()
            //{
            //    new Court(29,
            //        new List<CourtHours>(){
            //            new CourtHours(){From = "08:00", To ="08:30" },
            //            new CourtHours(){From = "08:30", To ="09:00" }
            //        }),
            //   new Court(25,
            //        new List<CourtHours>(){
            //            new CourtHours(){From = "15:00", To ="15:30" },
            //            new CourtHours(){From = "15:30", To ="16:00" }
            //         })
            //};
        }
        public void GetFreeSquashCourts_ValidRequest_ReturnCourts()
        {
            var freecourts = HastaHelper.GetFreeSquashCourts(response, new List <Court>()
            {
                new Court(2)
            });

            Assert.AreEqual(32, freecourts.Count);
        }
        public void FilterByTimeRange_ValidRequest_Return1Court()
        {
            DateTime timeFrom = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 0, 0);
            DateTime timeTo   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0);
            int      length   = 1; //1 hour between 15:00 and 17:00 date should not matter at this point

            var courtsToPlay = HastaHelper.FilterByTimeRange(foudCourst, timeFrom, timeTo, length);

            Assert.AreEqual(courtsToPlay.Count, 1);
            Assert.AreEqual(courtsToPlay[0].Number, 25);
        }
Beispiel #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string response = File.ReadAllText(@"D:\nauka\C#\HastaLaVista\Testing\TestingHelperApp\TestingHelperApp\retrieve2.txt");

            HastaHelper.GetFreeSquashCourts(response);
        }