Exemple #1
0
        public void GetBalance_AccountProvidedInCommandLine_UsesDefaultAccount()
        {
            string account = "rKsphokjVPYm9UqCrarZiNdFTpnTraayKH";

            var response = new GetAccountBalancesResponse()
            {
                Success   = true,
                Validated = true,
                Balances  = new GetAccountBalancesResponse.Balance[] {
                    new GetAccountBalancesResponse.Balance()
                    {
                        Value = 3, Currency = "XRP", Counterparty = null
                    }
                }
            };

            clientMock.Setup(c => c.GetAccountBalancesAsync(account)).Returns(Task.FromResult(response));

            var cmd = new GetBalanceCommand(clientMock.Object, accountProviderMock.Object);

            cmd.Execute(new string[] { account }, output, errorOutput);

            Assert.AreEqual("", errorOutput.ToString());
            Assert.AreEqual("", errorOutput.ToString());

            clientMock.Verify(c => c.GetAccountBalancesAsync(account), Times.Once);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var client = new TCPClient {
                ServerHost = "127.0.0.1", ServerPort = 32456
            };
            var cmd1 = new SignUpCommand()
            {
                UserLogin = "******", UserPassword = "******"
            };
            var answer1 = client.SendRequest(cmd1);

            if (answer1 is OkAnswer)
            {
                Console.WriteLine("OK");
            }
            else
            {
                Console.WriteLine("Registration is fail");
            }

            var cmd2 = new SignUpCommand()
            {
                UserLogin = "******", UserPassword = "******"
            };
            var answer2 = client.SendRequest(cmd2);

            if (answer2 is OkAnswer)
            {
                Console.WriteLine("OK");
            }
            else
            {
                Console.WriteLine("Registration is fail");
            }

            var cmd3 = new LoginCommand()
            {
                UserLogin = "******", UserPassword = "******"
            };
            var answer3 = client.SendRequest(cmd3);

            if (answer3 is OkAnswer)
            {
                Console.WriteLine("OK You are in Database ");
            }
            else
            {
                Console.WriteLine("Registration is fail");
            }

            var cmd4 = new CreateAccountCommand()
            {
                UserLogin = "******", Currency = Currency.UA
            };
            var answer4 = client.SendRequest(cmd4);

            if (answer4 is OkAnswer)
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine(" Is fail");
            }

            var cmd9 = new CreateAccountCommand()
            {
                UserLogin = "******", Currency = Currency.US
            };
            var answer9 = client.SendRequest(cmd9);

            if (answer9 is OkAnswer)
            {
                Console.WriteLine("Ok Second acc");
            }
            else
            {
                Console.WriteLine(" Is fail");
            }

            var cmd5 = new GetBalanceCommand()
            {
                AccountId = "1"
            };
            var answer5 = client.SendRequest(cmd5);

            if (answer5 is BalanceAnswer)
            {
                Console.WriteLine((answer5 as BalanceAnswer).Balans);
            }
            else
            {
                Console.WriteLine(" Is fail");
            }
            var cmd6 = new CreateFirstTransactionsCommand()
            {
                Sum = 100, AccountId = "1"
            };
            var answer6 = client.SendRequest(cmd6);

            if (answer6 is OkAnswer)
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine(" Is fail");
            }

            var cmd7 = new GetBalanceCommand()
            {
                AccountId = "1"
            };
            var answer7 = client.SendRequest(cmd7);

            if (answer7 is BalanceAnswer)
            {
                Console.WriteLine((answer7 as BalanceAnswer).Balans);
            }
            else
            {
                Console.WriteLine(" Is fail");
            }

            var cmd8 = new GetClientAccountCommand()
            {
                UserLogin = "******"
            };
            var answer8 = client.SendRequest(cmd8);

            if (answer8 is ClientAccountAnswer)
            {
                foreach (var p in (answer8 as ClientAccountAnswer).Accounts)
                {
                    Console.WriteLine(p.Balance);
                }
            }
            else
            {
                Console.WriteLine("Fail");
            }

            var cmd10 = new CreateTransactionCommand()
            {
                FromAccountId = "1", ToAccountId = "2", Sum = 50
            };
            var answer10 = client.SendRequest(cmd10);

            if (answer10 is OkAnswer)
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine(" Is fail");
            }

            var cmd11 = new GetClientAccountCommand()
            {
                UserLogin = "******"
            };
            var answer11 = client.SendRequest(cmd11);

            if (answer11 is ClientAccountAnswer)
            {
                foreach (var p in (answer11 as ClientAccountAnswer).Accounts)
                {
                    Console.WriteLine(p.Id);
                }
            }
            else
            {
                Console.WriteLine("Fail");
            }


            Console.ReadLine();
        }