|
|
@ -9,33 +9,74 @@ namespace Tests.Model_UTs
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestCreateWithSpecifiedTimeNotUTCThenValid()
|
|
|
|
public void TestCreateWithSpecifiedTimeNotUTCThenValid()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
DateTime dateTime = new(year: 2018, month: 06, day: 15, hour: 16, minute: 30, second: 0, kind: DateTimeKind.Local);
|
|
|
|
|
|
|
|
Player player = new("Alice");
|
|
|
|
|
|
|
|
Assert.NotEqual(DateTimeKind.Utc, dateTime.Kind);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
|
|
Turn turn = Turn.CreateWithSpecifiedTime(dateTime, player);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.Equal(DateTimeKind.Utc, turn.when.Kind);
|
|
|
|
|
|
|
|
Assert.Equal(dateTime.ToUniversalTime(), turn.when);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestCreateWithSpecifiedTimeUTCThenValid()
|
|
|
|
public void TestCreateWithSpecifiedTimeUTCThenValid()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
DateTime dateTime = new(year: 2018, month: 06, day: 15, hour: 16, minute: 30, second: 0, kind: DateTimeKind.Utc);
|
|
|
|
|
|
|
|
Player player = new("Bobby");
|
|
|
|
|
|
|
|
Assert.Equal(DateTimeKind.Utc, dateTime.Kind);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
|
|
Turn turn = Turn.CreateWithSpecifiedTime(dateTime, player);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.Equal(DateTimeKind.Utc, turn.when.Kind);
|
|
|
|
|
|
|
|
Assert.Equal(dateTime.ToUniversalTime(), turn.when);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestCreateWithSpecifiedTimeNullPlayerThenException()
|
|
|
|
public void TestCreateWithSpecifiedTimeNullPlayerThenException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
DateTime dateTime = new(year: 2018, month: 06, day: 15, hour: 16, minute: 30, second: 0, kind: DateTimeKind.Utc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
|
|
void action() => Turn.CreateWithSpecifiedTime(dateTime, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.Throws<ArgumentNullException>(action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestCreateWithDefaultTimeThenValid()
|
|
|
|
public void TestCreateWithDefaultTimeThenValid()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// check that the date (not the time part) is the same as today
|
|
|
|
// Arrange
|
|
|
|
// ... would fail tests at 11:59:59pm -- acceptable (?)
|
|
|
|
Player player = new("Chloe");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
|
|
Turn turn = Turn.CreateWithDefaultTime(player);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.Equal(DateTimeKind.Utc, turn.when.Kind);
|
|
|
|
|
|
|
|
Assert.Equal(DateTime.Now.ToUniversalTime().Date, turn.when.Date);
|
|
|
|
|
|
|
|
/*** N.B.: might fail between 11:59:59PM and 00:00:00AM ***/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestCreateWithDefaultTimeNullPlayerThenException()
|
|
|
|
public void TestCreateWithDefaultTimeNullPlayerThenException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
Player player = new("Devon");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
|
|
static void action() => Turn.CreateWithDefaultTime(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.Throws<ArgumentNullException>(action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|