Пример #1
0
        public void DiceCup_InitialRollHoldThreeValuesUnholdTwoValues_ThreeDiceInTheCupWerePlacedInTheHeldStateAndTwoDiceInTheCupWerePlacedInTheThrowableState()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die };

            // Act
            var diceCup = new DiceCup(dice);
            diceCup.Roll();
            diceCup.Hold(0, 2, 4);
            diceCup.Unhold(2, 4);

            // Assert
            _dieMock.VerifySet(x => x.State = DieState.Held, Times.Exactly(3));
            _dieMock.VerifySet(x => x.State = DieState.Throwable, Times.Exactly(2));
        }
Пример #2
0
        public void DiceCup_InitialRollSaveFirstThreeValues_ThreeDiceInTheCupWerePlacedInTheHeldState()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die };

            // Act
            var diceCup = new DiceCup(dice);
            diceCup.Roll();
            diceCup.Hold(0, 1, 2);

            //Assert
            _dieMock.VerifySet(x => x.State = DieState.Held, Times.Exactly(3));
        }
Пример #3
0
        public void DiceCup_RollTwoTimesAndCheckFinalizedState_FinalizedStateIsFalse()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die };

            // Act
            var diceCup = new DiceCup(dice);
            diceCup.Roll();
            diceCup.Roll();

            // Assert
            diceCup.IsFinal().Should().BeFalse();
        }
Пример #4
0
        public void DiceCup_RollThreeTimesAndPreventFourthRoll_ReturnsNull()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die };

            // Act
            var diceCup = new DiceCup(dice);
            diceCup.Roll();
            diceCup.Roll();
            diceCup.Roll();

            // Assert
            IEnumerable<IDie> finalRoll = diceCup.Roll();
            finalRoll.Should().BeNull();
        }
Пример #5
0
        public void DiceCup_InitialRoll_DieValuesMatchMockedDieValues()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die };
            var expectedResult = new[] { 4, 3, 2, 1, 2 };

            // Act
            var diceCup = new DiceCup(dice);
            diceCup.Roll();
            IEnumerable<IDie> rollResult = diceCup.Dice;

            // Assert
            rollResult.Select(x => x.Value).ToList().Should().BeEquivalentTo(expectedResult);
        }
Пример #6
0
        public void RollThreeTimesAndThrowExceptionOnTheFourth()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die };

            // Act
            var diceCup = new DiceCup(dice);
            diceCup.Roll();
            diceCup.Roll();
            diceCup.Roll();

            // Assert taken care of by ExpectedException decorator
            try
            {
                diceCup.Roll();
            }
            catch (InvalidOperationException e)
            {
                e.Message.Should().Be("Dice can not be thrown after three rolls.");
                throw;
            }
        }
Пример #7
0
        public void RollThreeTimesAndCheckFinalizedStateForFinalized()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die };

            // Act
            var diceCup = new DiceCup(dice);
            diceCup.Roll();
            diceCup.Roll();
            diceCup.Roll();

            // Assert
            diceCup.IsFinal().Should().BeTrue();
        }