From a84b0d07f063fc2e013c3c71af196d40a526c82b Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Thu, 7 Dec 2023 14:06:26 -0600
Subject: [PATCH] feat: solve part 1
---
07/CamelCards.Tests/CamelCards.Tests.csproj | 36 ++++
07/CamelCards.Tests/CardTests.cs | 31 +++
07/CamelCards.Tests/GlobalUsings.cs | 2 +
07/CamelCards.Tests/HandTests.cs | 204 ++++++++++++++++++++
07/CamelCards.Tests/ProgramTests.cs | 11 ++
07/CamelCards.Tests/TurnTests.cs | 95 +++++++++
07/CamelCards/CamelCards.csproj | 10 +
07/CamelCards/Program.cs | 173 +++++++++++++++++
AdventOfCode2023.sln | 16 ++
9 files changed, 578 insertions(+)
create mode 100644 07/CamelCards.Tests/CamelCards.Tests.csproj
create mode 100644 07/CamelCards.Tests/CardTests.cs
create mode 100644 07/CamelCards.Tests/GlobalUsings.cs
create mode 100644 07/CamelCards.Tests/HandTests.cs
create mode 100644 07/CamelCards.Tests/ProgramTests.cs
create mode 100644 07/CamelCards.Tests/TurnTests.cs
create mode 100644 07/CamelCards/CamelCards.csproj
create mode 100644 07/CamelCards/Program.cs
diff --git a/07/CamelCards.Tests/CamelCards.Tests.csproj b/07/CamelCards.Tests/CamelCards.Tests.csproj
new file mode 100644
index 0000000..9005157
--- /dev/null
+++ b/07/CamelCards.Tests/CamelCards.Tests.csproj
@@ -0,0 +1,36 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
diff --git a/07/CamelCards.Tests/CardTests.cs b/07/CamelCards.Tests/CardTests.cs
new file mode 100644
index 0000000..28bb3d0
--- /dev/null
+++ b/07/CamelCards.Tests/CardTests.cs
@@ -0,0 +1,31 @@
+namespace CamelCards.Tests;
+
+public class CardTests
+{
+ [Theory]
+ [InlineData('A', 12)]
+ [InlineData('K', 11)]
+ [InlineData('Q', 10)]
+ [InlineData('J', 9)]
+ [InlineData('T', 8)]
+ [InlineData('9', 7)]
+ [InlineData('8', 6)]
+ [InlineData('7', 5)]
+ [InlineData('6', 4)]
+ [InlineData('5', 3)]
+ [InlineData('4', 2)]
+ [InlineData('3', 1)]
+ [InlineData('2', 0)]
+ public void Card_WhenGivenValidCharacter_ItShouldReturnCardWithExpectedStrength(char character, int expectedStrength)
+ {
+ var card = new Card(character);
+ card.Strength.Should().Be(expectedStrength);
+ }
+
+ [Fact]
+ public void Card_WhenGivenInvalidCardCharacter_ItShouldThrowArgumentException()
+ {
+ Action act = () => new Card('X');
+ act.Should().Throw();
+ }
+}
\ No newline at end of file
diff --git a/07/CamelCards.Tests/GlobalUsings.cs b/07/CamelCards.Tests/GlobalUsings.cs
new file mode 100644
index 0000000..7fef4b0
--- /dev/null
+++ b/07/CamelCards.Tests/GlobalUsings.cs
@@ -0,0 +1,2 @@
+global using Xunit;
+global using FluentAssertions;
\ No newline at end of file
diff --git a/07/CamelCards.Tests/HandTests.cs b/07/CamelCards.Tests/HandTests.cs
new file mode 100644
index 0000000..6f75abc
--- /dev/null
+++ b/07/CamelCards.Tests/HandTests.cs
@@ -0,0 +1,204 @@
+namespace CamelCards.Tests;
+
+public class HandTests
+{
+ [Theory]
+ [MemberData(nameof(TestData.HandTypeTestData), MemberType = typeof(TestData))]
+ public void Type_WhenGivenListOfCards_ItShouldReturnExpectedHandType(List cards, HandType expectedHandType)
+ {
+ var hand = new Hand(cards);
+ hand.Type.Should().Be(expectedHandType);
+ }
+
+ [Theory]
+ [MemberData(nameof(TestData.CompareToTestData), MemberType = typeof(TestData))]
+ public void CompareTo_WhenGivenHandWithHigherType_ItShouldReturnNegative1(Hand hand, Hand otherHand, int sortResult)
+ {
+ hand.CompareTo(otherHand).Should().Be(sortResult);
+ }
+
+ public static class TestData
+ {
+ public static IEnumerable