public void Given_When_Accounts_Should_Return_CustomersAccounts() { //arrange var account = new Account { Id = 1, Balance = 50, FriendlyName = "FriendlyName", Number = "BankAccountNumer" }; var customer1 = new Customer { Id = 1, Name = "CustomerName1", Surname = "CustomerSurname1", Accounts = new List <Account> { account } }; var customer2 = new Customer { Id = 2, Name = "CustomerName2", Surname = "CustomerSurname2" }; var customers = new List <Customer> { customer1, customer2 }; _dataProviderMock.Setup(d => d.Get()).Returns(customers); //act var expectedCustomerAccounts = _customerService.Accounts(customer1.Id); var customerAccount = expectedCustomerAccounts.FirstOrDefault(); //assert Assert.NotNull(expectedCustomerAccounts); Assert.AreEqual(expectedCustomerAccounts.Count(), 1); Assert.AreEqual(customerAccount.Id, account.Id); Assert.AreEqual(customerAccount.Number, account.Number); Assert.AreEqual(customerAccount.FriendlyName, account.FriendlyName); Assert.AreEqual(customerAccount.Balance, account.Balance); }
public CustomerAccountsResponse ListCustomerAccounts(int customerId) { var customerAccounts = _customerService.Accounts(customerId); var customerAccountsResponse = new CustomerAccountsResponse { CustomerAccounts = customerAccounts.ToList() }; return(customerAccountsResponse); }