public async Task GetByName_HttpStatusCodeUnauthorizedTestAsync() { var name = "Diuor PleaBolosmakh"; var customerName = CustomerViewModelMock.GetCustomerName(name); var response = await _httpClient.GetAsync($"/api/v1/customers/name/{customerName}"); Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); }
public async Task GetByName_SucessTestAsync() { var name = "Zier Zuveiku"; var customerName = CustomerViewModelMock.GetCustomerName(name); _customerServiceMock.Setup(x => x.GetAddressByNameAsync(customerName)) .ReturnsAsync(CustomerViewModelMock.GetCustomerAddress()); var customerController = new CustomerController(_customerServiceMock.Object); var customerService = await customerController.Get(customerName); var actionResult = Assert.IsType <OkObjectResult>(customerService.Result); var actionValue = Assert.IsType <CustomerAddressViewModel>(actionResult.Value); Assert.NotNull(actionResult); Assert.Equal(StatusCodes.Status200OK, actionResult.StatusCode); }
public async Task GetAddressByNameAsync_ReturnCustomerAddressViewModelTestAsync() { var name = "Diuor PleaBolosmakh"; var customerName = CustomerViewModelMock.GetCustomerName(name); _customerRepositoryMock.Setup(x => x.GetByNameAsync(name)) .ReturnsAsync(CustomerMock.GetCustomerAddress()); _mapperMock.Setup(x => x.Map <CustomerAddressViewModel>(It.IsAny <CustomerAddress>())) .Returns(CustomerViewModelMock.GetCustomerAddress()); var customerService = new CustomerService(_customerRepositoryMock.Object, _viaCEPServiceMock.Object, _domainNotificationMock.Object, _unitOfWorkMock.Object, _mapperMock.Object); var customeMethod = await customerService.GetAddressByNameAsync(customerName); var customerResult = Assert.IsAssignableFrom <CustomerAddressViewModel>(customeMethod); Assert.NotNull(customerResult); }