public void SetUp()
        {
            this.playerEvent          = new MockPlayerEvent();
            this.view                 = new MockLibraryView();
            this.regionManager        = new MockRegionManager();
            this.configurationService = new MockConfigurationService();
            this.addAssetEvent        = new MockAddAssetEvent();
            this.assetsAvailableEvent = new MockAssetsAvailableEvent();
            this.showMetadataEvent    = new MockShowMetadataEvent();
            this.resetWindowsEvent    = new MockResetWindowsEvent();
            this.assetsLoadingEvent   = new MockAssetsLoadingEvent();
            this.mainRegion           = new MockRegion();
            this.errorView            = new MockErrorView();

            this.mainRegion.Name = RegionNames.MainRegion;
            this.regionManager.Regions.Add(this.mainRegion);

            this.eventAggregator = new MockEventAggregator();
            this.eventAggregator.AddMapping <AddAssetEvent>(this.addAssetEvent);
            this.eventAggregator.AddMapping <PlayerEvent>(this.playerEvent);
            this.eventAggregator.AddMapping <ShowMetadataEvent>(this.showMetadataEvent);
            this.eventAggregator.AddMapping <AssetsAvailableEvent>(this.assetsAvailableEvent);
            this.eventAggregator.AddMapping <ResetWindowsEvent>(this.resetWindowsEvent);
            this.eventAggregator.AddMapping <AssetsLoadingEvent>(this.assetsLoadingEvent);
        }
        public async Task CartItemUpdatedEventRaised_WhenItemRemoved()
        {
            var shoppingCartItemUpdatedRaised = false;
            var shoppingCartService           = new MockShoppingCartService()
            {
                RemoveShoppingCartItemDelegate = (s, s1) =>
                {
                    Assert.AreEqual("TestShoppingCartItemId", s1);
                    return(Task.FromResult(string.Empty));
                }
            };
            var shoppingCartItemUpdatedEvent = new ShoppingCartItemUpdatedEvent();

            shoppingCartItemUpdatedEvent.Subscribe((a) => shoppingCartItemUpdatedRaised = true);

            var eventAggregator = new MockEventAggregator()
            {
                GetEventDelegate = (a) => shoppingCartItemUpdatedEvent
            };

            var target = new ShoppingCartRepository(shoppingCartService, new MockAccountService(), eventAggregator, new MockSessionStateService());
            await target.RemoveShoppingCartItemAsync("TestShoppingCartItemId");

            Assert.IsTrue(shoppingCartItemUpdatedRaised);
        }
Esempio n. 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);
        }
Esempio n. 4
0
        public void NavigatedTo_CalculatesTotalNumberOfItemsInCart()
        {
            var shoppingCart = new ShoppingCart(new List <ShoppingCartItem>()
            {
                new ShoppingCartItem {
                    Quantity = 1
                },
                new ShoppingCartItem {
                    Quantity = 2
                }
            });
            var shoppingCartRepository = new MockShoppingCartRepository();
            var eventAggregator        = new MockEventAggregator();

            eventAggregator.GetEventDelegate = type =>
            {
                if (type == typeof(ShoppingCartUpdatedEvent))
                {
                    return(new ShoppingCartUpdatedEvent());
                }
                if (type == typeof(ShoppingCartItemUpdatedEvent))
                {
                    return(new ShoppingCartItemUpdatedEvent());
                }
                return(null);
            };
            var accountService = new MockAccountService();

            accountService.VerifyUserAuthenticationAsyncDelegate = () => Task.FromResult((UserInfo)null);
            shoppingCartRepository.GetShoppingCartAsyncDelegate  = () => Task.FromResult(shoppingCart);
            var target = new ShoppingCartTabUserControlViewModel(shoppingCartRepository, eventAggregator, null, null, accountService);

            Assert.AreEqual(3, target.ItemCount);
        }
        public void VMListensToShoppingCartUpdatedEvent_ThenCalculatesTotalNumberOfItemsInCart()
        {
            var shoppingCart = new ShoppingCart(new List<ShoppingCartItem>());
            var shoppingCartRepository = new MockShoppingCartRepository();

            shoppingCartRepository.GetShoppingCartAsyncDelegate = () => Task.FromResult(shoppingCart);
            var shoppingCartUpdatedEvent = new ShoppingCartUpdatedEvent();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.GetEventDelegate = type =>
            {
                if (type == typeof(ShoppingCartUpdatedEvent)) return shoppingCartUpdatedEvent;
                if (type == typeof(ShoppingCartItemUpdatedEvent)) return new ShoppingCartItemUpdatedEvent();
                return null;
            };
            var accountService = new MockAccountService();
            accountService.GetSignedInUserAsyncDelegate = () => Task.FromResult((UserInfo)null);
            var target = new ShoppingCartTabUserControlViewModel(shoppingCartRepository, eventAggregator, null, new AlertMessageService(), null, accountService);

            shoppingCart = new ShoppingCart(new List<ShoppingCartItem>()
                                               {
                                                   new ShoppingCartItem {Quantity = 1},
                                                   new ShoppingCartItem {Quantity = 2}
                                               });

            Assert.AreEqual(0, target.ItemCount);

            shoppingCartUpdatedEvent.Publish(null);

            Assert.AreEqual(3, target.ItemCount);

        }
