public void add_type() { var dependency = new ListDependency(typeof(ISomethingDoer[])); dependency.AddType(typeof (ASomethingDoer)).Type.ShouldEqual(typeof (ASomethingDoer)); dependency.Items.Count.ShouldEqual(1); }
void IDependencyVisitor.List(ListDependency dependency) { var elements = dependency.Items.Select(instanceFor).ToArray(); var instance = new EnumerableInstance(elements); Dependencies.Add(dependency.DependencyType, instance); }
void IDependencyVisitor.List(ListDependency dependency) { var elementType = dependency.ElementType; var elements = dependency.Items.Select(instanceFor).ToArray(); ChildArray(dependency.DependencyType).Contains(elements); }
public void accepting_the_visitor() { var visitor = MockRepository.GenerateMock<IDependencyVisitor>(); var dependency = new ListDependency(typeof (IList<ISomethingDoer>)); dependency.AcceptVisitor(visitor); visitor.AssertWasCalled(x => x.List(dependency)); }
void IDependencyVisitor.List(ListDependency dependency) { _components.AddRange(dependency .Items .Select(def => new WindsorDependencyVisitor(dependency.ElementType, def, true)) .SelectMany(v => v.Registrations())); _registration.DependsOn(Dependency.OnComponentCollection(dependency.DependencyType, dependency.Items.Select(def => def.Name).ToArray())); }
public void add_value() { var doer = new ASomethingDoer(); var dependency = new ListDependency(typeof (ISomethingDoer[])); dependency.AddValue(doer); dependency.Items.Count.ShouldEqual(1); dependency.Items[0].Value.ShouldBeTheSameAs(doer); }
private ListDependency findListDependency <T>(Type openType) { var dependencyType = openType.MakeGenericType(typeof(T)); var dependency = _dependencies.OfType <ListDependency>() .FirstOrDefault(x => x.DependencyType == typeof(IEnumerable <T>)); if (dependency == null) { dependency = new ListDependency(dependencyType); _dependencies.Add(dependency); } return(dependency); }
public void Should_satisfy_dependency() { var def = new ObjectDef(typeof(NeedListOfDoers)); var doer1 = new ASomethingDoer(); var doers = new ListDependency(typeof (IEnumerable<ISomethingDoer>)); doers.AddValue(doer1); doers.AddType(typeof (BSomethingDoer)); def.Dependency(doers); def.Dependencies.ShouldHaveCount(1); }