コード例 #1
0
        public async Task Read_returns_projection_of_all_episodes()
        {
            using (var connection = await CreateConnectionAsync())
                using (var context = await CreateContextAsync(connection))
                {
                    var episode1 = new Episode {
                        Title = "Space Pilot 3000", FirstAired = new DateTime(1999, 3, 28)
                    };
                    var episode2 = new Episode {
                        Title = "The Series Has Landed", FirstAired = new DateTime(1999, 4, 4)
                    };
                    context.Episodes.AddRange(episode1, episode2);

                    await context.SaveChangesAsync();

                    var repository = new EpisodeRepository(context);

                    var episodes = repository.Read().ToList();

                    Assert.Collection(episodes,
                                      e => { Assert.Equal("Space Pilot 3000", e.Title); Assert.Equal(new DateTime(1999, 3, 28), e.FirstAired); },
                                      e => { Assert.Equal("The Series Has Landed", e.Title); Assert.Equal(new DateTime(1999, 4, 4), e.FirstAired); }
                                      );
                }
        }