Ejemplo n.º 1
0
        public Benchmarks()
        {
            _optionsBuilder = GetNewOptionsBuilder()
                              .AddSection(section =>
                                          section
                                          .AddComment("Allow Googlebot")
                                          .AddUserAgent("Googlebot")
                                          .Allow("/")
                                          )
                              .AddSection(section =>
                                          section
                                          .AddComment("Allow Bing for most stuff")
                                          .AddUserAgent("Bing")
                                          .Disallow("/bing-should-not-see-this")
                                          .Allow("/")
                                          )
                              .AddSection(section =>
                                          section
                                          .AddComment("Disallow the rest")
                                          .AddUserAgent("*")
                                          .AddCrawlDelay(TimeSpan.FromSeconds(10))
                                          .Disallow("/")
                                          )
                              .AddSitemap("https://example.com/sitemap.xml");

            _options = _optionsBuilder.Build();
#if V1
            _middleware = new RobotsTxtMiddleware(RequestDelegateAsync, _options);
#endif

#if V2
            _middleware = new RobotsTxtMiddleware(RequestDelegateAsync);
            _provider   = new StaticRobotsTxtProvider(_options);
#endif
        }
Ejemplo n.º 2
0
 public void BeforeEach()
 {
     this.writer  = new Mock <IRobotTxtContentWriter>();
     this.context = new DefaultHttpContext
     {
         Request = { Path = new PathString("/robots.txt") }
     };
     this.next       = new Mock <RequestDelegate>();
     this.middleware = new RobotsTxtMiddleware(next.Object);
     this.writer.Setup(o => o.WriteAsync())
     .ReturnsAsync(WriterContent);
 }