mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 19:28:48 +00:00
test: use fixed point of reference for Age tests
This commit is contained in:
parent
3734965757
commit
708207305c
@ -1,4 +1,4 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using X10D.Time;
|
||||
|
||||
namespace X10D.Tests.Time;
|
||||
@ -7,12 +7,36 @@ namespace X10D.Tests.Time;
|
||||
public class DateTimeOffsetTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void Age_ShouldBeDifference_Given1Jan2000()
|
||||
public void Age_ShouldBe17_Given31December1991Birthday_And30December2017Date()
|
||||
{
|
||||
DateTimeOffset birthday = new DateTime(2000, 1, 1);
|
||||
DateTimeOffset today = DateTime.Now.Date;
|
||||
var reference = new DateTime(2017, 12, 30);
|
||||
DateTimeOffset birthday = new DateTime(1999, 12, 31);
|
||||
|
||||
Assert.AreEqual(today.Year - birthday.Year, birthday.Age());
|
||||
int age = birthday.Age(reference);
|
||||
|
||||
Assert.AreEqual(17, age);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Age_ShouldBe18_Given31December1991Birthday_And1January2018Date()
|
||||
{
|
||||
var reference = new DateTime(2018, 1, 1);
|
||||
DateTimeOffset birthday = new DateTime(1999, 12, 31);
|
||||
|
||||
int age = birthday.Age(reference);
|
||||
|
||||
Assert.AreEqual(18, age);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Age_ShouldBe18_Given31December1991Birthday_And31December2017Date()
|
||||
{
|
||||
var reference = new DateTime(2017, 12, 31);
|
||||
DateTimeOffset birthday = new DateTime(1999, 12, 31);
|
||||
|
||||
int age = birthday.Age(reference);
|
||||
|
||||
Assert.AreEqual(18, age);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using X10D.Time;
|
||||
|
||||
namespace X10D.Tests.Time;
|
||||
@ -7,12 +7,36 @@ namespace X10D.Tests.Time;
|
||||
public class DateTimeTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void Age_ShouldBeDifference_Given1Jan2000()
|
||||
public void Age_ShouldBe17_Given31December1991Birthday_And30December2017Date()
|
||||
{
|
||||
var birthday = new DateTime(2000, 1, 1);
|
||||
DateTime today = DateTime.Now.Date;
|
||||
var reference = new DateTime(2017, 12, 30);
|
||||
var birthday = new DateTime(1999, 12, 31);
|
||||
|
||||
Assert.AreEqual(today.Year - birthday.Year, birthday.Age());
|
||||
int age = birthday.Age(reference);
|
||||
|
||||
Assert.AreEqual(17, age);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Age_ShouldBe18_Given31December1991Birthday_And1January2018Date()
|
||||
{
|
||||
var reference = new DateTime(2018, 1, 1);
|
||||
var birthday = new DateTime(1999, 12, 31);
|
||||
|
||||
int age = birthday.Age(reference);
|
||||
|
||||
Assert.AreEqual(18, age);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Age_ShouldBe18_Given31December1991Birthday_And31December2017Date()
|
||||
{
|
||||
var reference = new DateTime(2017, 12, 31);
|
||||
var birthday = new DateTime(1999, 12, 31);
|
||||
|
||||
int age = birthday.Age(reference);
|
||||
|
||||
Assert.AreEqual(18, age);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
Loading…
Reference in New Issue
Block a user