Exemplo n.º 1
0
        public void ExtensionCanAddStrategy()
        {
            SpyStrategy  spy       = new SpyStrategy();
            SpyExtension extension = new SpyExtension(spy, UnityBuildStage.PostInitialization);

            IUnityContainer container = new UnityContainer()
                                        .AddExtension(extension);

            object result = container.Resolve <object>();

            Assert.True(spy.BuildUpWasCalled);
            Assert.Same(result, spy.Existing);
        }
Exemplo n.º 2
0
        public void ExtensionCanAddPolicy()
        {
            SpyStrategy spy       = new SpyStrategy();
            SpyPolicy   spyPolicy = new SpyPolicy();

            SpyExtension extension =
                new SpyExtension(spy, UnityBuildStage.PostInitialization, spyPolicy, typeof(SpyPolicy));

            IUnityContainer container = new UnityContainer()
                                        .AddExtension(extension);

            container.Resolve <object>();

            Assert.True(spyPolicy.WasSpiedOn);
        }