Ejemplo n.º 1
0
            public void ModifyLimitedGuestWithoutCountryIdAssignsCountryIdOfTheBusiness()
            {
                // Arrange
                IGuestDao guestDao = MockRepository.GenerateStub<IGuestDao>();
                IGuestEventDao guestEventDao = MockRepository.GenerateStub<IGuestEventDao>();
                ICountryDao countryDao = MockRepository.GenerateStub<ICountryDao>();
                GuestManager GuestManager = new GuestManager();
                GuestManager.GuestDao = guestDao;
                GuestManager.CountryDao = countryDao;
                GuestManager.GuestEventDao = guestEventDao;

                Guest guest = new Guest { Id = 1, BusinessId = 1, Surname = "Surname" };
                Country country = new Country { Id = 1, Name = "United Kingdom", IsoCode = 826 };
                guestDao.Stub(x => x.Modify(guest));
                guestDao.Stub(c => c.IsGuestAssociatedToConfirmedBooking(1, 1)).Return(false);
                guestEventDao.Stub(ev => ev.Create(Arg<GuestEvent>.Matches(ge => ge.GuestId == 1 && ge.GuestEventType == GuestEventType.Modified)));
                countryDao.Stub(c => c.GetByBusiness(1)).Return(country);

                // Act
                GuestManager.Modify(guest);

                // Assert
                Assert.AreEqual(country.Id, guest.CountryId, "Country id was updated incorrectly.");
            }  
Ejemplo n.º 2
0
            public void ModifyValidatingMinimumRequiredSetForProvisionalBooking()
            {
                //Arrange
                IGuestDao guestDao = MockRepository.GenerateStub<IGuestDao>();
                GuestManager GuestManager = new GuestManager();

                Guest guest = new Guest();
                guest.Id = 1;
                guest.BusinessId = 1;
                guest.TitleId = 2;

                guestDao.Stub(x => x.Modify(Arg<Guest>.Is.Anything));
                guestDao.Stub(c => c.IsGuestAssociatedToConfirmedBooking(1, 1)).Return(false);

                GuestManager.GuestDao = guestDao;

                //Act
                try
                {
                    GuestManager.Modify(guest);
                    Assert.Fail("An exception SRVEX30017 of type ValidationException should have been thrown"); 
                }
                catch (ValidationException ex)
                {
                    //Assert
                    Assert.AreEqual("SRVEX30017", ex.Code, "The Validation exception is not returning the right error code");
                }
            }
Ejemplo n.º 3
0
            public void ModifyValidatingMinimumRequiredSetForGuestWithConfirmedBooking()
            {
                //Arrange
                IGuestDao guestDao = MockRepository.GenerateStub<IGuestDao>();
                var guestManager = new GuestManager();

                var guest = new Guest
                    {
                        Id = 1,
                        BusinessId = 1,
                        TitleId = 2,
                        Surname = "Test",
                        IsConfirmationEmailToBeSent = true
                    };

                guestDao.Stub(c => c.IsGuestAssociatedToConfirmedBooking(1, 1)).Return(true);
                guestManager.GuestDao = guestDao;

                //Act
                try
                {
                    guestManager.Modify(guest);
                    Assert.Fail("An exception SRVEX30110 of type ValidationException should have been thrown"); 
                }
                catch (ValidationException ex)
                {
                    //Assert
                    Assert.AreEqual("SRVEX30110", ex.Code, "The Validation exception is not returning the right error code");
                }
            }
Ejemplo n.º 4
0
            public void ModifyGuest()
            {
                // Arrange
                IGuestDao guestDao = MockRepository.GenerateMock<IGuestDao>();
                IGuestEventDao guestEventDao = MockRepository.GenerateMock<IGuestEventDao>();

                GuestManager GuestManager = new GuestManager();
                GuestManager.GuestDao = guestDao;
                GuestManager.GuestEventDao = guestEventDao;

                guestDao.Expect(x => x.Modify(Arg<Guest>.Is.Anything));

                guestEventDao.Expect(eDao => eDao.Create(Arg<GuestEvent>.Matches(ge => ge.GuestEventType == GuestEventType.Modified && ge.GuestId == 1)));
                
                // Guest record
                Guest updatedGuest = new Guest {Id = 1, BusinessId = 1, Surname = "Test", CountryId = 1};

                // Act
                // Modify Guest record
                GuestManager.Modify(updatedGuest);

                // Assert
                guestDao.VerifyAllExpectations();
                guestEventDao.VerifyAllExpectations();
            }