コード例 #1
0
        public void canAddException()
        {
            int    resultMax = 10;
            int    valMax    = 4;
            Abacus abacus    = new Abacus(valMax, resultMax);
            //Assert.Equal(7, abacus.Add(5, 2));

            Exception ex = Assert.Throws <ValidationException>(() => abacus.Add(3, 8));

            Assert.Equal(string.Format("value must be less than or equal to {0}.", valMax), ex.Message);
        }
コード例 #2
0
        public void canAddNumbersFromInlineDataInput2(int x, int y)
        {
            //arrange
            Abacus abacus = new Abacus(Math.Max(x, y), x + y);

            Console.WriteLine("value :" + Math.Max(x, y));
            //act
            int result = abacus.Add(x, y);

            //assert
            Assert.True(result > 0);
            Assert.Equal(x + y, result);
        }
コード例 #3
0
        public void canAddNumbersFromInlineDataInput(int x, int y)
        {
            //arrange :Prepare for the test
            Abacus abacus = new Abacus(Math.Max(x, y), x + y);

            Console.WriteLine("value :" + Math.Max(x, y));
            //act : Run the SUT(System Under Test)
            int result = abacus.Add(x, y);

            //assert : Check et verify the result
            Assert.True(result > 0);
            Assert.Equal(x + y, result);
        }
コード例 #4
0
        public void canAddToResultLimit()
        {
            Abacus abacus = new Abacus(2, 4);

            Assert.Equal(4, abacus.Add(5, 2));
        }
コード例 #5
0
        public void canAddOnePlusOne()
        {
            Abacus abacus = new Abacus(2, 4);

            Assert.Equal(2, abacus.Add(1, 1));
        }