public void UpdateAutoTest()
        {
            TestEnvironmentHelper.InitializeTestData();

            Auto auto = new StandardAuto
            {
                Marke      = "Renault Clio",
                Tagestarif = 65
            };

            int autoId = Target.InsertAuto(auto);

            Assert.AreNotEqual(0, autoId);

            Auto org = Target.GetAutoById(autoId);
            Auto mod = Target.GetAutoById(autoId);

            mod.Marke = "Fiat 500";

            Target.UpdateAuto(mod, org);

            Auto result = Target.GetAutoById(autoId);

            Assert.AreEqual(mod.GetType(), result.GetType());
            Assert.AreEqual(mod.Id, result.Id);
            Assert.AreEqual(mod.Marke, result.Marke);
            Assert.AreEqual(mod.Tagestarif, result.Tagestarif);
        }
        public void ScenarioOkay01Test()
        {
            DateTime from = new DateTime(2020, 01, 10);
            DateTime to   = new DateTime(2020, 01, 20);

            Auto newAuto = new StandardAuto
            {
                Marke      = "BMW",
                Tagestarif = 70,
            };

            bool actual = Target.CheckAutoAvailabilty(from, to, newAuto.Id);

            Assert.IsTrue(actual);
        }
        private void ChangeAutoType(AutoKlasse autoType)
        {
            switch (autoType)
            {
            case AutoKlasse.Luxusklasse:
                Auto = new LuxusklasseAuto();
                break;

            case AutoKlasse.Mittelklasse:
                Auto = new MittelklasseAuto();
                break;

            case AutoKlasse.Standard:
                Auto = new StandardAuto();
                break;
            }
        }
        public void CreateAutoTest()
        {
            var newCar = new StandardAuto
            {
                Brand     = "TestBrand",
                DailyRate = 99
            };
            var cars = Target.GetAll().ToList();

            Target.Create(newCar);

            Assert.ProperSuperset(new HashSet <Auto>(cars), new HashSet <Auto>(Target.GetAll()));
            var newCarFromDb = Target.GetAll().First(c => !cars.Any(_c => _c.Id == c.Id));

            Assert.NotNull(newCarFromDb);
            Assert.Equal(newCar.Brand, newCarFromDb.Brand);
            Assert.Equal(newCar.DailyRate, newCarFromDb.DailyRate);
        }
        public void ScenarioNotOkay03Test()
        {
            Auto a1 = new StandardAuto();

            a1.Marke      = "BMW M3";
            a1.Tagestarif = 150;

            Kunde k1 = new Kunde();

            k1.Nachname     = "Hintersee";
            k1.Vorname      = "Hansi";
            k1.Geburtsdatum = new DateTime(1940, 12, 3);

            Reservation r1 = new Reservation();

            r1.Auto  = a1;
            r1.Kunde = k1;
            r1.Von   = new DateTime(2017, 12, 21);
            r1.Bis   = new DateTime(2018, 1, 11);

            Target.InstertReservation(r1);

            Kunde k2 = new Kunde();

            k2.Nachname     = "Forlin";
            k2.Vorname      = "Jan";
            k2.Geburtsdatum = new DateTime(1995, 2, 21);

            Reservation r2 = new Reservation();

            r2.AutoId = a1.Id;
            r2.Kunde  = k2;
            r2.Von    = new DateTime(2018, 1, 12);
            r2.Bis    = new DateTime(2018, 2, 5);

            Target.InstertReservation(r2);

            r2.Von = new DateTime(2018, 1, 1);

            Target.UpdateReservation(r2);
        }
        public void ScenarioOkay02Test()
        {
            Auto a1 = new StandardAuto();

            a1.Marke      = "VW Polo";
            a1.Tagestarif = 150;

            Kunde k1 = new Kunde();

            k1.Nachname     = "Del Curto";
            k1.Vorname      = "Arno";
            k1.Geburtsdatum = new DateTime(1921, 12, 3);

            Reservation r1 = new Reservation();

            r1.Auto  = a1;
            r1.Kunde = k1;
            r1.Von   = new DateTime(2017, 12, 21);
            r1.Bis   = new DateTime(2018, 2, 15);

            Target.InstertReservation(r1);

            Kunde k2 = new Kunde();

            k2.Nachname     = "Genoni";
            k2.Vorname      = "Leonardo";
            k2.Geburtsdatum = new DateTime(1989, 3, 21);

            Reservation r2 = new Reservation();

            r2.Auto  = a1;
            r2.Kunde = k2;
            r2.Von   = new DateTime(2018, 2, 16);
            r2.Bis   = new DateTime(2018, 8, 5);

            Target.InstertReservation(r2);

            Assert.IsTrue(r2.ReservationsNr > 0);
        }
        public void ScenarioOkay01Test_NoReservationsForCarYet()
        {
            var car = new StandardAuto
            {
                Brand     = "PaddyWaggon",
                DailyRate = 120
            };

            var autoManager = new AutoManager();

            autoManager.Create(car);

            var reservation = new Reservation
            {
                Auto    = autoManager.GetAll().OrderBy(c => c.Id).Last(),
                KundeId = 1,
                From    = DateTime.Today,
                To      = DateTime.Today.AddDays(2)
            };

            ReservationManager.CheckCarAvailability(reservation, Target);
        }
