-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/neo.UnitTests/SmartContract/Iterators/UT_PrimitiveWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo.SmartContract.Iterators; | ||
using Neo.VM; | ||
using Neo.VM.Types; | ||
using System; | ||
|
||
namespace Neo.UnitTests.SmartContract.Iterators | ||
{ | ||
[TestClass] | ||
public class UT_PrimitiveWrapper | ||
{ | ||
[TestMethod] | ||
public void TestGeneratorAndDispose() | ||
{ | ||
PrimitiveWrapper arrayWrapper = new PrimitiveWrapper(new ByteArray(new byte[0])); | ||
Assert.IsNotNull(arrayWrapper); | ||
Action action = () => arrayWrapper.Dispose(); | ||
action.Should().NotThrow<Exception>(); | ||
} | ||
|
||
[TestMethod] | ||
public void TestKeyAndValue() | ||
{ | ||
PrimitiveWrapper arrayWrapper = new PrimitiveWrapper(new byte[] { 0x01, 0x02 }); | ||
Action action1 = () => arrayWrapper.Key(); | ||
action1.Should().Throw<InvalidOperationException>(); | ||
Action action2 = () => arrayWrapper.Value(); | ||
action2.Should().Throw<InvalidOperationException>(); | ||
arrayWrapper.Next(); | ||
Assert.AreEqual(0x00, arrayWrapper.Key().GetBigInteger()); | ||
Assert.AreEqual(0x01, arrayWrapper.Value()); | ||
arrayWrapper.Next(); | ||
Assert.AreEqual(0x01, arrayWrapper.Key().GetBigInteger()); | ||
Assert.AreEqual(0x02, arrayWrapper.Value()); | ||
} | ||
|
||
[TestMethod] | ||
public void TestNext() | ||
{ | ||
PrimitiveWrapper arrayWrapper = new PrimitiveWrapper(new byte[] { 0x01, 0x02 }); | ||
Assert.AreEqual(true, arrayWrapper.Next()); | ||
Assert.AreEqual(0x01, arrayWrapper.Value()); | ||
Assert.AreEqual(true, arrayWrapper.Next()); | ||
Assert.AreEqual(0x02, arrayWrapper.Value()); | ||
Assert.AreEqual(false, arrayWrapper.Next()); | ||
} | ||
} | ||
} |