예제 #1
0
        public void GetRandomSafeRoomType_AllPossibleGenerations_NoUnsafeRooms()
        {
            // Figure out how many safe room types there are.
            int safeTypesCount = 0;

            RoomType[] roomTypes = (RoomType[])Enum.GetValues(typeof(RoomType));

            foreach (var type in roomTypes)
            {
                var room = rf.Create(type);
                if (room.BehaviourThreshold == 1)
                {
                    safeTypesCount++;
                }
            }

            // Generate every such room and make sure they all have a threshold of 1.
            bool allSafe = true;

            for (int i = 0; i < safeTypesCount; i++)
            {
                rg = new MockRandomGeneratorConst(intAnswer: i);
                // MockRandomGeneratorConst always gives the constructor argument back with Generate().
                // Using that with a loop index checks all room types deemed safe by GetRandomSafeRoomType.

                IRoom room = rf.Create(mg.GetRandomSafeRoomType(rg));
                if (room.BehaviourThreshold < 1.0)
                {
                    allSafe = false;
                    break;
                }
            }

            Assert.True(allSafe);
        }