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/nuget-reference-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# declared in Directory.Packages.props - keep the two in step. They are by design
# permanently "outdated", so they are excluded from the outdated signal only - the
# --deprecated and --vulnerable steps below do not use this filter.
IGNORE_PACKAGES="Microsoft\.NETCore\.Platforms|Microsoft\.NETCore\.Targets|Microsoft\.Extensions\.Logging\.Abstractions|Microsoft\.Extensions\.DependencyInjection\.Abstractions|System\.Collections\.Immutable|System\.IO\.Pipelines"
IGNORE_PACKAGES="Microsoft\.NETCore\.Platforms|Microsoft\.NETCore\.Targets|Microsoft\.Extensions\.Logging\.Abstractions|Microsoft\.Extensions\.DependencyInjection\.Abstractions|Microsoft\.Extensions\.Http|System\.Collections\.Immutable|System\.IO\.Pipelines"

# Full report for the workflow logs only, including transitive packages
dotnet list SysML2.NET.sln package --outdated --include-transitive > outdated-full-raw.log
Expand Down
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
IGNORE_PACKAGES in .github/workflows/nuget-reference-check.yml (outdated check only):

Microsoft.Extensions.DependencyInjection.Abstractions
Microsoft.Extensions.Http
Microsoft.Extensions.Logging.Abstractions
System.Collections.Immutable
System.IO.Pipelines
Expand All @@ -24,6 +25,7 @@
-->
<ItemGroup Label="Floored to LTS">
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.IO.Pipelines" Version="8.0.0" />
Expand Down Expand Up @@ -55,6 +57,7 @@
<PackageVersion Include="NUnit" Version="4.6.1" />
<PackageVersion Include="NUnit.Console" Version="3.22.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.3.0" />
<PackageVersion Include="RichardSzalay.MockHttp" Version="7.0.0" />
<PackageVersion Include="Serilog" Version="4.4.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.1.1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// ------------------------------------------------------------------------------------------------
// <copyright file="MergeConflictExceptionTestFixture.cs" company="Starion Group S.A.">
//
// Copyright (C) 2022-2026 Starion Group S.A.
// SPDX-License-Identifier: Apache-2.0
//
// </copyright>
// ------------------------------------------------------------------------------------------------

namespace SySML2.NET.REST.Tests.Exceptions
{
using System;
using System.Net;

using NUnit.Framework;

using SysML2.NET.PSM.DTO;
using SysML2.NET.REST.Exceptions;

[TestFixture]
public class MergeConflictExceptionTestFixture
{
[Test]
public void VerifyConstructor()
{
var exception = new MergeConflictException([]);

using (Assert.EnterMultipleScope())
{
Assert.That(exception.Conflicts, Has.Count.EqualTo(0));
Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Conflict));
Assert.That(exception.Error, Is.Null);
}

var conflict = new DataIdentity { Id = Guid.Parse("2f1a0e1c-6b2a-4d5e-9c3f-8a7b6d5e4c3b") };

exception = new MergeConflictException([conflict]);

using (Assert.EnterMultipleScope())
{
Assert.That(exception.Conflicts, Has.Count.EqualTo(1));
Assert.That(exception.Conflicts[0], Is.SameAs(conflict));
Assert.That(exception, Is.InstanceOf<PsmApiException>());
}

exception = new MergeConflictException();

using (Assert.EnterMultipleScope())
{
Assert.That(exception.Conflicts, Has.Count.EqualTo(0));
Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Conflict));
}

exception = new MergeConflictException("the message");

using (Assert.EnterMultipleScope())
{
Assert.That(exception.Message, Is.EqualTo("the message"));
Assert.That(exception.Conflicts, Has.Count.EqualTo(0));
}

var innerException = new InvalidOperationException();

exception = new MergeConflictException("the message", innerException);

using (Assert.EnterMultipleScope())
{
Assert.That(exception.InnerException, Is.SameAs(innerException));
Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Conflict));
Assert.That(exception.Error, Is.Null);
}
}
}
}
73 changes: 73 additions & 0 deletions SySML2.NET.REST.Tests/Exceptions/PsmApiExceptionTestFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ------------------------------------------------------------------------------------------------
// <copyright file="PsmApiExceptionTestFixture.cs" company="Starion Group S.A.">
//
// Copyright (C) 2022-2026 Starion Group S.A.
// SPDX-License-Identifier: Apache-2.0
//
// </copyright>
// ------------------------------------------------------------------------------------------------

namespace SySML2.NET.REST.Tests.Exceptions
{
using System;
using System.Net;

using NUnit.Framework;

using SysML2.NET.PSM.DTO;
using SysML2.NET.REST.Exceptions;

[TestFixture]
public class PsmApiExceptionTestFixture
{
[Test]
public void VerifyConstructor()
{
var error = new Error { Description = "the error description" };

var exception = new PsmApiException(HttpStatusCode.NotFound, error);

using (Assert.EnterMultipleScope())
{
Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
Assert.That(exception.Error, Is.SameAs(error));
Assert.That(exception.Message, Is.EqualTo("the error description"));
}

exception = new PsmApiException(HttpStatusCode.BadRequest, new Error { Description = " " });

Assert.That(exception.Message, Is.EqualTo("The server responded with status code 400 (BadRequest)"));

exception = new PsmApiException(HttpStatusCode.InternalServerError, null);

using (Assert.EnterMultipleScope())
{
Assert.That(exception.Error, Is.Null);
Assert.That(exception.Message, Is.EqualTo("The server responded with status code 500 (InternalServerError)"));
}

exception = new PsmApiException();

using (Assert.EnterMultipleScope())
{
Assert.That(exception.StatusCode, Is.EqualTo((HttpStatusCode)0));
Assert.That(exception.Error, Is.Null);
}

exception = new PsmApiException("the message");

Assert.That(exception.Message, Is.EqualTo("the message"));

var innerException = new InvalidOperationException();

exception = new PsmApiException("the message", innerException);

using (Assert.EnterMultipleScope())
{
Assert.That(exception.Message, Is.EqualTo("the message"));
Assert.That(exception.InnerException, Is.SameAs(innerException));
Assert.That(exception.Error, Is.Null);
}
}
}
}
Loading
Loading