コード例 #1
0
        public void PresenterProvidesViewModelToBindTo()
        {
            var view = new MockOrderDetailsView();
            var presenter = new OrderDetailsPresentationModel(view, null, null);

            Assert.IsNotNull(view.Model);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 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);
 }
コード例 #7
0
        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);

        }