Ejemplo n.º 1
0
        public async Task GetGlossaryEntry()
        {
            var contextId = Guid.NewGuid().ToString();

            await using (var context = InMemoryContentDbContext(contextId))
            {
                await context.AddAsync(
                    new GlossaryEntry
                {
                    Title = "Exclusion",
                    Slug  = "exclusion",
                    Body  = "Exclusion body",
                }
                    );

                await context.SaveChangesAsync();
            }

            await using (var context = InMemoryContentDbContext(contextId))
            {
                var glossaryService = new GlossaryService(context);

                var result = await glossaryService.GetGlossaryEntry("exclusion");

                var viewModel = result.AssertRight();

                Assert.Equal("Exclusion", viewModel.Title);
                Assert.Equal("exclusion", viewModel.Slug);
                Assert.Equal("Exclusion body", viewModel.Body);
            }
        }
Ejemplo n.º 2
0
        public async Task GetGlossaryEntry_NotFound()
        {
            await using var context = InMemoryContentDbContext();
            var glossaryService = new GlossaryService(context);

            var result = await glossaryService.GetGlossaryEntry("absence");

            result.AssertNotFound();
        }