Ejemplo n.º 1
0
        public void WhenInitializedWithInstance_ThatInstanceIsReturnedFromActivateInstance()
        {
            object instance = new object();

            ProvidedInstanceActivator target = new ProvidedInstanceActivator(instance);

            var container = Factory.CreateEmptyContainer();

            var invoker = target.GetPipelineInvoker(container.ComponentRegistry);

            var actual = invoker(container, Factory.NoParameters);

            Assert.Same(instance, actual);
        }
Ejemplo n.º 2
0
        public void ActivatingAProvidedInstanceTwice_RaisesException()
        {
            object instance = new object();

            ProvidedInstanceActivator target =
                new ProvidedInstanceActivator(instance);

            var container = Factory.CreateEmptyContainer();

            var invoker = target.GetPipelineInvoker(container.ComponentRegistry);

            invoker(container, Factory.NoParameters);

            Assert.Throws <InvalidOperationException>(() =>
                                                      invoker(container, Factory.NoParameters));
        }