Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/Neo.UnitTests/Builders/UT_SignerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void TestAllowContract()
.Build();

Assert.IsNotNull(signer);
Assert.AreEqual(1, signer.AllowedContracts.Length);
Assert.HasCount(1, signer.AllowedContracts);
Assert.AreEqual(UInt160.Zero, signer.AllowedContracts[0]);
}

Expand All @@ -59,7 +59,7 @@ public void TestAllowGroup()
.Build();

Assert.IsNotNull(signer);
Assert.AreEqual(1, signer.AllowedGroups.Length);
Assert.HasCount(1, signer.AllowedGroups);
Assert.AreEqual(myPublicKey, signer.AllowedGroups[0]);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ public void TestAddWitnessRule()
.Build();

Assert.IsNotNull(signer);
Assert.AreEqual(1, signer.Rules.Length);
Assert.HasCount(1, signer.Rules);
Assert.AreEqual(WitnessRuleAction.Allow, signer.Rules[0].Action);
Assert.IsInstanceOfType<ScriptHashCondition>(signer.Rules[0].Condition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void TestConflict()
.Build();

Assert.IsNotNull(attr);
Assert.AreEqual(1, attr.Length);
Assert.HasCount(1, attr);
Assert.IsInstanceOfType<Conflicts>(attr[0]);
Assert.AreEqual(UInt256.Zero, ((Conflicts)attr[0]).Hash);
}
Expand All @@ -52,7 +52,7 @@ public void TestOracleResponse()
.Build();

Assert.IsNotNull(attr);
Assert.AreEqual(1, attr.Length);
Assert.HasCount(1, attr);
Assert.IsInstanceOfType<OracleResponse>(attr[0]);
Assert.AreEqual(1ul, ((OracleResponse)attr[0]).Id);
Assert.AreEqual(OracleResponseCode.Success, ((OracleResponse)attr[0]).Code);
Expand All @@ -67,7 +67,7 @@ public void TestHighPriority()
.Build();

Assert.IsNotNull(attr);
Assert.AreEqual(1, attr.Length);
Assert.HasCount(1, attr);
Assert.IsInstanceOfType<HighPriorityAttribute>(attr[0]);
}

Expand All @@ -79,7 +79,7 @@ public void TestNotValidBefore()
.Build();

Assert.IsNotNull(attr);
Assert.AreEqual(1, attr.Length);
Assert.HasCount(1, attr);
Assert.IsInstanceOfType<NotValidBefore>(attr[0]);
Assert.AreEqual(10u, ((NotValidBefore)attr[0]).Height);
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Neo.UnitTests/Builders/UT_TransactionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void TestTransactionAttributes()
.AddAttributes(ab => ab.AddHighPriority())
.Build();

Assert.AreEqual(1, tx.Attributes.Length);
Assert.HasCount(1, tx.Attributes);
Assert.IsInstanceOfType<HighPriorityAttribute>(tx.Attributes[0]);
Assert.IsNotNull(tx.Hash);
}
Expand All @@ -135,7 +135,7 @@ public void TestWitness()
})
.Build();

Assert.AreEqual(1, tx.Witnesses.Length);
Assert.HasCount(1, tx.Witnesses);
Assert.AreEqual(0, tx.Witnesses[0].InvocationScript.Length);
Assert.AreEqual(0, tx.Witnesses[0].VerificationScript.Length);
Assert.IsNotNull(tx.Hash);
Expand Down Expand Up @@ -178,14 +178,14 @@ public void TestSigner()
.Build();

