2022-04-21 21:37:20 +01:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using X10D.Time;
|
|
|
|
|
|
|
|
|
|
namespace X10D.Tests.Time;
|
|
|
|
|
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class Int32Tests
|
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
2022-04-25 17:09:49 +01:00
|
|
|
|
public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero()
|
2022-04-21 21:37:20 +01:00
|
|
|
|
{
|
2022-04-25 17:09:49 +01:00
|
|
|
|
Assert.AreEqual(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), 0.FromUnixTimeMilliseconds());
|
2022-04-21 21:37:20 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2022-04-25 17:09:49 +01:00
|
|
|
|
public void FromUnixTimeSeconds_ShouldBeEpoch_GivenZero()
|
2022-04-21 21:37:20 +01:00
|
|
|
|
{
|
2022-04-25 17:09:49 +01:00
|
|
|
|
Assert.AreEqual(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), 0.FromUnixTimeSeconds());
|
2022-04-21 21:37:20 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2022-04-25 17:09:49 +01:00
|
|
|
|
public void TicksMillisecondsSecondsMinutesDaysHoursWeeks_ShouldBeNegative_GivenMinusOne()
|
2022-04-21 21:37:20 +01:00
|
|
|
|
{
|
|
|
|
|
Assert.IsTrue((-1).Ticks() < TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue((-1).Milliseconds() < TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue((-1).Seconds() < TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue((-1).Minutes() < TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue((-1).Days() < TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue((-1).Hours() < TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue((-1).Weeks() < TimeSpan.Zero);
|
|
|
|
|
}
|
2022-04-25 17:09:49 +01:00
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void TicksMillisecondsSecondsMinutesDaysHoursWeeks_ShouldBePositive_GivenOne()
|
|
|
|
|
{
|
|
|
|
|
Assert.IsTrue(1.Ticks() > TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue(1.Milliseconds() > TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue(1.Seconds() > TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue(1.Minutes() > TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue(1.Days() > TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue(1.Hours() > TimeSpan.Zero);
|
|
|
|
|
Assert.IsTrue(1.Weeks() > TimeSpan.Zero);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void TicksMillisecondsSecondsMinutesDaysHoursWeeks_ShouldBeZero_GivenZero()
|
|
|
|
|
{
|
|
|
|
|
Assert.AreEqual(TimeSpan.Zero, 0.Ticks());
|
|
|
|
|
Assert.AreEqual(TimeSpan.Zero, 0.Milliseconds());
|
|
|
|
|
Assert.AreEqual(TimeSpan.Zero, 0.Seconds());
|
|
|
|
|
Assert.AreEqual(TimeSpan.Zero, 0.Minutes());
|
|
|
|
|
Assert.AreEqual(TimeSpan.Zero, 0.Days());
|
|
|
|
|
Assert.AreEqual(TimeSpan.Zero, 0.Hours());
|
|
|
|
|
Assert.AreEqual(TimeSpan.Zero, 0.Weeks());
|
|
|
|
|
}
|
2022-04-21 21:37:20 +01:00
|
|
|
|
}
|