public void ValidateFileName_FileAlredyExists() { var mockStorageService = new Mock <IKeyValuePersistenceService>(); mockStorageService.Setup(x => x.ContainsAsync(It.IsAny <string>(), default(CancellationToken))) .ReturnsAsync(() => true); var service = new EsfFileNameValidationService(mockStorageService.Object, new FeatureFlags { DuplicateFileCheckEnabled = true }, new Mock <IJobService>().Object, new Mock <IDateTimeProvider>().Object, new Mock <IBespokeHttpClient>().Object, new ApiSettings()); service.ValidateUniqueFileAsync("SUPPDATA-10000116-ESF-2270-20180909-090919.csv", 1000).Result.ValidationResult.Should() .Be(FileNameValidationResult.FileAlreadyExists); }
public void ValidateFileName_ValidateContractReference() { var mockStorageService = new Mock <IKeyValuePersistenceService>(); mockStorageService.Setup(x => x.ContainsAsync(It.IsAny <string>(), default(CancellationToken))) .ReturnsAsync(() => false); var httpClientMock = new Mock <IBespokeHttpClient>(); httpClientMock.Setup(x => x.GetDataAsync(It.IsAny <string>())).Throws <Exception>(); var service = new EsfFileNameValidationService( mockStorageService.Object, new FeatureFlags { DuplicateFileCheckEnabled = true }, new Mock <IJobService>().Object, new Mock <IDateTimeProvider>().Object, httpClientMock.Object, new ApiSettings()); service.IsContractReferenceValid(10000116, "SUPPDATA-10000116-ESF-2270-20180909-090919.csv").Result.ValidationResult.Should() .Be(FileNameValidationResult.InvalidContractRefNumber); }