/// <summary>
        /// The helper read key value pairs from file.
        /// </summary>
        /// <param name="testStep">
        /// The test step.
        /// </param>
        /// <param name="inputFilename">
        /// The input filename.
        /// </param>
        /// <param name="assignmentOperator">
        /// The assignment operator.
        /// </param>
        /// <param name="commentIndicator">
        /// The comment indicator.
        /// </param>
        /// <param name="keyNameIgnoreCase">
        /// The key name ignore case.
        /// </param>
        private void HelperReadKeyValuePairsFromFile(string testStep, string inputFilename, string assignmentOperator = "=", string commentIndicator = "//", bool keyNameIgnoreCase = true)
        {
            StfLogger.LogHeader(testStep);

            var absolutePathInput    = stfTestUtils.GetTestCaseRootFilePath(inputFilename);
            var absolutePathExpected = stfTestUtils.GetTestCaseRootFilePath($@"Expected\{inputFilename}");
            var tempInputPath        = stfTestUtils.GetTestCaseTempFilePath(inputFilename, false);
            var tempActualPath       = stfTestUtils.GetTestCaseTempFilePath($@"{inputFilename}-Actual.txt", false);
            var tempExpectedPath     = stfTestUtils.GetTestCaseTempFilePath($@"{inputFilename}-Expected.txt", false);
            var fileUtils            = stfTestUtils.FileUtils;

            fileUtils.CopyFile(absolutePathInput, tempInputPath);
            fileUtils.CopyFile(absolutePathExpected, tempExpectedPath);

            // generate Actual
            var keyNameValueUtils = new KeyValuePairUtils(assignmentOperator, commentIndicator, keyNameIgnoreCase);
            var keyValuePairs     = keyNameValueUtils.ReadKeyValuePairsFromFile(tempInputPath);

            keyNameValueUtils.SaveKeyValuePairsToFile(tempActualPath, keyValuePairs);

            StfAssert.FilesDoNotDiffer(testStep, tempExpectedPath, tempActualPath);
        }
Exemplo n.º 2
0
        /// <summary>
        /// The helper get clean file content.
        /// </summary>
        /// <param name="testStep">
        /// The test step.
        /// </param>
        /// <param name="inputFilename">
        /// The input filename.
        /// </param>
        private void HelperGetCleanFileContent(string testStep, string inputFilename)
        {
            StfLogger.LogHeader(testStep);

            var expectedFilename     = $"{inputFilename}.Expected.txt";
            var absolutePathInput    = stfTestUtils.GetTestCaseRootFilePath(inputFilename);
            var absolutePathExpected = stfTestUtils.GetTestCaseRootFilePath(expectedFilename);
            var tempInputPath        = stfTestUtils.GetTestCaseTempFilePath(inputFilename, false);
            var tempActualPath       = stfTestUtils.GetTestCaseTempFilePath($@"{inputFilename}-Actual.txt", false);
            var tempExpectedPath     = stfTestUtils.GetTestCaseTempFilePath($@"{inputFilename}-Expected.txt", false);
            var fileUtils            = stfTestUtils.FileUtils;

            fileUtils.CopyFile(absolutePathInput, tempInputPath);
            fileUtils.CopyFile(absolutePathExpected, tempExpectedPath);

            // generate Actual
            var actual = fileUtils.GetCleanFileContent(tempInputPath);

            File.WriteAllText(tempActualPath, actual);

            StfAssert.FilesDoNotDiffer(testStep, tempExpectedPath, tempActualPath);
        }