public void PresenterProvidesViewModelToBindTo()
        {
            var view = new MockOrderDetailsView();
            var presenter = new OrderDetailsPresentationModel(view, null, null);

            Assert.IsNotNull(view.Model);
        }
        public void PropertyChangedIsRaisedWhenSharesIsChanged()
        {
            var presenter = new OrderDetailsPresentationModel(new MockOrderDetailsView(),null,null);
            presenter.Shares = 5;

            bool sharesPropertyChangedRaised = false;
            presenter.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "Shares")
                    sharesPropertyChangedRaised = true;
            };
            presenter.Shares = 1;
            Assert.IsTrue(sharesPropertyChangedRaised);
        }
        public void VerifyTransactionInfoModificationsInOrderDetails()
        {
            var view = new MockOrderDetailsView();
            var orderDetailsPresenter = new OrderDetailsPresentationModel(view, new MockAccountPositionService(), null);
            var transactionInfo = new TransactionInfo { TickerSymbol = "Fund0", TransactionType = TransactionType.Buy };
            orderDetailsPresenter.TransactionInfo = transactionInfo;
            orderDetailsPresenter.TransactionType = TransactionType.Sell;
            Assert.AreEqual(TransactionType.Sell, transactionInfo.TransactionType);

            orderDetailsPresenter.TickerSymbol = "Fund1";
            Assert.AreEqual("Fund1", transactionInfo.TickerSymbol);
        }
        public void SubmitCallsServiceWithCorrectOrder()
        {
            var ordersService = new MockOrdersService();
            var presenter = new OrderDetailsPresentationModel(new MockOrderDetailsView(),
                                                    new MockAccountPositionService(), ordersService);
            presenter.Shares = 2;
            presenter.TickerSymbol = "AAAA";
            presenter.TransactionType = TransactionType.Buy;
            presenter.TimeInForce = TimeInForce.EndOfDay;
            presenter.OrderType = OrderType.Limit;
            presenter.StopLimitPrice = 15;

            Assert.IsNull(ordersService.SubmitArgumentOrder);
            presenter.SubmitCommand.Execute(null);

            var submittedOrder = ordersService.SubmitArgumentOrder;
            Assert.IsNotNull(submittedOrder);
            Assert.AreEqual("AAAA", submittedOrder.TickerSymbol);
            Assert.AreEqual(TransactionType.Buy, submittedOrder.TransactionType);
            Assert.AreEqual(TimeInForce.EndOfDay, submittedOrder.TimeInForce);
            Assert.AreEqual(OrderType.Limit, submittedOrder.OrderType);
            Assert.AreEqual(15, submittedOrder.StopLimitPrice);
        }
        public void SetTransactionInfoShouldUpdateTheModel()
        {
            var view = new MockOrderDetailsView();
            var presenter = new OrderDetailsPresentationModel(view, new MockAccountPositionService(), null);
            presenter.TransactionInfo = new TransactionInfo { TickerSymbol = "T000", TransactionType = TransactionType.Sell };

            Assert.AreEqual("T000", presenter.TickerSymbol);
            Assert.AreEqual(TransactionType.Sell, presenter.TransactionType);
        }
 public void PresenterCreatesCallSetTimeInForce()
 {
     var view = new MockOrderDetailsView();
     var presenter = new OrderDetailsPresentationModel(view, null, null);
     Assert.IsNotNull(presenter.AvailableTimesInForce);
     Assert.IsTrue(presenter.AvailableTimesInForce.Count > 0);
     Assert.AreEqual(GetEnumCount(typeof(TimeInForce)), presenter.AvailableTimesInForce.Count);
 }
        public void PresenterCreatesCallSetOrderTypes()
        {
            var view = new MockOrderDetailsView();
            var presenter = new OrderDetailsPresentationModel(view, null, null);
            Assert.IsNotNull(presenter.AvailableOrderTypes);
            Assert.IsTrue(presenter.AvailableOrderTypes.Count > 0);
            Assert.AreEqual(Enum.GetValues(typeof(OrderType)).Length, presenter.AvailableOrderTypes.Count);

        }