public async Task CachedAddressesAndPaymentMethodsExpire_WhenUserChanged() { var accountService = new MockAccountService(); var target = new CheckoutDataRepository(SetupAddressService(), SetupPaymentMethodService(), accountService); var paymentMethods = await target.GetAllPaymentMethodsAsync(); Assert.AreSame(await target.GetAllPaymentMethodsAsync(), paymentMethods, "Cached data should be same."); accountService.RaiseUserChanged(null, null); Assert.AreNotSame(await target.GetAllPaymentMethodsAsync(), paymentMethods); }
public async Task GetAllPaymentMethodsAsync_ReturnsEmptyCollection_WhenServiceReturnsNull() { var paymentMethodService = new MockPaymentMethodService(); paymentMethodService.PaymentMethods = null; var target = new CheckoutDataRepository(null, paymentMethodService, null); var paymentMethods = await target.GetAllPaymentMethodsAsync(); Assert.IsNotNull(paymentMethods); Assert.AreEqual(0, paymentMethods.Count); }
public async Task GetAllEntities_Returns_AllEntities() { var target = new CheckoutDataRepository(SetupAddressService(), SetupPaymentMethodService(), null); var shippingAddresses = await target.GetAllShippingAddressesAsync(); var bilingAddresses = await target.GetAllBillingAddressesAsync(); var paymentMethods = await target.GetAllPaymentMethodsAsync(); Assert.AreEqual(3, shippingAddresses.Count()); Assert.AreEqual(2, bilingAddresses.Count()); Assert.AreEqual(1, paymentMethods.Count()); }