public void AuditoriumService_DeleteAuditorium_AuditoriumResultModel_Successful()
        {
            //Arrange
            Auditorium auditorium = _auditorium;
            IEnumerable <Projection> projections = null;
            IEnumerable <Seat>       seats       = null;

            _mockAuditoriumsRepository = new Mock <IAuditoriumsRepository>();
            Task <Auditorium> responseTaskAuditoriumsRepository = Task.FromResult(auditorium);

            _mockAuditoriumsRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).Returns(responseTaskAuditoriumsRepository);
            _mockProjectionRepository = new Mock <IProjectionsRepository>();
            _mockProjectionRepository.Setup(x => x.GetAllOfSpecificAuditorium(It.IsAny <int>())).Returns(projections);
            _mockSeatsRepository = new Mock <ISeatsRepository>();
            _mockSeatsRepository.Setup(x => x.GetAllOfSpecificAuditorium(It.IsAny <int>())).Returns(seats);
            AuditoriumService auditoriumController = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockCinemasRepository.Object, _mockSeatsRepository.Object, _mockProjectionRepository.Object, _mockTicketService.Object);
            //Act
            var resultAction = auditoriumController.DeleteAuditorium(It.IsAny <int>()).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNotNull(resultAction);
            Assert.IsTrue(resultAction.IsSuccessful);
            Assert.IsNull(resultAction.ErrorMessage);
            Assert.IsInstanceOfType(resultAction, typeof(AuditoriumResultModel));
            Assert.AreEqual(auditorium.Name, resultAction.Auditorium.Name);
        }
        public void AuditoriumService_DeleteAuditorium_AuditoriumResultModel_PROJECTION_IN_FUTURE()
        {
            //Arrange
            AuditoriumResultModel expectedResultModel = new AuditoriumResultModel()
            {
                ErrorMessage = "Cannot delete projection as it is scheduled in the future. "
            };
            Auditorium auditorium = _auditorium;
            IEnumerable <Projection> projections = _listOfProjections;

            _mockAuditoriumsRepository = new Mock <IAuditoriumsRepository>();
            Task <Auditorium> responseTask = Task.FromResult(auditorium);

            _mockAuditoriumsRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).Returns(responseTask);
            _mockProjectionRepository = new Mock <IProjectionsRepository>();
            _mockProjectionRepository.Setup(x => x.GetAllOfSpecificAuditorium(It.IsAny <int>())).Returns(projections);
            AuditoriumService auditoriumController = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockCinemasRepository.Object, _mockSeatsRepository.Object, _mockProjectionRepository.Object, _mockTicketService.Object);

            //Act
            var resultAction = auditoriumController.DeleteAuditorium(It.IsAny <int>()).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNotNull(resultAction);
            Assert.IsFalse(resultAction.IsSuccessful);
            Assert.AreEqual(expectedResultModel.ErrorMessage, resultAction.ErrorMessage);
            Assert.IsInstanceOfType(resultAction, typeof(AuditoriumResultModel));
        }
        public void AuditoriumService_DeleteAuditorium_AuditoriumRepositoryReturnsNull_ReturnsNull()
        {
            //Arrange
            Auditorium nullAuditorium = null;

            List <ProjectionDomainModel> projectionsModelsList = new List <ProjectionDomainModel>();

            projectionsModelsList.Add(_projectionDomainModel);
            IEnumerable <ProjectionDomainModel>         projections             = projectionsModelsList;
            Task <IEnumerable <ProjectionDomainModel> > projectionsResponseTask = Task.FromResult(projections);

            List <SeatDomainModel> seatsModelsList = new List <SeatDomainModel>();

            seatsModelsList.Add(_seatDomainModel);
            IEnumerable <SeatDomainModel>         seats             = seatsModelsList;
            Task <IEnumerable <SeatDomainModel> > seatsResponseTask = Task.FromResult(seats);

            AuditoriumService auditoriumService = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockProjectionService.Object, _mockSeatService.Object);

            _mockProjectionService.Setup(x => x.DeleteByAuditoriumId(It.IsAny <int>())).Returns(projectionsResponseTask);
            _mockSeatService.Setup(x => x.DeleteByAuditoriumId(It.IsAny <int>())).Returns(seatsResponseTask);
            _mockAuditoriumsRepository.Setup(x => x.Delete(It.IsAny <int>())).Returns(nullAuditorium);

            //Act
            var result = auditoriumService.DeleteAuditorium(_auditorium.Id).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNull(result);
        }
        public void AuditoriumService_DeleteAuditorium_ReturnsDeletedAuditorium_ReturnsDeletedProjectionsAndSeats()
        {
            //Arrange
            List <ProjectionDomainModel> projectionsModelsList = new List <ProjectionDomainModel>();

            projectionsModelsList.Add(_projectionDomainModel);
            IEnumerable <ProjectionDomainModel>         projections             = projectionsModelsList;
            Task <IEnumerable <ProjectionDomainModel> > projectionsResponseTask = Task.FromResult(projections);

            List <SeatDomainModel> seatsModelsList = new List <SeatDomainModel>();

            seatsModelsList.Add(_seatDomainModel);
            IEnumerable <SeatDomainModel>         seats             = seatsModelsList;
            Task <IEnumerable <SeatDomainModel> > seatsResponseTask = Task.FromResult(seats);

            AuditoriumService auditoriumService = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockProjectionService.Object, _mockSeatService.Object);

            _mockProjectionService.Setup(x => x.DeleteByAuditoriumId(It.IsAny <int>())).Returns(projectionsResponseTask);
            _mockSeatService.Setup(x => x.DeleteByAuditoriumId(It.IsAny <int>())).Returns(seatsResponseTask);
            _mockAuditoriumsRepository.Setup(x => x.Delete(It.IsAny <int>())).Returns(_auditorium);

            //Act
            var result = auditoriumService.DeleteAuditorium(_auditorium.Id).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(AuditoriumDomainModel));
            Assert.IsNotNull(result.SeatsList);
            Assert.AreEqual(result.Id, _auditorium.Id);
        }
        public void AuditoriumService_DeleteAuditorium_AuditoriumResultModel_AUDITORIUM_DOES_NOT_EXIST()
        {
            //Arrange
            AuditoriumResultModel expectedResultModel = new AuditoriumResultModel()
            {
                ErrorMessage = "Auditorium does not exist."
            };
            Auditorium auditorium = null;

            _mockAuditoriumsRepository = new Mock <IAuditoriumsRepository>();
            Task <Auditorium> responseTask = Task.FromResult(auditorium);

            _mockAuditoriumsRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).Returns(responseTask);
            AuditoriumService auditoriumController = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockCinemasRepository.Object, _mockSeatsRepository.Object, _mockProjectionRepository.Object, _mockTicketService.Object);

            //Act
            var resultAction = auditoriumController.DeleteAuditorium(It.IsAny <int>()).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNotNull(resultAction);
            Assert.IsFalse(resultAction.IsSuccessful);
            Assert.AreEqual(expectedResultModel.ErrorMessage, resultAction.ErrorMessage);
            Assert.IsInstanceOfType(resultAction, typeof(AuditoriumResultModel));
        }