-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathConvertHtmlToMardown.cs
More file actions
69 lines (52 loc) · 2.1 KB
/
ConvertHtmlToMardown.cs
File metadata and controls
69 lines (52 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
namespace CommandPipeline.Example
{
using System;
using System.Collections.Generic;
using CommandPipeline.Example.Commands;
using CommandPipeline.Example.Entities;
using CommandPipeline.Example.Services;
using CommandPipeline.Example.Services.Implementation;
using CommandPipeline.Infrastructure.ParametersContext.Implementation;
using CommandPipeline.Infrastructure.Pipeline;
using CommandPipeline.Infrastructure.Pipeline.Implementation;
using CommandPipeline.Ninject;
using FluentAssertions;
using Xunit;
public class DownloadPipelineTests
{
private readonly string[] links;
private readonly IPipelineBuilder builder;
public DownloadPipelineTests()
{
this.links = new[]
{
"http://habrahabr.ru/post/240219/",
"http://habrahabr.ru/post/240223/",
"http://habrahabr.ru/post/240225/"
};
this.builder = new PipelineBuilder();
}
[Fact]
public void ConvertAllLinksToMarkdownDocuments()
{
var container = new NinjectContainer();
container.Bind<IWebPageDownloader>().To<WebPageDownloader>();
container.Bind<IMarkdownConveter>().To<MarkdownConveter>();
container.Bind<IDataContainerService>().To<DataContainerServiceFake>();
var context = new ParametersContext<ICommand>();
var pipeline = builder.Create(container, context)
.Register<ExtractHtmlFromUrl>()
.Register<ConvertHtmlToMardown>()
.Register<UploadToDataContainer>();
var documentsId = new List<Guid>();
foreach (var link in links)
{
context.Set<ExtractHtmlFromUrl, Request>(x => x.Request, new Request { Url = link });
pipeline.Handle();
var documentId = context.Get<UploadToDataContainer, Guid>(x => x.UploadedDocumentId);
documentsId.Add(documentId);
}
documentsId.Should().HaveCount(links.Length);
}
}
}