public async Task GetAll_SucessTestAsync() { _customerServiceMock.Setup(x => x.GetAllAsync()) .ReturnsAsync(CustomerViewModelMock.GetCustomersAddress()); var customerController = new CustomerController(_customerServiceMock.Object); var customerService = await customerController.List(); var actionResult = Assert.IsType <OkObjectResult>(customerService.Result); var actionValue = Assert.IsAssignableFrom <IEnumerable <CustomerAddressViewModel> >(actionResult.Value); Assert.NotNull(actionResult); Assert.Equal(StatusCodes.Status200OK, actionResult.StatusCode); }
public async Task GetAll_ReturnCustomerAddressViewModelTestAsync() { var cep = "17052520"; _customerRepositoryMock.Setup(x => x.GetAllAsync()) .ReturnsAsync(CustomerMock.GetCustomersAddress()); _mapperMock.Setup(x => x.Map <IEnumerable <CustomerAddressViewModel> >(It.IsAny <IEnumerable <CustomerAddress> >())) .Returns(CustomerViewModelMock.GetCustomersAddress()); _viaCEPServiceMock.Setup(x => x.GetByCEPAsync(cep)) .ReturnsAsync(ViaCEPMock.GetCEP()); var customerService = new CustomerService(_customerRepositoryMock.Object, _viaCEPServiceMock.Object, _domainNotificationMock.Object, _unitOfWorkMock.Object, _mapperMock.Object); var customeMethod = await customerService.GetAllAsync(); var customerResult = Assert.IsAssignableFrom <IEnumerable <CustomerAddressViewModel> >(customeMethod); Assert.NotNull(customerResult); Assert.NotEmpty(customerResult); }