public void DistributedTransactionTest() { int account_count = 5; long init_balance = 1000; List <AccountBase> accounts = new List <AccountBase>(); // init account(s) for (int i = 0; i < account_count; i++) { accounts.Add(new NetworkAccount(new MainAccount(init_balance))); } Random _rnd = new Random(); // execute transactions for (int i = 0; i < 100000; i++) { // prepare transaction cmds List <TransactionCmd> cmds = new List <TransactionCmd>(); long total_amount = 0; for (int j = 0; j < (account_count - 1); j++) { TransactionCmd current_tc = new TransactionCmd() { account = accounts[j], amount = _rnd.Next(10) - 5 }; total_amount += current_tc.amount; cmds.Add(current_tc); } cmds.Add(new TransactionCmd() { account = accounts[accounts.Count - 1], amount = 0 - total_amount }); // execute transaction AccountBase.ExecTransaction(cmds.ToArray()); } // check result long total_balances = 0; foreach (AccountBase a in accounts) { total_balances += a.GetBalance(); } Assert.AreEqual <long>( account_count * init_balance, total_balances); }