public async void GetCustomer_ReturnsCustomer() { //Arrange var mapper = new MapperConfiguration(cfg => cfg.AddProfile <CustomerProfile>()) .CreateMapper(); var mockLogger = new Mock <ILogger <CustomerServiceWCF> >(); var mockCustomerService = new Mock <CustomerService.ICustomerService>(); mockCustomerService.Setup(x => x.GetCustomerAsync(It.IsAny <CustomerService.GetCustomerRequest>())) .ReturnsAsync(new CustomerService.GetCustomerResponseGetCustomerResult { Customer = new CustomerService.Customer1 { AccountNumber = "1" } }); var sut = new CustomerServiceWCF( mockLogger.Object, mapper, mockCustomerService.Object ); //Act var response = await sut.GetCustomerAsync(new GetCustomerRequest()); //Assert mockCustomerService.Verify(x => x.GetCustomerAsync(It.IsAny <CustomerService.GetCustomerRequest>())); response.Customer.AccountNumber.Should().Be("1"); }
public async void DeleteCustomerAddress_OK() { //Arrange var mapper = new MapperConfiguration(cfg => cfg.AddProfile <CustomerProfile>()) .CreateMapper(); var mockLogger = new Mock <ILogger <CustomerServiceWCF> >(); var mockCustomerService = new Mock <CustomerService.ICustomerService>(); var sut = new CustomerServiceWCF( mockLogger.Object, mapper, mockCustomerService.Object ); //Act await sut.DeleteCustomerAddressAsync(new DeleteCustomerAddressRequest()); //Assert mockCustomerService.Verify(x => x.DeleteCustomerAddressAsync(It.IsAny <CustomerService.DeleteCustomerAddressRequest>())); }
public async void ListCustomers_ReturnsCustomers() { //Arrange var mapper = new MapperConfiguration(cfg => cfg.AddProfile <CustomerProfile>()) .CreateMapper(); var mockLogger = new Mock <ILogger <CustomerServiceWCF> >(); var mockCustomerService = new Mock <CustomerService.ICustomerService>(); mockCustomerService.Setup(x => x.ListCustomersAsync(It.IsAny <CustomerService.ListCustomersRequest>())) .ReturnsAsync(new CustomerService.ListCustomersResponseListCustomersResult { Customers = new CustomerService.Customer[] { new CustomerService.Customer { AccountNumber = "1" }, new CustomerService.Customer { AccountNumber = "2" } }, TotalCustomers = 2 }); var sut = new CustomerServiceWCF( mockLogger.Object, mapper, mockCustomerService.Object ); //Act var response = await sut.ListCustomersAsync(new ListCustomersRequest()); //Assert mockCustomerService.Verify(x => x.ListCustomersAsync(It.IsAny <CustomerService.ListCustomersRequest>())); response.TotalCustomers.Should().Be(2); response.Customers[0].AccountNumber.Should().Be("1"); response.Customers[1].AccountNumber.Should().Be("2"); }