Esempio n. 6
0
        public void EventManagerTests_FireEvent_FoundEvent_ValidArguments()
        {
            LogUtility.SetLogToConsole();
            InvalidTimeZoneException workaroundStuff = new InvalidTimeZoneException();
            var mockAggregator = new MockEventAggregator(new List <Type> {
                typeof(EntityMoveEvent)
            });

            EventManager._aggregator = mockAggregator;

            try
            {
                var result = EventManager.FireEvent("EntityMoveEvent", new object[]
                {
                    false,
                    new UnityEngine.Vector3(),
                    new UnityEngine.Vector3(),
                    null,                     //new World(),
                    new {
                        pos = 12,
                        rot = 241
                    }
                });
            }
            catch (SurvivalKitPluginException exception)
            {
                // exception should not- be thrown. constructor arguments are correct.
                Assert.IsNotNull(exception);
                Assert.Fail("Code should not reach this part.");
            }
        }
        public void OnNavigatedTo_Fill_Properties_No_Shopping_Cart_Items()
        {
            var navigationService = new MockNavigationService();
            var shoppingCartRepository = new MockShoppingCartRepository();
            shoppingCartRepository.GetShoppingCartAsyncDelegate = () =>
            {
                var shoppingCartItems = new List<ShoppingCartItem>();
                shoppingCartItems.Add(new ShoppingCartItem { Quantity = 1, Product = new Product { ListPrice = 200, DiscountPercentage = 50}, Currency = "USD" });
                ShoppingCart shoppingCart = new ShoppingCart(new ObservableCollection<ShoppingCartItem>(shoppingCartItems)) { Currency = "USD" };
                return Task.FromResult(shoppingCart);
            };

            bool signInUserControlOnNavigatedToCalled = false;
            var signInUserControlViewModel = new MockSignInUserControlViewModel()
                {
                    OnNavigatedToDelegate = (a, b, c) => signInUserControlOnNavigatedToCalled = true
                };

            var eventAggregator = new MockEventAggregator();
            eventAggregator.GetEventDelegate = type => new MockShoppingCartUpdatedEvent();

            var target = new ShoppingCartPageViewModel(shoppingCartRepository, navigationService, new MockAccountService(), signInUserControlViewModel, null, null, null, null, eventAggregator);
            target.OnNavigatedTo(new NavigatedToEventArgs { Parameter = null, NavigationMode = NavigationMode.New }, null);

            Assert.IsTrue(signInUserControlOnNavigatedToCalled);
            Assert.AreEqual("$200.00", target.FullPrice);
            Assert.AreEqual("$100.00", target.TotalDiscount);
            Assert.AreEqual(1, target.ShoppingCartItemViewModels.Count);
        }
        public void OnNavigatedTo_Fill_Properties_With_Shopping_Cart_Items()
        {
            var navigationService = new MockNavigationService();
            var shoppingCartRepository = new MockShoppingCartRepository();
            shoppingCartRepository.GetShoppingCartAsyncDelegate = () =>
            {
                ShoppingCart shoppingCart = null;
                var shoppingCartItems = new ObservableCollection<ShoppingCartItem>
                                            {
                                                new ShoppingCartItem() {Product = new Product { ListPrice = 100, ProductNumber = "p1", ImageUri = new Uri("http://image")}, Currency = "USD", Quantity = 1}, 
                                                new ShoppingCartItem() {Product = new Product { ListPrice = 100, ProductNumber = "p2", ImageUri = new Uri("http://image")}, Currency = "USD", Quantity = 1}
                                            };
                shoppingCart = new ShoppingCart(shoppingCartItems) { Currency = "USD"};

                return Task.FromResult(shoppingCart);
            };
            var eventAggregator = new MockEventAggregator();
            eventAggregator.GetEventDelegate = type => new MockShoppingCartUpdatedEvent();
            var target = new ShoppingCartPageViewModel(shoppingCartRepository, navigationService, new MockAccountService(), null, null, null, null, null, eventAggregator);
            target.OnNavigatedTo(null, NavigationMode.New, null);

            Assert.AreEqual("$200.00", target.FullPrice);
            Assert.AreEqual("$100.00", target.TotalDiscount);
            Assert.AreEqual(2, target.ShoppingCartItemViewModels.Count);
        }
        public async Task Remove_InvalidatesCachedCart()
        {
            var shoppingCartService = new MockShoppingCartService
            {
                RemoveShoppingCartItemDelegate = (s, s1) => Task.FromResult(string.Empty),
                GetShoppingCartAsyncDelegate   = s => Task.FromResult(new ShoppingCart(new Collection <ShoppingCartItem>())
                {
                    Id = "first"
                })
            };
            var eventAggregator = new MockEventAggregator
            {
                GetEventDelegate = type => new ShoppingCartItemUpdatedEvent()
            };
            var target            = new ShoppingCartRepository(shoppingCartService, null, eventAggregator, new MockSessionStateService());
            var firstCartReturned = await target.GetShoppingCartAsync();

            await target.RemoveShoppingCartItemAsync("TestShoppingCartItemId");

            shoppingCartService.GetShoppingCartAsyncDelegate = s => Task.FromResult(new ShoppingCart(new Collection <ShoppingCartItem>())
            {
                Id = "second"
            });
            var secondCartReturned = await target.GetShoppingCartAsync();

            Assert.IsNotNull(firstCartReturned);
            Assert.IsNotNull(secondCartReturned);
            Assert.AreNotSame(firstCartReturned, secondCartReturned);
        }
 public void SetUp()
 {
     this.eventAggregator      = new MockEventAggregator();
     this.view                 = new MockOverlaysView();
     this.assetsAvailableEvent = new MockAssetsAvailableEvent();
     this.eventAggregator.AddMapping <AssetsAvailableEvent>(this.assetsAvailableEvent);
 }
