Exemplo n.º 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"); }
        }
        public void UpdateReservationTestWithOptimisticConcurrency()
        {
            TestEnvironmentHelper.InitializeTestData();

            // Client 1
            var            res = Target.Reservationen;
            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
            Target.UpdateReservation(modifiedReservation2, originalReservation2);
        }