Exemplo n.º 1
0
    public static void Main()
    {
        JointAccount acc = new JointAccount();

        acc.Deposit(10000);
        Console.WriteLine("Joint-Account with ID {0} opened for Jack and Jill.", acc.Id);
        Console.WriteLine("Initial balance = {0}", acc.Balance);

        Thread child = new Thread(delegate()
        {
            Console.WriteLine("Jack withdraws 6000 from joint-account...");
            if (acc.Withdraw(6000) == false)
            {
                Console.WriteLine("Jack's withdraw operation failed!");
            }
        });

        child.Start();

        Console.WriteLine("Jill withdraws 7000 from joint-account...");
        if (acc.Withdraw(7000) == false)
        {
            Console.WriteLine("Jill's withdraw operation failed!");
        }

        child.Join();         //current thread waits for child to exit
        Console.WriteLine("Final balance = {0}", acc.Balance);
    }
Exemplo n.º 2
0
        public void Setup()
        {
            MaxCups   = 25;
            softdrink = new Drink(0.50m, "Soft drink");

            accountServer = AccountServer.GetAccountServerInstance as AccountServer;

            card1 = new CashCard("12345", 1001);
            card2 = new CashCard("67890", 1002);

            card3 = new CashCard("11111", 2001);
            card4 = new CashCard("22222", 2002);

            accountWithBalance             = new JointAccount("101", 20m, card1, card2);
            accountWithInsufficientBalance = new JointAccount("102", 0.45m, card3, card4);

            //add some test accounts
            accountServer.AddAccount(accountWithBalance);
            accountServer.AddAccount(accountWithInsufficientBalance);
        }
        public async Task TestGetJointAccount()
        {
            // Perform API call
            JointAccount result = null;

            try
            {
                result = await _controller.GetJointAccountAsync();
            }
            catch (APIException) {};

            // Test response code
            Assert.AreEqual(200, HTTPCallBackHandler.Response.StatusCode,
                            "Status should be 200");

            // Test headers
            var headers = new Dictionary <string, string>();

            headers.Add("Content-Type", "application/json");

            Assert.IsTrue(TestHelper.AreHeadersProperSubsetOf(
                              headers, HTTPCallBackHandler.Response.Headers),
                          "Headers should match");
        }