Beispiel #1
0
        public void ConstructAnImproperlySizedDiceCup()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die, die, die };

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

            // Assert handled by ExpectedException decorator
        }
Beispiel #2
0
        public void DiceCup_ConstructorTakesMoreThanFiveDice_ArgumentOutOfRangeExceptionThrown()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die, die, die };

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

            // Assert handled by ExpectedException decorator
        }
Beispiel #3
0
        public void DiceCup_ConstructorTakesFiveDice_DiceCupConstructedSuccessfully()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die };

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

            // Assert
            diceCup.Should().NotBeNull();
        }
Beispiel #4
0
        public void ConstructAProperlySizedDiceCup()
        {
            // Arrange
            var die = _dieMock.Object;
            var dice = new List<IDie> { die, die, die, die, die };

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

            // Assert
            diceCup.Should().NotBeNull();
        }
Beispiel #5
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));
        }
Beispiel #6
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));
        }
Beispiel #7
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();
        }
Beispiel #8
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();
        }
Beispiel #9
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);
        }
Beispiel #10
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;
            }
        }
Beispiel #11
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();
        }