public void UseMonopolyCard_UseDevelopmentCard_ReceiveAllResourcesOfRequestedTypeFromOpponents() { // Arrange var monopolyCard = new MonopolyDevelopmentCard(); var testInstances = this.TestSetup(new MockGameBoardWithNoResourcesCollected(), monopolyCard); var localGameController = testInstances.LocalGameController; testInstances.Dice.AddSequenceWithRepeatingRoll(null, 8); var player = testInstances.MainPlayer; var firstOpponent = testInstances.FirstOpponent; var secondOpponent = testInstances.SecondOpponent; var thirdOpponent = testInstances.ThirdOpponent; player.AddResources(ResourceClutch.DevelopmentCard); firstOpponent.AddResources(ResourceClutch.OneOfEach); secondOpponent.AddResources(ResourceClutch.OneBrick * 2); thirdOpponent.AddResources(new ResourceClutch(0, 1, 1, 1, 1)); GameToken turnToken = null; localGameController.StartPlayerTurnEvent = (GameToken t) => { turnToken = t; }; ResourceTransactionList gainedResources = null; localGameController.ResourcesTransferredEvent = (ResourceTransactionList r) => { gainedResources = r; }; localGameController.StartGamePlay(); // Buy the monopoly card localGameController.BuyDevelopmentCard(turnToken); localGameController.EndTurn(turnToken); // Act localGameController.UseMonopolyCard(turnToken, monopolyCard, ResourceTypes.Brick); // Assert var expectedResources = new ResourceTransactionList(); expectedResources.Add(new ResourceTransaction(player.Id, firstOpponent.Id, ResourceClutch.OneBrick)); expectedResources.Add(new ResourceTransaction(player.Id, secondOpponent.Id, ResourceClutch.OneBrick * 2)); gainedResources.ShouldBe(expectedResources); player.Resources.Count.ShouldBe(3); player.Resources.BrickCount.ShouldBe(3); firstOpponent.Resources.Count.ShouldBe(4); firstOpponent.Resources.BrickCount.ShouldBe(0); secondOpponent.Resources.Count.ShouldBe(0); thirdOpponent.Resources.Count.ShouldBe(4); thirdOpponent.Resources.BrickCount.ShouldBe(0); }
public void TradeWithBank_LegitmateResourcesForTransaction_ResourceTransactionCompleted(Int32 brickCount, Int32 receivingCount, Int32 otherCount, Int32 leftOverBrickCount) { // Arrange var bankId = Guid.NewGuid(); var testInstances = this.TestSetupWithExplictGameBoard(bankId, new MockGameBoardWithNoResourcesCollected()); var localGameController = testInstances.LocalGameController; var paymentResources = ResourceClutch.OneBrick * (receivingCount * 4); var requestedResources = ResourceClutch.OneGrain * receivingCount; var player = testInstances.MainPlayer; player.AddResources(ResourceClutch.OneBrick * brickCount); player.AddResources(ResourceClutch.OneWool * otherCount); GameToken turnToken = null; localGameController.StartPlayerTurnEvent = (GameToken t) => { turnToken = t; }; ResourceTransactionList resources = null; localGameController.ResourcesTransferredEvent = (ResourceTransactionList r) => { resources = r; }; localGameController.StartGamePlay(); // Act localGameController.TradeWithBank(turnToken, ResourceTypes.Grain, receivingCount, ResourceTypes.Brick); // Assert resources.ShouldNotBeNull(); var expected = new ResourceTransactionList(); expected.Add(new ResourceTransaction(bankId, player.Id, paymentResources)); expected.Add(new ResourceTransaction(player.Id, bankId, requestedResources)); resources.ShouldBe(expected); player.Resources.Count.ShouldBe(receivingCount + otherCount + leftOverBrickCount); player.Resources.BrickCount.ShouldBe(leftOverBrickCount); player.Resources.GrainCount.ShouldBe(receivingCount); player.Resources.WoolCount.ShouldBe(otherCount); }
public void UseYearOfPlentyCard_UseDevelopmentCard_DifferentResourcesAreCollected() { // Arrange var bankId = Guid.NewGuid(); var yearOfPlentyCard = new YearOfPlentyDevelopmentCard(); var testInstances = this.TestSetupWithExplictGameBoard(bankId, yearOfPlentyCard, new MockGameBoardWithNoResourcesCollected()); var localGameController = testInstances.LocalGameController; var player = testInstances.MainPlayer; testInstances.Dice.AddSequenceWithRepeatingRoll(null, 8); testInstances.MainPlayer.AddResources(ResourceClutch.DevelopmentCard); GameToken turnToken = null; localGameController.StartPlayerTurnEvent = (GameToken t) => { turnToken = t; }; ResourceTransactionList resources = null; localGameController.ResourcesTransferredEvent = (ResourceTransactionList r) => { resources = r; }; localGameController.StartGamePlay(); // Buy the year of plenty card localGameController.BuyDevelopmentCard(turnToken); localGameController.EndTurn(turnToken); // Act localGameController.UseYearOfPlentyCard(turnToken, yearOfPlentyCard, ResourceTypes.Brick, ResourceTypes.Grain); // Assert var expected = new ResourceTransactionList(); expected.Add(new ResourceTransaction(player.Id, bankId, new ResourceClutch(1, 1, 0, 0, 0))); resources.ShouldBe(expected); player.Resources.Count.ShouldBe(2); player.Resources.BrickCount.ShouldBe(1); player.Resources.GrainCount.ShouldBe(1); }