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
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="xunit.v3" Version="3.2.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EverySecondTurnSolver\EverySecondTurnSolver.csproj" />
</ItemGroup>

</Project>
161 changes: 161 additions & 0 deletions DotNet/EverySecondTurnSolver.Tests/EverySecondTurnSolverTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
using Xunit;

namespace EverySecondTurnSolver.Tests;

public class EverySecondTurnSolverTest
{
private const char X = EverySecondTurnSolver.Circle;
private const char _ = EverySecondTurnSolver.Empty;

[Fact]
public void TestSolution_6_6_37g81()
{
// https://gridpuzzle.com/every-second-turn/37g81
var gridData = new char[,]
{
{ _, _, _, _, _, X },
{ _, X, _, _, _, _ },
{ _, _, _, _, X, _ },
{ X, _, _, X, _, _ },
{ _, _, X, _, _, X },
{ X, _, _, _, _, _ },
};

const string expectedSolutionStr =
" ┌──────────────┐ \n" +
" │ ┌────────┐ │ \n" +
" │ │ ┌─────┘ │ \n" +
" └──┘ │ ┌─────┘ \n" +
" ┌─────┘ └─────┐ \n" +
" └──────────────┘ ";

var solver = new EverySecondTurnSolver(gridData);
var solution = solver.GetSolution();
Assert.NotNull(solution);
Assert.Equal(expectedSolutionStr, solution.ToString());

var otherSolution = solver.GetOtherSolution();
Assert.True(otherSolution == null || otherSolution.Rows == 0);
}

[Fact]
public void TestSolution_6_6_3e9k2()
{
// https://gridpuzzle.com/every-second-turn/3e9k2
var gridData = new char[,]
{
{ X, _, _, _, _, _ },
{ _, _, _, _, _, X },
{ _, _, X, _, _, _ },
{ _, _, _, _, X, _ },
{ _, X, _, _, _, _ },
{ _, _, _, _, _, X }
};

const string expectedSolutionStr =
" ┌──────────────┐ \n" +
" │ ┌───────────┘ \n" +
" │ │ ┌────────┐ \n" +
" │ │ └─────┐ │ \n" +
" │ └────────┘ │ \n" +
" └──────────────┘ ";

var solver = new EverySecondTurnSolver(gridData);
var solution = solver.GetSolution();
Assert.NotNull(solution);
Assert.Equal(expectedSolutionStr, solution.ToString());

var otherSolution = solver.GetOtherSolution();
Assert.True(otherSolution == null || otherSolution.Rows == 0);
}

[Fact]
public void TestSolution_10_10_0ygm8()
{
// https://gridpuzzle.com/every-second-turn/0ygm8
var gridData = new[,]
{
{ X, _, _, _, _, X, _, _, X, _ },
{ _, _, _, X, _, _, _, X, _, _ },
{ _, _, X, _, _, _, X, _, _, _ },
{ _, X, _, _, X, _, _, _, X, _ },
{ X, _, _, _, X, _, _, _, _, _ },
{ _, _, _, _, _, _, _, _, X, _ },
{ _, X, _, X, _, _, X, _, _, _ },
{ _, _, _, X, _, X, _, X, _, X },
{ _, X, _, _, X, _, _, _, X, _ },
{ _, _, X, _, _, _, _, _, _, X }
};

const string expectedSolutionStr =
" ┌───────────┐ ┌─────┐ ┌──┐ \n" +
" │ ┌─────┐ │ │ ┌──┘ │ │ \n" +
" │ │ ┌──┘ │ │ └─────┘ │ \n" +
" └──┘ │ ┌──┘ └────────┐ │ \n" +
" ┌──┐ │ │ ┌───────────┘ │ \n" +
" │ │ │ │ └───────────┐ │ \n" +
" │ └──┘ └─────┐ ┌─────┘ │ \n" +
" │ ┌─────┐ ┌──┘ └──┐ ┌──┘ \n" +
" │ └──┐ │ └────────┘ └──┐ \n" +
" └─────┘ └─────────────────┘ ";

var solver = new EverySecondTurnSolver(gridData);
var solution = solver.GetSolution();
Assert.NotNull(solution);
Assert.Equal(expectedSolutionStr, solution.ToString());

var otherSolution = solver.GetOtherSolution();
Assert.True(otherSolution == null || otherSolution.Rows == 0);
}

[Fact]
public void TestSolution_16_16_0zny2()
{
// https://gridpuzzle.com/every-second-turn/0zny2
var gridData = new[,]
{
{ X, _, X, _, X, _, X, _, _, _, _, _, _, _, X, _ },
{ _, _, _, _, _, X, _, _, X, _, _, _, X, _, _, _ },
{ _, _, _, X, _, _, _, X, _, X, _, _, _, X, _, _ },
{ _, _, _, X, _, X, X, _, _, _, _, X, _, _, _, X },
{ _, X, _, _, X, _, _, _, X, _, X, _, X, _, X, _ },
{ _, _, _, _, X, _, _, _, _, X, _, X, _, X, _, _ },
{ X, _, _, _, _, X, _, _, _, _, _, X, _, _, X, _ },
{ _, X, _, X, X, _, _, X, _, X, X, _, X, _, _, X },
{ X, _, X, _, _, X, _, _, _, X, _, _, X, X, _, _ },
{ _, _, X, _, _, X, _, X, _, _, _, X, _, _, _, X },
{ X, _, _, _, X, _, _, _, X, _, _, X, _, X, _, _ },
{ _, X, _, _, _, _, X, _, X, _, X, _, _, _, X, _ },
{ _, _, X, X, _, _, _, X, _, _, X, _, _, X, _, _ },
{ X, _, _, _, _, X, X, _, _, X, _, _, X, _, _, X },
{ _, X, _, _, X, _, _, X, X, _, _, X, _, _, _, _ },
{ _, _, _, X, _, _, X, _, _, X, _, _, _, _, _, X }
};

const string expectedSolutionStr =
" ┌──┐ ┌──┐ ┌──┐ ┌────────────────────┐ ┌──┐ \n" +
" │ │ │ │ │ └──┘ ┌──┐ ┌────────┐ │ │ │ \n" +
" │ │ │ └──┘ ┌─────┘ │ └─────┐ │ └──┘ │ \n" +
" │ │ └──┐ ┌──┘ ┌─────┘ ┌─────┘ └────────┘ \n" +
" │ └─────┘ └──┐ │ ┌──┐ │ ┌──┐ ┌──┐ ┌──┐ \n" +
" └───────────┐ │ │ │ │ └──┘ └──┘ └──┘ │ \n" +
" ┌────────┐ └──┘ │ │ │ ┌─────┐ ┌─────┐ │ \n" +
" └──┐ ┌──┘ ┌──┐ └──┘ └──┘ ┌──┘ └──┐ └──┘ \n" +
" ┌──┘ └──┐ │ └────────┐ ┌──┘ ┌──┐ └─────┐ \n" +
" └─────┐ │ └──┐ ┌──┐ │ │ ┌──┘ │ ┌─────┘ \n" +
" ┌──┐ │ │ ┌──┘ │ │ └──┘ │ ┌──┘ └─────┐ \n" +
" │ └──┘ │ └─────┘ └──┐ ┌──┘ │ ┌─────┐ │ \n" +
" └─────┐ └────────┐ ┌──┘ │ ┌──┘ │ ┌──┘ │ \n" +
" ┌──┐ │ ┌─────┐ └──┘ ┌──┘ │ ┌──┘ └─────┘ \n" +
" │ └──┘ │ ┌──┘ ┌──┐ └──┐ │ └───────────┐ \n" +
" └────────┘ └─────┘ └─────┘ └──────────────┘ ";

var solver = new EverySecondTurnSolver(gridData);
var solution = solver.GetSolution();
Assert.NotNull(solution);
Assert.Equal(expectedSolutionStr, solution.ToString());

var otherSolution = solver.GetOtherSolution();
Assert.True(otherSolution == null || otherSolution.Rows == 0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("EverySecondTurnSolver.Tests")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d6901cb504262cbf162f69223fdcc3169a0e063f")]
[assembly: System.Reflection.AssemblyProductAttribute("EverySecondTurnSolver.Tests")]
[assembly: System.Reflection.AssemblyTitleAttribute("EverySecondTurnSolver.Tests")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyMetadata("Microsoft.Testing.Platform.Application", "true")]

// Généré par la classe MSBuild WriteCodeFragment.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2dcd871c63c72f873bb515cdc86fce434d7639058a53b7cdabbf138195008c08
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
is_global = true
build_property.TargetFramework = net10.0
build_property.TargetFrameworkIdentifier = .NETCoreApp
build_property.TargetFrameworkVersion = v10.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = EverySecondTurnSolver.Tests
build_property.ProjectDir = G:\projets infos\PuzzleGames\DotNet\EverySecondTurnSolver.Tests\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 10.0
build_property.EnableCodeStyleSeverity =
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a63d5e7d209e53f6c9bd8f7c0d3f6663cdf2f535b8e224f64d5fe74b1064c8bb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0de06d97a9c41eb92ad31ff5dde7edac9fbf796d148b5c7b187cda2ccdadb7b9
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
63cac8cbb351e959af87cbbbb3d95aed20d56c496fe77e86e913f8b73c12221a
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Microsoft.Testing.Platform.MSBuild
// </auto-generated>
//------------------------------------------------------------------------------

namespace EverySecondTurnSolver.Tests
{
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
internal static class SelfRegisteredExtensions
{
public static void AddSelfRegisteredExtensions(this global::Microsoft.Testing.Platform.Builder.ITestApplicationBuilder builder, string[] args)
{
global::Microsoft.Testing.Platform.MSBuild.TestingPlatformBuilderHook.AddExtensions(builder, args);
global::Microsoft.Testing.Extensions.Telemetry.TestingPlatformBuilderHook.AddExtensions(builder, args);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// <auto-generated> This file has been auto generated by xunit.v3.msbuildtasks. </auto-generated>

namespace EverySecondTurnSolver.Tests.AutoGenerated
{
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
internal class XunitAutoGeneratedEntryPoint
{
public static int Main(string[] args)
{
if (global::System.Linq.Enumerable.Any(args, arg => arg == "--server" || arg == "--internal-msbuild-node"))
return global::Xunit.MicrosoftTestingPlatform.TestPlatformTestFramework.RunAsync(args, SelfRegisteredExtensions.AddSelfRegisteredExtensions).GetAwaiter().GetResult();
else
return global::Xunit.Runner.InProc.SystemConsole.ConsoleRunner.Run(args).GetAwaiter().GetResult();
}
}
}
Loading
Loading