当前位置: 首页>>代码示例>>C#>>正文


C# TestObj.GetHashCode方法代码示例

本文整理汇总了C#中TestObj.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# TestObj.GetHashCode方法的具体用法?C# TestObj.GetHashCode怎么用?C# TestObj.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestObj的用法示例。


在下文中一共展示了TestObj.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateEWR

 private static bool ValidateEWR(bool NewData)
 {
     bool success = true;
     for (uint i = 1; i < 10; i++)
     {
         ewrs[i] = ExtendedWeakReference.Recover(typeof(TestObj), i);
         if (ewrs[i] == null)
         {
             success = false;
             Log.Exception("Unable to recover object #" + i + " after reboot " + runTracker.RebootCount);
             ewrs[i] = ExtendedWeakReference.RecoverOrCreate(typeof(TestObj), i,
                 ExtendedWeakReference.c_SurviveBoot |
                 ExtendedWeakReference.c_SurvivePowerdown);
         }
         TestObj obj = (TestObj)ewrs[i].Target;
         if (obj == null)
         {
             success = false;
             Log.Exception("Recovered object #" + i + " null after reboot " + runTracker.RebootCount);
         }
         if (runTracker.objHashes[i] != obj.GetHashCode())
         {
             success = false;
             Log.Exception("Recovered object #" + i + " hash value does not match stored hash value");
         }
         Log.Comment("Verified object #" + i);
         if (NewData)
         {
             Log.Comment("Creating new object and setting back to ewr");
             obj = new TestObj();
             ewrs[i].Target = obj;
             runTracker.objHashes[i] = obj.GetHashCode();
         }
         else
         {
             Log.Comment("Pushing object back into list");
             ewrs[i].PushBackIntoRecoverList();
         }
     }
     return success;
 }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:41,代码来源:Master.cs

示例2: Main

        public static void Main()
        {
            // This test suite does not use the Test Runner infrastructure as it requires a 
            // reboot of the physical device to verify the references have been saved.  It relies
            // on the test harness to time it out if it fails to complete because of issues with
            // EWR persistence.

            // Skip test on Emulator
            if (Microsoft.SPOT.Hardware.SystemInfo.SystemID.SKU == 3)
            {
                StartTestLog("Emulator, skipping...");
                EndTestLog(0, 0, 1);
            }

            else
            {
                ewrs[0] = ExtendedWeakReference.Recover(typeof(TestRunTracker), 0);
                if (ewrs[0] == null)
                {
                    ewrs[0] = ExtendedWeakReference.RecoverOrCreate(
                      typeof(TestRunTracker),
                      0,
                      ExtendedWeakReference.c_SurviveBoot | ExtendedWeakReference.c_SurvivePowerdown);
                    runTracker = new TestRunTracker() { RebootCount = -1, TestState = TestRunTracker.State.Initialize };
                }
                else
                {
                    runTracker = (TestRunTracker)ewrs[0].Target;
                }

                Log.Comment("State: " + runTracker.TestState + ", Reboot Count: " + runTracker.RebootCount);

                switch (runTracker.TestState)
                {
                    // Initial state
                    case TestRunTracker.State.Initialize:
                        if (runTracker.RebootCount == -1)
                            StartTestLog("No EWR found, initializing for first run...");
                        else
                            StartTestLog("Previous EWR found.  Re-initializing...");

                        runTracker.TestState = TestRunTracker.State.HardReboot;
                        runTracker.RebootCount = 0;
                        runTracker.TestState = TestRunTracker.State.HardReboot;
                        for (uint i = 1; i < 10; i++)
                        {
                            ewrs[i] = ExtendedWeakReference.RecoverOrCreate(typeof(TestObj), i,
                                ExtendedWeakReference.c_SurvivePowerdown |
                                ExtendedWeakReference.c_SurviveBoot);
                            TestObj obj = new TestObj();
                            ewrs[i].Target = obj;
                            runTracker.objHashes[i] = obj.GetHashCode();
                        }
                        break;

                    // HardReboot cases - Reboots 1 - 3
                    case TestRunTracker.State.HardReboot:
                        Debug.Print("<TestMethod name=\"HardReboot" + runTracker.RebootCount + "\">");

                        // Validate objects
                        if (ValidateEWR(true))
                        {
                            Debug.Print("    <TestMethodResult Result=\"Pass\">");
                            runTracker.PassCount++;
                        }
                        else
                        {
                            Debug.Print("    <TestMethodResult Result=\"Fail\">");
                            runTracker.FailCount++;
                        }
                        Debug.Print("        <Text><![CDATA[TEST: HardReboot" + runTracker.RebootCount + "]]></Text>" + TimeStamp());
                        Debug.Print("    </TestMethodResult>");
                        Debug.Print("</TestMethod>");

                        // End test
                        if (runTracker.RebootCount >= 3)
                            runTracker.TestState = TestRunTracker.State.SoftReboot;

                        break;

                    // SoftReboot cases - Reboots 4 - 6
                    case TestRunTracker.State.SoftReboot:
                        Debug.Print("<TestMethod name=\"SoftReboot" + runTracker.RebootCount + "\">");

                        // Validate objects
                        if (ValidateEWR(true))
                        {
                            Debug.Print("    <TestMethodResult Result=\"Pass\">");
                            runTracker.PassCount++;
                        }
                        else
                        {
                            Debug.Print("    <TestMethodResult Result=\"Fail\">");
                            runTracker.FailCount++;
                        }
                        Debug.Print("        <Text><![CDATA[TEST: SoftReboot" + runTracker.RebootCount + "]]></Text>" + TimeStamp());
                        Debug.Print("    </TestMethodResult>");
                        Debug.Print("</TestMethod>");

                        // End test
//.........这里部分代码省略.........
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:101,代码来源:Master.cs


注:本文中的TestObj.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。