CallOriginal on protected type test fail
This commit is contained in:
Родитель
215c341eb3
Коммит
01be874237
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче