public void GetPeriodTimeReservation_2ARGReservations_ArrayMatches()
        {
            MainSystem system = new MainSystem {
                Country = Country.Argentina
            };

            AddReserve_ARG_At(ref system, "17:00", "30");
            AddReserve_ARG_At(ref system, "17:15", "30");

            Reserve[] expectedArray = new Reserve[2];
            expectedArray[0] = MakeARGReserveAt(30, 17, 0);
            expectedArray[1] = MakeARGReserveAt(30, 17, 15);

            ReservationRequestLetter request = new ReservationRequestLetter
            {
                StartTime = SevenPM.AddMinutes(-5),
                EndTime   = SevenPM.AddMinutes(60),
                Country   = Country.Argentina
            };

            Reserve[] actual = system.GetPeriodTimeReservations(request);


            bool result = Enumerable.SequenceEqual(actual, expectedArray);

            Assert.IsTrue(result);
        }
        public void GetPeriodTimeReservation_5Reservations3OnTime_ArrayMatches()
        {
            MainSystem system = new MainSystem {
                Country = Country.Uruguay
            };

            AddReserve_UY_At(ref system, "17:05", "30");
            AddReserve_UY_At(ref system, "17:10", "30");
            AddReserve_UY_At(ref system, "17:15", "30");
            AddReserve_UY_At(ref system, "17:20", "30");
            AddReserve_UY_At(ref system, "17:30", "30");

            Reserve[] expectedArray = new Reserve[3];
            expectedArray[0] = MakeUYReserveAt(30, 17, 5);
            expectedArray[1] = MakeUYReserveAt(30, 17, 10);
            expectedArray[2] = MakeUYReserveAt(30, 17, 15);

            ReservationRequestLetter request = new ReservationRequestLetter
            {
                StartTime = SevenPM.AddMinutes(-5),
                EndTime   = SevenPM.AddMinutes(16),
                Country   = Country.Uruguay
            };

            Reserve[] actual = system.GetPeriodTimeReservations(request);
            bool      result = Enumerable.SequenceEqual(actual, expectedArray);

            Assert.IsTrue(result);
        }
        public void GetPeriodTimeReservation_5GlobalReservations4OnTime_ArrayMatches()
        {
            MainSystem system = new MainSystem();

            AddReserve_UY_At(ref system, "17:04", "30");
            AddReserve_UY_At(ref system, "17:05", "30");
            AddReserve_UY_At(ref system, "17:10", "30");
            AddReserve_ARG_At(ref system, "17:15", "30");
            AddReserve_ARG_At(ref system, "17:20", "30");

            Reserve[] expectedArray = new Reserve[4];
            expectedArray[0] = MakeUYReserveAt(30, 17, 4);
            expectedArray[1] = MakeUYReserveAt(30, 17, 5);
            expectedArray[2] = MakeUYReserveAt(30, 17, 10);
            expectedArray[3] = MakeARGReserveAt(30, 17, 15);

            ReservationRequestLetter request = new ReservationRequestLetter
            {
                StartTime = FivePM.AddMinutes(-5),
                EndTime   = FivePM.AddMinutes(16)
            };

            Reserve[] actual = system.GetPeriodTimeReservations(request);
            bool      result = Enumerable.SequenceEqual(actual, expectedArray);

            Assert.IsTrue(result);
        }
        public void GetPeriodTimeReservation_IncompleteRequest_Exception()
        {
            MainSystem system = new MainSystem {
                Country = Country.Uruguay
            };
            ReservationRequestLetter request = new ReservationRequestLetter {
            };

            system.GetPeriodTimeReservations(request);
        }
        public void GetPeriodTimeReservation_IncompleteRequest4_Exception()
        {
            DateTime   time   = DateTime.Now;
            MainSystem system = new MainSystem {
                Country = Country.Uruguay
            };
            ReservationRequestLetter request;

            request = new ReservationRequestLetter
            {
                Country = Country.Argentina
            };
            system.GetPeriodTimeReservations(request);
        }
コード例 #6
0
        private void ShowBtn_Click(object sender, EventArgs e)
        {
            this.reservationsListView.Items.Clear();
            DateTime start  = this.startDateTime.Value;
            DateTime finish = this.endDateTime.Value;
            Country  country;

            if (countrySelector.SelectedIndex == 2)
            {
                country = 0;
            }
            else
            {
                country = system.NumberToCountry(countrySelector.SelectedIndex + 1);
            }

            ReservationRequestLetter RRL = new ReservationRequestLetter
            {
                EndTime   = finish,
                StartTime = start,
            };

            if (country != 0)
            {
                RRL.Country = country;
            }
            try
            {
                Reserve[] reservations = system.GetPeriodTimeReservations(RRL);
                if (reservations != null)
                {
                    foreach (Reserve item in reservations)
                    {
                        this.reservationsListView.Items.Add(item.ToString());
                    }
                }
                else
                {
                    this.reservationsListView.Items.Add("Empty");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
        public void GetPeriodTimeReservation_1Reservation_ArrayMatches()
        {
            MainSystem system = new MainSystem {
                Country = Country.Uruguay
            };

            AddReserve_UY_At(ref system, "17:00", "30");

            Reserve[] expectedArray = new Reserve[1];
            expectedArray[0] = MakeUYReserveAt(30, 17, 0);

            ReservationRequestLetter request = new ReservationRequestLetter
            {
                StartTime = SevenPM.AddMinutes(-5),
                EndTime   = SevenPM.AddMinutes(60),
                Country   = Country.Uruguay
            };

            Reserve[] actual = system.GetPeriodTimeReservations(request);

            Assert.IsTrue(Enumerable.SequenceEqual(actual, expectedArray));
        }
        public void GetPeriodTimeReservation_2ReservationsNoOneOnTime_ArrayMatches()
        {
            MainSystem system = new MainSystem {
                Country = Country.Uruguay
            };

            AddReserve_UY_At(ref system, "17:15", "30");
            AddReserve_UY_At(ref system, "17:20", "30");



            ReservationRequestLetter request = new ReservationRequestLetter
            {
                StartTime = SevenPM.AddMinutes(-5),
                EndTime   = SevenPM.AddMinutes(5),
                Country   = Country.Uruguay
            };

            Reserve[] actual = null;
            actual = system.GetPeriodTimeReservations(request);

            Assert.IsNull(actual);
        }