public async Task PostRoomShouldCreateRoom()
        {
            //arrange
            var mockRepo   = new Mock <IRepository>();
            var mockLogger = new Mock <ILogger <ComplexController> >();

            mockRepo.Setup(r => r.CreateRoomAsync(
                               It.IsAny <Lib.Room>()
                               ));

            var controller = new ComplexController(mockRepo.Object, mockLogger.Object);

            //act
            var roomTest = new Revature.Room.Lib.Room
            {
                ComplexId         = Guid.NewGuid(),
                RoomId            = Guid.NewGuid(),
                RoomNumber        = "ABC",
                NumberOfBeds      = 4,
                NumberOfOccupants = 4,
                Gender            = "Male",
                RoomType          = "Apartment"
            };

            roomTest.SetLease(DateTime.Now, DateTime.Today.AddDays(3));
            var result = await controller.PostRoomAsync(roomTest);

            //assert
            Assert.IsAssignableFrom <CreatedAtRouteResult>(result);
        }
예제 #2
0
        public void RoomShouldCreate()
        {
            var newRoom = new BL.Room()
            {
                RoomId            = _newRoomId,
                ComplexId         = _newComplexId,
                Gender            = _newGender,
                RoomNumber        = _newRoomNumber,
                RoomType          = _newRoomType,
                NumberOfBeds      = _newNumOfBeds,
                NumberOfOccupants = _newNumOfOccupants
            };

            newRoom.SetLease(_newLeaseStart, _newLeaseEnd);
            Assert.NotNull(newRoom);
            Assert.True(newRoom.RoomId == _newRoomId);
            Assert.True(newRoom.ComplexId == _newComplexId);
            Assert.True(newRoom.Gender == _newGender);
            Assert.True(newRoom.RoomNumber == _newRoomNumber);
            Assert.True(newRoom.RoomType == _newRoomType);
            Assert.True(newRoom.NumberOfBeds == _newNumOfBeds);
            Assert.True(newRoom.NumberOfOccupants == _newNumOfOccupants);
            Assert.True(newRoom.LeaseStart == _newLeaseStart);
            Assert.True(newRoom.LeaseEnd == _newLeaseEnd);
        }
예제 #3
0
        public void RoomShouldRejectInvalidNumberOfOccupants()
        {
            Assert.Throws <ArgumentException>(() => new BL.Room()
            {
                NumberOfOccupants = -1
            });

            var room = new BL.Room()
            {
                NumberOfBeds = 2
            };

            Assert.Throws <ArgumentException>(() => room.NumberOfOccupants = 3);
        }
예제 #4
0
        /* End of Room Properties */

        // Use to set up a valid business logic Room
        private BusinessLogic.Room PresetBLRoom()
        {
            var room = new BusinessLogic.Room
            {
                RoomId            = _newRoomId,
                ComplexId         = _newComplexId,
                Gender            = _newGender,
                RoomNumber        = _newRoomNumber,
                RoomType          = _newRoomType,
                NumberOfBeds      = _newNumOfBeds,
                NumberOfOccupants = _newNumOfOccupants,
            };

            room.SetLease(_newLeaseStart, _newLeaseEnd);
            return(room);
        }