コード例 #1
0
        public void RemoveNotExistingClassFromHero_ThrowsException_Test()
        {
            // Arrange
            var removeClassMessage = ClassMessage.CreateRemove(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act & Assert
            Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, removeClassMessage));
        }
コード例 #2
0
        public void RemoveClassFromUnknownHero_ThrowsException_Test()
        {
            // Arrange
            var removeClassMessage = ClassMessage.CreateRemove(_sequence.Next, Guid.NewGuid(), new[] { _warriorClass });

            // Act & Assert
            Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, removeClassMessage));
        }
コード例 #3
0
        public void AddClassToHero_ThenRemoveIt_ResultsInNoChange_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });
            var removeClassMessage = ClassMessage.CreateRemove(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act
            _quest.AddMessage(_gameId, addClassMessage);
            var game = _quest.AddMessage(_gameId, removeClassMessage);

            // Assert
            Assert.Empty(game.Score.Heroes.First(x => x.Player.Id == _playerId).Classes);
        }
コード例 #4
0
        public void AddClassToHero_ThenRemoveIt_ThenUndoIt_ResultsInAddedClass_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });
            var removeClassMessage = ClassMessage.CreateRemove(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act
            _quest.AddMessage(_gameId, addClassMessage);
            _quest.AddMessage(_gameId, removeClassMessage);
            var game = _quest.Undo(_gameId);

            // Assert
            Assert.Single(game.Score.Heroes.First(x => x.Player.Id == _playerId).Classes);
            Assert.Contains(_warriorClass, game.Score.Heroes.First(x => x.Player.Id == _playerId).Classes);
        }