<commit_before>﻿using AngleSharp;
using AngleSharp.DOM;
using AngleSharp.DOM.Html;
using NUnit.Framework;
using System;

namespace UnitTests
{
    [TestFixture]
    public class CssSelectorTests
    {
        IDocument document;

        [SetUp]
        public void Setup()
        {
            document = DocumentBuilder.Html(Assets.selectors);
        }

        string GetAttributeValue(INode node, String attrName)
        {
            var element = node as IElement;

            if (element != null)
                return element.GetAttribute(attrName);

            return null;
        }

        IHtmlCollection RunQuery(String query)
        {
            return document.QuerySelectorAll(query);
        }

        [Test]
        public void PseudoSelectorFirstChild()
        {
            Assert.AreEqual(8, RunQuery("*:first-child").Length);
            Assert.AreEqual(1, RunQuery("p:first-child").Length);
        }

        [Test]
        public void PseudoSelectorLastChild()
        {
            Assert.AreEqual(7, RunQuery("*:last-child").Length);
            Assert.AreEqual(2, RunQuery("p:last-child").Length);
        }
        
        [Test]
        public void PseudoSelectorOnlyChild()
        {
            Assert.AreEqual(3, RunQuery("*:only-child").Length);
            Assert.AreEqual(1, RunQuery("p:only-child").Length);
        }

        [Test]
        public void PseudoSelectorEmpty()
        {
            var results = RunQuery("*:empty");
            Assert.AreEqual(2, results.Length);
            Assert.AreEqual("head", results[0].NodeName);
            Assert.AreEqual("input", results[1].NodeName);<commit_msg>Fixed test assertion<commit_after>﻿using AngleSharp;
using AngleSharp.DOM;
using NUnit.Framework;
using System;

namespace UnitTests
{
    [TestFixture]
    public class CssSelectorTests
    {
        IDocument document;

        [SetUp]
        public void Setup()
        {
            document = DocumentBuilder.Html(Assets.selectors);
        }

        string GetAttributeValue(INode node, String attrName)
        {
            var element = node as IElement;

            if (element != null)
                return element.GetAttribute(attrName);

            return null;
        }

        IHtmlCollection RunQuery(String query)
        {
            return document.QuerySelectorAll(query);
        }

        [Test]
        public void PseudoSelectorFirstChild()
        {
            Assert.AreEqual(8, RunQuery("*:first-child").Length);
            Assert.AreEqual(1, RunQuery("p:first-child").Length);
        }

        [Test]
        public void PseudoSelectorLastChild()
        {
            Assert.AreEqual(8, RunQuery("*:last-child").Length);
            Assert.AreEqual(2, RunQuery("p:last-child").Length);
        }
        
        [Test]
        public void PseudoSelectorOnlyChild()
        {
            Assert.AreEqual(3, RunQuery("*:only-child").Length);
            Assert.AreEqual(1, RunQuery("p:only-child").Length);
        }

        [Test]
        public void PseudoSelectorEmpty()
        {
            var results = RunQuery("*:empty");
            Assert.AreEqual(2, results.Length);
            Assert.AreEqual("head", results[0].NodeName);
            Assert.AreEqual("input", results[1].NodeName);
{'fraction_non_alphanumeric': 0.11195388349514564, 'fraction_numerical': 0.0054611650485436895, 'mean_word_length': 1.909973521624007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6617649', 'n_tokens_mistral': 915, 'n_tokens_neox': 882, 'n_words': 165}