Exemplo n.º 1
0
        public void Test_FromXml_GoodDivide()
        {
            TestUnitProperty tup = new TestUnitProperty();

            tup.UnitID   = "u6";
            tup.UnitType = UnitTypeCode.Divide;
            tup.NumeratorMeasure.MeasureSchema    = "http://www.xbrl.org/2003/iso4217";
            tup.NumeratorMeasure.MeasureNamespace = "iso4217";
            tup.NumeratorMeasure.MeasureValue     = "EUR";

            tup.DenominatorMeasure.MeasureSchema    = "http://www.xbrl.org/2003/instance";
            tup.DenominatorMeasure.MeasureNamespace = "xbrli";
            tup.DenominatorMeasure.MeasureValue     = "shares";

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("xbrl");

            doc.AppendChild(root);

            ArrayList errors = new ArrayList();

            XmlElement unit = null;

            Assert.IsTrue(tup.CreateElement(doc, root, errors, out unit, true), "element not created");
            Assert.AreEqual(0, errors.Count, "errors returned");
            Assert.IsNotNull(unit, "unit is null");

            root.AppendChild(unit);

            UnitProperty upBack = null;

            Assert.IsTrue(UnitProperty.TryCreateFromXml(unit, null, out upBack, ref errors), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty);

            Assert.IsTrue(tup.ValueEquals(upBack), "objects don't match");
        }
Exemplo n.º 2
0
        public void Test_FromXml_GoodMultiply()
        {
            TestUnitProperty tup = new TestUnitProperty();

            tup.UnitID   = "u3";
            tup.UnitType = UnitTypeCode.Multiply;
            tup.MultiplyMeasures[0].MeasureSchema    = "http://www.aucent.com";
            tup.MultiplyMeasures[0].MeasureNamespace = "myuofm";
            tup.MultiplyMeasures[0].MeasureValue     = "feet";

            tup.MultiplyMeasures[1].MeasureSchema    = "http://www.aucent.com";
            tup.MultiplyMeasures[1].MeasureNamespace = "myuofm";
            tup.MultiplyMeasures[1].MeasureValue     = "feet";

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("xbrl");

            doc.AppendChild(root);

            ArrayList errors = new ArrayList();

            XmlElement unit = null;

            Assert.IsTrue(tup.CreateElement(doc, root, errors, out unit, true));
            Assert.AreEqual(0, errors.Count);
            Assert.IsNotNull(unit);

            root.AppendChild(unit);

            UnitProperty upBack = null;

            Assert.IsTrue(UnitProperty.TryCreateFromXml(unit, null, out upBack, ref errors), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty);

            Assert.IsTrue(tup.ValueEquals(upBack), "objects don't match");
        }
Exemplo n.º 3
0
        public void Test_FromXml()
        {
            TestUnitProperty tup = new TestUnitProperty();

            tup.UnitID   = "US_Dollars";
            tup.UnitType = UnitTypeCode.Standard;
            tup.StandardMeasure.MeasureSchema    = "http://www.xbrl.org/2003/iso4217";
            tup.StandardMeasure.MeasureNamespace = "iso4217";
            tup.StandardMeasure.MeasureValue     = "USD";

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("xbrl");

            doc.AppendChild(root);

            ArrayList errors = new ArrayList();

            XmlElement unit = null;

            Assert.IsTrue(tup.CreateElement(doc, root, errors, out unit, true));

            root.AppendChild(unit);

            UnitProperty upBack = null;

            Assert.IsTrue(UnitProperty.TryCreateFromXml(unit, null, out upBack, ref errors), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty);

            Assert.IsTrue(tup.ValueEquals(upBack), "objects don't match");
        }
Exemplo n.º 4
0
        public void Test_GoodDivide_NO_COMMENT()
        {
            TestUnitProperty tup = new TestUnitProperty();

            tup.UnitID   = "u6";
            tup.UnitType = UnitTypeCode.Divide;
            tup.NumeratorMeasure.MeasureSchema    = "http://www.xbrl.org/2003/iso4217";
            tup.NumeratorMeasure.MeasureNamespace = "iso4217";
            tup.NumeratorMeasure.MeasureValue     = "EUR";

            tup.DenominatorMeasure.MeasureSchema    = "http://www.xbrl.org/2003/instance";
            tup.DenominatorMeasure.MeasureNamespace = "xbrli";
            tup.DenominatorMeasure.MeasureValue     = "shares";

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("xbrl");

            doc.AppendChild(root);

            ArrayList errors = new ArrayList();

            XmlElement unit = null;

            Assert.IsTrue(tup.CreateElement(doc, root, errors, out unit, false), "did not create element");
            Assert.AreEqual(0, errors.Count, "errors returned");
            Assert.IsNotNull(unit, "unit is null");

            root.AppendChild(unit);

            string expectedXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<xbrl xmlns:iso4217=""http://www.xbrl.org/2003/iso4217"" xmlns:xbrli=""http://www.xbrl.org/2003/instance"">
  <unit id=""u6"">
    <divide>
      <unitNumerator>
        <measure>iso4217:EUR</measure>
      </unitNumerator>
      <unitDenominator>
        <measure>xbrli:shares</measure>
      </unitDenominator>
    </divide>
  </unit>
</xbrl>";

            //doc.PreserveWhitespace = false;

            System.IO.StringWriter writer = new System.IO.StringWriter();

            doc.Save(writer);
            Assert.AreEqual(expectedXml, writer.ToString(), "expected xml is wrong");
        }
Exemplo n.º 5
0
        public void Test_GoodMultiply_NO_COMMENT()
        {
            TestUnitProperty tup = new TestUnitProperty();

            tup.UnitID   = "u3";
            tup.UnitType = UnitTypeCode.Multiply;
            tup.MultiplyMeasures[0].MeasureSchema    = "http://www.aucent.com";
            tup.MultiplyMeasures[0].MeasureNamespace = "myuofm";
            tup.MultiplyMeasures[0].MeasureValue     = "feet";

            tup.MultiplyMeasures[1].MeasureSchema    = "http://www.aucent.com";
            tup.MultiplyMeasures[1].MeasureNamespace = "myuofm";
            tup.MultiplyMeasures[1].MeasureValue     = "feet";

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("xbrl");

            doc.AppendChild(root);

            ArrayList errors = new ArrayList();

            XmlElement unit = null;

            Assert.IsTrue(tup.CreateElement(doc, root, errors, out unit, false));
            Assert.AreEqual(0, errors.Count);
            Assert.IsNotNull(unit);

            root.AppendChild(unit);

            string expectedXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<xbrl xmlns:myuofm=""http://www.aucent.com"">
  <unit id=""u3"">
    <measure>myuofm:feet</measure>
    <measure>myuofm:feet</measure>
  </unit>
</xbrl>";

            //doc.PreserveWhitespace = false;

            System.IO.StringWriter writer = new System.IO.StringWriter();

            doc.Save(writer);
            Assert.AreEqual(expectedXml, writer.ToString());
        }
Exemplo n.º 6
0
        public void Test_Append_NO_COMMENT()
        {
            TestUnitProperty tup = new TestUnitProperty();

            tup.UnitID   = "US_Dollars";
            tup.UnitType = UnitTypeCode.Standard;
            tup.StandardMeasure.MeasureSchema    = "http://www.xbrl.org/2003/iso4217";
            tup.StandardMeasure.MeasureNamespace = "iso4217";
            tup.StandardMeasure.MeasureValue     = "USD";

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("xbrl");

            doc.AppendChild(root);

            ArrayList errors = new ArrayList();

            XmlElement unit = null;

            tup.CreateElement(doc, root, errors, out unit, false);

            root.AppendChild(unit);

            string expectedXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<xbrl xmlns:iso4217=""http://www.xbrl.org/2003/iso4217"">
  <unit id=""US_Dollars"">
    <measure>iso4217:USD</measure>
  </unit>
</xbrl>";

            //doc.PreserveWhitespace = false;

            System.IO.StringWriter writer = new System.IO.StringWriter();

            doc.Save(writer);
            Assert.AreEqual(expectedXml, writer.ToString());
        }
Exemplo n.º 7
0
        public void Test_BadDivide()
        {
            TestUnitProperty tup = new TestUnitProperty();

            tup.UnitID   = "u6";
            tup.UnitType = UnitTypeCode.Divide;
            tup.NumeratorMeasure.MeasureSchema    = "http://www.xbrl.org/2003/iso4217";
            tup.NumeratorMeasure.MeasureNamespace = "iso4217";
            tup.NumeratorMeasure.MeasureValue     = "EUR";

            tup.DenominatorMeasure.MeasureSchema    = "http://www.xbrl.org/2003/iso4217";
            tup.DenominatorMeasure.MeasureNamespace = "iso4217";
            tup.DenominatorMeasure.MeasureValue     = "EUR";

            XmlDocument doc = new XmlDocument();

            ArrayList errors = new ArrayList();

            XmlElement unit = null;

            Assert.IsFalse(tup.CreateElement(doc, null, errors, out unit, true));
            Assert.AreEqual(1, errors.Count);
            Assert.IsNull(unit);
        }
Exemplo n.º 8
0
        public void Test_GoodMultiply_NO_COMMENT()
        {
            TestUnitProperty tup = new TestUnitProperty();
            tup.UnitID = "u3";
            tup.UnitType = UnitTypeCode.Multiply;
            tup.MultiplyMeasures[0].MeasureSchema = "http://www.aucent.com";
            tup.MultiplyMeasures[0].MeasureNamespace = "myuofm";
            tup.MultiplyMeasures[0].MeasureValue = "feet";

            tup.MultiplyMeasures[1].MeasureSchema = "http://www.aucent.com";
            tup.MultiplyMeasures[1].MeasureNamespace = "myuofm";
            tup.MultiplyMeasures[1].MeasureValue = "feet";

            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement( "xbrl" );

            doc.AppendChild( root );

            ArrayList errors = new ArrayList();

            XmlElement unit = null;
            Assert.IsTrue( tup.CreateElement( doc, root, errors, out unit, false ) );
            Assert.AreEqual( 0, errors.Count );
            Assert.IsNotNull( unit );

            root.AppendChild( unit );

            string expectedXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
            <xbrl xmlns:myuofm=""http://www.aucent.com"">
              <unit id=""u3"">
            <measure>myuofm:feet</measure>
            <measure>myuofm:feet</measure>
              </unit>
            </xbrl>";

            //doc.PreserveWhitespace = false;

            System.IO.StringWriter writer = new System.IO.StringWriter();

            doc.Save( writer );
            Assert.AreEqual( expectedXml, writer.ToString() );
        }
Exemplo n.º 9
0
        public void Test_GoodDivide_NO_COMMENT()
        {
            TestUnitProperty tup = new TestUnitProperty();
            tup.UnitID = "u6";
            tup.UnitType = UnitTypeCode.Divide;
            tup.NumeratorMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217";
            tup.NumeratorMeasure.MeasureNamespace = "iso4217";
            tup.NumeratorMeasure.MeasureValue = "EUR";

            tup.DenominatorMeasure.MeasureSchema = "http://www.xbrl.org/2003/instance";
            tup.DenominatorMeasure.MeasureNamespace = "xbrli";
            tup.DenominatorMeasure.MeasureValue = "shares";

            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement( "xbrl" );
            doc.AppendChild( root );

            ArrayList errors = new ArrayList();

            XmlElement unit = null;
            Assert.IsTrue( tup.CreateElement( doc, root, errors, out unit, false ), "did not create element" );
            Assert.AreEqual( 0, errors.Count, "errors returned" );
            Assert.IsNotNull( unit, "unit is null" );

            root.AppendChild( unit );

            string expectedXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
            <xbrl xmlns:iso4217=""http://www.xbrl.org/2003/iso4217"" xmlns:xbrli=""http://www.xbrl.org/2003/instance"">
              <unit id=""u6"">
            <divide>
              <unitNumerator>
            <measure>iso4217:EUR</measure>
              </unitNumerator>
              <unitDenominator>
            <measure>xbrli:shares</measure>
              </unitDenominator>
            </divide>
              </unit>
            </xbrl>";

            //doc.PreserveWhitespace = false;

            System.IO.StringWriter writer = new System.IO.StringWriter();

            doc.Save( writer );
            Assert.AreEqual( expectedXml, writer.ToString(), "expected xml is wrong" );
        }
Exemplo n.º 10
0
        public void Test_FromXml_GoodMultiply()
        {
            TestUnitProperty tup = new TestUnitProperty();
            tup.UnitID = "u3";
            tup.UnitType = UnitTypeCode.Multiply;
            tup.MultiplyMeasures[0].MeasureSchema = "http://www.aucent.com";
            tup.MultiplyMeasures[0].MeasureNamespace = "myuofm";
            tup.MultiplyMeasures[0].MeasureValue = "feet";

            tup.MultiplyMeasures[1].MeasureSchema = "http://www.aucent.com";
            tup.MultiplyMeasures[1].MeasureNamespace = "myuofm";
            tup.MultiplyMeasures[1].MeasureValue = "feet";

            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement( "xbrl" );

            doc.AppendChild( root );

            ArrayList errors = new ArrayList();

            XmlElement unit = null;
            Assert.IsTrue( tup.CreateElement( doc, root, errors, out unit, true ) );
            Assert.AreEqual( 0, errors.Count );
            Assert.IsNotNull( unit );

            root.AppendChild( unit );

            UnitProperty upBack = null;

            Assert.IsTrue( UnitProperty.TryCreateFromXml( unit, null, out upBack, ref errors  ), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty );

            Assert.IsTrue( tup.ValueEquals( upBack ), "objects don't match" );
        }
Exemplo n.º 11
0
        public void Test_FromXml_GoodDivide()
        {
            TestUnitProperty tup = new TestUnitProperty();
            tup.UnitID = "u6";
            tup.UnitType = UnitTypeCode.Divide;
            tup.NumeratorMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217";
            tup.NumeratorMeasure.MeasureNamespace = "iso4217";
            tup.NumeratorMeasure.MeasureValue = "EUR";

            tup.DenominatorMeasure.MeasureSchema = "http://www.xbrl.org/2003/instance";
            tup.DenominatorMeasure.MeasureNamespace = "xbrli";
            tup.DenominatorMeasure.MeasureValue = "shares";

            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement( "xbrl" );
            doc.AppendChild( root );

            ArrayList errors = new ArrayList();

            XmlElement unit = null;
            Assert.IsTrue( tup.CreateElement( doc, root, errors, out unit, true ), "element not created" );
            Assert.AreEqual( 0, errors.Count, "errors returned" );
            Assert.IsNotNull( unit, "unit is null" );

            root.AppendChild( unit );

            UnitProperty upBack = null;

            Assert.IsTrue( UnitProperty.TryCreateFromXml( unit, null, out upBack, ref errors  ), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty );

            Assert.IsTrue( tup.ValueEquals( upBack ), "objects don't match" );
        }
Exemplo n.º 12
0
        public void Test_FromXml()
        {
            TestUnitProperty tup = new TestUnitProperty();

            tup.UnitID = "US_Dollars";
            tup.UnitType = UnitTypeCode.Standard;
            tup.StandardMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217";
            tup.StandardMeasure.MeasureNamespace = "iso4217";
            tup.StandardMeasure.MeasureValue="USD";

            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement( "xbrl" );
            doc.AppendChild( root );

            ArrayList errors = new ArrayList();

            XmlElement unit = null;
            Assert.IsTrue( tup.CreateElement( doc, root, errors, out unit, true ) );

            root.AppendChild( unit );

            UnitProperty upBack = null;

            Assert.IsTrue( UnitProperty.TryCreateFromXml( unit, null, out upBack, ref errors  ), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty );

            Assert.IsTrue( tup.ValueEquals( upBack ), "objects don't match" );
        }
Exemplo n.º 13
0
        public void Test_BadDivide()
        {
            TestUnitProperty tup = new TestUnitProperty();
            tup.UnitID = "u6";
            tup.UnitType = UnitTypeCode.Divide;
            tup.NumeratorMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217";
            tup.NumeratorMeasure.MeasureNamespace = "iso4217";
            tup.NumeratorMeasure.MeasureValue = "EUR";

            tup.DenominatorMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217";
            tup.DenominatorMeasure.MeasureNamespace = "iso4217";
            tup.DenominatorMeasure.MeasureValue = "EUR";

            XmlDocument doc = new XmlDocument();

            ArrayList errors = new ArrayList();

            XmlElement unit = null;
            Assert.IsFalse( tup.CreateElement( doc, null, errors, out unit, true ) );
            Assert.AreEqual( 1, errors.Count );
            Assert.IsNull( unit );
        }
Exemplo n.º 14
0
        public void Test_Append_NO_COMMENT()
        {
            TestUnitProperty tup = new TestUnitProperty();

            tup.UnitID = "US_Dollars";
            tup.UnitType = UnitTypeCode.Standard;
            tup.StandardMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217";
            tup.StandardMeasure.MeasureNamespace = "iso4217";
            tup.StandardMeasure.MeasureValue="USD";

            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement( "xbrl" );
            doc.AppendChild( root );

            ArrayList errors = new ArrayList();

            XmlElement unit = null;
            tup.CreateElement( doc, root, errors, out unit, false );

            root.AppendChild( unit );

            string expectedXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
            <xbrl xmlns:iso4217=""http://www.xbrl.org/2003/iso4217"">
              <unit id=""US_Dollars"">
            <measure>iso4217:USD</measure>
              </unit>
            </xbrl>";

            //doc.PreserveWhitespace = false;

            System.IO.StringWriter writer = new System.IO.StringWriter();

            doc.Save( writer );
            Assert.AreEqual( expectedXml, writer.ToString() );
        }