Exemple #1
0
        public void Calculate_ShouldOnlyCountChosenScore(int correctInput, int incorrectInput, int expected)
        {
            //Create mockdice
            Mock <IDie> mockDie1 = new Mock <IDie>();
            Mock <IDie> mockDie2 = new Mock <IDie>();
            Mock <IDie> mockDie3 = new Mock <IDie>();
            Mock <IDie> mockDie4 = new Mock <IDie>();
            Mock <IDie> mockDie5 = new Mock <IDie>();

            mockDie1.Setup(x => x.Value).Returns(correctInput);
            mockDie2.Setup(x => x.Value).Returns(correctInput);
            mockDie3.Setup(x => x.Value).Returns(correctInput);
            mockDie4.Setup(x => x.Value).Returns(incorrectInput);
            mockDie5.Setup(x => x.Value).Returns(incorrectInput);

            //Create a dicelist
            List <IDie> diceList = new List <IDie>
            {
                mockDie1.Object,
                mockDie2.Object,
                mockDie3.Object,
                mockDie4.Object,
                mockDie5.Object,
            };

            Mock <IDiceHolder> mockDiceHolder = new Mock <IDiceHolder>();

            mockDiceHolder.Setup(x => x.DiceList).Returns(diceList);


            var sut = new FunScoreParser(mockDiceHolder.Object);

            Assert.AreEqual(expected, sut.CalculateSingleNumbers(correctInput));
        }
Exemple #2
0
        public void Calculate_ShouldReturnScoreForSelectingOneToSix(int input, int expected)
        {
            Mock <IDiceHolder> mockDiceHolder = GetMockDiceHolder(input, input, input, input, input);

            var sut = new FunScoreParser(mockDiceHolder.Object);

            Assert.AreEqual(sut.CalculateSingleNumbers(input), expected);
        }
Exemple #3
0
        public void Calculate_CalculateNOfAKindShouldOnlyMultiplyByCorrectScoring(int numberOfAkind, int inputDiceOne, int inputDiceTwo, int inputDiceThree, int inputDiceFour, int inputDiceFive, int expectedScoring)
        {
            Mock <IDiceHolder> mockDiceHolder = GetMockDiceHolder(inputDiceOne, inputDiceTwo, inputDiceThree, inputDiceFour, inputDiceFive);

            var sut = new FunScoreParser(mockDiceHolder.Object);

            Assert.AreEqual(expectedScoring, sut.CalculateNOfAKind(numberOfAkind));
        }
Exemple #4
0
        public void Calculate_ShouldCalculateChance(int inputDiceOne, int inputDiceTwo, int inputDiceThree, int inputDiceFour, int inputDiceFive, int expectedScoring)
        {
            Mock <IDiceHolder> mockDiceHolder = GetMockDiceHolder(inputDiceOne, inputDiceTwo, inputDiceThree, inputDiceFour, inputDiceFive);

            var sut = new FunScoreParser(mockDiceHolder.Object);

            Assert.AreEqual(expectedScoring, sut.CalculateChance());
        }
        public void GetFunScoreParser_ShouldReturnFunScoreParser()
        {
            string             typeOfParser       = "FunScoreParser";
            ScoreParserFactory scoreParserFactory = new ScoreParserFactory();
            Mock <IDiceHolder> mockDiceHolder     = GetMockDiceHolder(1, 2, 3, 4, 5);

            IScoreParser   actual   = scoreParserFactory.GetScoreParser(typeOfParser, mockDiceHolder.Object);
            FunScoreParser expected = new FunScoreParser(mockDiceHolder.Object);

            actual.Should().NotBeNull();
            actual.Should().BeEquivalentTo(expected);
        }