Beispiel #1
0
            public void ModifyRoomTypeWhereRoomTypeExistsThrowsValidationException()
            {
                // Arrange
                var roomTypeDao = MockRepository.GenerateMock<IRoomTypeDao>();
                var roomTypeManager = new RoomTypeManager { RoomTypeDao = roomTypeDao };

                var roomType = new RoomType();

                roomTypeDao.Expect(x => x.DoesRoomTypeExist(roomType)).Return(true);

                try
                {
                    // Act
                    roomTypeManager.ModifyRoomTypeAndBaseRatePlan(roomType);

                    // Assert
                    Assert.Fail("An exception SRVEX30093 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual(Errors.SRVEX30093.ToString(), ex.Code, "The Validation exception is not returning the right error code");
                }
            }
Beispiel #2
0
            public void ModifyRoomTypeAndBaseRatePlanPopulatedRoomTypeIdAndRatePlanId()
            {
                // Arrange
                const long BUSINESS_ID = 1;

                var roomTypeDao = new Mock<IRoomTypeDao>();
                var ratePlanManager = new Mock<IRatePlanManager>();
                var eventTrackingManager = new Mock<IEventTrackingManager>();

                var roomTypeManager = new RoomTypeManager
                {
                    RoomTypeDao = roomTypeDao.Object,
                    RatePlanManager = ratePlanManager.Object,
                    EventTrackingManager = eventTrackingManager.Object
                };

                var ratePlan = new BaseRatePlan
                {
                    MaxOccupancy = 4,
                    MaxAdults = 2,
                    MaxChildren = 2,
                    RatePlanType = new RatePlanType { Type = RatePlanTypeEnum.Base },
                    BoardBasis = new BoardBasis { Code = "BK" },
                    CancellationClass = new CancellationClass { Code = "FR" }
                };

                var roomType = new RoomType
                {
                    Id = 1,
                    BusinessId = BUSINESS_ID,
                    RoomClass = new RoomClass { Code = "DBL" },
                    QualityType = new QualityType { Code = "CTG" },
                    BathroomType = new BathroomType { Code = "PB" },
                    Aspect = new Aspect { Code = "CVW" },
                    BaseRatePlan = ratePlan
                };

                CacheHelper.StubRoomTypeCacheWithRoomType(roomType);

                roomTypeDao.Setup(rt => rt.DoesRoomTypeExist(roomType)).Returns(false);
                roomTypeDao.Setup(rt => rt.Modify(roomType));
                ratePlanManager.Setup(rp => rp.ModifyBaseRatePlan(roomType.BaseRatePlan));

                eventTrackingManager.Setup(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RoomTypeModified, roomType.Id.ToString(CultureInfo.InvariantCulture), null));
                
                // Act
                roomTypeManager.ModifyRoomTypeAndBaseRatePlan(roomType);

                // Assert
                roomTypeDao.VerifyAll();
                ratePlanManager.VerifyAll();
                eventTrackingManager.VerifyAll();

                // Make sure these are reset for future tests
                roomTypeManager.RoomTypeDao = new RoomTypeDao();
                roomTypeManager.RatePlanManager = new RatePlanManager();
                roomTypeManager.EventTrackingManager = new EventTrackingManager();
                CacheHelper.ReAssignRoomTypeDaoToRoomTypeCache();
            }