Exemplo n.º 1
1
 public FilesController(IFileSystemService fileSystemService, IUnitOfWorkFactory unitOfWorkFactory, ILogService logService, ICacheWrapper cacheWrapper)
 {
     _fileSystemService = fileSystemService;
     _unitOfWorkFactory = unitOfWorkFactory;
     _logService = logService;
     _cacheWrapper = cacheWrapper;
 }
        public TvShowImagesServiceTests()
        {
            _fileSystemService = Substitute.For<IFileSystemService>();
            _path = @"C:\Folder\TV Shows\Game of Thrones";

            _tvShowFileService = Substitute.For<ITvShowFileService>();
            TvShowImages images = new TvShowImages
            {
                Fanart = @"C:\Folder\TV Shows\Game of Thrones\fanart.jpg",
                Poster = @"C:\Folder\TV Shows\Game of Thrones\poster.jpg",
                Banner = @"C:\Folder\TV Shows\Game of Thrones\banner.jpg",
                Seasons = new List<Season>
                {
                    new Season
                    {
                        SeasonNumber = 0,
                        Path = @"C:\Folder\TV Shows\Game of Thrones\Specials",
                        PosterUrl = @"C:\Folder\TV Shows\Game of Thrones\season-specials-poster.jpg",
                        BannerUrl = @"C:\Folder\TV Shows\Game of Thrones\season-specials-banner.jpg"
                    },
                    new Season
                    {
                        SeasonNumber = 1,
                        Path = @"C:\Folder\TV Shows\Game of Thrones\Season 1",
                        PosterUrl = @"C:\Folder\TV Shows\Game of Thrones\season01-poster.jpg",
                        BannerUrl = @"C:\Folder\TV Shows\Game of Thrones\season01-banner.jpg"
                    }
                }
            };
            _tvShowFileService.GetShowImages(_path)
                .Returns(images.ToTask());

            _service = new TvShowImagesService(_fileSystemService, _tvShowFileService);
        }
 public TvShowMetadataService(IFileSystemService fileSystemService, ITvShowImagesService imagesService, ITvShowMetadataRepository metadataRepository, ITvShowMetadataUpdater metadataUpdater)
 {
     _fileSystemService = fileSystemService;
     _imagesService = imagesService;
     _metadataRepository = metadataRepository;
     _metadataUpdater = metadataUpdater;
 }
 public SourceManagerViewModelTests()
 {
     _sourceService = Substitute.For<ISourceService>();
     _fileSystemService = Substitute.For<IFileSystemService>();
     _busyProvider = Substitute.For<IBusyProvider>();
     _viewModel = new SourceManagerViewModel(_sourceService, _fileSystemService, _busyProvider, SourceType.Music);
 }
Exemplo n.º 5
0
 public ImageViewModel(IFileSystemService fileSystemService, IBusyProvider busyProvider, bool horizontalAlignement, IImageStrategy imageStrategy)
 {
     _fileSystemService = fileSystemService;
     _busyProvider = busyProvider;
     _imageStrategy = imageStrategy;
     _horizontalAlignement = horizontalAlignement;
 }
Exemplo n.º 6
0
        public XUnitTestRunner(IMessageBus bus, IConfiguration configuration, IAssemblyPropertyReader referenceResolver, IFileSystemService fsService)
        {
            _bus = bus;
            _configuration = configuration;
			_assemblyReader = referenceResolver;
            _fsService = fsService;
        }