Esempio n. 11
0
        protected void Configure()
        {
            var mockEventAggregator           = new MockEventAggregator();
            var mockSubsonicService           = new MockSubsonicService();
            var mockNavigationService         = new MockNavigationService();
            var mockNotificationService       = new MockToastNotificationService();
            var mockDialogNotificationService = new MockDialogNotificationService();
            var mockStorageService            = new MockStorageService();
            var mockWinRTWrappersService      = new MockWinRTWrappersService();
            var shellViewModel = new ShellViewModel(mockEventAggregator, mockSubsonicService, mockNavigationService,
                                                    mockNotificationService, mockDialogNotificationService, mockStorageService, mockWinRTWrappersService);

            IoC.GetInstance = (type, s) =>
            {
                object instance = null;
                if (type == typeof(IShellViewModel))
                {
                    instance = shellViewModel;
                }
                else if (type == typeof(ISubsonicService))
                {
                    instance = mockSubsonicService;
                }
                return(instance);
            };
        }
Esempio n. 12
0
 public void SetUp()
 {
     view              = new MockWatchListView();
     watchListService  = new MockWatchListService();
     marketFeedService = new MockMarketFeedService();
     eventAggregator   = new MockEventAggregator();
 }
 public void SetUp()
 {
     view = new MockWatchListView();
     watchListService = new MockWatchListService();
     marketFeedService = new MockMarketFeedService();
     eventAggregator = new MockEventAggregator();
 }
Esempio n. 14
0
        /// <summary>
        /// Given
        /// </summary>
        public override void Given()
        {
            base.Given();

            _eventAggregator = new MockEventAggregator();
            EventAggregator.SetAggregator(_eventAggregator);
        }
        public void CartUpdatedEventRaised_WhenUserChanged()
        {
            var shoppingCartUpdatedRaised = false;
            var accountService            = new MockAccountService();
            var shoppingCartUpdatedEvent  = new MockShoppingCartUpdatedEvent()
            {
                PublishDelegate = () => shoppingCartUpdatedRaised = true
            };
            var eventAggregator = new MockEventAggregator()
            {
                GetEventDelegate = (a) => shoppingCartUpdatedEvent
            };
            var shoppingCartService = new MockShoppingCartService()
            {
                MergeShoppingCartsAsyncDelegate = (s, s1) => Task.FromResult(false)
            };

            var target = new ShoppingCartRepository(shoppingCartService, accountService, eventAggregator, new MockSessionStateService());

            accountService.RaiseUserChanged(new UserInfo {
                UserName = "******"
            }, null);

            Assert.IsTrue(shoppingCartUpdatedRaised);
        }
Esempio n. 16
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");
        }
        public void SetUp()
        {
            this.view           = new MockSettingsView();
            this.projectService = new MockProjectService();
            this.projectService.GetCurrentProjectReturnValue.AutoSaveInterval = 30;
            this.aspectRatioChangedEvent   = new MockAspectRatioChangedEvent();
            this.smpteTimeCodeChangedEvent = new MockSmtpeTimeCodeChangedEvent();
            this.startTimeCodeChangedEvent = new MockStartTimeCodeChangedEvent();
            this.editModeChangedEvent      = new MockEditModeChangedEvent();
            this.pickThumbnailEvent        = new MockPickThumbnailEvent();
            this.thumbnailEvent            = new MockThumbnailEvent();
            this.regionManager             = new MockRegionManager();
            this.toolsRegion = new MockRegion {
                Name = RegionNames.ToolsRegion
            };

            this.regionManager.Regions.Add(this.toolsRegion);

            this.eventAggregator = new MockEventAggregator();
            this.eventAggregator.AddMapping <AspectRatioChangedEvent>(this.aspectRatioChangedEvent);
            this.eventAggregator.AddMapping <SmpteTimeCodeChangedEvent>(this.smpteTimeCodeChangedEvent);
            this.eventAggregator.AddMapping <StartTimeCodeChangedEvent>(this.startTimeCodeChangedEvent);
            this.eventAggregator.AddMapping <EditModeChangedEvent>(this.editModeChangedEvent);
            this.eventAggregator.AddMapping <PickThumbnailEvent>(this.pickThumbnailEvent);
            this.eventAggregator.AddMapping <ThumbnailEvent>(this.thumbnailEvent);
        }
