예제 #1
0
        public MainViewModel(
            Application app,
            ILogger logger,
            IResourceProvider resProvider,
            IApplicationControlFileProvider appControlFileProvider,
            IFileSystemHelper fsHelper,
            IByteConverter byteConverter,
            ICrashReporter crashReporter,
            IAnalyticsEngine analyticsEngine,
            IGenerator playlistGenerator,
            IDriveVolumeInfoViewFactory driveVolumeInfoViewFactory,
            IApplicationControlFileFactory applicationControlFileFactory) : base(app)
        {
            Logger = logger;
            Logger.Debug(() => $"MainViewModel:ctor");

            ApplicationContext             = app;
            ResourceProvider               = resProvider;
            ApplicationControlFileProvider = appControlFileProvider;
            FileSystemHelper               = fsHelper;
            ByteConverter                 = byteConverter;
            CrashReporter                 = crashReporter;
            AnalyticsEngine               = analyticsEngine;
            PlaylistGenerator             = playlistGenerator;
            DriveVolumeInfoViewFactory    = driveVolumeInfoViewFactory;
            ApplicationControlFileFactory = applicationControlFileFactory;
        }
        public void Setup()
        {
            ResetObservedResults();

            MockApplication = A.Fake <Application>();
            A.CallTo(() => MockApplication.PackageName).Returns("com.andrewandderek.podcastutilities");
            MockLogger           = A.Fake <ILogger>();
            MockResourceProvider = A.Fake <IResourceProvider>();
            MockFileSystemHelper = A.Fake <IFileSystemHelper>();
            MockApplicationControlFileProvider = A.Fake <IApplicationControlFileProvider>();
            MockCrashReporter              = A.Fake <ICrashReporter>();
            MockAnalyticsEngine            = A.Fake <IAnalyticsEngine>();
            MockPlaylistGenerator          = A.Fake <IGenerator>();
            MockDriveVolumeInfoViewFactory = A.Fake <IDriveVolumeInfoViewFactory>();
            MockDriveVolumeInfoView        = A.Fake <IDriveVolumeInfoView>();
            A.CallTo(() => MockDriveVolumeInfoViewFactory.GetNewView(MockApplication)).Returns(MockDriveVolumeInfoView);
            MockApplicationControlFileFactory = A.Fake <IApplicationControlFileFactory>();

            ByteConverter = new ByteConverter();

            SetupResources();

            ViewModel = new MainViewModel(
                MockApplication,
                MockLogger,
                MockResourceProvider,
                MockApplicationControlFileProvider,
                MockFileSystemHelper,
                ByteConverter,
                MockCrashReporter,
                MockAnalyticsEngine,
                MockPlaylistGenerator,
                MockDriveVolumeInfoViewFactory,
                MockApplicationControlFileFactory
                );
            ViewModel.Observables.Title              += SetTitle;
            ViewModel.Observables.SetCacheRoot       += SetCacheRoot;
            ViewModel.Observables.SetFeedItems       += SetFeedItems;
            ViewModel.Observables.ShowNoDriveMessage += ShowNoDriveMessage;
            ViewModel.Observables.AddInfoView        += AddInfoView;
            ViewModel.Observables.ToastMessage       += ToastMessage;
        }