Example #1
0
        public void UpdateReservationTestWithOptimisticConcurrency()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            // Client 1
            ReservationDto originalReservation1 = target.Reservationen[0];
            ReservationDto modifiedReservation1 = (ReservationDto)originalReservation1.Clone();

            modifiedReservation1.Bis = DateTime.Today.AddSeconds(10);

            // Client 2
            ReservationDto originalReservation2 = target.Reservationen[0];
            ReservationDto modifiedReservation2 = (ReservationDto)originalReservation2.Clone();

            modifiedReservation2.Bis = DateTime.Today.AddSeconds(20);

            //Client 1 Update
            target.UpdateReservation(modifiedReservation1, originalReservation1);

            //Client 2 Update
            try
            {
                target.UpdateReservation(modifiedReservation2, originalReservation2);
                Assert.Fail();
            }
            catch (OptimisticConcurrencyException <ReservationDto> ) { }
            catch { Assert.Fail("Unexpected Exception"); }
        }
Example #2
0
        public void UpdateKundeTestWithOptimisticConcurrency()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            // Client 1
            KundeDto originalKunde1 = target.Kunden[0];
            KundeDto modifiedKunde1 = (KundeDto)originalKunde1.Clone();

            modifiedKunde1.Nachname = "Hardegger";

            // Client 2
            KundeDto originalKunde2 = target.Kunden[0];
            KundeDto modifiedKunde2 = (KundeDto)originalKunde2.Clone();

            modifiedKunde2.Nachname = "Schmid";

            //Client 1 Update
            target.UpdateKunde(modifiedKunde1, originalKunde1);

            //Client 2 Update
            try
            {
                target.UpdateKunde(modifiedKunde2, originalKunde2);
                Assert.Fail();
            }
            catch (OptimisticConcurrencyException <KundeDto> ) { }
            catch { Assert.Fail("Unexpected Exception"); }
        }
Example #3
0
        public void UpdateReservationTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            ReservationDto reservation = new ReservationDto
            {
                Auto  = target.Autos[0],
                Kunde = target.Kunden[0],
                Von   = DateTime.Today,
                Bis   = DateTime.Today.AddDays(10)
            };

            int reservationNr = target.InsertReservation(reservation);

            Assert.AreNotEqual(0, reservationNr);

            ReservationDto org = target.GetReservationByNr(reservationNr);
            ReservationDto mod = target.GetReservationByNr(reservationNr);

            mod.Von = DateTime.Today.AddYears(1);
            mod.Bis = DateTime.Today.AddDays(10).AddYears(1);

            target.UpdateReservation(mod, org);

            ReservationDto result = target.GetReservationByNr(reservationNr);

            Assert.AreEqual(mod.ReservationNr, result.ReservationNr);
            Assert.AreEqual(mod.Auto.Id, result.Auto.Id);
            Assert.AreEqual(mod.Kunde.Id, result.Kunde.Id);
            Assert.AreEqual(mod.Von, result.Von);
            Assert.AreEqual(mod.Bis, result.Bis);
        }
Example #4
0
        public void UpdateAutoTestWithOptimisticConcurrency()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            // Client 1
            AutoDto originalAuto1 = target.Autos[0];
            AutoDto modifiedAuto1 = (AutoDto)originalAuto1.Clone();

            modifiedAuto1.Marke = "Citroen Saxo";

            // Client 2
            AutoDto originalAuto2 = target.Autos[0];
            AutoDto modifiedAuto2 = (AutoDto)originalAuto2.Clone();

            modifiedAuto2.Marke = "Peugot 106";

            //Client 1 Update
            target.UpdateAuto(modifiedAuto1, originalAuto1);

            //Client 2 Update
            try
            {
                target.UpdateAuto(modifiedAuto2, originalAuto2);
                Assert.Fail();
            }
            catch (OptimisticConcurrencyException <AutoDto> ) { }
            catch { Assert.Fail("Unexpected Exception"); }
        }
Example #5
0
        public void UpdateKundeTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            KundeDto kunde = new KundeDto
            {
                Nachname     = "Wand",
                Vorname      = "Andi",
                Geburtsdatum = new DateTime(1955, 4, 12)
            };

            int kundeId = target.InsertKunde(kunde);

            Assert.AreNotEqual(0, kundeId);

            KundeDto org = target.GetKundeById(kundeId);
            KundeDto mod = target.GetKundeById(kundeId);

            mod.Nachname = "Stein";
            mod.Vorname  = "Sean";

            target.UpdateKunde(mod, org);

            KundeDto result = target.GetKundeById(kundeId);

            Assert.AreEqual(mod.Id, result.Id);
            Assert.AreEqual(mod.Nachname, result.Nachname);
            Assert.AreEqual(mod.Vorname, result.Vorname);
            Assert.AreEqual(mod.Geburtsdatum, result.Geburtsdatum);
        }