Esempio n. 18
0
        public void SetUp()
        {
            this.view                 = new MockSettingsView();
            this.projectService       = new MockProjectService();
            this.configurationService = new MockConfigurationService();

            this.projectService.GetCurrentProjectReturnValue.AutoSaveInterval = 30;
            this.aspectRatioChangedEvent   = new MockAspectRatioChangedEvent();
            this.smpteTimeCodeChangedEvent = new MockSmtpeTimeCodeChangedEvent();
            this.startTimeCodeChangedEvent = new MockStartTimeCodeChangedEvent();
            this.editModeChangedEvent      = new MockEditModeChangedEvent();
            this.pickThumbnailEvent        = new MockPickThumbnailEvent();
            this.resetWindowsEvent         = new MockResetWindowsEvent();
            this.thumbnailEvent            = new MockThumbnailEvent();
            this.regionManager             = new MockRegionManager();
            this.mainRegion = new MockRegion {
                Name = RegionNames.MainRegion
            };
            this.userSettingsService = new MockUserSettingsService();
            this.persistenceService  = new MockPersistenceService();

            this.regionManager.Regions.Add(this.mainRegion);

            this.eventAggregator = new MockEventAggregator();
            this.eventAggregator.AddMapping <AspectRatioChangedEvent>(this.aspectRatioChangedEvent);
            this.eventAggregator.AddMapping <SmpteTimeCodeChangedEvent>(this.smpteTimeCodeChangedEvent);
            this.eventAggregator.AddMapping <StartTimeCodeChangedEvent>(this.startTimeCodeChangedEvent);
            this.eventAggregator.AddMapping <EditModeChangedEvent>(this.editModeChangedEvent);
            this.eventAggregator.AddMapping <PickThumbnailEvent>(this.pickThumbnailEvent);
            this.eventAggregator.AddMapping <ThumbnailEvent>(this.thumbnailEvent);
            this.eventAggregator.AddMapping <ResetWindowsEvent>(this.resetWindowsEvent);
        }
        public void ShoppingCartUpdated_WithNullCart_SetsItemCountZero()
        {
            var shoppingCartRepository = new MockShoppingCartRepository();
            var shoppingCart = new ShoppingCart(new List<ShoppingCartItem> {new ShoppingCartItem {Quantity = 99}});
            shoppingCartRepository.GetShoppingCartAsyncDelegate = () => Task.FromResult(shoppingCart);
            var eventAggregator = new MockEventAggregator();
            var shoppingCartUpdatedEvent = new ShoppingCartUpdatedEvent();
            eventAggregator.GetEventDelegate = type =>
            {
                if (type == typeof(ShoppingCartUpdatedEvent)) return shoppingCartUpdatedEvent;
                if (type == typeof(ShoppingCartItemUpdatedEvent)) return new ShoppingCartItemUpdatedEvent();
                return null;
            };
            var accountService = new MockAccountService();
            accountService.VerifyUserAuthenticationAsyncDelegate = () => Task.FromResult((UserInfo)null);
            var target = new ShoppingCartTabUserControlViewModel(shoppingCartRepository, eventAggregator, null, null, accountService);

            shoppingCartUpdatedEvent.Publish(null);

            Assert.AreEqual(99, target.ItemCount);

            shoppingCartRepository.GetShoppingCartAsyncDelegate = () => Task.FromResult<ShoppingCart>(null);
            shoppingCartUpdatedEvent.Publish(null);

            Assert.AreEqual(0, target.ItemCount);
        }
Esempio n. 20
0
        public void Checkout_WhenAnonymous_ShowsSignInFlyout()
        {
            var modalCalled    = false;
            var accountService = new MockAccountService
            {
                VerifyUserAuthenticationAsyncDelegate = () => Task.FromResult <UserInfo>(null)
            };
            var signInUserControlViewModel = new MockSignInUserControlViewModel
            {
                OpenDelegate = (s) =>
                {
                    modalCalled = true;
                    Assert.IsNotNull(s);
                }
            };
            var checkoutDataRepository = new MockCheckoutDataRepository()
            {
                GetDefaultShippingAddressAsyncDelegate = () => null,
                GetDefaultBillingAddressAsyncDelegate  = () => null,
                GetDefaultPaymentMethodAsyncDelegate   = () => Task.FromResult <PaymentMethod>(null)
            };
            var eventAggregator = new MockEventAggregator
            {
                GetEventDelegate = type => new MockShoppingCartUpdatedEvent()
            };
            var target = new ShoppingCartPageViewModel(null, new MockNavigationService(), accountService, signInUserControlViewModel, null, null, checkoutDataRepository, null, eventAggregator);

            target.CheckoutCommand.Execute();

            Assert.IsTrue(modalCalled);
        }
 public void SetUp()
 {
     this.sequenceMetadataView            = new MockSequenceMetadataView();
     this.sequenceRegistry                = new MockSequenceRegistry();
     this.eventAggregator                 = new MockEventAggregator();
     this.displayMarkerBrowserWindowEvent = new MockDisplayMarkerBrowserWindowEvent();
     this.eventAggregator.AddMapping <DisplayMarkerBrowserWindowEvent>(this.displayMarkerBrowserWindowEvent);
 }
Esempio n. 22
0
        protected override void TestInitializeExtensions()
        {
            _eventAggregator = new MockEventAggregator();

            var bottomBarViewModel = new DefaultBottomBarViewModel(MockNavigationService, _eventAggregator);

            Subject.BottomBar = bottomBarViewModel;
        }
Esempio n. 23
0
        private static IEventAggregator CreateEventAggregator()
        {
            var eventAggregator = new MockEventAggregator();

            eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent());

            return(eventAggregator);
        }
 public void SetUp()
 {
     view = new MockPositionSummaryView();
     ordersController = new MockOrdersController();
     observablePosition = new MockObservablePosition();
     this.eventAggregator = new MockEventAggregator();
     eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
 }
 public void SetUp()
 {
     view                 = new MockPositionSummaryView();
     ordersController     = new MockOrdersController();
     observablePosition   = new MockObservablePosition();
     this.eventAggregator = new MockEventAggregator();
     eventAggregator.AddMapping <TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
 }
