Ejemplo n.º 1
0
        public TvShowViewModelTests()
        {
            _viewModelFactory  = Substitute.For <ITvShowViewModelFactory>();
            _tvShowFileService = Substitute.For <ITvShowFileService>();
            _metadataService   = Substitute.For <ITvShowMetadataService>();
            _busyProvider      = Substitute.For <IBusyProvider>();
            _keyDataStore      = Substitute.For <IKeyDataStore>();

            _path             = @"C:\Folder\TV Shows\Game of Thrones";
            _viewModelFactory = Substitute.For <ITvShowViewModelFactory>();
            IActorManagerViewModel actorManager = Substitute.For <IActorManagerViewModel>();

            actorManager.Actors
            .Returns(new ObservableCollection <IActorViewModel>());
            _viewModelFactory.GetActorManager(_path, Arg.Any <Action>())
            .Returns(actorManager);

            _viewModel = new TvShowViewModel(_viewModelFactory, _tvShowFileService, _metadataService, _busyProvider, null, null, _keyDataStore, _path);
        }
Ejemplo n.º 2
0
        public async Task Refresh_Always_RefreshesImages()
        {
            // Arrange
            _metadataService.Get(_path)
            .Returns(new TvShowMetadata().ToTask());

            ITvShowImagesViewModel imagesViewModel = Substitute.For <ITvShowImagesViewModel>();

            _viewModelFactory.GetTvShowImages(Arg.Any <ITvShowViewModel>(), _path)
            .Returns(imagesViewModel);
            // Recreate the ViewModel as the ImagesViewModel is retrieved in the constructor
            _viewModel = new TvShowViewModel(_viewModelFactory, _tvShowFileService, _metadataService, _busyProvider, null, null, _keyDataStore, _path);

            // Act
            await _viewModel.Refresh();

            // Assert
            imagesViewModel.Received()
            .Refresh().Async();
        }