Skip to content

Commit

Permalink
test: Add tests when argument is null
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDave1999 committed Aug 28, 2024
1 parent 3666390 commit 8b611e6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Application.Tests/Maps/CurrentMapTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ public void Constructor_WhenBetaTeamLocationsIsNull_ShouldThrowArgumentNullExcep
.WithParameterName(nameof(betaTeamLocations));
}

[Test]
public void Constructor_WhenFlagLocationsIsNull_ShouldThrowArgumentNullException()
{
// Arrange
IMap map = MapCollection.GetById(0).Value;
List<SpawnLocation> betaTeamLocations = [SpawnLocation.Empty];
List<SpawnLocation> alphaTeamLocations = [SpawnLocation.Empty];
FlagLocations flagLocations = default;

// Act
Action act = () =>
{
var currentMap = new CurrentMap(map, alphaTeamLocations, betaTeamLocations, flagLocations);
};

// Assert
act.Should()
.Throw<ArgumentNullException>()
.WithParameterName(nameof(flagLocations));
}

[Test]
public void Constructor_WhenAlphaTeamLocationsIsEmpty_ShouldThrowArgumentException()
{
Expand Down
16 changes: 16 additions & 0 deletions tests/Application.Tests/Maps/MapInfoServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ public void Constructor_WhenLoadMethodIsNotInvoked_CurrentMapShouldNotBeNull()
currentMap.Should().NotBeNull();
}

[Test]
public void Load_WhenArgumentIsNull_ShouldThrowArgumentNullException()
{
// Arrange
var service = new MapInfoService();
IMap map = default;

// Act
Action act = () => service.Load(map);

// Assert
act.Should()
.Throw<ArgumentNullException>()
.WithParameterName(nameof(map));
}

[TestCaseSource(typeof(MapInfoServiceTestCases))]
public void Load_WhenMapIsLoadedFromFileSystem_ShouldCreateInstanceOfTypeCurrentMap(CurrentMap expectedCurrentMap)
{
Expand Down

0 comments on commit 8b611e6

Please sign in to comment.