public bool PosTest2()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify two struct RuntimeFieldHandle equals.");

        try
        {
            RuntimeFieldHandle rfh1 = new RuntimeFieldHandle();
            RuntimeFieldHandle rfh2 = new RuntimeFieldHandle();

            bool expected = true;
            bool actual = rfh1.Equals(rfh2);

            if (actual != expected)
            {
                TestLibrary.TestFramework.LogError("002.1", "Method Equals Err.");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actual = " + actual + ", expected = " + expected);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
示例#2
0
    public bool PosTest3()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest3: Verify a struct RuntimeFieldHandle is not equals to a object.");

        try
        {
            RuntimeFieldHandle rfh = new RuntimeFieldHandle();
            object             obj = new object();

            bool expected = false;
            bool actual   = rfh.Equals(obj);

            if (actual != expected)
            {
                TestLibrary.TestFramework.LogError("003.1", "Method Equals Err.");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actual = " + actual + ", expected = " + expected);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
示例#3
0
    public bool PosTest2()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify two struct RuntimeFieldHandle equals.");

        try
        {
            RuntimeFieldHandle rfh1 = new RuntimeFieldHandle();
            RuntimeFieldHandle rfh2 = new RuntimeFieldHandle();

            bool expected = true;
            bool actual   = rfh1.Equals(rfh2);

            if (actual != expected)
            {
                TestLibrary.TestFramework.LogError("002.1", "Method Equals Err.");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actual = " + actual + ", expected = " + expected);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
示例#4
0
    public static void  RuntimeFieldHandleTest()
    {
        Type               t = typeof(Derived);
        FieldInfo          f = t.GetField(nameof(Base.MyField));
        RuntimeFieldHandle h = f.FieldHandle;

        Assert.True(h.Value != IntPtr.Zero);

        Assert.Equal(h.GetHashCode(), h.GetHashCode());
        Assert.Equal(default(RuntimeFieldHandle).GetHashCode(), default(RuntimeFieldHandle).GetHashCode());

        Assert.True(h.Equals(h));
        Assert.False(h.Equals(default(RuntimeFieldHandle)));
        Assert.False(default(RuntimeFieldHandle).Equals(h));
        Assert.True(default(RuntimeFieldHandle).Equals(default(RuntimeFieldHandle)));

        Assert.True(h.Equals((object)h));
        Assert.True(((IEquatable <RuntimeFieldHandle>)h).Equals(h));
        Assert.False(h.Equals(new object()));
        Assert.False(h.Equals(null));

        Assert.False(h == default(RuntimeFieldHandle));
        Assert.True(h != default(RuntimeFieldHandle));

        IntPtr             hPtr = RuntimeFieldHandle.ToIntPtr(h);
        RuntimeFieldHandle hNew = RuntimeFieldHandle.FromIntPtr(hPtr);

        Assert.True(h.Equals(hNew));
        Assert.True(hNew.Equals(h));
    }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static bool operator !=(AccelFieldInfo left, AccelFieldInfo right)
        {
            RuntimeFieldHandle h1 = left is null ? default : left.FieldHandle;

                                    RuntimeFieldHandle h2 = right is null ? default : right.FieldHandle;

                                                            return(!h1.Equals(h2));
        }
    public bool PosTest3()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest3: Verify a struct RuntimeFieldHandle is not equals to a object.");

        try
        {
            RuntimeFieldHandle rfh = new RuntimeFieldHandle();
            object obj = new object();

            bool expected = false;
            bool actual = rfh.Equals(obj);

            if (actual != expected)
            {
                TestLibrary.TestFramework.LogError("003.1", "Method Equals Err.");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actual = " + actual + ", expected = " + expected);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }