예제 #1
0
        public void AuditoriumService_UpdateAuditorium_Returns_AuditoriumResultModel_Successful()
        {
            //Arrange
            AuditoriumDomainModel    auditoriumDomainModel = _auditoriumDomainModel;
            Auditorium               auditorium            = _auditorium;
            IEnumerable <Projection> projections           = null;
            IEnumerable <Seat>       seats = null;

            _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);
            _mockAuditoriumsRepository = new Mock <IAuditoriumsRepository>();
            _mockAuditoriumsRepository.Setup(x => x.Update(It.IsAny <Auditorium>())).Returns(auditorium);
            AuditoriumService auditoriumController = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockCinemasRepository.Object, _mockSeatsRepository.Object, _mockProjectionRepository.Object, _mockTicketService.Object);
            //Act
            var resultAction = auditoriumController.UpdateAuditorium(auditoriumDomainModel).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNotNull(resultAction);
            Assert.IsTrue(resultAction.IsSuccessful);
            Assert.IsNull(resultAction.ErrorMessage);
            Assert.IsInstanceOfType(resultAction, typeof(AuditoriumResultModel));
            Assert.AreEqual(auditoriumDomainModel.Name, resultAction.Auditorium.Name);
        }
예제 #2
0
        public void AuditoriumService_UpdateAuditorium_Returns_AuditoriumResultModel_AuditoriumUpdateError_ProjectionInFuture()
        {
            //Arrange
            AuditoriumResultModel expectedResultModel = new AuditoriumResultModel()
            {
                ErrorMessage = "Unable to update auditorium, please make sure there no upcoming projections and then try again. "
            };
            AuditoriumDomainModel    auditoriumDomainModel = _auditoriumDomainModel;
            IEnumerable <Projection> projections           = _listOfProjections;

            _mockProjectionRepository = new Mock <IProjectionsRepository>();
            _mockProjectionRepository.Setup(x => x.GetAllOfSpecificAuditorium(It.IsAny <int>())).Returns(_listOfProjections);
            AuditoriumService auditoriumController = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockCinemasRepository.Object, _mockSeatsRepository.Object, _mockProjectionRepository.Object, _mockTicketService.Object);
            //Act
            var resultAction = auditoriumController.UpdateAuditorium(auditoriumDomainModel).ConfigureAwait(false).GetAwaiter().GetResult();

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