public void SetHallToNull() { // set existing hall to null string[] inGrid = { "0.0.0.0", ". . . .", "0.0#0.0", ". . . .", "0.0.0.0", }; string[] outGrid = { "0.0.0.0", ". . . .", "0.0.0.0", ". . . .", "0.0.0.0", }; TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid); floorPlan.SetHall(new LocRay4(1, 1, Dir4.Right), null); TestGridFloorPlan compareFloorPlan = TestGridFloorPlan.InitGridToContext(outGrid); TestGridFloorPlan.CompareFloorPlans(floorPlan, compareFloorPlan); }
public void SetHallInDirs(Dir4 dir, int expectedOut) { // valid/invalid dir string[] inGrid = { "0.0.0.0", ". . . .", "0.0.0.0", ". . . .", "0.0.0.0", }; string[] outGrid = null; bool exception = false; switch (expectedOut) { case 0: outGrid = new string[] { "0.0.0.0", ". . . .", "0.0.0.0", ". # . .", "0.0.0.0", }; break; case 1: outGrid = new string[] { "0.0.0.0", ". . . .", "0#0.0.0", ". . . .", "0.0.0.0", }; break; case 2: outGrid = new string[] { "0.0.0.0", ". # . .", "0.0.0.0", ". . . .", "0.0.0.0", }; break; case 3: outGrid = new string[] { "0.0.0.0", ". . . .", "0.0#0.0", ". . . .", "0.0.0.0", }; break; default: exception = true; break; } TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid); var gen = new TestGridRoomGen((char)0); if (exception) { if (dir == Dir4.None) { Assert.Throws <ArgumentException>(() => { floorPlan.SetHall(new LocRay4(1, 1, dir), gen); }); } else { Assert.Throws <ArgumentOutOfRangeException>(() => { floorPlan.SetHall(new LocRay4(1, 1, dir), gen); }); } return; } else { floorPlan.SetHall(new LocRay4(1, 1, dir), gen); } TestGridFloorPlan compareFloorPlan = TestGridFloorPlan.InitGridToContext(outGrid); TestGridFloorPlan.CompareFloorPlans(floorPlan, compareFloorPlan); // set existing hall to null }