public static void ShouldBe(this ResourceTransactionList actual, ResourceTransactionList expected) { actual.ShouldNotBeNull(); expected.ShouldNotBeNull(); actual.Count.ShouldBe(expected.Count); for (var i = 0; i < actual.Count; i++) { actual[i].ReceivingPlayerId.ShouldBe(expected[i].ReceivingPlayerId); actual[i].GivingPlayerId.ShouldBe(expected[i].GivingPlayerId); actual[i].Resources.ShouldBe(expected[i].Resources); } }
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); }