Example #6
0
        public void UpdateAutoTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            AutoDto auto = new AutoDto
            {
                Marke      = "Renault Clio",
                AutoKlasse = AutoKlasse.Standard,
                Tagestarif = 65
            };

            int autoId = target.InsertAuto(auto);

            Assert.AreNotEqual(0, autoId);

            AutoDto org = target.GetAutoById(autoId);
            AutoDto mod = target.GetAutoById(autoId);

            mod.Marke = "Fiat 500";

            target.UpdateAuto(mod, org);

            AutoDto result = target.GetAutoById(autoId);

            Assert.AreEqual(mod.Id, result.Id);
            Assert.AreEqual(mod.Marke, result.Marke);
            Assert.AreEqual(mod.AutoKlasse, result.AutoKlasse);
            Assert.AreEqual(mod.Tagestarif, result.Tagestarif);
            Assert.AreEqual(mod.Basistarif, result.Basistarif);
        }
Example #7
0
        public void InitializeTestData()
        {
            kernel = new StandardKernel();
            kernel.Load("Dependencies.Ninject.xml");

            TestEnvironmentHelper.InitializeTestData();
        }
Example #8
0
        public void GetAutoByIdTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            AutoDto auto = new AutoDto
            {
                Marke      = "Opel Astra",
                AutoKlasse = AutoKlasse.Standard,
                Tagestarif = 45
            };

            int autoId = target.InsertAuto(auto);

            Assert.AreNotEqual(0, autoId);

            AutoDto actual = target.GetAutoById(autoId);

            Assert.IsNotNull(actual);
            Assert.AreEqual(autoId, actual.Id);
            Assert.AreEqual(auto.Marke, actual.Marke);
            Assert.AreEqual(auto.AutoKlasse, actual.AutoKlasse);
            Assert.AreEqual(auto.Tagestarif, actual.Tagestarif);
            Assert.AreEqual(auto.Basistarif, actual.Basistarif);
        }
Example #9
0
        public void InitializeTestData()
        {
            kernel = new StandardKernel();
            kernel.Load("AutoReservation.Ui.Factory.NinjectBindings.xml");

            TestEnvironmentHelper.InitializeTestData();
        }
Example #10
0
        public void ReservationenTest()
        {
            TestEnvironmentHelper.InitializeTestData();

            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();
            IList <ReservationDto>           actual = target.Reservationen;

            Assert.AreEqual(1, actual.Count);
        }
Example #11
0
        public void GetReservationByIllegalNr()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            ReservationDto actual = target.GetReservationByNr(-1);

            Assert.IsNull(actual);
        }
Example #12
0
 public static void CleanUpAfterAllTests()
 {
     TestEnvironmentHelper.InitializeTestData();
     File.Delete(FileToAdd);
     File.Delete(FileToDelete);
     File.Delete(Path.Combine(FileType.Document.ToString(), FileToAdd));
     File.Delete(Path.Combine(FileType.Document.ToString(), FileToDelete));
     Directory.Delete(FileType.Document.ToString());
 }
Example #13
0
        public void KundenLoadTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            var model   = new KundeViewModel();
            var command = model.LoadCommand;

            Assert.IsTrue(command.CanExecute(null));
            command.Execute(null);
            Assert.AreEqual(4, model.Kunden.Count);
        }
 public void InitializeTestData()
 {
     TestEnvironmentHelper.InitializeTestData();
     autoDto = new AutoDto {
         Id = 1, Marke = "Fiat Punto", Tagestarif = 50, AutoKlasse = AutoKlasse.Standard
     };
     kundeDto = new KundeDto {
         Id = 1, Nachname = "Nass", Vorname = "Anna", Geburtsdatum = new DateTime(1981, 05, 05)
     };
     reservationDto = new ReservationDto {
         ReservationsNr = 1, Auto = autoDto, Kunde = kundeDto, Von = new DateTime(2020, 01, 10), Bis = new DateTime(2020, 01, 20)
     };
 }
        public void AutosLoadTest()
        {
            TestEnvironmentHelper.InitializeTestData();

            AutoViewModel target        = new AutoViewModel();
            ICommand      targetCommand = target.LoadCommand;

            Assert.IsTrue(targetCommand.CanExecute(null));

            targetCommand.Execute(null);

            Assert.AreEqual(3, target.Autos.Count);
        }
        public void KundenLoadTest()
        {
            TestEnvironmentHelper.InitializeTestData();

            KundeViewModel target        = new KundeViewModel();
            ICommand       targetCommand = target.LoadCommand;

            Assert.IsTrue(targetCommand.CanExecute(null));

            targetCommand.Execute(null);

            Assert.AreEqual(4, target.Kunden.Count);
        }
        public void ReservationenLoadTest()
        {
            TestEnvironmentHelper.InitializeTestData();

            ReservationViewModel target        = new ReservationViewModel();
            ICommand             targetCommand = target.LoadCommand;

            Assert.IsTrue(targetCommand.CanExecute(null));

            targetCommand.Execute(null);

            Assert.AreEqual(1, target.Reservationen.Count);
        }
