From 15fbc24ae3ef0e5dda168a18acae7ff10fd41e94 Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Fri, 13 Dec 2019 09:24:13 -0600 Subject: [PATCH 01/10] Create initial projects --- ...ettingStartedWithInterfacesAndMocks.csproj | 7 ++++++ ...gStartedWithInterfacesAndMocksTests.csproj | 17 ++++++++++++++ TestingPracticesWithExamples.sln | 22 ++++++++++++++----- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 GettingStartedWithInterfacesAndMocks/GettingStartedWithInterfacesAndMocks.csproj create mode 100644 GettingStartedWithInterfacesAndMocksTests/GettingStartedWithInterfacesAndMocksTests.csproj diff --git a/GettingStartedWithInterfacesAndMocks/GettingStartedWithInterfacesAndMocks.csproj b/GettingStartedWithInterfacesAndMocks/GettingStartedWithInterfacesAndMocks.csproj new file mode 100644 index 0000000..cb63190 --- /dev/null +++ b/GettingStartedWithInterfacesAndMocks/GettingStartedWithInterfacesAndMocks.csproj @@ -0,0 +1,7 @@ + + + + netcoreapp3.1 + + + diff --git a/GettingStartedWithInterfacesAndMocksTests/GettingStartedWithInterfacesAndMocksTests.csproj b/GettingStartedWithInterfacesAndMocksTests/GettingStartedWithInterfacesAndMocksTests.csproj new file mode 100644 index 0000000..176482e --- /dev/null +++ b/GettingStartedWithInterfacesAndMocksTests/GettingStartedWithInterfacesAndMocksTests.csproj @@ -0,0 +1,17 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + + + diff --git a/TestingPracticesWithExamples.sln b/TestingPracticesWithExamples.sln index 4dfbcaf..3df040c 100644 --- a/TestingPracticesWithExamples.sln +++ b/TestingPracticesWithExamples.sln @@ -3,7 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29609.76 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GettingStarted", "GettingStarted\GettingStarted.csproj", "{AAB66502-A5F2-40D8-BCB4-F7EDB0923640}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InterfacesAndMocks", "InterfacesAndMocks", "{42786B9F-B4BA-4D56-8104-D359C5E0E917}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GettingStartedWithInterfacesAndMocks", "GettingStartedWithInterfacesAndMocks\GettingStartedWithInterfacesAndMocks.csproj", "{22E941F6-26EC-47CE-84A7-0456BF6EF2A1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GettingStartedWithInterfacesAndMocksTests", "GettingStartedWithInterfacesAndMocksTests\GettingStartedWithInterfacesAndMocksTests.csproj", "{7BE9A85F-1902-4448-8023-9DC5EF821EE7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,14 +15,22 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AAB66502-A5F2-40D8-BCB4-F7EDB0923640}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AAB66502-A5F2-40D8-BCB4-F7EDB0923640}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AAB66502-A5F2-40D8-BCB4-F7EDB0923640}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AAB66502-A5F2-40D8-BCB4-F7EDB0923640}.Release|Any CPU.Build.0 = Release|Any CPU + {22E941F6-26EC-47CE-84A7-0456BF6EF2A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22E941F6-26EC-47CE-84A7-0456BF6EF2A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22E941F6-26EC-47CE-84A7-0456BF6EF2A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22E941F6-26EC-47CE-84A7-0456BF6EF2A1}.Release|Any CPU.Build.0 = Release|Any CPU + {7BE9A85F-1902-4448-8023-9DC5EF821EE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BE9A85F-1902-4448-8023-9DC5EF821EE7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BE9A85F-1902-4448-8023-9DC5EF821EE7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BE9A85F-1902-4448-8023-9DC5EF821EE7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {22E941F6-26EC-47CE-84A7-0456BF6EF2A1} = {42786B9F-B4BA-4D56-8104-D359C5E0E917} + {7BE9A85F-1902-4448-8023-9DC5EF821EE7} = {42786B9F-B4BA-4D56-8104-D359C5E0E917} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BA44BE1E-A335-4CCF-9ACF-D80E199328B3} EndGlobalSection From 75e209b2bd4b947f993d48ffaa94f1b8d3cc63df Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Fri, 13 Dec 2019 10:32:16 -0600 Subject: [PATCH 02/10] Add simple Die implementation --- .../DiceGame/Entities/Die.cs | 21 +++++++++++++++++++ .../DiceGame/Extensions/DieExtensions.cs | 11 ++++++++++ .../DiceGame/Extensions/DieRoller.cs | 15 +++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 GettingStartedWithInterfacesAndMocks/DiceGame/Entities/Die.cs create mode 100644 GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs create mode 100644 GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieRoller.cs diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Entities/Die.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Entities/Die.cs new file mode 100644 index 0000000..ec2f37f --- /dev/null +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Entities/Die.cs @@ -0,0 +1,21 @@ +using GettingStartedWithInterfacesAndMocks.DiceGame.Extensions; +using System; +using System.Collections.Generic; +using System.Text; + +namespace GettingStartedWithInterfacesAndMocks.DiceGame.Entities +{ + public class Die + { + public Die() + { + Roll(); + } + + public int Value { get; private set; } + public void Roll() + { + Value = DieRoller.GetD6Roll(); + } + } +} diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs new file mode 100644 index 0000000..a77bed6 --- /dev/null +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace GettingStartedWithInterfacesAndMocks.DiceGame.Extensions +{ + public static class DieExtensions + { + + } +} diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieRoller.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieRoller.cs new file mode 100644 index 0000000..523eb11 --- /dev/null +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieRoller.cs @@ -0,0 +1,15 @@ +using System; + +namespace GettingStartedWithInterfacesAndMocks.DiceGame.Extensions +{ + public static class DieRoller + { + static Random _rng = new Random(); + + public static int GetD6Roll() + { + return _rng.Next(1, 7); + } + + } +} From 5c658947ce4beb78f8e79382f5dea5136b270471 Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Fri, 13 Dec 2019 11:05:26 -0600 Subject: [PATCH 03/10] Add IsValidRoll method and some tests --- .../DiceGame/Extensions/DieExtensions.cs | 10 +++++-- .../DiceGame/Extensions/DieRoller.cs | 9 +++++- .../DieExtensionsTests.cs | 29 +++++++++++++++++++ ...gStartedWithInterfacesAndMocksTests.csproj | 4 +++ 4 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs index a77bed6..5306f29 100644 --- a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs @@ -1,11 +1,15 @@ -using System; +using GettingStartedWithInterfacesAndMocks.DiceGame.Entities; +using System; using System.Collections.Generic; -using System.Text; +using System.Linq; namespace GettingStartedWithInterfacesAndMocks.DiceGame.Extensions { public static class DieExtensions { - + public static bool IsValidRoll(this IEnumerable dice) + { + throw new NotImplementedException(); + } } } diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieRoller.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieRoller.cs index 523eb11..161edb6 100644 --- a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieRoller.cs +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieRoller.cs @@ -1,4 +1,7 @@ -using System; +using GettingStartedWithInterfacesAndMocks.DiceGame.Entities; +using System; +using System.Collections.Generic; +using System.Linq; namespace GettingStartedWithInterfacesAndMocks.DiceGame.Extensions { @@ -11,5 +14,9 @@ public static int GetD6Roll() return _rng.Next(1, 7); } + public static IEnumerable GetGameRoll() + { + return Enumerable.Range(1, 5).Select(_ => new Die()); + } } } diff --git a/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs b/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs new file mode 100644 index 0000000..993be06 --- /dev/null +++ b/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs @@ -0,0 +1,29 @@ +using FluentAssertions; +using GettingStartedWithInterfacesAndMocks.DiceGame.Entities; +using GettingStartedWithInterfacesAndMocks.DiceGame.Extensions; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Linq; + +namespace GettingStartedWithInterfacesAndMocksTests +{ + [TestClass] + public class DieExtensionsTests + { + [TestMethod] + public void IsValidRoll_RollHas4Dice_ReturnsFalse() + { + var dice = Enumerable.Range(1, 4).Select(_ => new Die()); + + dice.IsValidRoll().Should().BeFalse(because: "A valid game roll has five dice"); + } + + [TestMethod] + public void IsValidRoll_RollHas5Dice_ReturnsTrue() + { + var dice = Enumerable.Range(1, 5).Select(_ => new Die()); + + dice.IsValidRoll().Should().BeTrue(because: "A valid game roll has five dice"); + } + } +} diff --git a/GettingStartedWithInterfacesAndMocksTests/GettingStartedWithInterfacesAndMocksTests.csproj b/GettingStartedWithInterfacesAndMocksTests/GettingStartedWithInterfacesAndMocksTests.csproj index 176482e..7abe736 100644 --- a/GettingStartedWithInterfacesAndMocksTests/GettingStartedWithInterfacesAndMocksTests.csproj +++ b/GettingStartedWithInterfacesAndMocksTests/GettingStartedWithInterfacesAndMocksTests.csproj @@ -14,4 +14,8 @@ + + + + From 03f3dd603dcc814425a9b532c443a44ca02c74eb Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Fri, 13 Dec 2019 11:19:01 -0600 Subject: [PATCH 04/10] Make the failing tests pass for IsValidRoll --- .../DiceGame/Extensions/DieExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs index 5306f29..27e1a9c 100644 --- a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs @@ -9,7 +9,7 @@ public static class DieExtensions { public static bool IsValidRoll(this IEnumerable dice) { - throw new NotImplementedException(); + return dice.Count() == 5; } } } From 833d9d4a505d3f588ec1dbd0b25eb1f9aed58b90 Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Fri, 13 Dec 2019 11:27:43 -0600 Subject: [PATCH 05/10] Add IsFiveOfAKind method and some tests for it --- .../DiceGame/Extensions/DieExtensions.cs | 5 +++++ .../DieExtensionsTests.cs | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs index 27e1a9c..64a2a4c 100644 --- a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs @@ -11,5 +11,10 @@ public static bool IsValidRoll(this IEnumerable dice) { return dice.Count() == 5; } + + public static bool IsFiveOfAKind(this IEnumerable dice) + { + throw new NotImplementedException(); + } } } diff --git a/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs b/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs index 993be06..a02cc6c 100644 --- a/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs +++ b/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs @@ -2,7 +2,7 @@ using GettingStartedWithInterfacesAndMocks.DiceGame.Entities; using GettingStartedWithInterfacesAndMocks.DiceGame.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; +using System.Collections.Generic; using System.Linq; namespace GettingStartedWithInterfacesAndMocksTests @@ -25,5 +25,17 @@ public void IsValidRoll_RollHas5Dice_ReturnsTrue() dice.IsValidRoll().Should().BeTrue(because: "A valid game roll has five dice"); } + + [TestMethod] + public void IsFiveOfAKind_AllDiceAreTheSame_ReturnsTrue() + { + IEnumerable dice = null; //Uh oh... how do I create dice that are all the same? + } + + [TestMethod] + public void IsFiveOfAKind_AllDiceAreNotTheSame_ReturnsFalse() + { + + } } } From e5a39a0346e58b9a9bbb356d8e332808f06cdc38 Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Fri, 13 Dec 2019 11:36:16 -0600 Subject: [PATCH 06/10] Create IDie interface and use in methods --- .../DiceGame/Entities/Die.cs | 3 ++- .../DiceGame/Extensions/DieExtensions.cs | 6 +++--- .../DiceGame/Interfaces/IDie.cs | 10 ++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 GettingStartedWithInterfacesAndMocks/DiceGame/Interfaces/IDie.cs diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Entities/Die.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Entities/Die.cs index ec2f37f..224e568 100644 --- a/GettingStartedWithInterfacesAndMocks/DiceGame/Entities/Die.cs +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Entities/Die.cs @@ -1,11 +1,12 @@ using GettingStartedWithInterfacesAndMocks.DiceGame.Extensions; +using GettingStartedWithInterfacesAndMocks.DiceGame.Interfaces; using System; using System.Collections.Generic; using System.Text; namespace GettingStartedWithInterfacesAndMocks.DiceGame.Entities { - public class Die + public class Die : IDie { public Die() { diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs index 64a2a4c..45271ad 100644 --- a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs @@ -1,4 +1,4 @@ -using GettingStartedWithInterfacesAndMocks.DiceGame.Entities; +using GettingStartedWithInterfacesAndMocks.DiceGame.Interfaces; using System; using System.Collections.Generic; using System.Linq; @@ -7,12 +7,12 @@ namespace GettingStartedWithInterfacesAndMocks.DiceGame.Extensions { public static class DieExtensions { - public static bool IsValidRoll(this IEnumerable dice) + public static bool IsValidRoll(this IEnumerable dice) { return dice.Count() == 5; } - public static bool IsFiveOfAKind(this IEnumerable dice) + public static bool IsFiveOfAKind(this IEnumerable dice) { throw new NotImplementedException(); } diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Interfaces/IDie.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Interfaces/IDie.cs new file mode 100644 index 0000000..5d6b6e6 --- /dev/null +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Interfaces/IDie.cs @@ -0,0 +1,10 @@ +using System; + +namespace GettingStartedWithInterfacesAndMocks.DiceGame.Interfaces +{ + public interface IDie + { + void Roll(); + int Value { get; } + } +} From 02e08343017a52efb9ab66a097f7a7a13cf2ba45 Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Sun, 15 Dec 2019 10:14:47 -0600 Subject: [PATCH 07/10] Implement a settable die to use for testing --- .../TestingMocks/SettableD6.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 GettingStartedWithInterfacesAndMocksTests/TestingMocks/SettableD6.cs diff --git a/GettingStartedWithInterfacesAndMocksTests/TestingMocks/SettableD6.cs b/GettingStartedWithInterfacesAndMocksTests/TestingMocks/SettableD6.cs new file mode 100644 index 0000000..18b0939 --- /dev/null +++ b/GettingStartedWithInterfacesAndMocksTests/TestingMocks/SettableD6.cs @@ -0,0 +1,22 @@ +using GettingStartedWithInterfacesAndMocks.DiceGame.Interfaces; +using System; +using System.Collections.Generic; +using System.Text; + +namespace GettingStartedWithInterfacesAndMocksTests.TestingMocks +{ + public class SettableD6 : IDie + { + public SettableD6(int value) + { + Value = value; + } + + public int Value { get; set; } + + public void Roll() + { + //Does nothing + } + } +} From ef9daa34502a272f13561081f624ea387f9e34ab Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Sun, 15 Dec 2019 10:22:58 -0600 Subject: [PATCH 08/10] Implement tests for IsFiveOfAKind --- .../DieExtensionsTests.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs b/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs index a02cc6c..0d559a3 100644 --- a/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs +++ b/GettingStartedWithInterfacesAndMocksTests/DieExtensionsTests.cs @@ -1,7 +1,9 @@ using FluentAssertions; using GettingStartedWithInterfacesAndMocks.DiceGame.Entities; using GettingStartedWithInterfacesAndMocks.DiceGame.Extensions; +using GettingStartedWithInterfacesAndMocksTests.TestingMocks; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; using System.Collections.Generic; using System.Linq; @@ -29,13 +31,36 @@ public void IsValidRoll_RollHas5Dice_ReturnsTrue() [TestMethod] public void IsFiveOfAKind_AllDiceAreTheSame_ReturnsTrue() { - IEnumerable dice = null; //Uh oh... how do I create dice that are all the same? + var dice = Enumerable.Range(1, 5).Select(_ => new SettableD6(5)); + + dice.IsFiveOfAKind().Should().BeTrue(); } [TestMethod] public void IsFiveOfAKind_AllDiceAreNotTheSame_ReturnsFalse() { + var dice = new[]{ + new SettableD6(1), + new SettableD6(3), + new SettableD6(4), + new SettableD6(1), + new SettableD6(1) + }; + + dice.IsFiveOfAKind().Should().BeFalse(); + } + + [TestMethod] + public void IsFiveOfAKind_NotAValidRoll_ThrowsArgumentException() + { + var dice = new[]{ + new SettableD6(2), + new SettableD6(3) + }; + + Action validateRoll = () => dice.IsFiveOfAKind(); + validateRoll.Should().Throw(); } } } From 98139d3a8772f3ea7167f795d5f056a6d4fd5015 Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Sun, 15 Dec 2019 10:28:04 -0600 Subject: [PATCH 09/10] Implement valid roll check in IsFiveOfAKind --- .../DiceGame/Extensions/DieExtensions.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs index 45271ad..88f163f 100644 --- a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs @@ -14,6 +14,11 @@ public static bool IsValidRoll(this IEnumerable dice) public static bool IsFiveOfAKind(this IEnumerable dice) { + if (!dice.IsValidRoll()) + { + throw new ArgumentException("A valid roll must contain exactly five dice"); + } + throw new NotImplementedException(); } } From 999b5e73b0ea91d993f7000555d16b779cf4b6f8 Mon Sep 17 00:00:00 2001 From: Nate Adams Date: Sun, 15 Dec 2019 10:29:45 -0600 Subject: [PATCH 10/10] Implement IsFiveOfAKind check --- .../DiceGame/Extensions/DieExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs index 88f163f..f7dfa14 100644 --- a/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs +++ b/GettingStartedWithInterfacesAndMocks/DiceGame/Extensions/DieExtensions.cs @@ -19,7 +19,7 @@ public static bool IsFiveOfAKind(this IEnumerable dice) throw new ArgumentException("A valid roll must contain exactly five dice"); } - throw new NotImplementedException(); + return dice.GroupBy(d => d.Value).Count() == 1; } } }