Exemplo n.º 7
0
 public void Setup()
 {
     this.mr = new MockRepository();
     this.fsSvc = mr.StrictMock<IFileSystemService>();
     this.tllSvc = mr.Stub<ITypeLibraryLoaderService>();
     this.services = mr.StrictMock<IServiceProvider>();
     var cfgSvc = mr.Stub<IConfigurationService>();
     var env = mr.Stub<OperatingEnvironment>();
     this.arch = new M68kArchitecture();
     this.rtls = new List<RtlInstruction>();
     this.m = new RtlEmitter(rtls);
     cfgSvc.Stub(c => c.GetEnvironment("amigaOS")).Return(env);
     env.Stub(e => e.TypeLibraries).Return(new List<ITypeLibraryElement>());
     env.Stub(e => e.CharacteristicsLibraries).Return(new List<ITypeLibraryElement>());
     env.Stub(e => e.Options).Return(new Dictionary<string, object>
     {
         { "versionDependentLibraries", new Dictionary<string,object>
             {
                 { "33", new List<object> { "exec_v33", "dos_v33" } },
                 { "34", new List<object> { "exec_v34", "dos_v34" } },
             }
         }
     });
     this.services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(cfgSvc);
     this.services.Stub(s => s.GetService(typeof(IFileSystemService))).Return(fsSvc);
     this.services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tllSvc);
     this.frame = new Frame(arch.FramePointerType);
 }
        public void SetUp()
        {
            _project = new Project(Path.GetFullPath("someProject.csproj"), new ProjectDocument(ProjectType.CSharp));
			_project.Value.SetOutputPath("");
			_project.Value.SetAssemblyName("someAssembly.dll");
            _bus = MockRepository.GenerateMock<IMessageBus>();
            _listGenerator = MockRepository.GenerateMock<IGenerateBuildList>();
            _configuration = MockRepository.GenerateMock<IConfiguration>();
            _buildRunner = MockRepository.GenerateMock<IBuildRunner>();
            _testRunner = MockRepository.GenerateMock<ITestRunner>();
			_testAssemblyValidator = MockRepository.GenerateMock<IDetermineIfAssemblyShouldBeTested>();
			_optimizer = MockRepository.GenerateMock<IOptimizeBuildConfiguration>();
            _fs = MockRepository.GenerateMock<IFileSystemService>();
            _cache = MockRepository.GenerateMock<ICache>();
            _runCache = MockRepository.GenerateMock<IRunResultCache>();
			_runInfo = new RunInfo(_project);
			_runInfo.ShouldBuild();
			_runInfo.SetAssembly(_project.Value.AssemblyName);
			_optimizer.Stub(o => o.AssembleBuildConfiguration(new string[] {})).IgnoreArguments().Return(new RunInfo[] { _runInfo });
            _preProcessor = MockRepository.GenerateMock<IPreProcessTestruns>();
            _preProcessor.Stub(x => x.PreProcess(null)).IgnoreArguments().Return(new PreProcessedTesRuns(null, new RunInfo[] { _runInfo }));
            var preProcessors = new IPreProcessTestruns[] { _preProcessor };
            var buildPreProcessor = MockRepository.GenerateMock<IPreProcessBuildruns>();
            buildPreProcessor.Stub(x => x.PreProcess(null)).IgnoreArguments().Return(new RunInfo[] { _runInfo });
            var buildPreProcessors = new IPreProcessBuildruns[] { buildPreProcessor };
            _removedTestLocator = MockRepository.GenerateMock<ILocateRemovedTests>();
            _buildSessionRunner = new BuildSessionRunner(new BuildConfiguration(null), _cache, _bus, _configuration, _buildRunner, buildPreProcessors, _fs, _runCache);
            _consumer = new ProjectChangeConsumer(_bus, _listGenerator, _configuration, _buildSessionRunner, new ITestRunner[] { _testRunner }, _testAssemblyValidator, _optimizer, preProcessors, _removedTestLocator);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImportService"/> class.
 /// </summary>
 /// <param name="settingsService">
 /// Провайдер настроек
 /// </param>
 /// <param name="fileSystemService">
 /// Сервис файловой системы
 /// </param>
 /// <param name="logService">
 /// Сервис логирования
 /// </param>
 /// <param name="dateTimeService">
 /// Сервис даты/времени
 /// </param>
 public ImportService(IAlbumeSettingsService settingsService, IFileSystemService fileSystemService, ILogService logService, IDateTimeService dateTimeService)
 {
     this.settingsService = settingsService;
     this.fileSystemService = fileSystemService;
     this.logService = logService;
     this.dateTimeService = dateTimeService;
 }
 public void SetUp()
 {
     _configuration = MockRepository.GenerateMock<IConfiguration>();
     _assemblyReader = MockRepository.GenerateMock<IAssemblyPropertyReader>();
     _fsService = MockRepository.GenerateMock<IFileSystemService>();
     _runner = new MSTestRunner(_configuration, _assemblyReader, _fsService);
 }
 public FileSystemFileStorageService(
     IConfiguration configuration,
     IFileSystemService fileSystemSvc)
 {
     _configuration = configuration;
     _fileSystemSvc = fileSystemSvc;
 }
Exemplo n.º 12
0
        public NUnitTestRunner(IMessageBus bus, IConfiguration configuration, IAssemblyReader assemblyReader, IFileSystemService fsService)
        {
            _bus = bus;
            _configuration = configuration;
			_assemblyReader = assemblyReader;
            _fsService = fsService;
        }
Exemplo n.º 13
0
        public MainWindowViewModel(IFileSystemService fileSystemService, IFileWatcherService fileWatcherService, IMessenger messenger)
        {
            _fileSystemService = fileSystemService;
            _fileWatcherService = fileWatcherService;

            _logger.Info("register on directoryChangedMessage");
            messenger.Register<DirectoryChangedMessage>(this, OnDirectoryChangedMessageReceive);
        }
Exemplo n.º 14
0
 public OpenIdService(ISecurityUserService securityUserService, IExtAccountService extAccountService,
                      IOpenIdConfigService openIdConfigService, IFileSystemService fileSystemService)
 {
     _securityUserService = securityUserService;
     _extAccountService = extAccountService;
     _openIdConfigService = openIdConfigService;
     _fileSystemService = fileSystemService;
 }
        public BackupFileSystemService(IPackageOperationContextService operationContextService, IFileSystemService fileSystemService)
        {
            Argument.IsNotNull(() => operationContextService);
            Argument.IsNotNull(() => fileSystemService);

            _operationContextService = operationContextService;
            _fileSystemService = fileSystemService;
        }
Exemplo n.º 16
0
 public MapDataLoader(IElevationProvider elevationProvider, IFileSystemService fileSystemService,
     ImaginaryProvider imaginaryProvider, IPathResolver pathResolver)
 {
     _elevationProvider = elevationProvider;
     _fileSystemService = fileSystemService;
     _imaginaryProvider = imaginaryProvider;
     _pathResolver = pathResolver;
 }
 public ApplicationSettingsService(ISystemService systemService,
                                   IFileSystemService fileSystemService,
                                   ISerializationService serializationService)
 {
     _systemService = systemService;
     _fileSystemService = fileSystemService;
     _serializationService = serializationService;
 }
 public ChooseImageFileViewModelTests()
 {
     _fileSystemService = Substitute.For<IFileSystemService>();
     _imageSelectionViewModel = Substitute.For<IImageSelectionViewModel>();
     _busyProvider = Substitute.For<IBusyProvider>();
     _path = @"C:\TV Shows\Adventure Time\fanart.jpg";
     _viewModel = new ChooseImageFileViewModel(_fileSystemService, _imageSelectionViewModel, _busyProvider, _path);
 }
Exemplo n.º 19
0
		public VTSViewModel (IFileSystemService fileSystem, ILocalizer localazer, ISQLitePlatform sqlitePlatform)
		{	
			_vacationList = new VacationInfoMockModel ().Vacations;

			_fileSystem = fileSystem;
			this.Localaizer = localazer;
			_sqlitePlatform = sqlitePlatform;
		}
		public void SetUp()
		{
			_configuration = MockRepository.GenerateMock<IConfiguration>();
            _fs = MockRepository.GenerateMock<IFileSystemService>();
			_validator = new TestRunValidator(_configuration, _fs);

            _fs.Stub(x => x.FileExists("InvalidAssembly.dll")).Return(true);
            _fs.Stub(x => x.FileExists("ValidAssembly.dll")).Return(true);
		}
 public EpisodeMetadataServiceTests()
 {
     _fileSystemService = Substitute.For<IFileSystemService>();
     _metadataRepository = Substitute.For<IEpisodeMetadataRepository>();
     _metadataUpdater = Substitute.For<ITvShowMetadataUpdater>();
     _fileInformationService = Substitute.For<IFileInformationService>();
     _path = @"C:\Folder\TV Shows\Game of Thrones\Season 3\3x09.mkv";
     _service = new EpisodeMetadataService(_fileSystemService, _metadataRepository, _metadataUpdater, _fileInformationService);
 }
Exemplo n.º 22
0
 internal static async Task<string> GetMovieSetFolder(IFileSystemService fileSystemService)
 {
     string movieSetFolder = Settings.Default.MovieSetArtworkFolder;
     if (string.IsNullOrEmpty(movieSetFolder) || !await fileSystemService.FolderExists(movieSetFolder))
     {
         movieSetFolder = SettingsHelper.GetAppDataFilePath("MovieSetArtwork");
     }
     return movieSetFolder;
 }
        protected override void establish_context()
        {
            var docs = GetListOfXDocuments();

            FileSystem = Dependancy<IFileSystemService>();
            OutputDirectory = @".\docs\";

            sut = new BatchWriter(docs) {FileSystemService = FileSystem};
        }
 public SourceControlBackupService(
     IAllConfiguration allConfiguration, IVsoRestApiService apiService,
     IFileSystemService fileSystemService, ILogger logger, IGitService gitService)
 {
     _allConfiguration = allConfiguration;
     _apiService = apiService;
     _fileSystemService = fileSystemService;
     _logger = logger;
     _gitService = gitService;
 }
 public ActorManagerViewModel(IActorViewModelFactory viewModelFactory, IFileSystemService fileSystemService, string path, Action onPropertyChanged)
 {
     _fileSystemService = fileSystemService;
     _path = path;
     _onPropertyChanged = onPropertyChanged;
     Actors = new ObservableCollection<IActorViewModel>();
     Actors.CollectionChanged += ActorsCollectionChanged;
     AddCommand = new AddCommand(this, viewModelFactory);
     RemoveCommand = new RemoveCommand(this);
 }
 public EpisodeMetadataService(IFileSystemService fileSystemService,
     IEpisodeMetadataRepository metadataRepository,
     ITvShowMetadataUpdater metadataUpdater,
     IFileInformationService fileInformationService)
 {
     _fileSystemService = fileSystemService;
     _metadataRepository = metadataRepository;
     _metadataUpdater = metadataUpdater;
     _fileInformationService = fileInformationService;
 }
Exemplo n.º 27
0
 public void Setup()
 {
     mr = new MockRepository();
     sc = new ServiceContainer();
     cfgSvc = mr.Stub<IConfigurationService>();
     fsSvc = mr.Stub<IFileSystemService>();
     diagSvc = mr.Stub<IDiagnosticsService>();
     sc.AddService<IFileSystemService>(fsSvc);
     sc.AddService<IDiagnosticsService>(diagSvc);
 }
Exemplo n.º 28
0
        public BlogController(IFileSystemService fileSystem, IConfiguration configuration)
        {
            _fileSystem = fileSystem;
            Configuration = configuration;

            MarkdownPipeline = new MarkdownPipelineBuilder()
                 .UseSoftlineBreakAsHardlineBreak()
                 .UseAdvancedExtensions()
                 .Build();
        }
Exemplo n.º 29
0
 /// <summary> Creates instance of <see cref="SrtmDownloader"/>. </summary>
 /// <param name="schemaPath">Uri schema path.</param>
 /// <param name="fileSystemService">File system service.</param>
 /// <param name="server">Server.</param>
 /// <param name="trace">Trace.</param>
 public SrtmDownloader(string server, 
     string schemaPath,
     IFileSystemService fileSystemService,
     ITrace trace)
 {
     _server = server;
     _schemaPath = schemaPath;
     _fileSystemService = fileSystemService;
     _trace = trace;
 }
 public MovieMetadataServiceTests()
 {
     _fileSystemService = Substitute.For<IFileSystemService>();
     _metadataRepository = Substitute.For<IMovieMetadataRepository>();
     _metadataUpdater = Substitute.For<IMovieMetadataUpdater>();
     _synopsisService = Substitute.For<IMovieSynopsisService>();
     _imagesService = Substitute.For<IMovieImagesService>();
     _fileInformationService = Substitute.For<IFileInformationService>();
     _service = new MovieMetadataService(_fileSystemService, _metadataRepository, _metadataUpdater, _synopsisService, _imagesService, _fileInformationService);
 }
Exemplo n.º 31
0
 internal VisualStudioCodeCredential(VisualStudioCodeCredentialOptions options, CredentialPipeline pipeline, MsalPublicClient client, IFileSystemService fileSystem,
                                     IVisualStudioCodeAdapter vscAdapter)
 {
     _tenantId   = options?.TenantId ?? _commonTenant;
     _pipeline   = pipeline ?? CredentialPipeline.GetInstance(options);
     Client      = client ?? new MsalPublicClient(_pipeline, options?.TenantId, ClientId, null, null, options?.IsLoggingPIIEnabled ?? false);
     _fileSystem = fileSystem ?? FileSystemService.Default;
     _vscAdapter = vscAdapter ?? GetVscAdapter();
     _allowMultiTenantAuthentication = options?.AllowMultiTenantAuthentication ?? false;
 }
Exemplo n.º 32
0
 public SearchController(SlimGetContext db, RedisService redis, IFileSystemService fs, IOptions <StorageConfiguration> storcfg, ILoggerFactory logger)
     : base(db, redis, fs, storcfg, logger)
 {
 }
 public FileSystemController(IFileSystemService fileSystemService)
 => FileSystemService = fileSystemService ??
 public BranchesService(IFileSystemService fileSystemService, ICommonValidator commonValidator, ILoggerFactory loggerFactory)
 {
     _fileSystemService = fileSystemService;
     _commonValidator   = commonValidator;
     _logger            = loggerFactory.CreateLogger <BranchesService>();
 }
Exemplo n.º 35
0
 public FileSystemFileStorageService(IAppConfiguration configuration, IFileSystemService fileSystemService)
 {
     _configuration     = configuration;
     _fileSystemService = fileSystemService;
 }
 public MSpecCommandLineBuilder(IFileSystemService fileSystem)
 {
     _fileSystem = fileSystem;
 }
Exemplo n.º 37
0
 public MediaScript(IProcessWorkerFactory processFactory, IFileSystemService fileSystemService)
 {
     this.factory    = processFactory ?? throw new ArgumentNullException(nameof(processFactory));
     this.fileSystem = fileSystemService ?? throw new ArgumentNullException(nameof(fileSystemService));
 }
Exemplo n.º 38
0
 /// <summary>
 /// Lazily registers the IFileSystemService
 /// </summary>
 /// <param name="service">Service to register.</param>
 public static void RegisterService(Func <IFileSystemService> service)
 {
     ServiceContainer.Register <IFileSystemService>(service);
     _registeredService     = null;
     _registeredServiceFunc = service;
 }
Exemplo n.º 39
0
        private void Given_MainFormInteractor()
        {
            svcFactory    = mr.StrictMock <IServiceFactory>();
            archSvc       = mr.StrictMock <IArchiveBrowserService>();
            dlgFactory    = mr.StrictMock <IDialogFactory>();
            memSvc        = mr.StrictMock <ILowLevelViewService>();
            disasmSvc     = mr.StrictMock <IDisassemblyViewService>();
            typeLibSvc    = mr.StrictMock <ITypeLibraryLoaderService>();
            brSvc         = mr.Stub <IProjectBrowserService>();
            uiPrefs       = mr.StrictMock <IUiPreferencesService>();
            fsSvc         = mr.StrictMock <IFileSystemService>();
            tcHostSvc     = mr.StrictMock <ITabControlHostService>();
            dcSvc         = mr.StrictMock <IDecompilerService>();
            srSvc         = MockRepository.GenerateMock <ISearchResultService, IWindowPane>();
            diagnosticSvc = MockRepository.GenerateMock <IDiagnosticsService, IWindowPane>();
            resEditSvc    = mr.StrictMock <IResourceEditorService>();
            cgvSvc        = mr.StrictMock <ICallGraphViewService>();
            loader        = mr.StrictMock <ILoader>();
            sbSvc         = mr.Stub <IStatusBarService>();
            vimpSvc       = mr.StrictMock <IViewImportsService>();
            cvSvc         = mr.StrictMock <ICodeViewerService>();
            imgSegSvc     = mr.StrictMock <ImageSegmentService>();
            symLoadSvc    = mr.StrictMock <ISymbolLoadingService>();
            selSvc        = mr.StrictMock <ISelectionService>();

            svcFactory.Stub(s => s.CreateArchiveBrowserService()).Return(archSvc);
            svcFactory.Stub(s => s.CreateCodeViewerService()).Return(cvSvc);
            svcFactory.Stub(s => s.CreateDecompilerConfiguration()).Return(new FakeDecompilerConfiguration());
            svcFactory.Stub(s => s.CreateDiagnosticsService()).Return(diagnosticSvc);
            svcFactory.Stub(s => s.CreateDecompilerService()).Return(dcSvc);
            svcFactory.Stub(s => s.CreateDisassemblyViewService()).Return(disasmSvc);
            svcFactory.Stub(s => s.CreateMemoryViewService()).Return(memSvc);
            svcFactory.Stub(s => s.CreateDecompilerEventListener()).Return(new FakeDecompilerEventListener());
            svcFactory.Stub(s => s.CreateImageSegmentService()).Return(imgSegSvc);
            svcFactory.Stub(s => s.CreateInitialPageInteractor()).Return(new FakeInitialPageInteractor());
            svcFactory.Stub(s => s.CreateScannedPageInteractor()).Return(new FakeScannedPageInteractor());
            svcFactory.Stub(s => s.CreateTypeLibraryLoaderService()).Return(typeLibSvc);
            svcFactory.Stub(s => s.CreateProjectBrowserService()).Return(brSvc);
            svcFactory.Stub(s => s.CreateUiPreferencesService()).Return(uiPrefs);
            svcFactory.Stub(s => s.CreateFileSystemService()).Return(fsSvc);
            svcFactory.Stub(s => s.CreateStatusBarService()).Return(sbSvc);
            svcFactory.Stub(s => s.CreateTabControlHost()).Return(tcHostSvc);
            svcFactory.Stub(s => s.CreateLoader()).Return(loader);
            svcFactory.Stub(s => s.CreateSearchResultService()).Return(srSvc);
            svcFactory.Stub(s => s.CreateResourceEditorService()).Return(resEditSvc);
            svcFactory.Stub(s => s.CreateCallGraphViewService()).Return(cgvSvc);
            svcFactory.Stub(s => s.CreateViewImportService()).Return(vimpSvc);
            svcFactory.Stub(s => s.CreateSymbolLoadingService()).Return(symLoadSvc);
            svcFactory.Stub(s => s.CreateSelectionService()).Return(selSvc);
            services.AddService(typeof(IDialogFactory), dlgFactory);
            services.AddService(typeof(IServiceFactory), svcFactory);
            brSvc.Stub(b => b.Clear());

            form = mr.StrictMock <IMainForm>();
            form.Stub(f => f.Dispose());
            form.Stub(f => f.UpdateToolbarState());
            form.Closed += null;
            LastCall.IgnoreArguments();
            tcHostSvc.Stub(t => t.QueryStatus(
                               Arg <CommandID> .Is.Anything,
                               Arg <CommandStatus> .Is.Anything,
                               Arg <CommandText> .Is.Anything)).Return(false);
            tcHostSvc.Stub(t => t.Execute(Arg <CommandID> .Is.Anything)).Return(false);

            uiSvc.Stub(u => u.DocumentWindows).Return(new List <IWindowFrame>());
            brSvc.Stub(u => u.ContainsFocus).Return(false);
            tcHostSvc.Stub(u => u.ContainsFocus).Return(false);

            // We currently don't care about testing the appearance of the Main window text.
            // Should this be required, you will need to remove the line below and add an
            // appropriate stub/expectation in all the tests below. Good luck with that.
            form.Stub(f => f.TitleText = "").IgnoreArguments();
        }
 internal VisualStudioCodeCredential(string tenantId, CredentialPipeline pipeline, MsalPublicClient client, IFileSystemService fileSystem, IVisualStudioCodeAdapter vscAdapter)
 {
     _tenantId   = tenantId ?? "common";
     _pipeline   = pipeline;
     _client     = client;
     _fileSystem = fileSystem ?? FileSystemService.Default;
     _vscAdapter = vscAdapter ?? GetVscAdapter();
 }
 internal VisualStudioCodeCredential(string tenantId, CredentialPipeline pipeline, IFileSystemService fileSystem, IVisualStudioCodeAdapter vscAdapter)
     : this(tenantId, pipeline, pipeline.CreateMsalPublicClient(ClientId), fileSystem, vscAdapter)
 {
 }
Exemplo n.º 42
0
        public BackupFileSystemService(IPackageOperationContextService operationContextService, IFileSystemService fileSystemService)
        {
            Argument.IsNotNull(() => operationContextService);
            Argument.IsNotNull(() => fileSystemService);

            _operationContextService = operationContextService;
            _fileSystemService       = fileSystemService;
        }
Exemplo n.º 43
0
 public FileSystemController(
     IFileSystemService fileSystemService)
 {
     _fileSystemService = fileSystemService;
 }
Exemplo n.º 44
0
 public FileService(IMapper mapper, IComponentContext scope, IFileSystemService fileSystemService) : base(mapper, scope)
 {
     _fileSystemService = fileSystemService;
 }
Exemplo n.º 45
0
 public void Setup()
 {
     fsSvc = new FileSystemServiceImpl();
 }
Exemplo n.º 46
0
        public ShellProfileViewModel(ShellProfile shellProfile, ISettingsService settingsService, IDialogService dialogService, IFileSystemService fileSystemService)
        {
            _shellProfile      = shellProfile;
            _settingsService   = settingsService;
            _dialogService     = dialogService;
            _fileSystemService = fileSystemService;

            Id               = shellProfile.Id;
            Name             = shellProfile.Name;
            Arguments        = shellProfile.Arguments;
            Location         = shellProfile.Location;
            WorkingDirectory = shellProfile.WorkingDirectory;

            SetDefaultCommand                = new RelayCommand(SetDefault);
            DeleteCommand                    = new RelayCommand(async() => await Delete().ConfigureAwait(false), CanDelete);
            EditCommand                      = new RelayCommand(Edit, CanEdit);
            CancelEditCommand                = new RelayCommand(async() => await CancelEdit().ConfigureAwait(false));
            SaveChangesCommand               = new RelayCommand(SaveChanges);
            BrowseForCustomShellCommand      = new RelayCommand(async() => await BrowseForCustomShell().ConfigureAwait(false));
            BrowseForWorkingDirectoryCommand = new RelayCommand(async() => await BrowseForWorkingDirectory().ConfigureAwait(false));
        }
Exemplo n.º 47
0
 public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService,
                          ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService, IFileSystemService fileSystemService)
 {
     KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, defaultValueProvider, trayProcessCommunicationService);
     General     = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider);
     Shell       = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService);
     Terminal    = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService);
     Themes      = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService);
 }
