public void Test_equalsLjava_lang_Object()
 {
     Junit.Framework.Assert.AssertTrue("Equal objects returned false", dfs.Equals(dfs.Clone()));
     dfs.SetDigit('B');
     Junit.Framework.Assert.AssertTrue("Un-Equal objects returned true", !dfs
                                       .Equals(new NumberFormatInfo()));
 }
    public bool PosTest1()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest1: Verify method Clone .");

        try
        {
            NumberFormatInfo nfi1 = new NumberFormatInfo();
            NumberFormatInfo nfi2 = (NumberFormatInfo)nfi1.Clone();

            if (!nfi1.Equals(nfi2) && nfi1.GetHashCode() == nfi2.GetHashCode())
            {
                TestLibrary.TestFramework.LogError("001.1", "Method Clone Err .");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

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

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest1: Verify method Clone .");

        try
        {
            NumberFormatInfo nfi1 = new NumberFormatInfo();
            NumberFormatInfo nfi2 = (NumberFormatInfo)nfi1.Clone();

            if (!nfi1.Equals(nfi2) && nfi1.GetHashCode() == nfi2.GetHashCode())
            {
                TestLibrary.TestFramework.LogError("001.1", "Method Clone Err .");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Exemple #4
0
    public static void Main()
    {
        NumberFormatInfo nfi1 = NumberFormatInfo.CurrentInfo;
        NumberFormatInfo nfi2 = CultureInfo.CurrentCulture.NumberFormat;

        Console.WriteLine("Objects equal: {0}", nfi1.Equals(nfi2));
        Console.WriteLine("Equal references: {0}\n", Object.ReferenceEquals(nfi1, nfi2));

        PropertyInfo[] props = nfi1.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
        Array.Sort(props, new Example());
        Console.WriteLine("Properties of NumberFormat.CurrentInfo object:");
        foreach (var prop in props)
        {
            if (prop.PropertyType.IsArray)
            {
                Array arr = prop.GetValue(nfi1) as Array;
                Console.Write(String.Format("   {0}: ", prop.Name) + "{ ");
                int ctr = 0;
                foreach (var item in arr)
                {
                    Console.Write("{0}{1}", item, ctr == arr.Length - 1 ?" }" : ", ");
                    ctr++;
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("   {0}: {1}", prop.Name, prop.GetValue(nfi1));
            }
        }
    }