Skip to content

Commit 23e2e65

Browse files
Updating test structure to match existing.
1 parent cffddc3 commit 23e2e65

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

crypto/test/src/crypto/test/NistEccTest.cs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,24 @@
77

88
namespace Org.BouncyCastle.Crypto.Tests
99
{
10-
public class NistEccTest
10+
[TestFixture]
11+
public class NistEccTest : SimpleTest
1112
{
13+
public override string Name { get; } = "NistEcc";
14+
15+
public override void PerformTest()
16+
{
17+
foreach (var testVector in CollectTestVectors())
18+
{
19+
TestMultiply(
20+
curve: testVector[0] as string,
21+
k: testVector[1] as BigInteger,
22+
expectedX:testVector[2] as BigInteger,
23+
expectedY: testVector[3] as BigInteger
24+
);
25+
}
26+
}
27+
1228
public IEnumerable<object[]> CollectTestVectors()
1329
{
1430
string curve = null;
@@ -55,7 +71,6 @@ public IEnumerable<object[]> CollectTestVectors()
5571
}
5672
}
5773

58-
[TestCaseSource(nameof(CollectTestVectors))]
5974
public void TestMultiply(string curve, BigInteger k, BigInteger expectedX, BigInteger expectedY)
6075
{
6176
// Arrange
@@ -65,8 +80,21 @@ public void TestMultiply(string curve, BigInteger k, BigInteger expectedX, BigIn
6580
var ecPoint = x9EcParameters.G.Multiply(k).Normalize();
6681

6782
// Assert
68-
Assert.AreEqual(expectedX, ecPoint.XCoord.ToBigInteger(), "Unexpected X Coordinate");
69-
Assert.AreEqual(expectedY, ecPoint.YCoord.ToBigInteger(), "Unexpected Y Coordinate");
83+
IsEquals("Unexpected X Coordinate", expectedX, ecPoint.AffineXCoord.ToBigInteger());
84+
IsEquals("Unexpected Y Coordinate", expectedY, ecPoint.AffineYCoord.ToBigInteger());
85+
}
86+
87+
public static void Main(string[] args)
88+
{
89+
RunTest(new NistEccTest());
90+
}
91+
92+
[Test]
93+
public void TestFunction()
94+
{
95+
string resultText = Perform().ToString();
96+
97+
Assert.AreEqual(Name + ": Okay", resultText);
7098
}
7199
}
72100
}

0 commit comments

Comments
 (0)