コード例 #1
0
        public void TestMethodTransactions()
        {
            //проверка поиска транзакций
            db0.DeleteAsync(ban).Wait();
            Assert.IsTrue(db.SearchUsers(userName).Count == 1);
            Assert.IsTrue(db.SearchUsers(VotingsUser.PublicKey).Count == 1);
            Assert.IsTrue(db.SearchUsers(userId).Count == 1);
            db0.InsertAsync(ban).Wait();
            Thread.Sleep(1000);


            Assert.IsTrue(db.GetTransaction(user.Hash).Hash == user.Hash);
            Assert.IsTrue(db.TransactionsCount() == 4);
            Assert.IsTrue(db.UsersCount() == 1);
            Assert.IsTrue(db.UserAsCandidateCount(VotingsUser.PublicKey) == 1);
            Assert.IsTrue(db.GetVoting(votingNum).Hash == voting.Hash);
            Assert.IsTrue(db.GetLastVoting().Hash == voting.Hash);
            Assert.IsTrue(db.GetLastVoting().Hash == voting.Hash);
            Assert.IsTrue(db.GetUserCreation(VotingsUser.PublicKey).Hash == user.Hash);

            Assert.IsTrue(db.GetLastUserCreation().Hash == user.Hash);
            Assert.IsTrue(db.GetLastTransaction().Hash == ban.Hash);
            Assert.IsTrue(db.GetFreeTransactionsFromDate(new DateTime(2015, 1, 1), 10).Count == 4);
            Assert.IsTrue(db.GetSameUser(user) == null);
            Assert.IsTrue(db.GetUserBan(VotingsUser.PublicKey).Hash == ban.Hash);
            Assert.IsTrue(db.GetUserVote(VotingsUser.PublicKey, votingNum).Hash == vote.Hash);
            Assert.IsTrue(db.GetVotings().Count == 1);

            var results = db.GetCandidatesResults(voting);

            Assert.IsTrue(results.Count == 1 && results.Keys.First().Hash == user.Hash && results.Values.First() == 1);

            var results2 = db.GetCandidates(voting);

            Assert.IsTrue(results2.Count == 1 && results2[0].Hash == user.Hash);

            var results3 = db.GetUserVotesAndVotings(VotingsUser.PublicKey);

            Assert.IsTrue(results3.Count == 1 && results3.Keys.First().Hash == voting.Hash && results3.Values.First().Hash == vote.Hash);

            Assert.IsTrue(db.GetUserOpenedVotings().Count == 0);
            Assert.IsTrue(db.GetUserVotes(VotingsUser.PublicKey).Count == 1);
            Assert.IsTrue(db.GetUserVotes(VotingsUser.PublicKey).Count == 1);
            Assert.IsTrue(db.GetFreeTransactions(10).Count == 4);

            //проверка пометки статуса транзакций
            ban.Status = TransactionStatus.InPendingBlock;
            db0.UpdateAsync(ban);
            db.MarkAsFreePendingTransactions(true);
            Assert.IsTrue(db.GetTransaction(ban.Hash).Status == TransactionStatus.Free);

            ban.Status = TransactionStatus.InBlock;
            db0.UpdateAsync(ban);
            db.MarkAsFreePendingTransactions(false);
            Assert.IsTrue(db.GetTransaction(ban.Hash).Status == TransactionStatus.InBlock);
        }