public object CreateInstance( Type type, TestInstanceStrategy strategy) { if (_typeCache.Contains(type)) { return(_typeCache[type]); } object result; var buildAction = strategy.GetBuildAction(type); if (buildAction == null) { result = _fakeProvider.GetDependency(type); } else { var dependencies = buildAction.GetDependencyTypes(); var parameters = dependencies .Select(x => CreateInstance(x, strategy)) .ToArray(); result = buildAction.Build(parameters); } _typeCache.Add( type, result); return(result); }
public void WithInvalidType_ReturnsFalse() { Assert.IsFalse(TypeCache.Contains <string>()); }
public void WithNullType_ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => TypeCache.Contains(null)); }
public void WithInvalidType_ReturnsFalse() { var contains = TypeCache.Contains <string>(); Assert.IsFalse(contains); }