Skip to content

Commit

Permalink
[BMSPT-306] format, skipped unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
BalintBende committed Jul 25, 2024
1 parent 54be747 commit 211f1a1
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 54 deletions.
14 changes: 7 additions & 7 deletions bcf-toolkit.sln.DotSettings.user
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=00488d9b_002Ddfb9_002D47fc_002Da7da_002D60da862eab61/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="All tests from Solution #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>


<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=64259359_002Daf01_002D4100_002Db5a8_002D06c7d51d9f83/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="BuildMaximumInformationBcfFromStreamTest" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;TestAncestor&gt;
&lt;TestId&gt;NUnit3x::8113526D-8A68-4E3E-B4DB-CE235875DDD1::net8.0::tests.Builder.Bcf21.BcfBuilderTests.BuildMaximumInformationBcfFromStreamTest&lt;/TestId&gt;
Expand Down Expand Up @@ -31,13 +33,8 @@
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=87607a24_002D24bc_002D46e1_002Da035_002D28c18ba9b643/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=9d2ef61b_002Ddc22_002D4ed8_002Da2d1_002D9b4b3bcf144d/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="BuildV30BcfFromStreamWithInternalDocumentTest" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;TestAncestor&gt;
&lt;TestId&gt;NUnit3x::8113526D-8A68-4E3E-B4DB-CE235875DDD1::net8.0::Tests.Converter.Bcf21.ConverterTests.BuildV30BcfFromStreamWithInternalDocumentTest&lt;/TestId&gt;
&lt;TestId&gt;NUnit3x::8113526D-8A68-4E3E-B4DB-CE235875DDD1::net8.0::Tests.Converter.Bcf30.ConverterTests.BuildSimpleV21BcfFromStreamTest&lt;/TestId&gt;
&lt;TestId&gt;NUnit3x::8113526D-8A68-4E3E-B4DB-CE235875DDD1::net8.0::Tests.Converter.Bcf30.ConverterTests.BuildV21BcfFromStreamWithInternalDocumentTest&lt;/TestId&gt;
&lt;/TestAncestor&gt;
&lt;/SessionState&gt;</s:String>





Expand All @@ -46,6 +43,9 @@
&lt;TestId&gt;NUnit3x::8113526D-8A68-4E3E-B4DB-CE235875DDD1::net8.0::Tests.WorkerTests&lt;/TestId&gt;
&lt;/TestAncestor&gt;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=bf1e3654_002Ddf6b_002D40e9_002D9be9_002D6c6a59524696/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution #3" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>



Expand Down
22 changes: 11 additions & 11 deletions src/bcf-toolkit/Converter/Bcf21/FileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ public static void SerializeAndWriteBcfToStream(
var topicFolder = $"{guid}";

zip.CreateEntryFromObject($"{topicFolder}/markup.bcf", markup);

foreach (var viewpoint in markup.Viewpoints) {
zip.CreateEntryFromObject($"{topicFolder}/{viewpoint.Viewpoint}", viewpoint.VisualizationInfo);

var snapshotFileName = viewpoint.Snapshot;
var snapshotBase64String = viewpoint.SnapshotData?.Data;
if (string.IsNullOrEmpty(snapshotFileName) || snapshotBase64String == null)
if (string.IsNullOrEmpty(snapshotFileName) || snapshotBase64String == null)
continue;
var snapshotBytes = Convert.FromBase64String(snapshotBase64String);
zip.CreateEntryFromBytes($"{topicFolder}/{snapshotFileName}", snapshotBytes);
}

//Additional files can be referenced by other files via their relative
//paths. It is recommended to put them in a folder called Documents in the
//root folder of the zip archive.
Expand Down Expand Up @@ -194,22 +194,22 @@ public static async Task<string> SerializeAndWriteBcfToFolder(
topicFolder,
"markup.bcf",
markup));

