public void Add_ReturnCustomerViewModelTestAsync() { var customer = CustomerViewModelMock.GetCustomer(); _mapperMock.Setup(x => x.Map <Customer>(It.IsAny <CustomerViewModel>())) .Returns(CustomerMock.GetCustomer()); _mapperMock.Setup(x => x.Map <CustomerViewModel>(It.IsAny <Customer>())) .Returns(CustomerViewModelMock.GetCustomer()); _customerRepositoryMock.Setup(x => x.GetByNameAsync(customer.Name)) .ReturnsAsync(CustomerMock.GetCustomerAddress()); var customerService = new CustomerService(_customerRepositoryMock.Object, _viaCEPServiceMock.Object, _domainNotificationMock.Object, _unitOfWorkMock.Object, _mapperMock.Object); customerService.Add(customer); Assert.NotNull(customer); }
public async Task GetAddressByIdAsync_ReturnCustomerAddressViewModelTestAsync() { int id = 1; var customerId = CustomerViewModelMock.GetCustomerId(id); _customerRepositoryMock.Setup(x => x.GetAddressByIdAsync(id)) .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.GetAddressByIdAsync(customerId); var customerResult = Assert.IsAssignableFrom <CustomerAddressViewModel>(customeMethod); Assert.NotNull(customerResult); }
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); }