public void TestUSDAdapterBalance() { USDollars usd = new USDollars(); USDollarToBitcoinAdapter usdAdapter = new USDollarToBitcoinAdapter(usd); double expected = 100000 / 48475.30; Assert.AreEqual(expected, usdAdapter.GetBalance()); }
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."); }