public void AuditoriumService_GetAllAuditoriums_ReturnsListOfAuditoriums()
        {
            //Arrange
            var expectedCount = 2;

            Auditorium auditorium2 = new Auditorium
            {
                Id        = 2,
                CinemaId  = 2,
                AuditName = "Stari auditorium"
            };

            List <Auditorium> auditoriums = new List <Auditorium>();

            auditoriums.Add(_auditorium);
            auditoriums.Add(auditorium2);

            List <AuditoriumDomainModel> auditoriumDomainModels = new List <AuditoriumDomainModel>();

            auditoriumDomainModels.Add(_auditoriumDomainModel);

            _mockAuditoriumRepository.Setup(x => x.GetAll()).ReturnsAsync(auditoriums);

            //Act
            var resultAction = _auditoriumService.GetAllAsync().ConfigureAwait(false).GetAwaiter().GetResult();
            var result       = resultAction.ToList();

            //Assert
            Assert.IsNotNull(resultAction);
            Assert.AreEqual(expectedCount, result.Count);
            Assert.AreEqual(result[0].Id, _auditoriumDomainModel.Id);
            Assert.IsInstanceOfType(result[0], typeof(AuditoriumDomainModel));
        }
Exemplo n.º 2
0
        public void AuditoriumsService_GetAllAsync_ReturnNull()
        {
            //Arrange
            IEnumerable <Auditorium>         auditoriums  = null;
            Task <IEnumerable <Auditorium> > responseTask = Task.FromResult(auditoriums);

            _mockAuditoriumsRepository = new Mock <IAuditoriumsRepository>();
            _mockAuditoriumsRepository.Setup(x => x.GetAll()).Returns(responseTask);
            AuditoriumService auditoriumController = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockCinemasRepository.Object, _mockSeatsRepository.Object, _mockProjectionRepository.Object, _mockTicketService.Object);
            //Act
            var resultAction = auditoriumController.GetAllAsync().ConfigureAwait(false).GetAwaiter().GetResult();
            var result       = (List <AuditoriumDomainModel>)resultAction;

            //Assert
            Assert.IsNull(result);
        }
        public void AuditoriumService_GetAllAsync_RepositoryReturnsNull_ReturnNull()
        {
            //Arrange
            IEnumerable <Auditorium>         auditoriums  = null;
            Task <IEnumerable <Auditorium> > responseTask = Task.FromResult(auditoriums);

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

            _mockAuditoriumsRepository.Setup(x => x.GetAll()).Returns(responseTask);

            //Act
            var result = auditoriumService.GetAllAsync().ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNull(result);
        }
Exemplo n.º 4
0
        public void AuditoriumsService_GetAllAsync_ReturnListOfAuditoriumDomainModel()
        {
            //Arrange
            int expectedResultCount = 1;
            IEnumerable <Auditorium>         auditoriums  = _listOFAuditoriums;
            Task <IEnumerable <Auditorium> > responseTask = Task.FromResult(auditoriums);

            _mockAuditoriumsRepository = new Mock <IAuditoriumsRepository>();
            _mockAuditoriumsRepository.Setup(x => x.GetAll()).Returns(responseTask);
            AuditoriumService auditoriumController = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockCinemasRepository.Object, _mockSeatsRepository.Object, _mockProjectionRepository.Object, _mockTicketService.Object);
            //Act
            var resultAction = auditoriumController.GetAllAsync().ConfigureAwait(false).GetAwaiter().GetResult();
            var result       = (List <AuditoriumDomainModel>)resultAction;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(expectedResultCount, result.Count);
            Assert.AreEqual(_auditorium.Id, result[0].Id);
            Assert.IsInstanceOfType(result[0], typeof(AuditoriumDomainModel));
        }
        public void AuditoriumService_GetAllAsync_ReturnsListOfAllAuditoriums()
        {
            //Arrange
            List <Auditorium> auditoriumsModelsList = new List <Auditorium>();

            auditoriumsModelsList.Add(_auditorium);
            IEnumerable <Auditorium>         auditoriums  = auditoriumsModelsList;
            Task <IEnumerable <Auditorium> > responseTask = Task.FromResult(auditoriums);
            int expectedCount = 1;

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

            _mockAuditoriumsRepository.Setup(x => x.GetAll()).Returns(responseTask);

            //Act
            var result = auditoriumService.GetAllAsync().ConfigureAwait(false).GetAwaiter().GetResult().ToList();

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(expectedCount, result.Count);
            Assert.IsInstanceOfType(result[0], typeof(AuditoriumDomainModel));
            Assert.AreEqual(result[0].Id, _auditorium.Id);
        }