using System.Linq; using NUnit.Framework; using STVrogue.GameLogic; using static STVrogue.Utils.HelperPredicates; namespace NUnitTests { [TestFixture] // An example of a test that is is mostly generated by CoPilot. It helps, // but you have to put critical eyes on the suggestions. It is also not // perfect so you have to fix some things manually. // Still, it can be help in producing starting code. public class Test_Dungeon { // This a parameterized test for the constructor of the Dungeon class, in particular for // the linear shaped dungeon. The test is parameterized over the number of rooms N and // the maximum capacity of the rooms. [TestCase(1,1)] [TestCase(1,2)] [TestCase(1,3)] [TestCase(2,1)] [TestCase(2,2)] [TestCase(2,3)] [TestCase(3,1)] [TestCase(3,2)] [TestCase(3,3)] [TestCase(2,0)] [TestCase(0,1)] [TestCase(0,0)] public void test_LinearDungeon(int N, int capacity) { Dungeon D = new Dungeon(DungeonShapeType.LINEARshape,N,capacity); // we have N rooms: Assert.IsTrue(D.Rooms.Count == N); // each room has a unique ID: Assert.IsTrue(Forall(D.Rooms, r => D.Rooms.Count(r2 => r2.Id == r.Id) == 1)); // each room has a capacity between 0 and capacity: Assert.That(Forall(D.Rooms, r => r.Capacity >= 0 && r.Capacity <= capacity)); // there is a unique startroom: Assert.IsTrue(D.StartRoom != null); Assert.IsTrue(D.Rooms.Count(r => r == D.StartRoom) == 1); // there is a unique exitroom: Assert.IsTrue(D.ExitRoom != null); Assert.IsTrue(D.Rooms.Count(r => r == D.ExitRoom) == 1); // all rooms are reachable from the startroom: Forall(D.Rooms, r => D.StartRoom.ReachableRooms().Contains(r)); } } }