<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base;
using PcapDotNet.Packets;
using PcapDotNet.Packets.Ip;
using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.Transport;
using PcapDotNet.TestUtils;

namespace PcapDotNet.Core.Test
{
    internal class WiresharkDatagramComparerTcp : WiresharkDatagramComparer
    {
        protected override string PropertyName
        {
            get { return "Tcp"; }
        }

        protected override bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram)
        {
            IpDatagram ipDatagram = (IpDatagram)parentDatagram;
            TcpDatagram tcpDatagram = (TcpDatagram)datagram;

            switch (field.Name())
            {
                case "tcp.len":
                    if (tcpDatagram.Payload == null)
                    {
                        // todo seems like a bug in tshark https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5235
                        break;
//                            field.AssertShowDecimal(tcpDatagram.Length);
                    }
                    else
                        field.AssertShowDecimal(tcpDatagram.Payload.Length);
                    field.AssertNoFields();
                    break;

                case "tcp.srcport":
                    field.AssertShowDecimal(tcpDatagram.SourcePort);
                    field.AssertNoFields();
                    break;

                case "tcp.dstport":
                    field.AssertShowDecimal(tcpDatagram.DestinationPort);
                    field.AssertNoFields();
                    break;

                case "tcp.port":
                    Assert.IsTrue(ushort.Parse(field.Show()) == tcpDatagram.SourcePort ||
                                  ushort.Parse(field.Show()) == tcpDatagram.DestinationPort);
                    field.AssertNoFields();
                    break;


                case "tcp.seq":
                    field.AssertShowDecimal(tcpDatagram.SequenceNumber);<commit_msg>Wireshark 1.12.1<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base;
using PcapDotNet.Packets;
using PcapDotNet.Packets.Ip;
using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.Transport;
using PcapDotNet.TestUtils;

namespace PcapDotNet.Core.Test
{
    internal class WiresharkDatagramComparerTcp : WiresharkDatagramComparer
    {
        protected override string PropertyName
        {
            get { return "Tcp"; }
        }

        protected override bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram)
        {
            IpDatagram ipDatagram = (IpDatagram)parentDatagram;
            TcpDatagram tcpDatagram = (TcpDatagram)datagram;

            switch (field.Name())
            {
                case "tcp.len":
                    field.AssertShowDecimal(tcpDatagram.Payload.Length);
                    field.AssertNoFields();
                    break;

                case "tcp.srcport":
                    field.AssertShowDecimal(tcpDatagram.SourcePort);
                    field.AssertNoFields();
                    break;

                case "tcp.dstport":
                    field.AssertShowDecimal(tcpDatagram.DestinationPort);
                    field.AssertNoFields();
                    break;

                case "tcp.port":
                    Assert.IsTrue(ushort.Parse(field.Show()) == tcpDatagram.SourcePort ||
                                  ushort.Parse(field.Show()) == tcpDatagram.DestinationPort);
                    field.AssertNoFields();
                    break;


                case "tcp.seq":
                    field.AssertShowDecimal(tcpDatagram.SequenceNumber);
{'fraction_non_alphanumeric': 0.08331223094454292, 'fraction_numerical': 0.0025322866548493288, 'mean_word_length': 1.7166437414030262, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5396330', 'n_tokens_mistral': 1056, 'n_tokens_neox': 995, 'n_words': 174}