public async Task ItShouldReturnAllResultsForSubscriber2() { await this.DatabaseTestAsync(async testDatabase => { this.target = new GetSubscriberChannelsSnapshotsDbStatement(testDatabase); var userIds = await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(SubscriberId2, 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].SubscriberId); Assert.AreEqual(Now.AddDays(i).AddHours(12), result[i].Timestamp); Assert.IsTrue(result[i].Timestamp.Kind == DateTimeKind.Utc); Assert.AreEqual(200 + i, result[i].SubscribedChannels[0].AcceptedPrice); Assert.AreEqual(200 + i, result[i].SubscribedChannels[1].AcceptedPrice); Assert.IsTrue(result[i].SubscribedChannels[0].SubscriptionStartDate.Kind == DateTimeKind.Utc); Assert.IsTrue(result[i].SubscribedChannels[1].SubscriptionStartDate.Kind == DateTimeKind.Utc); } return(ExpectedSideEffects.None); }); }
public async Task ItShouldReturnSubsetOfResultsForSubscriber1() { await this.DatabaseTestAsync(async testDatabase => { this.target = new GetSubscriberChannelsSnapshotsDbStatement(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, 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].SubscriberId); Assert.AreEqual(Now.AddDays(i + 1), result[i].Timestamp); Assert.IsTrue(result[i].Timestamp.Kind == DateTimeKind.Utc); Assert.AreEqual(100 + i + 1, result[i].SubscribedChannels[0].AcceptedPrice); Assert.AreEqual(100 + i + 1, result[i].SubscribedChannels[1].AcceptedPrice); Assert.IsTrue(result[i].SubscribedChannels[0].SubscriptionStartDate.Kind == DateTimeKind.Utc); Assert.IsTrue(result[i].SubscribedChannels[1].SubscriptionStartDate.Kind == DateTimeKind.Utc); } return(ExpectedSideEffects.None); }); }
public void Test() { this.target = new GetSubscriberChannelsSnapshotsDbStatement(new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object); }