public void Validate_WhenAllGood_ReturnsSuccess() { fileSystemOperationsMock.FileExists("arg1").Returns(true); fileSystemOperationsMock.DirectoryExists("arg2").Returns(true); Assert.That(systemUnderTest.Validate(new[] { "arg1", "arg2" }), Is.EqualTo(Constants.ErrorCodes.Success)); }
private void DeleteFileIfExists(string fullPath) { if (fileSystemOperationsService.FileExists(fullPath)) { fileSystemOperationsService.DeleteFile(fullPath); } }
private int ValidateInputFilename(string inputFilename) { if (string.IsNullOrWhiteSpace(inputFilename)) { return(Constants.ErrorCodes.InvalidInputFileName); } if (!fileSystemOperations.FileExists(inputFilename)) { return(Constants.ErrorCodes.InputFileDoesNotExist); } return(Constants.ErrorCodes.Success); }
public void Execute_WhenLegacyReaderRecordsForDayReadFires_RemovesTempFile() { var outputRecords = new List <StatsDataItem>(); outputRecords.Add(new StatsDataItem()); var inputRecords = SetUpLegacyDataReader(); dataMappingServiceMock.MapData(inputRecords).Returns(outputRecords); var intermediateOutputFilename = SetUpStatsFileIntermediateOutputFilename(inputRecords); var tempCompressedFilename = @"c:\path\to\tmp\tmpfile.tmp"; fileSystemOperationsServiceMock.GetTempFilename().Returns(tempCompressedFilename); fileSystemOperationsServiceMock.FileExists(intermediateOutputFilename).Returns(true); systemUnderTest.Execute(new[] { "arg1", @"c:\path\to\output" }); fileSystemOperationsServiceMock.Received(1).DeleteFile(intermediateOutputFilename); }