Exemplo n.º 48
0
 public FileDetailService(IFileSystemService fileSystemService)
 {
     _fileSystemService = fileSystemService;
 }
Exemplo n.º 49
0
 public FileController(IFileEntityService fileEntityService, IFileSystemService fileSystemService)
 {
     _fileEntityService = fileEntityService;
     _fileSystemService = fileSystemService;
 }
        public ProfilesPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider, IFileSystemService fileSystemService)
        {
            _settingsService      = settingsService;
            _dialogService        = dialogService;
            _defaultValueProvider = defaultValueProvider;
            _fileSystemService    = fileSystemService;

            CreateShellProfileCommand = new RelayCommand(CreateShellProfile);

            var defaultShellProfileId = _settingsService.GetDefaultShellProfileId();

            foreach (var shellProfile in _settingsService.GetShellProfiles())
            {
                var viewModel = new ShellProfileViewModel(shellProfile, settingsService, dialogService, fileSystemService);
                viewModel.Deleted      += OnShellProfileDeleted;
                viewModel.SetAsDefault += OnShellProfileSetAsDefault;

                if (shellProfile.Id == defaultShellProfileId)
                {
                    viewModel.IsDefault = true;
                }
                ShellProfiles.Add(viewModel);
            }

            SelectedShellProfile = ShellProfiles.First(p => p.IsDefault);
        }
