Example #1
0
        public async Task GetAllTest()
        {
            _repoWrapper.Setup(r => r.Gender.GetAllAsync(null, null)).ReturnsAsync(new List <Gender>().AsQueryable());

            var service = new GenderService(_repoWrapper.Object, _mapper.Object);

            _mapper.Setup(x => x.Map <Gender, GenderDTO>(It.IsAny <Gender>())).Returns(new GenderDTO());
            // Act
            var result = await service.GetAllAsync();

            // Assert
            Assert.NotNull(result);
            Assert.IsAssignableFrom <IEnumerable <GenderDTO> >(result);
        }
Example #2
0
        public async Task TestGetAllNoResults()
        {
            // Arrange
            var timeSlots = new List <Gender>();

            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork
            .Setup(x => x.GenderRepository.GetAllAsync(It.IsAny <bool>()))
            .ReturnsAsync(timeSlots);

            var service = new GenderService(_mapper, mockUnitOfWork.Object);

            // Act
            var result = await service.GetAllAsync();

            // Assert
            Assert.NotNull(result);
            Assert.Empty(result);
            Assert.IsAssignableFrom <IEnumerable <GenderDTO> >(result);
        }
Example #3
0
        public async Task TestGetAll()
        {
            // Arrange
            var consultants = GenerateGenders();

            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork
            .Setup(x => x.GenderRepository.GetAllAsync(It.IsAny <bool>()))
            .ReturnsAsync(consultants);

            var service = new GenderService(_mapper, mockUnitOfWork.Object);

            // Act
            var result = await service.GetAllAsync();

            // Assert
            Assert.NotNull(result);
            Assert.Equal(2, result.Count());
            Assert.IsAssignableFrom <IEnumerable <GenderDTO> >(result);
        }