55
66namespace Codebreaker . GameAPIs . Analyzer . Tests ;
77
8- // TODO: add more unit tests
98public class ShapeGame5x5x4AnalyzerTests
109{
10+
11+
1112 [ Fact ]
12- public void SetMoveShouldReturnThreeBlue ( )
13+ public void SetMoveShouldReturnTwoBlack ( )
14+ {
15+ ShapeAndColorResult expectedKeyPegs = new ( 2 , 0 , 0 ) ;
16+ ShapeAndColorResult ? resultKeyPegs = TestSkeleton (
17+ [ "Rectangle;Green" , "Circle;Yellow" , "Rectangle;Green" , "Circle;Yellow" ] ,
18+ [ "Rectangle;Green" , "Circle;Yellow" , "Star;Blue" , "Star;Blue" ]
19+ ) ;
20+
21+ Assert . Equal ( expectedKeyPegs , resultKeyPegs ) ;
22+ }
23+
24+ [ Fact ]
25+ public void SetMoveShouldReturnOneBlackWithMultipleCorrectCodes ( )
26+ {
27+ ShapeAndColorResult expectedKeyPegs = new ( 1 , 0 , 0 ) ;
28+ ShapeAndColorResult ? resultKeyPegs = TestSkeleton (
29+ [ "Rectangle;Green" , "Rectangle;Green" , "Rectangle;Green" , "Rectangle;Green" ] ,
30+ [ "Rectangle;Green" , "Star;Blue" , "Star;Blue" , "Star;Blue" ]
31+ ) ;
32+
33+ Assert . Equal ( expectedKeyPegs , resultKeyPegs ) ;
34+ }
35+
36+ [ Fact ]
37+ public void SetMoveShouldReturnOneBlackWithMultipleCorrectPairGuesses ( )
38+ {
39+ ShapeAndColorResult expectedKeyPegs = new ( 1 , 0 , 0 ) ;
40+ ShapeAndColorResult ? resultKeyPegs = TestSkeleton (
41+ [ "Rectangle;Green" , "Circle;Yellow" , "Circle;Yellow" , "Circle;Yellow" ] ,
42+ [ "Rectangle;Green" , "Rectangle;Green" , "Rectangle;Green" , "Rectangle;Green" ]
43+ ) ;
44+
45+ Assert . Equal ( expectedKeyPegs , resultKeyPegs ) ;
46+ }
47+
48+ [ Fact ]
49+ public void SetMoveShouldReturnThreeWhite ( )
1350 {
1451 ShapeAndColorResult expectedKeyPegs = new ( 0 , 3 , 0 ) ;
1552 ShapeAndColorResult ? resultKeyPegs = TestSkeleton (
@@ -20,48 +57,72 @@ public void SetMoveShouldReturnThreeBlue()
2057 Assert . Equal ( expectedKeyPegs , resultKeyPegs ) ;
2158 }
2259
23- //[InlineData(1, 2, Red, Yellow, Red, Blue)]
24- //[InlineData(2, 0, White, White, Blue, Red)]
25- //[Theory]
26- //public void SetMoveUsingVariousData(int expectedBlack, int expectedWhite, params string[] guessValues)
27- //{
28- // string[] code = new[] { Red, Green, Blue, Red };
29- // ColorResult expectedKeyPegs = new (expectedBlack, expectedWhite);
30- // ColorResult resultKeyPegs = TestSkeleton(code, guessValues);
31- // Assert.Equal(expectedKeyPegs, resultKeyPegs);
32- //}
33-
34- //[Theory]
35- //[ClassData(typeof(TestData6x4))]
36- //public void SetMoveUsingVariousDataUsingDataClass(string[] code, string[] guess, ColorResult expectedKeyPegs)
37- //{
38- // ColorResult actualKeyPegs = TestSkeleton(code, guess);
39- // Assert.Equal(expectedKeyPegs, actualKeyPegs);
40- //}
41-
42- //[Fact]
43- //public void ShouldThrowOnInvalidGuessCount()
44- //{
45- // Assert.Throws<ArgumentException>(() =>
46- // {
47- // TestSkeleton(
48- // new[] { "Black", "Black", "Black", "Black" },
49- // new[] { "Black" }
50- // );
51- // });
52- //}
53-
54- //[Fact]
55- //public void ShouldThrowOnInvalidGuessValues()
56- //{
57- // Assert.Throws<ArgumentException>(() =>
58- // {
59- // TestSkeleton(
60- // new[] { "Black", "Black", "Black", "Black" },
61- // new[] { "Black", "Der", "Blue", "Yellow" } // "Der" is the wrong value
62- // );
63- // });
64- //}
60+ [ Fact ]
61+ public void SetMoveShouldReturnOneWhiteWithMultipleCorrectPairIsGuesses ( )
62+ {
63+ ShapeAndColorResult expectedKeyPegs = new ( 0 , 1 , 0 ) ;
64+ ShapeAndColorResult ? resultKeyPegs = TestSkeleton (
65+ [ "Rectangle;Green" , "Circle;Yellow" , "Circle;Yellow" , "Circle;Yellow" ] ,
66+ [ "Triangle;Blue" , "Rectangle;Green" , "Rectangle;Green" , "Rectangle;Green" ]
67+ ) ;
68+
69+ Assert . Equal ( expectedKeyPegs , resultKeyPegs ) ;
70+ }
71+
72+ [ Fact ]
73+ public void SetMoveShouldReturnTwoBlueForMatchingColors ( )
74+ {
75+ // the second and third guess have a correct color in the correct position
76+ // all the shapes are incorrect
77+ ShapeAndColorResult expectedKeyPegs = new ( 0 , 0 , 2 ) ;
78+ ShapeAndColorResult ? resultKeyPegs = TestSkeleton (
79+ [ "Rectangle;Green" , "Circle;Yellow" , "Rectangle;Green" , "Circle;Yellow" ] ,
80+ [ "Star;Blue" , "Star;Yellow" , "Star;Green" , "Star;Blue" ]
81+ ) ;
82+
83+ Assert . Equal ( expectedKeyPegs , resultKeyPegs ) ;
84+ }
85+
86+ [ Fact ]
87+ public void SetMoveShouldReturnTwoBlueForMatchingShapesAndColors ( )
88+ {
89+ // the first guess has a correct shape, and the second guess a correct color. All other guesses are wrong.
90+ ShapeAndColorResult expectedKeyPegs = new ( 0 , 0 , 2 ) ;
91+ ShapeAndColorResult ? resultKeyPegs = TestSkeleton (
92+ [ "Rectangle;Green" , "Circle;Yellow" , "Rectangle;Green" , "Circle;Yellow" ] ,
93+ [ "Rectangle;Blue" , "Rectangle;Yellow" , "Star;Blue" , "Star;Blue" ]
94+ ) ;
95+
96+ Assert . Equal ( expectedKeyPegs , resultKeyPegs ) ;
97+ }
98+
99+ [ Fact ]
100+ public void SetMoveShouldReturnTwoBlueForMatchingShapes ( )
101+ {
102+ // the first and second guess have a correct shape, but a wrong color
103+ // all the colors are incorrect
104+ ShapeAndColorResult expectedKeyPegs = new ( 0 , 0 , 2 ) ;
105+ ShapeAndColorResult ? resultKeyPegs = TestSkeleton (
106+ [ "Rectangle;Green" , "Circle;Yellow" , "Rectangle;Green" , "Circle;Yellow" ] ,
107+ [ "Rectangle;Blue" , "Circle;Blue" , "Star;Blue" , "Star;Blue" ]
108+ ) ;
109+
110+ Assert . Equal ( expectedKeyPegs , resultKeyPegs ) ;
111+ }
112+
113+ [ Fact ]
114+ public void SetMoveShouldReturnOneBlackAndOneWhite ( )
115+ {
116+ // the first and second guess have a correct shape, but both in the wrong positon
117+ // all the colors are incorrect
118+ ShapeAndColorResult expectedKeyPegs = new ( 1 , 1 , 0 ) ;
119+ ShapeAndColorResult ? resultKeyPegs = TestSkeleton (
120+ [ "Rectangle;Blue" , "Circle;Yellow" , "Star;Green" , "Circle;Yellow" ] ,
121+ [ "Rectangle;Blue" , "Star;Green" , "Triangle;Red" , "Triangle;Red" ]
122+ ) ;
123+
124+ Assert . Equal ( expectedKeyPegs , resultKeyPegs ) ;
125+ }
65126
66127 private static ShapeAndColorResult TestSkeleton ( string [ ] codes , string [ ] guesses )
67128 {
0 commit comments