Exemple #1
0
            public void DeleteRoomWithInvalidBusinessdExpectExceptionThrown()
            {
                // Arrange
                const long BUSINESS_ID = 0;
                const int ROOM_ID = 1;
                var roomManager = new RoomManager();

                try
                {
                    // Act
                    roomManager.Delete(ROOM_ID, BUSINESS_ID);

                    // Assert
                    Assert.Fail("An exception SRVEX30075 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual(Errors.SRVEX30075.ToString(), ex.Code,
                                    "The Validation exception is not returning the right error code");
                }
            }
Exemple #2
0
            public void DeleteRoomWithForwardBookingsStartDateThrowsException()
            {
                // Arrange
                Room roomToDelete = new Room
                {
                    Id = VALID_ROOM_ID,
                    BusinessId = VALID_BUSINESS_ID,
                    Name = "Name"
                };

                IBookingManager bookingManager = MockRepository.GenerateMock<IBookingManager>();
                bookingManager.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(VALID_ROOM_ID), Arg<string>.Is.Anything))
                              .Return(new List<Booking>
                                          {
                                              new Booking
                                              {
                                                  EndDate = DateTime.UtcNow.AddDays(15),
                                                  StartDate = DateTime.UtcNow.AddDays(5)
                                              }
                                          });

                RoomManager roomManager = new RoomManager
                {
                    BookingManager = bookingManager
                };

                try
                {
                    // Act
                    roomManager.Delete(roomToDelete.Id, roomToDelete.BusinessId);
                    Assert.Fail("Validation exception should have been thrown");
                }
                catch (ValidationException vex)
                {
                    // Assert
                    Assert.AreEqual(Errors.SRVEX30097.ToString(), vex.Code,
                                    "Validation exception SRVEX30097 should have been thrown because of bookings");
                    bookingManager.VerifyAllExpectations();
                }
            }
Exemple #3
0
            public void DeleteRoomExpectSuccess()
            {
                // Arrange
                const long BUSINESS_ID = 1;
                const int ROOM_ID = 1;
                var mockRoomDao = MockRepository.GenerateMock<IRoomDao>();
                var mockBusinessEventDao = MockRepository.GenerateMock<IEventTrackingManager>();
                IBookingManager mockBookingManager = MockRepository.GenerateMock<IBookingManager>();
                mockBookingManager.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(ROOM_ID), Arg<string>.Is.Anything))
                              .Return(new List<Booking>
                                          {
                                              // booking in past
                                              new Booking
                                              {
                                                  EndDate = DateTime.UtcNow.AddDays(-5),
                                                  StartDate = DateTime.UtcNow.AddDays(-15)
                                              }
                                          });

                mockRoomDao.Expect(rt => rt.Delete(ROOM_ID)).Return(true);
                mockBusinessEventDao.Expect(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RoomDeleted, ROOM_ID.ToString(CultureInfo.DefaultThreadCurrentCulture)));

                var roomManager = new RoomManager 
                { 
                    RoomDao = mockRoomDao, 
                    EventTrackingManager = mockBusinessEventDao,
                    BookingManager = mockBookingManager
                };
                
                // Act
                roomManager.Delete(ROOM_ID,BUSINESS_ID);

                // Assert
                mockRoomDao.VerifyAllExpectations();
                mockBusinessEventDao.VerifyAllExpectations();
            }