public void ShouldNotAlterNiceName() { FilePathService ds = new FilePathService(); string dir = ds.GetTimeSeriesFilePath("/var/my/dummy/path", 3, "BTC_USD"); Assert.Equal("/var/my/dummy/path/3/BTC_USD.csv", dir); }
public void ShouldAlterNameWithSpace() { FilePathService ds = new FilePathService(); string dir = ds.GetTimeSeriesFilePath("/var/my/dummy/path", 128, "BTC USD"); Assert.Equal("/var/my/dummy/path/128/BTC_USD.csv", dir); }
public void Should_Provide_Path_From_Configuration() { var service = new FilePathService(); var expectedPath = ConfigurationManager.AppSettings["TextRepoFilePath"]; var result = service.GetPaymentDataFilePath(); result.Should().Be(expectedPath); }
/// <summary> /// Create and return a new <see cref="DocumentMetadataManager"/>, /// configured with the properties available in this builder instance /// </summary> /// <returns> /// A new <see cref="DocumentMetadataManager"/> for use in unit tests /// </returns> public DocumentMetadataManager CreateDocumentMetadataManager() { if (DocumentMetadataFactory == null) { var builder = new DocumentMetadataFactoryBuilder(TimeProviderMock); DocumentMetadataFactory = builder.CreateDocumentMetadataFactory(true); } if (UserPreferences == null) { UserPreferences = UserPreferencesBuilder.CreateUserPreferences(); } if (UpdateReactionMapping == null) { var displayNameHighlightEvaluator = new DisplayNameHighlightEvaluator(); var filePathService = new FilePathService(); var updateReactions = new IUpdateReaction[] { new AssignProjectColoursReaction(Mock.Of <IProjectBrushService>()), new GroupByProjectReaction(), new PathSegmentCountReaction(displayNameHighlightEvaluator, filePathService), new SelectedSortOptionReaction(SortOptionsService), new ShowRecentUsageReaction(NormalizedUsageOrderServiceMock.Object) }; UpdateReactionMapping = new UpdateReactionMapping(updateReactions); } if (UpdateReactionManager == null) { UpdateReactionManager = new UpdateReactionManager( UpdateReactionMapping, UserPreferences); } var manager = new DocumentMetadataManager( CollectionViewGenerator ?? new CollectionViewGenerator(), CountdownTimer ?? new TestingCountdownTimer(), DocumentMetadataEqualityService ?? new DocumentMetadataEqualityService(), DocumentMetadataFactory, NormalizedUsageOrderServiceMock.Object, ProjectItemServiceMock.Object, TimeProviderMock.Object, UpdateReactionManager, UserPreferences); // Initialization logic in the constructor of // DocumentMetadataManager will make calls on the mock // NormalizedUsageOrderService. Reset calls so that these are not // counted in the tests that the created DocumentMetadataManager // will be used in. NormalizedUsageOrderServiceMock.Invocations.Clear(); return(manager); }
public void TwoPathSegmentsIncludeFileAndOneParentDirectory() { // Arrange var service = new FilePathService(); // Act var path = service.ReducePath(@"C:\Three\Two\One.txt", 2); // Assert Assert.That(path, Is.EqualTo(@"Two\One.txt")); }
public void OnePathSegmentIncludesFileOnly() { // Arrange var service = new FilePathService(); // Act var path = service.ReducePath(@"C:\Three\Two\One.txt", 1); // Assert Assert.That(path, Is.EqualTo(@"One.txt")); }
public void FullNameIsReturnedIfPathSegmentCountIsGreaterThanSegmentsInFullName() { // Arrange const string fullName = @"C:\Three\Two\One.txt"; var service = new FilePathService(); // Act var path = service.ReducePath(fullName, 9); // Assert Assert.That(path, Is.EqualTo(fullName)); }
/// <summary> /// 导入失败时的导入失败报表文件名 /// </summary> /// <param name="fpservice"></param> /// <param name="batch"></param> /// <returns></returns> static public FileNameView DataImportEmployeesFailFileName(this FilePathService fpservice, string batch) { string file = $"fail-{batch}.xlsx"; string webPath = WebPath(DataImportEmployees); return(new FileNameView { DiskRoot = FilePathService.RootPath, WebRoot = "~", DiskPath = DataImportEmployees, WebPath = $"~/{webPath}", FileName = file, FileExtName = "xlsx", DiskFileFullName = $"{DataImportEmployees}\\{file}", WebFileFullName = $"~/{webPath}/{file}" }); }
/// <summary> /// 导入的员工信息文件名 /// </summary> static public FileNameView DataImportEmployeesFileName(this FilePathService fpservice) { string file = $"{Guid.NewGuid().ToString("N")}.xlsx"; string webPath = WebPath(DataImportEmployees); return(new FileNameView { DiskRoot = FilePathService.RootPath, WebRoot = "~", DiskPath = DataImportEmployees, WebPath = $"~/{webPath}", FileName = file, FileExtName = "xlsx", DiskFileFullName = $"{DataImportEmployees}\\{file}", WebFileFullName = $"~/{webPath}/{file}" }); }
public void ShouldInvokeExchangeWithCorrectDateRanges() { string seriesDir = Path.Combine(Environment.CurrentDirectory, "tests", "ShouldInvokeExchangeWithCorrectDateRanges"); Mock <IExchange> exchangeService = new Mock <IExchange>(MockBehavior.Loose); var batchNumberService = new BatchNumberService(); var filePathService = new FilePathService(); CancellationTokenSource cts = new CancellationTokenSource(); Mock <IEventSavingService> savingService = new Mock <IEventSavingService>(MockBehavior.Loose); var downloader = new SingleInstrumentDownloadService(exchangeService.Object, batchNumberService, filePathService, savingService.Object); var service = new HistoricalPricesDownloadService(downloader); var instruments = new string[] { "BTC_USD", "ETC_USD" }; service.DownloadAndSave(instruments, 12, seriesDir, cts.Token); exchangeService.Verify( g => g.GetHistoricalPrices("BTC_USD", 300, // batch12 start - 15 minutes DateTimeExtensions.CreateNodaTime(2019, 4, 27, 23, 45, 0), // batch12 end + 15 minutes DateTimeExtensions.CreateNodaTime(2019, 5, 5, 0, 14, 59) ), Times.Exactly(1) ); exchangeService.Verify( g => g.GetHistoricalPrices("ETC_USD", 300, DateTimeExtensions.CreateNodaTime(2019, 4, 27, 23, 45, 0), DateTimeExtensions.CreateNodaTime(2019, 5, 5, 0, 14, 59) ), Times.Exactly(1) ); exchangeService.VerifyNoOtherCalls(); Assert.False(File.Exists(Path.Combine(seriesDir, "12", "BTC_USD.csv"))); }
public SqliteDatabaseService(FilePathService filePathService, LoggerService loggerService) { FilePathService = filePathService; LoggerService = loggerService; }
public LoggerService(Program program, FilePathService filePathService) { Program = program; FilePathService = filePathService; }
public ConfigService(Program program, FilePathService filePathService, LoggerService loggerService) { Program = program; FilePathService = filePathService; LoggerService = loggerService; }
/// <summary> /// 构造方法 /// </summary> public DataImportController() { filePath = ServiceLoader.GetService <FilePathService>(); importService = ServiceLoader.GetService <TS>(); }
public SqliteContext(FilePathService filePathService, bool readOnly = false) { FilePathService = filePathService; ReadOnly = readOnly; }
public LoggerService(FilePathService filePathService) { FilePathService = filePathService; }