Skip to content

Commit

Permalink
Fixes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
CBenghi committed Mar 6, 2024
1 parent f967e1a commit 5e0ecd0
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FluentAssertions;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -95,12 +94,11 @@ public static FileInfo GetIdsSchema()
return new FileInfo(schema);
}

internal static FileInfo GetDocumentationTestCaseFileInfo(string idsFile)
public static FileInfo GetDocumentationTestCaseFileInfo(string idsFile)
{
var d = new DirectoryInfo(IdsRepositoryTestcasesPath);
var comb = d.FullName + idsFile;
var f = new FileInfo(comb);
f.Exists.Should().BeTrue("test file must be found");
return f;
}

Expand All @@ -125,12 +123,11 @@ private static IEnumerable<object[]> GetIdsOrEmpty(DirectoryInfo d)
}
}

internal static FileInfo GetIdsRepositoryDevelopmentFileInfo(string idsFile)
public static FileInfo GetIdsRepositoryDevelopmentFileInfo(string idsFile)
{
var d = new DirectoryInfo(IdsRepositoryDevelopmentPath);
var comb = d.FullName + idsFile;
var f = new FileInfo(comb);
f.Exists.Should().BeTrue("test file must be found");
return f;
}

Expand Down
9 changes: 9 additions & 0 deletions SolutionTooling/SolutionTooling.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions ids-lib.codegen/IfcSchema_ObjectToTypeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static string Execute()
Debug.WriteLine(item);
}
var source = stub;
var genSchemas = new[] { IfcSchema.SchemaInfo.SchemaIfc4, IfcSchema.SchemaInfo.SchemaIfc4x3 };
var genSchemas = new[] { "Ifc4", "Ifc4x3" };
var sourceSchemas = new[] { "IFC4", "IFC4X3_ADD1" };

for (int i = 0; i < genSchemas.Length; i++)
Expand All @@ -78,7 +78,7 @@ public static string Execute()
{
sb.AppendLine($"\t\tschema.AddRelationType(\"{pair.ObjectName}\", \"{pair.TypeName}\");");
}
var replace = $"<PlaceHolder{schema.Version}>\r\n";
var replace = $"<PlaceHolder{schema}>\r\n";
source = source.Replace(replace, sb.ToString());

}
Expand Down
1 change: 0 additions & 1 deletion ids-lib.codegen/IfcSchema_PartOfRelationGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Text;
using Xbim.Common.Metadata;
using static NSubstitute.Arg;

namespace IdsLib.codegen;

