public async Task WhenUserIdIsNotNull_ItShouldUpdateSpecifiedUser() { await this.DatabaseTestAsync(async testDatabase => { this.target = new UpdateAccountBalancesDbStatement(testDatabase); // We have to run it once to exclude for all the seed data that has been inserted. await this.target.ExecuteAsync(null, Now.AddSeconds(-0.1)); await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); var inserts = new List <CalculatedAccountBalance> { new CalculatedAccountBalance(SubscriberId2.Value, LedgerAccountType.Stripe, Now, -60m), new CalculatedAccountBalance(SubscriberId2.Value, LedgerAccountType.SalesTax, Now, 10m), new CalculatedAccountBalance(SubscriberId2.Value, LedgerAccountType.FifthweekCredit, Now, 5m), }; var expected = ToExpectedResult(inserts); var result = await this.target.ExecuteAsync(SubscriberId2, Now); CollectionAssert.AreEquivalent(expected, result.ToList()); return(new ExpectedSideEffects { Inserts = inserts }); }); }
public async Task WhenDataHasNotChanged_ItShouldNotInsertAnyRecords() { await this.DatabaseTestAsync(async testDatabase => { this.target = new UpdateAccountBalancesDbStatement(testDatabase); await this.CreateDataAsync(testDatabase); await this.target.ExecuteAsync(null, Now.AddSeconds(-0.1)); await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(null, Now); Assert.AreEqual(0, result.Count); return(ExpectedSideEffects.None); }); }
private void InitializeServices(TestDatabaseContext testDatabase) { this.updateAccountBalances = new UpdateAccountBalancesDbStatement(testDatabase); this.getAccountSettings = new GetAccountSettingsDbStatement(testDatabase); this.getCreatorRevenue = new GetCreatorRevenueDbStatement(testDatabase); this.persistCreditRefund = new PersistCreditRefund( new GuidCreator(), new PersistCommittedRecordsDbStatement(testDatabase)); this.createTransactionRefund = new CreateTransactionRefund( new GuidCreator(), new GetRecordsForTransactionDbStatement(testDatabase), new PersistCommittedRecordsDbStatement(testDatabase)); this.getCreditTransactionInformation = new GetCreditTransactionInformation( new GetRecordsForTransactionDbStatement(testDatabase)); this.getCalculatedAccountBalances = new GetCalculatedAccountBalancesDbStatement(testDatabase); }
public void Initialize() { this.target = new UpdateAccountBalancesDbStatement(new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object); }