public async Task WhenBlogIdDoesNotExist_ItShouldReturnAnEmptyResultList() { await this.DatabaseTestAsync(async testDatabase => { this.target = new GetFreeAccessUsersDbStatement(testDatabase); await this.CreateDataAsync(testDatabase, true); await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(new BlogId(Guid.NewGuid())); Assert.AreEqual(0, result.FreeAccessUsers.Count); return(ExpectedSideEffects.None); }); }
public async Task WhenBlogIdExists_ItShouldReturnTheUserForTheBlog() { await this.DatabaseTestAsync(async testDatabase => { this.target = new GetFreeAccessUsersDbStatement(testDatabase); await this.CreateDataAsync(testDatabase, true); await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(BlogId1); Assert.AreEqual(3, result.FreeAccessUsers.Count); var user1 = result.FreeAccessUsers.FirstOrDefault(v => v.Email.Value == "*****@*****.**"); var user2 = result.FreeAccessUsers.FirstOrDefault(v => v.Email.Value == "*****@*****.**"); var user3 = result.FreeAccessUsers.FirstOrDefault(v => v.Email.Value == "*****@*****.**"); Assert.IsNotNull(user1); Assert.IsNotNull(user2); Assert.IsNotNull(user3); Assert.AreEqual(UserId1, user1.UserId); Assert.AreEqual(Username1, user1.Username); Assert.AreEqual(0, user1.ChannelIds.Count); Assert.AreEqual(UserId2, user2.UserId); Assert.AreEqual(Username2, user2.Username); Assert.AreEqual(2, user2.ChannelIds.Count); Assert.IsTrue(user2.ChannelIds.Contains(ChannelId1)); Assert.IsTrue(user2.ChannelIds.Contains(ChannelId2)); Assert.IsNull(user3.UserId); Assert.IsNull(user3.Username); Assert.AreEqual(0, user3.ChannelIds.Count); return(ExpectedSideEffects.None); }); }
public void TestInitialize() { this.target = new GetFreeAccessUsersDbStatement(new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object); }