public void CaseInsensitiveContext()
        {
            XmlApplicationContext ctx =
                new XmlApplicationContext(false, "assembly://Oragon.Spring.Core.Tests/Oragon.Spring.Context.Support/objects.xml");

            Assert.IsTrue(ctx.ContainsObject("goran"));
            Assert.IsTrue(ctx.ContainsObject("Goran"));
            Assert.IsTrue(ctx.ContainsObject("GORAN"));
            Assert.AreEqual(ctx.GetObject("goran"), ctx.GetObject("GORAN"));
        }
        public void GetObjectOnUnknownIdThrowsNoSuchObjectDefinition()
        {
            XmlApplicationContext ctx =
                new XmlApplicationContext(false, "assembly://Oragon.Spring.Core.Tests/Oragon.Spring.Context.Support/objects.xml");
            string DOES_NOT_EXIST = "does_not_exist";

            Assert.IsFalse(ctx.ContainsObject(DOES_NOT_EXIST));
            Assert.Throws <NoSuchObjectDefinitionException>(() => ctx.GetObject(DOES_NOT_EXIST));
        }
        public void ContextWithInvalidLazyType()
        {
            XmlApplicationContext ctx =
                new XmlApplicationContext(false,
                                          "assembly://Oragon.Spring.Core.Tests/Oragon.Spring.Context.Support/invalidType.xml");

            Assert.IsTrue(ctx.ContainsObject("someMessageSource"));
            ctx.GetObject("someMessageSource");
        }
        public void MultipleConfigLocations()
        {
            XmlApplicationContext ctx =
                new XmlApplicationContext(false, "assembly://Oragon.Spring.Core.Tests/Oragon.Spring.Context.Support/contextB.xml",
                                          "assembly://Oragon.Spring.Core.Tests/Oragon.Spring.Context.Support/contextC.xml",
                                          "assembly://Oragon.Spring.Core.Tests/Oragon.Spring.Context.Support/contextA.xml");

            Assert.IsTrue(ctx.ContainsObject("service"));
            Assert.IsTrue(ctx.ContainsObject("logicOne"));
            Assert.IsTrue(ctx.ContainsObject("logicTwo"));
            Service service = (Service)ctx.GetObject("service");

            ctx.Refresh();
            Assert.IsTrue(service.ProperlyDestroyed);
            service = (Service)ctx.GetObject("service");
            ctx.Dispose();
            Assert.IsTrue(service.ProperlyDestroyed);
        }
        public void RefreshDisposesExistingObjectFactory_SPRNET479()
        {
            string tmp = typeof(DestroyTester).FullName;

            Console.WriteLine(tmp);

            IApplicationContext ctx =
                new XmlApplicationContext("assembly://Oragon.Spring.Core.Tests/Oragon.Spring.Context.Support/objects.xml");

            DestroyTester destroyTester = (DestroyTester)ctx.GetObject("destroyTester");
            DisposeTester disposeTester = (DisposeTester)ctx.GetObject("disposeTester");

            Assert.IsFalse(destroyTester.IsDestroyed);
            Assert.IsFalse(disposeTester.IsDisposed);

            ((IConfigurableApplicationContext)ctx).Refresh();

            Assert.IsTrue(destroyTester.IsDestroyed);
            Assert.IsTrue(disposeTester.IsDisposed);
        }
 public void InnerObjectWithPostProcessing()
 {
     try
     {
         XmlApplicationContext ctx = new XmlApplicationContext(false, "assembly://Oragon.Spring.Core.Tests/Oragon.Spring.Context.Support/innerObjectsWithPostProcessor.xml");
         ctx.GetObject("hasInnerObjects");
         Assert.Fail("should throw ObjectCreationException");
     }
     catch (ObjectCreationException e)
     {
         NoSuchObjectDefinitionException ex = e.InnerException as NoSuchObjectDefinitionException;
         Assert.IsNotNull(ex);
         //Pass
     }
 }
        public void ConfigureObject()
        {
            const string objDefLocation = "assembly://Oragon.Spring.Core.Tests/Oragon.Spring.Context.Support/objects.xml";

            XmlApplicationContext xmlContext = new XmlApplicationContext(new string[] { objDefLocation });

            object objGoran = xmlContext.GetObject("goran");

            Assert.IsTrue(objGoran is TestObject);
            TestObject fooGet = objGoran as TestObject;

            TestObject fooConfigure = new TestObject();

            xmlContext.ConfigureObject(fooConfigure, "goran");
            Assert.IsNotNull(fooGet);
            Assert.AreEqual(fooGet.Name, fooConfigure.Name);
            Assert.AreEqual(fooGet.Age, fooConfigure.Age);
            Assert.AreEqual(fooGet.ObjectName, fooConfigure.ObjectName);
            Assert.IsNotNull(fooGet.ObjectName);
            Assert.AreEqual(xmlContext, fooGet.ApplicationContext);
            Assert.AreEqual(xmlContext, fooConfigure.ApplicationContext);
        }