Exemple #1
0
        public bool PosTest5()
        {
            bool   retVal = true;
            string strA;
            string strB;
            int    ActualResult;

            TestLibrary.TestFramework.BeginScenario("PosTest5:Two like strings CompareTo");

            try
            {
                strA         = "helloword!";
                strB         = "helloword!";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // 0
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("009", "Two like strings CompareTo ExpectResult is equel 0 ActualResult is (" + ActualResult + ")");
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("010", "Unexpected exception" + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #2
0
        public bool PosTest17()
        {
            bool   retVal = true;
            string strA;
            string strB;
            int    ActualResult;

            TestLibrary.TestFramework.BeginScenario("PosTest17:Globalized strings CompareTo");
            try
            {
                strA         = "A\u0300";
                strB         = "\u00C0";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // 0
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("033", "Globalized strings CompareTo ExpectResult is equel 0,ActualResult is (" + ActualResult + ")");
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("034", "Unexpected Exception" + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #3
0
        public bool PosTest19()
        {
            bool   retVal = true;
            string strA;
            string strB;
            int    ActualResult;

            TestLibrary.TestFramework.BeginScenario("PosTest19:Two different strings CompareTo two");
            try
            {
                strA         = "\uD801\uDC00";
                strB         = "\uD801\uDC28";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // -1
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("037", "Two different strings CompareTo two ExpectResult is less 0,ActualResult is (" + ActualResult + ")");
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("038", "Unexpected Exception" + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #4
0
        public bool PosTest13()
        {
            bool   retVal = true;
            string strA;
            string strB;
            int    ActualResult;

            TestLibrary.TestFramework.BeginScenario("PosTest13:string CompareTo its with newline symbol three");
            try
            {
                strA         = "\nhelloword";
                strB         = "helloword";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // -1
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("025", "string CompareTo its with newline symbol three ExpectResult is less 0,ActualResult is (" + ActualResult + ")");
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("026", "Unexpected Exception" + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #5
0
        public bool PosTest16()
        {
            bool   retVal = true;
            string strA;
            string strB;
            int    ActualResult;

            TestLibrary.TestFramework.BeginScenario("PosTest16:strings embedded nulls CompareTo three");
            try
            {
                strA         = "\0helloword";
                strB         = "helloword";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // 0
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("031", "strings embedded nulls CompareTo three ExpectResult is equel 0,ActualResult is (" + ActualResult + ")");
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("032", "Unexpected Exception" + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #6
0
        public bool PosTest10()
        {
            bool   retVal = true;
            string strA;
            string strB;
            int    ActualResult;

            TestLibrary.TestFramework.BeginScenario("PosTest10:strings with one char CompareTo");
            try
            {
                strA         = "A";
                strB         = "a";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // 1
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("019", "strings with one char CompareTo ExpectResult is greater 0,ActualResult is (" + ActualResult + ")");
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("020", "Unexpected Exception" + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #7
0
        public bool PosTest8()
        {
            bool   retVal = true;
            string strA;
            string strB;
            int    ActualResult;

            TestLibrary.TestFramework.BeginScenario("PosTest8:string CompareTo its with space two");

            try
            {
                strA         = "helloword";
                strB         = "hello word";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // 1
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("015", "string CompareTo its with space one ExpectResult is greater 0 ActualResult is (" + ActualResult + ")");
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("016", "Unexpected exception" + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #8
0
        public bool PosTest6()
        {
            bool   retVal = true;
            string strA;
            string strB;
            int    ActualResult;

            TestLibrary.TestFramework.BeginScenario("PosTest6:One string with lower chars CompareTo the uppers ");

            try
            {
                strA         = "helloWord";
                strB         = "helloword";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // 1
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("011", "One string with lower chars CompareTo the uppers ExpectResult is greater 0 ActualResult is (" + ActualResult + ")");
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("012", "Unexpected exception" + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #9
0
        public bool PosTest21()
        {
            bool   retVal = true;
            int    ActualResult;
            string strA;
            string strB;

            TestLibrary.TestFramework.BeginScenario("PosTest21: Tab CompareTo four spaces ");

            try
            {
                strA         = "\t";
                strB         = "    ";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // 1
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("041", "Tab CompareTo four spaces Expected Result is greater 0,Actual Result is ( " + ActualResult + ")");
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("042", "Unexpected exception: " + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #10
0
        public bool PosTest20()
        {
            bool   retVal = true;
            int    ActualResult;
            string strA;
            string strB;

            TestLibrary.TestFramework.BeginScenario("PosTest20: Two different strings CompareTo three");

            try
            {
                strA         = "\\\\my documents\\my files\\";
                strB         = @"\\my documents\my files\";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // 0
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("039", "Two different strings CompareTo three Expected Result is equel 0,Actual Result is ( " + ActualResult + ")");
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("040", "Unexpected exception: " + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #11
0
        public bool PosTest4()
        {
            bool   retVal = true;
            string strA;
            string strB;
            int    ActualResult;

            TestLibrary.TestFramework.BeginScenario("PosTest4:one space CompareTo two spaces");

            try
            {
                strA         = " ";
                strB         = "  ";
                ActualResult = strA.CompareTo(strB);
                int ExpectedResult = GlobLocHelper.OSCompare(strA, strB); // -1
                if (ActualResult != ExpectedResult)
                {
                    TestLibrary.TestFramework.LogError("007", "one space CompareTo two spaces ExpectResult is less 0 ActualResult is (" + ActualResult + ")");
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("008", "Unexpected exception" + e);
                retVal = false;
            }
            return(retVal);
        }
Exemple #12
0
    public bool Test(CultureInfo culture, string str1, string str2, int expected, CompareOptions options, string id)
    {
		if (!Utilities.IsVistaOrLater || !culture.Name.Equals("tr-TR")) //Due Windows 7 bug 130925
			expected = GlobLocHelper.OSCompare(culture, str1, 0, str1.Length, str2, 0, str2.Length, options);

        CompareInfo ci = culture.CompareInfo;
        bool result = true;
        if (str1 == null || str2 == null || (str1.Length < 100 && str2.Length < 100))
            TestFramework.BeginScenario(id + ": Comparing " + ((str1 == null) ? "null" : str1) + " / " + ((str2 == null) ? "null" : str2) + "; options: " + options + "; culture: " + ci.Name);
        else
            TestFramework.BeginScenario(id + ": Comparing LongStr (" + str1.Length + ") / LongStr(" + str2.Length + "); options: " + options + "; culture: " + ci.Name);
        try
        {
            int i = ci.Compare(str1, str2, options);
            i = (i == 0) ? 0 : i / Math.Abs(i); // We don't care what i is, just whether it's =,>, or < 0
            if (i != expected)
            {
                result = false;
                TestFramework.LogError("001", "Error in " + id + ", unexpected comparison result. Actual: " + i + ", Expected: " + expected);
            }
            i = ci.Compare(str2, str1, options);
            i = (i == 0) ? 0 : i / Math.Abs(i); // We don't care what i is, just whether it's =,>, or < 0
            if (i != (0 - expected))
            {
                result = false;
                TestFramework.LogError("002", "Error in " + id + ", unexpected comparison result. Actual: " + i + ", Expected: " + (0 - expected));
            }
        }
        catch (Exception exc)
        {
            result = false;
            TestFramework.LogError("003", "Unexpected exception in " + id + ", excpetion: " + exc.ToString());
        }
        return result;
    }
Exemple #13
0
        // if value is no-weight char, return true
        public static bool NoWeightChar(int value)
        {
            if ((int)'a' == value) // 'a' = 97
            {
                return(false);
            }

            String strA = "a" + Convert.ToChar(value);
            String strB = "a";

            if (0 == GlobLocHelper.OSCompare(CultureInfo.CurrentCulture, strA, 0, 2, strB, 0, 1, CompareOptions.None))
            {
                return(true);
            }

            return(false);
        }
Exemple #14
0
    // True value returned from test method means that the first substring lesser than the second
    private bool ExecutePosTestLesser(Parameters paras, bool expectedValue, string testDesc)
    {
        bool retVal = true;

        UpdateCounts(TestType.PositiveTest);

        string testInfo = c_POS_TEST_PREFIX + this.posTestCount.ToString() + ": " + testDesc;
        bool   actualValue;

        TestResult testResult = TestResult.NotRun;

        TestLibrary.TestFramework.BeginScenario(testInfo);
        try
        {
            actualValue = (0 > this.CallTestMethod(paras));
            if (paras.strA != null && paras.strB != null)
            {
                expectedValue = (0 > GlobLocHelper.OSCompare(paras.strA, paras.strB));
            }
            if (expectedValue != actualValue)
            {
                string errorDesc = "Value is not " + expectedValue + " as expected: Actual(" + actualValue + ")";
                errorDesc += paras.DataString;
                TestLibrary.TestFramework.LogError(GenerateErrorNum(this.totalTestCount), errorDesc);
                testResult = TestResult.FailedTest;
                retVal     = false;
            }
            testResult = TestResult.PassedTest;
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError(GenerateErrorNum(this.totalTestCount + 1), "Unexpected exception: " + e);
            testResult = TestResult.FailedTest;
            retVal     = false;
        }

        UpdateCounts(testResult);
        return(retVal);
    }
Exemple #15
0
        /// <summary>
        /// Compare the same string with different cases when the case is considered
        /// </summary>
        /// <returns></returns>
        public bool PosTest2()
        {
            bool retVal = true;

            try
            {
                TestLibrary.TestFramework.BeginScenario("Compare the same string with different cases when the case is considered...");
                int expected = GlobLocHelper.OSCompare(str1, 2, str2, 2, 3, false); // 1;
                if (String.Compare(str1, 2, str2, 2, 3, StringComparison.CurrentCulture) != expected)
                {
                    TestLibrary.TestFramework.LogError("009", "LLOWO is not larger than llowo when the case is considered!");
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
                retVal = false;
            }


            return(retVal);
        }
Exemple #16
0
        /// <summary>
        /// Compare the same string with different cases when ignore the case
        /// </summary>
        /// <returns></returns>
        public bool PosTest1()
        {
            bool retVal = true;

            try
            {
                TestLibrary.TestFramework.BeginScenario("Compare the same string with different cases when ignore the case...");
                int expected = GlobLocHelper.OSCompare(str1, 2, str2, 2, 3, true); // 0;
                if (String.Compare(str1, 2, str2, 2, 3, StringComparison.CurrentCultureIgnoreCase) != expected)
                {
                    TestLibrary.TestFramework.LogError("001", "LLOWO is not equal to llowo when ignore the case...");
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
                retVal = false;
            }


            return(retVal);
        }
Exemple #17
0
    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Compare two strings using the CultureInfo myCItrad which uses the traditional sort.");
        try
        {
            CultureInfo myCItrad       = new CultureInfo("es-ES_tradnl");
            string      compareString1 = "llegar";
            string      compareString2 = "lugar";
            if (myCItrad.CompareInfo.Compare(compareString1, compareString2) != GlobLocHelper.OSCompare(compareString1, compareString2, myCItrad))
            {
                TestLibrary.TestFramework.LogError("003", "return  error");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }
        return(retVal);
    }
Exemple #18
0
    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Compare two strings using the CultureInfo  myCIintl which uses the international sort.");
        try
        {
            CultureInfo myCIintl       = new CultureInfo("es-ES");;
            string      compareString1 = "llegar";
            string      compareString2 = "lugar";
            if (myCIintl.CompareInfo.Compare(compareString1, compareString2) != GlobLocHelper.OSCompare(compareString1, compareString2, myCIintl))
            {
                TestLibrary.TestFramework.LogError("001", "return  error");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            retVal = false;
        }
        return(retVal);
    }
Exemple #19
0
    /// <summary>
    /// Compare two same strings with different cases...
    /// </summary>
    /// <returns></returns>
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("Compare two same strings with different cases...");

        try
        {
            int expected = GlobLocHelper.OSCompare(str1, 0, str2, 0, str1.Length);  // 1;
            if (String.Compare(str1, 0, str2, 0, str1.Length) != expected)
            {
                TestLibrary.TestFramework.LogError("001", "The result is equal when compare different cases string!");
                TestLibrary.TestFramework.LogInformation("Expected: " + expected.ToString() + " Actual: " + String.Compare(str1, 0, str2, 0, str1.Length).ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected Exception occurs :" + e);
            retVal = false;
        }

        return(retVal);
    }