public void ViaXML()
        {
            IResource                  resource = new ReadOnlyXmlTestResource("PropertyResourceConfigurerTests.xml", GetType());
            XmlObjectFactory           xbf      = new XmlObjectFactory(resource);
            PropertyOverrideConfigurer poc      = (PropertyOverrideConfigurer)xbf.GetObject("OverrideConfigurer");

            Assert.IsNotNull(poc);
            poc.PostProcessObjectFactory(xbf);
            TestObject to = (TestObject)xbf.GetObject("Test2");

            Assert.AreEqual("Overriden Name", to.Name);
        }
예제 #2
0
        public void MalformedOverrideKey()
        {
            IConfigurableListableObjectFactory objectFactory = A.Fake <IConfigurableListableObjectFactory>();
            IConfigurableListableObjectFactory fac           = objectFactory;

            PropertyOverrideConfigurer cfg = new PropertyOverrideConfigurer();
            NameValueCollection        defaultProperties = new NameValueCollection();

            defaultProperties.Add("malformedKey", "Rick Evans");
            cfg.Properties = defaultProperties;

            Assert.Throws <FatalObjectException>(() => cfg.PostProcessObjectFactory(fac));
        }
예제 #3
0
        public void MissingObjectDefinitionDoesntRaiseFatalException()
        {
            const string valueTo_NOT_BeOveridden = "Jenny Lewis";
            TestObject   foo = new TestObject(valueTo_NOT_BeOveridden, 30);
            IConfigurableListableObjectFactory objectFactory = A.Fake <IConfigurableListableObjectFactory>();

            A.CallTo(() => objectFactory.GetObjectDefinition("rubbish")).Returns(null);
            IConfigurableListableObjectFactory fac = objectFactory;

            PropertyOverrideConfigurer cfg = new PropertyOverrideConfigurer();
            NameValueCollection        defaultProperties = new NameValueCollection();

            defaultProperties.Add("rubbish.Name", "Rick Evans");
            cfg.Properties = defaultProperties;

            cfg.PostProcessObjectFactory(fac);
            Assert.AreEqual(valueTo_NOT_BeOveridden, foo.Name, "Property value was overridden, but a rubbish objectName root was supplied.");
        }
        public void MalformedOverrideKey()
        {
            IConfigurableListableObjectFactory objectFactory = mocks.StrictMock <IConfigurableListableObjectFactory>();
            IConfigurableListableObjectFactory fac           = objectFactory;

            PropertyOverrideConfigurer cfg = new PropertyOverrideConfigurer();
            NameValueCollection        defaultProperties = new NameValueCollection();

            defaultProperties.Add("malformedKey", "Rick Evans");
            cfg.Properties = defaultProperties;
            mocks.ReplayAll();
            try
            {
                cfg.PostProcessObjectFactory(fac);
                Assert.Fail("Should have had a FatalObjectException at this point because of a malformed key.");
            }
            catch (FatalObjectException)
            {
            }
            mocks.VerifyAll();
        }
        public void MissingObjectDefinitionDoesntRaiseFatalException()
        {
            const string valueTo_NOT_BeOveridden = "Jenny Lewis";
            TestObject   foo = new TestObject(valueTo_NOT_BeOveridden, 30);
            IConfigurableListableObjectFactory objectFactory =
                (IConfigurableListableObjectFactory)mocks.CreateMock(typeof(IConfigurableListableObjectFactory));

            Expect.Call(objectFactory.GetObjectDefinition("rubbish")).Return(null);
            IConfigurableListableObjectFactory fac = (IConfigurableListableObjectFactory)objectFactory;

            PropertyOverrideConfigurer cfg = new PropertyOverrideConfigurer();
            NameValueCollection        defaultProperties = new NameValueCollection();

            defaultProperties.Add("rubbish.Name", "Rick Evans");
            cfg.Properties = defaultProperties;
            mocks.ReplayAll();
            cfg.PostProcessObjectFactory(fac);
            Assert.AreEqual(valueTo_NOT_BeOveridden, foo.Name,
                            "Property value was overridden, but a rubbish objectName root was supplied.");

            mocks.VerifyAll();
        }
        public void MalformedOverrideKey()
        {
            IConfigurableListableObjectFactory objectFactory =
                (IConfigurableListableObjectFactory) mocks.CreateMock(typeof (IConfigurableListableObjectFactory));
            IConfigurableListableObjectFactory fac = (IConfigurableListableObjectFactory) objectFactory;

            PropertyOverrideConfigurer cfg = new PropertyOverrideConfigurer();
            NameValueCollection defaultProperties = new NameValueCollection();
            defaultProperties.Add("malformedKey", "Rick Evans");
            cfg.Properties = defaultProperties;
            mocks.ReplayAll();
            try
            {
                cfg.PostProcessObjectFactory(fac);
                Assert.Fail("Should have had a FatalObjectException at this point because of a malformed key.");
            }
            catch (FatalObjectException)
            {
            }
            mocks.VerifyAll();
        }
        public void MissingObjectDefinitionDoesntRaiseFatalException()
        {
            const string valueTo_NOT_BeOveridden = "Jenny Lewis";
            TestObject foo = new TestObject(valueTo_NOT_BeOveridden, 30);
            IConfigurableListableObjectFactory objectFactory =
                (IConfigurableListableObjectFactory)mocks.CreateMock(typeof(IConfigurableListableObjectFactory));
            Expect.Call(objectFactory.GetObjectDefinition("rubbish")).Return(null);
            IConfigurableListableObjectFactory fac = (IConfigurableListableObjectFactory) objectFactory;

            PropertyOverrideConfigurer cfg = new PropertyOverrideConfigurer();
            NameValueCollection defaultProperties = new NameValueCollection();
            defaultProperties.Add("rubbish.Name", "Rick Evans");
            cfg.Properties = defaultProperties;
            mocks.ReplayAll();
            cfg.PostProcessObjectFactory(fac);
            Assert.AreEqual(valueTo_NOT_BeOveridden, foo.Name,
                            "Property value was overridden, but a rubbish objectName root was supplied.");

            mocks.VerifyAll();
        }