Assert.IsNotNull(tx.Hash);
Assert.AreEqual(1, tx.Signers.Length);
Assert.HasCount(1, tx.Signers);
Assert.AreEqual(expectedContractHash, tx.Signers[0].Account);
Assert.AreEqual(1, tx.Signers[0].AllowedContracts.Length);
Assert.HasCount(1, tx.Signers[0].AllowedContracts);
Assert.AreEqual(expectedContractHash, tx.Signers[0].AllowedContracts[0]);
Assert.AreEqual(1, tx.Signers[0].AllowedGroups.Length);
Assert.HasCount(1, tx.Signers[0].AllowedGroups);
Assert.AreEqual(expectedPublicKey, tx.Signers[0].AllowedGroups[0]);
Assert.AreEqual(WitnessScope.WitnessRules, tx.Signers[0].Scopes);
Assert.AreEqual(1, tx.Signers[0].Rules.Length);
Assert.HasCount(1, tx.Signers[0].Rules);
Assert.AreEqual(WitnessRuleAction.Deny, tx.Signers[0].Rules[0].Action);
Assert.IsNotNull(tx.Signers[0].Rules[0].Condition);
Assert.IsInstanceOfType<ScriptHashCondition>(tx.Signers[0].Rules[0].Condition);
Expand Down
8 changes: 4 additions & 4 deletions tests/Neo.UnitTests/Builders/UT_WitnessConditionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void TestAndCondition()

Assert.IsNotNull(actual);
Assert.IsInstanceOfType<AndCondition>(condition);
Assert.AreEqual(2, actual.Expressions.Length);
Assert.HasCount(2, actual.Expressions);
Assert.IsInstanceOfType<CalledByContractCondition>(actual.Expressions[0]);
Assert.IsInstanceOfType<CalledByGroupCondition>(actual.Expressions[1]);
Assert.AreEqual(expectedContractHash, (actual.Expressions[0] as CalledByContractCondition).Hash);
Expand All @@ -60,7 +60,7 @@ public void TestOrCondition()

Assert.IsNotNull(actual);
Assert.IsInstanceOfType<OrCondition>(condition);
Assert.AreEqual(2, actual.Expressions.Length);
Assert.HasCount(2, actual.Expressions);
Assert.IsInstanceOfType<CalledByContractCondition>(actual.Expressions[0]);
Assert.IsInstanceOfType<CalledByGroupCondition>(actual.Expressions[1]);
Assert.AreEqual(expectedContractHash, (actual.Expressions[0] as CalledByContractCondition).Hash);
Expand Down Expand Up @@ -176,7 +176,7 @@ public void TestNotConditionWithAndCondition()
Assert.IsNotNull(actual);
Assert.IsInstanceOfType<NotCondition>(condition);
Assert.IsInstanceOfType<AndCondition>(actual.Expression);
Assert.AreEqual(2, actualAndCondition.Expressions.Length);
Assert.HasCount(2, actualAndCondition.Expressions);
Assert.IsInstanceOfType<CalledByContractCondition>(actualAndCondition.Expressions[0]);
Assert.IsInstanceOfType<CalledByGroupCondition>(actualAndCondition.Expressions[1]);
Assert.AreEqual(expectedContractHash, (actualAndCondition.Expressions[0] as CalledByContractCondition).Hash);
Expand Down Expand Up @@ -205,7 +205,7 @@ public void TestNotConditionWithOrCondition()
Assert.IsNotNull(actual);
Assert.IsInstanceOfType<NotCondition>(condition);
Assert.IsInstanceOfType<OrCondition>(actual.Expression);
Assert.AreEqual(2, actualOrCondition.Expressions.Length);
Assert.HasCount(2, actualOrCondition.Expressions);
Assert.IsInstanceOfType<CalledByContractCondition>(actualOrCondition.Expressions[0]);
Assert.IsInstanceOfType<CalledByGroupCondition>(actualOrCondition.Expressions[1]);
Assert.AreEqual(expectedContractHash, (actualOrCondition.Expressions[0] as CalledByContractCondition).Hash);
Expand Down
6 changes: 3 additions & 3 deletions tests/Neo.UnitTests/Cryptography/UT_Ed25519.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void TestGenerateKeyPair()
{
byte[] keyPair = Ed25519.GenerateKeyPair();
Assert.IsNotNull(keyPair);
Assert.AreEqual(32, keyPair.Length);
Assert.HasCount(32, keyPair);
}

