Exemple #1
0
 public void CanDeleteFacilityWithoutReservations()
 {
     using (var dbContext = GetContext())
     {
         var facility = new Facility {
             Name = "Test", Id = 2
         };
         facilities.Add(facility);
         var facilityManagement =
             new FacilityManagement(dbContext, TestHelper.GetGenericPrincipalAdmin(), mapper);
         facilityManagement.Delete(facility.Id);
         Assert.False(facilities.Any());
     }
 }
Exemple #2
0
        public void DeleteFacilityWithReservationsPerformsLogicalDeletion()
        {
            var user = new User
            {
                Address    = "Address",
                Email      = "*****@*****.**",
                Name       = "Name",
                UserName   = "******",
                MiddleName = "Middle"
            };
            var facility = new Facility {
                Name = "Test"
            };
            var reservation = new Reservation
            {
                CreationdDate   = DateTime.Now,
                CreatedBy       = "Test",
                Ends            = new TimeSpan(20, 0, 0),
                ReservationDate = DateTime.Now,
                Starts          = new TimeSpan(19, 0, 0),
                UpdatedBy       = "Test",
                UpdatedDate     = DateTime.Now,
                User            = user,
                Facility        = facility
            };

            facilities.Add(facility);
            reservations.Add(reservation);

            using (var dbContext = GetContext())
            {
                using (var facilityManagement = new FacilityManagement(dbContext,
                                                                       TestHelper.GetGenericPrincipalAdmin(), mapper))
                {
                    facilityManagement.Delete(facility.Id);
                    facility = facilityManagement.GetById(facility.Id);
                    Assert.False(facility.IsActive);
                }
            }
        }