public void TradeItems() { var trader1 = TestHelper.GetPlayer(); var trader2 = TestHelper.GetPlayer(); var tradeRequestAction = new TradeRequestAction(); var tradeResponseAction = new TradeAcceptAction(); var item1 = this.GetItem(); var item2 = this.GetItem(); trader1.Inventory.AddItem(20, item1); trader1.Inventory.AddItem(21, item2); tradeRequestAction.RequestTrade(trader1, trader2); tradeResponseAction.HandleTradeAccept(trader2, true); var itemMoveAction = new MoveItemAction(); itemMoveAction.MoveItem(trader1, 20, Storages.Inventory, 0, Storages.Trade); itemMoveAction.MoveItem(trader1, 21, Storages.Inventory, 2, Storages.Trade); Assert.That(trader1.TemporaryStorage.Items.First(), Is.SameAs(item1)); var gameContext = new Mock <IGameContext>(); gameContext.Setup(c => c.PersistenceContextProvider).Returns(new InMemoryPersistenceContextProvider()); var tradeButtonHandler = new TradeButtonAction(gameContext.Object); tradeButtonHandler.TradeButtonChanged(trader1, TradeButtonState.Checked); tradeButtonHandler.TradeButtonChanged(trader2, TradeButtonState.Checked); Assert.That(trader1.Inventory.ItemStorage.Items, Is.Empty); Assert.That(trader2.Inventory.ItemStorage.Items.First(), Is.SameAs(item1)); }
public void TradeItems() { var trader1 = TestHelper.GetPlayer(); var trader2 = TestHelper.GetPlayer(); var tradeRequestAction = new TradeRequestAction(); var tradeResponseAction = new TradeAcceptAction(); var item1 = this.GetItem(); var item2 = this.GetItem(); trader1.Inventory !.AddItem(20, item1); trader1.Inventory.AddItem(21, item2); tradeRequestAction.RequestTrade(trader1, trader2); tradeResponseAction.HandleTradeAccept(trader2, true); var itemMoveAction = new MoveItemAction(); itemMoveAction.MoveItem(trader1, 20, Storages.Inventory, 0, Storages.Trade); itemMoveAction.MoveItem(trader1, 21, Storages.Inventory, 2, Storages.Trade); Assert.That(trader1.TemporaryStorage !.Items.First(), Is.SameAs(item1)); var tradeButtonHandler = new TradeButtonAction(); tradeButtonHandler.TradeButtonChanged(trader1, TradeButtonState.Checked); tradeButtonHandler.TradeButtonChanged(trader2, TradeButtonState.Checked); Assert.That(trader1.Inventory.ItemStorage.Items, Is.Empty); Assert.That(trader2.Inventory !.ItemStorage.Items.First(), Is.SameAs(item1)); }
public void TestTradeResponse() { var requester = this.CreateTrader(PlayerState.TradeRequested); var responder = this.CreateTrader(PlayerState.TradeRequested); requester.TradingPartner = responder; responder.TradingPartner = requester; var responseHandler = new TradeAcceptAction(); responseHandler.HandleTradeAccept(responder, true); Assert.AreEqual(requester.PlayerState.CurrentState, PlayerState.TradeOpened); Assert.AreEqual(responder.PlayerState.CurrentState, PlayerState.TradeOpened); Mock.Get(requester.ViewPlugIns.GetPlugIn <IShowTradeRequestAnswerPlugIn>()).Verify(view => view !.ShowTradeRequestAnswer(true), Times.Once); }
public void TestTradeResponse() { var requester = this.CreateTrader(PlayerState.TradeRequested); var responder = this.CreateTrader(PlayerState.TradeRequested); requester.TradingPartner = responder; responder.TradingPartner = requester; requester.TradeView.Expect(view => view.ShowTradeRequestAnswer(true)); var responseHandler = new TradeAcceptAction(); responseHandler.HandleTradeAccept(responder, true); Assert.AreEqual(requester.PlayerState.CurrentState, PlayerState.TradeOpened); Assert.AreEqual(responder.PlayerState.CurrentState, PlayerState.TradeOpened); requester.TradeView.VerifyAllExpectations(); }
/// <summary> /// Initializes a new instance of the <see cref="TradeAcceptHandler"/> class. /// </summary> public TradeAcceptHandler() { this.acceptAction = new TradeAcceptAction(); }