I am currently writing a unit test framework, which should run standard unit tests written in Visual Studio at the end. Framework currently does not work with accessories. Consider the following testing method:
[TestMethod()]
public void TestMethod()
{
ExampleMethods_Accessor target = null;
target = new ExampleMethods_Accessor();
target.SomeMethod();
}
In this example, an accessor was generated by Visual Studio. unit test works great on startup using the Visual Studio Unit Testing Environment. However, I would like to call TestMethod () from my Framework. The following exception was thrown in the line "target = new ExampleMethods_Accessor ()":
The type initializer for "Proband.ExampleMethods_Accessor" threw an exception.
Internal exception:
Could not load file or assembly: Proband, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null ...
- , Microsoft Unit Testing Framework ? , - TestContext. "null" . unit test Visual Studio TestContext . , ? ?
,
Christian
EDIT:
, . ILSpy, , Proband_Accessor.dll. , , :
SomeClass_Accessor.m_privateType = new PrivateType("Probant, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Probant.SomeClass");
unit test ( ):
[TestMethod()]
[DeploymentItem("Proband.dll")]
public void SomeMethodTest()
{
ExampleMethods_Accessor target = null;
ExampleMethods c = null;
try
{
Assembly.Load("Proband, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
PrivateType tx = new PrivateType(typeof(ExampleMethods));
PrivateType t = new PrivateType("Proband, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Proband.ExampleMethods");
c = new ExampleMethods();
target = new ExampleMethods_Accessor();
}
catch (Exception ex)
{
Console.WriteLine();
}
int actual;
actual = target.SomeMethod();
}
, " PrivateType (" Proband, Version.... " . - ?