Пример #1
0
        public void DetailsShouldReturnNotFound_WhenPathIdNotFound()
        {
            var query = new GetSourceDetailsQuery()
            {
                PathId = 99999, ModuleId = 1, ThemeId = 1, Id = 1
            };

            FluentActions.Invoking(() =>
                                   SendAsync(query)).Should().ThrowAsync <NotFoundException>();
        }
Пример #2
0
        public async Task GetDetails_ShouldReturnSourceDetails()
        {
            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
            });

            var theme = await AddAsync(new Theme
            {
                Title       = "New Theme",
                ModuleId    = module.Id,
                Description = "New Theme Description",
                Necessity   = Necessity.MustKnow,
                Complexity  = Complexity.Beginner,
                Order       = 2
            });

            var source = await AddAsync(new Source
            {
                ThemeId      = theme.Id,
                Title        = "Source 1",
                Description  = "Some description",
                Url          = "https://source1.com",
                Order        = 0,
                Type         = SourceType.Documentation,
                Availability = Availability.Free,
                Relevance    = Relevance.Relevant,
                Tags         = new List <string> {
                    "Tag1", "Tag2", "Tag3"
                }
            });

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

            var createdSource = await SendAsync(query);

            createdSource.Id.Should().Be(source.Id);
            createdSource.Title.Should().Be("Source 1");
            createdSource.Description.Should().Be("Some description");
            createdSource.Url.Should().Be("https://source1.com");
            createdSource.Type.Should().Be(SourceType.Documentation);
            createdSource.ThemeId.Should().Be(theme.Id);
            createdSource.Tags.Should().HaveCount(3);
        }
Пример #3
0
        public void GetDetails_ShouldThrow_WhenCanceled()
        {
            var cts = new CancellationTokenSource();

            cts.Cancel();

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

            FluentActions.Invoking(() =>
                                   SendAsync(query, cts.Token)).Should().ThrowAsync <TaskCanceledException>();
        }