[TestMethod]
Expand All @@ -34,7 +34,7 @@ public void TestGetPublicKey()
byte[] privateKey = Ed25519.GenerateKeyPair();
byte[] publicKey = Ed25519.GetPublicKey(privateKey);
Assert.IsNotNull(publicKey);
Assert.AreEqual(Ed25519.PublicKeySize, publicKey.Length);
Assert.HasCount(Ed25519.PublicKeySize, publicKey);
}

[TestMethod]
Expand All @@ -46,7 +46,7 @@ public void TestSignAndVerify()

byte[] signature = Ed25519.Sign(privateKey, message);
Assert.IsNotNull(signature);
Assert.AreEqual(Ed25519.SignatureSize, signature.Length);
Assert.HasCount(Ed25519.SignatureSize, signature);

bool isValid = Ed25519.Verify(publicKey, message, signature);
Assert.IsTrue(isValid);
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.UnitTests/Cryptography/UT_MerkleTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void TestTrim()
tree.Trim(bitArray);
var hashArray = tree.ToHashArray();

Assert.AreEqual(1, hashArray.Length);
Assert.HasCount(1, hashArray);
var rootHash = MerkleTree.ComputeRoot(hashes);
var hash4 = Crypto.Hash256(hash1.ToArray().Concat(hash2.ToArray()).ToArray());
var hash5 = Crypto.Hash256(hash3.ToArray().Concat(hash3.ToArray()).ToArray());
Expand Down
38 changes: 19 additions & 19 deletions tests/Neo.UnitTests/IO/Caching/UT_Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ public void Init()
[TestMethod]
public void TestCount()
{
Assert.AreEqual(0, cache.Count);
Assert.IsEmpty(cache);

cache.Add("hello");
cache.Add("world");
Assert.AreEqual(2, cache.Count);
Assert.HasCount(2, cache);

cache.Remove("hello");
Assert.AreEqual(1, cache.Count);
Assert.HasCount(1, cache);
}

[TestMethod]
Expand All @@ -99,47 +99,47 @@ public void TestIsReadOnly()
public void TestAddAndAddInternal()
{
cache.Add("hello");
Assert.IsTrue(cache.Contains("hello"));
Assert.IsFalse(cache.Contains("world"));
Assert.Contains("hello", cache);
Assert.DoesNotContain("world", cache);
cache.Add("hello");
Assert.AreEqual(1, cache.Count);
Assert.HasCount(1, cache);
}

[TestMethod]
public void TestAddRange()
{
string[] range = { "hello", "world" };
cache.AddRange(range);
Assert.AreEqual(2, cache.Count);
Assert.IsTrue(cache.Contains("hello"));
Assert.IsTrue(cache.Contains("world"));
Assert.IsFalse(cache.Contains("non exist string"));
Assert.HasCount(2, cache);
Assert.Contains("hello", cache);
Assert.Contains("world", cache);
Assert.DoesNotContain("non exist string", cache);
}

[TestMethod]
public void TestClear()
{
cache.Add("hello");
cache.Add("world");
Assert.AreEqual(2, cache.Count);
Assert.HasCount(2, cache);
cache.Clear();
Assert.AreEqual(0, cache.Count);
Assert.IsEmpty(cache);
}

[TestMethod]
public void TestContainsKey()
{
cache.Add("hello");
Assert.IsTrue(cache.Contains("hello"));
Assert.IsFalse(cache.Contains("world"));
Assert.Contains("hello", cache);
Assert.DoesNotContain("world", cache);
}

[TestMethod]
public void TestContainsValue()
{
cache.Add("hello");
Assert.IsTrue(cache.Contains("hello".GetHashCode()));
Assert.IsFalse(cache.Contains("world".GetHashCode()));
Assert.Contains("hello", cache);
Assert.DoesNotContain("world", cache);
}

[TestMethod]
Expand Down Expand Up @@ -169,7 +169,7 @@ public void TestRemoveKey()
cache.Add("hello");
Assert.IsTrue(cache.Remove("hello".GetHashCode()));
Assert.IsFalse(cache.Remove("world".GetHashCode()));
Assert.IsFalse(cache.Contains("hello"));
Assert.DoesNotContain("hello", cache);
}

