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(); }
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); } }
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); } }
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(); }
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(); }