Exemple #1
0
        [Test] public void StubbedMethodsCanBeCalledByOtherMethodsWithinObject()
        {
            DynamicMock mock = new DynamicMock(typeof(SameClass));

            mock.Ignore("A");
            mock.Ignore("c");
            SameClass sc = (SameClass)mock.MockInstance;

            mock.SetupResult("b", "hello");

            Assertion.AssertEquals("hello", sc.A());
        }
Exemple #2
0
        [Test] public void CanSetStubsAndExpectationsOnMethodsInTheSameClass()
        {
            DynamicMock mock = new DynamicMock(typeof(SameClass));

            mock.Ignore("A");
            SameClass sc = (SameClass)mock.MockInstance;

            mock.ExpectAndReturn("c", true);
            mock.SetupResult("b", "hello");

            AssertEquals("Should have overriden B()", "hello", sc.A());

            mock.Verify();
        }
Exemple #3
0
        public void ReuseGeneratedAssembly()
        {
            DynamicMock mock = new DynamicMock(typeof(SameClass));

            mock.Ignore("A");
            mock.Ignore("c");
            SameClass sc = (SameClass)mock.MockInstance;

            mock.SetupResult("b", "hello");
            Assertion.AssertEquals("hello", sc.A());

            mock = new DynamicMock(typeof(SameClass));
            mock.Ignore("A");
            sc = (SameClass)mock.MockInstance;

            mock.ExpectAndReturn("c", true);
            mock.SetupResult("b", "hello");

            AssertEquals("Should have overriden B()", "hello", sc.A());
            mock.Verify();
        }