public void BeforeEach() { this.robotGroupsProvider = new Mock <IRobotGroupProvider>(); this.writer = new DefaultRobotsTxtContentWriter(robotGroupsProvider.Object); this.robotGroups = new List <RobotGroup>(); this.robotGroupsProvider.Setup(o => o.GetGroups()) .ReturnsAsync(robotGroups.ToArray); }
public async Task InvokeAsync(HttpContext context, IRobotTxtContentWriter writer) { if (!context.Request.Path.Equals("/robots.txt")) { await next(context); return; } context.Response.ContentType = "text/plain"; string content = await writer.WriteAsync(); await context.Response.WriteAsync(content); }