示例#1
0
        public void GetRoomForExitReturnsNullForNonExistentRoom_UnLockedDoor()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            roomExits.AddExit(Direction.North, room);
            roomExits.AddExit(Direction.South, room2);

            Assert.AreEqual(null, roomExits.GetRoomForExit(Direction.East));
            Assert.AreEqual(null, roomExits.GetRoomForExit(Direction.West));
        }
示例#2
0
        public void GetRoomForExitReturnsValidRoom_UnLockedDoor()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            roomExits.AddExit(Direction.North, room);
            roomExits.AddExit(Direction.South, room2);

            Assert.AreEqual(room, roomExits.GetRoomForExit(Direction.North));
            Assert.AreEqual(room2, roomExits.GetRoomForExit(Direction.South));
        }
示例#3
0
        public void AddExitThrowsInvalidOperationExceptionIfSameDirectionUsedMoreThanOnce_UnLockedDoor()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            roomExits.AddExit(Direction.North, room);
            roomExits.AddExit(Direction.North, room2);

            roomExits.AddExit(Direction.South, room);
            roomExits.AddExit(Direction.South, room2);
        }
示例#4
0
        public void AddExitThrowsArgumentNullExceptionIfRoomIsNull()
        {
            RoomExits roomExits = new RoomExits();
            DoorWay   doorway   = new DoorWay
            {
                Direction = Direction.North
            };

            roomExits.AddExit(doorway, null);
        }
示例#5
0
        public void GetRoomForExitReturnsValidRoom()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            DoorWay doorway = new DoorWay
            {
                Direction = Direction.North
            };

            DoorWay doorway2 = new DoorWay
            {
                Direction = Direction.South
            };

            roomExits.AddExit(doorway, room);
            roomExits.AddExit(doorway2, room2);

            Assert.AreEqual(room, roomExits.GetRoomForExit(Direction.North));
            Assert.AreEqual(room2, roomExits.GetRoomForExit(Direction.South));
        }
示例#6
0
        public void AddExitThrowsInvalidOperationExceptionIfSameDirectionUsedMoreThanOnce()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            DoorWay doorway = new DoorWay
            {
                Direction = Direction.North
            };

            DoorWay doorway2 = new DoorWay
            {
                Direction = Direction.South
            };

            roomExits.AddExit(doorway, room);
            roomExits.AddExit(doorway, room2);

            roomExits.AddExit(doorway2, room);
            roomExits.AddExit(doorway2, room2);
        }
示例#7
0
        public void AddExitForNorthAddsTheExit_UnLockedDoor()
        {
            var game = new Game();
            var room = new Room("testRoom", "this is a test room.", game);

            var roomExits = new RoomExits();

            roomExits.AddExit(Direction.North, room);

            var savedRoom = roomExits.GetRoomForExit(Direction.North);

            Assert.AreEqual(room, savedRoom);
            Assert.AreSame("testRoom", savedRoom.Name);
            Assert.AreSame("this is a test room.", savedRoom.Description);
        }
示例#8
0
        public void AddExitForNorthAddsTheExit()
        {
            var game = new Game();
            var room = new Room("testRoom", "this is a test room.", game);

            var roomExits = new RoomExits();

            DoorWay doorway = new DoorWay
            {
                Direction = Direction.North
            };

            roomExits.AddExit(doorway, room);

            var savedRoom = roomExits.GetRoomForExit(Direction.North);

            Assert.AreEqual(room, savedRoom);
            Assert.AreSame("testRoom", savedRoom.Name);
            Assert.AreSame("this is a test room.", savedRoom.Description);
        }