public async Task WhenDataExistsAndNewValuesAreNull_ItShouldSaveDataAndClearOriginalTransactionKey()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new SetUserPaymentOriginDbStatement(testDatabase);
                await this.CreateDataAsync(UserId, testDatabase, true);
                await testDatabase.TakeSnapshotAsync();

                await this.target.ExecuteAsync(
                    UserId,
                    null,
                    PaymentOriginKeyType.None,
                    null,
                    null,
                    null);

                return(new ExpectedSideEffects
                {
                    Update = new UserPaymentOrigin(
                        UserId.Value,
                        null,
                        null,
                        PaymentOriginKeyType.None,
                        null,
                        null,
                        null,
                        null,
                        PaymentStatus)
                });
            });
        }
        public async Task WhenValuesAreNull_ItShouldSaveData()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new SetUserPaymentOriginDbStatement(testDatabase);
                await this.CreateDataAsync(UserId, testDatabase, false);
                await testDatabase.TakeSnapshotAsync();

                await this.target.ExecuteAsync(
                    UserId,
                    null,
                    PaymentOriginKeyType.None,
                    null,
                    null,
                    null);

                return(new ExpectedSideEffects
                {
                    Insert = new UserPaymentOrigin(
                        UserId.Value,
                        null,
                        null,
                        PaymentOriginKeyType.None,
                        null,
                        null,
                        null,
                        null,
                        default(PaymentStatus))
                });
            });
        }
        public async Task WhenDataExistsAndNewValuesArePopulated_ItShouldSaveDataAndClearOriginalTransactionKey()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new SetUserPaymentOriginDbStatement(testDatabase);
                await this.CreateDataAsync(UserId, testDatabase, true);
                await testDatabase.TakeSnapshotAsync();

                await this.target.ExecuteAsync(
                    UserId,
                    PaymentOriginKey,
                    PaymentOriginKeyType,
                    CountryCode,
                    CreditCardPrefix,
                    IpAddress);

                return(new ExpectedSideEffects
                {
                    Update = new UserPaymentOrigin(
                        UserId.Value,
                        null,
                        PaymentOriginKey,
                        PaymentOriginKeyType,
                        CountryCode.Value,
                        CreditCardPrefix.Value,
                        IpAddress.Value,
                        null,
                        PaymentStatus)
                });
            });
        }
        public async Task WhenValuesArePopulated_ItShouldSaveData()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new SetUserPaymentOriginDbStatement(testDatabase);
                await this.CreateDataAsync(UserId, testDatabase, false);
                await testDatabase.TakeSnapshotAsync();

                await this.target.ExecuteAsync(
                    UserId,
                    PaymentOriginKey,
                    PaymentOriginKeyType,
                    CountryCode,
                    CreditCardPrefix,
                    IpAddress);

                return(new ExpectedSideEffects
                {
                    Insert = new UserPaymentOrigin(
                        UserId.Value,
                        null,
                        PaymentOriginKey,
                        PaymentOriginKeyType,
                        CountryCode.Value,
                        CreditCardPrefix.Value,
                        IpAddress.Value,
                        null,
                        default(PaymentStatus))
                });
            });
        }
 public void Initialize()
 {
     this.target = new SetUserPaymentOriginDbStatement(new Mock <FifthweekDbConnectionFactory>(MockBehavior.Strict).Object);
 }