CallOriginal on protected type test fail

This commit is contained in:
Stefan Dragnev 2015-04-16 08:17:52 +03:00
Родитель 215c341eb3
Коммит 01be874237
1 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -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<int>(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