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
29 changes: 17 additions & 12 deletions MapManager.UnitTests/Apis/Config/ConfigTest.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
using MapManager.Apis;
using Serilog;
using Serilog.Events;
using System.IO;
using Xunit;
Comment on lines 1 to 5

namespace MapManager.Tests.Apis.Config
{
public class ConfigTest
{
private static string OutputDirectory => AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Qualify AppContext so the test project builds

In this net48 project, implicit global usings are not enabled in the project file, so AppContext is not in scope here. A clean build of the test assembly will fail on this added expression before discovery can run; add using System; or qualify it as System.AppContext so the new discovery setup can compile.

Useful? React with 👍 / 👎.

private static string DefaultDirectory => Path.Combine(OutputDirectory, "Default");
private static string SharedDirectory => new DirectoryInfo(OutputDirectory).Parent.Parent.FullName + Path.DirectorySeparatorChar + "Shared";

private ILogger Log { get; }

public ConfigTest(ITestOutputHelper output)
Expand All @@ -26,95 +31,95 @@ public void Default()
{
var fullName = MapManager.Apis.Config.Default.Directory.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default", fullName);
Assert.Equal(DefaultDirectory, fullName);
}

[Fact]
public void DefaultAnnotationMap()
{
var fullName = MapManager.Apis.Config.DefaultAnnotationMap.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\Annotation.map", fullName);
Assert.Equal(Path.Combine(DefaultDirectory, "Annotation.map"), fullName);
}

[Fact]
public void DefaultFontList()
{
var fullName = MapManager.Apis.Config.DefaultFontList.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\font.list", fullName);
Assert.Equal(Path.Combine(DefaultDirectory, "font.list"), fullName);
}

[Fact]
public void DefaultMap()
{
var fullName = MapManager.Apis.Config.DefaultMap.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\Default.map", fullName);
Assert.Equal(Path.Combine(DefaultDirectory, "Default.map"), fullName);
}

[Fact]
public void DefaultStyleLibraryMap()
{
var fullName = MapManager.Apis.Config.DefaultStyleLibraryMap.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\StyleLibrary.map", fullName);
Assert.Equal(Path.Combine(DefaultDirectory, "StyleLibrary.map"), fullName);
}

[Fact]
public void DefaultSymbols()
{
var fullName = MapManager.Apis.Config.DefaultSymbols.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\symbols.sym", fullName);
Assert.Equal(Path.Combine(DefaultDirectory, "symbols.sym"), fullName);
}

[Fact]
public void Shared()
{
var fullName = MapManager.Apis.Config.Shared.Directory.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Shared", fullName);
Assert.Equal(SharedDirectory, fullName);
}

[Fact]
public void SharedAnnotationMap()
{
var fullName = MapManager.Apis.Config.SharedAnnotationMap.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\Annotation.map", fullName);
Assert.Equal(Path.Combine(SharedDirectory, "Annotation.map"), fullName);
}

[Fact]
public void SharedFontList()
{
var fullName = MapManager.Apis.Config.SharedFontList.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\font.list", fullName);
Assert.Equal(Path.Combine(SharedDirectory, "font.list"), fullName);
}

[Fact]
public void SharedMap()
{
var fullName = MapManager.Apis.Config.SharedDefaultMap.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\Default.map", fullName);
Assert.Equal(Path.Combine(SharedDirectory, "Default.map"), fullName);
}

[Fact]
public void SharedStyleLibraryMap()
{
var fullName = MapManager.Apis.Config.SharedStyleLibraryMap.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\StyleLibrary.map", fullName);
Assert.Equal(Path.Combine(SharedDirectory, "StyleLibrary.map"), fullName);
}

[Fact]
public void SharedSymbols()
{
var fullName = MapManager.Apis.Config.SharedSymbols.File.FullName;
Log.Debug(fullName);
Assert.Equal(@"C:\Code\mapdojo\Xyzt\MapManager\MapManager.UnitTests\bin\Debug\net461\Default\symbols.sym", fullName);
Assert.Equal(Path.Combine(SharedDirectory, "symbols.sym"), fullName);
}
}
}
7 changes: 7 additions & 0 deletions MapManager.UnitTests/MapManager.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputType>Exe</OutputType>
<IsTestProject>true</IsTestProject>

<IsPackable>false</IsPackable>

Expand All @@ -14,10 +15,16 @@
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.Sinks.XUnit3" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio" />
Comment on lines 17 to +18

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pin the xUnit adapter to a v3-capable version

When this project is restored without central package versions (there is no Directory.Packages.props in the repo), this versionless PackageReference does not mean “latest”; NuGet restores the lowest available version for an unbounded dependency (NU1604 docs). The xUnit v3 docs require xunit.runner.visualstudio 3.0+ for v3 support (xUnit package docs), so a clean restore can select a 2.x adapter and dotnet test/Test Explorer still won't discover the xunit.v3 tests. Please pin this package to >= 3.0.0 (or add a central version).

Useful? React with 👍 / 👎.

</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MapManager.Apis\MapManager.Apis.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\Default\**" Link="Default\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
<Content Include="..\MapManager\Shared\**" Link="Shared\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
Comment on lines +26 to +27

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Copy Shared resources to the directory Config uses

When a test or helper actually uses a shared map/font/symbol file, this copies ..\MapManager\Shared\** under the test output's Shared child because CopyToOutputDirectory respects Link metadata (MSBuild item docs). However MapManager.Apis.Config.Shared resolves shared files two parents above the assembly directory plus Shared (for example bin\Shared from bin\Debug\net48), so these copied files land in a directory the code never reads and SharedDefaultMap.File.Exists/file opens can still fail after build. Use a TargetPath or copy target that places them in the Shared directory that Config.Shared resolves.

Useful? React with 👍 / 👎.

</ItemGroup>

</Project>