Exemplo n.º 1
0
        /// <summary>
        /// The helper test GUID functions.
        /// </summary>
        /// <param name="functionName">
        /// The function name.
        /// </param>
        /// <param name="arg">
        /// The arg.
        /// </param>
        /// <param name="expected">
        /// The expected.
        /// </param>
        private void HelperTestGuid(string functionName, string arg, bool expected)
        {
            var guid      = stringTransformationUtils.EvaluateFunction(functionName, arg);
            var formatArg = string.IsNullOrEmpty(arg) ? "D" : arg;
            var actual    = System.Guid.TryParseExact(guid, formatArg, out _);

            StfAssert.AreEqual($"{functionName} - {arg}", expected, actual);
        }
Exemplo n.º 2
0
        /// <summary>
        /// The helper multi test select.
        /// </summary>
        /// <param name="arg">
        /// The arg.
        /// </param>
        /// <param name="numberOfValues">
        /// The number of values.
        /// </param>
        private void HelperMultiTestSelect(string arg, int numberOfValues)
        {
            var dictOutcomes = new Dictionary <string, int>();

            for (var i = 0; i < 50 * numberOfValues; i++)
            {
                var actual = stringTransformationUtils.EvaluateFunction("SELECT", arg);

                if (!dictOutcomes.ContainsKey(actual))
                {
                    dictOutcomes[actual] = 0;
                }

                dictOutcomes[actual]++;
            }

            // TODO: Missing a evaluation of the distribution - for now we check all values are chosen
            StfAssert.AreEqual("all values are chosen", numberOfValues, dictOutcomes.Count);
        }
Exemplo n.º 3
0
        /// <summary>
        /// The helper test Pad.... functions.
        /// </summary>
        /// <param name="direction">
        /// The direction of the padding PadRight or PadLeft
        /// </param>
        /// <param name="source">
        /// The source string
        /// </param>
        /// <param name="totalWidth">
        /// The total width if the transformed string
        /// </param>
        /// <param name="paddingChar">
        /// The character with which to pad the string
        /// </param>
        /// <param name="expected">
        /// The expected value of the transformed string
        /// </param>
        /// <param name="testLengthAgainstTotalWidth">
        /// The test Length Against Total Width.
        /// </param>
        private void HelperTestPad(string direction, string source, string totalWidth, string paddingChar, string expected, bool testLengthAgainstTotalWidth = false)
        {
            var arg    = $@"""{direction}"" ""{source}"" ""{totalWidth}"" ""{paddingChar}""";
            var actual = stringTransformationUtils.EvaluateFunction("STRING", arg);

            StfAssert.AreEqual($"Unittest {direction} test actual / expected", expected, actual);
            if (testLengthAgainstTotalWidth)
            {
                StfAssert.AreEqual($"Unittest {direction} test actual length / total width", expected.Length.ToString(), totalWidth);
            }
        }
        /// <summary>
        /// The helper test simple functions.
        /// </summary>
        /// <param name="arg">
        /// The arg.
        /// </param>
        /// <param name="expected">
        /// The expected.
        /// </param>
        private void HelperTestSimple(string arg, string expected)
        {
            var actual = stringTransformationUtils.EvaluateFunction("MAPVALUES", arg);

            StfAssert.AreEqual(arg, expected, actual);
        }
Exemplo n.º 5
0
        /// <summary>
        /// The helper test format.
        /// </summary>
        /// <param name="arg">
        /// The arg.
        /// </param>
        /// <param name="expected">
        /// The expected.
        /// </param>
        private void HelperTestFormat(string arg, string expected)
        {
            var actual = stringTransformationUtils.EvaluateFunction("FORMAT", arg);

            StfAssert.AreEqual(arg, expected, actual);
        }
Exemplo n.º 6
0
        /// <summary>
        /// The helper test bob.
        /// </summary>
        /// <param name="functionName">
        /// The function name.
        /// </param>
        /// <param name="arg">
        /// The arg.
        /// </param>
        /// <param name="expected">
        /// The expected.
        /// </param>
        private void HelperTestBob(string functionName, string arg, string expected)
        {
            var actual = stringTransformationUtils.EvaluateFunction(functionName, arg);

            StfAssert.AreEqual($"{functionName} - {arg}", expected, actual);
        }