Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CodeQuality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
- name: Sonarqube end
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN"
run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit.Console" Version="3.20.2" />
Expand All @@ -34,8 +34,8 @@

<ItemGroup>
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ECoreNetto.Extensions/ECoreNetto.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.12.4" />
<PackageReference Include="Microsoft.Sbom.Targets" Version="4.1.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.Sbom.Targets" Version="4.1.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit.Console" Version="3.20.2" />
<PackageReference Include="NUnit3TestAdapter" Version="5.2.0">
Expand All @@ -30,8 +30,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ECoreNetto.HandleBars/ECoreNetto.HandleBars.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<ItemGroup>
<PackageReference Include="Handlebars.Net.Helpers" Version="2.5.3" />
<PackageReference Include="Microsoft.Sbom.Targets" Version="4.1.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.Sbom.Targets" Version="4.1.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions ECoreNetto.Reporting.Tests/ECoreNetto.Reporting.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit.Console" Version="3.20.2" />
<PackageReference Include="NUnit3TestAdapter" Version="5.2.0">
Expand All @@ -27,8 +27,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions ECoreNetto.Reporting/ECoreNetto.Reporting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@

<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.105.0" />
<PackageReference Include="Microsoft.Sbom.Targets" Version="4.1.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.Sbom.Targets" Version="4.1.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="Transitive Dependency overrides">
<PackageReference Include="System.IO.Packaging" Version="9.0.10" />
<PackageReference Include="System.IO.Packaging" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions ECoreNetto.Tests/ECoreNetto.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit.Console" Version="3.20.2" />
Expand All @@ -34,8 +34,8 @@

<ItemGroup>
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
64 changes: 47 additions & 17 deletions ECoreNetto.Tools.Tests/Commands/HtmlReportCommandTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
namespace ECoreNetto.Tools.Tests.Commands
{
using System;
using System.CommandLine.Invocation;
using System.CommandLine;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

using ECoreNetto.Reporting.Generators;
using ECoreNetto.Tools.Commands;

using Moq;
using ECoreNetto.Tools.Services;

using Moq;
using NUnit.Framework;

/// <summary>
Expand All @@ -38,24 +39,36 @@
[TestFixture]
public class HtmlReportCommandTestFixture
{
private RootCommand rootCommand;

Check warning on line 42 in ECoreNetto.Tools.Tests/Commands/HtmlReportCommandTestFixture.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Non-nullable field 'rootCommand' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

See more on https://sonarcloud.io/project/issues?id=STARIONGROUP_EcoreNetto&issues=AZq2jAYYQCxATVI_cwnY&open=AZq2jAYYQCxATVI_cwnY&pullRequest=24

private Mock<IHtmlReportGenerator> htmlReportGenerator;

private Mock<IVersionChecker> versionChecker;

Check warning on line 46 in ECoreNetto.Tools.Tests/Commands/HtmlReportCommandTestFixture.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Non-nullable field 'versionChecker' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

See more on https://sonarcloud.io/project/issues?id=STARIONGROUP_EcoreNetto&issues=AZq2jAYYQCxATVI_cwnZ&open=AZq2jAYYQCxATVI_cwnZ&pullRequest=24

private HtmlReportCommand.Handler handler;

private CancellationTokenSource cts;

Check warning on line 50 in ECoreNetto.Tools.Tests/Commands/HtmlReportCommandTestFixture.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Non-nullable field 'cts' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

See more on https://sonarcloud.io/project/issues?id=STARIONGROUP_EcoreNetto&issues=AZq2jAYYQCxATVI_cwna&open=AZq2jAYYQCxATVI_cwna&pullRequest=24

[SetUp]
public void SetUp()
{
this.cts = new CancellationTokenSource();

var htmlReportCommand = new HtmlReportCommand();
this.rootCommand = new RootCommand();
this.rootCommand.Add(htmlReportCommand);

this.htmlReportGenerator = new Mock<IHtmlReportGenerator>();
this.versionChecker = new Mock<IVersionChecker>();

this.htmlReportGenerator.Setup(x => x.IsValidReportExtension(It.IsAny<FileInfo>()))
.Returns(new Tuple<bool, string>(true, "valid extension"));

this.handler = new HtmlReportCommand.Handler(
this.htmlReportGenerator.Object);
this.handler = new HtmlReportCommand.Handler(this.htmlReportGenerator.Object, this.versionChecker.Object);
}

[Test]
public void Verify_that_inspect_command_can_be_constructed()
public void Verify_that_HtmlReportCommand_can_be_constructed()
{
Assert.That(() =>
{
Expand All @@ -66,42 +79,59 @@
[Test]
public async Task Verify_that_InvokeAsync_returns_0()
{
var invocationContext = new InvocationContext(null!);
var args = new[]
{
"html-report",
"--no-logo",
"--input-model", Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "recipe.ecore"),
"--output-report", Path.Combine(TestContext.CurrentContext.TestDirectory, "html-report.html")
};

this.handler.InputModel = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "recipe.ecore"));
this.handler.OutputReport = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "html-report.html"));
var parseResult = this.rootCommand.Parse(args);

var result = await this.handler.InvokeAsync(invocationContext);
var result = await this.handler.InvokeAsync(parseResult, this.cts.Token);

this.htmlReportGenerator.Verify(x => x.GenerateReport(It.IsAny<FileInfo>(), It.IsAny<FileInfo>()), Times.Once);

this.versionChecker.Verify(x => x.ExecuteAsync(It.IsAny<CancellationToken>()), Times.Once);

Assert.That(result, Is.EqualTo(0), "InvokeAsync should return 0 upon success.");
}