Esempio n. 26
0
        public void SetUp()
        {
            var discardPile = new DiscardPile();
            var deck        = new Deck(7.Coppers(), 3.Estates());

            _eventAggregator = new MockEventAggregator();
            player           = new Player(deck, discardPile, new NaivePlayerController());
        }
Esempio n. 27
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"
            }));
        }
Esempio n. 28
0
        public void SetUp()
        {
            this.eventAggregator = new MockEventAggregator();
            this.operationExecutedInTimelineEvent = new MockOperationExecutedInTimelineEvent();
            this.operationUndoneInTimeline        = new MockOperationUndoneInTimeline();

            this.eventAggregator.AddMapping <OperationExecutedInTimelineEvent>(this.operationExecutedInTimelineEvent);
            this.eventAggregator.AddMapping <OperationUndoneInTimelineEvent>(this.operationUndoneInTimeline);
        }
 public void TestInitialize()
 {
     IoC.GetInstance    = (type, s) => null;
     _eventAggregator   = new MockEventAggregator();
     _navigationService = new MockNavigationService();
     _subject           = new DefaultBottomBarViewModel(_navigationService, _eventAggregator)
     {
         Navigate = _navigationService.DoNavigate
     };
 }
 public void SetUp()
 {
     view = new MockPositionSummaryView();
     accountPositionService = new MockAccountPositionService();
     marketFeedService = new MockMarketFeedService();
     marketHistoryService = new MockMarketHistoryService();
     trendLinePresenter = new MockTrendLinePresenter();
     ordersController = new MockOrdersController();
     this.eventAggregator = new MockEventAggregator();
 }
 public void SetUp()
 {
     view = new MockPositionSummaryView();
     accountPositionService = new MockAccountPositionService();
     marketFeedService      = new MockMarketFeedService();
     marketHistoryService   = new MockMarketHistoryService();
     trendLinePresenter     = new MockTrendLinePresenter();
     ordersController       = new MockOrdersController();
     this.eventAggregator   = new MockEventAggregator();
 }
 public void TestInitialize()
 {
     this.view                 = new MockSubClipView();
     this.eventAggregator      = new MockEventAggregator();
     this.resetWindowsEvent    = new MockResetWindowsEvent();
     this.addPreviewEvent      = new MockAddPreviewEvent();
     this.configurationService = new MockConfigurationService();
     this.eventAggregator.AddMapping <ResetWindowsEvent>(this.resetWindowsEvent);
     this.eventAggregator.AddMapping <AddPreviewEvent>(this.addPreviewEvent);
 }
        public void CanInitPresenter()
        {
            var historyService = new MockMarketHistoryService();
            var view = new MockTrendLineView();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            TrendLinePresentationModel presentationModel = new TrendLinePresentationModel(view, historyService, eventAggregator);

            Assert.IsNotNull(presentationModel);
        }
Esempio n. 34
0
        public void CanInitPresenter()
        {
            var historyService  = new MockMarketHistoryService();
            var view            = new MockTrendLineView();
            var eventAggregator = new MockEventAggregator();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            TrendLinePresentationModel presentationModel = new TrendLinePresentationModel(view, historyService, eventAggregator);

            Assert.IsNotNull(presentationModel);
        }
Esempio n. 35
0
        public void ShoppingCartUpdated_WhenShoppingCartChanged()
        {
            var navigationService      = new MockNavigationService();
            var accountService         = new MockAccountService();
            var shoppingCartRepository = new MockShoppingCartRepository();

            shoppingCartRepository.GetShoppingCartAsyncDelegate = () =>
            {
                ShoppingCart shoppingCart = new ShoppingCart(new ObservableCollection <ShoppingCartItem>())
                {
                    Currency = "USD"
                };
                return(Task.FromResult(shoppingCart));
            };
            bool signInUserControlOnNavigatedToCalled = false;
            var  signInUserControlViewModel           = new MockSignInUserControlViewModel()
            {
                OnNavigatedToDelegate = (a, b, c) => signInUserControlOnNavigatedToCalled = true
            };
            var eventAggregator          = new MockEventAggregator();
            var shoppingCartUpdatedEvent = new ShoppingCartUpdatedEvent();

            eventAggregator.GetEventDelegate = type => shoppingCartUpdatedEvent;
            var target = new ShoppingCartPageViewModel(shoppingCartRepository, navigationService, accountService, signInUserControlViewModel, null, null, null, null, eventAggregator);

            target.OnNavigatedTo(new NavigatedToEventArgs {
                Parameter = null, NavigationMode = NavigationMode.New
            }, null);

            Assert.AreEqual("$0.00", target.FullPrice);

            shoppingCartRepository.GetShoppingCartAsyncDelegate = () =>
            {
                var shoppingCartItems = new ObservableCollection <ShoppingCartItem>
                {
                    new ShoppingCartItem()
                    {
                        Product = new Product {
                            ListPrice = 100, ProductNumber = "p1", ImageUri = new Uri("http://image")
                        }, Currency = "USD", Quantity = 2
                    },
                };
                ShoppingCart shoppingCart = new ShoppingCart(new ObservableCollection <ShoppingCartItem>(shoppingCartItems))
                {
                    Currency = "USD"
                };
                return(Task.FromResult(shoppingCart));
            };

            shoppingCartUpdatedEvent.Publish(null);

            Assert.IsTrue(signInUserControlOnNavigatedToCalled);
            Assert.AreEqual("$200.00", target.FullPrice);
        }
Esempio n. 36
0
        public void ShowNewsResolvesPresenterAndCallsSetTickerSymbolOnItAndAddsNamedViewToRegion()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var controller = new NewsController(CreateRegionManager(), presenter, eventAggregator, new MockNewsReaderPresenter());

            controller.ShowNews("Test");

            Assert.IsNotNull(presenter.SetTickerSymbolArgumentCompanySymbol);
            Assert.AreEqual("Test", presenter.SetTickerSymbolArgumentCompanySymbol);
        }
Esempio n. 37
0
        public void ShouldNotifyReaderWhenCurrentNewsArticleChanges()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();
            var controller = new NewsController(CreateRegionManager(), presenter, eventAggregator, newsReaderPresenter);

            controller.CurrentNewsArticleChanged(new NewsArticle() { Title = "SomeTitle", Body = "Newsbody" });

            Assert.IsTrue(newsReaderPresenter.SetNewsArticleCalled);
        }
 protected override void ConfigureContainer(StructureMap.IContainer container)
 {
     container.Configure(cfg =>
     {
         cfg.For <IEventAggregator>().Singleton().Use <MockEventAggregator>();
         cfg.For <Deck>().Singleton().Use(new Deck(7.Coppers(), 3.Estates()));
         cfg.For <DiscardPile>().Use <DiscardPile>();
         cfg.For <Player>().Use <Player>().Ctor <string>().Is("Test player");
         cfg.For <Guid>().Use(Guid.NewGuid);
     });
     _eventAggregator = container.GetInstance <IEventAggregator>() as MockEventAggregator;
 }
        public void SetUp()
        {
            this.view = new MockMetadataView();
            this.showMetadataEvent = new MockShowMetadataEvent();
            this.hideMetadataEvent = new MockHideMetadataEvent();

            this.configurationService = new MockConfigurationService();
            this.eventAggregator      = new MockEventAggregator();

            this.eventAggregator.AddMapping <ShowMetadataEvent>(this.showMetadataEvent);
            this.eventAggregator.AddMapping <HideMetadataEvent>(this.hideMetadataEvent);
        }
        public void SetUp()
        {
            this.view            = new MockNotificationView();
            this.projectService  = new MockProjectService();
            this.eventAggregator = new MockEventAggregator();
            this.errorView       = new MockErrorView();

            this.saveProjectEvent = new MockSaveProjectEvent();
            this.statusEvent      = new MockStatusEvent();

            this.eventAggregator.AddMapping <SaveProjectEvent>(this.saveProjectEvent);
            this.eventAggregator.AddMapping <StatusEvent>(this.statusEvent);
        }
Esempio n. 41
0
        public void ShowNewsResolvesPresenterAndCallsSetTickerSymbolOnItAndAddsNamedViewToRegion()
        {
            var presenter       = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var controller = new NewsController(CreateRegionManager(), presenter, eventAggregator, new MockNewsReaderPresenter());

            controller.ShowNews("Test");

            Assert.IsNotNull(presenter.SetTickerSymbolArgumentCompanySymbol);
            Assert.AreEqual("Test", presenter.SetTickerSymbolArgumentCompanySymbol);
        }
        public void PresenterUnsubcribesFromFundAddedEventIfCustomerIDIsSetTwice()
        {
            var mockEventAggregator = new MockEventAggregator();

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

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

            Assert.AreEqual(1, mockEvent.SubscribeCount);
        }
Esempio n. 43
0
        public void ControllerShowNewsWhenRasingGlobalEvent()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            var tickerSymbolSelectedEvent = new MockTickerSymbolSelectedEvent();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(tickerSymbolSelectedEvent);
            var controller = new NewsController(CreateRegionManager(), presenter, eventAggregator, new MockNewsReaderPresenter());

            controller.Run();

            Assert.IsNotNull(tickerSymbolSelectedEvent.SubscribeArgumentAction);

            tickerSymbolSelectedEvent.SubscribeArgumentAction("TEST_SYMBOL");
            Assert.AreEqual("TEST_SYMBOL", presenter.SetTickerSymbolArgumentCompanySymbol);
        }
        public void PresenterSubscribesToFundAddedForCorrectCustomer()
        {
            var mockEventAggregator = new MockEventAggregator();

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

            presenter.CustomerId = "ALFKI";

            Assert.IsTrue(mockEvent.SubscribeArgumentFilter(new FundOrder { CustomerId = "ALFKI" }));
            Assert.AreEqual(ThreadOption.UIThread, mockEvent.ThreadOption);
            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.SubscribeArgumentAction(payload);
            StringAssert.Contains(view.AddContentArgumentContent, "MSFT");
        }
Esempio n. 46
0
        public void ControllerShowNewsViewWhenArticlePresenterReceivesEvent()
        {
            var articlePresentationModel = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();
            var regionManager = CreateRegionManager();
            var shellRegion = (MockRegion)regionManager.Regions["SecondaryRegion"];

            var controller = new NewsController(regionManager, articlePresentationModel, eventAggregator, newsReaderPresenter);

            controller.ShowNewsReader();

            Assert.IsTrue(shellRegion.ActivateCalled);
            Assert.AreEqual(newsReaderPresenter.View, shellRegion.ActivateArg);
        }
Esempio n. 47
0
        public void PresenterPublishesFundAddedOnViewAddClick()
        {
            var view = new MockAddFundView();
            var EventAggregator = new MockEventAggregator();
            var mockFundAddedEvent = new MockFundAddedEvent();
            EventAggregator.AddMapping<FundAddedEvent>(mockFundAddedEvent);
            var presenter = new AddFundPresenter(EventAggregator);
            presenter.View = view;
            view.Customer = "99";
            view.Fund = "TestFund";

            view.PublishAddClick();

            Assert.IsTrue(mockFundAddedEvent.PublishCalled);
            Assert.AreEqual("99", mockFundAddedEvent.PublishArgumentPayload.CustomerId);
            Assert.AreEqual("TestFund", mockFundAddedEvent.PublishArgumentPayload.TickerSymbol);
        }
        public void ShouldUpdateModelWithDataFromServiceOnTickerSymbolSelected()
        {
            var historyService = new MockMarketHistoryService();
            var eventAggregator = new MockEventAggregator();
            var tickerSymbolSelected = new MockTickerSymbolSelectedEvent();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(tickerSymbolSelected);
            TrendLinePresentationModel presentationModel = new TrendLinePresentationModel(new MockTrendLineView(), historyService, eventAggregator);

            tickerSymbolSelected.SubscribeArgumentAction("MyTickerSymbol");
            
            Assert.IsTrue(historyService.GetPriceHistoryCalled);
            Assert.AreEqual("MyTickerSymbol", historyService.GetPriceHistoryArgument);
            Assert.IsNotNull(presentationModel.HistoryCollection);
            Assert.AreEqual(historyService.Data.Count, presentationModel.HistoryCollection.Count);
            Assert.AreEqual(historyService.Data[0], presentationModel.HistoryCollection[0]);
            Assert.AreEqual("MyTickerSymbol", presentationModel.TickerSymbol);
        }
        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 CartItemUpdatedEventRaised_WhenProductRemoved()
        {
            var shoppingCartItemUpdatedRaised = false;
            var shoppingCartService = new MockShoppingCartService();
            shoppingCartService.RemoveProductFromShoppingCartAsyncDelegate =
                (s, s1) => Task.FromResult(string.Empty);
            var shoppingCartItemUpdatedEvent = new ShoppingCartItemUpdatedEvent();
            shoppingCartItemUpdatedEvent.Subscribe((_) =>
            {
                shoppingCartItemUpdatedRaised = true;
            });
            var eventAggregator = new MockEventAggregator();
            eventAggregator.GetEventDelegate = type => shoppingCartItemUpdatedEvent;
            var target = new ShoppingCartRepository(shoppingCartService, new MockAccountService(), eventAggregator, new MockProductCatalogRepository(), new MockSuspensionManagerState());

            target.RemoveProductFromShoppingCartAsync("TestProductId");

            Assert.IsTrue(shoppingCartItemUpdatedRaised);
        }
        public async void CartItemUpdatedEventRaised_WhenProductAdded()
        {
            var shoppingCartItemUpdatedRaised = false;
            var shoppingCartService = new MockShoppingCartService();
            shoppingCartService.AddProductToShoppingCartAsyncDelegate =
                (s, s1) => Task.FromResult(string.Empty);
            var shoppingCartItemUpdatedEvent = new ShoppingCartItemUpdatedEvent();
            shoppingCartItemUpdatedEvent.Subscribe((_) =>
                                                   {
                                                       shoppingCartItemUpdatedRaised = true;
                                                   });
            var eventAggregator = new MockEventAggregator();
            eventAggregator.GetEventDelegate = type => shoppingCartItemUpdatedEvent;
            var target = new ShoppingCartRepository(shoppingCartService, new MockAccountService(), eventAggregator, new MockSessionStateService());

            await target.AddProductToShoppingCartAsync("TestProductId");

            Assert.IsTrue(shoppingCartItemUpdatedRaised);
        }
        public void OnNavigatedTo_Fill_Properties_No_Shopping_Cart_Items()
        {
            var navigationService = new MockNavigationService();
            var shoppingCartRepository = new MockShoppingCartRepository();
            shoppingCartRepository.GetShoppingCartAsyncDelegate = () =>
            {
                var shoppingCartItems = new List<ShoppingCartItem>();
                shoppingCartItems.Add(new ShoppingCartItem { Quantity = 1, Product = new Product { ListPrice = 200}, Currency = "USD" });
                ShoppingCart shoppingCart = new ShoppingCart(new ObservableCollection<ShoppingCartItem>(shoppingCartItems)) { Currency = "USD" };
                return Task.FromResult(shoppingCart);
            };
            var eventAggregator = new MockEventAggregator();
            eventAggregator.GetEventDelegate = type => new MockShoppingCartUpdatedEvent();

            var target = new ShoppingCartPageViewModel(shoppingCartRepository, navigationService, new MockAccountService(), null, null, null, null, null, eventAggregator);
            target.OnNavigatedTo(null, NavigationMode.New, null);

            Assert.AreEqual("$200.00", target.FullPrice);
            Assert.AreEqual("$100.00", target.TotalDiscount);
            Assert.AreEqual(1, target.ShoppingCartItemViewModels.Count);
        }
        public void NavigatedTo_CalculatesTotalNumberOfItemsInCart()
        {
            var shoppingCart = new ShoppingCart(new List<ShoppingCartItem>()
                                               {
                                                   new ShoppingCartItem {Quantity = 1},
                                                   new ShoppingCartItem {Quantity = 2}
                                               });
            var shoppingCartRepository = new MockShoppingCartRepository();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.GetEventDelegate = type =>
            {
                if (type == typeof(ShoppingCartUpdatedEvent)) return new ShoppingCartUpdatedEvent();
                if (type == typeof(ShoppingCartItemUpdatedEvent)) return new ShoppingCartItemUpdatedEvent();
                return null;
            };
            var accountService = new MockAccountService();
            accountService.VerifyUserAuthenticationAsyncDelegate = () => Task.FromResult((UserInfo)null);
            shoppingCartRepository.GetShoppingCartAsyncDelegate = () => Task.FromResult(shoppingCart);
            var target = new ShoppingCartTabUserControlViewModel(shoppingCartRepository, eventAggregator, null, null, accountService);

            Assert.AreEqual(3, target.ItemCount);
        }
        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 async Task CartItemUpdatedEventRaised_WhenItemRemoved()
        {
            var shoppingCartItemUpdatedRaised = false;
            var shoppingCartService = new MockShoppingCartService()
                {
                    RemoveShoppingCartItemDelegate = (s, s1) =>
                        {
                            Assert.AreEqual("TestShoppingCartItemId", s1);
                            return Task.FromResult(string.Empty);
                        }
                };
            var shoppingCartItemUpdatedEvent = new ShoppingCartItemUpdatedEvent();
            shoppingCartItemUpdatedEvent.Subscribe((a) => shoppingCartItemUpdatedRaised = true);

            var eventAggregator = new MockEventAggregator()
                {
                    GetEventDelegate = (a) => shoppingCartItemUpdatedEvent
                };

            var target = new ShoppingCartRepository(shoppingCartService, new MockAccountService(), eventAggregator, new MockProductCatalogRepository(), new MockSuspensionManagerState());
            await target.RemoveShoppingCartItemAsync("TestShoppingCartItemId");

            Assert.IsTrue(shoppingCartItemUpdatedRaised);
        }