Exemplo n.º 51
0
 public ChocolateyService(ICommandService command, IFileSystemService fileSystem)
 {
     m_command    = command;
     m_fileSystem = fileSystem;
 }
Exemplo n.º 52
0
 public ProjectCrawler(ICache cache, IFileSystemService fsService, IMessageBus bus)
 {
     _cache     = cache;
     _fsService = fsService;
     _bus       = bus;
 }
Exemplo n.º 53
0
 public FileManager(IFileSystemService fileSystemService)
 {
     _fileSystemService = fileSystemService;
     _logger            = LogManager.GetCurrentClassLogger();
 }
Exemplo n.º 54
0
        /// <summary>
        /// Return a list of resources which this user is allowed to install from DBL.
        /// If we cannot contact DBL, return an empty list.
        /// </summary>
        /// <param name="userSecret">The user secret.</param>
        /// <param name="paratextOptions">The paratext options.</param>
        /// <param name="restClientFactory">The rest client factory.</param>
        /// <param name="fileSystemService">The file system service.</param>
        /// <param name="jwtTokenHelper">The JWT token helper.</param>
        /// <param name="baseUrl">The base URL.</param>
        /// <returns>The Installable Resources.</returns>
        /// <exception cref="ArgumentNullException">restClientFactory
        /// or
        /// userSecret</exception>
        /// <remarks>Tests on this method can be found in ParatextServiceTests.cs calling GetResources().</remarks>
        public static IEnumerable <SFInstallableDblResource> GetInstallableDblResources(UserSecret userSecret,
                                                                                        ParatextOptions paratextOptions, ISFRestClientFactory restClientFactory,
                                                                                        IFileSystemService fileSystemService, IJwtTokenHelper jwtTokenHelper, IExceptionHandler exceptionHandler,
                                                                                        string baseUrl = null)
        {
            // Parameter check (just like the constructor)
            if (restClientFactory == null)
            {
                throw new ArgumentNullException(nameof(restClientFactory));
            }
            else if (userSecret == null)
            {
                throw new ArgumentNullException(nameof(userSecret));
            }

            ISFRestClient client =
                restClientFactory.Create(string.Empty, userSecret);

            baseUrl = string.IsNullOrWhiteSpace(baseUrl) ? InternetAccess.ParatextDBLServer : baseUrl;
            string response = null;

            try
            {
                response = client.Get(BuildDblResourceEntriesUrl(baseUrl));
            }
            catch (WebException e)
            {
                // If we get a temporary 401 Unauthorized response, return an empty list.
                string errorExplanation = "GetInstallableDblResources failed when attempting to inquire about"
                                          + $" resources and is ignoring error {e}";
                var report = new Exception(errorExplanation);
                // Report to bugsnag, but don't throw.
                exceptionHandler.ReportException(report);
                return(Enumerable.Empty <SFInstallableDblResource>());
            }
            IEnumerable <SFInstallableDblResource> resources = ConvertJsonResponseToInstallableDblResources(baseUrl,
                                                                                                            response, restClientFactory, fileSystemService, jwtTokenHelper, DateTime.Now, userSecret,
                                                                                                            paratextOptions, new ParatextProjectDeleter(), new ParatextMigrationOperations(),
                                                                                                            new ParatextZippedResourcePasswordProvider(paratextOptions));

            return(resources);
        }
 public StyleguideController(IFileSystemService fileSystem)
 {
     _fileSystem = fileSystem;
 }