Esempio n. 8
0
        public void ScenarioOkay01Test()
        {
            Auto auto = new StandardAuto {
            };
            Reservation reservation1 =
                new Reservation {
                Von  = new DateTime(2017, 1, 1),
                Bis  = new DateTime(2017, 1, 5),
                Auto = auto
            };
            Reservation reservation2 = new Reservation {
            };

            Target.addReservation(reservation1);
            Assert.IsTrue(
                Target.IsCarAvailable(new Reservation
            {
                Von  = new DateTime(2017, 1, 7),
                Bis  = new DateTime(2017, 1, 8),
                Auto = auto
            }, auto
                                      ));
        }
Esempio n. 9
0
        public void ScenarioNotOkay01Test()
        {
            Auto a1 = new StandardAuto();

            a1.Marke      = "Nissan Leaf";
            a1.Tagestarif = 69;


            Kunde k1 = new Kunde();

            k1.Nachname     = "Elon";
            k1.Vorname      = "Musk";
            k1.Geburtsdatum = new DateTime(1942, 8, 1);

            Reservation r1 = new Reservation();

            r1.Auto  = a1;
            r1.Kunde = k1;
            r1.Von   = new DateTime(2018, 7, 21);
            r1.Bis   = new DateTime(2018, 5, 2);

            Target.InstertReservation(r1);
        }
        public void ScenarioNotOkay02Test()
        {
            Auto a1 = new StandardAuto();

            a1.Marke      = "Ford Mustang";
            a1.Tagestarif = 275;

            Kunde k1 = new Kunde();

            k1.Nachname     = "Schiffer";
            k1.Vorname      = "Claudia";
            k1.Geburtsdatum = new DateTime(1987, 12, 3);

            Reservation r1 = new Reservation();

            r1.Auto  = a1;
            r1.Kunde = k1;
            r1.Von   = new DateTime(2020, 12, 21);
            r1.Bis   = new DateTime(2020, 1, 11);

            Target.InstertReservation(r1);

            Kunde k2 = new Kunde();

            k2.Nachname     = "Oliver";
            k2.Vorname      = "John";
            k2.Geburtsdatum = new DateTime(1981, 8, 21);

            Reservation r2 = new Reservation();

            r2.AutoId = a1.Id;
            r2.Kunde  = k2;
            r2.Von    = new DateTime(2020, 1, 8);
            r2.Bis    = new DateTime(2020, 2, 5);

            Target.InstertReservation(r2);
        }
        public void ScenarioNotOkay01Test()
        {
            Auto a1 = new StandardAuto();

            a1.Marke      = "Audi TT";
            a1.Tagestarif = 150;

            Kunde k1 = new Kunde();

            k1.Nachname     = "Paris";
            k1.Vorname      = "Hilton";
            k1.Geburtsdatum = new DateTime(1987, 12, 3);

            Reservation r1 = new Reservation();

            r1.Auto  = a1;
            r1.Kunde = k1;
            r1.Von   = new DateTime(2017, 12, 21);
            r1.Bis   = new DateTime(2018, 1, 11);

            Target.InstertReservation(r1);

            Kunde k2 = new Kunde();

            k2.Nachname     = "Martullo-Blocher";
            k2.Vorname      = "Magdalena";
            k2.Geburtsdatum = new DateTime(1981, 8, 21);

            Reservation r2 = new Reservation();

            r2.AutoId = a1.Id;
            r2.Kunde  = k2;
            r2.Von    = new DateTime(2018, 1, 8);
            r2.Bis    = new DateTime(2018, 2, 5);

            Target.InstertReservation(r2);
        }