summaryrefslogtreecommitdiff
path: root/tests/src/CoreMangLib/cti/system/timespan/timespanticks.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/CoreMangLib/cti/system/timespan/timespanticks.cs')
-rw-r--r--tests/src/CoreMangLib/cti/system/timespan/timespanticks.cs74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/src/CoreMangLib/cti/system/timespan/timespanticks.cs b/tests/src/CoreMangLib/cti/system/timespan/timespanticks.cs
new file mode 100644
index 0000000000..cd871bbf92
--- /dev/null
+++ b/tests/src/CoreMangLib/cti/system/timespan/timespanticks.cs
@@ -0,0 +1,74 @@
+// 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;
+
+/// <summary>
+/// Ticks
+/// </summary>
+public class TimeSpanTicks
+{
+ #region Public Methods
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ #region Positive Test Cases
+ public bool PosTest1()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Call Ticks to get the correct ticks 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", "Ticks returns wrong value");
+ TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] ts = " + ts + ", expected = " + expected + ", actual = " + actual);
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+ #endregion
+ #endregion
+
+ public static int Main()
+ {
+ TimeSpanTicks test = new TimeSpanTicks();
+
+ TestLibrary.TestFramework.BeginTestCase("TimeSpanTicks");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+}