[Test]
public async Task Verify_that_when_the_input_ecore_model_does_not_exists_returns_not_0()
{
var invocationContext = new InvocationContext(null!);
var args = new[]
{
"html-report",
"--no-logo",
"--input-model", Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "non-existent.ecore"),
"--output-report", Path.Combine(TestContext.CurrentContext.TestDirectory, "html-report.html")
};

this.handler.InputModel = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "non-existent.ecore"));
this.handler.OutputReport = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "html-report.html"));
var parseResult = this.rootCommand.Parse(args);

var result = await this.handler.InvokeAsync(invocationContext);
var result = await this.handler.InvokeAsync(parseResult, this.cts.Token);

Assert.That(result, Is.EqualTo(-1), "InvokeAsync should return -1 upon failure.");
}

[Test]
public async Task Verify_that_when_the_output_extensions_is_not_supported_returns_not_0()
{
var invocationContext = new InvocationContext(null!);
var args = new[]
{
"html-report",
"--no-logo",
"--input-model", Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "recipe.ecore"),
};

this.htmlReportGenerator.Setup(x => x.IsValidReportExtension(It.IsAny<FileInfo>()))
.Returns(new Tuple<bool, string>(false, "invalid extension"));

this.handler.InputModel = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "recipe.ecore"));
var parseResult = this.rootCommand.Parse(args);

var result = await this.handler.InvokeAsync(invocationContext);
var result = await this.handler.InvokeAsync(parseResult, this.cts.Token);

