public void StrategyProperlyWiresEvents()
        {
            MockBuilderContext context  = CreateContext();
            NamedTypeBuildKey  buildKey = NamedTypeBuildKey.Make <ClipboardManager>();

            EventBroker broker         = new EventBroker();
            var         brokerLifetime = new ExternallyControlledLifetimeManager();

            brokerLifetime.SetValue(broker);
            context.Policies.Set <ILifetimePolicy>(brokerLifetime, NamedTypeBuildKey.Make <EventBroker>());

            EventBrokerInfoPolicy policy = new EventBrokerInfoPolicy();

            policy.AddPublication("cut", "Cut");
            policy.AddPublication("copy", "Copy");
            policy.AddPublication("paste", "Paste");

            policy.AddSubscription("copy", typeof(ClipboardManager).GetMethod("OnCopy"));
            policy.AddSubscription("clipboard data available",
                                   typeof(ClipboardManager).GetMethod("OnClipboardDataAvailable"));

            context.Policies.Set <IEventBrokerInfoPolicy>(policy, buildKey);

            ClipboardManager existing = new ClipboardManager();

            context.ExecuteBuildUp(buildKey, existing);

            List <string> registeredEvents = new List <string>(broker.RegisteredEvents);

            registeredEvents.Sort();

            List <string> expectedEvents = new List <string>(new string[]
            {
                "cut",
                "copy",
                "paste",
                "clipboard data available"
            });

            expectedEvents.Sort();

            CollectionAssert.AreEqual(expectedEvents, registeredEvents);
        }
        public void WhenResolvingThroughTheExtensionWithAName_ThenTransientPoliciesAreUsed()
        {
            var singleton = new object();

            var transientLifetimeManager = new ExternallyControlledLifetimeManager();

            transientLifetimeManager.SetValue(singleton);

            object instance =
                this.container.Configure <TransientPolicyBuildUpExtension>()
                .BuildUp(
                    typeof(object),
                    null,
                    "name",
                    new TestTransientLifetimePolicy {
                LifetimeManager = transientLifetimeManager
            });

            Assert.AreSame(singleton, instance);
        }