예제 #1
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Check two different instance");

        try
        {
            string str = TestLibrary.Generator.GetString(-55, false, c_MINI_STRING_LENGTH, c_MAX_STRING_LENGTH);
            StringInfo stringInfo1 = new StringInfo(str);
            StringInfo stringInfo2 = new StringInfo("");
            if (stringInfo1.GetHashCode() == stringInfo2.GetHashCode())
            {
                TestLibrary.TestFramework.LogError("003", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
예제 #2
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: The two instances created by the same argument return the same hashcode");

        try
        {
            string str = TestLibrary.Generator.GetString(-55, false, c_MINI_STRING_LENGTH, c_MAX_STRING_LENGTH);
            StringInfo stringInfo1 = new StringInfo(str);
            StringInfo stringInfo2 = new StringInfo(str);
            if (stringInfo1.GetHashCode() != stringInfo2.GetHashCode())
            {
                TestLibrary.TestFramework.LogError("001", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
예제 #3
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Check two different instance");

        try
        {
            string     str         = TestLibrary.Generator.GetString(-55, false, c_MINI_STRING_LENGTH, c_MAX_STRING_LENGTH);
            StringInfo stringInfo1 = new StringInfo(str);
            StringInfo stringInfo2 = new StringInfo("");
            if (stringInfo1.GetHashCode() == stringInfo2.GetHashCode())
            {
                TestLibrary.TestFramework.LogError("003", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
예제 #4
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: The two instances created by the same argument return the same hashcode");

        try
        {
            string     str         = TestLibrary.Generator.GetString(-55, false, c_MINI_STRING_LENGTH, c_MAX_STRING_LENGTH);
            StringInfo stringInfo1 = new StringInfo(str);
            StringInfo stringInfo2 = new StringInfo(str);
            if (stringInfo1.GetHashCode() != stringInfo2.GetHashCode())
            {
                TestLibrary.TestFramework.LogError("001", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
예제 #5
0
 public void Equals(StringInfo stringInfo, object value, bool expected)
 {
     Assert.Equal(expected, stringInfo.Equals(value));
     if (value is StringInfo)
     {
         Assert.Equal(expected, stringInfo.GetHashCode().Equals(value.GetHashCode()));
     }
 }
예제 #6
0
        public void TestDiffInstances()
        {
            string     str         = _generator.GetString(-55, false, c_MINI_STRING_LENGTH, c_MAX_STRING_LENGTH);
            StringInfo stringInfo1 = new StringInfo(str);
            StringInfo stringInfo2 = new StringInfo("");

            Assert.NotEqual(stringInfo2.GetHashCode(), stringInfo1.GetHashCode());
        }
예제 #7
0
 public void Equals(StringInfo stringInfo, object value, bool expected)
 {
     Assert.Equal(expected, stringInfo.Equals(value));
     if (value is StringInfo)
     {
         Assert.Equal(expected, stringInfo.GetHashCode().Equals(value.GetHashCode()));
     }
 }