Assert.That(result, Is.EqualTo(-1), "InvokeAsync should return -1 upon failure.");
}
Expand Down
62 changes: 46 additions & 16 deletions ECoreNetto.Tools.Tests/Commands/MarkdownReportCommandTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
namespace ECoreNetto.Tools.Tests.Commands
{
using System;
using System.CommandLine.Invocation;
using System.CommandLine;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

using ECoreNetto.Reporting.Generators;
using ECoreNetto.Tools.Commands;
using ECoreNetto.Tools.Services;

using Moq;

using NUnit.Framework;

/// <summary>
Expand All @@ -38,24 +39,36 @@
[TestFixture]
public class MarkdownReportCommandTestFixture
{
private RootCommand rootCommand;

Check warning on line 42 in ECoreNetto.Tools.Tests/Commands/MarkdownReportCommandTestFixture.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'rootCommand' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 42 in ECoreNetto.Tools.Tests/Commands/MarkdownReportCommandTestFixture.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Non-nullable field 'rootCommand' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

See more on https://sonarcloud.io/project/issues?id=STARIONGROUP_EcoreNetto&issues=AZq2jAZAQCxATVI_cwnb&open=AZq2jAZAQCxATVI_cwnb&pullRequest=24

private Mock<IMarkdownReportGenerator> markdownReportGenerator;

Check warning on line 44 in ECoreNetto.Tools.Tests/Commands/MarkdownReportCommandTestFixture.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'markdownReportGenerator' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

private Mock<IVersionChecker> versionChecker;

Check warning on line 46 in ECoreNetto.Tools.Tests/Commands/MarkdownReportCommandTestFixture.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'versionChecker' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 46 in ECoreNetto.Tools.Tests/Commands/MarkdownReportCommandTestFixture.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Non-nullable field 'versionChecker' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

See more on https://sonarcloud.io/project/issues?id=STARIONGROUP_EcoreNetto&issues=AZq2jAZAQCxATVI_cwnc&open=AZq2jAZAQCxATVI_cwnc&pullRequest=24

private MarkdownReportCommand.Handler handler;

Check warning on line 48 in ECoreNetto.Tools.Tests/Commands/MarkdownReportCommandTestFixture.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'handler' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

private CancellationTokenSource cts;

Check warning on line 50 in ECoreNetto.Tools.Tests/Commands/MarkdownReportCommandTestFixture.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'cts' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 50 in ECoreNetto.Tools.Tests/Commands/MarkdownReportCommandTestFixture.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Non-nullable field 'cts' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

See more on https://sonarcloud.io/project/issues?id=STARIONGROUP_EcoreNetto&issues=AZq2jAZAQCxATVI_cwnd&open=AZq2jAZAQCxATVI_cwnd&pullRequest=24

[SetUp]
public void SetUp()
{
this.cts = new CancellationTokenSource();

var markdownReportCommand = new MarkdownReportCommand();
this.rootCommand = new RootCommand();
this.rootCommand.Add(markdownReportCommand);

this.markdownReportGenerator = new Mock<IMarkdownReportGenerator>();
this.versionChecker = new Mock<IVersionChecker>();

this.markdownReportGenerator.Setup(x => x.IsValidReportExtension(It.IsAny<FileInfo>()))
.Returns(new Tuple<bool, string>(true, "valid extension"));

this.handler = new MarkdownReportCommand.Handler(
this.markdownReportGenerator.Object);
this.handler = new MarkdownReportCommand.Handler(this.markdownReportGenerator.Object, this.versionChecker.Object);
}

[Test]
public void Verify_that_inspect_command_can_be_constructed()
public void Verify_that_MarkdownReportCommand_can_be_constructed()
{
Assert.That(() =>
{
Expand All @@ -66,42 +79,59 @@
[Test]
public async Task Verify_that_InvokeAsync_returns_0()
{
var invocationContext = new InvocationContext(null!);
var args = new[]
{
"md-report",
"--no-logo",
"--input-model", Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "recipe.ecore"),
"--output-report", Path.Combine(TestContext.CurrentContext.TestDirectory, "md-report.md")
};

this.handler.InputModel = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "recipe.ecore"));
this.handler.OutputReport = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "md-report.md"));
var parseResult = this.rootCommand.Parse(args);

var result = await this.handler.InvokeAsync(invocationContext);
var result = await this.handler.InvokeAsync(parseResult, this.cts.Token);

this.markdownReportGenerator.Verify(x => x.GenerateReport(It.IsAny<FileInfo>(), It.IsAny<FileInfo>()), Times.Once);

this.versionChecker.Verify(x => x.ExecuteAsync(It.IsAny<CancellationToken>()), Times.Once);

Assert.That(result, Is.EqualTo(0), "InvokeAsync should return 0 upon success.");
}

[Test]
public async Task Verify_that_when_the_input_ecore_model_does_not_exists_returns_not_0()
{
var invocationContext = new InvocationContext(null!);
var args = new[]
{
"md-report",
"--no-logo",
"--input-model", Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "non-existent.ecore"),
"--output-report", Path.Combine(TestContext.CurrentContext.TestDirectory, "md-report.md")
};

this.handler.InputModel = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "non-existent.ecore"));
this.handler.OutputReport = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "md-report.md"));
var parseResult = this.rootCommand.Parse(args);

var result = await this.handler.InvokeAsync(invocationContext);
var result = await this.handler.InvokeAsync(parseResult, this.cts.Token);

Assert.That(result, Is.EqualTo(-1), "InvokeAsync should return -1 upon failure.");
}

[Test]
public async Task Verify_that_when_the_output_extensions_is_not_supported_returns_not_0()
{
var invocationContext = new InvocationContext(null!);
var args = new[]
{
"md-report",
"--no-logo",
"--input-model", Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "recipe.ecore"),
};

this.markdownReportGenerator.Setup(x => x.IsValidReportExtension(It.IsAny<FileInfo>()))
.Returns(new Tuple<bool, string>(false, "invalid extension"));

this.handler.InputModel = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "recipe.ecore"));
var parseResult = this.rootCommand.Parse(args);

var result = await this.handler.InvokeAsync(invocationContext);
var result = await this.handler.InvokeAsync(parseResult, this.cts.Token);

Assert.That(result, Is.EqualTo(-1), "InvokeAsync should return -1 upon failure.");
}
Expand Down
Loading
Loading