Exemple #1
0
        public void Sell_XRPTest()
        {
            User    test    = new MoneyTransfer657.User("Erik Lomas");
            decimal xrp_bal = test.Xrp;

            test.Sell_XRP(1m);
            Assert.AreEqual(test.Xrp, (xrp_bal - 1m));
        }
Exemple #2
0
        private void SellCoinButton_Click(object sender, RoutedEventArgs e)
        {
            decimal amount_to_sell;
            bool    isNumeric = decimal.TryParse(coinBuySellAmountTextBox.Text, out amount_to_sell);

            if (isNumeric == false)
            {
                MessageBox.Show("Only enter numbers for amount of coins to buy/sell");
                return;
            }
            if (selectCoinComboBox.SelectedIndex == 0)
            {
                if (amount_to_sell > user.Btc)
                {
                    MessageBox.Show("You dont have that much BTC to sell");
                    return;
                }
                Thread sell = new Thread(() =>
                {
                    user.Sell_BTC(amount_to_sell);
                    user.Add_Transaction(user.Username, "global", "BTC", amount_to_sell.ToString(), "sell crypto");
                });
                sell.Start();
                sell.Join();
            }
            else if (selectCoinComboBox.SelectedIndex == 1)
            {
                if (amount_to_sell > user.Eth)
                {
                    MessageBox.Show("You dont have that much ETH to sell");
                    return;
                }
                Thread sell = new Thread(() =>
                {
                    user.Sell_ETH(amount_to_sell);
                    user.Add_Transaction(user.Username, "global", "ETH", amount_to_sell.ToString(), "sell crypto");
                });
                sell.Start();
                sell.Join();
            }
            else if (selectCoinComboBox.SelectedIndex == 2)
            {
                if (amount_to_sell > user.Xrp)
                {
                    MessageBox.Show("You dont have that much XRP to sell");
                    return;
                }
                Thread sell = new Thread(() =>
                {
                    user.Sell_XRP(amount_to_sell);
                    user.Add_Transaction(user.Username, "global", "XRP", amount_to_sell.ToString(), "sell crypto");
                });
                sell.Start();
                sell.Join();
            }
            else
            {
                MessageBox.Show("Please select a coin before buying or selling.");
            }
            Update_Owned();
            MessageBox.Show("Sale Complete");
        }