Implement UTs on Turn class
continuous-integration/drone/push Build is passing Details

pull/53/head
Alexis Drai 2 years ago
parent d734fd9215
commit 85e16cf590

@ -9,33 +9,74 @@ namespace Tests.Model_UTs
[Fact]
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]
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]
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]
public void TestCreateWithDefaultTimeThenValid()
{
// check that the date (not the time part) is the same as today
// ... would fail tests at 11:59:59pm -- acceptable (?)
// Arrange
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]
public void TestCreateWithDefaultTimeNullPlayerThenException()
{
// Arrange
Player player = new("Devon");
// Act
static void action() => Turn.CreateWithDefaultTime(null);
// Assert
Assert.Throws<ArgumentNullException>(action);
}
[Fact]

Loading…
Cancel
Save