Skip to content

Commit

Permalink
stricter test suite for server content type.
Browse files Browse the repository at this point in the history
See buildingSMART/IDS#250.

Also improved documentation slightly, and removed nullability
warnings on generators.
  • Loading branch information
CBenghi committed Apr 22, 2024
1 parent 4cc55cb commit 27af440
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IfcDataTypeInformation class

Metadata container for entities containing measures of an IfcSchema
Metadata container for entities containing measures of an IfcSchema. Access the list from [`AllDataTypes`](./SchemaInfo/AllDataTypes.md).

```csharp
public class IfcDataTypeInformation
Expand Down
2 changes: 1 addition & 1 deletion ids-lib-documentation/ids-lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
| enum [FunctionalType](./IdsLib.IfcSchema/FunctionalType.md) | the IFC classes we present can be classified with regards to their potential role in the IfcRelDefinesByType relation. |
| class [IfcAttributeInformation](./IdsLib.IfcSchema/IfcAttributeInformation.md) | Metadata container for attributes of entities in IfcSchema |
| class [IfcClassInformation](./IdsLib.IfcSchema/IfcClassInformation.md) | Simplistic metadata container for entities of an IfcSchema |
| class [IfcDataTypeInformation](./IdsLib.IfcSchema/IfcDataTypeInformation.md) | Metadata container for entities containing measures of an IfcSchema |
| class [IfcDataTypeInformation](./IdsLib.IfcSchema/IfcDataTypeInformation.md) | Metadata container for entities containing measures of an IfcSchema. Access the list from [`AllDataTypes`](./IdsLib.IfcSchema/SchemaInfo/AllDataTypes.md). |
| struct [IfcMeasureInformation](./IdsLib.IfcSchema/IfcMeasureInformation.md) | Metadata about measure conversion behaviours. |
| class [IfcSchemaAttribute](./IdsLib.IfcSchema/IfcSchemaAttribute.md) | Metadata attribute to define if a value of [`IfcSchemaVersions`](./IdsLib.IfcSchema/IfcSchemaVersions.md) identifies a single version of the schema |
| [Flags] enum [IfcSchemaVersions](./IdsLib.IfcSchema/IfcSchemaVersions.md) | Enumerations for the identification of multiple schema versions. |
Expand Down
10 changes: 6 additions & 4 deletions ids-lib.codegen/IfcSchema_PropertiesGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class IfcSchema_PropertiesGenerator
{
private class propSetTempInfo
{
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
public IEnumerable<string>? ApplicableClasses { get; set; }
public IEnumerable<string>? CsSourceOfProperties { get; set; }

Expand All @@ -36,6 +36,8 @@ public static string Execute()
propsets = GetPsets(f).OrderBy(x => x.Name).ToArray();
foreach (var item in propsets)
{
if (item.ApplicableClasses is null)
continue;
var cArr = NewStringArray(item.ApplicableClasses);
if (item.CsSourceOfProperties is null)
continue;
Expand All @@ -54,8 +56,8 @@ private static IEnumerable<propSetTempInfo> GetPsets(FileInfo f)
var psets = store.Instances.OfType<Xbim.Ifc4x3.Kernel.IfcPropertySetTemplate>();
foreach (var pset in psets)
{
propSetTempInfo ret = new propSetTempInfo() { Name = pset.Name };
var tmpClasses = pset.ApplicableEntity.Value.Value.ToString().Split(",");
propSetTempInfo ret = new propSetTempInfo() { Name = pset.Name ?? "" };
var tmpClasses = (pset.ApplicableEntity!.Value.Value.ToString() ?? "").Split(",");
ret.ApplicableClasses = tmpClasses.Select(x => RemovePredefinedType(x));
var props = new List<string>();
foreach (var proptemp in pset.HasPropertyTemplates.OrderBy(x=>x.Name.ToString()))
Expand Down Expand Up @@ -90,7 +92,7 @@ private static IEnumerable<propSetTempInfo> GetPsets(FileInfo f)
props.Add($"new SingleValuePropertyType(\"{singleV.Name}\", \"IfcTimeMeasure\"){def}");
break;
case IfcSimplePropertyTemplateTypeEnum.P_ENUMERATEDVALUE:
props.Add($"new EnumerationPropertyType(\"{singleV.Name}\", {NewStringArray(singleV.Enumerators.EnumerationValues.Select(x => x.Value.ToString()))} ){def}");
props.Add($"new EnumerationPropertyType(\"{singleV.Name}\", {NewStringArray(singleV.Enumerators.EnumerationValues.Select(x => x.Value.ToString() ?? ""))} ){def}");
break;
case IfcSimplePropertyTemplateTypeEnum.P_SINGLEVALUE:
case IfcSimplePropertyTemplateTypeEnum.P_REFERENCEVALUE:
Expand Down
4 changes: 2 additions & 2 deletions ids-lib/IdsSchema/IdsNodes/IdsSpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ internal protected override Audit.Status PerformAudit(AuditStateInformation stat
var totalFilters = IfcTypeConstraint.Intersect(aF, rF);
if (IfcTypeConstraint.IsNotNullAndEmpty(totalFilters))
{
var appDesc = aF.ConcreteTypes.Count() > 5
var appDesc = aF!.ConcreteTypes.Count() > 5
? $"{aF.ConcreteTypes.Count()} types"
: $"{string.Join(", ", aF.ConcreteTypes)}";
var reqDesc = rF.ConcreteTypes.Count() > 5
var reqDesc = rF!.ConcreteTypes.Count() > 5
? $"{rF.ConcreteTypes.Count()} types"
: $"{string.Join(", ", rF.ConcreteTypes)}";
ret |= IdsErrorMessages.Report201IncompatibleClauses(logger, this, schemaInfo, $"impossible match of types between applicability ({appDesc}) and requirements ({reqDesc})");
Expand Down
3 changes: 2 additions & 1 deletion ids-lib/IfcSchema/IfcDataTypeInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
namespace IdsLib.IfcSchema;

/// <summary>
/// Metadata container for entities containing measures of an IfcSchema
/// Metadata container for entities containing measures of an IfcSchema.
/// Access the list from <see cref="SchemaInfo.AllDataTypes"/>.
/// </summary>
[DebuggerDisplay("{IfcDataTypeClassName} ({ValidSchemaVersions})")]
public class IfcDataTypeInformation
Expand Down
2 changes: 1 addition & 1 deletion ids-lib/LibraryInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ public static class LibraryInformation
/// <summary>
/// Static field with hardcoded DLL version number.
/// </summary>
public static string AssemblyVersion => "1.0.70";
public static string AssemblyVersion => "1.0.71";
}
2 changes: 1 addition & 1 deletion ids-lib/ids-lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReleaseNotes>First implementation.</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<!-- Github actions are setup so that when this version is bumped the nuget package is uploaded -->
<AssemblyVersion>1.0.70</AssemblyVersion>
<AssemblyVersion>1.0.71</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<Version>$(AssemblyVersion)</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
10 changes: 5 additions & 5 deletions ids-tool.tests/IdsSchemaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void XsdTestSuiteSchemaIsAlignedWithIdsRepository()
schemasAreIdentical.Should().BeTrue("testing schema and repository schema should be identical");
}

[SkippableTheory]
[Theory]
[InlineData("http://standards.buildingsmart.org/IDS/0.9.6/ids.xsd")]
[InlineData("http://standards.buildingsmart.org/IDS/0.9.7/ids.xsd")]
[InlineData("https://www.w3.org/2001/03/xml.xsd")]
Expand All @@ -100,10 +100,10 @@ public async void BuildingSmartWebServerShouldReturnSchemaCorrectly(string url)

var c = new HttpClient();
var t = await c.GetAsync(url);

var tp = t.Content.Headers.ContentType;
Skip.If(tp is null, "contentype is null");
Skip.If(!acceptable.Contains(tp.ToString()), $"contentype is `{tp}` is not in the acceptable range.");
Assert.NotNull(t.Content.Headers.ContentType);
var receivedContentType = t.Content.Headers.ContentType.MediaType;
receivedContentType.Should().NotBeNull();
receivedContentType.Should().BeOneOf(acceptable);
}
}
}
8 changes: 8 additions & 0 deletions ids-tool.tests/TestingSuiteSelfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ namespace idsTool.tests
/// </summary>
public class TestingSuiteSelfTests
{
[Fact]
public void BackingTypesVariabilityTest()
{
var types = IdsLib.IfcSchema.SchemaInfo.AllDataTypes.Select(x=>x.BackingType).Distinct().ToList();
var nullBacking = IdsLib.IfcSchema.SchemaInfo.AllDataTypes.Where(x => x.BackingType is null).ToList();
types.Count.Should().Be(9);
}

[Fact]
public void IdsRepositoryFileMethodsAreCoherent()
{
Expand Down
2 changes: 1 addition & 1 deletion ids-tool/ids-tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageIcon>icon.png</PackageIcon>
<PackageTags>IDS, buildingSmart</PackageTags>
<!-- Github actions are setup so that when this version is bumped the nuget package is uploaded -->
<AssemblyVersion>1.0.70</AssemblyVersion>
<AssemblyVersion>1.0.71</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<Version>$(AssemblyVersion)</Version>
<RepositoryUrl>https://github.com/buildingSMART/IDS-Audit-tool.git</RepositoryUrl>
Expand Down

0 comments on commit 27af440

Please sign in to comment.