示例#1
0
        private void UpdateSpyPolicy(IBuilderContext context)
        {
            SpyPolicy policy = context.Policies.Get <SpyPolicy>(context.BuildKey);

            if (policy != null)
            {
                policy.WasSpiedOn = true;
            }
        }
示例#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);
        }
示例#3
0
        public void PipelineCreatedOnlyOnce()
        {
            // Setup
            var          pipeline  = new SpyPipeline();
            SpyPolicy    spy       = new SpyPolicy();
            SpyExtension extension = new SpyExtension(pipeline, Stage.Setup, spy, typeof(SpyPolicy));

            IUnityContainerAsync Container = new UnityContainer()
                                             .AddExtension(extension);

            // Act
            Container.ResolveAsync <object>();
            Container.ResolveAsync <object>();

            // Validate
            Assert.AreEqual(1, pipeline.Count);
            Assert.AreEqual(2, spy.Count);
        }