public void GetPendingAction_PassNonNullChain_LocksChainToPlayer() { var chainList = new Mock<IChainList>(); var player = new Mock<IPlayer>(); var chain = new Mock<IInPlayChain>(); var pendingActions = new Mock<ILoadableDictionary<IPlayer, IPendingAction>>(); chain.Setup(c => c.Lock(It.Is<IPlayer>(p => p == player.Object))).Verifiable(); var factory = new PendingActionFactory(chainList.Object, pendingActions.Object); factory.GetPendingAction(player.Object, chain.Object); chain.Verify(); }
public void GetPendingAction_PassNullChain_ResultingActionCreatesNewChain() { var chainList = new Mock<IChainList>(); var player = new Mock<IPlayer>(); var guess = new Mock<IGuessInfo>(); var pendingActions = new Mock<ILoadableDictionary<IPlayer, IPendingAction>>(); chainList.Setup(t => t.CreateNew(It.Is<IGuessInfo>(g => g== guess.Object))).Verifiable(); var factory = new PendingActionFactory(chainList.Object, pendingActions.Object); var action = factory.GetPendingAction(player.Object, null); action.Execute(guess.Object); chainList.Verify(); }
public void GetPendingAction_PassNonNullChain_ResultingActionCallsAddGuessAndRelease() { var chainList = new Mock<IChainList>(); var player = new Mock<IPlayer>(); var chain = new Mock<IInPlayChain>(); var guess = new Mock<IGuessInfo>(); var pendingActions = new Mock<ILoadableDictionary<IPlayer, IPendingAction>>(); guess.Setup(g => g.Contributor).Returns(player.Object); chain.Setup(c => c.AddGuess(It.Is<IGuessInfo>(g => g == guess.Object))).Verifiable(); chain.Setup(c => c.Release(It.Is<IPlayer>(p => p==player.Object))).Verifiable(); var factory = new PendingActionFactory(chainList.Object, pendingActions.Object); var action = factory.GetPendingAction(player.Object, chain.Object); action.Execute(guess.Object); chain.Verify(); }