예제 #1
0
        public async Task ItShouldReturnAllResultsForCreator2()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new GetCreatorChannelsSnapshotsDbStatement(testDatabase);

                var userIds = await this.CreateDataAsync(testDatabase);
                await testDatabase.TakeSnapshotAsync();

                var result = await this.target.ExecuteAsync(CreatorId2, 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(CreatorId2, result[i].CreatorId);
                    Assert.AreEqual(Now.AddDays(i).AddHours(12), result[i].Timestamp);
                    Assert.IsTrue(result[i].Timestamp.Kind == DateTimeKind.Utc);
                    Assert.AreEqual(200 + i, result[i].CreatorChannels[0].Price);
                    Assert.AreEqual(200 + i, result[i].CreatorChannels[1].Price);
                }

                return(ExpectedSideEffects.None);
            });
        }
예제 #2
0
        public async Task ItShouldReturnSubsetOfResultsForCreator1()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new GetCreatorChannelsSnapshotsDbStatement(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(CreatorId1, 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(CreatorId1, result[i].CreatorId);
                    Assert.AreEqual(Now.AddDays(i + 1), result[i].Timestamp);
                    Assert.IsTrue(result[i].Timestamp.Kind == DateTimeKind.Utc);
                    Assert.AreEqual(100 + i + 1, result[i].CreatorChannels[0].Price);
                    Assert.AreEqual(100 + i + 1, result[i].CreatorChannels[1].Price);
                }

                return(ExpectedSideEffects.None);
            });
        }
예제 #3
0
 public void Test()
 {
     this.target = new GetCreatorChannelsSnapshotsDbStatement(new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object);
 }