diff --git a/Telerik.JustMock.Tests/MockFixture.cs b/Telerik.JustMock.Tests/MockFixture.cs index dfdbc28..76a3bfc 100644 --- a/Telerik.JustMock.Tests/MockFixture.cs +++ b/Telerik.JustMock.Tests/MockFixture.cs @@ -2338,11 +2338,24 @@ namespace Telerik.JustMock.Tests { var nestedType = typeof(NestingType).GetNestedType("NestedWrapperType", BindingFlags.NonPublic) .GetNestedType("NestedType", BindingFlags.NonPublic); + var mock = Mock.Create(nestedType); Mock.NonPublic.Arrange(mock, "Do").Returns(123); Assert.Equal(123, NestingType.Test(mock)); } + [TestMethod] + public void ShouldCallOriginalMethodOnProtectedType() + { + var nestedType = typeof(NestingType).GetNestedType("NestedWrapperType", BindingFlags.NonPublic) + .GetNestedType("NestedType", BindingFlags.NonPublic); + + var mock = Mock.Create(nestedType); + + Mock.NonPublic.Arrange(mock, "Original").CallOriginal(); + Assert.Equal(15, NestingType.TestOriginal(mock)); + } + public class NestingType { protected class NestedWrapperType @@ -2351,22 +2364,42 @@ namespace Telerik.JustMock.Tests { protected abstract int Do(); + protected virtual int Original() + { + return 15; + } + public int CallDo() { return Do(); } + + public int CallOriginal() + { + return Original(); + } } public static int Test(object nestedType) { return ((NestedType)nestedType).CallDo(); } + + public static int TestOriginal(object nestedType) + { + return ((NestedType)nestedType).CallOriginal(); + } } public static int Test(object nestedType) { return NestedWrapperType.Test(nestedType); } + + public static int TestOriginal(object nestedType) + { + return NestedWrapperType.TestOriginal(nestedType); + } } public class OverrideNestingType : NestingType