Beispiel #1
0
        public void AllowRobotGroupToString(string expected, string userAgent, params string[] allowPaths)
        {
            var group = new RobotGroup
            {
                UserAgent = userAgent,
                Allow     = allowPaths
            };

            group.ToString().Should().Be(expected);
        }
        public void ReturnUserAgent_AndAllow_WhenAny_WihoutDisallow_WhenNone(string userAgent, string allow)
        {
            var group = new RobotGroup(userAgent, new[] { allow }, new string[0]);

            string output = group.ToString();

            string[] parts = output.Split(Environment.NewLine);
            Assert.AreEqual($"User-agent: {group.UserAgent}", parts[0]);
            Assert.AreEqual($"Allow: {allow}", parts[1]);
            Assert.AreEqual(2, parts.Length);
        }
        public void ReturnOnlyUserAgent(string userAgent)
        {
            var group = new RobotGroup(userAgent);

            string output = group.ToString();

            var parts = output.Split(Environment.NewLine);

            Assert.AreEqual($"User-agent: {group.UserAgent}", parts[0]);
            Assert.AreEqual(1, parts.Length);
        }
        public void ReturnUserAgent_AndAllow_WhenAny_AndDisallow_WhenAny(string userAgent, string allow, string disallow)
        {
            var group = new RobotGroup(userAgent, new[] { allow }, new[] { disallow });

            string output = group.ToString();

            var parts = output.Split(Environment.NewLine);

            Assert.AreEqual($"User-agent: {group.UserAgent}", parts[0]);
            Assert.AreEqual($"Allow: {allow}", parts[1]);
            Assert.AreEqual($"Disallow: {disallow}", parts[2]);
        }
        public async Task ReturnEachGroupOnOneLine()
        {
            var robotGroup      = new RobotGroup("TestAgent");
            var otherRobotGroup = new RobotGroup("AnotherTestAgent");

            this.robotGroups.Add(robotGroup);
            this.robotGroups.Add(otherRobotGroup);

            string output = await this.writer.WriteAsync();

            string[] parts = output.Split(Environment.NewLine);
            Assert.AreEqual(5, parts.Length);
            Assert.AreEqual(robotGroup.ToString(), parts[1]);
            Assert.AreEqual(otherRobotGroup.ToString(), parts[3]);
        }