示例#1
0
 public void Ext_CanAddPolicy()
 {
     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.IsTrue(spyPolicy.WasSpiedOn);
 }
示例#2
0
        public void Ext_CanAddStrategy()
        {
            SpyStrategy spy = new SpyStrategy();
            SpyExtension extension = new SpyExtension(spy, UnityBuildStage.PostInitialization);

            IUnityContainer container = new UnityContainer()
                .AddExtension(extension);
            object result = container.Resolve<object>();
            
            Assert.IsTrue(spy.BuildUpWasCalled);
            Assert.AreSame(result, spy.Existing);
        }