public void MockClassWithVirtualMethodCallFromConstructor()
        {
            MockRepository mocks = new MockRepository();
            ClassWithVirtualMethodCallFromConstructor cwvmcfc = (ClassWithVirtualMethodCallFromConstructor)mocks.StrictMock(typeof(ClassWithVirtualMethodCallFromConstructor));

            Assert.NotNull(cwvmcfc);
            Expect.Call(cwvmcfc.ToString()).Return("Success");
            mocks.ReplayAll();
            Assert.Equal("Success", cwvmcfc.ToString());
            mocks.VerifyAll();
        }
Exemple #2
0
        public void MockClassWithVirtualMethodCallFromConstructor()
        {
            ClassWithVirtualMethodCallFromConstructor cwvmcfc =
                MockRepository.Mock <ClassWithVirtualMethodCallFromConstructor>();

            Assert.NotNull(cwvmcfc);

            cwvmcfc.Expect(x => x.ToString())
            .Return("Success");

            Assert.Equal("Success", cwvmcfc.ToString());
            cwvmcfc.VerifyExpectations(true);
        }