// 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; /// /// ctor(System.Int64) /// public class TimeSpanCtor4 { #region Public Methods public bool RunTests() { bool retVal = true; TestLibrary.TestFramework.LogInformation("[Positive]"); retVal = PosTest1() && retVal; retVal = PosTest2() && retVal; retVal = PosTest3() && retVal; return retVal; } #region Positive Test Cases public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Call ctor with rand long value"); try { long expected = TestLibrary.Generator.GetInt64(-55); TimeSpan ts = new TimeSpan(expected); long actual = ts.Ticks; if (actual != expected) { TestLibrary.TestFramework.LogError("001.1", "Calling ctor with rand long value construct a wrong instance"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actual = " + actual + ", expected = " + expected); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; } public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: Call ctor with MaxValue"); try { long expected = Int64.MaxValue; TimeSpan ts = new TimeSpan(expected); long actual = ts.Ticks; if (actual != expected) { TestLibrary.TestFramework.LogError("002.1", "Calling ctor with rand long value construct a wrong instance"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actual = " + actual + ", expected = " + expected); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; } public bool PosTest3() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest3: Call ctor with MinValue"); try { long expected = Int64.MinValue; TimeSpan ts = new TimeSpan(expected); long actual = ts.Ticks; if (actual != expected) { TestLibrary.TestFramework.LogError("003.1", "Calling ctor with rand long value construct a wrong instance"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actual = " + actual + ", expected = " + expected); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; } #endregion #endregion public static int Main() { TimeSpanCtor4 test = new TimeSpanCtor4(); TestLibrary.TestFramework.BeginTestCase("TimeSpanCtor4"); if (test.RunTests()) { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("PASS"); return 100; } else { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("FAIL"); return 0; } } }