Exemplo n.º 1
0
        public void TestCarUnity()
        {
            IUnityContainer      container = new UnityContainer();
            Mock <MockTest.ICar> car       = new Mock <MockTest.ICar>();
            bool isCarRun = false;

            car.Setup(m => m.Run()).Callback(() =>
            {
                isCarRun = true;
            }).Returns(3);
            container.RegisterInstance(car.Object);
            MockTest mockTest = new MockTest(container);
            int      res      = mockTest.DoRun();

            Assert.AreEqual(3, res);
            Assert.AreEqual(isCarRun, true);
        }
Exemplo n.º 2
0
        public void TestCarUnityRhino()
        {
            IUnityContainer container = new UnityContainer();
            var             car       = MockRepository.GenerateStub <MockTest.ICar>();
            bool            isCarRun  = false;

            car.Stub(m => m.Run()).Callback(() =>
            {
                isCarRun = true;
                return(true);
            }).Return(3);
            container.RegisterInstance(car);
            MockTest mockTest = new MockTest(container);
            int      res      = mockTest.DoRun();

            Assert.AreEqual(3, res);
            Assert.AreEqual(isCarRun, true);
        }