private void UpdateSpyPolicy(IBuilderContext context) { SpyPolicy policy = context.Policies.Get <SpyPolicy>(context.BuildKey); if (policy != null) { policy.WasSpiedOn = true; } }
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); }
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); }