Expand Down
2 changes: 1 addition & 1 deletion ids-lib.codegen/ids-lib.codegen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="XmlDocMarkdown.Core" Version="2.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ids-tool.tests\ids-tool.tests.csproj" />
<ProjectReference Include="..\SolutionTooling\SolutionTooling.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="buildingSMART\IFC_TYPES_MAPPING_BPS.csv">
Expand Down
6 changes: 6 additions & 0 deletions ids-tool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ids-lib", "ids-lib\ids-lib.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ids-lib.codegen", "ids-lib.codegen\ids-lib.codegen.csproj", "{B4BF756F-4399-480C-A475-CF60D587AD02}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SolutionTooling", "SolutionTooling\SolutionTooling.csproj", "{6D103999-3F44-4586-A2AB-157098773FC4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -41,6 +43,10 @@ Global
{B4BF756F-4399-480C-A475-CF60D587AD02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4BF756F-4399-480C-A475-CF60D587AD02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4BF756F-4399-480C-A475-CF60D587AD02}.Release|Any CPU.Build.0 = Release|Any CPU
{6D103999-3F44-4586-A2AB-157098773FC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D103999-3F44-4586-A2AB-157098773FC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D103999-3F44-4586-A2AB-157098773FC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D103999-3F44-4586-A2AB-157098773FC4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 4 additions & 4 deletions ids-tool.tests/AuditTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public AuditTests(ITestOutputHelper outputHelper)
public void FullAuditOfDevelopmentFilesOk(string developmentIdsFile)
{
Skip.If(developmentIdsFile == string.Empty, "IDS repository folder not available for extra tests.");
FileInfo f = GetIdsRepositoryDevelopmentFileInfo(developmentIdsFile);
FileInfo f = LoggerAndAuditHelpers.GetAndCheckIdsRepositoryDevelopmentFileInfo(developmentIdsFile);
LoggerAndAuditHelpers.FullAudit(f, XunitOutputHelper, Audit.Status.Ok, 0);
}

Expand All @@ -40,7 +40,7 @@ public void FullAuditOfDevelopmentFilesWithItsSchemaOk(string developmentIdsFile
var repoSchema = BuildingSmartRepoFiles.GetIdsSchema();
Skip.IfNot(repoSchema.Exists, "IDS repository folder not available for extra tests.");
Skip.If(developmentIdsFile == string.Empty, "IDS repository folder not available for extra tests.");
FileInfo f = GetIdsRepositoryDevelopmentFileInfo(developmentIdsFile);
FileInfo f = LoggerAndAuditHelpers.GetAndCheckIdsRepositoryDevelopmentFileInfo(developmentIdsFile);

BatchOpts opt = new BatchOpts() {
InputSource = f.FullName
Expand All @@ -57,7 +57,7 @@ public void OmitContentAuditOfDocumentationFilesOk(string developmentIdsFile)
// should the exception be prevented by the schema validation?
//
Skip.If(developmentIdsFile == string.Empty, "IDS repository folder not available for extra tests.");
FileInfo f = GetDocumentationTestCaseFileInfo(developmentIdsFile);
FileInfo f = LoggerAndAuditHelpers.GetAndCheckDocumentationTestCaseFileInfo(developmentIdsFile);
var c = new BatchAuditOptions()
{
InputSource = f.FullName,
Expand All @@ -80,7 +80,7 @@ public void OmitContentAuditOfDocumentationFilesOk(string developmentIdsFile)
public void AuditOfDocumentationPassFilesOk(string developmentIdsFile)
{
Skip.If(developmentIdsFile == string.Empty, "IDS repository folder not available for extra tests.");
FileInfo f = GetDocumentationTestCaseFileInfo(developmentIdsFile);
FileInfo f = LoggerAndAuditHelpers.GetAndCheckDocumentationTestCaseFileInfo(developmentIdsFile);
var c = new BatchAuditOptions()
{
InputSource = f.FullName,
Expand Down
18 changes: 17 additions & 1 deletion ids-tool.tests/Helpers/LoggerAndAuditHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,23 @@ namespace idsTool.tests.Helpers;

internal static class LoggerAndAuditHelpers
{
internal static Audit.Status AuditWithoutExpectations(BatchAuditOptions c, ITestOutputHelper OutputHelper)
public static FileInfo GetAndCheckIdsRepositoryDevelopmentFileInfo(string idsFile)
{
FileInfo f = BuildingSmartRepoFiles.GetIdsRepositoryDevelopmentFileInfo(idsFile);
f.Exists.Should().BeTrue("test file must be found");
return f;
}
public static FileInfo GetAndCheckDocumentationTestCaseFileInfo(string idsFile)
{
FileInfo f = BuildingSmartRepoFiles.GetDocumentationTestCaseFileInfo(idsFile);
f.Exists.Should().BeTrue("test file must be found");
return f;
}




internal static Audit.Status AuditWithoutExpectations(BatchAuditOptions c, ITestOutputHelper OutputHelper)
{
return BatchAuditWithOptions(c, OutputHelper, null, -1);
}
Expand Down
4 changes: 2 additions & 2 deletions ids-tool.tests/IdsInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task InvalidFilesDontBreak(string idsFile, bool isIds)
public async Task CanReadIdsDevelopmentFiles(string idsFile)
{
Skip.If(idsFile == string.Empty, "IDS repository folder not available for extra tests.");
FileInfo f = GetIdsRepositoryDevelopmentFileInfo(idsFile);
FileInfo f = LoggerAndAuditHelpers.GetAndCheckIdsRepositoryDevelopmentFileInfo(idsFile);
var t = await IdsXmlHelpers.GetIdsInformationAsync(f);
t.Should().NotBeNull();
t.Version.Should().NotBe(IdsVersion.Invalid);
Expand All @@ -41,7 +41,7 @@ public async Task CanReadIdsDevelopmentFiles(string idsFile)
public async Task CanReadIdsTestCases(string idsFile)
{
Skip.If(idsFile == string.Empty, "IDS repository folder not available for extra tests.");
FileInfo f = GetDocumentationTestCaseFileInfo(idsFile);
FileInfo f = LoggerAndAuditHelpers.GetAndCheckDocumentationTestCaseFileInfo(idsFile);
var idsInformation = await IdsXmlHelpers.GetIdsInformationAsync(f);
idsInformation.Should().NotBeNull();
var schemaVersion = idsInformation.Version;
Expand Down
2 changes: 1 addition & 1 deletion ids-tool.tests/SchemaLoadingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public SchemaLoadingTests(ITestOutputHelper outputHelper)
public void CanLoadEmbeddedResourceSchema(string idsFile)
{
Skip.If(idsFile == string.Empty, "IDS repository folder not available for extra tests.");
FileInfo f = GetIdsRepositoryDevelopmentFileInfo(idsFile);
FileInfo f = LoggerAndAuditHelpers.GetAndCheckIdsRepositoryDevelopmentFileInfo(idsFile);
var c = new BatchAuditOptions()
{
InputSource = f.FullName,
Expand Down
3 changes: 1 addition & 2 deletions ids-tool.tests/TestingSuiteSelfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public void IdsRepositoryFileMethodsAreCoherent()
var str = Frststr as string;
if (str == "") // repository not found
continue;
var f = BuildingSmartRepoFiles.GetDocumentationTestCaseFileInfo(str!);
f.Should().NotBeNull();
var f = LoggerAndAuditHelpers.GetAndCheckDocumentationTestCaseFileInfo(str!);
f.Exists.Should().BeTrue($"{str} is returned from the automation code");
}
}
Expand Down
1 change: 1 addition & 0 deletions ids-tool.tests/ids-tool.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<ItemGroup>
<ProjectReference Include="..\ids-lib\ids-lib.csproj" />
<ProjectReference Include="..\ids-tool\ids-tool.csproj" />
<ProjectReference Include="..\SolutionTooling\SolutionTooling.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 5e0ecd0

Please sign in to comment.