Exemplo n.º 56
0
        /// <summary>
        /// Checks the resource permission.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="userSecret">The user secret.</param>
        /// <param name="paratextOptions">The paratext options.</param>
        /// <param name="restClientFactory">The rest client factory.</param>
        /// <param name="fileSystemService">The file system service.</param>
        /// <param name="jwtTokenHelper">The JWT token helper.</param>
        /// <param name="baseUrl">The base URL.</param>
        /// <returns>
        ///   <c>true</c> if the user has permission to access the resource; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">id
        /// or
        /// userSecret
        /// or
        /// restClientFactory</exception>
        public static bool CheckResourcePermission(string id, UserSecret userSecret,
                                                   ParatextOptions paratextOptions, ISFRestClientFactory restClientFactory,
                                                   IFileSystemService fileSystemService, IJwtTokenHelper jwtTokenHelper,
                                                   IExceptionHandler exceptionHandler, string baseUrl = null)
        {
            // Parameter check
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(nameof(id));
            }
            else if (userSecret == null)
            {
                throw new ArgumentNullException(nameof(userSecret));
            }
            else if (restClientFactory == null)
            {
                throw new ArgumentNullException(nameof(restClientFactory));
            }

            ISFRestClient client = restClientFactory.Create(string.Empty, userSecret);

            baseUrl = string.IsNullOrWhiteSpace(baseUrl) ? InternetAccess.ParatextDBLServer : baseUrl;
            try
            {
                _ = client.Head(BuildDblResourceEntriesUrl(baseUrl, id));
                return(true);
            }
            catch (Exception ex)
            {
                // Normally we would catch the specific WebException,
                // but something in ParatextData is interfering with it.
                if (ex.InnerException?.Message.StartsWith("401: ", StringComparison.OrdinalIgnoreCase) ?? false)
                {
                    // A 401 error means unauthorized (probably a bad token)
                    return(false);
                }
                else if (ex.InnerException?.Message.StartsWith("403: ", StringComparison.OrdinalIgnoreCase) ?? false)
                {
                    // A 403 error means no access.
                    return(false);
                }
                else if (ex.InnerException?.Message.StartsWith("404: ", StringComparison.OrdinalIgnoreCase) ?? false)
                {
                    // A 404 error means that the resource is not on the server
                    return(false);
                }
                else if (ex.InnerException?.Message.StartsWith("405: ", StringComparison.OrdinalIgnoreCase) ?? false)
                {
                    // A 405 means that HEAD request does not work on the server, so we will use the resource list
                    // This is slower (although faster than a GET request on the resource), but more reliable
                    IEnumerable <SFInstallableDblResource> resources =
                        GetInstallableDblResources(
                            userSecret,
                            paratextOptions,
                            restClientFactory,
                            fileSystemService,
                            jwtTokenHelper,
                            exceptionHandler,
                            baseUrl);
                    return(resources.Any(r => r.DBLEntryUid.Id == id));
                }
                else if (ex.Source == "NSubstitute")
                {
                    // This occurs during unit tests to test whether there is permission or not
                    return(false);
                }
                else
                {
                    // An unknown error
                    throw;
                }
            }
        }
