コード例 #1
0
        /// <summary>
        /// The transform test data values.
        /// </summary>
        /// <returns>
        /// The <see cref="OrderedDictionary"/>.
        /// </returns>
        private OrderedDictionary TransformTestDataValues()
        {
            //// Transformation Step
            //// - Results\TestDataValues.transformed.txt(ready to load using KeyValuePairUtils)
            ////    -values evaluated
            ////    - Constants applied(Results\Constants.transformed.txt)
            ////- Simple functions called
            var resolvedTestDataValuesFilePath =
                TestCaseFileAndFolderUtils.GetTestCaseTempFilePath("TestDataValues.resolved.txt", false);
            var resolvedDict = KeyValuePairUtils.ReadKeyValuePairsFromFile(resolvedTestDataValuesFilePath);

            var transformedDict = new OrderedDictionary();

            // TODO: Is this the kind of transformation we require see above
            foreach (var key in resolvedDict.Keys)
            {
                var value = (string)resolvedDict[key];

                var evaluatedValue = StringTransformationUtils.Evaluate(value);

                transformedDict.Add(key, evaluatedValue);
            }

            var transformedTestDataValuesFilePath =
                TestCaseFileAndFolderUtils.GetTestCaseResultsFilePath("TestDataValues.transformed.txt", false);

            KeyValuePairUtils.SaveKeyValuePairsToFile(
                transformedTestDataValuesFilePath,
                transformedDict,
                "Transformed Test Data Values");
            return(transformedDict);
        }
コード例 #2
0
        public void TestTestCaseDirectoryDoesNotExists()
        {
            var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(5001, UnitTestTestDataRoot);
            var actual = testCaseFileAndFolderUtils.TestCaseDirectory;

            StfAssert.IsNull("TestCaseDirectory does not exists", actual);
        }
コード例 #3
0
        /// <summary>
        /// The helper test file paths all steps.
        /// </summary>
        /// <param name="testCaseName">
        /// The test case name.
        /// </param>
        /// <param name="testCaseId">
        /// The test case id.
        /// </param>
        /// <param name="fileNameFilters">
        /// The file name filters.
        /// </param>
        /// <param name="numSteps">
        /// The num steps.
        /// </param>
        /// <param name="expectedFilePaths">
        /// The expected file paths.
        /// </param>
        private void HelperTestFilePathsAllSteps(
            string testCaseName,
            int testCaseId,
            string[] fileNameFilters,
            int numSteps,
            string[,] expectedFilePaths)
        {
            StfLogger.LogHeader(testCaseName);
            var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(testCaseId, UnitTestTestDataRoot);
            var testCaseStepFilePathUtils  = new TestCaseStepFilePathUtils(
                testCaseFileAndFolderUtils.TestCaseDirectory,
                fileNameFilters,
                true);

            for (int stepNum = 1; stepNum <= numSteps; stepNum++)
            {
                StfLogger.LogSubHeader($"Step {stepNum}");
                for (var fileNameFilterNo = 0; fileNameFilterNo < fileNameFilters.Length; fileNameFilterNo++)
                {
                    var actual = testCaseStepFilePathUtils.GetFileNameForStep(fileNameFilters[fileNameFilterNo], stepNum);
                    StfAssert.AreEqual(
                        "FileNames for step are equal",
                        expectedFilePaths[stepNum - 1, fileNameFilterNo],
                        actual);
                }
            }
        }
コード例 #4
0
        public void TestTestCaseDirectoriesExists()
        {
            var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(9001, UnitTestTestDataRoot);

            // root
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseRootFilePath(null), @"Tc9001");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseRootFilePath(string.Empty), @"Tc9001");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseRootFilePath("FileName.NotExists"), null);
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseRootFilePath("FileName.NotExists", false), @"Tc9001\FileName.NotExists");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseRootFilePath("UnitTestRootFile01.txt"), @"Tc9001\UnitTestRootFile01.txt");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseRootFilePath("UnitTestRootFile01.txt", false), @"Tc9001\UnitTestRootFile01.txt");

            // Results
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseResultsFilePath(null), @"Tc9001\Results");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseResultsFilePath(string.Empty), @"Tc9001\Results");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseResultsFilePath("FileName.NotExists"), null);
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseResultsFilePath("FileName.NotExists", false), @"Tc9001\Results\FileName.NotExists");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseResultsFilePath("UnitTestResultFile01.txt"), @"Tc9001\Results\UnitTestResultFile01.txt");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseResultsFilePath("UnitTestResultFile01.txt", false), @"Tc9001\Results\UnitTestResultFile01.txt");

            // Temp
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseTempFilePath(null), @"Tc9001\Temp");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseTempFilePath(string.Empty), @"Tc9001\Temp");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseTempFilePath("FileName.NotExists"), null);
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseTempFilePath("FileName.NotExists", false), @"Tc9001\Temp\FileName.NotExists");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseTempFilePath("UnitTestTempFile01.txt"), @"Tc9001\Temp\UnitTestTempFile01.txt");
            HelperTestCaseDirectories(testCaseFileAndFolderUtils.GetTestCaseTempFilePath("UnitTestTempFile01.txt", false), @"Tc9001\Temp\UnitTestTempFile01.txt");
        }
