public void GetAllInAmountRange_ShouldReturn_EmptyCollectionOnNonExistingRange() { //Arrange IChainblock cb = new Chainblock(); Transaction tx1 = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 1); Transaction tx2 = new Transaction(6, TransactionStatus.Successfull, "joro", "pesho", 2); Transaction tx3 = new Transaction(7, TransactionStatus.Successfull, "joro", "pesho", 5.5); Transaction tx4 = new Transaction(12, TransactionStatus.Successfull, "joro", "pesho", 15.6); Transaction tx5 = new Transaction(15, TransactionStatus.Successfull, "joro", "pesho", 7.8); List <Transaction> expected = new List <Transaction>(); //Act cb.Add(tx1); cb.Add(tx3); cb.Add(tx2); cb.Add(tx4); cb.Add(tx5); List <Transaction> actual = cb.GetAllInAmountRange(7.7, 7.75).ToList(); //Assert CollectionAssert.AreEqual(expected, actual); cb.RemoveTransactionById(12); cb.RemoveTransactionById(15); actual = cb.GetAllInAmountRange(7.8, 16).ToList(); CollectionAssert.AreEqual(expected, actual); }
public void GetInAmountRange_ShouldReturn_CorrectTransactionsByInsertionOrder() { //Arrange IChainblock cb = new Chainblock(); Transaction tx1 = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 1); Transaction tx2 = new Transaction(6, TransactionStatus.Successfull, "joro", "pesho", 2); Transaction tx3 = new Transaction(7, TransactionStatus.Successfull, "joro", "pesho", 5.5); Transaction tx4 = new Transaction(12, TransactionStatus.Successfull, "joro", "pesho", 15.6); Transaction tx5 = new Transaction(15, TransactionStatus.Successfull, "joro", "pesho", 7.8); List <Transaction> expected = new List <Transaction>() { tx4, tx5 }; //Act cb.Add(tx1); cb.Add(tx3); cb.Add(tx2); cb.Add(tx4); cb.Add(tx5); List <Transaction> actual = cb.GetAllInAmountRange(7.8, 16).ToList(); //Assert CollectionAssert.AreEqual(expected, actual); }
public void GetAllInAmountRange_ShouldReturnEmptyEnumeration_On_EmptyCB() { //Arrange IChainblock cb = new Chainblock(); //Act List <Transaction> actual = cb.GetAllInAmountRange(7.7, 7.75).ToList(); //Assert CollectionAssert.AreEqual(new List <Transaction>(), actual); }
public void GetAllInAmountRange() { IChainblock cb = new Chainblock(); List <Transaction> txs = new List <Transaction>(); Random rand = new Random(); for (int i = 0; i < 100000; i++) { int amount = rand.Next(0, 1000); Transaction tx = new Transaction(i, TransactionStatus.Successfull, "sender", "from", amount); cb.Add(tx); if (amount >= 200 && amount <= 600) { txs.Add(tx); } } int count = cb.Count; Assert.AreEqual(100000, count); Stopwatch watch = new Stopwatch(); watch.Start(); IEnumerable <Transaction> all = cb.GetAllInAmountRange(200, 600); int c = 0; foreach (Transaction tx in all) { Assert.AreSame(tx, txs[c]); c++; } watch.Stop(); long l1 = watch.ElapsedMilliseconds; Assert.IsTrue(l1 < 150); Assert.AreEqual(txs.Count, c); }
public void GetAllInAmountRange_ReturnsEmpty_WhenNoMatches() { CreateBulkOfTransactions(); Assert.That(testChainblock.GetAllInAmountRange(300, 350), Is.Empty); }
public void GetAllInAmountRange_ShouldReturnEmptyCollection() { var result = chainblock.GetAllInAmountRange(1, 100); Assert.IsEmpty(result); }