Hi Eddy
generally what you want to so in this case is to fake the creation of class A, set the expectations on the fake object and than swap it with the real object.
There is a limitation of the Isolator which you may encountered in your tries:
We cannot fake mscorlib types like the Dictionary class.
However we can fake mscorlib interfaces.
So i see two possible workarounds in this case:
1. Change the return type of B.Interfaces and A.Interfaces to IDictionary
2. Create a wrapper around Dictionary class.
In the example bellow I assume that the methods returns IDictionary:
[Test]
public void Test()
{
Dictionary<Type> fakeDictionary = new Dictionary<Type>();
fakeDictionary.Add(typeof(int), "int");
fakeDictionary.Add(typeof(B), "B");
//fake the A class.
A fakeA = Isolate.Fake.Instance<A>();
//create expetation for A.Interfaces property and return fake Dictionary.
Isolate.WhenCalled(()=> fakeA.Interfaces).WillReturnCollectionValuesOf(fakeDictionary);
//Here we swap the next instance of A with our fakeA object.
Isolate.Swap.NextInstance<A>().With(fakeA);
IDictionary<Type> d = B.Interfaces;
Assert.AreEqual(d[typeof(int)], "int");
Assert.AreEqual(d[typeof(B)], "B");
}
Additionally if you don't need the Dictionary that is returned from Interfaces property you can create your fake A with default Members.ReturnRecursiveFakes
That will make all methods and properties return faked objects or default values in cases where the Isolator can not create fakes.
A fakeA = Isolate.Fake.Instance<A>(Members.ReturnRecursiveFakes);
// set expectations on fakeA as needed
Hope it helps.