public void ClearWithConfigurationSection() { IApplicationContext ctx1 = ContextRegistry.GetContext(); ContextRegistry.Clear(); IApplicationContext ctx2 = ContextRegistry.GetContext(); Assert.AreNotSame(ctx1, ctx2); }
public void Setup() { //ensure prior-registered contexts are removed ContextRegistry.Clear(); _parentContext = new MockApplicationContext(); _parentContext.MockName = "parent"; _childContext = new MockApplicationContext(_parentContext); _childContext.MockName = "child"; _childContext.ParentContext = _parentContext; _grandChildContext = new MockApplicationContext(_childContext); _grandChildContext.MockName = "grandchild"; _grandChildContext.ParentContext = _childContext; _greatGrandChildContext = new MockApplicationContext(_grandChildContext); _greatGrandChildContext.MockName = "greatgrandchild"; _greatGrandChildContext.ParentContext = _grandChildContext; }
public void UsingCustomParsers() { ContextRegistry.Clear(); IApplicationContext ctx = ContextRegistry.GetContext(); Assert.IsNotNull(ctx); IApplicationContext parentCtx = ContextRegistry.GetContext("Parent"); Assert.IsNotNull(parentCtx, "Parent context not registered."); TestObject to = (TestObject)ctx.GetObject("Parent"); Assert.IsNotNull(to); Assert.IsTrue(TestObjectConfigParser.ParseElementCalled); TestObject to2 = (TestObject)ctx.GetObject("testObject"); Assert.AreEqual(12, to2.Age); Assert.AreEqual("John", to2.Name); Assert.AreEqual(2, ctx.ObjectDefinitionCount); }
public void ClearWithDynamicProxies() { CompositionProxyTypeBuilder typeBuilder = new CompositionProxyTypeBuilder(); typeBuilder.TargetType = typeof(TestObject); Type proxyType = typeBuilder.BuildProxyType(); DefaultListableObjectFactory of = new DefaultListableObjectFactory(); RootObjectDefinition od1 = new RootObjectDefinition(proxyType, false); od1.PropertyValues.Add("Name", "Bruno"); of.RegisterObjectDefinition("testObject", od1); GenericApplicationContext ctx1 = new GenericApplicationContext(of); ContextRegistry.RegisterContext(ctx1); ITestObject to1 = ContextRegistry.GetContext().GetObject("testObject") as ITestObject; Assert.IsNotNull(to1); Assert.AreEqual("Bruno", to1.Name); DefaultListableObjectFactory of2 = new DefaultListableObjectFactory(); RootObjectDefinition od2 = new RootObjectDefinition(proxyType, false); od2.PropertyValues.Add("Name", "Baia"); of2.RegisterObjectDefinition("testObject", od2); GenericApplicationContext ctx2 = new GenericApplicationContext(of2); ContextRegistry.Clear(); ITestObject to2 = ctx2.GetObject("testObject") as ITestObject; Assert.IsNotNull(to2); Assert.AreEqual("Baia", to2.Name); }
public void SetUp() { ContextRegistry.Clear(); }
public void TearDown() { ContextRegistry.Clear(); }
public void SetUp() { ContextRegistry.Clear(); ResetConfigurationSystem(); }