コード例 #1
0
        public void LoadInAnotherCastleRedirectConfigSection_PocoXMLPresent()
        {
            var    section = new InAnotherCastleConfigSectionRedirect();
            string xml     = @"<InAnotherCastleConfigSectionRedirect Mode=""Poco"" Name=""TestName"" SystemName=""TestSystem"" Type=""TestType"" CacheDurationInMinutes=""23"" >
                          <PocoBody>  <![CDATA[<TestTag></TestTag>]]></PocoBody>
                           </InAnotherCastleConfigSectionRedirect>";

            using (StringReader stringReader = new StringReader(xml))
                using (XmlReader reader = XmlReader.Create(stringReader))
                {
                    section.ExposedDeserializeSection(reader);
                }
            section.WithDeepEqual(new MockRedirectIdentifier()
            {
                CacheDurationInMinutes = 23,
                Name       = "TestName",
                Type       = "TestType",
                SystemName = "TestSystem",
                Mode       = Mode.Poco,
                PocoBody   = new PocoBody()
                {
                    Value = "<TestTag></TestTag>"
                }
            }).IgnoreUnmatchedProperties().Assert();
        }
コード例 #2
0
        public void LoadInAnotherCastleRedirectConfigSection_MissingRequiredFieldsXml_Type_ConfigurationExceptionThrown()
        {
            var section = new InAnotherCastleConfigSectionRedirect();
            //missing Type
            string xml = @"<InAnotherCastleConfigSectionRedirect Mode=""Poco"" Name=""TestName""  SystemName=""SystemNameTest"" CacheDurationInMinutes=""23"" ></InAnotherCastleConfigSectionRedirect>";

            using (StringReader stringReader = new StringReader(xml))
                using (XmlReader reader = XmlReader.Create(stringReader))
                {
                    section.ExposedDeserializeSection(reader);
                }
        }
コード例 #3
0
 public IRedirectIdentifier ParseRedirectDetails(string xml)
 {
     //TODO get exceptions and wrap
     using (StringReader stringReader = new StringReader(xml.Trim()))
         using (XmlReader reader = XmlReader.Create(stringReader, new XmlReaderSettings()
         {
             CloseInput = true
         }))
         {
             var redirectDetails = new InAnotherCastleConfigSectionRedirect();
             redirectDetails.ExposedDeserializeSection(reader);
             return(redirectDetails);
         }
 }
コード例 #4
0
        public void LoadInAnotherCastleRedirectConfigSection_ValidXml_ProperObjectReturned()
        {
            var    section = new InAnotherCastleConfigSectionRedirect();
            string xml     = @"<InAnotherCastleConfigSectionRedirect Mode=""Poco"" Name=""TestName"" SystemName=""TestSystem"" Type=""TestType"" CacheDurationInMinutes=""23"" ></InAnotherCastleConfigSectionRedirect>";

            using (StringReader stringReader = new StringReader(xml))
                using (XmlReader reader = XmlReader.Create(stringReader))
                {
                    section.ExposedDeserializeSection(reader);
                }
            new MockRedirectIdentifier()
            {
                CacheDurationInMinutes = 23,
                Name       = "TestName",
                Type       = "TestType",
                SystemName = "TestSystem",
                Mode       = Mode.Poco,
                PocoBody   = new PocoBody()
            }.WithDeepEqual(section).IgnoreUnmatchedProperties().Assert();
        }
コード例 #5
0
        public void LoadInAnotherCastleRedirectConfigSection_MissingRequiredFieldsXml_CacheDuration_Valid()
        {
            var section = new InAnotherCastleConfigSectionRedirect();
            //missing CacheDurationInMinutes
            string xml = @"<InAnotherCastleConfigSectionRedirect Mode=""Poco"" Name=""TestName"" SystemName=""SystemNameTest"" Type=""TestType"" ></InAnotherCastleConfigSectionRedirect>";

            using (StringReader stringReader = new StringReader(xml))
                using (XmlReader reader = XmlReader.Create(stringReader))
                {
                    section.ExposedDeserializeSection(reader);
                }
            section.WithDeepEqual(new MockRedirectIdentifier()
            {
                //By default will be assigned 1
                CacheDurationInMinutes = 1,
                Name       = "TestName",
                Type       = "TestType",
                SystemName = "SystemNameTest",
                Mode       = Mode.Poco,
                PocoBody   = new PocoBody()
            }).IgnoreUnmatchedProperties().Assert();
        }