public static void Main()
    {
        UTF8Encoding utf8          = new UTF8Encoding();
        UTF8Encoding utf8true      = new UTF8Encoding(true);
        UTF8Encoding utf8truetrue  = new UTF8Encoding(true, true);
        UTF8Encoding utf8falsetrue = new UTF8Encoding(false, true);

        DescribeEquivalence(utf8.Equals(utf8));
        DescribeEquivalence(utf8.Equals(utf8true));
        DescribeEquivalence(utf8.Equals(utf8truetrue));
        DescribeEquivalence(utf8.Equals(utf8falsetrue));

        DescribeEquivalence(utf8true.Equals(utf8));
        DescribeEquivalence(utf8true.Equals(utf8true));
        DescribeEquivalence(utf8true.Equals(utf8truetrue));
        DescribeEquivalence(utf8true.Equals(utf8falsetrue));

        DescribeEquivalence(utf8truetrue.Equals(utf8));
        DescribeEquivalence(utf8truetrue.Equals(utf8true));
        DescribeEquivalence(utf8truetrue.Equals(utf8truetrue));
        DescribeEquivalence(utf8truetrue.Equals(utf8falsetrue));

        DescribeEquivalence(utf8falsetrue.Equals(utf8));
        DescribeEquivalence(utf8falsetrue.Equals(utf8true));
        DescribeEquivalence(utf8falsetrue.Equals(utf8truetrue));
        DescribeEquivalence(utf8falsetrue.Equals(utf8falsetrue));
    }
Beispiel #2
0
        public void PosTest3()
        {
            UTF8Encoding utf8a = new UTF8Encoding();
            UTF8Encoding utf8b = new UTF8Encoding(true);

            Assert.False(utf8a.Equals(utf8b));
        }
Beispiel #3
0
        public void PosTest2()
        {
            UTF8Encoding utf8a = new UTF8Encoding();
            UTF8Encoding utf8b = new UTF8Encoding();

            Assert.True(utf8a.Equals(utf8b));
        }
Beispiel #4
0
    public bool PosTest3()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest3: Verify a instance of UTF8Encoding is not equal to different one");

        try
        {
            UTF8Encoding utf8a = new UTF8Encoding();
            UTF8Encoding utf8b = new UTF8Encoding(true);

            if (utf8a.Equals(utf8b) != false)
            {
                TestLibrary.TestFramework.LogError("003.1", "Method Equals Err.");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
    public bool PosTest2()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify a instance of UTF8Encoding equals to another one");

        try
        {
            UTF8Encoding utf8a = new UTF8Encoding();
            UTF8Encoding utf8b = new UTF8Encoding();

            if (utf8a.Equals(utf8b) != true)
            {
                TestLibrary.TestFramework.LogError("002.1", "Method Equals Err.");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Beispiel #6
0
    public bool PosTest1()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest1: Verify a instance of UTF8Encoding equals to itself");

        try
        {
            UTF8Encoding utf8 = new UTF8Encoding();

            if (utf8.Equals(utf8) != true)
            {
                TestLibrary.TestFramework.LogError("001.1", "Method Equals Err.");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
        private void updateItemEncoding(int index, Encoding encoding)
        {
            ListViewItem lvi = listView_Filelist.Items[index];

            if (encoding != null)
            {
                if (encoding.BodyName == "utf-8")
                {
                    Encoding utf8WithoutBom = new UTF8Encoding(true);

                    UTF8Encoding enc8 = (UTF8Encoding)encoding;
                    if (enc8.Equals(utf8WithoutBom))
                    {
                        lvi.SubItems[3].Text = "utf-8-bom";
                    }
                    else
                    {
                        lvi.SubItems[3].Text = "utf-8";
                    }
                }
                else
                {
                    lvi.SubItems[3].Text = encoding.BodyName;
                }
            }
        }
    public static bool VerifyHash(byte[] hashedPassword1, byte[] hashedPassword2)
    {
        var a = new UTF8Encoding().GetString(hashedPassword1);
        var b = new UTF8Encoding().GetString(hashedPassword2);

        // return hashedPassword1.Equals(hashedPassword2);
        return(a.Equals(b));
    }
Beispiel #9
0
 public void EqualsTest(UTF8Encoding encoding, object value, bool expected)
 {
     Assert.Equal(expected, encoding.Equals(value));
     if (value is UTF8Encoding)
     {
         Assert.Equal(expected, encoding.GetHashCode().Equals(value.GetHashCode()));
     }
 }
Beispiel #10
0
        public void PosTest1()
        {
            UTF8Encoding utf8 = new UTF8Encoding();

            Assert.True(utf8.Equals(utf8));
        }
Beispiel #11
0
 public void PosTest3()
 {
     UTF8Encoding utf8a = new UTF8Encoding();
     UTF8Encoding utf8b = new UTF8Encoding(true);
     Assert.False(utf8a.Equals(utf8b));
 }
Beispiel #12
0
 public void PosTest2()
 {
     UTF8Encoding utf8a = new UTF8Encoding();
     UTF8Encoding utf8b = new UTF8Encoding();
     Assert.True(utf8a.Equals(utf8b));
 }
Beispiel #13
0
 public void PosTest1()
 {
     UTF8Encoding utf8 = new UTF8Encoding();
     Assert.True(utf8.Equals(utf8));
 }
Beispiel #14
0
 public void Equals(UTF8Encoding encoding, object value, bool expected)
 {
     Assert.Equal(expected, encoding.Equals(value));
     if (value is UTF8Encoding)
     {
         Assert.Equal(expected, encoding.GetHashCode().Equals(value.GetHashCode()));
     }
 }