Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pcap-Net
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Pcap-Net
Commits
2c6cf6da
Commit
2c6cf6da
authored
Mar 31, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code coverage 95.65%
parent
7a662074
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
1 deletion
+151
-1
BitSequenceTest.cs
PcapDotNet/src/PcapDotNet.Base.Test/BitSequenceTest.cs
+62
-0
DateTimeExtensionsTest.cs
...DotNet/src/PcapDotNet.Base.Test/DateTimeExtensionsTest.cs
+60
-0
IEnumerableExtensionsTests.cs
...et/src/PcapDotNet.Base.Test/IEnumerableExtensionsTests.cs
+17
-0
PcapDotNet.Base.Test.csproj
...tNet/src/PcapDotNet.Base.Test/PcapDotNet.Base.Test.csproj
+2
-0
UInt128Tests.cs
PcapDotNet/src/PcapDotNet.Base.Test/UInt128Tests.cs
+10
-1
No files found.
PcapDotNet/src/PcapDotNet.Base.Test/BitSequenceTest.cs
0 → 100644
View file @
2c6cf6da
using
System
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
PcapDotNet.TestUtils
;
namespace
PcapDotNet.Base.Test
{
/// <summary>
/// Summary description for BitSequenceTest
/// </summary>
[
TestClass
]
public
class
BitSequenceTest
{
/// <summary>
/// Gets or sets the test context which provides
/// information about and functionality for the current test run.
/// </summary>
public
TestContext
TestContext
{
get
;
set
;
}
#
region
Additional
test
attributes
//
// You can use the following additional attributes as you write your tests:
//
// Use ClassInitialize to run code before running the first test in the class
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// Use ClassCleanup to run code after all tests in a class have run
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// Use TestInitialize to run code before running each test
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// Use TestCleanup to run code after each test has run
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#
endregion
[
TestMethod
]
public
void
Merge8BoolRandomTest
()
{
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
!=
10
;
++
i
)
{
byte
expectedResult
=
0
;
bool
[]
input
=
new
bool
[
8
];
for
(
int
bit
=
0
;
bit
!=
8
;
++
bit
)
{
bool
bitValue
=
random
.
NextBool
();
input
[
bit
]
=
bitValue
;
expectedResult
<<=
1
;
if
(
bitValue
)
++
expectedResult
;
}
Assert
.
AreEqual
(
expectedResult
,
BitSequence
.
Merge
(
input
[
0
],
input
[
1
],
input
[
2
],
input
[
3
],
input
[
4
],
input
[
5
],
input
[
6
],
input
[
7
]));
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Base.Test/DateTimeExtensionsTest.cs
0 → 100644
View file @
2c6cf6da
using
System
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
namespace
PcapDotNet.Base.Test
{
/// <summary>
/// Summary description for DateTimeExtensionsTest
/// </summary>
[
TestClass
]
public
class
DateTimeExtensionsTest
{
/// <summary>
/// Gets or sets the test context which provides
/// information about and functionality for the current test run.
/// </summary>
public
TestContext
TestContext
{
get
;
set
;
}
#
region
Additional
test
attributes
//
// You can use the following additional attributes as you write your tests:
//
// Use ClassInitialize to run code before running the first test in the class
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// Use ClassCleanup to run code after all tests in a class have run
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// Use TestInitialize to run code before running each test
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// Use TestCleanup to run code after each test has run
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#
endregion
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
),
AllowDerivedTypes
=
false
)]
public
void
AddMicrosecondsValueTooBigTest
()
{
DateTime
dateTime
=
DateTime
.
Now
;
dateTime
.
AddMicroseconds
((
long
.
MaxValue
/
TimeSpanExtensions
.
TicksPerMicrosecond
)
*
2
);
Assert
.
IsNotNull
(
dateTime
);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
),
AllowDerivedTypes
=
false
)]
public
void
AddMicrosecondsValueTooSmallTest
()
{
DateTime
dateTime
=
DateTime
.
Now
;
dateTime
.
AddMicroseconds
((
long
.
MinValue
/
TimeSpanExtensions
.
TicksPerMicrosecond
)
*
2
);
Assert
.
IsNotNull
(
dateTime
);
Assert
.
Fail
();
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Base.Test/IEnumerableExtensionsTests.cs
View file @
2c6cf6da
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
...
...
@@ -93,5 +94,21 @@ namespace PcapDotNet.Base.Test
};
Assert
.
AreEqual
(
0x87654321L
,
longValues
.
Xor
());
}
[
TestMethod
]
public
void
IsStrictOrderedTest
()
{
Assert
.
IsTrue
(
new
[]
{
1
,
2
,
3
,
4
,
5
}.
IsStrictOrdered
(
value
=>
value
,
Comparer
<
int
>.
Default
));
Assert
.
IsFalse
(
new
[]
{
1
,
2
,
3
,
3
,
5
}.
IsStrictOrdered
(
value
=>
value
,
Comparer
<
int
>.
Default
));
Assert
.
IsFalse
(
new
[]
{
1
,
2
,
3
,
4
,
3
}.
IsStrictOrdered
(
value
=>
value
,
Comparer
<
int
>.
Default
));
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
IsStrictOrderedNullComparerTest
()
{
Assert
.
IsFalse
(
new
[]
{
1
,
2
,
3
,
4
,
5
}.
IsStrictOrdered
(
value
=>
value
,
null
));
Assert
.
Fail
();
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Base.Test/PcapDotNet.Base.Test.csproj
View file @
2c6cf6da
...
...
@@ -67,6 +67,8 @@
<Reference
Include=
"System.Numerics"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"BitSequenceTest.cs"
/>
<Compile
Include=
"DateTimeExtensionsTest.cs"
/>
<Compile
Include=
"IDictionaryExtensionsTests.cs"
/>
<Compile
Include=
"FuncExtensionsTest.cs"
/>
<Compile
Include=
"IEnumerableExtensionsTests.cs"
/>
...
...
PcapDotNet/src/PcapDotNet.Base.Test/UInt128Tests.cs
View file @
2c6cf6da
...
...
@@ -48,7 +48,7 @@ namespace PcapDotNet.Base.Test
{
UInt128
value
=
random
.
NextUInt128
();
// Test
equality
// Test
comparisons.
Assert
.
AreEqual
(
value
,
value
);
Assert
.
AreNotEqual
(
value
,
string
.
Empty
);
Assert
.
AreNotEqual
(
value
,
UInt128
.
MaxValue
);
...
...
@@ -56,7 +56,16 @@ namespace PcapDotNet.Base.Test
// ReSharper disable EqualExpressionComparison
Assert
.
IsTrue
(
value
==
value
);
Assert
.
IsFalse
(
value
!=
value
);
Assert
.
IsTrue
(
value
<=
value
);
Assert
.
IsTrue
(
value
>=
value
);
// ReSharper restore EqualExpressionComparison
if
(
value
!=
UInt128
.
MaxValue
)
{
Assert
.
IsTrue
(
value
<
value
+
1
);
Assert
.
IsTrue
(
value
<=
value
+
1
);
Assert
.
IsTrue
(
value
+
1
>
value
);
Assert
.
IsTrue
(
value
+
1
>=
value
);
}
// Test GetHashCode
Assert
.
IsNotNull
(
value
.
GetHashCode
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment