Exemple #1
0
        public async Task HandleStartButtonClicked_Test_Success()
        {
            // arrange
            var          fakeService = A.Fake <IWishlistService>();
            WishlistItem item1       = new WishlistItem {
                Id = 1
            };
            WishlistItem item2 = new WishlistItem {
                Id = 2
            };
            List <WishlistItem> items = new List <WishlistItem>
            {
                item1,
                item2
            };

            A.CallTo(() => fakeService.GetAll()).Returns(items);
            var           fakeExcelFile = A.Fake <IExcelFile>();
            var           fakeDialog    = A.Fake <IExportDialog>();
            MockPresenter presenter     = new MockPresenter(fakeService, fakeExcelFile, fakeDialog);

            // act
            await presenter.HandleStartButtonClicked(null, null);

            // assert
            Assert.AreEqual("Task complete.", fakeDialog.Label1);
            Assert.AreEqual("2 rows exported", fakeDialog.Label2);
        }
Exemple #2
0
        public async Task HandleStartButtonClicked_Test_Success()
        {
            // arrange
            var    fakeService = A.Fake <IAuthorService>();
            Author author1     = new Author {
                Id = 1, FirstName = "John", LastName = "Smith"
            };
            Author author2 = new Author {
                Id = 2, FirstName = "Jane", LastName = "Doe"
            };
            List <Author> authors = new List <Author>
            {
                author1,
                author2
            };

            A.CallTo(() => fakeService.GetAll()).Returns(authors);
            var           fakeExcelFile = A.Fake <IExcelFile>();
            var           fakeDialog    = A.Fake <IExportDialog>();
            MockPresenter presenter     = new MockPresenter(fakeService, fakeExcelFile, fakeDialog);

            // act
            await presenter.HandleStartButtonClicked(null, null);

            // assert
            Assert.AreEqual("Task complete.", fakeDialog.Label1);
            Assert.AreEqual("2 rows exported", fakeDialog.Label2);
        }
        public async Task HandleStartButtonClicked_Test_Success()
        {
            // arrange
            var fakeService = A.Fake <ITagService>();
            Tag tag1        = new Tag {
                Id = 1, Name = "tag1"
            };
            Tag tag2 = new Tag {
                Id = 2, Name = "tag2"
            };
            List <Tag> tags = new List <Tag>
            {
                tag1,
                tag2
            };

            A.CallTo(() => fakeService.GetAll()).Returns(tags);
            var           fakeExcelFile = A.Fake <IExcelFile>();
            var           fakeDialog    = A.Fake <IExportDialog>();
            MockPresenter presenter     = new MockPresenter(fakeService, fakeExcelFile, fakeDialog);

            // act
            await presenter.HandleStartButtonClicked(null, null);

            // assert
            Assert.AreEqual("Task complete.", fakeDialog.Label1);
            Assert.AreEqual("2 rows exported", fakeDialog.Label2);
        }
        public async Task HandleStartButtonClicked_Test_Success()
        {
            // arrange
            var       fakeService = A.Fake <IPublisherService>();
            Publisher publisher1  = new Publisher {
                Id = 1, Name = "publisher1"
            };
            Publisher publisher2 = new Publisher {
                Id = 2, Name = "publisher2"
            };
            List <Publisher> publishers = new List <Publisher>
            {
                publisher1,
                publisher2
            };

            A.CallTo(() => fakeService.GetAll()).Returns(publishers);
            var           fakeExcelFile = A.Fake <IExcelFile>();
            var           fakeDialog    = A.Fake <IExportDialog>();
            MockPresenter presenter     = new MockPresenter(fakeService, fakeExcelFile, fakeDialog);

            // act
            await presenter.HandleStartButtonClicked(null, null);

            // assert
            Assert.AreEqual("Task complete.", fakeDialog.Label1);
            Assert.AreEqual("2 rows exported", fakeDialog.Label2);
        }
		private void Initialization()
		{
			SetupLogging();
			if (Helper.InDesignerMode)
			{
				DebugMessage = "Mockup Mode";
				Presenter = new MockPresenter(Page.ePageType.AVItemCollectionGallery, Settings.Default.Excluded_Folder_Names);
			}
			else
			{
				Presenter = new UPnPPresenter
								{
									TitlesExcludedFromImageReplacement = Settings.Default.Excluded_Folder_Names,
									ImageWidth = Settings.Default.DefaultImageWidth,
									ImageHeight = Settings.Default.DefaultImageHeight,
									EnableDetailsPage = true,
								};
				DebugMessage = string.Empty;
			}
			Presenter.ParseBegin += OnParseBegin;
			Presenter.ParseEnd += OnParseEnd;

			GalleryViewModel = new GalleryViewModel(_commandSink);
			GalleryViewModel.ExecuteInUIThread += OnExecuteInUIThread;
			PlaybackViewModel = new PlaybackViewModel(_commandSink);
			PlaybackViewModel.ExecuteInUIThread += OnExecuteInUIThread;

			CommandsEnabled = true;

			NavigationCommandList = new ObservableCollection<RoutedCommand>
			                        	{
			                        		AppNavigationCommands.BuyNowCommand,
			                        		AppNavigationCommands.GoToSettingsCommand,
			                        		AppNavigationCommands.GoToSupportCommand,
			                        	};

			//Downloads = new ObservableCollection<Download>();
			//Favorites = new ObservableCollection<Favorite>();
			//PlaylistPaths = new ObservableCollection<PlaylistPath>();

			DataModel = UtilityDataModel.NewContext();
			DataModel.SavedChanges += (sender, args) => RefreshData(null);

			if (!Helper.InDesignerMode)
			{
				StartDataRefresher();
			}

			ReplacementPlaybackExtension = DefaultReplacementPlaybackExtension;
			ReplacePlaybackExtension = Settings.Default.ForceWmvPlayback;
			ShowNavigationZone = Settings.Default.ShowNavigationZone;
			ShowFeedbackZone = Settings.Default.ShowFeedbackZone;
			ShowTitleZone = Settings.Default.ShowTitleZone;

			_commandSink = new CommandSink();
			RegisterCommands();
			CommandsReceived = new ObservableCollection<RoutedCommand>();
			Presenter.PropertyChanged += (o, e) =>
											{
												if (e.PropertyName == "ActivePageType")
												{
													_activePageType = Presenter.ActivePageType;
													OnPropertyChanged("ActivePageType");
												}
											};
		}
