Skip to content

Commit

Permalink
[Implement] XlReportGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
samatstariongroup committed Dec 28, 2024
1 parent 41f657f commit 51e479e
Show file tree
Hide file tree
Showing 2 changed files with 306 additions and 93 deletions.
87 changes: 87 additions & 0 deletions uml4net.Reporting.Tests/Generators/XlReportGeneratorTestFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="XlReportGeneratorTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2019-2024 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// </copyright>
// ------------------------------------------------------------------------------------------------

namespace uml4net.Reporting.Tests.Generators
{
using System.Collections.Generic;
using System.IO;

using Microsoft.Extensions.Logging;

using NUnit.Framework;

using Reporting.Generators;

using Serilog;

[TestFixture]
public class XlReportGeneratorTestFixture
{
private ILoggerFactory loggerFactory;

private XlReportGenerator xlReportGenerator;

private FileInfo umlModelFileInfo;

private FileInfo sysml2ModelFileInfo;

[SetUp]
public void SetUp()
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Console()
.CreateLogger();

this.loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddSerilog();
});

this.umlModelFileInfo = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "UML.xmi"));
this.sysml2ModelFileInfo = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "SysML.uml"));
}

[Test]
public void Verify_that_the_report_generator_generates_a_report_of_uml()
{
this.xlReportGenerator = new XlReportGenerator(this.loggerFactory);

var reportFileInfo = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "uml-xl-report.xlsx"));

var pathmap = new Dictionary<string, string>();

Assert.That(() => this.xlReportGenerator.GenerateReport(this.umlModelFileInfo, this.umlModelFileInfo.Directory, pathmap, reportFileInfo), Throws.Nothing);
}

[Test]
public void Verify_that_the_report_generator_generates_a_report_of_sysml2()
{
this.xlReportGenerator = new XlReportGenerator(this.loggerFactory);

var reportFileInfo = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "sysml2-xl-report.xlsx"));

var pathmap = new Dictionary<string, string>();
pathmap.Add("pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml", Path.Combine("TestData", "PrimitiveTypes.xmi"));

Assert.That(() => this.xlReportGenerator.GenerateReport(this.sysml2ModelFileInfo, this.umlModelFileInfo.Directory, pathmap, reportFileInfo), Throws.Nothing);
}
}
}
Loading

0 comments on commit 51e479e

Please sign in to comment.