Ejemplo n.º 1
0
        public void GetScoreShouldShouldReturnMultipleScoreCategoryObjects()
        {
            sut = new Scoresheet(MockedFactory.Object);

            List <int> faceValues1 = new List <int>()
            {
                1, 1, 1, 1, 1
            };
            CategoryScore expected1 = BuildCategoryScore(ScoreCategory.Aces, m_defaultScore, faceValues1);

            List <int> faceValues2 = new List <int>()
            {
                2, 2, 2, 2, 2
            };
            CategoryScore expected2 = BuildCategoryScore(ScoreCategory.Twos, m_defaultScore, faceValues2);

            IPlayer player = MockedPlayerFactory.Object;

            sut.RegisterScore(player, ScoreCategory.Aces, faceValues1);
            sut.RegisterScore(player, ScoreCategory.Twos, faceValues2);

            CategoryScore actual1 = sut.GetScore(player, ScoreCategory.Aces);
            CategoryScore actual2 = sut.GetScore(player, ScoreCategory.Twos);

            Assert.True(CategoryScoresEqual(expected1, actual1) && CategoryScoresEqual(expected2, actual2));
        }
Ejemplo n.º 2
0
        public void GetScoreShouldShouldReturnAScoreCategoryObject()
        {
            /*
             * We realize that we are "testing" another class here that we have not mocked.
             * The reason for this is that we cannot in a clean way mock an internal class being returned.
             * We could mock the sut and change the return type, but then we're no longer testing the sut.
             * We could add a factory creating CategoryScores, but then how do we test that factory?
             * Then the factory itself will need a factory, and that factory will need its own factory, and you see where this is going.
             * We also believe that the class CategoryScore is rather trivial (e.g. it has no methods) which helps justify this approach.
             */

            sut = new Scoresheet(MockedFactory.Object);

            List <int> faceValues = new List <int>()
            {
                1, 1, 1, 1, 1
            };
            CategoryScore expected = BuildCategoryScore(ScoreCategory.Aces, m_defaultScore, faceValues);

            IPlayer player = MockedPlayerFactory.Object;

            sut.RegisterScore(player, ScoreCategory.Aces, faceValues);

            CategoryScore actual = sut.GetScore(player, ScoreCategory.Aces);

            Assert.True(CategoryScoresEqual(expected, actual));
        }
Ejemplo n.º 3
0
 public void ConstructorShouldThrowNullArgumentExceptionIfNotGivenAScoreFactory()
 {
     Assert.Throws <ArgumentNullException>(delegate()
     {
         sut = new Scoresheet(null);
     });
 }
Ejemplo n.º 4
0
        public void GetScoreShouldShouldThrowWhenNotGivenAPlayer()
        {
            sut = new Scoresheet(MockedFactory.Object);

            Assert.Throws <ArgumentNullException>(delegate()
            {
                sut.GetScore(null, ScoreCategory.Aces);
            });
        }
Ejemplo n.º 5
0
        public void RegisterScoreShouldThrowWhenNotGivenAPlayer()
        {
            sut = new Scoresheet(MockedFactory.Object);

            Assert.Throws <ArgumentNullException>(delegate()
            {
                sut.RegisterScore(null, ScoreCategory.Aces, new List <int> {
                    1, 1, 1, 1, 1
                });
            });
        }
Ejemplo n.º 6
0
 public EntityHandler(Scoresheet scoresheet, Rectangle playArea)
 {
     this.scoresheet = scoresheet;
     this.playArea   = playArea;
     EntityList      = new List <Entity>();
 }