Files
minesweeper-codex/tests/Minesweeper.Tests/DifficultyTests.cs
T
drobor-ai 2ba405b19c Initial commit: terminal Minesweeper in C# for .NET 10
A playable console Minesweeper (arrow keys, chording, flags, question marks,
pause, difficulty presets) plus a deduction-and-guess solver that can play the
game headlessly. Game logic lives in src/Minesweeper/Game and has no console
dependencies, so it is covered by 65 unit tests.

Includes publishing helpers for self-contained, trimmed single-file binaries
(publish.sh) and an .editorconfig that the sources conform to: UTF-8 BOM and
4-space indents for C#, 2-space indents for project files, LF endings and
2-space indents for shell scripts, System-first usings, no redundant `this.`,
and s_/ _ prefixed private static and instance fields.
2026-09-08 07:12:51 +00:00

53 lines
1.6 KiB
C#

using Minesweeper.Game;
using Xunit;
namespace Minesweeper.Tests;
public class DifficultyTests
{
[Theory]
[InlineData("beginner", 9, 9, 10)]
[InlineData("NOVICE", 9, 9, 10)]
[InlineData("1", 9, 9, 10)]
[InlineData("intermediate", 16, 16, 40)]
[InlineData("normal", 16, 16, 40)]
[InlineData("2", 16, 16, 40)]
[InlineData("expert", 30, 16, 99)]
[InlineData("e", 30, 16, 99)]
[InlineData("3", 30, 16, 99)]
[InlineData("14x10x25", 14, 10, 25)]
[InlineData("12x8", 12, 8, 14)]
[InlineData("10,10,20", 10, 10, 20)]
public void NamesResolve(string value, int width, int height, int mines)
{
Assert.True(DifficultyProfile.TryResolve(value, out var profile, out var error));
Assert.Null(error);
Assert.Equal(width, profile!.Width);
Assert.Equal(height, profile.Height);
Assert.Equal(mines, profile.Mines);
}
[Theory]
[InlineData("")]
[InlineData(" ")]
[InlineData("banana")]
[InlineData("16x16x900")]
[InlineData("300x300x10")]
[InlineData("16x16xzero")]
public void BadNamesAreRejected(string value)
{
Assert.False(DifficultyProfile.TryResolve(value, out var profile, out var error));
Assert.Null(profile);
Assert.False(string.IsNullOrWhiteSpace(error));
}
[Fact]
public void PresetsMatchTheClassicBoards()
{
Assert.Equal(
new[] { "Beginner", "Intermediate", "Expert" },
DifficultyProfile.Presets.Select(preset => preset.Name));
Assert.Equal("30x16", DifficultyProfile.Expert.SizeLabel);
}
}