Beispiel #1
0
        public void DetailsShouldReturnNotFound_WhenPathIdNotFound()
        {
            var query = new GetThemeDetailsQuery()
            {
                PathId = 99999, ModuleId = 1, Id = 1
            };

            FluentActions.Invoking(() =>
                                   SendAsync(query)).Should().ThrowAsync <NotFoundException>();
        }
Beispiel #2
0
        public void GetDetails_ShouldThrow_WhenCanceled()
        {
            var cts = new CancellationTokenSource();

            cts.Cancel();

            var query = new GetThemeDetailsQuery()
            {
                PathId = 1, ModuleId = 1, Id = 1
            };

            FluentActions.Invoking(() =>
                                   SendAsync(query, cts.Token)).Should().ThrowAsync <TaskCanceledException>();
        }
Beispiel #3
0
        public async Task GetDetails_ShouldReturnThemeDetails()
        {
            var path = await AddAsync(
                new Path { Title = "Some Path", Key = "some-path", Description = "Some Path Description" });

            var module = await SendAsync(new CreateModule
            {
                Key         = "module-key",
                Title       = "New Module Module",
                Description = "New Module Description",
                Necessity   = Necessity.MustKnow,
                Tags        = new List <string> {
                    "Tag1", "Tag2", "Tag3"
                }
            });

            var theme = await AddAsync(new Theme
            {
                Title       = "New Other Theme",
                ModuleId    = module.Id,
                Description = "New Other Theme Description",
                Necessity   = Necessity.MustKnow,
                Complexity  = Complexity.Beginner,
                Tags        = new List <string> {
                    "Theme1", "ThemeTag2", "Tag3"
                },
                Order   = 2,
                Sources = new List <Source>
                {
                    new Source {
                        Title        = "Source1",
                        Type         = SourceType.Blog,
                        Url          = "https://www.google.com",
                        Availability = Availability.Free
                    },
                    new Source {
                        Title        = "Source2",
                        Type         = SourceType.Blog,
                        Url          = "https://www.microsoft.com",
                        Availability = Availability.RequiresRegistration
                    }
                },
                Section = new Section
                {
                    ModuleId = module.Id,
                    Title    = "First Section"
                }
            });

            var query = new GetThemeDetailsQuery()
            {
                Id = theme.Id, PathId = path.Id, ModuleId = module.Id
            };

            var createdTheme = await SendAsync(query);

            createdTheme.Id.Should().Be(theme.Id);
            createdTheme.Title.Should().NotBeEmpty();
            createdTheme.Description.Should().NotBeEmpty();
            createdTheme.Section.Should().NotBeNull();
            createdTheme.Module.Should().NotBeNull();
            createdTheme.Module.Id.Should().Be(module.Id);
            createdTheme.Sources.Should().HaveCount(2);
            createdTheme.Tags.Should().HaveCount(3);
        }