public void ShouldAddDetailsViewAndControlsViewToContentArea()
        {
            MockOrderCompositeView compositeView = new MockOrderCompositeView();
            var detailsPresenter = new MockOrderDetailsPresentationModel();

            var composite = new OrderCompositePresentationModel(compositeView, detailsPresenter, new MockOrderCommandsView());

            Assert.AreEqual(detailsPresenter.View, composite.OrderDetailsView);
            Assert.IsNotNull(composite.OrderCommandsView as IOrderCommandsView);
        }
        public void ShouldCreateOrderDetailsPresenter()
        {
            var detailsPresenter = new MockOrderDetailsPresentationModel();
            IOrderCompositeView compositeView = new MockOrderCompositeView();

            var composite = new OrderCompositePresentationModel(compositeView, detailsPresenter, new MockOrderCommandsView());

            composite.TransactionInfo = new TransactionInfo("FXX01", TransactionType.Sell);

            Assert.IsNotNull(detailsPresenter.TransactionInfo);
        }
        public void ShouldDelegateIsActivePropertyChangesToDetailView()
        {
            var detailsPresenter = new MockOrderDetailsPresentationModel();
            MockOrderCompositeView compositeView = new MockOrderCompositeView();

            var composite = new OrderCompositePresentationModel(compositeView, detailsPresenter, new OrderCommandsView());
            compositeView.IsActive = false;

            Assert.IsFalse(detailsPresenter.View.IsActive);
            compositeView.IsActive = true;
            Assert.IsTrue(detailsPresenter.View.IsActive);
        }
        public void PresenterExposesChildOrderPresentersCloseRequested()
        {
            var detailsPresenter = new MockOrderDetailsPresentationModel();
            MockOrderCompositeView compositeView = new MockOrderCompositeView();

            var composite = new OrderCompositePresentationModel(compositeView, detailsPresenter, new MockOrderCommandsView());

            var closeViewRequestedFired = false;
            composite.CloseViewRequested += delegate
                                                {
                                                    closeViewRequestedFired = true;
                                                };

            detailsPresenter.RaiseCloseViewRequested();

            Assert.IsTrue(closeViewRequestedFired);

        }
        public void TransactionInfoAndSharesAndCommandsAreTakenFromOrderDetails()
        {
            var orderDetailsPM = new MockOrderDetailsPresentationModel();
            var composite = new OrderCompositePresentationModel(new MockOrderCompositeView(), orderDetailsPM, new MockOrderCommandsView());
            orderDetailsPM.Shares = 100;

            Assert.AreEqual(orderDetailsPM.Shares, composite.Shares);
            Assert.AreSame(orderDetailsPM.SubmitCommand, composite.SubmitCommand);
            Assert.AreSame(orderDetailsPM.CancelCommand, composite.CancelCommand);
            Assert.AreSame(orderDetailsPM.TransactionInfo, composite.TransactionInfo);
        }
        public void ShouldUpdateHeaderInfoWhenUpdatingTransactionInfo()
        {
            var orderDetailsPM = new MockOrderDetailsPresentationModel();
            var composite = new OrderCompositePresentationModel(new MockOrderCompositeView(), orderDetailsPM, new MockOrderCommandsView());

            composite.TransactionInfo = new TransactionInfo("FXX01", TransactionType.Sell);

            orderDetailsPM.TransactionInfo.TickerSymbol = "NEW_SYMBOL";
            Assert.AreEqual("Sell NEW_SYMBOL", composite.HeaderInfo);

            orderDetailsPM.TransactionInfo.TransactionType = TransactionType.Buy;
            Assert.AreEqual("Buy NEW_SYMBOL", composite.HeaderInfo);
        }