예제 #1
0
        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);
        }