Exemplo n.º 57
0
        /// <summary>
        /// Converts the JSON response to a list of Installable DBL Resources.
        /// </summary>
        /// <param name="baseUri">The base URI.</param>
        /// <param name="response">The response.</param>
        /// <param name="restClientFactory">The rest client factory.</param>
        /// <param name="fileSystemService">The file system service.</param>
        /// <param name="jwtTokenHelper">The JWT token helper.</param>
        /// <param name="createdTimestamp">The created timestamp.</param>
        /// <param name="userSecret">The user secret.</param>
        /// <param name="paratextOptions">The paratext options.</param>
        /// <param name="projectDeleter">The project deleter.</param>
        /// <param name="migrationOperations">The migration operations.</param>
        /// <param name="passwordProvider">The password provider.</param>
        /// <returns>
        /// The Installable Resources.
        /// </returns>
        private static IEnumerable <SFInstallableDblResource> ConvertJsonResponseToInstallableDblResources(
            string baseUri, string response, ISFRestClientFactory restClientFactory,
            IFileSystemService fileSystemService, IJwtTokenHelper jwtTokenHelper, DateTime createdTimestamp,
            UserSecret userSecret, ParatextOptions paratextOptions, IProjectDeleter projectDeleter,
            IMigrationOperations migrationOperations, IZippedResourcePasswordProvider passwordProvider)
        {
            if (!string.IsNullOrWhiteSpace(response))
            {
                JObject jsonResources;
                try
                {
                    jsonResources = JObject.Parse(response);
                }
                catch (JsonReaderException)
                {
                    // Ignore the exception and just return empty result
                    // This is probably caused by partial result from poor connection to DBL
                    yield break;
                }
                foreach (JToken jsonResource in jsonResources["resources"] as JArray ?? new JArray())
                {
                    var name       = (string)jsonResource["name"];
                    var nameCommon = (string)jsonResource["nameCommon"];
                    var fullname   = (string)jsonResource["fullname"];
                    if (string.IsNullOrWhiteSpace(fullname))
                    {
                        fullname = nameCommon;
                    }

                    var        languageName        = (string)jsonResource["languageName"];
                    var        id                  = (string)jsonResource["id"];
                    var        revision            = (string)jsonResource["revision"];
                    var        permissionsChecksum = (string)jsonResource["permissions-checksum"];
                    var        manifestChecksum    = (string)jsonResource["p8z-manifest-checksum"];
                    var        languageIdLdml      = (string)jsonResource["languageLDMLId"];
                    var        languageIdCode      = (string)jsonResource["languageCode"];
                    LanguageId languageId          =
                        migrationOperations.DetermineBestLangIdToUseForResource(languageIdLdml, languageIdCode);
                    if (string.IsNullOrEmpty(languageId.Id))
                    {
                        languageId = LanguageIdHelper.FromCommonLanguageName(languageName);
                    }
                    else
                    {
                        languageId = LanguageId.FromEthnologueCode(languageId.Id);
                    }

                    string url      = BuildDblResourceEntriesUrl(baseUri, id);
                    var    resource = new SFInstallableDblResource(userSecret, paratextOptions, restClientFactory,
                                                                   fileSystemService, jwtTokenHelper, projectDeleter, migrationOperations, passwordProvider)
                    {
                        DisplayName         = name,
                        Name                = name,
                        FullName            = fullname,
                        LanguageID          = languageId,
                        DblSourceUrl        = url,
                        DBLEntryUid         = HexId.FromStr(id),
                        DBLRevision         = int.Parse(revision),
                        PermissionsChecksum = permissionsChecksum,
                        ManifestChecksum    = manifestChecksum,
                        CreatedTimestamp    = createdTimestamp,
                    };

                    resource.LanguageName = MacroLanguageHelper.GetMacroLanguage(resource.LanguageID) ?? languageName;

                    yield return(resource);
                }
            }
        }
