コード例 #1
0
 public void GetNetPayableAmountForEmployeeTest3()
 {
     Billing target = new Billing();
     User user = new User();
     double nonGroceryBill = 0;
     double groceryBill = 0; 
     UserType userType = UserType.Employee;
     double expected = 0; 
     double actual;
     actual = target.GetNetPayableAmount(user, nonGroceryBill, groceryBill, userType);
     Assert.AreEqual(expected, actual);
 }
コード例 #2
0
        /// <summary>
        /// To test the billing system.
        /// </summary>
        /// <param name="args">string argument</param>
        public static void Main(string[] args)
        {
            try
            {
                User user = new User();

                // Read the type of the user
                Console.WriteLine("\n----------------");
                Console.WriteLine("User Type:");
                Console.WriteLine("----------------\n");

                Console.Write(@"
1 - Employee
2 - Affiliate
3 - Customer

Please select one (1, 2, or 3): ");

                int userType = Int32.Parse(Console.ReadLine());
                while (true)
                {
                    if (userType < 1 || userType > 3)
                    {
                        Console.WriteLine("Invalid input");
                        Console.ReadKey();
                        break;
                    }

                    // Perform explicit cast from int to UserType enum type
                    UserType myUserType = (UserType)userType;

                    if (myUserType == UserType.Customer)
                    {
                        // Read membership date of the user
                        Console.Write("Enter Membership Date: ");
                        user.MembershipDate = DateTime.Parse(Console.ReadLine());
                    }

                    // Read Non Grocery Bill of the user
                    Console.Write("Enter Non Grocery Bill: ");
                    user.NonGroceryBill = Double.Parse(Console.ReadLine());

                    // Read Grocery Bill of the user
                    Console.Write("Enter Grocery Bill: ");
                    user.GroceryBill = Double.Parse(Console.ReadLine());

                    Billing billingObj = new Billing();
                    double netPayableAmount = billingObj.GetNetPayableAmount(user, user.NonGroceryBill, user.GroceryBill, myUserType);
                    Console.WriteLine("Net payable amount is: {0}", netPayableAmount);
                    Console.ReadLine();

                    System.Environment.Exit(0);
                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                Console.Read();

            }
        }
コード例 #3
0
        public void GetNetPayableAmountForNewCustomerTest7()
        {
            Billing target = new Billing();
            User user = new User();    
            user.MembershipDate = Convert.ToDateTime("2012-01-01");

            double nonGroceryBill = 50;
            double groceryBill = 50;
            UserType userType = UserType.Customer;
            double expected = 100;
            double actual;
            actual = target.GetNetPayableAmount(user, nonGroceryBill, groceryBill, userType);
            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
 public void GetNetPayableAmountForAffiliateTest7()
 {
     Billing target = new Billing();
     User user = new User();
     double nonGroceryBill = 50;
     double groceryBill = 50;
     UserType userType = UserType.Affiliate;
     double expected = 95;
     double actual;
     actual = target.GetNetPayableAmount(user, nonGroceryBill, groceryBill, userType);
     Assert.AreEqual(expected, actual);
 }