Пример #1
0
        public void TestValidDataLinks()
        {
            PcapDataLink dataLink = new PcapDataLink();
            Assert.AreEqual(new PcapDataLink("NULL"), dataLink);
            string previousDataLinkName = null;
            for (int i = 0; i != 1000; ++i)
            {
                dataLink = new PcapDataLink(i);
                string dataLinkName;
                try
                {
                    dataLinkName = dataLink.Name;
                }
                catch (InvalidOperationException)
                {
                    // Ignore invalid values
                    continue;
                }

                Assert.AreEqual(new PcapDataLink(dataLinkName), dataLink);
                Assert.IsFalse(dataLink.Equals(null));
                Assert.IsTrue(new PcapDataLink(dataLinkName) == dataLink);
                Assert.IsFalse(new PcapDataLink(dataLinkName) != dataLink);
                Assert.IsTrue(previousDataLinkName == null || new PcapDataLink(previousDataLinkName) != dataLink);
                Assert.IsNotNull(dataLink.Description);
                Assert.AreEqual(i, dataLink.Value);
                Assert.AreEqual(dataLink.Value.GetHashCode(), dataLink.GetHashCode());

                previousDataLinkName = dataLinkName;
            }
        }
Пример #2
0
        public void TestValidDataLinks()
        {
            PcapDataLink dataLink = new PcapDataLink();

            Assert.AreEqual(new PcapDataLink("NULL"), dataLink);
            string previousDataLinkName = null;

            for (int i = 0; i != 1000; ++i)
            {
                dataLink = new PcapDataLink(i);
                string dataLinkName;
                try
                {
                    dataLinkName = dataLink.Name;
                }
                catch (InvalidOperationException)
                {
                    // Ignore invalid values
                    continue;
                }

                Assert.AreEqual(new PcapDataLink(dataLinkName), dataLink);
                Assert.IsFalse(dataLink.Equals(null));
                Assert.IsTrue(new PcapDataLink(dataLinkName) == dataLink);
                Assert.IsFalse(new PcapDataLink(dataLinkName) != dataLink);
                Assert.IsTrue(previousDataLinkName == null || new PcapDataLink(previousDataLinkName) != dataLink);
                Assert.IsNotNull(dataLink.Description);
                Assert.AreEqual(i, dataLink.Value);
                Assert.AreEqual(dataLink.Value.GetHashCode(), dataLink.GetHashCode());

                previousDataLinkName = dataLinkName;
            }
        }
Пример #3
0
        public void NoDescriptionErrorTest()
        {
            PcapDataLink dataLink = GetInvalidDataLink();

            Assert.IsNotNull(dataLink.Description);
            Assert.Fail();
        }
Пример #4
0
        public void InvalidNameErrorTest()
        {
            PcapDataLink dataLink = new PcapDataLink("Invalid Name");

            Assert.IsNotNull(dataLink);
            Assert.Fail();
        }
Пример #5
0
 public void InvalidKindTest()
 {
     const DataLinkKind InvalidKind = (DataLinkKind)100;
     IDataLink dataLink = new PcapDataLink(InvalidKind);
     Assert.IsNotNull(dataLink);
     Assert.Fail();
 }
Пример #6
0
        public void InvalidKindTest()
        {
            const DataLinkKind InvalidKind = (DataLinkKind)100;
            IDataLink          dataLink    = new PcapDataLink(InvalidKind);

            Assert.IsNotNull(dataLink);
            Assert.Fail();
        }
Пример #7
0
 private static PcapDataLink GetInvalidDataLink()
 {
     for (int i = 0; i != 1000; ++i)
     {
         PcapDataLink dataLink = new PcapDataLink(i);
         try
         {
             string dataLinkName = dataLink.Name;
             Assert.IsNotNull(dataLinkName);
         }
         catch (InvalidOperationException)
         {
             return(dataLink);
         }
         catch (Exception)
         {
             Assert.Fail();
         }
     }
     Assert.Fail();
     return(new PcapDataLink());
 }
Пример #8
0
 public PacketHandler(HandlePacket callback, PcapDataLink dataLink)
 {
     this._callback = callback;
     this._dataLink = dataLink;
 }
Пример #9
0
 public void UnsupportedKindErrorTest()
 {
     PcapDataLink dataLink = new PcapDataLink();
     Assert.IsNotNull(dataLink.Kind);
 }
Пример #10
0
 private static PcapDataLink GetInvalidDataLink()
 {
     for (int i = 0; i != 1000; ++i)
     {
         PcapDataLink dataLink = new PcapDataLink(i);
         try
         {
             string dataLinkName = dataLink.Name;
             Assert.IsNotNull(dataLinkName);
         }
         catch (InvalidOperationException)
         {
             return dataLink;
         }
         catch (Exception)
         {
             Assert.Fail();
         }
     }
     Assert.Fail();
     return new PcapDataLink();
 }
Пример #11
0
 public void InvalidNameErrorTest()
 {
     PcapDataLink dataLink = new PcapDataLink("Invalid Name");
     Assert.IsNotNull(dataLink);
     Assert.Fail();
 }
Пример #12
0
        public void UnsupportedKindErrorTest()
        {
            PcapDataLink dataLink = new PcapDataLink();

            Assert.IsNotNull(dataLink.Kind);
        }