public void AddTest()
        {
            var controller = new MathController(new MathDbRepository());
            var id         = controller.Add(value1, value2);
            var result     = controller.GetResultById((int)id);

            Assert.AreEqual(result, 9);
        }
예제 #2
0
        public void ControllerUsesMathService()
        {
            //Arrange
            var service = new SpyMathService {
                Add_Result = 42
            };                                            // The answer to life, the universe, and everything.
            var controller = new MathController(service); //Now we can pass our fake in!
            int left       = 4;
            int right      = 12;

            //Act
            var result = controller.Add(left, right);

            //Assert
            Assert.AreEqual(service.Add_Result, result.ViewBag.TotalCount);
            Assert.AreEqual(service.Add_Left, left);
            Assert.AreEqual(service.Add_Right, right);
        }