Hi.
I have the following code snippet:
The error message is:
Test method TestProject1.UnitTest1.TestMethod1 threw exception:
System.TypeAccessException: Attempt by method 'Class1_Interceptor_c1e1c12fbbc845f8a8921237e642d7ff.Intercept(TryJM.Class1, Boolean ByRef)' to access type 'TryJM.VMParameter' failed.
I've followed the instruction at http://www.telerik.com/help/justmock/basic-usage-mock-internal-types-via-proxy.html to add the InternalsVisibleTo to the Telerik.JustMock assembly. My guess is that the interceptor class is generated dynamically and the 'assembly' of that dynamically generated type doesn't have the InternalsVisibleTo attribute applied to it. Any suggestions for a workaround for this?
Ciao.
Muljadi Budiman.
I have the following code snippet:
public class Class1
{
public Class1()
{
Parameter = new VMParameter() { Token = 21 };
}
internal VMParameter Parameter { get; set; }
}
internal class VMParameter
{
public int Token { get; set; }
}
// Unit Test
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var c = Mock.Create<
Class1
>(Behavior.CallOriginal);
var p = Mock.Create<
VMParameter
>();
p.Token = 1;
Mock.Arrange(() => c.Parameter).Returns(p);
Assert.AreEqual(c.Parameter.Token, 1);
}
}
The error message is:
Test method TestProject1.UnitTest1.TestMethod1 threw exception:
System.TypeAccessException: Attempt by method 'Class1_Interceptor_c1e1c12fbbc845f8a8921237e642d7ff.Intercept(TryJM.Class1, Boolean ByRef)' to access type 'TryJM.VMParameter' failed.
I've followed the instruction at http://www.telerik.com/help/justmock/basic-usage-mock-internal-types-via-proxy.html to add the InternalsVisibleTo to the Telerik.JustMock assembly. My guess is that the interceptor class is generated dynamically and the 'assembly' of that dynamically generated type doesn't have the InternalsVisibleTo attribute applied to it. Any suggestions for a workaround for this?
Ciao.
Muljadi Budiman.