public OrdersPresenter(IOrdersView view, IRestAPI api, ISettings settings) { this.view = view; this.settings = settings; this.api = api; args = new Dictionary <string, object>() { { "start", 0 }, { "limit", settings.ItemsPerPage }, { "filter_customer", string.Empty } }; WireUpEvents(); }
/// <summary> /// Initializes a new instance of the <see cref="OrdersPresenterTest" /> class. /// </summary> public OrdersPresenterTest() { this.orderManager = Substitute.For<VisitorOrderManager, IUserAware>(); this.coreOrderManager = Substitute.For<SampleOrderManager>(Substitute.For<CoreOrderStateConfiguration>(), Substitute.For<Repository<Order>>()); var order1 = new Order { OrderId = "first", BuyerCustomerParty = new CustomerParty { SupplierAssignedAccountID = "111" } }; var order2 = new Order { OrderId = "second", BuyerCustomerParty = new CustomerParty { SupplierAssignedAccountID = "111" } }; this.orders = new Collection<Order> { order1, order2 }.AsQueryable(); this.orderManager.GetAll().Returns(this.orders); this.coreOrderManager.GetAllOrders(Arg.Any<Expression<Func<Order, bool>>>()).Returns(this.orders); this.view = Substitute.For<IOrdersView>(); this.httpContext = Substitute.For<HttpContextBase>(); new OrdersPresenter(this.view, this.orderManager, this.coreOrderManager) { HttpContext = this.httpContext }; this.httpContext.Request.QueryString.Returns(new NameValueCollection { { "user", "111" } }); }
public void AfterAllOrdersSubmittedSubmitAllCommandShouldBeDisabled() { try { Mock <IOrdersView> mockOrdersView = new Mock <IOrdersView>(); Mock <IOrdersViewModel> mockOrdersViewModel = new Mock <IOrdersViewModel>(); Mock <ServiceLocatorImplBase> mockServiceLocator = new Mock <ServiceLocatorImplBase>(); var orderCompositePresenter = new MockOrderCompositePresentationModel(); var commandProxy = new MockStockTraderTransaqCommandProxy(); IOrdersView orderCompositeView = mockOrdersView.Object; IOrdersViewModel orderCompositePresentationModel = mockOrdersViewModel.Object; mockServiceLocator.Setup(x => x.GetInstance <IOrdersView>()).Returns(orderCompositeView); mockServiceLocator.Setup(x => x.GetInstance <IOrdersViewModel>()).Returns(orderCompositePresentationModel); mockServiceLocator.Setup(x => x.GetInstance <IOrderCompositeViewModel>()).Returns(orderCompositePresenter); ServiceLocator.SetLocatorProvider(() => mockServiceLocator.Object); var controller = new TestableOrdersController(regionManager, commandProxy, new MockAccountPositionService()); var buyOrder = new MockOrderCompositePresentationModel() { Shares = 100 }; mockServiceLocator.Setup(x => x.GetInstance <IOrderCompositeViewModel>()).Returns(buyOrder); controller.InvokeStartOrder(TransactionType.Buy, "STOCK1"); bool canExecuteChangedCalled = false; bool canExecuteResult = false; commandProxy.SubmitAllOrdersCommand.CanExecuteChanged += delegate { canExecuteChangedCalled = true; canExecuteResult = controller.SubmitAllVoteOnlyCommand.CanExecute(); }; buyOrder.RaiseCloseViewRequested(); Assert.IsTrue(canExecuteChangedCalled); Assert.IsFalse(canExecuteResult); } finally { ServiceLocator.SetLocatorProvider(() => null); } }
virtual protected void StartOrder(string tickerSymbol, TransactionType transactionType) { if (String.IsNullOrEmpty(tickerSymbol)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, "tickerSymbol")); } IRegion region = _regionManager.Regions[RegionNames.MainRegion]; //Make Sure OrdersView is in CollapsibleRegion if (region.GetView("OrdersView") == null) { var ordersPresentationModel = _container.Resolve <IOrdersPresentationModel>(); _ordersView = ordersPresentationModel.View; region.Add(_ordersView, "OrdersView"); region.Activate(_ordersView); } IRegion ordersRegion = _regionManager.Regions[ORDERS_REGION]; var orderCompositePresentationModel = _container.Resolve <IOrderCompositePresentationModel>(); orderCompositePresentationModel.TransactionInfo = new TransactionInfo(tickerSymbol, transactionType); orderCompositePresentationModel.CloseViewRequested += delegate { OrderModels.Remove(orderCompositePresentationModel); commandProxy.SubmitAllOrdersCommand.UnregisterCommand(orderCompositePresentationModel.SubmitCommand); commandProxy.CancelAllOrdersCommand.UnregisterCommand(orderCompositePresentationModel.CancelCommand); commandProxy.SubmitOrderCommand.UnregisterCommand(orderCompositePresentationModel.SubmitCommand); commandProxy.CancelOrderCommand.UnregisterCommand(orderCompositePresentationModel.CancelCommand); ordersRegion.Remove(orderCompositePresentationModel.View); }; ordersRegion.Add(orderCompositePresentationModel.View); OrderModels.Add(orderCompositePresentationModel); commandProxy.SubmitAllOrdersCommand.RegisterCommand(orderCompositePresentationModel.SubmitCommand); commandProxy.CancelAllOrdersCommand.RegisterCommand(orderCompositePresentationModel.CancelCommand); //The following commands are Active Aware commandProxy.SubmitOrderCommand.RegisterCommand(orderCompositePresentationModel.SubmitCommand); commandProxy.CancelOrderCommand.RegisterCommand(orderCompositePresentationModel.CancelCommand); ordersRegion.Activate(orderCompositePresentationModel.View); }
virtual protected void StartOrder(string tickerSymbol, TransactionType transactionType) { if (String.IsNullOrEmpty(tickerSymbol)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, "tickerSymbol")); } IRegion region = _regionManager.Regions[RegionNames.MainRegion]; //Make Sure OrdersView is in CollapsibleRegion if (region.GetView("OrdersView") == null) { var ordersPresentationModel = _container.Resolve<IOrdersPresentationModel>(); _ordersView = ordersPresentationModel.View; region.Add(_ordersView, "OrdersView"); region.Activate(_ordersView); } IRegion ordersRegion = _regionManager.Regions[ORDERS_REGION]; var orderCompositePresentationModel = _container.Resolve<IOrderCompositePresentationModel>(); orderCompositePresentationModel.TransactionInfo = new TransactionInfo(tickerSymbol, transactionType); orderCompositePresentationModel.CloseViewRequested += delegate { OrderModels.Remove(orderCompositePresentationModel); commandProxy.SubmitAllOrdersCommand.UnregisterCommand(orderCompositePresentationModel.SubmitCommand); commandProxy.CancelAllOrdersCommand.UnregisterCommand(orderCompositePresentationModel.CancelCommand); commandProxy.SubmitOrderCommand.UnregisterCommand(orderCompositePresentationModel.SubmitCommand); commandProxy.CancelOrderCommand.UnregisterCommand(orderCompositePresentationModel.CancelCommand); ordersRegion.Remove(orderCompositePresentationModel.View); }; ordersRegion.Add(orderCompositePresentationModel.View); OrderModels.Add(orderCompositePresentationModel); commandProxy.SubmitAllOrdersCommand.RegisterCommand(orderCompositePresentationModel.SubmitCommand); commandProxy.CancelAllOrdersCommand.RegisterCommand(orderCompositePresentationModel.CancelCommand); //The following commands are Active Aware commandProxy.SubmitOrderCommand.RegisterCommand(orderCompositePresentationModel.SubmitCommand); commandProxy.CancelOrderCommand.RegisterCommand(orderCompositePresentationModel.CancelCommand); ordersRegion.Activate(orderCompositePresentationModel.View); }
public OrdersPresentationModel(IOrdersView view) { this.View = view; this.View.SetModel(this); }
public OrdersPresenter(IOrdersView view) { view.OrderSelected += (sender, args) => DoOrderSelection(args.Order); }
public OrdersPresentationModel(IOrdersView view) { View = view; View.Model = this; }
public void Setup() { _viewMock = new OrdesViewMock(); _presenter = new OrdersPresenter(_viewMock, TestDbContext.Instance); }
public OrdersPresenter(IOrdersView view, IAppDbContext dbContext) : base(dbContext) { _view = view; }