Skip to content

Commit 66d01b9

Browse files
[Add] serializer test fixture and some implementation notes
1 parent 1c91d54 commit 66d01b9

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

SysML2.NET.Serializer.Xmi.Tests/SerializerTestFixture.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,21 @@ namespace SysML2.NET.Serializer.Xmi.Tests
2424
using System.IO;
2525
using System.Threading;
2626
using System.Threading.Tasks;
27-
27+
using Core.POCO.Root.Namespaces;
2828
using Microsoft.Extensions.DependencyInjection;
2929
using Microsoft.Extensions.Logging;
3030

3131
using SysML2.NET.Serializer.Xmi.Extensions;
3232
using SysML2.NET.Serializer.Xmi.Readers;
33-
33+
3434
[TestFixture]
3535
public class SerializerTestFixture
3636
{
3737
private Serializer serializer;
38+
private DeSerializer deSerializer;
3839
private XmiDataCache xmiDataCache;
40+
41+
private INamespace anonymouseNameSpace;
3942

4043
[SetUp]
4144
public void Setup()
@@ -46,9 +49,26 @@ public void Setup()
4649

4750
this.xmiDataCache = new XmiDataCache(new PocoReferenceResolveExtensionsFacade(),serviceProvider.GetRequiredService<ILogger<XmiDataCache>>());
4851

52+
this.deSerializer = new DeSerializer(new ExternalReferenceService(serviceProvider.GetRequiredService<ILogger<ExternalReferenceService>>()), new XmiDataReaderFacade(), this.xmiDataCache, serviceProvider.GetRequiredService<ILoggerFactory>());
53+
54+
this.ReadAndAssemblePopulationFromXmiFile();
55+
4956
this.serializer = new Serializer(serviceProvider.GetRequiredService<ILoggerFactory>());
5057
}
51-
52-
58+
59+
[Test]
60+
public void Verify_that_the_name_space_can_be_serialized_to_xmi()
61+
{
62+
var targetStream = new MemoryStream();
63+
64+
Assert.That(() => this.serializer.Serialize(this.anonymouseNameSpace, false,targetStream), Throws.Nothing);
65+
66+
}
67+
68+
private void ReadAndAssemblePopulationFromXmiFile()
69+
{
70+
var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "Domain Libraries", "Quantities and Units", "Quantities.sysmlx");
71+
this.anonymouseNameSpace = this.deSerializer.DeSerialize(new Uri(filePath));
72+
}
5373
}
5474
}

SysML2.NET.Serializer.Xmi/Serializer.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ public Serializer(ILoggerFactory loggerFactory)
6969
/// </param>
7070
public void Serialize(INamespace @namespace, bool includeDerivedProperties, Stream stream)
7171
{
72+
// if the namespace is not an anonymouse namespace, then first create that and make the
73+
// provide namespace owned by the anonymouse
74+
7275
throw new System.NotImplementedException();
73-
}
76+
}
7477

7578
/// <summary>
7679
/// Asynchronously serialize an <see cref="INamespace"/> as XMI to a target <see cref="Stream"/>
@@ -89,6 +92,9 @@ public void Serialize(INamespace @namespace, bool includeDerivedProperties, Stre
8992
/// </param>
9093
public Task SerializeAsync(INamespace @namespace, bool includeDerivedProperties, Stream stream, CancellationToken cancellationToken)
9194
{
95+
// if the namespace is not an anonymouse namespace, then first create that and make the
96+
// provide namespace owned by the anonymouse
97+
9298
throw new System.NotImplementedException();
9399
}
94100
}

0 commit comments

Comments
 (0)