Esempio n. 56
0
        public void ControllerShowNewsViewWhenArticlePresenterReceivesEvent()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();

            var controller = new NewsController(new MockRegionManager(), presenter, eventAggregator, newsReaderPresenter);

            controller.ShowNewsReader();

            Assert.IsTrue(newsReaderPresenter.ShowWasCalled);
        }
 public void Setup()
 {
     _eventAggregator = new MockEventAggregator();
     _subject = new MediaControlHandler(_eventAggregator);
 }
Esempio n. 58
0
        private static IEventAggregator CreateEventAggregator()
        {
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent());

            return eventAggregator;
        }
        public void ShoppingCartUpdated_WithNullCart_SetsItemCountZero()
        {
            var shoppingCartRepository = new MockShoppingCartRepository();
            shoppingCartRepository.GetShoppingCartAsyncDelegate = () => Task.FromResult<ShoppingCart>(null);
            var eventAggregator = new MockEventAggregator();
            var shoppingCartUpdatedEvent = new ShoppingCartUpdatedEvent();
            eventAggregator.GetEventDelegate = type =>
            {
                if (type == typeof(ShoppingCartUpdatedEvent)) return shoppingCartUpdatedEvent;
                if (type == typeof(ShoppingCartItemUpdatedEvent)) return new ShoppingCartItemUpdatedEvent();
                return null;
            };
            var accountService = new MockAccountService();
            accountService.GetSignedInUserAsyncDelegate = () => Task.FromResult((UserInfo)null);
            var target = new ShoppingCartTabUserControlViewModel(shoppingCartRepository, eventAggregator, null, new AlertMessageService(), null, accountService);
            target.ItemCount = 99;

            shoppingCartUpdatedEvent.Publish(null);

            Assert.AreEqual(0, target.ItemCount);
        }
        public void ExecutingShoppingCartCommand_NavigatesToShoppingCart()
        {
            var navigateCalled = false;
            var navigationService = new MockNavigationService();
            navigationService.NavigateDelegate = (s, o) =>
                                                     {
                                                         Assert.AreEqual("ShoppingCart", s);
                                                         navigateCalled = true;
                                                         return true;
                                                     };
            var eventAggregator = new MockEventAggregator();
            eventAggregator.GetEventDelegate = type =>
            {
                if (type == typeof(ShoppingCartUpdatedEvent)) return new ShoppingCartUpdatedEvent();
                if (type == typeof(ShoppingCartItemUpdatedEvent)) return new ShoppingCartItemUpdatedEvent();
                return null;
            };
            var shoppingCartRepository = new MockShoppingCartRepository();
            shoppingCartRepository.GetShoppingCartAsyncDelegate = () => Task.FromResult(new ShoppingCart(null));
            var accountService = new MockAccountService();
            accountService.GetSignedInUserAsyncDelegate = () => Task.FromResult((UserInfo)null);
            var target = new ShoppingCartTabUserControlViewModel(shoppingCartRepository, eventAggregator, navigationService, new AlertMessageService(), null, accountService);
            target.ShoppingCartTabCommand.Execute();

            Assert.IsTrue(navigateCalled);
        }