diff --git a/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/AttributeDefinitionExtensionsTestFixture.cs b/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/AttributeDefinitionExtensionsTestFixture.cs index 8981ae2..f47aaa2 100644 --- a/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/AttributeDefinitionExtensionsTestFixture.cs +++ b/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/AttributeDefinitionExtensionsTestFixture.cs @@ -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(() => 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(); - } } } } diff --git a/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/DatatypeDefinitionExtensionsTestFixture.cs b/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/DatatypeDefinitionExtensionsTestFixture.cs index dd790e5..a9e0f23 100644 --- a/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/DatatypeDefinitionExtensionsTestFixture.cs +++ b/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/DatatypeDefinitionExtensionsTestFixture.cs @@ -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(() => testDataTypeDefinition.QueryDatatypeName()); - } - - private class TestDataTypeDefinition : DatatypeDefinition - { - public override Task ReadXmlAsync(XmlReader reader, CancellationToken token) - { - throw new NotImplementedException(); - } } } } diff --git a/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/SpecElementWithAttributesExtensionTestFixture.cs b/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/SpecElementWithAttributesExtensionTestFixture.cs index aa245ef..d221eec 100644 --- a/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/SpecElementWithAttributesExtensionTestFixture.cs +++ b/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/SpecElementWithAttributesExtensionTestFixture.cs @@ -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(); diff --git a/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/SpecificationExtensionsTestFixture.cs b/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/SpecificationExtensionsTestFixture.cs index 331b451..3fb8934 100644 --- a/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/SpecificationExtensionsTestFixture.cs +++ b/ReqifViewer.Infrastructure.Tests/ReqIFExtensions/SpecificationExtensionsTestFixture.cs @@ -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(); diff --git a/ReqifViewer.Infrastructure.Tests/Services/ReqIFLoaderServiceTestFixture.cs b/ReqifViewer.Infrastructure.Tests/Services/ReqIFLoaderServiceTestFixture.cs index c596054..b6e1c85 100644 --- a/ReqifViewer.Infrastructure.Tests/Services/ReqIFLoaderServiceTestFixture.cs +++ b/ReqifViewer.Infrastructure.Tests/Services/ReqIFLoaderServiceTestFixture.cs @@ -29,6 +29,8 @@ namespace ReqifViewer.Infrastructure.Tests.Services using NUnit.Framework; + using ReqIFSharp; + using ReqifViewer.Infrastructure.ReqIFExtensions; using ReqifViewer.Infrastructure.Services; @@ -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] diff --git a/ReqifViewer.Infrastructure/ReqifViewer.Infrastructure.csproj b/ReqifViewer.Infrastructure/ReqifViewer.Infrastructure.csproj index f4ec740..88987f2 100644 --- a/ReqifViewer.Infrastructure/ReqifViewer.Infrastructure.csproj +++ b/ReqifViewer.Infrastructure/ReqifViewer.Infrastructure.csproj @@ -4,7 +4,7 @@ net5.0 RHEA System S.A. ReqifViewer.Infrastructure - 0.6.0 + 0.7.0 Shared Infrastructure Copyright © RHEA System S.A. Sam Gerené @@ -15,7 +15,7 @@ - + diff --git a/ReqifViewer.Infrastructure/Services/ReqIFLoaderService.cs b/ReqifViewer.Infrastructure/Services/ReqIFLoaderService.cs index 2dc92ea..424b209 100644 --- a/ReqifViewer.Infrastructure/Services/ReqIFLoaderService.cs +++ b/ReqifViewer.Infrastructure/Services/ReqIFLoaderService.cs @@ -44,6 +44,8 @@ public class ReqIFLoaderService : IReqIFLoaderService /// private Stream sourceStream; + private readonly IReqIFDeSerializer reqIfDeSerializer; + /// /// The used to log /// @@ -52,12 +54,17 @@ public class ReqIFLoaderService : IReqIFLoaderService /// /// Initializes a new instance of the /// - /// - /// The (injected) logger + /// + /// The (injected) + /// + /// + /// The (injected) /// - public ReqIFLoaderService(ILogger logger = null) + public ReqIFLoaderService(IReqIFDeSerializer reqIfDeSerializer, ILoggerFactory loggerFactory = null) { - this.logger = logger ?? NullLogger.Instance; + this.reqIfDeSerializer = reqIfDeSerializer; + + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } /// @@ -130,12 +137,10 @@ public async Task Load(Stream reqIFStream, CancellationToken token) } IEnumerable 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(); diff --git a/reqifviewer/Program.cs b/reqifviewer/Program.cs index 5752bf4..d3ae989 100644 --- a/reqifviewer/Program.cs +++ b/reqifviewer/Program.cs @@ -28,6 +28,8 @@ namespace reqifviewer using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.Extensions.DependencyInjection; + using ReqIFSharp; + using Radzen; using ReqifViewer.Infrastructure.Services; @@ -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() @@ -72,6 +74,7 @@ public static async Task Main(string[] args) builder.Services.AddGoogleAnalytics("295704041"); + builder.Services.AddSingleton(); builder.Services.AddSingleton(); await builder.Build().RunAsync(); diff --git a/reqifviewer/reqifviewer.csproj b/reqifviewer/reqifviewer.csproj index a0de871..e51621d 100644 --- a/reqifviewer/reqifviewer.csproj +++ b/reqifviewer/reqifviewer.csproj @@ -4,7 +4,7 @@ net5.0 RHEA System S.A. reqifviewer - 0.9.0 + 0.10.0 Web Application to inspect ReqIF files Copyright © RHEA System S.A. Sam Gerené