Example #1
0
 public void TestAdd()
 {
     Calculator calculator = new Calculator();
     calculator.Operand1 = 10;
     calculator.Operand2 = 20;
     Assert.AreEqual(calculator.Add(), 30);
 }
        public void Add_ValidNumbers()
        {
            var target = new Calculator();
            var ret = target.Add(1, 2);

            Assert.AreEqual(3, ret);
        }
 public void AddSimple()
 {
     //ARRANGE: (set up environment to run test)
     var calculator = new MyCalculator.Calculator();
     //ACT: (run code we are trying to test)
     int sum = calculator.Add(1, 2);
     //ASSERT: (validate expected results)
     Assert.AreEqual(3, sum);
 }
Example #4
0
 public static void Main()
 {
     Calculator caclulator = new Calculator();
     caclulator.Operand1 = 100;
     caclulator.Operand2 = 200;
     Console.WriteLine(caclulator.Add());
     Console.WriteLine(caclulator.Subtract());
     Console.WriteLine(caclulator.Multiply());
     Console.WriteLine(caclulator.Divide());
 }
        [Priority(0)]                 // Another 'Attribute' for catagorizing
        public void AddSimple()
        {
            //ARRANGE: (set up environment to run test)
            var calculator = new MyCalculator.Calculator();
            //ACT: (run code we are trying to test)
            int sum = calculator.Add(1, 2);

            //ASSERT: (validate expected results)
            Assert.AreEqual(3, sum);
        }
        public void testAdd()
        {
            // Arrange
            Calculator calculator = new Calculator();
            int augend = 1,
                addend = 2,
                expected = 3,
                actual;

            // Act
            actual = calculator.Add(augend, addend);

            // Assert
            Assert.AreEqual(expected, actual);
        }
Example #7
0
        public void TestCreateACalculator()
        {
            Calculator eenCalculator = new Calculator();
            double bigInt = 1;
            Assert.AreEqual(bigInt, eenCalculator.Add(0, 1), "0 + 1 is in decimale Stelsel  1 ");
            
            ///Invariant introduceren...
            for (int i = 0; i < 1000; i++)///int.MaxValue=> te lang?
            {
                Assert.AreEqual((double)i + 1, eenCalculator.Add(i, 1));
            }

            #region simple calculator


            bigInt = 10;
            Assert.AreEqual(bigInt, eenCalculator.TelOp(new double[] { 1, 2, 3, 4 }));
            bigInt = 10;
            Assert.AreEqual(bigInt, eenCalculator.PersistResults());

            #endregion

            var eenComputer = new Computer<TertaireStelsel>();
            IMathFunctions andereCalculator = eenComputer.MathFunctions;
            IOutput anderUItvoer = eenComputer.Output;
            
            bigInt = 2;
            Assert.AreEqual(bigInt, andereCalculator.Add(1, 1), "1+1=2 ook in tertaire Stelsel.");
            Assert.AreEqual(bigInt, anderUItvoer.PersistResults());

            
            ///eenCalculator.GaInTertaireStelselModus();///???
            /// ///eenCalculator.GaInTertaireStelselModus();///???
            /// ///eenCalculator.GaInXStelselModus();///???
            /// ///eenCalculator.GaInTertaireStelselModus(X);///???
            /// ///eenCalculator.GaInStelselModus(Y);///???
            #region uitbreiding stelsel (functionaliteit) naar ander uitvoer.

            //var andereModus = new Computer<TertaireStelsel>();
            //IMathFunctions andereCalculator = andereModus.MathFunctions;
            //IOutput anderUItvoer = andereModus.Output;

            //bigInt = 1;
            //Assert.AreEqual(bigInt, andereCalculator.Add(1, 2), "review tertaire Stelsel.");
            //Assert.AreEqual(bigInt, anderUItvoer.PersistResults());

            //MathFunctions<TCalculator> calc = new MathFunctions<TCalculator>();
            
            //Assert.AreEqual(bigInt, andereCalculator.Add(353, 445), "(1242) review quartaire Stelsel.");
            
            //Assert.AreEqual("", eenCalculator.Add(0, 1), "review kwintaire Stelsel.");
            //Assert.AreEqual("", eenCalculator.Add(0, 1), "review sextaire Stelsel."); 


            #endregion

            #region Uitbreiding onbekende functionaliteit



            Log.ConsoleWriteline(ulong.MaxValue.ToString());
            Log.ConsoleWriteline(double.MaxValue.ToString());
            Log.ConsoleWriteline(long.MaxValue.ToString());
            double getal = 18446744073709551615 - 1;
            Log.ConsoleWriteline(getal.ToString());
            #endregion
            
        }
Example #8
0
        static void Main(string[] args)
        {
            Calculator c = new Calculator();
            // Calculator c2 = new Calculator();
            // Console.WriteLine(Math.Round(c2.Tan(20), 4));
            double n1 = 0, n2;
            string again = "";
            bool   keep  = true;


            do
            {
                do
                {
                    keep = true;
                    try
                    {
                        Console.WriteLine("This is a Calculator, enter number, action, number ");
                        Console.WriteLine("Available Actions : ");
                        Console.WriteLine("+ - * / % pow sqrt sine cos tan ");

                        n1 = double.Parse(Console.ReadLine());
                    }

                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        keep = false;
                    }
                } while (keep == false);

                string action = (Console.ReadLine());



                if ((action.ToUpper() != "SQRT") &&
                    (action.ToUpper() != "SINE") &&
                    (action.ToUpper() != "COS") &&
                    (action.ToUpper() != "TAN"))
                {
                    n2 = int.Parse(Console.ReadLine());
                }

                else
                {
                    n2 = 0;
                }


                if (action == "+")
                {
                    Console.WriteLine("Answer is " + c.Add(n1, n2));
                }

                else if (action == "-")
                {
                    Console.WriteLine(c.Sub(n1, n2));
                }

                else if (action == "*")
                {
                    Console.WriteLine(c.Mul(n1, n2));
                }

                else if (action == "/")
                {
                    Console.WriteLine(c.Div(n1, n2));
                }

                else if (action == "%")
                {
                    Console.WriteLine(c.Mod(n1, n2));
                }

                else if (action.ToUpper() == "POW")
                {
                    Console.WriteLine(c.Power(n1, n2));
                }

                else if (action.ToUpper() == "SQRT")
                {
                    Console.WriteLine(c.Sqrt(n1));
                }

                else if (action.ToUpper() == "SINE")
                {
                    Console.WriteLine(c.Sine(n1));
                }

                else if (action.ToUpper() == "COS")
                {
                    Console.WriteLine(c.Cos(n1));
                }

                else if (action.ToUpper() == "TAN")
                {
                    Console.WriteLine(c.Tan(n1));
                }

                else
                {
                    Console.WriteLine("Invalid Entry");
                }

                Console.WriteLine("Continue, Yes or No? ");
                again = Console.ReadLine();
            } while (again.ToUpper() == "YES");
        }