Exemplo n.º 58
0
        private void Given_MainFormInteractor()
        {
            program       = CreateFakeProgram();
            svcFactory    = mr.StrictMock <IServiceFactory>();
            archSvc       = mr.StrictMock <IArchiveBrowserService>();
            dlgFactory    = mr.StrictMock <IDialogFactory>();
            uiSvc         = mr.StrictMock <IDecompilerShellUiService>();
            memSvc        = mr.StrictMock <ILowLevelViewService>();
            disasmSvc     = mr.StrictMock <IDisassemblyViewService>();
            typeLibSvc    = mr.StrictMock <ITypeLibraryLoaderService>();
            brSvc         = mr.Stub <IProjectBrowserService>();
            uiPrefs       = mr.StrictMock <IUiPreferencesService>();
            fsSvc         = mr.StrictMock <IFileSystemService>();
            tcHostSvc     = mr.StrictMock <ITabControlHostService>();
            dcSvc         = mr.StrictMock <IDecompilerService>();
            srSvc         = MockRepository.GenerateMock <ISearchResultService, IWindowPane>();
            diagnosticSvc = MockRepository.GenerateMock <IDiagnosticsService, IWindowPane>();
            resEditSvc    = mr.StrictMock <IResourceEditorService>();
            cgvSvc        = mr.StrictMock <ICallGraphViewService>();
            loader        = mr.StrictMock <ILoader>();
            vimpSvc       = mr.StrictMock <IViewImportsService>();

            svcFactory.Stub(s => s.CreateArchiveBrowserService()).Return(archSvc);
            svcFactory.Stub(s => s.CreateDecompilerConfiguration()).Return(new FakeDecompilerConfiguration());
            svcFactory.Stub(s => s.CreateDiagnosticsService(Arg <ListView> .Is.Anything)).Return(diagnosticSvc);
            svcFactory.Stub(s => s.CreateDecompilerService()).Return(dcSvc);
            svcFactory.Stub(s => s.CreateDisassemblyViewService()).Return(disasmSvc);
            svcFactory.Stub(s => s.CreateMemoryViewService()).Return(memSvc);
            svcFactory.Stub(s => s.CreateDecompilerEventListener()).Return(new FakeDecompilerEventListener());
            svcFactory.Stub(s => s.CreateInitialPageInteractor()).Return(new FakeInitialPageInteractor());
            svcFactory.Stub(s => s.CreateScannedPageInteractor()).Return(new FakeScannedPageInteractor());
            svcFactory.Stub(s => s.CreateAnalyzedPageInteractor()).Return(new FakeAnalyzedPageInteractor());
            svcFactory.Stub(s => s.CreateFinalPageInteractor()).Return(new FakeFinalPageInteractor());
            svcFactory.Stub(s => s.CreateTypeLibraryLoaderService()).Return(typeLibSvc);
            svcFactory.Stub(s => s.CreateProjectBrowserService(Arg <ITreeView> .Is.NotNull)).Return(brSvc);
            svcFactory.Stub(s => s.CreateUiPreferencesService()).Return(uiPrefs);
            svcFactory.Stub(s => s.CreateFileSystemService()).Return(fsSvc);
            svcFactory.Stub(s => s.CreateShellUiService(Arg <IMainForm> .Is.NotNull, Arg <DecompilerMenus> .Is.NotNull)).Return(uiSvc);
            svcFactory.Stub(s => s.CreateTabControlHost(Arg <TabControl> .Is.NotNull)).Return(tcHostSvc);
            svcFactory.Stub(s => s.CreateLoader()).Return(loader);
            svcFactory.Stub(s => s.CreateSearchResultService(Arg <ListView> .Is.NotNull)).Return(srSvc);
            svcFactory.Stub(s => s.CreateResourceEditorService()).Return(resEditSvc);
            svcFactory.Stub(s => s.CreateCallGraphViewService()).Return(cgvSvc);
            svcFactory.Stub(s => s.CreateViewImportService()).Return(vimpSvc);
            services.AddService(typeof(IDialogFactory), dlgFactory);
            services.AddService(typeof(IServiceFactory), svcFactory);
            brSvc.Stub(b => b.Clear());

            form = mr.StrictMock <IMainForm>();
            var listView       = new ListView();
            var imagelist      = new ImageList();
            var tabResults     = new TabPage();
            var tabDiagnostics = new TabPage();
            var tabControl     = new TabControl {
                TabPages = { tabResults, tabDiagnostics }
            };
            var toolStrip   = new ToolStrip {
            };
            var statusStrip = new StatusStrip {
                Items = { new ToolStripLabel() }
            };
            var brToolbar      = new ToolStrip();
            var projectBrowser = mr.Stub <ITreeView>();

            form.Stub(f => f.DiagnosticsList).Return(listView);
            form.Stub(f => f.ImageList).Return(imagelist);
            form.Stub(f => f.Menu).SetPropertyAndIgnoreArgument();
            form.Stub(f => f.AddToolbar(null)).IgnoreArguments();
            form.Stub(f => f.AddProjectBrowserToolbar(null)).IgnoreArguments();
            form.Stub(f => f.Dispose());
            form.Stub(f => f.TabControl).Return(tabControl);
            form.Stub(f => f.FindResultsPage).Return(tabResults);
            form.Stub(f => f.DiagnosticsPage).Return(tabDiagnostics);
            form.Stub(f => f.FindResultsList).Return(listView);
            form.Stub(f => f.ToolBar).Return(toolStrip);
            form.Stub(f => f.ProjectBrowserToolbar).Return(toolStrip);
            form.Stub(f => f.ProjectBrowser).Return(projectBrowser);
            form.Stub(f => f.StatusStrip).Return(statusStrip);
            form.Stub(f => f.AddProjectBrowserToolbar(null)).IgnoreArguments();
            form.Stub(f => f.ProjectBrowserToolbar).Return(brToolbar);
            form.Load += null;
            LastCall.IgnoreArguments();
            form.Closed += null;
            LastCall.IgnoreArguments();
            form.ProcessCommandKey += null;
            LastCall.IgnoreArguments();
            dlgFactory.Stub(d => d.CreateMainForm()).Return(form);
            tcHostSvc.Stub(t => t.Attach(Arg <IWindowPane> .Is.NotNull, Arg <TabPage> .Is.NotNull));
            tcHostSvc.Stub(t => t.QueryStatus(
                               Arg <CommandID> .Is.Anything,
                               Arg <CommandStatus> .Is.Anything,
                               Arg <CommandText> .Is.Anything)).Return(false);
            tcHostSvc.Stub(t => t.Execute(Arg <CommandID> .Is.Anything)).Return(false);

            uiSvc.Stub(u => u.DocumentWindows).Return(new List <IWindowFrame>());
        }
Exemplo n.º 59
0
 public ProjectService(IRealtimeService realtimeService, IOptions <SiteOptions> siteOptions,
                       IAudioService audioService, IRepository <TSecret> projectSecrets, IFileSystemService fileSystemService)
 {
     RealtimeService   = realtimeService;
     SiteOptions       = siteOptions;
     _audioService     = audioService;
     ProjectSecrets    = projectSecrets;
     FileSystemService = fileSystemService;
 }
 public TvShowFileServiceTests()
 {
     _fileSystemService = Substitute.For <IFileSystemService>();
     _service           = new TvShowFileService(_fileSystemService);
 }