示例#1
0
        public void CalculateTest()
        {
            ITwoArgumentsCalculator calculator = new Multiplier();
            double result = calculator.Calculate(4, 2);

            Assert.AreEqual(8, result);
        }
示例#2
0
        public void CalculateTest(
            double firstValue,
            double secondValue,
            double expected)
        {
            var calculator   = new Multiplier();
            var actualResult = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, actualResult);
        }
示例#3
0
        public void CalculateTest2()
        {
            var multiplier = new Multiplier();

            var value1 = 2;
            var value2 = 5;

            var result = multiplier.Calculate(value1, value2);

            Assert.AreEqual(10, result);
        }
示例#4
0
        public void CalculateTest()
        {
            List <TestCalculation> tests = new List <TestCalculation>(new[]
            {
                new TestCalculation("10x100", "1000"),              // 2 x 4 = 8
                new TestCalculation("1101x10001", "11011101"),      // 13 x 17 = 221,
                new TestCalculation("1x11011‬", "11011"),           // 1 x 27 = 27
                new TestCalculation("0x10111", "0")                 // 0 x 23 = 0,
            });

            foreach (TestCalculation testCalculation in tests)
            {
                Multiplier multiplier = new Multiplier(testCalculation.TapeContent, Mode.Result);
                multiplier.Calculate();
                Assert.AreEqual(testCalculation.Output, multiplier.GetTapeContent());
            }
        }
示例#5
0
        public void TestMultiplier()
        {
            IExpression e = new Multiplier(new Constant(5.0), new Constant(2.0));

            Assert.AreEqual(10, e.Calculate());
        }