Beispiel #1
0
        public void TestUSDDeposit()
        {
            USDollars dollars = new USDollars();

            double expected = 100500;

            dollars.Deposit(500);

            Assert.AreEqual(expected, dollars.GetBalance());
        }
Beispiel #2
0
        public void TestUSDWithdraw()
        {
            USDollars dollars = new USDollars();

            double expected = 99500;

            dollars.Withdraw(500);

            Assert.AreEqual(expected, dollars.GetBalance());
        }
Beispiel #3
0
        public void TestUSDAdapterBalance()
        {
            USDollars usd = new USDollars();

            USDollarToBitcoinAdapter usdAdapter = new USDollarToBitcoinAdapter(usd);

            double expected = 100000 / 48475.30;

            Assert.AreEqual(expected, usdAdapter.GetBalance());
        }
Beispiel #4
0
        public void TestUSDAdapterDeposit()
        {
            USDollars usd = new USDollars();

            USDollarToBitcoinAdapter usdAdapter = new USDollarToBitcoinAdapter(usd);

            var amount = 1;

            usdAdapter.Deposit(amount);

            double expected = (100000 + 48475.30) / 48475.30;

            Assert.AreEqual(expected, usdAdapter.GetBalance());
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            MallardDuck duck = new MallardDuck();

            WildTurkey turkey = new WildTurkey();

            IDuck turkeyAdapter = new TurkeyAdapter(turkey);

            Console.WriteLine("The Turkey says...");
            turkey.Gobble();
            turkey.Fly();

            Console.WriteLine("\nThe Duck says...");
            testDuck(duck);

            Console.WriteLine("\nThe TurkeyAdapter says...");
            testDuck(turkeyAdapter);

            Bitcoin bitcoin = new Bitcoin();

            USDollars usd = new USDollars();

            IBit bitAdapter = new BitcoinToUSDollarsAdapter(bitcoin);

            IUSD usdAdapter = new USDollarToBitcoinAdapter(usd);

            Console.WriteLine($"\nYou have ${usd.GetBalance()} in your account.");

            Console.WriteLine($"\nYou have {bitcoin.GetBalance()} bitcoins in your account.");

            bitAdapter.Deposit(5000);

            usdAdapter.Deposit(1.5);

            Console.WriteLine($"\nYou have ${usd.GetBalance()} in your account.");

            Console.WriteLine($"\nYou have {bitcoin.GetBalance()} bitcoins in your account.");
        }