Esempio n. 1
0
    public void GetByTransactionStatusAndMaximumAmount_ShouldWorkCorrectly()
    {
        //Arrange
        IChainblock        cb       = new Chainblock();
        Transaction        tx1      = new Transaction(2, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction        tx2      = new Transaction(1, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction        tx3      = new Transaction(4, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction        tx4      = new Transaction(3, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction        tx5      = new Transaction(8, TransactionStatus.Successfull, "valq", "pesho", 17.8);
        List <Transaction> expected = new List <Transaction>()
        {
            tx3, tx4, tx1, tx2
        };

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        //Assert
        List <Transaction> actual = cb
                                    .GetByTransactionStatusAndMaximumAmount(TransactionStatus.Successfull, 17.0)
                                    .ToList();

        CollectionAssert.AreEqual(expected, actual);
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
    public void GetByTransactionStatus_ShouldReturnCorrectResult()
    {
        //Arrange
        IChainblock        cb       = new Chainblock();
        Transaction        tx1      = new Transaction(2, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction        tx2      = new Transaction(1, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction        tx3      = new Transaction(4, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction        tx4      = new Transaction(3, TransactionStatus.Failed, "valq", "pesho", 15.6);
        Transaction        tx5      = new Transaction(8, TransactionStatus.Successfull, "valq", "pesho", 17.8);
        List <Transaction> expected = new List <Transaction>()
        {
            tx5, tx3, tx1, tx2
        };

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        //Assert
        List <Transaction> actual = cb
                                    .GetByTransactionStatus(TransactionStatus.Successfull)
                                    .ToList();

        CollectionAssert.AreEqual(expected, actual);
    }
Esempio n. 4
0
    public void GetAllReceiversWithTransactionStatus_ShoudlThrowAfterRemove()
    {
        //Arrange
        IChainblock cb  = new Chainblock();
        Transaction tx1 = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 1);
        Transaction tx2 = new Transaction(6, TransactionStatus.Successfull, "joro", "pesho", 5.5);
        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.Failed, "joro", "pesho", 7.8);

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        cb.RemoveTransactionById(5);
        cb.RemoveTransactionById(7);
        cb.RemoveTransactionById(6);
        cb.RemoveTransactionById(12);
        cb.RemoveTransactionById(15);
        //Assert
        Assert.Throws <InvalidOperationException>(() =>
        {
            cb.GetAllReceiversWithTransactionStatus(TransactionStatus.Failed);
        });
    }
Esempio n. 5
0
    public void GetBySenderOrderedByAmountDescending_ShouldOn_MissingSender()
    {
        //Arrange
        IChainblock cb  = new Chainblock();
        Transaction tx1 = new Transaction(2, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction tx2 = new Transaction(1, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction tx3 = new Transaction(4, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction tx4 = new Transaction(3, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction tx5 = new Transaction(8, TransactionStatus.Failed, "valq", "pesho", 17.8);

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        cb.RemoveTransactionById(8);
        cb.RemoveTransactionById(3);
        //Assert
        Assert.Throws <InvalidOperationException>(() =>
        {
            List <Transaction> actual = cb
                                        .GetBySenderOrderedByAmountDescending("momo")
                                        .ToList();
        });
    }
    public void GetByTransactionStatusAndMaximumAmount_ShouldReturnEmptyCollection()
    {
        //Arrange
        IChainblock cb  = new Chainblock();
        Transaction tx1 = new Transaction(2, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction tx2 = new Transaction(1, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction tx3 = new Transaction(4, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction tx4 = new Transaction(3, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction tx5 = new Transaction(8, TransactionStatus.Failed, "valq", "pesho", 17.8);

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        //Assert
        List <Transaction> actual = cb
                                    .GetByTransactionStatusAndMaximumAmount(TransactionStatus.Unauthorized, 5)
                                    .ToList();

        CollectionAssert.AreEqual(new List <Transaction>(), actual);
        cb     = new Chainblock();
        actual = cb
                 .GetByTransactionStatusAndMaximumAmount(TransactionStatus.Unauthorized, 10)
                 .ToList();
        CollectionAssert.AreEqual(new List <Transaction>(), actual);
    }
Esempio n. 7
0
    public void GetByReceiverAndAmountRange_ShouldWorkCorrectly_On_CorrectRange()
    {
        //Arrange
        IChainblock        cb       = new Chainblock();
        Transaction        tx1      = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 1);
        Transaction        tx2      = new Transaction(6, TransactionStatus.Successfull, "joro", "pesho", 5.5);
        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.Failed, "joro", "resho", 7.8);
        List <Transaction> expected = new List <Transaction>()
        {
            tx4, tx2, tx3, tx1
        };

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        //Assert
        List <Transaction> actual = cb.GetByReceiverAndAmountRange("pesho", 0, 20).ToList();

        CollectionAssert.AreEqual(expected, actual);
    }
Esempio n. 8
0
    public void GetAllOrderedByAmountDescendingThenById_ShouldWorkCorrectly()
    {
        //Arrange
        IChainblock        cb       = new Chainblock();
        Transaction        tx1      = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 1);
        Transaction        tx2      = new Transaction(6, TransactionStatus.Successfull, "joro", "pesho", 5.5);
        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, tx2, tx3, tx1
        };

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        List <Transaction> actual = cb.GetAllOrderedByAmountDescendingThenById().ToList();

        //Assert
        CollectionAssert.AreEqual(expected, actual);
    }
Esempio n. 9
0
    public void GetBySenderOrderedByAmountDescending_ShouldWorkCorrectly_OnExistingSender()
    {
        //Arrange
        IChainblock        cb       = new Chainblock();
        Transaction        tx1      = new Transaction(2, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction        tx2      = new Transaction(1, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction        tx3      = new Transaction(4, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction        tx4      = new Transaction(3, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction        tx5      = new Transaction(8, TransactionStatus.Failed, "valq", "pesho", 17.8);
        List <Transaction> expected = new List <Transaction>()
        {
            tx5, tx3, tx4, tx1, tx2
        };

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        //Assert
        List <Transaction> actual = cb.GetBySenderOrderedByAmountDescending("valq").ToList();

        CollectionAssert.AreEqual(expected, actual);
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
    public void GetBySenderAndMinimumAmountDescending_ShouldOrderAndPickCorrectly()
    {
        //Arrange
        IChainblock        cb       = new Chainblock();
        Transaction        tx1      = new Transaction(2, TransactionStatus.Successfull, "joro", "pesho", 1);
        Transaction        tx2      = new Transaction(1, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction        tx3      = new Transaction(4, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction        tx4      = new Transaction(3, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction        tx5      = new Transaction(8, TransactionStatus.Failed, "valq", "pesho", 17.8);
        List <Transaction> expected = new List <Transaction>()
        {
            tx3
        };

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        cb.RemoveTransactionById(8);
        cb.RemoveTransactionById(3);
        //Assert
        List <Transaction> actual = cb.GetBySenderAndMinimumAmountDescending("valq", 15.5).ToList();

        CollectionAssert.AreEqual(expected, actual);
    }
Esempio n. 12
0
    public void GetAllReceiversWithTransactionStatus_ShouldWorkCorrectly()
    {
        //Arrange
        IChainblock   cb       = new Chainblock();
        Transaction   tx1      = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 1);
        Transaction   tx2      = new Transaction(6, TransactionStatus.Aborted, "joro", "pesho", 5.5);
        Transaction   tx3      = new Transaction(7, TransactionStatus.Successfull, "joro", "pesho", 5.5);
        Transaction   tx4      = new Transaction(12, TransactionStatus.Unauthorized, "joro", "pesho", 15.6);
        Transaction   tx5      = new Transaction(15, TransactionStatus.Unauthorized, "moro", "vesho", 7.8);
        List <string> expected = new List <string>()
        {
            "pesho", "vesho"
        };

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        List <string> actual = cb
                               .GetAllReceiversWithTransactionStatus(TransactionStatus.Unauthorized)
                               .ToList();

        //Assert
        CollectionAssert.AreEqual(expected, actual);
    }
Esempio n. 13
0
    public static void Main()
    {
        IChainblock cb = new Chainblock();

        Transaction tx1 = new Transaction(2, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction tx2 = new Transaction(1, TransactionStatus.Successfull, "valq", "pesho", 14.8);
        Transaction tx3 = new Transaction(4, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction tx4 = new Transaction(3, TransactionStatus.Successfull, "valq", "pesho", 15.6);
        Transaction tx5 = new Transaction(8, TransactionStatus.Failed, "valq", "pesho", 17.8);

        //List<Transaction> expected = new List<Transaction>()
        //{
        //    tx2
        //};
        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        cb.RemoveTransactionById(tx1.Id);
        //Assert
        List <Transaction> actual = cb
                                    .GetByTransactionStatusAndMaximumAmount(TransactionStatus.Successfull, 15.0)
                                    .ToList();

        Console.WriteLine(cb.Count);
        Console.WriteLine(string.Join(Environment.NewLine, actual));
    }
Esempio n. 14
0
    public void GetByReceiver_ShouldWorkCorrectly()
    {
        //Arrange
        IChainblock        cb       = new Chainblock();
        Transaction        tx1      = new Transaction(2, TransactionStatus.Successfull, "joro", "pesho", 1);
        Transaction        tx2      = new Transaction(1, TransactionStatus.Successfull, "joro", "pesho", 1);
        Transaction        tx3      = new Transaction(4, TransactionStatus.Successfull, "joro", "pesho", 15.6);
        Transaction        tx4      = new Transaction(3, TransactionStatus.Successfull, "joro", "pesho", 15.6);
        Transaction        tx5      = new Transaction(8, TransactionStatus.Failed, "joro", "pesho", 17.8);
        List <Transaction> expected = new List <Transaction>()
        {
            tx5, tx4, tx3, tx2, tx1
        };

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        //Assert
        List <Transaction> actual = cb.GetByReceiverOrderedByAmountThenById("pesho").ToList();

        CollectionAssert.AreEqual(expected, actual);
    }
Esempio n. 15
0
        public void Add_ThrowsException_WhenTransactionAlreadyExists()
        {
            Transaction first  = CreateSimpleTransaction();
            Transaction second = CreateSimpleTransaction();

            testChainblock.Add(first);
            Assert.Throws <InvalidOperationException>(() => testChainblock.Add(second));
        }
Esempio n. 16
0
        public void ContainsTransactionShouldReturnTrueIfTransactionExist()
        {
            //Act
            chainblock.Add(this.firstTransaction);
            //Assert
            var result = chainblock.Contains(this.firstTransaction);

            Assert.IsTrue(result);
        }
        public void Add_AddExistingTransactionShouldNotChangeCount()
        {
            IChainblock  chainblock     = new Chainblock();
            ITransaction transactionTwo = new Transaction(1, "C", "D", 20, TransactionStatus.Failed);

            chainblock.Add(this.transactionOne);
            chainblock.Add(transactionTwo);

            Assert.AreEqual(1, chainblock.Count);
        }
        public void Add_AddTwoTransaction_ShouldChangeCountToTwo()
        {
            IChainblock  chainblock     = new Chainblock();
            ITransaction transactionTwo = new Transaction(2, "C", "D", 20, TransactionStatus.Failed);

            chainblock.Add(this.transactionOne);
            chainblock.Add(transactionTwo);

            Assert.AreEqual(2, chainblock.Count);
        }
Esempio n. 19
0
    public void Count_Should_IncreaseOnMultiple_Elements()
    {
        //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.AreEqual(3, cb.Count);
    }
Esempio n. 20
0
        public void AddingTransactionWithExistingIdShouldThrowException()
        {
            ITransaction dummyTx = new Transaction(1, TransactionStatus.Aborted,
                                                   "me", "my friend", 1234.0);

            IChainblock chainblock = new Chainblock();

            chainblock.Add(dummyTx);

            Assert.Throws <InvalidOperationException>(() => chainblock.Add(dummyTx),
                                                      "Transaction id already exists.");

            Assert.That(chainblock.Count, Is.EqualTo(1),
                        "The count shouldn't increase with Add operation is invalid.");
        }
    public void Add_100000_Transactions_Should_WorkFast()
    {
        IChainblock cb    = new Chainblock();
        Stopwatch   sw    = new Stopwatch();
        int         count = 100_000;

        TransactionStatus[] statuses = new TransactionStatus[]
        {
            TransactionStatus.Aborted,
            TransactionStatus.Failed,
            TransactionStatus.Successfull,
            TransactionStatus.Unauthorized
        };
        Random rand = new Random();

        sw.Start();
        for (int i = 0; i < count; i++)
        {
            //int status = rand.Next(0, 4);
            cb.Add(new Transaction(i, TransactionStatus.Successfull,
                                   i.ToString(), i.ToString(), i));
        }

        sw.Stop();
        Assert.AreEqual(count, cb.Count);
        Assert.IsTrue(sw.ElapsedMilliseconds < 400);
    }
Esempio n. 22
0
    public void GetOrderedByAmountDescendingThenById_ShouldWorkFast()
    {
        IChainblock        cb  = new Chainblock();
        List <Transaction> txs = new List <Transaction>();

        for (int i = 0; i < 100000; i++)
        {
            Transaction tx = new Transaction(i, TransactionStatus.Successfull,
                                             i.ToString(), i.ToString(), i);
            cb.Add(tx);
            txs.Add(tx);
        }

        int count = cb.Count;

        Assert.AreEqual(100000, count);
        Stopwatch watch = new Stopwatch();

        watch.Start();

        IEnumerable <Transaction> all = cb.GetAllOrderedByAmountDescendingThenById();
        int c = 0;

        foreach (Transaction tx in all)
        {
            c++;
        }

        watch.Stop();
        long l1 = watch.ElapsedMilliseconds;

        Assert.IsTrue(l1 < 150);
        Assert.AreEqual(100000, c);
    }
Esempio n. 23
0
    public void GetById_On_NonExistingElement_ShouldThrow()
    {
        //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);
        cb.RemoveTransactionById(5);
        //Assert
        Assert.Throws <InvalidOperationException>(() => cb.GetById(5));
    }
Esempio n. 24
0
    public void RemoveById_ShoudlWorkFast()
    {
        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, 40000);
            int         status = amount % 4;
            Transaction tx     = new Transaction(i, (TransactionStatus)status,
                                                 i.ToString(), i.ToString(), amount);
            cb.Add(tx);
            txs.Add(tx);
        }

        int count = cb.Count;

        Assert.AreEqual(100000, count);

        Stopwatch watch = new Stopwatch();

        watch.Start();

        foreach (Transaction tx in txs)
        {
            cb.RemoveTransactionById(tx.Id);
        }

        watch.Stop();
        long l1 = watch.ElapsedMilliseconds;

        Assert.Less(l1, 220);
    }
Esempio n. 25
0
    public void ChangeTransactionStatus_ShouldWorkCorrectly_On_ExistingTX()
    {
        //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);
        cb.ChangeTransactionStatus(5, TransactionStatus.Aborted);
        //Assert
        Assert.AreEqual(TransactionStatus.Aborted, tx1.Status);
        Assert.AreEqual(3, cb.Count);
    }
    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));
    }
Esempio n. 27
0
    static void Main(string[] args)
    {
        IChainblock cb  = new Chainblock();
        Transaction tx1 = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 1);
        Transaction tx2 = new Transaction(6, TransactionStatus.Aborted, "joro", "pesho", 5.5);
        Transaction tx3 = new Transaction(7, TransactionStatus.Aborted, "joro", "pesho", 5.5);
        Transaction tx4 = new Transaction(12, TransactionStatus.Failed, "joro", "pesho", 15.6);
        Transaction tx5 = new Transaction(15, TransactionStatus.Successfull, "joro", "pesho", 7.8);

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.Add(tx4);
        cb.Add(tx5);
        //Assert
        var res = cb.GetAllSendersWithTransactionStatus(TransactionStatus.Unauthorized);
    }
Esempio n. 28
0
    public void Count_Should_RemainCorrect_AfterRemoving()
    {
        //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);
        cb.RemoveTransactionById(tx1.Id);
        cb.RemoveTransactionById(tx3.Id);
        //Assert
        Assert.AreEqual(1, cb.Count);
        Assert.AreNotSame(tx1, cb.GetById(tx2.Id));
    }
    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)));
    }
Esempio n. 30
0
    public void GetByReceiverAndAmountRange_ShouldThrow_AfterRemovingReceiver()
    {
        //Arrange
        IChainblock cb  = new Chainblock();
        Transaction tx1 = new Transaction(5, TransactionStatus.Successfull, "joro", "pesho", 1);
        Transaction tx2 = new Transaction(6, TransactionStatus.Successfull, "joro", "mesho", 5.5);
        Transaction tx3 = new Transaction(7, TransactionStatus.Successfull, "joro", "vesho", 5.5);

        //Act
        cb.Add(tx1);
        cb.Add(tx3);
        cb.Add(tx2);
        cb.RemoveTransactionById(5);
        //Assert
        Assert.Throws <InvalidOperationException>(() =>
        {
            cb.GetByReceiverAndAmountRange("pesho", 0, 20).ToList();
        });
    }