public async ValueTask ReturnAllStudentsSpecificationWithIncludesToLoginAndSessionAndCourse() { const string dbName = "FakeDatabase"; using (TrainingDb dbContext = this.testFixture.CreateInMemoryDbContext(dbName)) { dbContext.Database.EnsureCreated(); var repo = new StudentRepository(dbContext); var specification = new AllStudentsSpecification(); System.Collections.Generic.IEnumerable <Student> allStudents = await repo.ListAsync(specification .Including(st => st.Login)); allStudents.All(student => specification.Test(student)).Should().BeTrue(); allStudents.Should().HaveCount(3); allStudents.Select(st => st.Login) .Should().NotBeNull(); allStudents.Select(st => st.Sessions) .Should().NotBeNull(); allStudents.SelectMany(st => st.Sessions) .Select(ss => ss.Session) .Select(s => s.Course).Should().NotBeNull(); foreach (Student student in allStudents) { student.Login.Should().NotBeNull(); student.Sessions.Should().NotBeNull(); foreach (StudentSession session in student.Sessions) { session.Session.Should().NotBeNull(); session.Session.Course.Should().NotBeNull(); } } } }