Skip to content

Commit

Permalink
[Bump] reqifsharp to version 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sam.gerene committed Jan 1, 2022
1 parent abebc12 commit e12e8cc
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,6 @@ public void Verify_that_QueryDatatypeName_returns_expected_results()

var attributeDefinitionXhtml = new AttributeDefinitionXHTML();
Assert.That(attributeDefinitionXhtml.QueryDatatypeName(), Is.EqualTo("XHTML"));

var attributeDefinition = new TestAttributeDefinition();
Assert.Throws<InvalidOperationException>(() => attributeDefinition.QueryDatatypeName());
}

private class TestAttributeDefinition : AttributeDefinition
{
protected override DatatypeDefinition GetDatatypeDefinition()
{
throw new NotImplementedException();
}

protected override void SetDatatypeDefinition(DatatypeDefinition datatypeDefinition)
{
throw new NotImplementedException();
}

public override Task ReadXmlAsync(XmlReader reader, CancellationToken token)
{
throw new NotImplementedException();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ public void Verify_that_QueryDatatypeName_returns_expected_results()

var datatypeDefinitionXhtml = new DatatypeDefinitionXHTML();
Assert.That(datatypeDefinitionXhtml.QueryDatatypeName(), Is.EqualTo("XHTML"));

var testDataTypeDefinition = new TestDataTypeDefinition();
Assert.Throws<InvalidOperationException>(() => testDataTypeDefinition.QueryDatatypeName());
}

private class TestDataTypeDefinition : DatatypeDefinition
{
public override Task ReadXmlAsync(XmlReader reader, CancellationToken token)
{
throw new NotImplementedException();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@ namespace ReqifViewer.Infrastructure.Tests.ReqIFExtensions
public class SpecElementWithAttributesExtensionTestFixture
{
private ReqIF reqIf;

[SetUp]
public async Task SetUp()
{
var reqIfDeserializer = new ReqIFDeserializer();

var cts = new CancellationTokenSource();

var reqifPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "ProR_Traceability-Template-v1.0.reqif");

await using var fileStream = new FileStream(reqifPath, FileMode.Open);
var reqIfLoaderService = new ReqIFLoaderService();
var reqIfLoaderService = new ReqIFLoaderService(reqIfDeserializer);
await reqIfLoaderService.Load(fileStream, cts.Token);

this.reqIf = reqIfLoaderService.ReqIFData.Single();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public async Task SetUp()
var reqifPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "ProR_Traceability-Template-v1.0.reqif");

await using var fileStream = new FileStream(reqifPath, FileMode.Open);
var reqIfLoaderService = new ReqIFLoaderService();
var reqIfDeserializer = new ReqIFDeserializer();
var reqIfLoaderService = new ReqIFLoaderService(reqIfDeserializer);
await reqIfLoaderService.Load(fileStream, cts.Token);

this.reqIf = reqIfLoaderService.ReqIFData.Single();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace ReqifViewer.Infrastructure.Tests.Services

using NUnit.Framework;

using ReqIFSharp;

using ReqifViewer.Infrastructure.ReqIFExtensions;
using ReqifViewer.Infrastructure.Services;

Expand All @@ -42,7 +44,8 @@ public class ReqIFLoaderServiceTestFixture
[SetUp]
public void Setup()
{
this.reqIfLoaderService = new ReqIFLoaderService();
var reqIfDeserializer = new ReqIFDeserializer();
this.reqIfLoaderService = new ReqIFLoaderService(reqIfDeserializer);
}

[Test]
Expand Down
4 changes: 2 additions & 2 deletions ReqifViewer.Infrastructure/ReqifViewer.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<Company>RHEA System S.A.</Company>
<Title>ReqifViewer.Infrastructure</Title>
<Version>0.6.0</Version>
<Version>0.7.0</Version>
<Description>Shared Infrastructure</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam Gerené</Authors>
Expand All @@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.13" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="ReqIFSharp" Version="5.0.0-rc5" />
<PackageReference Include="ReqIFSharp" Version="5.0.0" />
</ItemGroup>

</Project>
21 changes: 13 additions & 8 deletions ReqifViewer.Infrastructure/Services/ReqIFLoaderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class ReqIFLoaderService : IReqIFLoaderService
/// </summary>
private Stream sourceStream;

private readonly IReqIFDeSerializer reqIfDeSerializer;

/// <summary>
/// The <see cref="ILogger"/> used to log
/// </summary>
Expand All @@ -52,12 +54,17 @@ public class ReqIFLoaderService : IReqIFLoaderService
/// <summary>
/// Initializes a new instance of the <see cref="ReqIFLoaderService"/>
/// </summary>
/// <param name="logger">
/// The (injected) logger
/// <param name="reqIfDeSerializer">
/// The (injected) <see cref="IReqIFDeSerializer"/>
/// </param>
/// <param name="loggerFactory">
/// The (injected) <see cref="ILoggerFactory"/>
/// </param>
public ReqIFLoaderService(ILogger<ReqIFLoaderService> logger = null)
public ReqIFLoaderService(IReqIFDeSerializer reqIfDeSerializer, ILoggerFactory loggerFactory = null)
{
this.logger = logger ?? NullLogger<ReqIFLoaderService>.Instance;
this.reqIfDeSerializer = reqIfDeSerializer;

this.logger = loggerFactory == null ? NullLogger<ReqIFLoaderService>.Instance : loggerFactory.CreateLogger<ReqIFLoaderService>();
}

/// <summary>
Expand Down Expand Up @@ -130,12 +137,10 @@ public async Task Load(Stream reqIFStream, CancellationToken token)
}

IEnumerable<ReqIF> result = null;

var reqIfDeserializer = new ReqIFDeserializer();


var sw = Stopwatch.StartNew();
this.logger.LogDebug("starting deserialization");
result = await reqIfDeserializer.DeserializeAsync(deserializationStream, token);
result = await this.reqIfDeSerializer.DeserializeAsync(deserializationStream, token);
this.logger.LogDebug("deserialization finished in {time} [ms]", sw.ElapsedMilliseconds);

await deserializationStream.DisposeAsync();
Expand Down
5 changes: 4 additions & 1 deletion reqifviewer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace reqifviewer
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;

using ReqIFSharp;

using Radzen;

using ReqifViewer.Infrastructure.Services;
Expand All @@ -51,7 +53,7 @@ public static class Program
public static async Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.BrowserConsole()
Expand All @@ -72,6 +74,7 @@ public static async Task Main(string[] args)

builder.Services.AddGoogleAnalytics("295704041");

builder.Services.AddSingleton<IReqIFDeSerializer, ReqIFDeserializer>();
builder.Services.AddSingleton<IReqIFLoaderService, ReqIFLoaderService>();

await builder.Build().RunAsync();
Expand Down
2 changes: 1 addition & 1 deletion reqifviewer/reqifviewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<Company>RHEA System S.A.</Company>
<Title>reqifviewer</Title>
<Version>0.9.0</Version>
<Version>0.10.0</Version>
<Description>Web Application to inspect ReqIF files</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam Gerené</Authors>
Expand Down

0 comments on commit e12e8cc

Please sign in to comment.