diff --git a/ReqIFSharp.Extensions.Tests/ReqIFSharp.Extensions.Tests.csproj b/ReqIFSharp.Extensions.Tests/ReqIFSharp.Extensions.Tests.csproj index 9ab3378..2098e6d 100644 --- a/ReqIFSharp.Extensions.Tests/ReqIFSharp.Extensions.Tests.csproj +++ b/ReqIFSharp.Extensions.Tests/ReqIFSharp.Extensions.Tests.csproj @@ -14,16 +14,16 @@ - - - + + + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionBooleanTestFixture.cs b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionBooleanTestFixture.cs index beb2de8..9449e8d 100644 --- a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionBooleanTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionBooleanTestFixture.cs @@ -47,11 +47,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeDefinition = (AttributeDefinition)attributeDefinitionBoolean; - Assert.AreEqual(datatypeDefinitionBoolean, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionBoolean)); attributeDefinition.DatatypeDefinition = datatypeDefinitionBoolean; - Assert.AreEqual(datatypeDefinitionBoolean, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionBoolean)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionDateTestFixture.cs b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionDateTestFixture.cs index d4a15da..e95ee49 100644 --- a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionDateTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionDateTestFixture.cs @@ -47,11 +47,11 @@ public void Verify_That_The_Attribute_Definition_Can_Be_Set_Or_Get() var attributeDefinition = (AttributeDefinition)attributeDefinitionDate; - Assert.AreEqual(datatypeDefinitionDate, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionDate)); attributeDefinition.DatatypeDefinition = datatypeDefinitionDate; - Assert.AreEqual(datatypeDefinitionDate, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionDate)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionEnumerationTestFixture.cs b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionEnumerationTestFixture.cs index 1287db9..8fb39a0 100644 --- a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionEnumerationTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionEnumerationTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeDefinition = (AttributeDefinition)attributeDefinitionEnumeration; - Assert.AreEqual(datatypeDefinitionEnumeration, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionEnumeration)); attributeDefinition.DatatypeDefinition = datatypeDefinitionEnumeration; - Assert.AreEqual(datatypeDefinitionEnumeration, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionEnumeration)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionIntegerTestFixture.cs b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionIntegerTestFixture.cs index a4b71fe..0c6ef1b 100644 --- a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionIntegerTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionIntegerTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeDefinition = (AttributeDefinition)attributeDefinitionInteger; - Assert.AreEqual(datatypeDefinitionInteger, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionInteger)); attributeDefinition.DatatypeDefinition = datatypeDefinitionInteger; - Assert.AreEqual(datatypeDefinitionInteger, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionInteger)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionRealTestFixture.cs b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionRealTestFixture.cs index cfd30b4..bb96c25 100644 --- a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionRealTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionRealTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeDefinition = (AttributeDefinition)attributeDefinitionReal; - Assert.AreEqual(datatypeDefinitionReal, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionReal)); attributeDefinition.DatatypeDefinition = datatypeDefinitionReal; - Assert.AreEqual(datatypeDefinitionReal, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionReal)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionStringTestFixture.cs b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionStringTestFixture.cs index a4d8c6e..c187573 100644 --- a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionStringTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionStringTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeDefinition = (AttributeDefinition)attributeDefinitionString; - Assert.AreEqual(datatypeDefinitionString, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionString)); attributeDefinition.DatatypeDefinition = datatypeDefinitionString; - Assert.AreEqual(datatypeDefinitionString, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionString)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionXHTMLTestFixture.cs b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionXHTMLTestFixture.cs index dfa36c4..033abbd 100644 --- a/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionXHTMLTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeDefinitionTests/AttributeDefinitionXHTMLTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeDefinition = (AttributeDefinition)attributeDefinitionXhtml; - Assert.AreEqual(datatypeDefinitionXhtml, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionXhtml)); attributeDefinition.DatatypeDefinition = datatypeDefinitionXhtml; - Assert.AreEqual(datatypeDefinitionXhtml, attributeDefinition.DatatypeDefinition); + Assert.That(attributeDefinition.DatatypeDefinition, Is.EqualTo(datatypeDefinitionXhtml)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueBooleanTestFixture.cs b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueBooleanTestFixture.cs index bb12b3c..6a41e17 100644 --- a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueBooleanTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueBooleanTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeValue = (AttributeValue)attributeValueBoolean; - Assert.AreEqual(atrAttributeDefinitionBoolean, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(atrAttributeDefinitionBoolean)); attributeValue.AttributeDefinition = atrAttributeDefinitionBoolean; - Assert.AreEqual(atrAttributeDefinitionBoolean, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(atrAttributeDefinitionBoolean)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueDateTestFixture.cs b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueDateTestFixture.cs index d34aa48..31f7e41 100644 --- a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueDateTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueDateTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeValue = (AttributeValue)attributeValueDate; - Assert.AreEqual(attributeDefinitionDate, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionDate)); attributeValue.AttributeDefinition = attributeDefinitionDate; - Assert.AreEqual(attributeDefinitionDate, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionDate)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueIntegerTestFixture.cs b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueIntegerTestFixture.cs index 2029c23..8762d01 100644 --- a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueIntegerTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueIntegerTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeValue = (AttributeValue)attributeValueInteger; - Assert.AreEqual(attributeDefinitionInteger, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionInteger)); attributeValue.AttributeDefinition = attributeDefinitionInteger; - Assert.AreEqual(attributeDefinitionInteger, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionInteger)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueRealTestFixture.cs b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueRealTestFixture.cs index 4dedb9a..7a49191 100644 --- a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueRealTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueRealTestFixture.cs @@ -56,11 +56,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeValue = (AttributeValue)attributeValueReal; - Assert.AreEqual(attributeDefinitionReal, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionReal)); attributeValue.AttributeDefinition = attributeDefinitionReal; - Assert.AreEqual(attributeDefinitionReal, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionReal)); } [Test] @@ -138,8 +138,8 @@ public void Verify_Convenience_Value_Property() var val = 3.66; attributeValue.ObjectValue = val; - Assert.AreEqual(attributeValue.TheValue, val); - Assert.AreEqual(attributeValue.ObjectValue, val); + Assert.That(val, Is.EqualTo(attributeValue.TheValue)); + Assert.That(val, Is.EqualTo(attributeValue.ObjectValue)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueStringTestFixture.cs b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueStringTestFixture.cs index d1fae2b..3a63272 100644 --- a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueStringTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueStringTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeValue = (AttributeValue)attributeValueString; - Assert.AreEqual(attributeDefinitionString, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionString)); attributeValue.AttributeDefinition = attributeDefinitionString; - Assert.AreEqual(attributeDefinitionString, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionString)); } [Test] @@ -114,8 +114,8 @@ public void Verify_Convenience_Value_Property() var val = "test"; attributeValue.ObjectValue = val; - Assert.AreEqual(attributeValue.TheValue, val); - Assert.AreEqual(attributeValue.ObjectValue, val); + Assert.That(val, Is.EqualTo(attributeValue.TheValue)); + Assert.That(val, Is.EqualTo(attributeValue.ObjectValue)); } [Test] diff --git a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueXHTMLTestFixture.cs b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueXHTMLTestFixture.cs index 46cd218..66d11c8 100644 --- a/ReqIFSharp.Tests/AttributeValueTests/AttributeValueXHTMLTestFixture.cs +++ b/ReqIFSharp.Tests/AttributeValueTests/AttributeValueXHTMLTestFixture.cs @@ -46,11 +46,11 @@ public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() var attributeValue = (AttributeValue)attributeValueXhtml; - Assert.AreEqual(attributeDefinitionXhtml, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionXhtml)); attributeValue.AttributeDefinition = attributeDefinitionXhtml; - Assert.AreEqual(attributeDefinitionXhtml, attributeValue.AttributeDefinition); + Assert.That(attributeValue.AttributeDefinition, Is.EqualTo(attributeDefinitionXhtml)); } [Test] @@ -116,8 +116,8 @@ public void Verify_Convenience_Value_Property() var val = "testetestes"; attributeValue.ObjectValue = val; - Assert.AreEqual(attributeValue.TheValue, val); - Assert.AreEqual(attributeValue.ObjectValue, val); + Assert.That(val, Is.EqualTo(attributeValue.TheValue)); + Assert.That(val, Is.EqualTo(attributeValue.ObjectValue)); } [Test] diff --git a/ReqIFSharp.Tests/ReqIFDeSerializerTestFixture.cs b/ReqIFSharp.Tests/ReqIFDeSerializerTestFixture.cs index 81a55fa..a6b7164 100644 --- a/ReqIFSharp.Tests/ReqIFDeSerializerTestFixture.cs +++ b/ReqIFSharp.Tests/ReqIFDeSerializerTestFixture.cs @@ -130,31 +130,31 @@ public void Verify_That_A_ReqIF_Document_Can_Be_Deserialized_Without_Validation( var deserializer = new ReqIFDeserializer(this.loggerFactory); var reqIf = deserializer.Deserialize(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "output.reqif")).First(); - Assert.AreEqual("en", reqIf.Lang); + Assert.That(reqIf.Lang, Is.EqualTo("en")); var firstobject = reqIf.CoreContent.SpecObjects.First(); var xhtmlAttribute = firstobject.Values.OfType().SingleOrDefault(); - Assert.IsNotNull(xhtmlAttribute); - Assert.IsNotEmpty(xhtmlAttribute.TheValue); - Assert.IsNotNull(xhtmlAttribute.AttributeDefinition); - - Assert.AreEqual(7, reqIf.CoreContent.DataTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecObjects.Count); - Assert.AreEqual(2, reqIf.CoreContent.SpecRelations.Count); - Assert.AreEqual(3, reqIf.CoreContent.Specifications.Count); - Assert.AreEqual(1, reqIf.CoreContent.Specifications[0].Children.Count); - Assert.AreEqual(2, reqIf.CoreContent.Specifications[0].Children[0].Children.Count); - Assert.AreEqual(2, reqIf.CoreContent.SpecRelationGroups.Count); + Assert.That(xhtmlAttribute, Is.Not.Null); + Assert.That(xhtmlAttribute.TheValue, Is.Not.Empty); + Assert.That(xhtmlAttribute.AttributeDefinition, Is.Not.Null); + + Assert.That(reqIf.CoreContent.DataTypes.Count, Is.EqualTo(7)); + Assert.That(reqIf.CoreContent.SpecTypes.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecObjects.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecRelations.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.Specifications.Count, Is.EqualTo(3)); + Assert.That(reqIf.CoreContent.Specifications[0].Children.Count, Is.EqualTo(1)); + Assert.That(reqIf.CoreContent.Specifications[0].Children[0].Children.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.SpecRelationGroups.Count, Is.EqualTo(2)); Assert.That(reqIf.TheHeader.DocumentRoot, Is.EqualTo(reqIf)); var unknownSpecRel = reqIf.CoreContent.SpecRelations.First(x => x.Identifier == "specobject_1-unknown"); - Assert.IsNotNull(unknownSpecRel.Target); - Assert.AreEqual("unknown-specobject", unknownSpecRel.Target.Identifier); + Assert.That(unknownSpecRel.Target, Is.Not.Null); + Assert.That(unknownSpecRel.Target.Identifier, Is.EqualTo("unknown-specobject")); var unknownrelGroup = reqIf.CoreContent.SpecRelationGroups.First(x => x.Identifier == "relationgroup-no-target"); - Assert.AreEqual("unknown", unknownrelGroup.TargetSpecification.Identifier); + Assert.That(unknownrelGroup.TargetSpecification.Identifier, Is.EqualTo("unknown")); } [Test] @@ -165,29 +165,29 @@ public async Task Verify_That_A_ReqIF_Document_Can_Be_DeserializedAsync_Without_ var deserializer = new ReqIFDeserializer(); var reqIf = (await deserializer.DeserializeAsync(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "output.reqif"), cancellationTokenSource.Token)).First(); - Assert.AreEqual("en", reqIf.Lang); + Assert.That(reqIf.Lang, Is.EqualTo("en")); var firstobject = reqIf.CoreContent.SpecObjects.First(); var xhtmlAttribute = firstobject.Values.OfType().SingleOrDefault(); - Assert.IsNotNull(xhtmlAttribute); - Assert.IsNotEmpty(xhtmlAttribute.TheValue); - Assert.IsNotNull(xhtmlAttribute.AttributeDefinition); - - Assert.AreEqual(7, reqIf.CoreContent.DataTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecObjects.Count); - Assert.AreEqual(2, reqIf.CoreContent.SpecRelations.Count); - Assert.AreEqual(3, reqIf.CoreContent.Specifications.Count); - Assert.AreEqual(1, reqIf.CoreContent.Specifications[0].Children.Count); - Assert.AreEqual(2, reqIf.CoreContent.Specifications[0].Children[0].Children.Count); - Assert.AreEqual(2, reqIf.CoreContent.SpecRelationGroups.Count); + Assert.That(xhtmlAttribute, Is.Not.Null); + Assert.That(xhtmlAttribute.TheValue, Is.Not.Empty); + Assert.That(xhtmlAttribute.AttributeDefinition, Is.Not.Null); + + Assert.That(reqIf.CoreContent.DataTypes.Count, Is.EqualTo(7)); + Assert.That(reqIf.CoreContent.SpecTypes.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecObjects.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecRelations.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.Specifications.Count, Is.EqualTo(3)); + Assert.That(reqIf.CoreContent.Specifications[0].Children.Count, Is.EqualTo(1)); + Assert.That(reqIf.CoreContent.Specifications[0].Children[0].Children.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.SpecRelationGroups.Count, Is.EqualTo(2)); var unknownSpecRel = reqIf.CoreContent.SpecRelations.First(x => x.Identifier == "specobject_1-unknown"); - Assert.IsNotNull(unknownSpecRel.Target); - Assert.AreEqual("unknown-specobject", unknownSpecRel.Target.Identifier); + Assert.That(unknownSpecRel.Target, Is.Not.Null); + Assert.That(unknownSpecRel.Target.Identifier, Is.EqualTo("unknown-specobject")); var unknownrelGroup = reqIf.CoreContent.SpecRelationGroups.First(x => x.Identifier == "relationgroup-no-target"); - Assert.AreEqual("unknown", unknownrelGroup.TargetSpecification.Identifier); + Assert.That(unknownrelGroup.TargetSpecification.Identifier, Is.EqualTo("unknown")); } [Test] @@ -334,14 +334,14 @@ public void Verify_That_A_ReqIF_XML_Document_Can_Be_Deserialized_With_Validation var deserializer = new ReqIFDeserializer(); var reqIf = deserializer.Deserialize(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "output.reqif"), true, this.ValidationEventHandler).First(); - Assert.AreEqual("en", reqIf.Lang); + Assert.That(reqIf.Lang, Is.EqualTo("en")); - Assert.AreEqual(7, reqIf.CoreContent.DataTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecObjects.Count); - Assert.AreEqual(2, reqIf.CoreContent.SpecRelations.Count); - Assert.AreEqual(3, reqIf.CoreContent.Specifications.Count); - Assert.AreEqual(2, reqIf.CoreContent.SpecRelationGroups.Count); + Assert.That(reqIf.CoreContent.DataTypes.Count, Is.EqualTo(7)); + Assert.That(reqIf.CoreContent.SpecTypes.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecObjects.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecRelations.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.Specifications.Count, Is.EqualTo(3)); + Assert.That(reqIf.CoreContent.SpecRelationGroups.Count, Is.EqualTo(2)); } [Test] @@ -352,14 +352,14 @@ public async Task Verify_That_A_ReqIF_Document_Can_Be_DeserializedAsync_With_Val var deserializer = new ReqIFDeserializer(); var reqIf = (await deserializer.DeserializeAsync(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "output.reqif"), cancellationTokenSource.Token,true, this.ValidationEventHandler)).First(); - Assert.AreEqual("en", reqIf.Lang); + Assert.That(reqIf.Lang, Is.EqualTo("en")); - Assert.AreEqual(7, reqIf.CoreContent.DataTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecObjects.Count); - Assert.AreEqual(2, reqIf.CoreContent.SpecRelations.Count); - Assert.AreEqual(3, reqIf.CoreContent.Specifications.Count); - Assert.AreEqual(2, reqIf.CoreContent.SpecRelationGroups.Count); + Assert.That(reqIf.CoreContent.DataTypes.Count, Is.EqualTo(7)); + Assert.That(reqIf.CoreContent.SpecTypes.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecObjects.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecRelations.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.Specifications.Count, Is.EqualTo(3)); + Assert.That(reqIf.CoreContent.SpecRelationGroups.Count, Is.EqualTo(2)); } [Test] @@ -390,7 +390,7 @@ public void Verify_that_XHTML_attributes_can_de_Deserialized() var deserializer = new ReqIFDeserializer(); var reqIf = deserializer.Deserialize(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "testreqif.reqif")).First(); - Assert.AreEqual("en", reqIf.Lang); + Assert.That(reqIf.Lang, Is.EqualTo("en")); var specObject = reqIf.CoreContent.SpecObjects.Single(r => r.Identifier == "R001"); @@ -407,7 +407,7 @@ public async Task Verify_that_XHTML_attributes_can_de_DeserializedAsync() var deserializer = new ReqIFDeserializer(); var reqIf = (await deserializer.DeserializeAsync(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "testreqif.reqif"), cancellationTokenSource.Token)).First(); - Assert.AreEqual("en", reqIf.Lang); + Assert.That(reqIf.Lang, Is.EqualTo("en")); var specObject = reqIf.CoreContent.SpecObjects.Single(r => r.Identifier == "R001"); @@ -422,22 +422,22 @@ public void Verify_That_A_ReqIF_Archive_Can_Be_Deserialized_Without_Validation() var deserializer = new ReqIFDeserializer(); var reqIf = deserializer.Deserialize(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "test-multiple-reqif.reqifz")).First(); - Assert.AreEqual("en", reqIf.Lang); + Assert.That(reqIf.Lang, Is.EqualTo("en")); var firstobject = reqIf.CoreContent.SpecObjects.First(); var xhtmlAttribute = firstobject.Values.OfType().SingleOrDefault(); - Assert.IsNotNull(xhtmlAttribute); - Assert.IsNotEmpty(xhtmlAttribute.TheValue); - Assert.IsNotNull(xhtmlAttribute.AttributeDefinition); - - Assert.AreEqual(7, reqIf.CoreContent.DataTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecTypes.Count); - Assert.AreEqual(3, reqIf.CoreContent.SpecObjects.Count); - Assert.AreEqual(1, reqIf.CoreContent.SpecRelations.Count); - Assert.AreEqual(2, reqIf.CoreContent.Specifications.Count); - Assert.AreEqual(1, reqIf.CoreContent.Specifications[0].Children.Count); - Assert.AreEqual(2, reqIf.CoreContent.Specifications[0].Children[0].Children.Count); - Assert.AreEqual(1, reqIf.CoreContent.SpecRelationGroups.Count); + Assert.That(xhtmlAttribute, Is.Not.Null); + Assert.That(xhtmlAttribute.TheValue, Is.Not.Empty); + Assert.That(xhtmlAttribute.AttributeDefinition, Is.Not.Null); + + Assert.That(reqIf.CoreContent.DataTypes.Count, Is.EqualTo(7)); + Assert.That(reqIf.CoreContent.SpecTypes.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecObjects.Count, Is.EqualTo(3)); + Assert.That(reqIf.CoreContent.SpecRelations.Count, Is.EqualTo(1)); + Assert.That(reqIf.CoreContent.Specifications.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.Specifications[0].Children.Count, Is.EqualTo(1)); + Assert.That(reqIf.CoreContent.Specifications[0].Children[0].Children.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.SpecRelationGroups.Count, Is.EqualTo(1)); } [Test] @@ -448,22 +448,22 @@ public async Task Verify_That_A_ReqIF_Archive_Can_Be_DeserializedAsync_Without_V var deserializer = new ReqIFDeserializer(); var reqIf = (await deserializer.DeserializeAsync(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "test-multiple-reqif.reqifz"), cancellationTokenSource.Token)).First(); - Assert.AreEqual("en", reqIf.Lang); + Assert.That(reqIf.Lang, Is.EqualTo("en")); var firstobject = reqIf.CoreContent.SpecObjects.First(); var xhtmlAttribute = firstobject.Values.OfType().SingleOrDefault(); - Assert.IsNotNull(xhtmlAttribute); - Assert.IsNotEmpty(xhtmlAttribute.TheValue); - Assert.IsNotNull(xhtmlAttribute.AttributeDefinition); - - Assert.AreEqual(7, reqIf.CoreContent.DataTypes.Count); - Assert.AreEqual(4, reqIf.CoreContent.SpecTypes.Count); - Assert.AreEqual(3, reqIf.CoreContent.SpecObjects.Count); - Assert.AreEqual(1, reqIf.CoreContent.SpecRelations.Count); - Assert.AreEqual(2, reqIf.CoreContent.Specifications.Count); - Assert.AreEqual(1, reqIf.CoreContent.Specifications[0].Children.Count); - Assert.AreEqual(2, reqIf.CoreContent.Specifications[0].Children[0].Children.Count); - Assert.AreEqual(1, reqIf.CoreContent.SpecRelationGroups.Count); + Assert.That(xhtmlAttribute, Is.Not.Null); + Assert.That(xhtmlAttribute.TheValue, Is.Not.Empty); + Assert.That(xhtmlAttribute.AttributeDefinition, Is.Not.Null); + + Assert.That(reqIf.CoreContent.DataTypes.Count, Is.EqualTo(7)); + Assert.That(reqIf.CoreContent.SpecTypes.Count, Is.EqualTo(4)); + Assert.That(reqIf.CoreContent.SpecObjects.Count, Is.EqualTo(3)); + Assert.That(reqIf.CoreContent.SpecRelations.Count, Is.EqualTo(1)); + Assert.That(reqIf.CoreContent.Specifications.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.Specifications[0].Children.Count, Is.EqualTo(1)); + Assert.That(reqIf.CoreContent.Specifications[0].Children[0].Children.Count, Is.EqualTo(2)); + Assert.That(reqIf.CoreContent.SpecRelationGroups.Count, Is.EqualTo(1)); } [Test] diff --git a/ReqIFSharp.Tests/ReqIFSerializerTestFixture.cs b/ReqIFSharp.Tests/ReqIFSerializerTestFixture.cs index f554878..faef221 100644 --- a/ReqIFSharp.Tests/ReqIFSerializerTestFixture.cs +++ b/ReqIFSharp.Tests/ReqIFSerializerTestFixture.cs @@ -1,953 +1,953 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2017-2022 RHEA System S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace ReqIFSharp.Tests -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - - using NUnit.Framework; - - using ReqIFSharp; - - [TestFixture] - internal class ReqIFSerializerTestFixture - { - private ReqIF reqIF; - - private string resultFileUri; - private string resultFileUriArchive; - private string asyncResultFileUri; - private string asyncResultFileUriArchive; - - private const string ReqIFNamespace = @"http://www.omg.org/spec/ReqIF/20110401/reqif.xsd"; - - private string specobject_1_id; - - private string specobject_2_id; - - private string specobject_3_id; - - private string enumdatatype_id; - - private string enum_value_low_id; - - private string enum_value_medium_id; - - private string xhtmlcontent; - - [SetUp] - public void SetUp() - { - this.resultFileUri = Path.Combine(TestContext.CurrentContext.TestDirectory, "result.reqif"); - this.resultFileUriArchive = Path.Combine(TestContext.CurrentContext.TestDirectory, "result.reqifz"); - this.asyncResultFileUri = Path.Combine(TestContext.CurrentContext.TestDirectory, "async-result.reqif"); - this.asyncResultFileUriArchive = Path.Combine(TestContext.CurrentContext.TestDirectory, "async-result.reqifz"); - - this.CleanUpFiles(); - - this.enumdatatype_id = "enumeration"; - this.enum_value_low_id = "enumlow"; - this.enum_value_medium_id = "enummedium"; - - this.specobject_1_id = "specobject_1"; - this.specobject_2_id = "specobject_2"; - this.specobject_3_id = "specobject_3"; - - this.xhtmlcontent = "XhtmlPType text before brtext after br text before spanXhtmlSpanTypetext after span text before emXhtmlEmTypetext after em text before strongXhtmlStrongTypetext after strong text before dfnXhtmlDfnTypetext after dfn text before codeXhtmlCodeTypetext after code text before sampXhtmlSampTypetext after samp text before kbdXhtmlKbdTypetext after kbd text before varXhtmlVarTypetext after var text before citeXhtmlCiteTypetext after cite text before abbrXhtmlAbbrTypetext after abbr text before acronymXhtmlAcronymTypetext after acronym text before qXhtmlQTypetext after q text before ttXhtmlInlPresTypetext after tt text before iXhtmlInlPresTypetext after i text before bXhtmlInlPresTypetext after b text before bigXhtmlInlPresTypetext after big text before smallXhtmlInlPresTypetext after small text before subXhtmlInlPresTypetext after sub text before supXhtmlInlPresTypetext after sup text before insXhtmlEditTypetext after ins text before delXhtmlEditTypetext after del"; - - this.reqIF = new ReqIF(); - this.reqIF.Lang = "en"; - - var header = new ReqIFHeader(); - header.Comment = "this is a comment"; - header.CreationTime = DateTime.Parse("2015-12-01"); - header.Identifier = "reqifheader"; - header.RepositoryId = "a repos id"; - header.ReqIFToolId = "tool - CDP4"; - header.ReqIFVersion = "1.0"; - header.SourceToolId = "source tool - CDP4"; - header.Title = "this is a title"; - - this.reqIF.TheHeader = header; - - var reqIfContent = new ReqIFContent(); - this.reqIF.CoreContent = reqIfContent; - - this.CreateDataTypes(); - this.CreateSpecObjectType(); - this.CreateSpecificationType(); - this.CreateSpecRelationType(); - this.CreateRelationGroupType(); - - this.CreateSpecObjects(); - this.CreateSpecRelations(); - this.CreateSpecifications(); - this.CreateRelationGroup(); - } - - [TearDown] - public void TearDown() - { - this.CleanUpFiles(); - } - - /// - /// Clean up generated reqif and reqifz files - /// - private void CleanUpFiles() - { - File.Delete(this.resultFileUri); - File.Delete(this.resultFileUriArchive); - File.Delete(this.asyncResultFileUri); - File.Delete(this.asyncResultFileUriArchive); - } - - /// - /// create all the different s - /// - private void CreateDataTypes() - { - var datatypeDefinitionBoolean = new DatatypeDefinitionBoolean(); - datatypeDefinitionBoolean.Description = "boolean data type definition"; - datatypeDefinitionBoolean.Identifier = "boolean"; - datatypeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); - datatypeDefinitionBoolean.LongName = "a boolean"; - CreateAlternativeId(datatypeDefinitionBoolean); - this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionBoolean); - - var datatypeDefinitionDate = new DatatypeDefinitionDate(); - datatypeDefinitionDate.Description = "date data type definition"; - datatypeDefinitionDate.Identifier = "DateTime"; - datatypeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); - datatypeDefinitionDate.LongName = "a date"; - CreateAlternativeId(datatypeDefinitionDate); - this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionDate); - - var datatypeDefinitionEnumeration = new DatatypeDefinitionEnumeration(); - datatypeDefinitionEnumeration.Description = "enum value type definition"; - datatypeDefinitionEnumeration.Identifier = this.enumdatatype_id; - datatypeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); - datatypeDefinitionEnumeration.LongName = "an enumeration"; - CreateAlternativeId(datatypeDefinitionEnumeration); - - var enumValuelow = new EnumValue(); - enumValuelow.Identifier = this.enum_value_low_id; - enumValuelow.LastChange = DateTime.Parse("2015-12-01"); - enumValuelow.LongName = "low"; - CreateAlternativeId(enumValuelow); - - var embeddedValueLow = new EmbeddedValue(); - embeddedValueLow.Key = 1; - embeddedValueLow.OtherContent = "foo"; - enumValuelow.Properties = embeddedValueLow; - - var enumValuemedium = new EnumValue(); - enumValuemedium.Identifier = this.enum_value_medium_id; - enumValuemedium.LastChange = DateTime.Parse("2015-12-01"); - enumValuemedium.LongName = "medium"; - CreateAlternativeId(enumValuemedium); - - var embeddedValueMedium = new EmbeddedValue(); - embeddedValueMedium.Key = 2; - embeddedValueMedium.OtherContent = "bar"; - enumValuemedium.Properties = embeddedValueMedium; - - datatypeDefinitionEnumeration.SpecifiedValues.Add(enumValuelow); - datatypeDefinitionEnumeration.SpecifiedValues.Add(enumValuemedium); - - this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionEnumeration); - - var datatypeDefinitionInteger = new DatatypeDefinitionInteger(); - datatypeDefinitionInteger.Description = "integer data type definition"; - datatypeDefinitionInteger.Identifier = "integer"; - datatypeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); - datatypeDefinitionInteger.LongName = "an integer"; - datatypeDefinitionInteger.Min = 2; - datatypeDefinitionInteger.Max = 6; - CreateAlternativeId(datatypeDefinitionInteger); - this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionInteger); - - var datatypeDefinitionReal = new DatatypeDefinitionReal(); - datatypeDefinitionReal.Description = "real data type definition"; - datatypeDefinitionReal.Identifier = "real"; - datatypeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); - datatypeDefinitionReal.LongName = "a real"; - datatypeDefinitionReal.Accuracy = 5; - datatypeDefinitionReal.Min = 1; - datatypeDefinitionReal.Max = 5; - CreateAlternativeId(datatypeDefinitionReal); - this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionReal); - - var datatypeDefinitionString = new DatatypeDefinitionString(); - datatypeDefinitionString.Description = "string data type definition"; - datatypeDefinitionString.Identifier = "string"; - datatypeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); - datatypeDefinitionString.MaxLength = 32000; - datatypeDefinitionString.LongName = "a string"; - CreateAlternativeId(datatypeDefinitionString); - this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionString); - - var datatypeDefinitionXhtml = new DatatypeDefinitionXHTML(); - datatypeDefinitionXhtml.Description = "string data type definition"; - datatypeDefinitionXhtml.Identifier = "xhtml"; - datatypeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); - datatypeDefinitionXhtml.LongName = "a string"; - CreateAlternativeId(datatypeDefinitionXhtml); - this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionXhtml); - } - - /// - /// create a with attribute definitions - /// - private void CreateSpecObjectType() - { - var specObjectType = new SpecObjectType(); - specObjectType.LongName = "Requirement Type"; - specObjectType.Identifier = "requirement"; - specObjectType.LastChange = DateTime.Parse("2015-12-01"); - CreateAlternativeId(specObjectType); - - var attributeDefinitionBoolean = new AttributeDefinitionBoolean(); - attributeDefinitionBoolean.LongName = "boolean attribute"; - attributeDefinitionBoolean.Identifier = "requirement-boolean-attribute"; - attributeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionBoolean.Type = (DatatypeDefinitionBoolean)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionBoolean)); - CreateAlternativeId(attributeDefinitionBoolean); - specObjectType.SpecAttributes.Add(attributeDefinitionBoolean); - - var attributeDefinitionDate = new AttributeDefinitionDate(); - attributeDefinitionDate.LongName = "date attribute"; - attributeDefinitionDate.Identifier = "requirement-date-attribute"; - attributeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionDate.Type = (DatatypeDefinitionDate)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionDate)); - CreateAlternativeId(attributeDefinitionDate); - specObjectType.SpecAttributes.Add(attributeDefinitionDate); - - var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration(); - attributeDefinitionEnumeration.LongName = "enumeration attribute"; - attributeDefinitionEnumeration.Identifier = "requirement-enumeration-attribute"; - attributeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionEnumeration.Type = (DatatypeDefinitionEnumeration)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionEnumeration)); - CreateAlternativeId(attributeDefinitionEnumeration); - specObjectType.SpecAttributes.Add(attributeDefinitionEnumeration); - - var attributeDefinitionInteger = new AttributeDefinitionInteger(); - attributeDefinitionInteger.LongName = "integer attribute"; - attributeDefinitionInteger.Identifier = "requirement-integer-attribute"; - attributeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionInteger.Type = (DatatypeDefinitionInteger)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionInteger)); - CreateAlternativeId(attributeDefinitionInteger); - specObjectType.SpecAttributes.Add(attributeDefinitionInteger); - - var attributeDefinitionReal = new AttributeDefinitionReal(); - attributeDefinitionReal.LongName = "real attribute"; - attributeDefinitionReal.Identifier = "requirement-real-attribute"; - attributeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionReal.Type = (DatatypeDefinitionReal)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionReal)); - CreateAlternativeId(attributeDefinitionReal); - specObjectType.SpecAttributes.Add(attributeDefinitionReal); - - var attributeDefinitionString = new AttributeDefinitionString(); - attributeDefinitionString.LongName = "string attribute"; - attributeDefinitionString.Identifier = "requirement-string-attribute"; - attributeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionString.Type = (DatatypeDefinitionString)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionString)); - CreateAlternativeId(attributeDefinitionString); - specObjectType.SpecAttributes.Add(attributeDefinitionString); - - var attributeDefinitionXhtml = new AttributeDefinitionXHTML(); - attributeDefinitionXhtml.LongName = "xhtml attribute"; - attributeDefinitionXhtml.Identifier = "requirement-xhtml-attribute"; - attributeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionXhtml.Type = (DatatypeDefinitionXHTML)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionXHTML)); - CreateAlternativeId(attributeDefinitionXhtml); - specObjectType.SpecAttributes.Add(attributeDefinitionXhtml); - - this.reqIF.CoreContent.SpecTypes.Add(specObjectType); - } - - /// - /// create a with attribute definitions - /// - private void CreateSpecificationType() - { - var reqIfContent = this.reqIF.CoreContent; - - var specificationType = new SpecificationType(); - specificationType.LongName = "Specification Type"; - specificationType.Identifier = "specificationtype"; - specificationType.LastChange = DateTime.Parse("2015-12-01"); - CreateAlternativeId(specificationType); - - CreateAndAddAttributeDefinitionsToSpecType(specificationType, reqIfContent); - - reqIfContent.SpecTypes.Add(specificationType); - } - - /// - /// create a with attribute definitions - /// - private void CreateSpecRelationType() - { - var reqIfContent = this.reqIF.CoreContent; - - var specRelationType = new SpecRelationType(); - specRelationType.LongName = "Specification Relation Type"; - specRelationType.Identifier = "specificationrelation"; - specRelationType.LastChange = DateTime.Parse("2015-12-01"); - CreateAlternativeId(specRelationType); - - var attributeDefinitionBoolean = new AttributeDefinitionBoolean(); - attributeDefinitionBoolean.LongName = "boolean attribute"; - attributeDefinitionBoolean.Identifier = "specificationrelation-boolean-attribute"; - attributeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionBoolean.Type = (DatatypeDefinitionBoolean)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionBoolean)); - CreateAlternativeId(attributeDefinitionBoolean); - specRelationType.SpecAttributes.Add(attributeDefinitionBoolean); - - var attributeDefinitionDate = new AttributeDefinitionDate(); - attributeDefinitionDate.LongName = "date attribute"; - attributeDefinitionDate.Identifier = "specificationrelation-date-attribute"; - attributeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionDate.Type = (DatatypeDefinitionDate)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionDate)); - CreateAlternativeId(attributeDefinitionDate); - specRelationType.SpecAttributes.Add(attributeDefinitionDate); - - var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration(); - attributeDefinitionEnumeration.LongName = "enumeration attribute"; - attributeDefinitionEnumeration.Identifier = "specificationrelation-enumeration-attribute"; - attributeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionEnumeration.Type = (DatatypeDefinitionEnumeration)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionEnumeration)); - CreateAlternativeId(attributeDefinitionEnumeration); - specRelationType.SpecAttributes.Add(attributeDefinitionEnumeration); - - var attributeDefinitionInteger = new AttributeDefinitionInteger(); - attributeDefinitionInteger.LongName = "integer attribute"; - attributeDefinitionInteger.Identifier = "specificationrelation-integer-attribute"; - attributeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionInteger.Type = (DatatypeDefinitionInteger)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionInteger)); - CreateAlternativeId(attributeDefinitionInteger); - specRelationType.SpecAttributes.Add(attributeDefinitionInteger); - - var attributeDefinitionReal = new AttributeDefinitionReal(); - attributeDefinitionReal.LongName = "real attribute"; - attributeDefinitionReal.Identifier = "specificationrelation-real-attribute"; - attributeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionReal.Type = (DatatypeDefinitionReal)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionReal)); - CreateAlternativeId(attributeDefinitionReal); - specRelationType.SpecAttributes.Add(attributeDefinitionReal); - - var attributeDefinitionString = new AttributeDefinitionString(); - attributeDefinitionString.LongName = "string attribute"; - attributeDefinitionString.Identifier = "specificationrelation-string-attribute"; - attributeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionString.Type = (DatatypeDefinitionString)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionString)); - CreateAlternativeId(attributeDefinitionString); - specRelationType.SpecAttributes.Add(attributeDefinitionString); - - var attributeDefinitionXhtml = new AttributeDefinitionXHTML(); - attributeDefinitionXhtml.LongName = "xhtml attribute"; - attributeDefinitionXhtml.Identifier = "specificationrelation-xhtml-attribute"; - attributeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionXhtml.Type = (DatatypeDefinitionXHTML)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionXHTML)); - CreateAlternativeId(attributeDefinitionXhtml); - specRelationType.SpecAttributes.Add(attributeDefinitionXhtml); - - reqIfContent.SpecTypes.Add(specRelationType); - } - - /// - /// create a with attribute definitions - /// - private void CreateRelationGroupType() - { - var relationGroupType = new RelationGroupType(); - relationGroupType.LongName = "Relation Group Type"; - relationGroupType.Identifier = "relationgrouptype"; - relationGroupType.LastChange = DateTime.Parse("2015-12-01"); - CreateAlternativeId(relationGroupType); - - var attributeDefinitionBoolean = new AttributeDefinitionBoolean(); - attributeDefinitionBoolean.LongName = "boolean attribute"; - attributeDefinitionBoolean.Identifier = "relationgrouptype-boolean-attribute"; - attributeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionBoolean.Type = (DatatypeDefinitionBoolean)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionBoolean)); - CreateAlternativeId(attributeDefinitionBoolean); - relationGroupType.SpecAttributes.Add(attributeDefinitionBoolean); - - var attributeDefinitionDate = new AttributeDefinitionDate(); - attributeDefinitionDate.LongName = "date attribute"; - attributeDefinitionDate.Identifier = "relationgrouptype-date-attribute"; - attributeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionDate.Type = (DatatypeDefinitionDate)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionDate)); - CreateAlternativeId(attributeDefinitionDate); - relationGroupType.SpecAttributes.Add(attributeDefinitionDate); - - var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration(); - attributeDefinitionEnumeration.LongName = "enumeration attribute"; - attributeDefinitionEnumeration.Identifier = "relationgrouptype-enumeration-attribute"; - attributeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionEnumeration.Type = (DatatypeDefinitionEnumeration)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionEnumeration)); - CreateAlternativeId(attributeDefinitionEnumeration); - relationGroupType.SpecAttributes.Add(attributeDefinitionEnumeration); - - var attributeDefinitionInteger = new AttributeDefinitionInteger(); - attributeDefinitionInteger.LongName = "integer attribute"; - attributeDefinitionInteger.Identifier = "relationgrouptype-integer-attribute"; - attributeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionInteger.Type = (DatatypeDefinitionInteger)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionInteger)); - CreateAlternativeId(attributeDefinitionInteger); - relationGroupType.SpecAttributes.Add(attributeDefinitionInteger); - - var attributeDefinitionReal = new AttributeDefinitionReal(); - attributeDefinitionReal.LongName = "real attribute"; - attributeDefinitionReal.Identifier = "relationgrouptype-real-attribute"; - attributeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionReal.Type = (DatatypeDefinitionReal)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionReal)); - CreateAlternativeId(attributeDefinitionReal); - relationGroupType.SpecAttributes.Add(attributeDefinitionReal); - - var attributeDefinitionString = new AttributeDefinitionString(); - attributeDefinitionString.LongName = "string attribute"; - attributeDefinitionString.Identifier = "relationgrouptype-string-attribute"; - attributeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionString.Type = (DatatypeDefinitionString)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionString)); - CreateAlternativeId(attributeDefinitionString); - relationGroupType.SpecAttributes.Add(attributeDefinitionString); - - var attributeDefinitionXhtml = new AttributeDefinitionXHTML(); - attributeDefinitionXhtml.LongName = "xhtml attribute"; - attributeDefinitionXhtml.Identifier = "relationgrouptype-xhtml-attribute"; - attributeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionXhtml.Type = (DatatypeDefinitionXHTML)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionXHTML)); - CreateAlternativeId(attributeDefinitionXhtml); - relationGroupType.SpecAttributes.Add(attributeDefinitionXhtml); - - this.reqIF.CoreContent.SpecTypes.Add(relationGroupType); - } - - /// - /// Create and add s to a - /// - /// - /// The to add the s to - /// - /// - /// An instance of - /// - private static void CreateAndAddAttributeDefinitionsToSpecType(SpecType specType, ReqIFContent reqIfContent) - { - var attributeDefinitionBoolean = new AttributeDefinitionBoolean(); - attributeDefinitionBoolean.LongName = "boolean attribute"; - attributeDefinitionBoolean.Identifier = "specification-boolean-attribute"; - attributeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionBoolean.Type = (DatatypeDefinitionBoolean)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionBoolean)); - CreateAlternativeId(attributeDefinitionBoolean); - specType.SpecAttributes.Add(attributeDefinitionBoolean); - - var attributeDefinitionDate = new AttributeDefinitionDate(); - attributeDefinitionDate.LongName = "date attribute"; - attributeDefinitionDate.Identifier = "specification-date-attribute"; - attributeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionDate.Type = (DatatypeDefinitionDate)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionDate)); - CreateAlternativeId(attributeDefinitionDate); - specType.SpecAttributes.Add(attributeDefinitionDate); - - var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration(); - attributeDefinitionEnumeration.LongName = "enumeration attribute"; - attributeDefinitionEnumeration.Identifier = "specification-enumeration-attribute"; - attributeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionEnumeration.Type = (DatatypeDefinitionEnumeration)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionEnumeration)); - CreateAlternativeId(attributeDefinitionEnumeration); - specType.SpecAttributes.Add(attributeDefinitionEnumeration); - - var attributeDefinitionInteger = new AttributeDefinitionInteger(); - attributeDefinitionInteger.LongName = "integer attribute"; - attributeDefinitionInteger.Identifier = "specification-integer-attribute"; - attributeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionInteger.Type = (DatatypeDefinitionInteger)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionInteger)); - CreateAlternativeId(attributeDefinitionInteger); - specType.SpecAttributes.Add(attributeDefinitionInteger); - - var attributeDefinitionReal = new AttributeDefinitionReal(); - attributeDefinitionReal.LongName = "real attribute"; - attributeDefinitionReal.Identifier = "specification-real-attribute"; - attributeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionReal.Type = (DatatypeDefinitionReal)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionReal)); - CreateAlternativeId(attributeDefinitionReal); - specType.SpecAttributes.Add(attributeDefinitionReal); - - var attributeDefinitionString = new AttributeDefinitionString(); - attributeDefinitionString.LongName = "string attribute"; - attributeDefinitionString.Identifier = "specification-string-attribute"; - attributeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionString.Type = (DatatypeDefinitionString)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionString)); - CreateAlternativeId(attributeDefinitionString); - specType.SpecAttributes.Add(attributeDefinitionString); - - var attributeDefinitionXhtml = new AttributeDefinitionXHTML(); - attributeDefinitionXhtml.LongName = "xhtml attribute"; - attributeDefinitionXhtml.Identifier = "specification-xhtml-attribute"; - attributeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); - attributeDefinitionXhtml.Type = (DatatypeDefinitionXHTML)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionXHTML)); - CreateAlternativeId(attributeDefinitionXhtml); - specType.SpecAttributes.Add(attributeDefinitionXhtml); - } - - /// - /// create a s with attribute values - /// - private void CreateSpecObjects() - { - var reqIfContent = this.reqIF.CoreContent; - - var specObject = new SpecObject(); - specObject.LongName = "spec object 1"; - specObject.Identifier = this.specobject_1_id; - specObject.LastChange = DateTime.Parse("2015-12-01"); - var specType = (SpecObjectType)reqIfContent.SpecTypes.SingleOrDefault(x => x.GetType() == typeof(SpecObjectType)); - specObject.Type = specType; - this.CreateValuesForSpecElementWithAttributes(specObject, specType); - CreateAlternativeId(specObject); - reqIfContent.SpecObjects.Add(specObject); - - var specobject_2 = new SpecObject(); - specobject_2.LongName = "spec object 2"; - specobject_2.Identifier = this.specobject_2_id; - specobject_2.LastChange = DateTime.Parse("2015-12-01"); - specobject_2.Type = specType; - this.CreateValuesForSpecElementWithAttributes(specobject_2, specType); - CreateAlternativeId(specobject_2); - reqIfContent.SpecObjects.Add(specobject_2); - - var specobject_3 = new SpecObject(); - specobject_3.LongName = "spec object 3"; - specobject_3.Identifier = this.specobject_3_id; - specobject_3.LastChange = DateTime.Parse("2015-12-01"); - specobject_3.Type = specType; - this.CreateValuesForSpecElementWithAttributes(specobject_3, specType); - CreateAlternativeId(specobject_3); - reqIfContent.SpecObjects.Add(specobject_3); - } - - /// - /// create a s - /// - private void CreateSpecRelations() - { - var reqIfContent = this.reqIF.CoreContent; - - var specRelationType = (SpecRelationType)reqIfContent.SpecTypes.SingleOrDefault(x => x.GetType() == typeof(SpecRelationType)); - var source = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_1_id); - var target = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_2_id); - - var specRelation = new SpecRelation(); - specRelation.Identifier = string.Format("{0}-{1}", source.Identifier, target.Identifier); - specRelation.LastChange = DateTime.Parse("2015-12-01"); - specRelation.LongName = "A relationship between spec objects"; - specRelation.Type = specRelationType; - specRelation.Source = source; - specRelation.Target = target; - this.CreateValuesForSpecElementWithAttributes(specRelation, specRelationType); - CreateAlternativeId(specRelation); - - reqIfContent.SpecRelations.Add(specRelation); - } - - /// - /// create a s - /// - private void CreateSpecifications() - { - var reqIfContent = this.reqIF.CoreContent; - var specificationType = (SpecificationType)reqIfContent.SpecTypes.SingleOrDefault(x => x.GetType() == typeof(SpecificationType)); - - var object1 = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_1_id); - var object2 = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_2_id); - var object3 = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_3_id); - - var specification1 = new Specification(); - specification1.Identifier = "specification-1"; - specification1.LastChange = DateTime.Parse("2015-12-01"); - specification1.LongName = "specification 1"; - specification1.Type = specificationType; - this.CreateValuesForSpecElementWithAttributes(specification1, specificationType); - CreateAlternativeId(specification1); - - var specHierarchy1 = new SpecHierarchy(); - specHierarchy1.Identifier = "spec-hierarchy-1"; - specHierarchy1.LastChange = DateTime.Parse("2015-12-01"); - specHierarchy1.LongName = "specHierarchy 1"; - specHierarchy1.Object = object1; +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2017-2022 RHEA System S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace ReqIFSharp.Tests +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using System.Xml; + + using NUnit.Framework; + + using ReqIFSharp; + + [TestFixture] + internal class ReqIFSerializerTestFixture + { + private ReqIF reqIF; + + private string resultFileUri; + private string resultFileUriArchive; + private string asyncResultFileUri; + private string asyncResultFileUriArchive; + + private const string ReqIFNamespace = @"http://www.omg.org/spec/ReqIF/20110401/reqif.xsd"; + + private string specobject_1_id; + + private string specobject_2_id; + + private string specobject_3_id; + + private string enumdatatype_id; + + private string enum_value_low_id; + + private string enum_value_medium_id; + + private string xhtmlcontent; + + [SetUp] + public void SetUp() + { + this.resultFileUri = Path.Combine(TestContext.CurrentContext.TestDirectory, "result.reqif"); + this.resultFileUriArchive = Path.Combine(TestContext.CurrentContext.TestDirectory, "result.reqifz"); + this.asyncResultFileUri = Path.Combine(TestContext.CurrentContext.TestDirectory, "async-result.reqif"); + this.asyncResultFileUriArchive = Path.Combine(TestContext.CurrentContext.TestDirectory, "async-result.reqifz"); + + this.CleanUpFiles(); + + this.enumdatatype_id = "enumeration"; + this.enum_value_low_id = "enumlow"; + this.enum_value_medium_id = "enummedium"; + + this.specobject_1_id = "specobject_1"; + this.specobject_2_id = "specobject_2"; + this.specobject_3_id = "specobject_3"; + + this.xhtmlcontent = "XhtmlPType text before brtext after br text before spanXhtmlSpanTypetext after span text before emXhtmlEmTypetext after em text before strongXhtmlStrongTypetext after strong text before dfnXhtmlDfnTypetext after dfn text before codeXhtmlCodeTypetext after code text before sampXhtmlSampTypetext after samp text before kbdXhtmlKbdTypetext after kbd text before varXhtmlVarTypetext after var text before citeXhtmlCiteTypetext after cite text before abbrXhtmlAbbrTypetext after abbr text before acronymXhtmlAcronymTypetext after acronym text before qXhtmlQTypetext after q text before ttXhtmlInlPresTypetext after tt text before iXhtmlInlPresTypetext after i text before bXhtmlInlPresTypetext after b text before bigXhtmlInlPresTypetext after big text before smallXhtmlInlPresTypetext after small text before subXhtmlInlPresTypetext after sub text before supXhtmlInlPresTypetext after sup text before insXhtmlEditTypetext after ins text before delXhtmlEditTypetext after del"; + + this.reqIF = new ReqIF(); + this.reqIF.Lang = "en"; + + var header = new ReqIFHeader(); + header.Comment = "this is a comment"; + header.CreationTime = DateTime.Parse("2015-12-01"); + header.Identifier = "reqifheader"; + header.RepositoryId = "a repos id"; + header.ReqIFToolId = "tool - CDP4"; + header.ReqIFVersion = "1.0"; + header.SourceToolId = "source tool - CDP4"; + header.Title = "this is a title"; + + this.reqIF.TheHeader = header; + + var reqIfContent = new ReqIFContent(); + this.reqIF.CoreContent = reqIfContent; + + this.CreateDataTypes(); + this.CreateSpecObjectType(); + this.CreateSpecificationType(); + this.CreateSpecRelationType(); + this.CreateRelationGroupType(); + + this.CreateSpecObjects(); + this.CreateSpecRelations(); + this.CreateSpecifications(); + this.CreateRelationGroup(); + } + + [TearDown] + public void TearDown() + { + this.CleanUpFiles(); + } + + /// + /// Clean up generated reqif and reqifz files + /// + private void CleanUpFiles() + { + File.Delete(this.resultFileUri); + File.Delete(this.resultFileUriArchive); + File.Delete(this.asyncResultFileUri); + File.Delete(this.asyncResultFileUriArchive); + } + + /// + /// create all the different s + /// + private void CreateDataTypes() + { + var datatypeDefinitionBoolean = new DatatypeDefinitionBoolean(); + datatypeDefinitionBoolean.Description = "boolean data type definition"; + datatypeDefinitionBoolean.Identifier = "boolean"; + datatypeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); + datatypeDefinitionBoolean.LongName = "a boolean"; + CreateAlternativeId(datatypeDefinitionBoolean); + this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionBoolean); + + var datatypeDefinitionDate = new DatatypeDefinitionDate(); + datatypeDefinitionDate.Description = "date data type definition"; + datatypeDefinitionDate.Identifier = "DateTime"; + datatypeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); + datatypeDefinitionDate.LongName = "a date"; + CreateAlternativeId(datatypeDefinitionDate); + this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionDate); + + var datatypeDefinitionEnumeration = new DatatypeDefinitionEnumeration(); + datatypeDefinitionEnumeration.Description = "enum value type definition"; + datatypeDefinitionEnumeration.Identifier = this.enumdatatype_id; + datatypeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); + datatypeDefinitionEnumeration.LongName = "an enumeration"; + CreateAlternativeId(datatypeDefinitionEnumeration); + + var enumValuelow = new EnumValue(); + enumValuelow.Identifier = this.enum_value_low_id; + enumValuelow.LastChange = DateTime.Parse("2015-12-01"); + enumValuelow.LongName = "low"; + CreateAlternativeId(enumValuelow); + + var embeddedValueLow = new EmbeddedValue(); + embeddedValueLow.Key = 1; + embeddedValueLow.OtherContent = "foo"; + enumValuelow.Properties = embeddedValueLow; + + var enumValuemedium = new EnumValue(); + enumValuemedium.Identifier = this.enum_value_medium_id; + enumValuemedium.LastChange = DateTime.Parse("2015-12-01"); + enumValuemedium.LongName = "medium"; + CreateAlternativeId(enumValuemedium); + + var embeddedValueMedium = new EmbeddedValue(); + embeddedValueMedium.Key = 2; + embeddedValueMedium.OtherContent = "bar"; + enumValuemedium.Properties = embeddedValueMedium; + + datatypeDefinitionEnumeration.SpecifiedValues.Add(enumValuelow); + datatypeDefinitionEnumeration.SpecifiedValues.Add(enumValuemedium); + + this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionEnumeration); + + var datatypeDefinitionInteger = new DatatypeDefinitionInteger(); + datatypeDefinitionInteger.Description = "integer data type definition"; + datatypeDefinitionInteger.Identifier = "integer"; + datatypeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); + datatypeDefinitionInteger.LongName = "an integer"; + datatypeDefinitionInteger.Min = 2; + datatypeDefinitionInteger.Max = 6; + CreateAlternativeId(datatypeDefinitionInteger); + this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionInteger); + + var datatypeDefinitionReal = new DatatypeDefinitionReal(); + datatypeDefinitionReal.Description = "real data type definition"; + datatypeDefinitionReal.Identifier = "real"; + datatypeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); + datatypeDefinitionReal.LongName = "a real"; + datatypeDefinitionReal.Accuracy = 5; + datatypeDefinitionReal.Min = 1; + datatypeDefinitionReal.Max = 5; + CreateAlternativeId(datatypeDefinitionReal); + this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionReal); + + var datatypeDefinitionString = new DatatypeDefinitionString(); + datatypeDefinitionString.Description = "string data type definition"; + datatypeDefinitionString.Identifier = "string"; + datatypeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); + datatypeDefinitionString.MaxLength = 32000; + datatypeDefinitionString.LongName = "a string"; + CreateAlternativeId(datatypeDefinitionString); + this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionString); + + var datatypeDefinitionXhtml = new DatatypeDefinitionXHTML(); + datatypeDefinitionXhtml.Description = "string data type definition"; + datatypeDefinitionXhtml.Identifier = "xhtml"; + datatypeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); + datatypeDefinitionXhtml.LongName = "a string"; + CreateAlternativeId(datatypeDefinitionXhtml); + this.reqIF.CoreContent.DataTypes.Add(datatypeDefinitionXhtml); + } + + /// + /// create a with attribute definitions + /// + private void CreateSpecObjectType() + { + var specObjectType = new SpecObjectType(); + specObjectType.LongName = "Requirement Type"; + specObjectType.Identifier = "requirement"; + specObjectType.LastChange = DateTime.Parse("2015-12-01"); + CreateAlternativeId(specObjectType); + + var attributeDefinitionBoolean = new AttributeDefinitionBoolean(); + attributeDefinitionBoolean.LongName = "boolean attribute"; + attributeDefinitionBoolean.Identifier = "requirement-boolean-attribute"; + attributeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionBoolean.Type = (DatatypeDefinitionBoolean)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionBoolean)); + CreateAlternativeId(attributeDefinitionBoolean); + specObjectType.SpecAttributes.Add(attributeDefinitionBoolean); + + var attributeDefinitionDate = new AttributeDefinitionDate(); + attributeDefinitionDate.LongName = "date attribute"; + attributeDefinitionDate.Identifier = "requirement-date-attribute"; + attributeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionDate.Type = (DatatypeDefinitionDate)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionDate)); + CreateAlternativeId(attributeDefinitionDate); + specObjectType.SpecAttributes.Add(attributeDefinitionDate); + + var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration(); + attributeDefinitionEnumeration.LongName = "enumeration attribute"; + attributeDefinitionEnumeration.Identifier = "requirement-enumeration-attribute"; + attributeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionEnumeration.Type = (DatatypeDefinitionEnumeration)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionEnumeration)); + CreateAlternativeId(attributeDefinitionEnumeration); + specObjectType.SpecAttributes.Add(attributeDefinitionEnumeration); + + var attributeDefinitionInteger = new AttributeDefinitionInteger(); + attributeDefinitionInteger.LongName = "integer attribute"; + attributeDefinitionInteger.Identifier = "requirement-integer-attribute"; + attributeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionInteger.Type = (DatatypeDefinitionInteger)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionInteger)); + CreateAlternativeId(attributeDefinitionInteger); + specObjectType.SpecAttributes.Add(attributeDefinitionInteger); + + var attributeDefinitionReal = new AttributeDefinitionReal(); + attributeDefinitionReal.LongName = "real attribute"; + attributeDefinitionReal.Identifier = "requirement-real-attribute"; + attributeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionReal.Type = (DatatypeDefinitionReal)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionReal)); + CreateAlternativeId(attributeDefinitionReal); + specObjectType.SpecAttributes.Add(attributeDefinitionReal); + + var attributeDefinitionString = new AttributeDefinitionString(); + attributeDefinitionString.LongName = "string attribute"; + attributeDefinitionString.Identifier = "requirement-string-attribute"; + attributeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionString.Type = (DatatypeDefinitionString)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionString)); + CreateAlternativeId(attributeDefinitionString); + specObjectType.SpecAttributes.Add(attributeDefinitionString); + + var attributeDefinitionXhtml = new AttributeDefinitionXHTML(); + attributeDefinitionXhtml.LongName = "xhtml attribute"; + attributeDefinitionXhtml.Identifier = "requirement-xhtml-attribute"; + attributeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionXhtml.Type = (DatatypeDefinitionXHTML)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionXHTML)); + CreateAlternativeId(attributeDefinitionXhtml); + specObjectType.SpecAttributes.Add(attributeDefinitionXhtml); + + this.reqIF.CoreContent.SpecTypes.Add(specObjectType); + } + + /// + /// create a with attribute definitions + /// + private void CreateSpecificationType() + { + var reqIfContent = this.reqIF.CoreContent; + + var specificationType = new SpecificationType(); + specificationType.LongName = "Specification Type"; + specificationType.Identifier = "specificationtype"; + specificationType.LastChange = DateTime.Parse("2015-12-01"); + CreateAlternativeId(specificationType); + + CreateAndAddAttributeDefinitionsToSpecType(specificationType, reqIfContent); + + reqIfContent.SpecTypes.Add(specificationType); + } + + /// + /// create a with attribute definitions + /// + private void CreateSpecRelationType() + { + var reqIfContent = this.reqIF.CoreContent; + + var specRelationType = new SpecRelationType(); + specRelationType.LongName = "Specification Relation Type"; + specRelationType.Identifier = "specificationrelation"; + specRelationType.LastChange = DateTime.Parse("2015-12-01"); + CreateAlternativeId(specRelationType); + + var attributeDefinitionBoolean = new AttributeDefinitionBoolean(); + attributeDefinitionBoolean.LongName = "boolean attribute"; + attributeDefinitionBoolean.Identifier = "specificationrelation-boolean-attribute"; + attributeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionBoolean.Type = (DatatypeDefinitionBoolean)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionBoolean)); + CreateAlternativeId(attributeDefinitionBoolean); + specRelationType.SpecAttributes.Add(attributeDefinitionBoolean); + + var attributeDefinitionDate = new AttributeDefinitionDate(); + attributeDefinitionDate.LongName = "date attribute"; + attributeDefinitionDate.Identifier = "specificationrelation-date-attribute"; + attributeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionDate.Type = (DatatypeDefinitionDate)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionDate)); + CreateAlternativeId(attributeDefinitionDate); + specRelationType.SpecAttributes.Add(attributeDefinitionDate); + + var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration(); + attributeDefinitionEnumeration.LongName = "enumeration attribute"; + attributeDefinitionEnumeration.Identifier = "specificationrelation-enumeration-attribute"; + attributeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionEnumeration.Type = (DatatypeDefinitionEnumeration)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionEnumeration)); + CreateAlternativeId(attributeDefinitionEnumeration); + specRelationType.SpecAttributes.Add(attributeDefinitionEnumeration); + + var attributeDefinitionInteger = new AttributeDefinitionInteger(); + attributeDefinitionInteger.LongName = "integer attribute"; + attributeDefinitionInteger.Identifier = "specificationrelation-integer-attribute"; + attributeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionInteger.Type = (DatatypeDefinitionInteger)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionInteger)); + CreateAlternativeId(attributeDefinitionInteger); + specRelationType.SpecAttributes.Add(attributeDefinitionInteger); + + var attributeDefinitionReal = new AttributeDefinitionReal(); + attributeDefinitionReal.LongName = "real attribute"; + attributeDefinitionReal.Identifier = "specificationrelation-real-attribute"; + attributeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionReal.Type = (DatatypeDefinitionReal)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionReal)); + CreateAlternativeId(attributeDefinitionReal); + specRelationType.SpecAttributes.Add(attributeDefinitionReal); + + var attributeDefinitionString = new AttributeDefinitionString(); + attributeDefinitionString.LongName = "string attribute"; + attributeDefinitionString.Identifier = "specificationrelation-string-attribute"; + attributeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionString.Type = (DatatypeDefinitionString)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionString)); + CreateAlternativeId(attributeDefinitionString); + specRelationType.SpecAttributes.Add(attributeDefinitionString); + + var attributeDefinitionXhtml = new AttributeDefinitionXHTML(); + attributeDefinitionXhtml.LongName = "xhtml attribute"; + attributeDefinitionXhtml.Identifier = "specificationrelation-xhtml-attribute"; + attributeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionXhtml.Type = (DatatypeDefinitionXHTML)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionXHTML)); + CreateAlternativeId(attributeDefinitionXhtml); + specRelationType.SpecAttributes.Add(attributeDefinitionXhtml); + + reqIfContent.SpecTypes.Add(specRelationType); + } + + /// + /// create a with attribute definitions + /// + private void CreateRelationGroupType() + { + var relationGroupType = new RelationGroupType(); + relationGroupType.LongName = "Relation Group Type"; + relationGroupType.Identifier = "relationgrouptype"; + relationGroupType.LastChange = DateTime.Parse("2015-12-01"); + CreateAlternativeId(relationGroupType); + + var attributeDefinitionBoolean = new AttributeDefinitionBoolean(); + attributeDefinitionBoolean.LongName = "boolean attribute"; + attributeDefinitionBoolean.Identifier = "relationgrouptype-boolean-attribute"; + attributeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionBoolean.Type = (DatatypeDefinitionBoolean)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionBoolean)); + CreateAlternativeId(attributeDefinitionBoolean); + relationGroupType.SpecAttributes.Add(attributeDefinitionBoolean); + + var attributeDefinitionDate = new AttributeDefinitionDate(); + attributeDefinitionDate.LongName = "date attribute"; + attributeDefinitionDate.Identifier = "relationgrouptype-date-attribute"; + attributeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionDate.Type = (DatatypeDefinitionDate)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionDate)); + CreateAlternativeId(attributeDefinitionDate); + relationGroupType.SpecAttributes.Add(attributeDefinitionDate); + + var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration(); + attributeDefinitionEnumeration.LongName = "enumeration attribute"; + attributeDefinitionEnumeration.Identifier = "relationgrouptype-enumeration-attribute"; + attributeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionEnumeration.Type = (DatatypeDefinitionEnumeration)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionEnumeration)); + CreateAlternativeId(attributeDefinitionEnumeration); + relationGroupType.SpecAttributes.Add(attributeDefinitionEnumeration); + + var attributeDefinitionInteger = new AttributeDefinitionInteger(); + attributeDefinitionInteger.LongName = "integer attribute"; + attributeDefinitionInteger.Identifier = "relationgrouptype-integer-attribute"; + attributeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionInteger.Type = (DatatypeDefinitionInteger)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionInteger)); + CreateAlternativeId(attributeDefinitionInteger); + relationGroupType.SpecAttributes.Add(attributeDefinitionInteger); + + var attributeDefinitionReal = new AttributeDefinitionReal(); + attributeDefinitionReal.LongName = "real attribute"; + attributeDefinitionReal.Identifier = "relationgrouptype-real-attribute"; + attributeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionReal.Type = (DatatypeDefinitionReal)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionReal)); + CreateAlternativeId(attributeDefinitionReal); + relationGroupType.SpecAttributes.Add(attributeDefinitionReal); + + var attributeDefinitionString = new AttributeDefinitionString(); + attributeDefinitionString.LongName = "string attribute"; + attributeDefinitionString.Identifier = "relationgrouptype-string-attribute"; + attributeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionString.Type = (DatatypeDefinitionString)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionString)); + CreateAlternativeId(attributeDefinitionString); + relationGroupType.SpecAttributes.Add(attributeDefinitionString); + + var attributeDefinitionXhtml = new AttributeDefinitionXHTML(); + attributeDefinitionXhtml.LongName = "xhtml attribute"; + attributeDefinitionXhtml.Identifier = "relationgrouptype-xhtml-attribute"; + attributeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionXhtml.Type = (DatatypeDefinitionXHTML)this.reqIF.CoreContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionXHTML)); + CreateAlternativeId(attributeDefinitionXhtml); + relationGroupType.SpecAttributes.Add(attributeDefinitionXhtml); + + this.reqIF.CoreContent.SpecTypes.Add(relationGroupType); + } + + /// + /// Create and add s to a + /// + /// + /// The to add the s to + /// + /// + /// An instance of + /// + private static void CreateAndAddAttributeDefinitionsToSpecType(SpecType specType, ReqIFContent reqIfContent) + { + var attributeDefinitionBoolean = new AttributeDefinitionBoolean(); + attributeDefinitionBoolean.LongName = "boolean attribute"; + attributeDefinitionBoolean.Identifier = "specification-boolean-attribute"; + attributeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionBoolean.Type = (DatatypeDefinitionBoolean)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionBoolean)); + CreateAlternativeId(attributeDefinitionBoolean); + specType.SpecAttributes.Add(attributeDefinitionBoolean); + + var attributeDefinitionDate = new AttributeDefinitionDate(); + attributeDefinitionDate.LongName = "date attribute"; + attributeDefinitionDate.Identifier = "specification-date-attribute"; + attributeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionDate.Type = (DatatypeDefinitionDate)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionDate)); + CreateAlternativeId(attributeDefinitionDate); + specType.SpecAttributes.Add(attributeDefinitionDate); + + var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration(); + attributeDefinitionEnumeration.LongName = "enumeration attribute"; + attributeDefinitionEnumeration.Identifier = "specification-enumeration-attribute"; + attributeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionEnumeration.Type = (DatatypeDefinitionEnumeration)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionEnumeration)); + CreateAlternativeId(attributeDefinitionEnumeration); + specType.SpecAttributes.Add(attributeDefinitionEnumeration); + + var attributeDefinitionInteger = new AttributeDefinitionInteger(); + attributeDefinitionInteger.LongName = "integer attribute"; + attributeDefinitionInteger.Identifier = "specification-integer-attribute"; + attributeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionInteger.Type = (DatatypeDefinitionInteger)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionInteger)); + CreateAlternativeId(attributeDefinitionInteger); + specType.SpecAttributes.Add(attributeDefinitionInteger); + + var attributeDefinitionReal = new AttributeDefinitionReal(); + attributeDefinitionReal.LongName = "real attribute"; + attributeDefinitionReal.Identifier = "specification-real-attribute"; + attributeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionReal.Type = (DatatypeDefinitionReal)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionReal)); + CreateAlternativeId(attributeDefinitionReal); + specType.SpecAttributes.Add(attributeDefinitionReal); + + var attributeDefinitionString = new AttributeDefinitionString(); + attributeDefinitionString.LongName = "string attribute"; + attributeDefinitionString.Identifier = "specification-string-attribute"; + attributeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionString.Type = (DatatypeDefinitionString)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionString)); + CreateAlternativeId(attributeDefinitionString); + specType.SpecAttributes.Add(attributeDefinitionString); + + var attributeDefinitionXhtml = new AttributeDefinitionXHTML(); + attributeDefinitionXhtml.LongName = "xhtml attribute"; + attributeDefinitionXhtml.Identifier = "specification-xhtml-attribute"; + attributeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); + attributeDefinitionXhtml.Type = (DatatypeDefinitionXHTML)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionXHTML)); + CreateAlternativeId(attributeDefinitionXhtml); + specType.SpecAttributes.Add(attributeDefinitionXhtml); + } + + /// + /// create a s with attribute values + /// + private void CreateSpecObjects() + { + var reqIfContent = this.reqIF.CoreContent; + + var specObject = new SpecObject(); + specObject.LongName = "spec object 1"; + specObject.Identifier = this.specobject_1_id; + specObject.LastChange = DateTime.Parse("2015-12-01"); + var specType = (SpecObjectType)reqIfContent.SpecTypes.SingleOrDefault(x => x.GetType() == typeof(SpecObjectType)); + specObject.Type = specType; + this.CreateValuesForSpecElementWithAttributes(specObject, specType); + CreateAlternativeId(specObject); + reqIfContent.SpecObjects.Add(specObject); + + var specobject_2 = new SpecObject(); + specobject_2.LongName = "spec object 2"; + specobject_2.Identifier = this.specobject_2_id; + specobject_2.LastChange = DateTime.Parse("2015-12-01"); + specobject_2.Type = specType; + this.CreateValuesForSpecElementWithAttributes(specobject_2, specType); + CreateAlternativeId(specobject_2); + reqIfContent.SpecObjects.Add(specobject_2); + + var specobject_3 = new SpecObject(); + specobject_3.LongName = "spec object 3"; + specobject_3.Identifier = this.specobject_3_id; + specobject_3.LastChange = DateTime.Parse("2015-12-01"); + specobject_3.Type = specType; + this.CreateValuesForSpecElementWithAttributes(specobject_3, specType); + CreateAlternativeId(specobject_3); + reqIfContent.SpecObjects.Add(specobject_3); + } + + /// + /// create a s + /// + private void CreateSpecRelations() + { + var reqIfContent = this.reqIF.CoreContent; + + var specRelationType = (SpecRelationType)reqIfContent.SpecTypes.SingleOrDefault(x => x.GetType() == typeof(SpecRelationType)); + var source = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_1_id); + var target = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_2_id); + + var specRelation = new SpecRelation(); + specRelation.Identifier = string.Format("{0}-{1}", source.Identifier, target.Identifier); + specRelation.LastChange = DateTime.Parse("2015-12-01"); + specRelation.LongName = "A relationship between spec objects"; + specRelation.Type = specRelationType; + specRelation.Source = source; + specRelation.Target = target; + this.CreateValuesForSpecElementWithAttributes(specRelation, specRelationType); + CreateAlternativeId(specRelation); + + reqIfContent.SpecRelations.Add(specRelation); + } + + /// + /// create a s + /// + private void CreateSpecifications() + { + var reqIfContent = this.reqIF.CoreContent; + var specificationType = (SpecificationType)reqIfContent.SpecTypes.SingleOrDefault(x => x.GetType() == typeof(SpecificationType)); + + var object1 = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_1_id); + var object2 = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_2_id); + var object3 = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_3_id); + + var specification1 = new Specification(); + specification1.Identifier = "specification-1"; + specification1.LastChange = DateTime.Parse("2015-12-01"); + specification1.LongName = "specification 1"; + specification1.Type = specificationType; + this.CreateValuesForSpecElementWithAttributes(specification1, specificationType); + CreateAlternativeId(specification1); + + var specHierarchy1 = new SpecHierarchy(); + specHierarchy1.Identifier = "spec-hierarchy-1"; + specHierarchy1.LastChange = DateTime.Parse("2015-12-01"); + specHierarchy1.LongName = "specHierarchy 1"; + specHierarchy1.Object = object1; CreateAlternativeId(specHierarchy1); - var specHierarchy1_1 = new SpecHierarchy(); - specHierarchy1_1.Identifier = "spec-hierarchy-1-1"; - specHierarchy1_1.LastChange = DateTime.Parse("2015-12-01"); - specHierarchy1_1.LongName = "specHierarchy 1_1"; - specHierarchy1_1.Object = object2; - CreateAlternativeId(specHierarchy1_1); - - var specHierarchy1_2 = new SpecHierarchy(); - specHierarchy1_2.Identifier = "spec-hierarchy-1-2"; - specHierarchy1_2.LastChange = DateTime.Parse("2015-12-01"); - specHierarchy1_2.LongName = "specHierarchy 1_2"; - specHierarchy1_2.Object = object3; - CreateAlternativeId(specHierarchy1_2); - - specification1.Children.Add(specHierarchy1); - specHierarchy1.Children.Add(specHierarchy1_1); - specHierarchy1.Children.Add(specHierarchy1_2); - - reqIfContent.Specifications.Add(specification1); - - var specification2 = new Specification(); - specification2.Identifier = "specification-2"; - specification2.LastChange = DateTime.Parse("2015-12-01"); - specification2.LongName = "specification 2"; - specification2.Type = specificationType; - this.CreateValuesForSpecElementWithAttributes(specification2, specificationType); - CreateAlternativeId(specification2); - reqIfContent.Specifications.Add(specification2); - } - - /// - /// Creates a - /// - private void CreateRelationGroup() - { - var reqIfContent = this.reqIF.CoreContent; - - var relationGroupType = (RelationGroupType)reqIfContent.SpecTypes.SingleOrDefault(x => x.GetType() == typeof(RelationGroupType)); - - var relationGroup = new RelationGroup(); - relationGroup.Identifier = "relationgroup-1"; - relationGroup.LastChange = DateTime.Parse("2015-12-01"); - relationGroup.LongName = "relationgroup 1"; - relationGroup.Type = relationGroupType; - CreateAlternativeId(relationGroup); - - var sourceSpecification = reqIfContent.Specifications.SingleOrDefault(x => x.Identifier == "specification-1"); - var targetSpecification = reqIfContent.Specifications.SingleOrDefault(x => x.Identifier == "specification-2"); - - relationGroup.SourceSpecification = sourceSpecification; - relationGroup.TargetSpecification = targetSpecification; - - reqIfContent.SpecRelationGroups.Add(relationGroup); - } - - /// - /// Create For - /// - /// - /// The to which s need to be added. - /// - /// - /// The of the - /// - private void CreateValuesForSpecElementWithAttributes(SpecElementWithAttributes specElementWithAttributes, SpecType specType) - { - var attributeValueBoolean = new AttributeValueBoolean(); - attributeValueBoolean.Definition = (AttributeDefinitionBoolean)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionBoolean)); - attributeValueBoolean.TheValue = true; - specElementWithAttributes.Values.Add(attributeValueBoolean); - - var attributeValueDate = new AttributeValueDate(); - attributeValueDate.Definition = (AttributeDefinitionDate)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionDate)); - attributeValueDate.TheValue = XmlConvert.ToDateTime("2015-12-01", XmlDateTimeSerializationMode.Utc); - specElementWithAttributes.Values.Add(attributeValueDate); - - var attributeValueEnumeration = new AttributeValueEnumeration(); - attributeValueEnumeration.Definition = (AttributeDefinitionEnumeration)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionEnumeration)); - var enumValue = attributeValueEnumeration.Definition.Type.SpecifiedValues.FirstOrDefault(); - attributeValueEnumeration.Values.Add(enumValue); - specElementWithAttributes.Values.Add(attributeValueEnumeration); - - var attributeValueInteger = new AttributeValueInteger(); - attributeValueInteger.Definition = (AttributeDefinitionInteger)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionInteger)); - attributeValueInteger.TheValue = 1; - specElementWithAttributes.Values.Add(attributeValueInteger); - - var attributeValueReal = new AttributeValueReal(); - attributeValueReal.Definition = (AttributeDefinitionReal)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionReal)); - attributeValueReal.TheValue = 100; - specElementWithAttributes.Values.Add(attributeValueReal); - - var attributeValueString = new AttributeValueString(); - attributeValueString.Definition = (AttributeDefinitionString)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionString)); - attributeValueString.TheValue = "a string value"; - specElementWithAttributes.Values.Add(attributeValueString); - - var attributeValueXhtml = new AttributeValueXHTML(); - attributeValueXhtml.Definition = (AttributeDefinitionXHTML)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionXHTML)); - attributeValueXhtml.TheValue = this.xhtmlcontent; - specElementWithAttributes.Values.Add(attributeValueXhtml); - - var simplifiedAttributeValueXhtml = new AttributeValueXHTML(); - simplifiedAttributeValueXhtml.Definition = (AttributeDefinitionXHTML)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionXHTML)); - simplifiedAttributeValueXhtml.IsSimplified = true; - simplifiedAttributeValueXhtml.TheValue = "simplified content"; - simplifiedAttributeValueXhtml.TheOriginalValue= this.xhtmlcontent; - specElementWithAttributes.Values.Add(simplifiedAttributeValueXhtml); - } - - /// - /// Create an for the - /// - /// - /// The for which an needs to be created - /// - private static void CreateAlternativeId(Identifiable identifiable) - { - var alternativeId = new AlternativeId(); - alternativeId.Identifier = identifiable.Identifier + "_alternative"; - - alternativeId.Ident = identifiable; - identifiable.AlternativeId = alternativeId; - } - - [Test] - public void Verify_That_ArgumentException_Is_Raised_OnSerialize_to_file() - { - var serializer = new ReqIFSerializer(); - - string filePath = null; - - var reqifs = new List(); - - Assert.That( - () => serializer.Serialize(reqifs, filePath), - Throws.Exception.TypeOf() - .With.Message.Contains("The path of the ReqIF file cannot be null.")); - - Assert.That( - () => serializer.Serialize(reqifs, string.Empty), - Throws.Exception.TypeOf() - .With.Message.Contains("The path of the ReqIF file cannot be empty.")); - - filePath = this.resultFileUri; - - Assert.That( - () => serializer.Serialize(null, filePath), - Throws.Exception.TypeOf() - .With.Message.Contains("The reqIfs object cannot be null.")); - - Assert.That(() => serializer.Serialize(reqifs, filePath), - Throws.Exception.TypeOf() - .With.Message.Contains("One and only one ReqIF object can be serialized to a reqif file. If multiple ReqIF objects need to be serialized, please make use of the reqifz format.")); - - filePath = this.resultFileUriArchive; - - Assert.That(() => serializer.Serialize(reqifs, filePath), - Throws.Exception.TypeOf() - .With.Message.Contains("At least one ReqIF object must be serialized.")); - - filePath = Path.ChangeExtension(filePath, "xml"); - - Assert.That(() => serializer.Serialize(reqifs, filePath), - Throws.Exception.TypeOf() - .With.Message.Contains("only .reqif, .reqifz and .zip are supported file extensions.")); - } - - [Test] - public void Verify_That_ArgumentException_Is_Raised_OnAsyncSerialize_to_file() - { - var cancellationTokenSource = new CancellationTokenSource(); - - var serializer = new ReqIFSerializer(); - - string filePath = null; - - var reqifs = new List(); - - Assert.That( - async () => await serializer.SerializeAsync(reqifs, filePath, cancellationTokenSource.Token), - Throws.Exception.TypeOf() - .With.Message.Contains("The path of the ReqIF file cannot be null.")); - - Assert.That( - async () => await serializer.SerializeAsync(reqifs, string.Empty, cancellationTokenSource.Token), - Throws.Exception.TypeOf() - .With.Message.Contains("The path of the ReqIF file cannot be empty.")); - - filePath = this.resultFileUri; - - Assert.That( - async () => await serializer.SerializeAsync(null, filePath, cancellationTokenSource.Token), - Throws.Exception.TypeOf() - .With.Message.Contains("The reqIfs object cannot be null.")); - - Assert.That( - async () => await serializer.SerializeAsync(reqifs, filePath, cancellationTokenSource.Token), - Throws.Exception.TypeOf() - .With.Message.Contains("One and only one ReqIF object can be serialized to a reqif file. If multiple ReqIF objects need to be serialized, please make use of the reqifz format.")); - - filePath = Path.ChangeExtension(filePath, "reqifz"); - - Assert.That( - async () => await serializer.SerializeAsync(reqifs, filePath, cancellationTokenSource.Token), - Throws.Exception.TypeOf() - .With.Message.Contains("At least one ReqIF object must be serialized.")); - - filePath = Path.ChangeExtension(filePath, "xml"); - - Assert.That( - async () => await serializer.SerializeAsync(reqifs, filePath, cancellationTokenSource.Token), - Throws.Exception.TypeOf() - .With.Message.Contains("only .reqif, .reqifz and .zip are supported file extensions.")); - - } - - [Test] - public void Verify_That_ArgumentException_Is_Raised_On_Serialize_to_stream() - { - var serializer = new ReqIFSerializer(); - - Stream stream = null; - - var reqifs = new List(); - - Assert.That( - () => serializer.Serialize(null, stream, SupportedFileExtensionKind.Reqif), - Throws.Exception.TypeOf() - .With.Message.Contains("The reqIfs object cannot be null.")); - - reqifs.Add(this.reqIF); - - Assert.That( - () => serializer.Serialize(reqifs, stream, SupportedFileExtensionKind.Reqif), - Throws.Exception.TypeOf() - .With.Message.Contains("The stream cannot be null.")); - } - - [Test] - public void Verify_That_ArgumentException_Is_Raised_On_Async_Serialize_to_stream() - { - var cancellationTokenSource = new CancellationTokenSource(); - - var serializer = new ReqIFSerializer(); - - var reqifs = new List { this.reqIF }; - - Stream stream = null; - - Assert.That( - async () => await serializer.SerializeAsync(null, stream, SupportedFileExtensionKind.Reqif, cancellationTokenSource.Token), - Throws.Exception.TypeOf() - .With.Message.Contains("The reqIfs object cannot be null.")); - - Assert.That( - async () => await serializer.SerializeAsync(reqifs, stream, SupportedFileExtensionKind.Reqif, cancellationTokenSource.Token), - Throws.Exception.TypeOf() - .With.Message.Contains("The stream cannot be null.")); - } - - [Test] - public void Verify_That_The_ReqIfSerializer_Serializes_a_ReqIf_Document_to_file_Without_Validation() - { - var reqifs = new List { this.reqIF }; - - var serializer = new ReqIFSerializer(); - serializer.Serialize(reqifs, this.resultFileUri); - - Assert.IsTrue(File.Exists(this.resultFileUri)); - } - - [Test] - public async Task Verify_That_The_ReqIfSerializer_Serializes_Async_a_ReqIf_Document_to_file_Without_Validation() - { - var reqifs = new List { this.reqIF }; - - var cancellationTokenSource = new CancellationTokenSource(); - - var serializer = new ReqIFSerializer(); - await serializer.SerializeAsync(reqifs, this.asyncResultFileUri, cancellationTokenSource.Token); - - Assert.IsTrue(File.Exists(this.asyncResultFileUri)); - } - - [Test] - public void Verify_That_The_ReqIfSerializer_Serializes_a_ReqIf_Document_to_stream_Without_Validation() - { - var reqifs = new List { this.reqIF }; - - var stream = new MemoryStream(); - - var serializer = new ReqIFSerializer(); - serializer.Serialize(reqifs, stream, SupportedFileExtensionKind.Reqif); - - Assert.That(stream.Length, Is.Not.Zero); - } - - [Test] - public async Task Verify_That_The_ReqIfSerializer_Async_Serializes_a_ReqIf_Document_to_stream_Without_Validation() - { - var reqifs = new List { this.reqIF }; - - var cancellationTokenSource = new CancellationTokenSource(); - - var stream = new MemoryStream(); - - var serializer = new ReqIFSerializer(); - await serializer.SerializeAsync(reqifs, stream, SupportedFileExtensionKind.Reqif, cancellationTokenSource.Token); - - Assert.That(stream.Length, Is.Not.Zero); - } - - [Test] - public void Verify_that_multiple_ReqIF_objects_can_be_serialized_to_archive_file_based() - { - var reqifs = new List { this.reqIF, this.reqIF }; - - var serializer = new ReqIFSerializer(); - - serializer.Serialize(reqifs, this.resultFileUriArchive); - - Assert.IsTrue(File.Exists(this.resultFileUriArchive)); - } - - [Test] - public async Task Verify_that_multiple_ReqIF_objects_can_be_serialized_to_archive_file_based_Async() - { - var reqifs = new List { this.reqIF, this.reqIF }; - - var cancellationTokenSource = new CancellationTokenSource(); - - var serializer = new ReqIFSerializer(); - - await serializer.SerializeAsync(reqifs, this.asyncResultFileUriArchive, cancellationTokenSource.Token); - - Assert.IsTrue(File.Exists(this.asyncResultFileUriArchive)); - - var deserializer = new ReqIFDeserializer(); - - var deserializedReqifs = await deserializer.DeserializeAsync(this.asyncResultFileUriArchive, cancellationTokenSource.Token); - - Assert.That(deserializedReqifs.Count(), Is.EqualTo(2)); - - } - } -} + var specHierarchy1_1 = new SpecHierarchy(); + specHierarchy1_1.Identifier = "spec-hierarchy-1-1"; + specHierarchy1_1.LastChange = DateTime.Parse("2015-12-01"); + specHierarchy1_1.LongName = "specHierarchy 1_1"; + specHierarchy1_1.Object = object2; + CreateAlternativeId(specHierarchy1_1); + + var specHierarchy1_2 = new SpecHierarchy(); + specHierarchy1_2.Identifier = "spec-hierarchy-1-2"; + specHierarchy1_2.LastChange = DateTime.Parse("2015-12-01"); + specHierarchy1_2.LongName = "specHierarchy 1_2"; + specHierarchy1_2.Object = object3; + CreateAlternativeId(specHierarchy1_2); + + specification1.Children.Add(specHierarchy1); + specHierarchy1.Children.Add(specHierarchy1_1); + specHierarchy1.Children.Add(specHierarchy1_2); + + reqIfContent.Specifications.Add(specification1); + + var specification2 = new Specification(); + specification2.Identifier = "specification-2"; + specification2.LastChange = DateTime.Parse("2015-12-01"); + specification2.LongName = "specification 2"; + specification2.Type = specificationType; + this.CreateValuesForSpecElementWithAttributes(specification2, specificationType); + CreateAlternativeId(specification2); + reqIfContent.Specifications.Add(specification2); + } + + /// + /// Creates a + /// + private void CreateRelationGroup() + { + var reqIfContent = this.reqIF.CoreContent; + + var relationGroupType = (RelationGroupType)reqIfContent.SpecTypes.SingleOrDefault(x => x.GetType() == typeof(RelationGroupType)); + + var relationGroup = new RelationGroup(); + relationGroup.Identifier = "relationgroup-1"; + relationGroup.LastChange = DateTime.Parse("2015-12-01"); + relationGroup.LongName = "relationgroup 1"; + relationGroup.Type = relationGroupType; + CreateAlternativeId(relationGroup); + + var sourceSpecification = reqIfContent.Specifications.SingleOrDefault(x => x.Identifier == "specification-1"); + var targetSpecification = reqIfContent.Specifications.SingleOrDefault(x => x.Identifier == "specification-2"); + + relationGroup.SourceSpecification = sourceSpecification; + relationGroup.TargetSpecification = targetSpecification; + + reqIfContent.SpecRelationGroups.Add(relationGroup); + } + + /// + /// Create For + /// + /// + /// The to which s need to be added. + /// + /// + /// The of the + /// + private void CreateValuesForSpecElementWithAttributes(SpecElementWithAttributes specElementWithAttributes, SpecType specType) + { + var attributeValueBoolean = new AttributeValueBoolean(); + attributeValueBoolean.Definition = (AttributeDefinitionBoolean)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionBoolean)); + attributeValueBoolean.TheValue = true; + specElementWithAttributes.Values.Add(attributeValueBoolean); + + var attributeValueDate = new AttributeValueDate(); + attributeValueDate.Definition = (AttributeDefinitionDate)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionDate)); + attributeValueDate.TheValue = XmlConvert.ToDateTime("2015-12-01", XmlDateTimeSerializationMode.Utc); + specElementWithAttributes.Values.Add(attributeValueDate); + + var attributeValueEnumeration = new AttributeValueEnumeration(); + attributeValueEnumeration.Definition = (AttributeDefinitionEnumeration)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionEnumeration)); + var enumValue = attributeValueEnumeration.Definition.Type.SpecifiedValues.FirstOrDefault(); + attributeValueEnumeration.Values.Add(enumValue); + specElementWithAttributes.Values.Add(attributeValueEnumeration); + + var attributeValueInteger = new AttributeValueInteger(); + attributeValueInteger.Definition = (AttributeDefinitionInteger)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionInteger)); + attributeValueInteger.TheValue = 1; + specElementWithAttributes.Values.Add(attributeValueInteger); + + var attributeValueReal = new AttributeValueReal(); + attributeValueReal.Definition = (AttributeDefinitionReal)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionReal)); + attributeValueReal.TheValue = 100; + specElementWithAttributes.Values.Add(attributeValueReal); + + var attributeValueString = new AttributeValueString(); + attributeValueString.Definition = (AttributeDefinitionString)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionString)); + attributeValueString.TheValue = "a string value"; + specElementWithAttributes.Values.Add(attributeValueString); + + var attributeValueXhtml = new AttributeValueXHTML(); + attributeValueXhtml.Definition = (AttributeDefinitionXHTML)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionXHTML)); + attributeValueXhtml.TheValue = this.xhtmlcontent; + specElementWithAttributes.Values.Add(attributeValueXhtml); + + var simplifiedAttributeValueXhtml = new AttributeValueXHTML(); + simplifiedAttributeValueXhtml.Definition = (AttributeDefinitionXHTML)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionXHTML)); + simplifiedAttributeValueXhtml.IsSimplified = true; + simplifiedAttributeValueXhtml.TheValue = "simplified content"; + simplifiedAttributeValueXhtml.TheOriginalValue= this.xhtmlcontent; + specElementWithAttributes.Values.Add(simplifiedAttributeValueXhtml); + } + + /// + /// Create an for the + /// + /// + /// The for which an needs to be created + /// + private static void CreateAlternativeId(Identifiable identifiable) + { + var alternativeId = new AlternativeId(); + alternativeId.Identifier = identifiable.Identifier + "_alternative"; + + alternativeId.Ident = identifiable; + identifiable.AlternativeId = alternativeId; + } + + [Test] + public void Verify_That_ArgumentException_Is_Raised_OnSerialize_to_file() + { + var serializer = new ReqIFSerializer(); + + string filePath = null; + + var reqifs = new List(); + + Assert.That( + () => serializer.Serialize(reqifs, filePath), + Throws.Exception.TypeOf() + .With.Message.Contains("The path of the ReqIF file cannot be null.")); + + Assert.That( + () => serializer.Serialize(reqifs, string.Empty), + Throws.Exception.TypeOf() + .With.Message.Contains("The path of the ReqIF file cannot be empty.")); + + filePath = this.resultFileUri; + + Assert.That( + () => serializer.Serialize(null, filePath), + Throws.Exception.TypeOf() + .With.Message.Contains("The reqIfs object cannot be null.")); + + Assert.That(() => serializer.Serialize(reqifs, filePath), + Throws.Exception.TypeOf() + .With.Message.Contains("One and only one ReqIF object can be serialized to a reqif file. If multiple ReqIF objects need to be serialized, please make use of the reqifz format.")); + + filePath = this.resultFileUriArchive; + + Assert.That(() => serializer.Serialize(reqifs, filePath), + Throws.Exception.TypeOf() + .With.Message.Contains("At least one ReqIF object must be serialized.")); + + filePath = Path.ChangeExtension(filePath, "xml"); + + Assert.That(() => serializer.Serialize(reqifs, filePath), + Throws.Exception.TypeOf() + .With.Message.Contains("only .reqif, .reqifz and .zip are supported file extensions.")); + } + + [Test] + public void Verify_That_ArgumentException_Is_Raised_OnAsyncSerialize_to_file() + { + var cancellationTokenSource = new CancellationTokenSource(); + + var serializer = new ReqIFSerializer(); + + string filePath = null; + + var reqifs = new List(); + + Assert.That( + async () => await serializer.SerializeAsync(reqifs, filePath, cancellationTokenSource.Token), + Throws.Exception.TypeOf() + .With.Message.Contains("The path of the ReqIF file cannot be null.")); + + Assert.That( + async () => await serializer.SerializeAsync(reqifs, string.Empty, cancellationTokenSource.Token), + Throws.Exception.TypeOf() + .With.Message.Contains("The path of the ReqIF file cannot be empty.")); + + filePath = this.resultFileUri; + + Assert.That( + async () => await serializer.SerializeAsync(null, filePath, cancellationTokenSource.Token), + Throws.Exception.TypeOf() + .With.Message.Contains("The reqIfs object cannot be null.")); + + Assert.That( + async () => await serializer.SerializeAsync(reqifs, filePath, cancellationTokenSource.Token), + Throws.Exception.TypeOf() + .With.Message.Contains("One and only one ReqIF object can be serialized to a reqif file. If multiple ReqIF objects need to be serialized, please make use of the reqifz format.")); + + filePath = Path.ChangeExtension(filePath, "reqifz"); + + Assert.That( + async () => await serializer.SerializeAsync(reqifs, filePath, cancellationTokenSource.Token), + Throws.Exception.TypeOf() + .With.Message.Contains("At least one ReqIF object must be serialized.")); + + filePath = Path.ChangeExtension(filePath, "xml"); + + Assert.That( + async () => await serializer.SerializeAsync(reqifs, filePath, cancellationTokenSource.Token), + Throws.Exception.TypeOf() + .With.Message.Contains("only .reqif, .reqifz and .zip are supported file extensions.")); + + } + + [Test] + public void Verify_That_ArgumentException_Is_Raised_On_Serialize_to_stream() + { + var serializer = new ReqIFSerializer(); + + Stream stream = null; + + var reqifs = new List(); + + Assert.That( + () => serializer.Serialize(null, stream, SupportedFileExtensionKind.Reqif), + Throws.Exception.TypeOf() + .With.Message.Contains("The reqIfs object cannot be null.")); + + reqifs.Add(this.reqIF); + + Assert.That( + () => serializer.Serialize(reqifs, stream, SupportedFileExtensionKind.Reqif), + Throws.Exception.TypeOf() + .With.Message.Contains("The stream cannot be null.")); + } + + [Test] + public void Verify_That_ArgumentException_Is_Raised_On_Async_Serialize_to_stream() + { + var cancellationTokenSource = new CancellationTokenSource(); + + var serializer = new ReqIFSerializer(); + + var reqifs = new List { this.reqIF }; + + Stream stream = null; + + Assert.That( + async () => await serializer.SerializeAsync(null, stream, SupportedFileExtensionKind.Reqif, cancellationTokenSource.Token), + Throws.Exception.TypeOf() + .With.Message.Contains("The reqIfs object cannot be null.")); + + Assert.That( + async () => await serializer.SerializeAsync(reqifs, stream, SupportedFileExtensionKind.Reqif, cancellationTokenSource.Token), + Throws.Exception.TypeOf() + .With.Message.Contains("The stream cannot be null.")); + } + + [Test] + public void Verify_That_The_ReqIfSerializer_Serializes_a_ReqIf_Document_to_file_Without_Validation() + { + var reqifs = new List { this.reqIF }; + + var serializer = new ReqIFSerializer(); + serializer.Serialize(reqifs, this.resultFileUri); + + Assert.That(File.Exists(this.resultFileUri), Is.True); + } + + [Test] + public async Task Verify_That_The_ReqIfSerializer_Serializes_Async_a_ReqIf_Document_to_file_Without_Validation() + { + var reqifs = new List { this.reqIF }; + + var cancellationTokenSource = new CancellationTokenSource(); + + var serializer = new ReqIFSerializer(); + await serializer.SerializeAsync(reqifs, this.asyncResultFileUri, cancellationTokenSource.Token); + + Assert.That(File.Exists(this.asyncResultFileUri), Is.True); + } + + [Test] + public void Verify_That_The_ReqIfSerializer_Serializes_a_ReqIf_Document_to_stream_Without_Validation() + { + var reqifs = new List { this.reqIF }; + + var stream = new MemoryStream(); + + var serializer = new ReqIFSerializer(); + serializer.Serialize(reqifs, stream, SupportedFileExtensionKind.Reqif); + + Assert.That(stream.Length, Is.Not.Zero); + } + + [Test] + public async Task Verify_That_The_ReqIfSerializer_Async_Serializes_a_ReqIf_Document_to_stream_Without_Validation() + { + var reqifs = new List { this.reqIF }; + + var cancellationTokenSource = new CancellationTokenSource(); + + var stream = new MemoryStream(); + + var serializer = new ReqIFSerializer(); + await serializer.SerializeAsync(reqifs, stream, SupportedFileExtensionKind.Reqif, cancellationTokenSource.Token); + + Assert.That(stream.Length, Is.Not.Zero); + } + + [Test] + public void Verify_that_multiple_ReqIF_objects_can_be_serialized_to_archive_file_based() + { + var reqifs = new List { this.reqIF, this.reqIF }; + + var serializer = new ReqIFSerializer(); + + serializer.Serialize(reqifs, this.resultFileUriArchive); + + Assert.That(File.Exists(this.resultFileUriArchive), Is.True); + } + + [Test] + public async Task Verify_that_multiple_ReqIF_objects_can_be_serialized_to_archive_file_based_Async() + { + var reqifs = new List { this.reqIF, this.reqIF }; + + var cancellationTokenSource = new CancellationTokenSource(); + + var serializer = new ReqIFSerializer(); + + await serializer.SerializeAsync(reqifs, this.asyncResultFileUriArchive, cancellationTokenSource.Token); + + Assert.That(File.Exists(this.asyncResultFileUriArchive), Is.True); + + var deserializer = new ReqIFDeserializer(); + + var deserializedReqifs = await deserializer.DeserializeAsync(this.asyncResultFileUriArchive, cancellationTokenSource.Token); + + Assert.That(deserializedReqifs.Count(), Is.EqualTo(2)); + + } + } +} diff --git a/ReqIFSharp.Tests/ReqIFSharp.Tests.csproj b/ReqIFSharp.Tests/ReqIFSharp.Tests.csproj index 4941b93..4ee043f 100644 --- a/ReqIFSharp.Tests/ReqIFSharp.Tests.csproj +++ b/ReqIFSharp.Tests/ReqIFSharp.Tests.csproj @@ -22,16 +22,16 @@ - - - + + + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ReqIFSharp.Tests/ReqIfFactoryTestFixture.cs b/ReqIFSharp.Tests/ReqIfFactoryTestFixture.cs index c6d4530..253a5ce 100644 --- a/ReqIFSharp.Tests/ReqIfFactoryTestFixture.cs +++ b/ReqIFSharp.Tests/ReqIfFactoryTestFixture.cs @@ -49,14 +49,13 @@ public void SetUp() public void Verify_That_XmlElementName_Returns_AttributeDefinition() { var spectType = new SpecObjectType(); - - Assert.IsInstanceOf(ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-BOOLEAN", spectType, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-DATE", spectType, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-ENUMERATION", spectType, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-INTEGER", spectType, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-REAL", spectType, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-STRING", spectType, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-XHTML", spectType, this.loggerFactory)); + Assert.That(() => ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-BOOLEAN", spectType, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-DATE", spectType, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-ENUMERATION", spectType, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-INTEGER", spectType, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-REAL", spectType, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-STRING", spectType, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.AttributeDefinitionConstruct("ATTRIBUTE-DEFINITION-XHTML", spectType, this.loggerFactory), Is.InstanceOf()); } [Test] @@ -65,7 +64,7 @@ public void Verify_That_Unkown_Element_AttributeDefinition_Throws_ArgumentExcept var spectType = new SpecObjectType(); string unknownName = "RHEA"; - Assert.IsNull(ReqIfFactory.AttributeDefinitionConstruct(unknownName, spectType, this.loggerFactory)); + Assert.That(ReqIfFactory.AttributeDefinitionConstruct(unknownName, spectType, this.loggerFactory), Is.Null); } [Test] @@ -73,17 +72,16 @@ public void Verify_That_XmlElementName_Returns_DataTypeDefinition() { var reqIfContent = new ReqIFContent(); - Assert.IsInstanceOf(ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-BOOLEAN", reqIfContent, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-DATE", reqIfContent, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-ENUMERATION", reqIfContent, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-INTEGER", reqIfContent, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-REAL", reqIfContent, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-STRING", reqIfContent, this.loggerFactory)); - Assert.IsInstanceOf(ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-XHTML", reqIfContent, this.loggerFactory)); + Assert.That(() => ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-BOOLEAN", reqIfContent, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-DATE", reqIfContent, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-ENUMERATION", reqIfContent, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-INTEGER", reqIfContent, this.loggerFactory), Is.InstanceOf()); Assert.That(() => ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-REAL", reqIfContent, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-STRING", reqIfContent, this.loggerFactory), Is.InstanceOf()); + Assert.That(() => ReqIfFactory.DatatypeDefinitionConstruct("DATATYPE-DEFINITION-XHTML", reqIfContent, this.loggerFactory), Is.InstanceOf()); } [Test] - public void Verify_That_Unkown_Element_DataTypeDefinition_Throws_ArgumentException() + public void Verify_That_Unknown_Element_DataTypeDefinition_Throws_ArgumentException() { var reqIfContent = new ReqIFContent(); diff --git a/ReqIFSharp.Tests/SpecElementWithAttributesTests/RelationGroupTestFixture.cs b/ReqIFSharp.Tests/SpecElementWithAttributesTests/RelationGroupTestFixture.cs index ab1b928..be681ff 100644 --- a/ReqIFSharp.Tests/SpecElementWithAttributesTests/RelationGroupTestFixture.cs +++ b/ReqIFSharp.Tests/SpecElementWithAttributesTests/RelationGroupTestFixture.cs @@ -134,7 +134,7 @@ public void Verify_That_The_SpectType_Can_Be_Set() relationGroup.SpecType = relationGroupType; - Assert.AreEqual(relationGroupType, relationGroup.SpecType); + Assert.That(relationGroup.SpecType, Is.EqualTo(relationGroupType)); } [Test] diff --git a/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecObjectTestFixture.cs b/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecObjectTestFixture.cs index ace6b2a..5c06390 100644 --- a/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecObjectTestFixture.cs +++ b/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecObjectTestFixture.cs @@ -54,13 +54,13 @@ public void VerifyThatTheSpecTypeCanBeSetOrGet() var specElementWithAttributes = (SpecElementWithAttributes)spectObject; - Assert.AreEqual(specObjectType, specElementWithAttributes.SpecType); + Assert.That(specElementWithAttributes.SpecType, Is.EqualTo(specObjectType)); var otherSpecObjectType = new SpecObjectType(); specElementWithAttributes.SpecType = otherSpecObjectType; - Assert.AreEqual(otherSpecObjectType, spectObject.SpecType); + Assert.That(spectObject.SpecType, Is.EqualTo(otherSpecObjectType)); } [Test] diff --git a/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecRelationTestFixture.cs b/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecRelationTestFixture.cs index abe8bbc..fbdf430 100644 --- a/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecRelationTestFixture.cs +++ b/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecRelationTestFixture.cs @@ -53,13 +53,13 @@ public void VerifyThatTheSpecTypeCanBeSetOrGet() var specElementWithAttributes = (SpecElementWithAttributes)specRelation; - Assert.AreEqual(specRelationType, specElementWithAttributes.SpecType); + Assert.That(specElementWithAttributes.SpecType, Is.EqualTo(specRelationType)); var relationType = new SpecRelationType(); specElementWithAttributes.SpecType = relationType; - Assert.AreEqual(relationType, specRelation.SpecType); + Assert.That(specRelation.SpecType, Is.EqualTo(relationType)); } [Test] diff --git a/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecificationTestFixture.cs b/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecificationTestFixture.cs index 24c6726..e589cb4 100644 --- a/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecificationTestFixture.cs +++ b/ReqIFSharp.Tests/SpecElementWithAttributesTests/SpecificationTestFixture.cs @@ -54,13 +54,13 @@ public void VerifyThatTheSpecTypeCanBeSetOrGet() var specElementWithAttributes = (SpecElementWithAttributes)specification; - Assert.AreEqual(specificationType, specElementWithAttributes.SpecType); + Assert.That(specElementWithAttributes.SpecType, Is.EqualTo(specificationType)); var otherspecificationType = new SpecificationType(); specElementWithAttributes.SpecType = otherspecificationType; - Assert.AreEqual(otherspecificationType, specification.SpecType); + Assert.That(specification.SpecType, Is.EqualTo(otherspecificationType)); } [Test] diff --git a/ReqIFSharp.sln.DotSettings b/ReqIFSharp.sln.DotSettings index f835d06..766b4e7 100644 --- a/ReqIFSharp.sln.DotSettings +++ b/ReqIFSharp.sln.DotSettings @@ -1,6 +1,6 @@  ------------------------------------------------------------------------------------------------- - <copyright file="$FILENAME$" company="RHEA System S.A."> + <copyright file="${File.FileName}" company="RHEA System S.A."> Copyright 2017-2022 RHEA System S.A. @@ -20,4 +20,5 @@ ------------------------------------------------------------------------------------------------- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + True True \ No newline at end of file diff --git a/ReqIFSharp/ReqIFSharp.csproj b/ReqIFSharp/ReqIFSharp.csproj index 43de59c..919da26 100644 --- a/ReqIFSharp/ReqIFSharp.csproj +++ b/ReqIFSharp/ReqIFSharp.csproj @@ -89,7 +89,7 @@ - + \ No newline at end of file