public void should_discover_dependencies()
        {
            // setup
            var builder = new ContainerBuilder();
            var context = new InitializationTaskContext(builder);

            // discoverers IMockDependencies
            var convention = Substitute.For<IRegistrationConvention>();
            convention.IsMatch(Arg.Any<Type>()).Returns(true);

            convention.When(
                c =>
                c.Apply(
                    Arg.Any<IRegistrationBuilder<object, ConcreteReflectionActivatorData, SingleRegistrationStyle>>(),
                    Arg.Any<Type>())).Do(
                        ci =>
                            {
                                var dpr =
                                    ci
                                        .Arg
                                        <
                                            IRegistrationBuilder
                                                <object, ConcreteReflectionActivatorData, SingleRegistrationStyle>>();

                                dpr.As<IMockDependency>();
                            });

            // act
            discoveryTask.AddConvention(convention);
            discoveryTask.Execute(context);

            // assert
            var container = builder.Build();
            var registration =
                container.ComponentRegistry.RegistrationsFor(new TypedService(typeof(IMockDependency))).
                          SingleOrDefault();

            registration.Should().NotBeNull();
        }
Example #2
0
 public void Execute(InitializationTaskContext context)
 {
     action(context);
 }