コード例 #5
0
        /// <summary>
        /// The helper number of steps.
        /// </summary>
        /// <param name="testStep">
        /// The test step.
        /// </param>
        /// <param name="testCaseId">
        /// The test case id.
        /// </param>
        /// <param name="expected">
        /// The expected.
        /// </param>
        private void HelperNumberOfSteps(string testStep, int testCaseId, int expected)
        {
            var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(testCaseId, UnitTestTestDataRoot);
            var templateConfigUtils        = new TemplateConfigUtils(testCaseFileAndFolderUtils.TestCaseDirectory);
            var actual = templateConfigUtils.NumberOfSteps;

            StfAssert.AreEqual(testStep, expected, actual);
        }
コード例 #6
0
        /// <summary>
        /// The helper number of steps.
        /// </summary>
        /// <param name="testStep">
        /// The test step.
        /// </param>
        /// <param name="testCaseId">
        /// The test case id.
        /// </param>
        /// <param name="expected">
        /// The expected.
        /// </param>
        private void HelperNumberOfSteps(string testStep, int testCaseId, int expected)
        {
            var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(testCaseId, UnitTestTestDataRoot);
            var fileNameFilters            = new[] { "Template.txt", "Config.txt" };
            var testCaseStepFilePathUtils  = new TestCaseStepFilePathUtils(testCaseFileAndFolderUtils.TestCaseDirectory, fileNameFilters);
            var actual = testCaseStepFilePathUtils.NumberOfSteps;

            StfAssert.AreEqual(testStep, expected, actual);
        }
