Ejemplo n.º 1
0
        public void NoItemsNoScore()
        {
            // Arrange
            var column1 = new ObservableCollection<Tile>();
            var column2 = new ObservableCollection<Tile>();
            var column3 = new ObservableCollection<Tile>();
            var columns = new List<ObservableCollection<Tile>>() { column1, column2, column3 };

            // Act
            var score = new ScoreChecker().CheckScoreAndUpdate(columns);

            // Assert
            Assert.AreEqual(0, score);
            Assert.AreEqual(0, column1.Count);
            Assert.AreEqual(0, column2.Count);
            Assert.AreEqual(0, column3.Count);
        }
Ejemplo n.º 2
0
        public void FiveInAColumnIsAMatch()
        {
            // Arrange
            var column1 = new ObservableCollection<Tile>() { Tile("2"), Tile("3"), Tile("4"), Tile("5") };
            var column2 = new ObservableCollection<Tile>() { Tile("2"), Tile("2"), Tile("2"), Tile("2"), Tile("2") };
            var column3 = new ObservableCollection<Tile>() { Tile("1") };
            var columns = new List<ObservableCollection<Tile>>() { column1, column2, column3 };

            // Act
            var score = new ScoreChecker().CheckScoreAndUpdate(columns);

            // Assert
            Assert.AreEqual(400, score);
            Assert.AreEqual(4, column1.Count);
            Assert.AreEqual(0, column2.Count);
            Assert.AreEqual(1, column3.Count);
        }
Ejemplo n.º 3
0
        public void MatchOnlyCountsForColumnEvenIfItRunsIntoNextColumn()
        {
            // Arrange
            var column1 = new ObservableCollection<Tile>();
            var column2 = new ObservableCollection<Tile>();
            var column3 = new ObservableCollection<Tile>();
            var column4 = new ObservableCollection<Tile>();

            var column5 = new ObservableCollection<Tile>() { Tile("1"), Tile("2"), Tile("2"), Tile("2") };
            var column6 = new ObservableCollection<Tile>() { Tile("2") };
            var columns = new List<ObservableCollection<Tile>>() { column1, column2, column3, column4, column5, column6 };

            // Act
            var score = new ScoreChecker().CheckScoreAndUpdate(columns);

            // Assert
            Assert.AreEqual(100, score);
            Assert.AreEqual(0, column1.Count);
            Assert.AreEqual(0, column2.Count);
            Assert.AreEqual(0, column3.Count);
            Assert.AreEqual(0, column4.Count);
            Assert.AreEqual(1, column5.Count);
            Assert.AreEqual(1, column6.Count);
        }
Ejemplo n.º 4
0
        public void MatchCanBeMadeOnLowerRow()
        {
            // Arrange
            var column1 = new ObservableCollection<Tile>();
            var column2 = new ObservableCollection<Tile>();
            var column3 = new ObservableCollection<Tile>(){  Tile("1") };
            var column4 = new ObservableCollection<Tile>(){  Tile("1") };
            var column5 = new ObservableCollection<Tile>() { Tile("1"), Tile("5") };
            var column6 = new ObservableCollection<Tile>();
            var column7 = new ObservableCollection<Tile>();
            var columns = new List<ObservableCollection<Tile>>() { column1, column2, column3, column4, column5, column6, column7 };

            // Act
            var score = new ScoreChecker().CheckScoreAndUpdate(columns);

            // Assert
            Assert.AreEqual(100, score);
            Assert.AreEqual(0, column1.Count);
            Assert.AreEqual(0, column2.Count);
            Assert.AreEqual(0, column3.Count);
            Assert.AreEqual(0, column4.Count);
            Assert.AreEqual(1, column5.Count);
            Assert.AreEqual(0, column6.Count);
            Assert.AreEqual(0, column7.Count);
        }
Ejemplo n.º 5
0
        public void HorizontalRunOfFourScoresWhenNotAtTopOfColumn()
        {
            // Arrange
            var column1 = new ObservableCollection<Tile>();
            var column2 = new ObservableCollection<Tile>(){  Tile("3"), Tile("1"), Tile("4"), Tile("2")};;
            var column3 = new ObservableCollection<Tile>(){  Tile("5"), Tile("1")};
            var column4 = new ObservableCollection<Tile>(){  Tile("2"), Tile("1"), Tile("5") };
            var column5 = new ObservableCollection<Tile>() { Tile("3"), Tile("1"), Tile("4"), Tile("2") };
            var columns = new List<ObservableCollection<Tile>>() { column1, column2, column3, column4, column5 };

            // Act
            var score = new ScoreChecker().CheckScoreAndUpdate(columns);

            // Assert
            Assert.AreEqual(250, score);
            Assert.AreEqual(0, column1.Count);
            Assert.AreEqual(3, column2.Count);
            Assert.AreEqual(1, column3.Count);
            Assert.AreEqual(2, column4.Count);
            Assert.AreEqual(3, column5.Count);
        }
Ejemplo n.º 6
0
        public void HorizontalMatchAtEndWithPopulatedColumsIsAScore()
        {
            // Arrange
            var column1 = new ObservableCollection<Tile>();
            var column2 = new ObservableCollection<Tile>(){  Tile("1"), Tile("3"), Tile("4"), Tile("1")};;
            var column3 = new ObservableCollection<Tile>(){  Tile("1"), Tile("1")};
            var column4 = new ObservableCollection<Tile>(){  Tile("2"), Tile("1") };
            var column5 = new ObservableCollection<Tile>() { Tile("3"), Tile("1") };
            var columns = new List<ObservableCollection<Tile>>() { column1, column2, column3, column4, column5 };

            // Act
            var score = new ScoreChecker().CheckScoreAndUpdate(columns);

            // Assert
            Assert.AreEqual(100, score);
            Assert.AreEqual(0, column1.Count);
            Assert.AreEqual(4, column2.Count);
            Assert.AreEqual(1, column3.Count);
            Assert.AreEqual(1, column4.Count);
            Assert.AreEqual(1, column5.Count);
        }
Ejemplo n.º 7
0
        public void MatchFollowedByEmptyColumnFollowedByPopulatedColumnIsAScore()
        {
            // Arrange
            var column1 = new ObservableCollection<Tile>();
            var column2 = new ObservableCollection<Tile>();
            var column3 = new ObservableCollection<Tile>(){  Tile("2"), Tile("2"), Tile("2") };
            var column4 = new ObservableCollection<Tile>();
            var column5 = new ObservableCollection<Tile>() { Tile("1") };
            var columns = new List<ObservableCollection<Tile>>() { column1, column2, column3, column4, column5 };

            // Act
            var score = new ScoreChecker().CheckScoreAndUpdate(columns);

            // Assert
            Assert.AreEqual(100, score);
            Assert.AreEqual(0, column1.Count);
            Assert.AreEqual(0, column2.Count);
            Assert.AreEqual(0, column3.Count);
            Assert.AreEqual(0, column4.Count);
            Assert.AreEqual(1, column5.Count);
        }
Ejemplo n.º 8
0
 private void CheckScore()
 {
     var lastScore = 0;
     var scoreChecker = new ScoreChecker ();
     do {
         lastScore = scoreChecker.CheckScoreAndUpdate (_columns);
         Score += lastScore;
         if (lastScore > 0)
         {
             Scored.Invoke (this, new ScoreEventArgs (scoreChecker.RemovedItems));
         }
     }
     while (lastScore > 0);
 }