public void GetFragmentTypes_PrioritizesLayers() { var lowerPriorityStub = MockRepository.GenerateStub <IBlacklistManager>(); var lowerPriorityFragmentSignature = new FragmentSignature(new string[0], "ReturnType", false); lowerPriorityStub .Stub(stub => stub.GetFragmentTypes(_assemblyName, _typename, _methodname, _parameters)) .Return(lowerPriorityFragmentSignature); var higherPriorityStub = MockRepository.GenerateStub <IBlacklistManager>(); var higherPriorityFragmentSignature = new FragmentSignature(new string[0], "ReturnType", false); higherPriorityStub .Stub(stub => stub.GetFragmentTypes(_assemblyName, _typename, _methodname, _parameters)) .Return(higherPriorityFragmentSignature); var layers = new Stack <IBlacklistManager>(); layers.Push(lowerPriorityStub); layers.Push(higherPriorityStub); var layeredConfigurationAdapter = new LayeredConfigurationAdapter(layers); Assert.That( layeredConfigurationAdapter.GetFragmentTypes(_assemblyName, _typename, _methodname, _parameters), Is.SameAs(higherPriorityFragmentSignature)); }
public void GetFragmentTypes_ReturnsFragmentType() { var blacklistManagerStub = MockRepository.GenerateStub <IBlacklistManager>(); var expected = new FragmentSignature(new string[0], "ReturnType", false); blacklistManagerStub .Stub(stub => stub.GetFragmentTypes(_assemblyName, _typename, _methodname, _parameters)) .Return(expected); var layers = new Stack <IBlacklistManager>(); layers.Push(blacklistManagerStub); var layeredConfigurationAdapter = new LayeredConfigurationAdapter(layers); Assert.That(layeredConfigurationAdapter.GetFragmentTypes(_assemblyName, _typename, _methodname, _parameters), Is.SameAs(expected)); }
private Fragment[] GetParameterFragmentTypes(Method calleeMethod) { List <string> parameterTypes = IntrospectionUtility.GetParameterTypes(calleeMethod); string assemblyName = calleeMethod.ContainingAssembly().Name; FragmentSignature signature = _blacklistManager.GetFragmentTypes(assemblyName, calleeMethod.DeclaringType.FullName, calleeMethod.Name.Name, parameterTypes); Fragment[] parameterFragmentTypes; if (signature == null) { parameterFragmentTypes = FragmentUtility.GetAnnotatedParameterFragmentTypes(calleeMethod); } else { parameterFragmentTypes = signature.ParameterFragmentTypes.Select(name => name != null ? Fragment.CreateNamed(name) : Fragment.CreateEmpty()).ToArray(); } return(parameterFragmentTypes); }