public async Task ItShouldReturnSubsetOfResultsForSubscriber1() { await this.DatabaseTestAsync(async testDatabase => { this.target = new GetCalculatedAccountBalancesDbStatement(testDatabase); var userIds = await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); // Two fewer results at the end, and one fewer at the beginning as we select first // result in front of timestamp. var result = await this.target.ExecuteAsync(SubscriberId1, LedgerAccountType.Stripe, Now.AddHours(18).AddDays(1), Now.AddDays(Days - 2)); Assert.AreEqual(Days - 3, result.Count); result = result.OrderBy(v => v.Timestamp).ToList(); for (int i = 0; i < result.Count; i++) { Assert.AreEqual(SubscriberId1, result[i].UserId); Assert.AreEqual(LedgerAccountType.Stripe, result[i].AccountType); Assert.AreEqual(Now.AddDays(i + 1), result[i].Timestamp); Assert.IsTrue(result[i].Timestamp.Kind == DateTimeKind.Utc); Assert.AreEqual(i + 1 + 0.25m, result[i].Amount); } return(ExpectedSideEffects.None); }); }
public async Task ItShouldReturnAllResultsForSubscriber2() { await this.DatabaseTestAsync(async testDatabase => { this.target = new GetCalculatedAccountBalancesDbStatement(testDatabase); var userIds = await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(SubscriberId2, LedgerAccountType.Stripe, Now, Now.AddDays(Days)); Assert.AreEqual(Days, result.Count); result = result.OrderBy(v => v.Timestamp).ToList(); for (int i = 0; i < result.Count; i++) { Assert.AreEqual(SubscriberId2, result[i].UserId); Assert.AreEqual(LedgerAccountType.Stripe, result[i].AccountType); Assert.AreEqual(Now.AddDays(i).AddHours(12), result[i].Timestamp); Assert.IsTrue(result[i].Timestamp.Kind == DateTimeKind.Utc); Assert.AreEqual(i + 0.75m, result[i].Amount); } 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 GetCalculatedAccountBalancesDbStatement(new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object); }