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);
        }
Esempio n. 2
0
 public void WithInvalidType_ReturnsFalse()
 {
     Assert.IsFalse(TypeCache.Contains <string>());
 }
Esempio n. 3
0
 public void WithNullType_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           TypeCache.Contains(null));
 }
Esempio n. 4
0
        public void WithInvalidType_ReturnsFalse()
        {
            var contains = TypeCache.Contains <string>();

            Assert.IsFalse(contains);
        }