public void Subrogation_NoSurrogatesTest() { // Instantiate a dummy object referencing other objects to be potentially // subrogated var dummy = new DummyNoSurrogate(); // Instantiate a new subrogation scope with the previous dummy object as the // scope's initial object var surrogateScope = new TestableDeepSubrogationScope(dummy, GetSurrogateFromType, GetObjectFromType); // Add the original referenced objects by dummy to be restored later _typeToObjectDictionary.Add(typeof(ICalculator), dummy.Calculator); _typeToObjectDictionary.Add(typeof(Vehicle), dummy.Vehicle); // Method under test surrogateScope.Execute(() => { // Verify that neither the Calculator nor the Vehicule object were subrogated // as the fields that reference them do not have the SubrogateAttribute. Assert.AreSame(GetObjectFromType(typeof(ICalculator)), dummy.Calculator); Assert.AreNotSame(GetSurrogateFromType(typeof(ICalculator)), dummy.Calculator); Assert.AreSame(GetObjectFromType(typeof(Vehicle)), dummy.Vehicle); Assert.AreNotSame(GetSurrogateFromType(typeof(Vehicle)), dummy.Vehicle); }); }
public void TypesToSubrogate_NoFieldWithSubrogateAttributeTest() { var dummy = new DummyNoSurrogate(); var surrogateScope = new TestableDeepSubrogationScope(dummy, type => null, type => null); // Since none of the fields have the SubrogateAttribute, then nothing must be subrogated. var expectedSet = new HashSet <Type>(); // Property under test Assert.AreEqual(expectedSet, surrogateScope.TypesToSubrogateSet); }