// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Reflection.Emit; /// /// PackingSize.Size1(v-yaduoj) /// public class PackingSizeTest { private enum MyPackingSize { Unspecified = 0, Size1 = 1, Size2 = 2, Size4 = 4, Size8 = 8, Size16 = 16, Size32 = 32, Size64 = 64, Size128 = 128, } public static int Main() { PackingSizeTest testObj = new PackingSizeTest(); TestLibrary.TestFramework.BeginTestCase("for Enumeration: PackingSize.Size1"); if (testObj.RunTests()) { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("PASS"); return 100; } else { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("FAIL"); return 0; } } public bool RunTests() { bool retVal = true; TestLibrary.TestFramework.LogInformation("[Positive]"); retVal = PosTest1() && retVal; return retVal; } #region Positive tests public bool PosTest1() { bool retVal = true; const string c_TEST_ID = "P001"; const string c_TEST_DESC = "PosTest1: PackingSize is Size1"; string errorDesc; int expectedValue; int actualValue; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { expectedValue = (int)MyPackingSize.Size1; actualValue = (int)PackingSize.Size1; if (actualValue != expectedValue) { errorDesc = "Size1 value of PackingSize is not the value " + expectedValue + "as expected: actual(" + actualValue + ")"; TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return retVal; } #endregion }