Ejemplo n.º 1
0
        [InlineData(20, 11)] //// Huge width, not divisible three
        public void TestGetColumnToHandleRarelyReturnsSameColumnForTwoPlayersAfterSecondTime(int width, int numberOfPlayers)
        {
            // Arrange
            Assert.False(width < numberOfPlayers);
            var handledColumns = new HashSet <int>();
            int repeatCount    = 0;

            // Act
            for (int k = 0; k < numberOfPlayers; ++k)
            {
                var columnGenerator = new ColumnGenerator(k, width, numberOfPlayers);

                int col1 = columnGenerator.GetColumnToHandle(1);
                int col2 = columnGenerator.GetColumnToHandle(2);
                repeatCount += handledColumns.Contains(col1) ? 1 : 0;
                repeatCount += handledColumns.Contains(col2) ? 1 : 0;
                handledColumns.Add(col1);
                handledColumns.Add(col2);
            }

            // Assert
            int val = Math.Max((numberOfPlayers * 2) - width, numberOfPlayers * 2 / width);

            Assert.True(repeatCount <= val, $"Should not repeat, \n expected {repeatCount} <= {val} ");
        }
Ejemplo n.º 2
0
        [InlineData(40, 11)] //// Huge width, not divisible three
        public void TestGetColumnToHandleNeverReturnsSameColumnForTwoPlayersInitialy(int width, int numberOfPlayers)
        {
            Assert.False(width < numberOfPlayers);

            // A & A & A
            var handledColumns = new HashSet <int>();

            for (int k = 0; k < numberOfPlayers; ++k)
            {
                var columnGenerator = new ColumnGenerator(k, width, numberOfPlayers);
                int col             = columnGenerator.GetColumnToHandle(1);
                Assert.DoesNotContain(col, handledColumns);
                handledColumns.Add(col);
            }
        }
Ejemplo n.º 3
0
 [InlineData(15, 20)] //// Huge number of players
 public void TestGetColumnToHandleNeverReturnsSameColumnForParticularPlayer(int width, int numberOfPlayers)
 {
     // A & A & A
     for (int k = 0; k < numberOfPlayers; ++k)
     {
         var columnGenerator = new ColumnGenerator(k, width, numberOfPlayers);
         var handledColumns  = new HashSet <int>();
         for (int i = 1; i <= width; ++i)
         {
             int col = columnGenerator.GetColumnToHandle(i);
             Assert.DoesNotContain(col, handledColumns);
             handledColumns.Add(col);
         }
     }
 }