For my ned to end testing it is important that my testassembly does not preload a shadowcopy of a dependent assembly.
Assembly T is the Testframework that loads and tests Assembly A.
Assembly A depends on interfaces defined in B.
For testing purposes i have to replace some static members in A without having them available during buildtime.
Here is some pseudo code that illustrates the dilemma i am in:
A_assembly = Assembly.LoadFrom("A.dll");
A_type = A_assembly.GetType("TheSingleton.Master", true);
MethodInfo Master_Init_Info = type.GetMethod("Init", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
//before init is called some things need to be replaced
FieldInfo semiknown = A_type.GetField("needsmocking", BindingFlags.Public | BindingFlags.Static));
??? mock_semiknown = MockRepository.GenerateMock<???>();
semiknown.SetValue((???)mock_semiknown, mock_semiknown);
//testing makes only sense if that static is replaced.
Master_Init_Info.Invoke(null, null);
- I can access the type via
semiknown.FieldTypebut what good does
that do me? Can i use that information somehow to create the mock
and replace the static member with it? - Suppose i get the type and am able to replace the static member –
how can i build my expectancies in the mock?
You can call it by reflection