public async Task WhenUserIdDoesNotExist_ItShouldReturnAnEmptyResultList() { await this.DatabaseTestAsync(async testDatabase => { this.target = new GetUserSubscriptionsDbStatement(testDatabase); await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(new UserId(Guid.NewGuid())); Assert.AreEqual(0, result.Blogs.Count); Assert.AreEqual(0, result.FreeAccessChannelIds.Count); return(ExpectedSideEffects.None); }); }
public void TestInitialize() { this.target = new GetUserSubscriptionsDbStatement(new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object); }
public async Task WhenUserIdExists_ItShouldReturnTheBlogSubscriptions() { await this.DatabaseTestAsync(async testDatabase => { this.target = new GetUserSubscriptionsDbStatement(testDatabase); await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(UserId); Assert.AreEqual(3, result.Blogs.Count); Assert.AreEqual(3, result.FreeAccessChannelIds.Count); CollectionAssert.AreEquivalent( Blog1ChannelIds.Concat(Blog2ChannelIds).ToList(), result.FreeAccessChannelIds.ToList()); var blog1 = result.Blogs.First(v => v.BlogId.Equals(Blog1Id)); var blog2 = result.Blogs.First(v => v.BlogId.Equals(Blog2Id)); var blog3 = result.Blogs.First(v => v.BlogId.Equals(Blog3Id)); Assert.IsTrue(blog1.FreeAccess); Assert.IsTrue(blog2.FreeAccess); Assert.IsFalse(blog3.FreeAccess); Assert.AreEqual(0, blog1.Channels.Count); Assert.AreEqual(1, blog2.Channels.Count); Assert.AreEqual(2, blog3.Channels.Count); Assert.IsTrue(blog1.Name.Length > 0); Assert.IsTrue(blog2.Name.Length > 0); Assert.IsTrue(blog3.Name.Length > 0); Assert.AreEqual(Creator1Id, blog1.CreatorId); Assert.AreEqual(Creator2Id, blog2.CreatorId); Assert.AreEqual(Creator3Id, blog3.CreatorId); Assert.AreEqual(blog1.ProfileImageFileId, Creator1ProfileImageFileId); Assert.IsNull(blog2.ProfileImageFileId); Assert.IsNull(blog3.ProfileImageFileId); Assert.IsTrue(blog1.CreatorUsername.Value.Length > 0); Assert.IsTrue(blog2.CreatorUsername.Value.Length > 0); Assert.IsTrue(blog3.CreatorUsername.Value.Length > 0); var blog2Channel1 = blog2.Channels.First(v => v.ChannelId.Equals(Blog2ChannelIds[0])); var blog3Channel1 = blog3.Channels.First(v => v.ChannelId.Equals(Blog3ChannelIds[0])); var blog3Channel3 = blog3.Channels.First(v => v.ChannelId.Equals(Blog3ChannelIds[2])); Assert.IsTrue(blog2Channel1.Name.Length > 0); Assert.IsTrue(blog3Channel1.Name.Length > 0); Assert.IsTrue(blog3Channel3.Name.Length > 0); Assert.AreEqual(Blog2Channel1CurrentPrice, blog2Channel1.Price); Assert.AreEqual(Blog2Channel1AcceptedPrice, blog2Channel1.AcceptedPrice); Assert.AreEqual(true, blog2Channel1.IsVisibleToNonSubscribers); Assert.AreEqual(Blog3Channel1CurrentPrice, blog3Channel1.Price); Assert.AreEqual(Blog3Channel1AcceptedPrice, blog3Channel1.AcceptedPrice); Assert.AreEqual(false, blog3Channel1.IsVisibleToNonSubscribers); Assert.AreEqual(Blog3Channel3CurrentPrice, blog3Channel3.Price); Assert.AreEqual(Blog3Channel3AcceptedPrice, blog3Channel3.AcceptedPrice); Assert.AreEqual(true, blog3Channel3.IsVisibleToNonSubscribers); Assert.AreEqual(PriceLastSetDate, blog2Channel1.PriceLastSetDate); Assert.AreEqual(PriceLastSetDate, blog3Channel1.PriceLastSetDate); Assert.AreEqual(PriceLastSetDate, blog3Channel3.PriceLastSetDate); Assert.AreEqual(SubscriptionStartDate, blog2Channel1.SubscriptionStartDate); Assert.AreEqual(SubscriptionStartDate, blog3Channel1.SubscriptionStartDate); Assert.AreEqual(SubscriptionStartDate, blog3Channel3.SubscriptionStartDate); return(ExpectedSideEffects.None); }); }