Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 4
0
        public void AddExitThrowsArgumentNullExceptionIfRoomIsNull()
        {
            RoomExits roomExits = new RoomExits();
            DoorWay   doorway   = new DoorWay
            {
                Direction = Direction.North
            };

            roomExits.AddExit(doorway, null);
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }