Exemplo n.º 1
0
        public void CanReadSimple()
        {
            createSUT(ExampleData.simpleStepWithCommentString());

            //read Iso declaration
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartSTEP, SUT.TokenType);
            Assert.AreEqual("ISO-10303-21", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            //read header section definition
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartSection, SUT.TokenType);
            Assert.AreEqual("HEADER", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            //read file description name
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EntityName, SUT.TokenType);
            Assert.AreEqual("FILE_DESCRIPTION", SUT.Value);

            //read start of file_description object
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartEntity, SUT.TokenType);
            Assert.IsNull(SUT.Value);

            //read start of array
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartArray, SUT.TokenType);
            Assert.IsNull(SUT.Value);

            //read only value in array
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.String, SUT.TokenType);
            Assert.AreEqual("ViewDefinition [CoordinationView, QuantityTakeOffAddOnView]", SUT.Value);

            //read end of array
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndArray, SUT.TokenType);
            Assert.IsNull(SUT.Value);

            //read implementation level
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.String, SUT.TokenType);
            Assert.AreEqual("2;1", SUT.Value);

            //read close of entity
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndEntity, SUT.TokenType);
            Assert.IsNull(SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            //read file_name function name
            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EntityName, SUT.TokenType);
            Assert.AreEqual("FILE_NAME", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.String, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Date, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartArray, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.String, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndArray, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EntityName, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartArray, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.String, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndArray, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndSection, SUT.TokenType);
            Assert.AreEqual("ENDSEC", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartSection, SUT.TokenType);
            Assert.AreEqual("DATA", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.LineIdentifier, SUT.TokenType);
            Assert.AreEqual("#1", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Operator, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EntityName, SUT.TokenType);
            Assert.AreEqual("IFCPROJECT", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.String, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.LineReference, SUT.TokenType);
            Assert.AreEqual("#2", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.String, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.String, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Null, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Float, SUT.TokenType);
            Assert.AreEqual(-22.4, SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Null, SUT.TokenType);


            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartArray, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.LineReference, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndArray, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.LineReference, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Comment, SUT.TokenType);
            Assert.AreEqual(" a comment ", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.LineIdentifier, SUT.TokenType);
            Assert.AreEqual("#2", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Operator, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EntityName, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.LineReference, SUT.TokenType);
            Assert.AreEqual("#3", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EntityName, SUT.TokenType);
            Assert.AreEqual("IFCTEXT", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.StartEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.String, SUT.TokenType);
            Assert.AreEqual("foobar", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Null, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Enumeration, SUT.TokenType);
            Assert.AreEqual("ADDED", SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Null, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Boolean, SUT.TokenType);
            Assert.AreEqual(false, SUT.Value);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Overridden, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.Integer, SUT.TokenType);
            Assert.AreEqual(1217620436, SUT.Value);
            Assert.AreEqual(typeof(int), SUT.ValueType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndEntity, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndSection, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndLine, SUT.TokenType);

            Assert.IsTrue(SUT.Read());
            Assert.AreEqual(StepToken.EndSTEP, SUT.TokenType);

            Assert.IsFalse(SUT.Read());
        }
Exemplo n.º 2
0
        public void CanDeserializeSimpleStep()
        {
            StepReader sr = createStepReader(ExampleData.simpleStepWithCommentString());

            StepFile result = SUT.Deserialize(sr);

            Assert.IsNotNull(result);

            Assert.IsNotNull(result.Header);
            Assert.AreEqual(3, result.Header.Count);

            StepDataObject header0 = result.Header[0];

            AssertObject("FILE_DESCRIPTION", 2, header0);
            AssertArray(1, header0.Properties[0]);
            AssertString("ViewDefinition [CoordinationView, QuantityTakeOffAddOnView]", getArray(header0.Properties[0])[0]);
            AssertString("2;1", header0.Properties[1]);

            StepDataObject header1 = result.Header[1];

            AssertObject("FILE_NAME", 3, header1);
            AssertString("example.ifc", header1.Properties[0]);
            AssertDate("2008-08-01T21:53:56", header1.Properties[1]);
            AssertArray(1, header1.Properties[2]);
            AssertString("Architect", getArray(header1.Properties[2])[0]);

            StepDataObject header2 = result.Header[2];

            AssertObject("FILE_SCHEMA", 1, header2);
            AssertArray(1, header2.Properties[0]);
            AssertString("IFC2X3", getArray(header2.Properties[0])[0]);

            AssertKeysAreInOrder(2, result.Data);
            ICollection <StepDataObject> valuesCollection = result.Data.Values;
            IList <StepDataObject>       values           = new List <StepDataObject>(valuesCollection);

            StepDataObject entity0 = values[0];

            AssertObject("IFCPROJECT", 9, entity0);
            AssertString("3MD_HkJ6X2EwpfIbCFm0g_", entity0.Properties[0]);
            AssertLineReference(2, entity0.Properties[1]);
            AssertString("Default Project", entity0.Properties[2]);
            AssertString("Description of Default Project", entity0.Properties[3]);
            AssertNull(entity0.Properties[4]);
            AssertFloat(-22.4, entity0.Properties[5]);
            AssertNull(entity0.Properties[6]);
            AssertArray(1, entity0.Properties[7]);
            AssertLineReference(20, getArray(entity0.Properties[7])[0]);
            AssertLineReference(7, entity0.Properties[8]);

            StepDataObject entity1 = values[1];

            AssertObject("IFCOWNERHISTORY", 8, entity1);
            AssertLineReference(3, entity1.Properties[0]);
            AssertNestedObject("IFCTEXT", 1, entity1.Properties[1]);
            //AssertLineReference(6, entity1.Properties[1]);
            AssertNull(entity1.Properties[2]);
            AssertEnum("ADDED", entity1.Properties[3]);
            AssertNull(entity1.Properties[4]);
            AssertBoolean(false, entity1.Properties[5]);
            AssertOverridden(entity1.Properties[6]);
            AssertInteger(1217620436, entity1.Properties[7]);
        }
Exemplo n.º 3
0
        private void createSUT(string sample)
        {
            StringReader reader = new StringReader(ExampleData.simpleStepWithCommentString());

            SUT = new StepReader(reader);
        }