예제 #1
0
        public async Task GetAll()
        {
            // arrange
            var model = new List <GenderModel>()
            {
                new GenderModel(), new GenderModel()
            };

            _repository.Setup(x => x.GetAllAsync()).Returns(Task.FromResult <IEnumerable <GenderModel> >(model));

            // act
            var result = await _controller.GetAll();

            // assert
            _repository.Verify(x => x.GetAllAsync(), Times.Once);
            Assert.IsType <OkObjectResult>(result.Result);
            Assert.Same(model, (result.Result as OkObjectResult).Value);
        }
예제 #2
0
        public void GetAll_Test()
        {
            // Arrange
            var mockService = new Mock <IGenderService>();
            var controller  = new GenderController(mockService.Object);

            // Act
            IQueryable <GenderModel> response = controller.GetAll();

            // Assert
            Assert.IsNotNull(response);
        }