Skip to content

Commit

Permalink
Improvded coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ben_singer committed Nov 28, 2024
1 parent 0f0a3b3 commit 176e033
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1 deletion.
22 changes: 22 additions & 0 deletions NetAF.Tests/Assets/Locations/Overworld_Tests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using NetAF.Assets.Locations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NetAF.Assets.Characters;
using NetAF.Assets;

namespace NetAF.Tests.Assets.Locations
{
Expand Down Expand Up @@ -72,5 +74,25 @@ public void GivenRegionIsNotPresent_WhenMoveRegion_ThenReturnFalse()

Assert.IsFalse(result);
}

[TestMethod]
public void GivenNotOverworld_WhenExamine_ThenReturnNonEmptyString()
{
var overworld = new Overworld(string.Empty, "An overworld");

var result = overworld.Examination(new ExaminationRequest(new PlayableCharacter("a", "b"), new ExaminationScene(null, new Room(string.Empty, string.Empty))));

Assert.IsTrue(result.Description.Length > 0);
}

[TestMethod]
public void GivenOverworld_WhenExamine_ThenReturnNonEmptyString()
{
var overworld = new Overworld(string.Empty, "An overworld");

var result = overworld.Examination(new ExaminationRequest(overworld, new ExaminationScene(null, new Room(string.Empty, string.Empty))));

Assert.IsTrue(result.Description.Length > 0);
}
}
}
22 changes: 21 additions & 1 deletion NetAF.Tests/Assets/Locations/Region_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NetAF.Assets.Locations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NetAF.Commands;
using NetAF.Assets.Characters;

namespace NetAF.Tests.Assets.Locations
{
Expand Down Expand Up @@ -491,11 +492,30 @@ public void GivenCurrentRoomNullAndNoStartRoomAssigned_WhenEnter_ThenCurrentRoom
public void GivenCurrentRoomNullAndNoRooms_WhenEnter_ThenCurrentRoomIsNull()
{
var region = new Region(string.Empty, string.Empty);
var room = new Room(string.Empty, string.Empty);

region.Enter();

Assert.IsNull(region.CurrentRoom);
}

[TestMethod]
public void GivenNotRegion_WhenExamine_ThenReturnNonEmptyString()
{
var region = new Region(string.Empty, "A region");

var result = region.Examination(new ExaminationRequest(new PlayableCharacter("a", "b"), new ExaminationScene(null, new Room(string.Empty, string.Empty))));

Assert.IsTrue(result.Description.Length > 0);
}

[TestMethod]
public void GivenRegion_WhenExamine_ThenReturnNonEmptyString()
{
var region = new Region(string.Empty, "A region");

var result = region.Examination(new ExaminationRequest(region, new ExaminationScene(null, new Room(string.Empty, string.Empty))));

Assert.IsTrue(result.Description.Length > 0);
}
}
}
40 changes: 40 additions & 0 deletions NetAF.Tests/Assets/Locations/Room_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,45 @@ public void GivenInvalid_WhenFindInteractionTarget_ThenReturnFalse()

Assert.IsFalse(result);
}

[TestMethod]
public void GivenNotRoom_WhenExamine_ThenReturnNonEmptyString()
{
var room = new Room(string.Empty, "A room");

var result = room.Examination(new ExaminationRequest(new PlayableCharacter("a", "b"), new ExaminationScene(null, room)));

Assert.IsTrue(result.Description.Length > 0);
}

[TestMethod]
public void GivenNoItems_WhenExamine_ThenReturnNonEmptyString()
{
var room = new Room(string.Empty, "A room");

var result = room.Examination(new ExaminationRequest(room, new ExaminationScene(null, room)));

Assert.IsTrue(result.Description.Length > 0);
}

[TestMethod]
public void Given1Item_WhenExamine_ThenReturnNonEmptyString()
{
var room = new Room(string.Empty, "A room", items: [new Item("a", "b")]);

var result = room.Examination(new ExaminationRequest(room, new ExaminationScene(null, room)));

Assert.IsTrue(result.Description.Length > 0);
}

[TestMethod]
public void Given2Items_WhenExamine_ThenReturnNonEmptyString()
{
var room = new Room(string.Empty, "A room", items: [new Item("a", "b"), new Item("c", "d")]);

var result = room.Examination(new ExaminationRequest(room, new ExaminationScene(null, room)));

Assert.IsTrue(result.Description.Length > 0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,15 @@ public void GivenAttributeWhenValueIs3_WhenFromAttribute_ThenValueIs3()

Assert.AreEqual(3, result.Value);
}

[TestMethod]
public void GivenRestore_ThenNoExceptionThrown()
{
Assertions.NoExceptionThrown(() =>
{
AttributeAndValueSerialization value = new();
value.Restore(new System.Collections.Generic.KeyValuePair<Attribute, int>());
});
}
}
}

0 comments on commit 176e033

Please sign in to comment.