[TestMethod]
Expand All @@ -193,7 +193,7 @@ public void TestRemoveValue()
cache.Add("hello");
Assert.IsTrue(cache.Remove("hello"));
Assert.IsFalse(cache.Remove("world"));
Assert.IsFalse(cache.Contains("hello"));
Assert.DoesNotContain("hello", cache);
}

[TestMethod]
Expand Down Expand Up @@ -248,7 +248,7 @@ public void TestOverMaxCapacity()
}
cache.Add(i.ToString()); // The first one will be deleted
Assert.AreEqual(maxCapacity, cache.Count);
Assert.IsTrue(cache.Contains((maxCapacity + 1).ToString()));
Assert.Contains((maxCapacity + 1).ToString(), cache);
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.UnitTests/IO/Caching/UT_ECPointCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void SetUp()
public void TestGetKeyForItem()
{
relayCache.Add(ECCurve.Secp256r1.G);
Assert.IsTrue(relayCache.Contains(ECCurve.Secp256r1.G));
Assert.Contains(ECCurve.Secp256r1.G, relayCache);
Assert.IsTrue(relayCache.TryGet(ECCurve.Secp256r1.G.EncodePoint(true), out ECPoint tmp));
Assert.IsTrue(tmp is ECPoint);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/Neo.UnitTests/IO/Caching/UT_HashSetCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void TestHashSetCache()
Assert.IsTrue(bucket.TryAdd(i));
Assert.IsFalse(bucket.TryAdd(i));
}
Assert.AreEqual(100, bucket.Count);
Assert.HasCount(100, bucket);

var sum = 0;
foreach (var ele in bucket)
Expand All @@ -39,7 +39,7 @@ public void TestHashSetCache()
Assert.AreEqual(5050, sum);

bucket.TryAdd(101);
Assert.AreEqual(100, bucket.Count);
Assert.HasCount(100, bucket);

var items = new int[10];
var value = 11;
Expand All @@ -49,10 +49,10 @@ public void TestHashSetCache()
value += 2;
}
bucket.ExceptWith(items);
Assert.AreEqual(90, bucket.Count);
Assert.HasCount(90, bucket);

Assert.IsFalse(bucket.Contains(13));
Assert.IsTrue(bucket.Contains(50));
Assert.DoesNotContain(13, bucket);
Assert.Contains(50, bucket);
}

[TestMethod]
Expand Down
14 changes: 7 additions & 7 deletions tests/Neo.UnitTests/IO/Caching/UT_IndexedQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public class UT_IndexedQueue
public void TestDefault()
{
var queue = new IndexedQueue<int>(10);
Assert.AreEqual(0, queue.Count);
Assert.IsEmpty(queue);

queue = new IndexedQueue<int>();
Assert.AreEqual(0, queue.Count);
Assert.IsEmpty(queue);
queue.TrimExcess();
Assert.AreEqual(0, queue.Count);
Assert.IsEmpty(queue);

queue = new IndexedQueue<int>(Array.Empty<int>());
Assert.AreEqual(0, queue.Count);
Assert.IsEmpty(queue);
Assert.IsFalse(queue.TryPeek(out var a));
Assert.AreEqual(0, a);
Assert.IsFalse(queue.TryDequeue(out a));
Expand All @@ -50,10 +50,10 @@ public void TestDefault()
public void TestQueue()
{
var queue = new IndexedQueue<int>(new int[] { 1, 2, 3 });
Assert.AreEqual(3, queue.Count);
Assert.HasCount(3, queue);

queue.Enqueue(4);
Assert.AreEqual(4, queue.Count);
Assert.HasCount(4, queue);
Assert.AreEqual(1, queue.Peek());
Assert.IsTrue(queue.TryPeek(out var a));
Assert.AreEqual(1, a);
Expand All @@ -70,7 +70,7 @@ public void TestQueue()

queue.Enqueue(4);
queue.Clear();
Assert.AreEqual(0, queue.Count);
Assert.IsEmpty(queue);
}

[TestMethod]
Expand Down
Loading
Loading