Exemple #6
0
 public MockFormView(MockPresenter presenter)
 {
     this.presenter = presenter;
     Load += delegate { presenter.ViewReady(); };
 }
 public MockUserControlView(MockPresenter presenter)
 {
     this.presenter = presenter;
 }
		public GlobalViewModel()
		{
			// TODO: enclose in a designer only test
			if (InDesignerMode)
			{
				DebugMessage = "Mockup Mode";
				Presenter = new MockPresenter(Page.ePageType.AVItemCollectionGallery, Settings.Default.Excluded_Folder_Names);
			}
			else
			{
				Presenter = new UPnPPresenter
								{
									TitlesExcludedFromImageReplacement = Settings.Default.Excluded_Folder_Names,
									ImageWidth = 160,
									ImageHeight = 100,
									EnableDetailsPage = true
								};
				DebugMessage = string.Empty;
			}
			Presenter.ParseBegin += OnParseBegin;
			Presenter.ParseEnd += OnParseEnd;

			GalleryViewModel = new GalleryViewModel();
			GalleryViewModel.ExecuteInUIThread += OnExecuteInUIThread;
			PlaybackViewModel = new PlaybackViewModel();
			PlaybackViewModel.ExecuteInUIThread += OnExecuteInUIThread;

			CommandsEnabled = true;

			NavigationCommandList = new ObservableCollection<RoutedCommand>
			                        	{
			                        		AppNavigationCommands.BuyNowCommand,
											AppNavigationCommands.GoToSettingsCommand,
											AppNavigationCommands.GoToSupportCommand,
			                        	};

			Downloads = new ObservableCollection<Download>();
			Favorites = new ObservableCollection<Favorite>();
			PlaylistPaths = new ObservableCollection<PlaylistPath>();

			DataModel = new UtilityDataModel(UtilityDataModel.ConnectionString);
			DataModel.SavedChanges += (sender, args) => RefreshData();

			foreach (var download in DataModel.Downloads)
			{
				Downloads.Add(download);
			}

			foreach (var favorite in DataModel.Favorites)
			{
				Favorites.Add(favorite);
			}

			foreach (var playlistPath in PlaylistPaths)
			{
				PlaylistPaths.Add(playlistPath);
			}

			Launcher.Fire(() =>
							{
								while (!Done)
								{
									Thread.Sleep(3000);
									RefreshData();
								}
							});

			_commandSink = new CommandSink();

			#region currently not used

			_commandSink.RegisterCommand(_copyUrlCommand, CanExecuteCopyUrlCommand, ExecuteCopyUrlCommand);
			_commandSink.RegisterCommand(GoBackCommand, CanExecuteGoBackCommand, ExecuteGoBackCommand);
			_commandSink.RegisterCommand(GoHomeCommand, CanExecuteGoHomeCommand, ExecuteGoHomeCommand);
			_commandSink.RegisterCommand(GalleryCommand, CanExecuteGalleryCommand, ExecuteGalleryCommand);
			_commandSink.RegisterCommand(PlaybackCommand, CanExecutePlaybackCommand, ExecutePlaybackCommand);
			_commandSink.RegisterCommand(_goToPageCommand, CanExecuteGoToPageCommand, ExecuteGoToPageCommand);

			#endregion

			//_commandSink.RegisterCommand(AppNavigationCommands.GoToFavoritesCommand, CanExecuteGoToFavoritesCommand, ExecuteGoToFavoritesCommand);
			//_commandSink.RegisterCommand(AppNavigationCommands.GoToDownloadsCommand, CanExecuteGoToDownloadsCommand, ExecuteGoToDownloadsCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.GoToSupportCommand, CanExecuteGoToSupportCommand, ExecuteGoToSupportCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.GoToSettingsCommand, CanExecuteGoToSettingsCommand, ExecuteGoToSettingsCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.BuyNowCommand, CanExecuteBuyNowCommand, ExecuteBuyNowCommand);

			_commandSink.RegisterCommand(AppNavigationCommands.FavoriteCommand, CanExecuteFavoriteCommand, ExecuteFavoriteCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.DownloadCommand, CanExecuteDownloadCommand, ExecuteDownloadCommand);
			_commandSink.RegisterCommand(AppNavigationCommands.PlaylistCommand, CanExecutePlaylistCommand, ExecutePlaylistCommand);

			_commandSink.CommandsEnabled = CommandsEnabled;
			PropertyChanged += (o, e) =>
								{
									if (e.PropertyName == "CommandsEnabled")
									{
										_commandSink.CommandsEnabled = CommandsEnabled;
									}
								};

			_commandSink.CommandExecutedNotifier += OnCommandExecuted;

			ReplacementPlaybackExtension = DefaultReplacementPlaybackExtension;
			ReplacePlaybackExtension = Settings.Default.ForceWmvPlayback;
			ShowNavigationZone = Settings.Default.ShowNavigationZone;
			ShowFeedbackZone = Settings.Default.ShowFeedbackZone;
			ShowTitleZone = Settings.Default.ShowTitleZone;

			CommandsReceived = new ObservableCollection<RoutedCommand>();
		}