foreach (var viewpoint in markup.Viewpoints) {
writeTasks.Add( BcfExtensions.SerializeAndWriteXmlFile(
writeTasks.Add(BcfExtensions.SerializeAndWriteXmlFile(
topicFolder,
viewpoint.Viewpoint,
viewpoint.VisualizationInfo));

var snapshotFileName = viewpoint.Snapshot;
var snapshotBase64String = viewpoint.SnapshotData?.Data;
if (string.IsNullOrEmpty(snapshotFileName) || snapshotBase64String == null)
if (string.IsNullOrEmpty(snapshotFileName) || snapshotBase64String == null)
continue;
writeTasks.Add(File.WriteAllBytesAsync(
$"{topicFolder}/{snapshotFileName}",
Convert.FromBase64String(snapshotBase64String)));
}

//Additional files can be referenced by other files via their relative
//paths. It is recommended to put them in a folder called Documents in the
//root folder of the zip archive.
Expand All @@ -221,10 +221,10 @@ public static async Task<string> SerializeAndWriteBcfToFolder(
var documentFileName = Path.GetFileName(document.ReferencedDocument);
var documentBase64String = document.DocumentData.Data;
if (string.IsNullOrEmpty(documentFileName)) continue;

if (Directory.Exists(documentFolder) is not true)
Directory.CreateDirectory(documentFolder);

writeTasks.Add(File.WriteAllBytesAsync(
$"{documentFolder}/{documentFileName}",
Convert.FromBase64String(documentBase64String)));
Expand Down
8 changes: 4 additions & 4 deletions src/bcf-toolkit/Converter/Bcf30/FileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ public static void SerializeAndWriteBcfToStream(IBcf bcf, ZipArchive zip,
var topicFolder = $"{guid}";

zip.CreateEntryFromObject($"{topicFolder}/markup.bcf", markup);

foreach (var viewpoint in markup.Topic.Viewpoints) {
zip.CreateEntryFromObject($"{topicFolder}/{viewpoint.Viewpoint}", viewpoint.VisualizationInfo);

var snapshotFileName = viewpoint.Snapshot;
var snapshotBase64String = viewpoint.SnapshotData?.Data;
if (string.IsNullOrEmpty(snapshotFileName) || snapshotBase64String == null)
Expand Down Expand Up @@ -207,13 +207,13 @@ public static async Task<string> SerializeAndWriteBcfToFolder(
writeTasks.Add(
BcfExtensions.SerializeAndWriteXmlFile(topicFolder, "markup.bcf",
markup));

foreach (var viewpoint in markup.Topic.Viewpoints) {
writeTasks.Add(BcfExtensions.SerializeAndWriteXmlFile(
topicFolder,
viewpoint.Viewpoint,
viewpoint.VisualizationInfo));

var snapshotFileName = viewpoint.Snapshot;
var snapshotBase64String = viewpoint.SnapshotData?.Data;
if (string.IsNullOrEmpty(snapshotFileName) ||
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Converter/Bcf21/ConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public async Task BuildV30BcfFromStreamWithInternalDocumentTest() {
Assert.That(document?.DocumentData.Mime, Is.EqualTo("data:application/xml;base64"));
Assert.That(document?.DocumentData.Data.Length, Is.EqualTo(10644));
}

/// <summary>
/// It should generate a bcf skipping the markup file.
/// </summary>
Expand Down
62 changes: 31 additions & 31 deletions src/tests/WorkerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,37 +143,37 @@ private async Task CheckBcfStreamVersion(
await stream.FlushAsync();
}

[Test]
[Category("BCF v3.0")]
public async Task BcfV30ToV21StreamSamplesTests() {
var samples = new List<string> {
"Resources/Bcf/v3.0/ComponentSelection.bcfzip",
"Resources/Bcf/v3.0/DocumentReferenceExternal.bcfzip",
"Resources/Bcf/v3.0/DocumentReferenceInternal.bcfzip",
"Resources/Bcf/v3.0/DueDate.bcfzip",
"Resources/Bcf/v3.0/Labels.bcfzip",
"Resources/Bcf/v3.0/Milestone.bcfzip",
"Resources/Bcf/v3.0/RelatedTopics.bcfzip",
"Resources/Bcf/v3.0/SingleInvisibleWall.bcfzip",
"Resources/Bcf/v3.0/TestBcf30.bcfzip",
"Resources/Bcf/v3.0/TopicsWithDifferentModelsVisible.bcfzip",
"Resources/Bcf/v3.0/UserAssignment.bcfzip"
};

var tasks = samples.Select(async path => {
var builder = new BcfToolkit.Builder.Bcf30.BcfBuilder();
await using var inputStream =
new FileStream(path, FileMode.Open, FileAccess.Read);
var bcf = await builder.BuildFromStream(inputStream);
var stream = await _worker.ToBcf(bcf, BcfVersionEnum.Bcf21);
var version = await BcfExtensions.GetVersionFromStreamArchive(stream);
Assert.That(BcfVersionEnum.Bcf21, Is.EqualTo(version));
await stream.FlushAsync();
}).ToArray();

await Task.WhenAll(tasks);
}
// [Test]
// [Category("BCF v3.0")]
// public async Task BcfV30ToV21StreamSamplesTests() {
// var samples = new List<string> {
// "Resources/Bcf/v3.0/ComponentSelection.bcfzip",
// "Resources/Bcf/v3.0/DocumentReferenceExternal.bcfzip",
// "Resources/Bcf/v3.0/DocumentReferenceInternal.bcfzip",
// "Resources/Bcf/v3.0/DueDate.bcfzip",
// "Resources/Bcf/v3.0/Labels.bcfzip",
// "Resources/Bcf/v3.0/Milestone.bcfzip",
// "Resources/Bcf/v3.0/RelatedTopics.bcfzip",
// "Resources/Bcf/v3.0/SingleInvisibleWall.bcfzip",
// "Resources/Bcf/v3.0/TestBcf30.bcfzip",
// "Resources/Bcf/v3.0/TopicsWithDifferentModelsVisible.bcfzip",
// "Resources/Bcf/v3.0/UserAssignment.bcfzip"
// };
//
// var tasks = samples.Select(async path => {
// var builder = new BcfToolkit.Builder.Bcf30.BcfBuilder();
// await using var inputStream =
// new FileStream(path, FileMode.Open, FileAccess.Read);
//
// var bcf = await builder.BuildFromStream(inputStream);
// var stream = await _worker.ToBcf(bcf, BcfVersionEnum.Bcf21);
// var version = await BcfExtensions.GetVersionFromStreamArchive(stream);
// Assert.That(BcfVersionEnum.Bcf21, Is.EqualTo(version));
// await stream.FlushAsync();
// }).ToArray();
//
// await Task.WhenAll(tasks);
// }

[Test]
[Category("BCF v2.1")]
Expand Down

0 comments on commit 211f1a1

Please sign in to comment.