public void Equals_ParameterIsDifferentType_ReturnsFalse()
        {
            var parameter1 = new PlayMonopolyCardEvent(Guid.NewGuid(), null);
            var parameter2 = new Object();

            parameter1.Equals(parameter2).ShouldBeFalse();
        }
        public void Equals_ParameterIsSameObject_ReturnsTrue()
        {
            var parameter1 = new PlayMonopolyCardEvent(Guid.NewGuid(), null);
            var parameter2 = parameter1;

            parameter1.Equals(parameter2).ShouldBeTrue();
        }
Example #3
0
        public void Scenario_OpponentUsesMonopolyCardAndGetsResourcesFromPlayer()
        {
            // Arrange
            var monopolyCard        = new MonopolyDevelopmentCard();
            var testInstances       = this.TestSetup(new MockGameBoardWithNoResourcesCollected(), monopolyCard);
            var localGameController = testInstances.LocalGameController;

            testInstances.Dice.AddSequence(new uint[] { 8, 8, 8, 8 });

            var player         = testInstances.MainPlayer;
            var firstOpponent  = testInstances.FirstOpponent;
            var secondOpponent = testInstances.SecondOpponent;
            var thirdOpponent  = testInstances.ThirdOpponent;

            testInstances.Dice.AddSequence(new uint[] { 3, 3, 8, 8 });  // Only second opp will collect resources (2 Ore)

            player.AddResources(ResourceClutch.OneBrick);
            firstOpponent.AddResources(ResourceClutch.DevelopmentCard);
            firstOpponent.AddBuyDevelopmentCardChoice(1).EndTurn()
            .AddPlaceMonopolyCardInstruction(new PlayMonopolyCardInstruction {
                ResourceType = ResourceTypes.Brick
            }).EndTurn();

            secondOpponent.AddResources(new ResourceClutch(2, 1, 1, 1, 1));

            var       turn      = 0;
            GameToken turnToken = null;

            localGameController.StartPlayerTurnEvent = (GameToken t) => { turnToken = t; turn++; };

            var gameEvents = new List <List <GameEvent> >();

            localGameController.GameEvents = (List <GameEvent> e) => { gameEvents.Add(e); };

            localGameController.StartGamePlay();
            localGameController.EndTurn(turnToken); // Opponent buys development cards
            localGameController.EndTurn(turnToken); // Opponent plays monopoly cards

            // Assert
            var expectedBuyDevelopmentCardEvent = new BuyDevelopmentCardEvent(firstOpponent.Id);

            var expectedResourceTransactionList = new ResourceTransactionList();

            expectedResourceTransactionList.Add(new ResourceTransaction(firstOpponent.Id, player.Id, ResourceClutch.OneBrick));
            expectedResourceTransactionList.Add(new ResourceTransaction(firstOpponent.Id, secondOpponent.Id, ResourceClutch.OneBrick * 2));
            var expectedPlayMonopolyCardEvent = new PlayMonopolyCardEvent(firstOpponent.Id, expectedResourceTransactionList);

            gameEvents.Count.ShouldBe(15);
            gameEvents[2].Count.ShouldBe(2);
            gameEvents[2][1].ShouldBe(expectedBuyDevelopmentCardEvent);
            gameEvents[9].Count.ShouldBe(2);
            gameEvents[9][1].ShouldBe(expectedPlayMonopolyCardEvent);

            player.Resources.Count.ShouldBe(0);
            firstOpponent.Resources.Count.ShouldBe(3);
            firstOpponent.Resources.BrickCount.ShouldBe(firstOpponent.Resources.Count);
            secondOpponent.Resources.Count.ShouldBe(4);
            secondOpponent.Resources.BrickCount.ShouldBe(0);
            thirdOpponent.Resources.Count.ShouldBe(0);
        }
        public void Equals_ParameterIsDifferentObjectWithSamePlayerId_ReturnsTrue()
        {
            var id         = Guid.NewGuid();
            var parameter1 = new PlayMonopolyCardEvent(id, null);
            var parameter2 = new PlayMonopolyCardEvent(id, null);

            parameter1.Equals(parameter2).ShouldBeTrue();
        }
Example #5
0
        public ScenarioRunner ReceivesMonopolyCardPlayedEvent(Dictionary <string, ResourceClutch> resourcesByPlayerName, string playerName = null)
        {
            var playerId = playerName != null ? this.playerAgentsByName[playerName].Id : this.currentPlayerAgent.Id;
            var resourceTransactionList = new ResourceTransactionList();

            if (resourcesByPlayerName != null && resourcesByPlayerName.Count > 0)
            {
                foreach (var kv in resourcesByPlayerName)
                {
                    resourceTransactionList.Add(new ResourceTransaction(playerId, this.playerAgentsByName[kv.Key].Id, kv.Value));
                }
            }
            var gameEvent        = new PlayMonopolyCardEvent(playerId, resourceTransactionList);
            var eventInstruction = new EventInstruction(gameEvent);

            this.currentPlayerAgent.AddInstruction(eventInstruction);
            return(this);
        }
        public void Equals_ParameterIsNull_ReturnsFalse()
        {
            var parameter = new PlayMonopolyCardEvent(Guid.NewGuid(), null);

            parameter.Equals(null).ShouldBeFalse();
        }