public void TakeClosestElevator_WhenOneElevatorAvailable_ReturnsElevatorAndThenNull()
        {
            // Arrange
            routeValidationServiceMock
            .Setup(x => x.IsFloorNumberCorrect(It.IsAny <int>()))
            .Returns(true);

            buildingConfigurationServiceMock
            .Setup(x => x.GetNumberOfElevators())
            .Returns(1);

            sut = new ElevatorPoolService(
                elevatorEventLogServiceMock.Object,
                buildingConfigurationServiceMock.Object,
                routeValidationServiceMock.Object);

            // Act
            var first  = sut.TakeClosestElevator(1);
            var second = sut.TakeClosestElevator(1);

            // Assert
            Assert.IsNotNull(first);
            Assert.IsNull(second);
            elevatorEventLogServiceMock.Verify(x => x.LogEvent(It.IsAny <ElevatorModel>(), It.IsAny <string>()), Times.Once);
        }
        public void ReleaseElevator_WhenIncorrectIdProvided_ThrowsException()
        {
            // Arrange
            buildingConfigurationServiceMock
            .Setup(x => x.GetNumberOfElevators())
            .Returns(1);

            sut = new ElevatorPoolService(
                elevatorEventLogServiceMock.Object,
                buildingConfigurationServiceMock.Object,
                routeValidationServiceMock.Object);

            // Act
            sut.ReleaseElevator(2);
        }
        public void Initialize()
        {
            elevatorEventLogServiceMock = new Mock <IElevatorEventLogService>();

            buildingConfigurationServiceMock = new Mock <IBuildingConfigurationService>();
            buildingConfigurationServiceMock
            .Setup(x => x.GetNumberOfElevators())
            .Returns(2);

            routeValidationServiceMock = new Mock <IRouteValidationService>();

            sut = new ElevatorPoolService(
                elevatorEventLogServiceMock.Object,
                buildingConfigurationServiceMock.Object,
                routeValidationServiceMock.Object);
        }
        public void ReleaseElevator_WhenElevatorIsNotOccupied_DoesNotReleaseElevator()
        {
            // Arrange
            buildingConfigurationServiceMock
            .Setup(x => x.GetNumberOfElevators())
            .Returns(1);

            sut = new ElevatorPoolService(
                elevatorEventLogServiceMock.Object,
                buildingConfigurationServiceMock.Object,
                routeValidationServiceMock.Object);

            // Act
            sut.ReleaseElevator(0);

            // Assert
            elevatorEventLogServiceMock.Verify(x => x.LogEvent(It.IsAny <ElevatorModel>(), It.IsAny <string>()), Times.Never);
        }
        public void ReleaseElevator_WhenElevatorIsOccupied_ReleasesElevator()
        {
            // Arrange
            routeValidationServiceMock
            .Setup(x => x.IsFloorNumberCorrect(It.IsAny <int>()))
            .Returns(true);

            buildingConfigurationServiceMock
            .Setup(x => x.GetNumberOfElevators())
            .Returns(1);

            sut = new ElevatorPoolService(
                elevatorEventLogServiceMock.Object,
                buildingConfigurationServiceMock.Object,
                routeValidationServiceMock.Object);

            // Act
            sut.TakeClosestElevator(1);
            sut.ReleaseElevator(0);

            // Assert
            elevatorEventLogServiceMock.Verify(x => x.LogEvent(It.IsAny <ElevatorModel>(), It.IsAny <string>()), Times.Exactly(2));
        }