mardi 21 avril 2020

Moq C# call method to test

I'm new to Testing in C# and I'm trying to test a method that only increments some passed integer value (when it's called with 5 it returns 6). What am I doing wrong here? result is always 0.

public void TestMethod2()
        {
            //Act
            int numberToCheck = 5;
            mock.CallBase = true;
            mock.Setup(x => x.CalculateTest(numberToCheck)).Returns(6);
            int result = mock.Object.CalculateTest(It.IsAny<int>());
            int expected = numberToCheck + 1;

            //Assert
            Assert.AreEqual(expected, result);
        }

Aucun commentaire:

Enregistrer un commentaire