public void Test_FromXml_CreateCurrentForPeriod() { TestContextProperty tcp = new TestContextProperty(); tcp.ContextID = "current_ForPeriod"; tcp.EntitySchema = "http://www.aucent.com/test"; tcp.EntityValue = "Aucent Corporation"; tcp.PeriodStartDate = new DateTime(2004, 1, 15); tcp.PeriodEndDate = new DateTime(2004, 7, 31); tcp.PeriodType = Element.PeriodType.duration; XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("root"); doc.AppendChild(root); XmlElement elem = tcp.Append(doc, root, null); XmlNamespaceManager theManager = new XmlNamespaceManager(doc.NameTable); theManager.AddNamespace("link2", "http://www.xbrl.org/2003/instance"); ArrayList errors = null; ContextProperty cpBack = null; Assert.IsTrue(ContextProperty.TryCreateFromXml(elem, theManager, out cpBack, ref errors), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty); Assert.IsTrue(tcp.ValueEquals(cpBack), "objects don't match"); }
public void CreateCurrentForPeriod_WithScenario() { TestContextProperty tcp = new TestContextProperty(); tcp.ContextID = "current_ForPeriod"; tcp.EntitySchema = "http://www.aucent.com/test"; tcp.EntityValue = "Aucent Corporation"; tcp.PeriodStartDate = new DateTime(2004, 1, 15); tcp.PeriodEndDate = new DateTime(2004, 7, 31); tcp.PeriodType = Element.PeriodType.duration; tcp.Scenarios.Add(new Scenario("name", "MA", "residence", "fid", "http://www.someInsuranceCo.com/scenarios")); tcp.Scenarios.Add(new Scenario("name2", "true", "nonSmoker", "fid", "http://www.someInsuranceCo.com/scenarios")); tcp.Scenarios.Add(new Scenario("name3", "34", "minAge", "fid", "http://www.someInsuranceCo.com/scenarios")); tcp.Scenarios.Add(new Scenario("name4", "49", "maxAge", "fid", "http://www.someInsuranceCo.com/scenarios")); string expectedXML = @"<?xml version=""1.0"" encoding=""utf-16""?> <root xmlns:fid=""http://www.someInsuranceCo.com/scenarios""> <context id=""current_ForPeriod""> <entity> <identifier scheme=""http://www.aucent.com/test"">Aucent Corporation</identifier> </entity> <period> <startDate>2004-01-15</startDate> <endDate>2004-07-31</endDate> </period> <scenario> <fid:residence>MA</fid:residence> <fid:nonSmoker>true</fid:nonSmoker> <fid:minAge>34</fid:minAge> <fid:maxAge>49</fid:maxAge> </scenario> </context> </root>"; XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("root"); doc.AppendChild(root); root.AppendChild(tcp.Append(doc, root, null)); doc.PreserveWhitespace = false; System.IO.StringWriter writer = new System.IO.StringWriter(); doc.Save(writer); Assert.AreEqual(expectedXML, writer.ToString()); }
public void CreateCurrentForPeriod() { TestContextProperty tcp = new TestContextProperty(); tcp.ContextID = "current_ForPeriod"; tcp.EntitySchema = "http://www.aucent.com/test"; tcp.EntityValue = "Aucent Corporation"; tcp.PeriodStartDate = new DateTime(2004, 1, 15); tcp.PeriodEndDate = new DateTime(2004, 7, 31); tcp.PeriodType = Element.PeriodType.duration; string expectedXML = @"<?xml version=""1.0"" encoding=""utf-16""?> <root> <context id=""current_ForPeriod""> <entity> <identifier scheme=""http://www.aucent.com/test"">Aucent Corporation</identifier> </entity> <period> <startDate>2004-01-15</startDate> <endDate>2004-07-31</endDate> </period> </context> </root>"; XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("root"); doc.AppendChild(root); root.AppendChild(tcp.Append(doc, root, null)); doc.PreserveWhitespace = false; System.IO.StringWriter writer = new System.IO.StringWriter(); doc.Save(writer); Assert.AreEqual(expectedXML, writer.ToString()); }
public void Test_FromXml_WithScenarioAndSegment() { TestContextProperty tcp = new TestContextProperty(); tcp.ContextID = "current_ForPeriod"; tcp.EntitySchema = "http://www.aucent.com/test"; tcp.EntityValue = "Aucent Corporation"; tcp.PeriodStartDate = new DateTime(2004, 1, 15); tcp.PeriodEndDate = new DateTime(2004, 7, 31); tcp.PeriodType = Element.PeriodType.duration; tcp.Scenarios.Add(new Scenario("name", "MA", "residence", "fid", "http://www.someInsuranceCo.com/scenarios")); tcp.Scenarios.Add(new Scenario("name2", "true", "nonSmoker", "fid", "http://www.someInsuranceCo.com/scenarios")); tcp.Scenarios.Add(new Scenario("name3", "34", "minAge", "fid", "http://www.someInsuranceCo.com/scenarios")); tcp.Scenarios.Add(new Scenario("name4", "49", "maxAge", "fid", "http://www.someInsuranceCo.com/scenarios")); tcp.Segments.Add(new Segment("name", "MI", "stateProvince", "my", "http://www.someCompany.com/segment")); tcp.Segments.Add(new Segment("name", "CO", "stateProvince", "my", "http://www.someCompany.com/segment")); tcp.Segments.Add(new Segment("name", "AL", "stateProvince", "my", "http://www.someCompany.com/segment")); tcp.Segments.Add(new Segment("name", "AK", "stateProvince", "my", "http://www.someCompany.com/segment")); XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("root"); doc.AppendChild(root); XmlElement elem = tcp.Append(doc, root, null); XmlNamespaceManager theManager = new XmlNamespaceManager(doc.NameTable); theManager.AddNamespace("link2", "http://www.xbrl.org/2003/instance"); ArrayList errors = null; ContextProperty cpBack = null; Assert.IsTrue(ContextProperty.TryCreateFromXml(elem, theManager, out cpBack, ref errors), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty); Assert.IsTrue(tcp.ValueEquals(cpBack), "objects don't match"); }
public void CreateCurrentForPeriod() { TestContextProperty tcp = new TestContextProperty(); tcp.ContextID = "current_ForPeriod"; tcp.EntitySchema = "http://www.aucent.com/test"; tcp.EntityValue = "Aucent Corporation"; tcp.PeriodStartDate = new DateTime( 2004, 1, 15 ); tcp.PeriodEndDate = new DateTime( 2004, 7, 31 ); tcp.PeriodType = Element.PeriodType.duration; string expectedXML = @"<?xml version=""1.0"" encoding=""utf-16""?> <root> <context id=""current_ForPeriod""> <entity> <identifier scheme=""http://www.aucent.com/test"">Aucent Corporation</identifier> </entity> <period> <startDate>2004-01-15</startDate> <endDate>2004-07-31</endDate> </period> </context> </root>"; XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement( "root" ); doc.AppendChild( root ); root.AppendChild(tcp.Append(doc, root, null)); doc.PreserveWhitespace = false; System.IO.StringWriter writer = new System.IO.StringWriter(); doc.Save( writer ); Assert.AreEqual( expectedXML, writer.ToString() ); }
public void CreateCurrentForPeriod_WithScenario() { TestContextProperty tcp = new TestContextProperty(); tcp.ContextID = "current_ForPeriod"; tcp.EntitySchema = "http://www.aucent.com/test"; tcp.EntityValue = "Aucent Corporation"; tcp.PeriodStartDate = new DateTime( 2004, 1, 15 ); tcp.PeriodEndDate = new DateTime( 2004, 7, 31 ); tcp.PeriodType = Element.PeriodType.duration; tcp.Scenarios.Add( new Scenario( "name", "MA", "residence", "fid", "http://www.someInsuranceCo.com/scenarios" ) ); tcp.Scenarios.Add( new Scenario( "name2", "true", "nonSmoker", "fid", "http://www.someInsuranceCo.com/scenarios" ) ); tcp.Scenarios.Add( new Scenario( "name3", "34", "minAge", "fid", "http://www.someInsuranceCo.com/scenarios" ) ); tcp.Scenarios.Add( new Scenario( "name4", "49", "maxAge", "fid", "http://www.someInsuranceCo.com/scenarios" ) ); string expectedXML = @"<?xml version=""1.0"" encoding=""utf-16""?> <root xmlns:fid=""http://www.someInsuranceCo.com/scenarios""> <context id=""current_ForPeriod""> <entity> <identifier scheme=""http://www.aucent.com/test"">Aucent Corporation</identifier> </entity> <period> <startDate>2004-01-15</startDate> <endDate>2004-07-31</endDate> </period> <scenario> <fid:residence>MA</fid:residence> <fid:nonSmoker>true</fid:nonSmoker> <fid:minAge>34</fid:minAge> <fid:maxAge>49</fid:maxAge> </scenario> </context> </root>"; XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement( "root" ); doc.AppendChild( root ); root.AppendChild(tcp.Append(doc, root, null)); doc.PreserveWhitespace = false; System.IO.StringWriter writer = new System.IO.StringWriter(); doc.Save( writer ); Assert.AreEqual( expectedXML, writer.ToString() ); }
public void Test_FromXml_WithScenarioAndSegment() { TestContextProperty tcp = new TestContextProperty(); tcp.ContextID = "current_ForPeriod"; tcp.EntitySchema = "http://www.aucent.com/test"; tcp.EntityValue = "Aucent Corporation"; tcp.PeriodStartDate = new DateTime( 2004, 1, 15 ); tcp.PeriodEndDate = new DateTime( 2004, 7, 31 ); tcp.PeriodType = Element.PeriodType.duration; tcp.Scenarios.Add( new Scenario( "name", "MA", "residence", "fid", "http://www.someInsuranceCo.com/scenarios" ) ); tcp.Scenarios.Add( new Scenario( "name2", "true", "nonSmoker", "fid", "http://www.someInsuranceCo.com/scenarios" ) ); tcp.Scenarios.Add( new Scenario( "name3", "34", "minAge", "fid", "http://www.someInsuranceCo.com/scenarios" ) ); tcp.Scenarios.Add( new Scenario( "name4", "49", "maxAge", "fid", "http://www.someInsuranceCo.com/scenarios" ) ); tcp.Segments.Add( new Segment( "name", "MI", "stateProvince", "my", "http://www.someCompany.com/segment" ) ); tcp.Segments.Add( new Segment( "name", "CO", "stateProvince", "my", "http://www.someCompany.com/segment" ) ); tcp.Segments.Add( new Segment( "name", "AL", "stateProvince", "my", "http://www.someCompany.com/segment" ) ); tcp.Segments.Add( new Segment( "name", "AK", "stateProvince", "my", "http://www.someCompany.com/segment" ) ); XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement( "root" ); doc.AppendChild( root ); XmlElement elem = tcp.Append(doc, root, null); XmlNamespaceManager theManager = new XmlNamespaceManager( doc.NameTable ); theManager.AddNamespace( "link2", "http://www.xbrl.org/2003/instance" ); ArrayList errors = null; ContextProperty cpBack = null; Assert.IsTrue( ContextProperty.TryCreateFromXml( elem, theManager, out cpBack, ref errors ), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty ); Assert.IsTrue( tcp.ValueEquals( cpBack ), "objects don't match" ); }
public void Test_FromXml_CurrentAsOf() { TestContextProperty tcp = new TestContextProperty(); tcp.ContextID = "current_AsOf"; tcp.EntitySchema = "http://www.aucent.com/test"; tcp.EntityValue = "Aucent Corporation"; tcp.PeriodStartDate = new DateTime( 2004, 7, 9 ); tcp.PeriodType = Element.PeriodType.instant; XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement( "root" ); doc.AppendChild( root ); XmlElement cpXml = tcp.Append(doc, root, null); XmlNamespaceManager theManager = new XmlNamespaceManager( doc.NameTable ); theManager.AddNamespace( "link2", "http://www.xbrl.org/2003/instance" ); ArrayList errors = null; ContextProperty cpBack = null; Assert.IsTrue( ContextProperty.TryCreateFromXml( cpXml, theManager, out cpBack, ref errors ), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty ); Assert.IsTrue( tcp.ValueEquals( cpBack ), "objects don't match" ); }