コード例 #1
0
        public async Task Get_conferences()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "Get_conferences")
                          .Options;

            await GetTestConferences(options);

            using (var context = new ApplicationDbContext(options))
            {
                var controller = new ConferencesController(context);
                var result     = await controller.GetConferences();

                var okResult = Assert.IsType <OkObjectResult>(result);
                var response = Assert.IsType <List <ConferenceResponse> >(okResult.Value);

                Assert.Equal(2, response.Count);
                Assert.Contains(response, c => c.Name == "Conference1");
                Assert.Contains(response, c => c.Name == "Conference2");
            }
        }