コード例 #1
0
        public void ContainsTransaction_ShouldReturnFalse()
        {
            ITransaction t =
                new Transaction(1, TransactionStatus.Successfull, "Gosho", "Gichka", 12);

            Assert.IsFalse(chainblock.Contains(t));
        }
コード例 #2
0
ファイル: ChainblockTest.cs プロジェクト: stormageddon94/OOP
        public void ContainsTransactionShouldReturnTrueIfTransactionExist()
        {
            //Act
            chainblock.Add(this.firstTransaction);
            //Assert
            var result = chainblock.Contains(this.firstTransaction);

            Assert.IsTrue(result);
        }
コード例 #3
0
ファイル: Test05.cs プロジェクト: player200/SoftUni
    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)));
    }
コード例 #4
0
        public void ContainsTransaction_EmptyCollection_ShoudReturnFalse()
        {
            IChainblock chainblock = new Chainblock();
            bool        actualRes  = chainblock.Contains(this.transactionOne);

            Assert.IsFalse(actualRes);
        }
コード例 #5
0
        public void ContainsId_ExistingCollection_ShoudReturnTrue()
        {
            IChainblock chainblock = new Chainblock(this.transactionOne);
            bool        actualRes  = chainblock.Contains(1);

            Assert.IsTrue(actualRes);
        }
コード例 #6
0
        public void ContainsId_EmptyCollection_ShoudReturnFalse()
        {
            IChainblock chainblock = new Chainblock();
            bool        actualRes  = chainblock.Contains(1);

            Assert.IsFalse(actualRes);
        }
コード例 #7
0
    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));
    }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
    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)));
    }
コード例 #11
0
    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);
    }
コード例 #12
0
ファイル: Program.cs プロジェクト: robologic/DataStructures
    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);
    }
コード例 #13
0
ファイル: Tests.cs プロジェクト: Bozhikov99/CSharp-Advanced
 public void Contains_DoesNotContainTransaction()
 {
     Assert.That(testChainblock.Contains(CreateSimpleTransaction()), Is.False);
 }