public void ContainsTransaction_ShouldReturnFalse() { ITransaction t = new Transaction(1, TransactionStatus.Successfull, "Gosho", "Gichka", 12); Assert.IsFalse(chainblock.Contains(t)); }
public void ContainsTransactionShouldReturnTrueIfTransactionExist() { //Act chainblock.Add(this.firstTransaction); //Assert var result = chainblock.Contains(this.firstTransaction); Assert.IsTrue(result); }
public void Contains_OnEmptyChainblock_ShouldReturnFalse() { //Arrange IChainblock cb = new Chainblock(); //Act //Assert Assert.IsFalse(cb.Contains(5)); Assert.IsFalse(cb.Contains(new Transaction(3, TransactionStatus.Failed, "a", "b", 0.5))); }
public void ContainsTransaction_EmptyCollection_ShoudReturnFalse() { IChainblock chainblock = new Chainblock(); bool actualRes = chainblock.Contains(this.transactionOne); Assert.IsFalse(actualRes); }
public void ContainsId_ExistingCollection_ShoudReturnTrue() { IChainblock chainblock = new Chainblock(this.transactionOne); bool actualRes = chainblock.Contains(1); Assert.IsTrue(actualRes); }
public void ContainsId_EmptyCollection_ShoudReturnFalse() { IChainblock chainblock = new Chainblock(); bool actualRes = chainblock.Contains(1); Assert.IsFalse(actualRes); }
public void Add_MultipleElements_CB_ShouldContainThemById() { //Arrange IChainblock cb = new Chainblock(); Transaction tx1 = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 5); Transaction tx2 = new Transaction(6, TransactionStatus.Successfull, "joro", "pesho", 5); Transaction tx3 = new Transaction(7, TransactionStatus.Successfull, "joro", "pesho", 5); //Act cb.Add(tx1); cb.Add(tx2); cb.Add(tx3); //Assert Assert.IsTrue(cb.Contains(tx1.Id)); Assert.IsTrue(cb.Contains(tx2.Id)); Assert.IsTrue(cb.Contains(tx3.Id)); }
public void ContainsTransaction_ExistingCollection_ShoudReturnTrue() { ITransaction transactionTwo = new Transaction(1, "X", "Z", 1, TransactionStatus.Aborted); IChainblock chainblock = new Chainblock(transactionTwo); bool actualRes = chainblock.Contains(this.transactionOne); Assert.IsTrue(actualRes); }
public void ContainsId_NotExistingCollection_ShoudReturnFalse() { ITransaction transactionTwo = new Transaction(2, "X", "Z", 1, TransactionStatus.Aborted); IChainblock chainblock = new Chainblock(transactionOne); bool actualRes = chainblock.Contains(2); Assert.IsFalse(actualRes); }
public void Contains_OnExistingElement_ShouldReturnTrue() { //Arrange IChainblock cb = new Chainblock(); Transaction tx1 = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 5); Transaction tx2 = new Transaction(6, TransactionStatus.Successfull, "joro", "pesho", 5); Transaction tx3 = new Transaction(7, TransactionStatus.Successfull, "joro", "pesho", 5); //Act cb.Add(tx1); cb.Add(tx2); cb.Add(tx3); //Assert Assert.IsTrue(cb.Contains(5)); Assert.IsFalse(cb.Contains(3)); Assert.IsTrue(cb.Contains(tx2)); Assert.IsFalse(cb.Contains(new Transaction(0, TransactionStatus.Failed, "b", "b", 5))); }
public void ContainsById_100000_ShouldWorkFast() { IChainblock cb = new Chainblock(); int count = 100000; List <Transaction> txs = new List <Transaction>(); TransactionStatus[] statuses = new TransactionStatus[] { TransactionStatus.Aborted, TransactionStatus.Failed, TransactionStatus.Successfull, TransactionStatus.Unauthorized }; Random rand = new Random(); Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < count; i++) { int status = rand.Next(0, 4); Transaction tx = new Transaction(i, statuses[status], i.ToString(), i.ToString(), i); cb.Add(tx); txs.Add(tx); } sw.Stop(); Assert.AreEqual(count, cb.Count); Stopwatch watch = new Stopwatch(); watch.Start(); foreach (Transaction tx in txs) { Assert.IsTrue(cb.Contains(tx.Id)); } watch.Stop(); long l1 = watch.ElapsedMilliseconds; Assert.Less(l1, 200); }
static void Main(string[] args) { IChainblock cb = new Chainblock(); int count = 100000; List <Transaction> txs = new List <Transaction>(); TransactionStatus[] statuses = new TransactionStatus[] { TransactionStatus.Aborted, TransactionStatus.Failed, TransactionStatus.Successfull, TransactionStatus.Unauthorized }; Random rand = new Random(); for (int i = 0; i < count; i++) { int status = rand.Next(0, 4); Transaction tx = new Transaction(i, statuses[status], i.ToString(), i.ToString(), i); cb.Add(tx); txs.Add(tx); } Stopwatch watch = new Stopwatch(); watch.Start(); foreach (Transaction tx in txs) { cb.Contains(tx); } watch.Stop(); long l1 = watch.ElapsedMilliseconds; Console.WriteLine(l1); }
public void Contains_DoesNotContainTransaction() { Assert.That(testChainblock.Contains(CreateSimpleTransaction()), Is.False); }