Beispiel #1
0
        public void PresenterSubscribesToFundAddedForCorrectCustomer()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();

            mockEventAggregator.AddMapping <FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);

            presenter.View = new MockActivityView();

            string customerId = "ALFKI";

            presenter.CustomerId = customerId;

            FundOrder payload = new FundOrder()
            {
                CustomerId = customerId
            };

            mockEvent.Subscribe(delegate { new FundOrder()
                                           {
                                               CustomerId = customerId
                                           }; }, ThreadOption.UIThread, true, delegate {
                if (customerId == "ALFKI")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
            mockEvent.Publish(payload);

            Assert.IsTrue(mockEvent.SubscribeArgumentFilter(new FundOrder {
                CustomerId = "ALFKI"
            }));
            Assert.AreEqual(ThreadOption.UIThread, mockEvent.ThreadOption);
            customerId = "FilteredOutCustomer";
            mockEvent.Subscribe(delegate { new FundOrder()
                                           {
                                               CustomerId = customerId
                                           }; }, ThreadOption.UIThread, true, delegate {
                if (customerId == "ALFKI")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
            Assert.IsFalse(mockEvent.SubscribeArgumentFilter(new FundOrder {
                CustomerId = "FilteredOutCustomer"
            }));
        }
Beispiel #2
0
        public void PresenterAddsFundOnEvent()
        {
            var view = new MockActivityView();
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();

            mockEventAggregator.AddMapping <FundAddedEvent>(mockEvent);

            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);

            presenter.View = view;
            string customerId = "ALFKI";

            presenter.CustomerId = customerId;
            FundOrder payload = new FundOrder()
            {
                CustomerId = customerId, TickerSymbol = "MSFT"
            };

            mockEvent.Subscribe(delegate { new FundOrder()
                                           {
                                               CustomerId = customerId, TickerSymbol = "MSFT"
                                           }; }, ThreadOption.UIThread, true, delegate { return(true); });
            mockEvent.Publish(payload);
            StringAssert.Contains(view.AddContentArgumentContent, "MSFT");
        }
Beispiel #3
0
        public void PresenterUnsubcribesFromFundAddedEventIfCustomerIDIsSetTwice()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent  = new MockFundAddedEvent();
            string             customerId = "ALFKI";
            FundOrder          payload    = new FundOrder()
            {
                CustomerId = customerId, TickerSymbol = "MSFT"
            };

            mockEvent.Subscribe(delegate { new FundOrder()
                                           {
                                               CustomerId = customerId, TickerSymbol = "MSFT"
                                           }; }, ThreadOption.UIThread, true, delegate { return(true); });
            mockEventAggregator.AddMapping <FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);

            presenter.View = new MockActivityView();


            presenter.CustomerId = "ALFKI";
            presenter.CustomerId = "ALFKI";

            Assert.AreEqual(1, mockEvent.SubscribeCount);
        }
        public void PresenterSubscribesToFundAddedForCorrectCustomer()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();
            mockEventAggregator.AddMapping<FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);
            presenter.View = new MockActivityView();

            string customerId = "ALFKI";
            presenter.CustomerId = customerId;

            FundOrder payload = new FundOrder() { CustomerId = customerId };
            mockEvent.Subscribe(delegate { new FundOrder() { CustomerId = customerId }; }, ThreadOption.UIThread, true, delegate{
                if (customerId == "ALFKI"){
                    return true;
                }
                else{
                    return false;
                }
                                                                                                                        });
            mockEvent.Publish(payload);

            Assert.IsTrue(mockEvent.SubscribeArgumentFilter(new FundOrder { CustomerId = "ALFKI" }));
            Assert.AreEqual(ThreadOption.UIThread, mockEvent.ThreadOption);
            customerId = "FilteredOutCustomer";
            mockEvent.Subscribe(delegate { new FundOrder() { CustomerId = customerId }; }, ThreadOption.UIThread, true, delegate {
                if (customerId == "ALFKI")
                {
                    return true;
                }
                else {
                    return false;
                }
            });
            Assert.IsFalse(mockEvent.SubscribeArgumentFilter(new FundOrder { CustomerId = "FilteredOutCustomer" }));
        }
        public void PresenterAddsFundOnEvent()
        {
            var view = new MockActivityView();
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();
            mockEventAggregator.AddMapping<FundAddedEvent>(mockEvent);

            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);
            presenter.View = view;
            string customerId = "ALFKI";
            presenter.CustomerId = customerId;
            FundOrder payload = new FundOrder() { CustomerId = customerId, TickerSymbol = "MSFT" };
            mockEvent.Subscribe(delegate { new FundOrder() { CustomerId = customerId, TickerSymbol = "MSFT" }; }, ThreadOption.UIThread, true, delegate { return true; });
            mockEvent.Publish(payload);
            StringAssert.Contains(view.AddContentArgumentContent, "MSFT");
        }
        public void PresenterUnsubcribesFromFundAddedEventIfCustomerIDIsSetTwice()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();
            string customerId = "ALFKI";
            FundOrder payload = new FundOrder() { CustomerId = customerId, TickerSymbol = "MSFT" };
            mockEvent.Subscribe(delegate { new FundOrder() { CustomerId = customerId, TickerSymbol = "MSFT" }; }, ThreadOption.UIThread, true, delegate { return true; });
            mockEventAggregator.AddMapping<FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);
            presenter.View = new MockActivityView();


            presenter.CustomerId = "ALFKI";
            presenter.CustomerId = "ALFKI";

            Assert.AreEqual(1, mockEvent.SubscribeCount);
        }