Inheritance: ICalculator, ICalc2
Exemplo n.º 1
0
        public void Calculate2Test_針對Revenue資料每4筆進行加總()
        {
            var target = new MyCalculator();

            int GroupCountTest = 4;
            // DdlType: 0:Cost,1:Revenue,2:SellPrice。
            var DType = "1";
            var lhw = new List<HomeWork>()
            {
                new HomeWork(){ Id = 1, Cost = 1, Revenue = 11, SellPrice = 21 },
                new HomeWork(){ Id = 2, Cost = 2, Revenue = 12, SellPrice = 22 },
                new HomeWork(){ Id = 3, Cost = 3, Revenue = 13, SellPrice = 23 },
                new HomeWork(){ Id = 4, Cost = 4, Revenue = 14, SellPrice = 24 },
                new HomeWork(){ Id = 5, Cost = 5, Revenue = 15, SellPrice = 25 },
                new HomeWork(){ Id = 6, Cost = 6, Revenue = 16, SellPrice = 26 },
                new HomeWork(){ Id = 7, Cost = 7, Revenue = 17, SellPrice = 27 },
                new HomeWork(){ Id = 8, Cost = 8, Revenue = 18, SellPrice = 28 },
                new HomeWork(){ Id = 9, Cost = 9, Revenue = 19, SellPrice = 29 },
                new HomeWork(){ Id = 10, Cost = 10, Revenue = 20, SellPrice = 30 },
                new HomeWork(){ Id = 11, Cost = 11, Revenue = 21, SellPrice = 31 }
            };
            List<int> strAns = new List<int>() { 50, 66, 60 };

            List<int> strAnsCalculate = target.Calculation_results(GroupCountTest, DType, lhw);

            CollectionAssert.AreEqual(strAns, strAnsCalculate);//會比順序       
        }
Exemplo n.º 2
0
        public void 傳入1跟2然後回傳3()
        {
            //arrange
            var target = new MyCalculator();
            var first = 1;
            var second = 2;

            var expected = 3;
            //act
            var actual = target.Add(first, second);
            //assert

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void AddTest_first_1_second_2_should_be_3()
        {
            //arrange
            var target = new MyCalculator();
            var first = 1;
            var second = 2;
            var expected = 3;

            //act
            var actual = target.Add(first, second);

            //assert
            Assert.AreEqual(expected, actual);
        }
 public MainWindow()
 {
     InitializeComponent();
     MyCalculator _app = new MyCalculator(this);
 }
Exemplo n.º 5
0
 static void Main(string[] args)
 {
     ICalc2 mu= new MyCalculator();
     Console.WriteLine(mu.Sum());
 }
Exemplo n.º 6
0
            public bool Menu()
            {
                Console.Clear();
                Console.WriteLine("\tCalculator");
                Console.WriteLine("Choose any of these options o peform: ");
                Console.WriteLine("1) Addition");
                Console.WriteLine("2) Substraction");
                Console.WriteLine("3) Multiplication");
                Console.WriteLine("4) Division");
                Console.WriteLine("5) Squaer root");
                Console.WriteLine("6) Power of x");
                Console.WriteLine("7) sin(x)");
                Console.WriteLine("8) cos(x)");
                Console.WriteLine("9) tan(x)");
                Console.WriteLine("Press Any keywrod to close Program.... ");

                MyCalculator cls          = new MyCalculator();
                string       chosenOption = Console.ReadLine();

                switch (chosenOption)
                {
                case "1":
                    Console.Clear();
                    cls.Addition();
                    return(true);

                case "2":
                    Console.Clear();
                    cls.Substractions();
                    return(true);

                case "3":
                    Console.Clear();
                    cls.Multiplicaion();
                    return(true);

                case "4":
                    Console.Clear();
                    cls.Division();
                    return(true);

                case "5":
                    Console.Clear();
                    cls.SqrtRoot();
                    return(true);

                case "6":
                    Console.Clear();
                    cls.Power();
                    return(true);

                case "7":
                    Console.Clear();
                    cls.sin();
                    return(true);

                case "8":
                    Console.Clear();
                    cls.cos();
                    return(true);

                case "9":
                    Console.Clear();
                    cls.tan();
                    return(true);

                default:
                    return(false);
                }
            }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            MyCalculator cal = new MyCalculator();

            cal.displayMenu();
        }