Ejemplo n.º 1
0
        public void TestBitAdapterBalance()
        {
            Bitcoin bitcoin = new Bitcoin();

            BitcoinToUSDollarsAdapter bitcoinAdapter = new BitcoinToUSDollarsAdapter(bitcoin);


            double expected = 28 * 48475.30;

            Assert.AreEqual(expected, bitcoinAdapter.GetBalance());
        }
Ejemplo n.º 2
0
        public void TestBitAdapterDeposit()
        {
            Bitcoin bitcoin = new Bitcoin();

            BitcoinToUSDollarsAdapter bitcoinAdapter = new BitcoinToUSDollarsAdapter(bitcoin);

            var amount = 48475.30;

            bitcoinAdapter.Deposit(amount);

            double expected = 29 * 48475.30;

            Assert.AreEqual(expected, bitcoinAdapter.GetBalance());
        }
Ejemplo n.º 3
0
        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.");
        }