コード例 #7
0
        public void TestTestCaseDirectoryExists()
        {
            var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(9001, UnitTestTestDataRoot);
            var actual   = testCaseFileAndFolderUtils.TestCaseDirectory;
            var expected = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), UnitTestTestDataRoot, "Tc9001"));

            StfAssert.AreEqual("TestCaseDirectory exists", expected, actual);
            StfAssert.AreEqual("TestCaseID", 9001, testCaseFileAndFolderUtils.TestCaseId);
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestCaseDirectoryDataUtils"/> class.
 /// </summary>
 /// <param name="testCaseId">
 /// The test case id.
 /// </param>
 /// <param name="testCaseDirectoryRoot">
 /// The test case directory root.
 /// </param>
 public TestCaseDirectoryDataUtils(int testCaseId, string testCaseDirectoryRoot)
 {
     TestCaseDirectoryRoot      = testCaseDirectoryRoot;
     TestCaseId                 = testCaseId;
     TestCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(TestCaseId, TestCaseDirectoryRoot);
     TestDataValuesFilePath     = TestCaseFileAndFolderUtils.GetTestCaseRootFilePath("TestDataValues.txt");
     ConstantsFilePath          = TestCaseFileAndFolderUtils.GetTestCaseRootFilePath("Constants.txt");
     KeyValuePairUtils          = new KeyValuePairUtils();
     StringTransformationUtils  = new StringTransformationUtils();
     Init();
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestCaseDirectoryDataUtils"/> class.
 /// </summary>
 /// <param name="testCaseFileAndFolderUtils">
 /// The test Case File And Folder Utils.
 /// </param>
 /// <param name="stringTransformationUtils">
 /// The string Transformation Utils.
 /// </param>
 public TestCaseDirectoryDataUtils(TestCaseFileAndFolderUtils testCaseFileAndFolderUtils, IStringTransformationUtils stringTransformationUtils)
 {
     TestCaseDirectoryRoot      = testCaseFileAndFolderUtils.TestCaseDirectory;
     TestCaseId                 = testCaseFileAndFolderUtils.TestCaseId;
     TestCaseFileAndFolderUtils = testCaseFileAndFolderUtils;
     TestDataValuesFilePath     = TestCaseFileAndFolderUtils.GetTestCaseRootFilePath("TestDataValues.txt");
     ConstantsFilePath          = TestCaseFileAndFolderUtils.GetTestCaseRootFilePath("Constants.txt");
     KeyValuePairUtils          = new KeyValuePairUtils();
     StringTransformationUtils  = stringTransformationUtils;
     StringTransformationUtils.RegisterAllStuFunctionsForType(this);
     Init();
 }
コード例 #10
0
        public void TestSimpleTestDataManagement2()
        {
            var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(4002, @".\TestData\EndToEnd");
            var testDataValuesFilePath     = testCaseFileAndFolderUtils.GetTestCaseRootFilePath("TestDataValues.txt");
            var keyValuePairUtils          = new KeyValuePairUtils();
            var testData = keyValuePairUtils.ReadKeyValuePairsFromFile(testDataValuesFilePath);

            foreach (var testDataKey in testData.Keys)
            {
                var value = testData[testDataKey];

                StfLogger.LogInfo($"[{testDataKey}] has the value [{value}]");
            }
        }
コード例 #11
0
        /// <summary>
        /// The get constants values.
        /// </summary>
        /// <returns>
        /// The <see cref="OrderedDictionary"/>.
        /// </returns>
        private OrderedDictionary GetConstantsValues()
        {
            ////(2) Evaluate Constants.txt
            ////    - Temp\Constants.list.txt(all constant files compiled into one file)
            ////    - include files resolved(marked for debug with comments)
            ////    -Temp\Constants.resolved.txt
            ////    - values overlayed
            ////    - Results\Constants.transformed.txt(ready to load using KeyValuePairUtils)

            var retVal = KeyValuePairUtils.ReadKeyValuePairsFromFile(ConstantsFilePath);
            var resolvedConstantFilePath = TestCaseFileAndFolderUtils.GetTestCaseResultsFilePath("Constants.Resolved.txt", false);

            KeyValuePairUtils.SaveKeyValuePairsToFile(resolvedConstantFilePath, retVal, "Resolved Constants");
            return(retVal);
        }
コード例 #12
0
        /// <summary>
        /// The helper file paths.
        /// </summary>
        /// <param name="testStep">
        /// The test step.
        /// </param>
        /// <param name="testCaseId">
        /// The test case id.
        /// </param>
        /// <param name="fileNameFilter">
        /// The file name filter.
        /// </param>
        /// <param name="step">
        /// The step.
        /// </param>
        /// <param name="expectedFilePath">
        /// The expected file path.
        /// </param>
        private void HelperFilePaths(
            string testStep,
            int testCaseId,
            string fileNameFilter,
            int step,
            string expectedFilePath)
        {
            StfLogger.LogSubHeader(testStep);

            var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(testCaseId, UnitTestTestDataRoot);
            var fileNameFilters            = new[] { "Template.txt", "Config.txt" };
            var testCaseStepFilePathUtils  = new TestCaseStepFilePathUtils(testCaseFileAndFolderUtils.TestCaseDirectory, fileNameFilters);
            var actual = testCaseStepFilePathUtils.GetFileNameForStep(fileNameFilter, step);

            StfAssert.AreEqual(testStep, expectedFilePath, actual);
        }
コード例 #13
0
        /// <summary>
        /// The compile test data values.
        /// </summary>
        /// <returns>
        /// The <see cref="OrderedDictionary"/>.
        /// </returns>
        private OrderedDictionary CompileTestDataValues()
        {
            //// Compilation Step
            //// -Temp\TestDataValues.txt(all TestDataValue files compiled into one file)
            ////    - include files resolved(marked for debug with comments)
            ////
            var originalDict = KeyValuePairUtils.ReadKeyValuePairsFromFile(TestDataValuesFilePath);

            // TODO: Do some compilation here as per comment above (gathering all TDV's together)
            var retVal = originalDict;

            var compiledTestDataValuesFilePath =
                TestCaseFileAndFolderUtils.GetTestCaseTempFilePath("TestDataValues.compiled.txt", false);

            KeyValuePairUtils.SaveKeyValuePairsToFile(compiledTestDataValuesFilePath, retVal, "Compiled Test Data Values");

            return(retVal);
        }
コード例 #14
0
        /// <summary>
        /// The resolve test data values.
        /// </summary>
        /// <returns>
        /// The <see cref="OrderedDictionary"/>.
        /// </returns>
        private OrderedDictionary ResolveTestDataValues()
        {
            //// Resolution Step
            //// -Temp\TestDataValues.resolved.txt
            ////    - values overlayed
            ////
            var compiledTestDataValuesFilePath =
                TestCaseFileAndFolderUtils.GetTestCaseTempFilePath("TestDataValues.compiled.txt", false);
            var compiledDict = KeyValuePairUtils.ReadKeyValuePairsFromFile(compiledTestDataValuesFilePath);

            // TODO: Do some resolving and overlaying as per comment above on Resolving step
            var retVal = compiledDict;

            var resolvedTestDataValuesFilePath =
                TestCaseFileAndFolderUtils.GetTestCaseTempFilePath("TestDataValues.resolved.txt", false);

            KeyValuePairUtils.SaveKeyValuePairsToFile(
                resolvedTestDataValuesFilePath,
                retVal,
                "Resolved Test Data Values");
            return(retVal);
        }