public async Task SaveEntity_SavesEntity()
        {
            var encryptedCardNumber = false;
            var service = SetupService();
            var encryptionService = new MockEncryptionService();
            encryptionService.EncryptMessageDelegate = s =>
                                                           {
                                                               Assert.AreEqual("12345", s);
                                                               encryptedCardNumber = true;
                                                               return Task.FromResult<IBuffer>(null);
                                                           };
            encryptionService.DecryptMessageDelegate = buffer => Task.FromResult("1111");

            var target = new CheckoutDataRepository(service, encryptionService);

            var savedShippingAddress = target.SaveShippingAddress(new Address() { FirstName = "TestFirstName", LastName = "TestLastName" });
            var savedBillingAddress = target.SaveBillingAddress(new Address() { FirstName = "TestFirstName", LastName = "TestLastName" });
            var savedPaymentMethod = await target.SavePaymentMethodAsync(new PaymentMethod() { CardholderName = "TestCardholderName", CardNumber = "12345"});

            Assert.IsNotNull(savedShippingAddress);
            Assert.IsNotNull(savedBillingAddress);
            Assert.IsNotNull(savedPaymentMethod);

            var shippingAddress = target.GetShippingAddress(savedShippingAddress.Id);
            var billingAddress = target.GetBillingAddress(savedBillingAddress.Id);
            var paymentMethod = await target.GetPaymentMethodAsync(savedPaymentMethod.Id);
            
            Assert.AreEqual(savedShippingAddress.Id, shippingAddress.Id);
            Assert.AreEqual(savedBillingAddress.Id, billingAddress.Id);
            Assert.AreEqual(savedPaymentMethod.Id, paymentMethod.Id);

            Assert.IsTrue(encryptedCardNumber);
        }
        public async Task GetAllEntities_Returns_AllEntities()
        {
            var service = SetupService();
            var encryptionService = new MockEncryptionService();
            encryptionService.DecryptMessageDelegate = buffer => Task.FromResult("1234");
            var target = new CheckoutDataRepository(service, encryptionService);

            var shippingAddresses = target.GetAllShippingAddresses();
            var bilingAddresses = target.GetAllBillingAddresses();
            var paymentMethods = await target.GetAllPaymentMethodsAsync();

            Assert.AreEqual(3, shippingAddresses.Count());
            Assert.AreEqual(2, bilingAddresses.Count());
            Assert.AreEqual(1, paymentMethods.Count());
        }
        public async Task GetEntity_Returns_Entity()
        {
            var service = SetupService();
            var encryptionService = new MockEncryptionService();
            encryptionService.DecryptMessageDelegate = buffer => Task.FromResult("1234");
            var target = new CheckoutDataRepository(service, encryptionService);

            var shippingAddress = target.GetShippingAddress("3");
            var bilingAddress = target.GetBillingAddress("2");
            var paymentMethod = await target.GetPaymentMethodAsync("1");

            Assert.AreEqual(shippingAddress.FirstName, "Anne");
            Assert.AreEqual(bilingAddress.FirstName, "Jane");
            Assert.AreEqual(paymentMethod.CardholderName, "John Doe");
        }
        public async Task GetDefaultValues_Returns_DefaultValues()
        {
            var service = SetupService();
            var encryptionService = new MockEncryptionService();
            encryptionService.DecryptMessageDelegate = buffer => Task.FromResult("1234");
            var target = new CheckoutDataRepository(service, encryptionService);

            var defaultShippingAddress = target.GetDefaultShippingAddress();
            var defaultBilingAddress = target.GetDefaultBillingAddress();
            var defaultPaymentMethod = await target.GetDefaultPaymentMethodAsync();

            Assert.IsNotNull(defaultShippingAddress);
            Assert.AreEqual(defaultShippingAddress.Id, "3");
            Assert.IsNotNull(defaultBilingAddress);
            Assert.AreEqual(defaultBilingAddress.Id, "2");
            Assert.IsNull(defaultPaymentMethod);
        }
        public async Task RemoveDefaultEntity_RemovesDefaultEntity()
        {
            var service = SetupService();
            var encryptionService = new MockEncryptionService();
            encryptionService.DecryptMessageDelegate = buffer => Task.FromResult("1234");
            var target = new CheckoutDataRepository(service, encryptionService);
            target.SetDefaultPaymentMethod(await target.GetPaymentMethodAsync("1"));

            var defaultShippingAddress = target.GetDefaultShippingAddress();
            var defaultBillingAddress = target.GetDefaultBillingAddress();
            var defaultPaymentMethod = await target.GetDefaultPaymentMethodAsync();

            Assert.IsNotNull(defaultShippingAddress);
            Assert.IsNotNull(defaultBillingAddress);
            Assert.IsNotNull(defaultPaymentMethod);

            target.RemoveDefaultShippingAddress();
            target.RemoveDefaultBillingAddress();
            target.RemoveDefaultPaymentMethod();

            defaultShippingAddress = target.GetDefaultShippingAddress();
            defaultBillingAddress = target.GetDefaultBillingAddress();
            defaultPaymentMethod = await target.GetDefaultPaymentMethodAsync();

            Assert.IsNull(defaultShippingAddress);
            Assert.IsNull(defaultBillingAddress);
            Assert.IsNull(defaultPaymentMethod);
        }