Example #18
0
        public void DeleteAutoTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            AutoDto actual = target.Autos[0];

            target.DeleteAuto(actual);

            AutoDto result = target.GetAutoById(actual.Id);

            Assert.IsNull(result);
        }
Example #19
0
        public void DeleteReservationTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            ReservationDto actual = target.Reservationen[0];

            target.DeleteReservation(actual);

            ReservationDto result = target.GetReservationByNr(actual.ReservationNr);

            Assert.IsNull(result);
        }
Example #20
0
        public void GetReservationByNrTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            var reservationen = target.Reservationen;

            Assert.AreNotEqual(reservationen.Count, 0);

            ReservationDto expected = reservationen[0];
            ReservationDto actual   = target.GetReservationByNr(expected.ReservationNr);

            Assert.AreEqual(expected.ReservationNr, actual.ReservationNr);
        }
Example #21
0
        public void InsertKundeTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            KundeDto kunde = new KundeDto
            {
                Nachname     = "Kolade",
                Vorname      = "Joe",
                Geburtsdatum = new DateTime(1911, 1, 27)
            };

            int kundeId = target.InsertKunde(kunde);

            Assert.AreNotEqual(0, kundeId);

            KundeDto result = target.GetKundeById(kundeId);

            Assert.AreEqual(kundeId, result.Id);
            Assert.AreEqual(kunde.Nachname, result.Nachname);
            Assert.AreEqual(kunde.Vorname, result.Vorname);
            Assert.AreEqual(kunde.Geburtsdatum, result.Geburtsdatum);
        }
Example #22
0
        public void InsertAutoTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            AutoDto auto = new AutoDto
            {
                Marke      = "Seat Ibiza",
                AutoKlasse = AutoKlasse.Standard,
                Tagestarif = 40
            };

            int autoId = target.InsertAuto(auto);

            Assert.AreNotEqual(0, autoId);

            AutoDto result = target.GetAutoById(autoId);

            Assert.AreEqual(autoId, result.Id);
            Assert.AreEqual(auto.Marke, result.Marke);
            Assert.AreEqual(auto.AutoKlasse, result.AutoKlasse);
            Assert.AreEqual(auto.Tagestarif, result.Tagestarif);
            Assert.AreEqual(auto.Basistarif, result.Basistarif);
        }
Example #23
0
        public void GetKundeByIdTest()
        {
            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent target = new AutoReservationBusinessComponent();

            KundeDto kunde = new KundeDto
            {
                Nachname     = "Jewo",
                Vorname      = "Sara",
                Geburtsdatum = new DateTime(1961, 6, 21)
            };

            int kundeId = target.InsertKunde(kunde);

            Assert.AreNotEqual(0, kundeId);

            KundeDto actual = target.GetKundeById(kundeId);

            Assert.IsNotNull(actual);
            Assert.AreEqual(kundeId, actual.Id);
            Assert.AreEqual(kunde.Nachname, actual.Nachname);
            Assert.AreEqual(kunde.Vorname, actual.Vorname);
            Assert.AreEqual(kunde.Geburtsdatum, actual.Geburtsdatum);
        }
 public void InitializeTestData()
 {
     TestEnvironmentHelper.InitializeTestData();
 }
Example #25
0
 public void InitializeTestData()
 {
     TestEnvironmentHelper.InitializeTestData();
     context    = new TinyErpContext();
     unitOfWork = new UnitOfWork(context);
 }
Example #26
0
 public void ReservationenLoadTest()
 {
     TestEnvironmentHelper.InitializeTestData();
 }
Example #27
0
 public void AutosLoadTest()
 {
     TestEnvironmentHelper.InitializeTestData();
 }
Example #28
0
 static void Main(string[] args)
 {
     TestEnvironmentHelper.InitializeTestData();
 }
Example #29
0
 public void InitializeTestData()
 {
     TestEnvironmentHelper.InitializeTestData();
     viewModel = new ReservationViewModel();
 }
 public void InitializeTestData()
 {
     service = new AutoReservationService();
     TestEnvironmentHelper.InitializeTestData();
 }