2023-04-05 22:26:31 +01:00
|
|
|
using NUnit.Framework;
|
2022-04-21 21:37:20 +01:00
|
|
|
using X10D.Time;
|
|
|
|
|
|
|
|
namespace X10D.Tests.Time;
|
|
|
|
|
2023-04-05 22:26:31 +01:00
|
|
|
[TestFixture]
|
2023-08-22 17:32:47 +01:00
|
|
|
internal class DoubleTests
|
2022-04-21 21:37:20 +01:00
|
|
|
{
|
|
|
|
private Half _negativeOne;
|
|
|
|
private Half _one;
|
|
|
|
private Half _zero;
|
|
|
|
|
2023-04-05 22:26:31 +01:00
|
|
|
[SetUp]
|
2022-04-21 21:37:20 +01:00
|
|
|
public void Initialize()
|
|
|
|
{
|
|
|
|
_negativeOne = (Half)(-1);
|
|
|
|
_one = (Half)1;
|
|
|
|
_zero = (Half)0;
|
|
|
|
}
|
|
|
|
|
2023-04-05 22:26:31 +01:00
|
|
|
[Test]
|
2022-04-25 17:09:49 +01:00
|
|
|
public void TicksMillisecondsSecondsMinutesDaysHoursWeeks_ShouldBeZero_GivenZero()
|
2022-04-21 21:37:20 +01:00
|
|
|
{
|
2023-04-05 22:26:31 +01:00
|
|
|
Assert.That(_zero.Milliseconds(), Is.EqualTo(TimeSpan.Zero));
|
|
|
|
Assert.That(_zero.Seconds(), Is.EqualTo(TimeSpan.Zero));
|
|
|
|
Assert.That(_zero.Minutes(), Is.EqualTo(TimeSpan.Zero));
|
|
|
|
Assert.That(_zero.Days(), Is.EqualTo(TimeSpan.Zero));
|
|
|
|
Assert.That(_zero.Hours(), Is.EqualTo(TimeSpan.Zero));
|
|
|
|
Assert.That(_zero.Weeks(), Is.EqualTo(TimeSpan.Zero));
|
2022-04-21 21:37:20 +01:00
|
|
|
}
|
|
|
|
|
2023-04-05 22:26:31 +01:00
|
|
|
[Test]
|
2022-04-25 17:09:49 +01:00
|
|
|
public void TicksMillisecondsSecondsMinutesDaysHoursWeeks_ShouldBePositive_GivenOne()
|
2022-04-21 21:37:20 +01:00
|
|
|
{
|
2023-04-05 22:26:31 +01:00
|
|
|
Assert.That(_one.Milliseconds() > TimeSpan.Zero);
|
|
|
|
Assert.That(_one.Seconds() > TimeSpan.Zero);
|
|
|
|
Assert.That(_one.Minutes() > TimeSpan.Zero);
|
|
|
|
Assert.That(_one.Days() > TimeSpan.Zero);
|
|
|
|
Assert.That(_one.Hours() > TimeSpan.Zero);
|
|
|
|
Assert.That(_one.Weeks() > TimeSpan.Zero);
|
2022-04-21 21:37:20 +01:00
|
|
|
}
|
|
|
|
|
2023-04-05 22:26:31 +01:00
|
|
|
[Test]
|
2022-04-25 17:09:49 +01:00
|
|
|
public void TicksMillisecondsSecondsMinutesDaysHoursWeeks_ShouldBeNegative_GivenMinusOne()
|
2022-04-21 21:37:20 +01:00
|
|
|
{
|
2023-04-05 22:26:31 +01:00
|
|
|
Assert.That((_negativeOne).Milliseconds() < TimeSpan.Zero);
|
|
|
|
Assert.That((_negativeOne).Seconds() < TimeSpan.Zero);
|
|
|
|
Assert.That((_negativeOne).Minutes() < TimeSpan.Zero);
|
|
|
|
Assert.That((_negativeOne).Days() < TimeSpan.Zero);
|
|
|
|
Assert.That((_negativeOne).Hours() < TimeSpan.Zero);
|
|
|
|
Assert.That((_negativeOne).Weeks() < TimeSpan.Zero);
|
2022-04-21 21:37:20 +01:00
|
|
|
}
|
|
|
|
}
|