public void it_should_set_up_dislikes_and_likes_for_characters()
        {
            RandomNumberGenerator      randomNumberGenerator      = new SystemRandomNumberGenerator();
            TagFactory                 tagFactory                 = new TagFactory(randomNumberGenerator);
            ItemFactory                itemFactory                = new ItemFactory(tagFactory);
            CharacterNameGenerator     characterNameGenerator     = new CharacterNameGenerator(randomNumberGenerator);
            CharacterSafeCodeGenerator characterSafeCodeGenerator = new CharacterSafeCodeGenerator(randomNumberGenerator);

            for (int i = 1; i < 51; i++)
            {
                itemFactory.CreateItem("item" + i, "", "", "", new List <String> {
                    "item" + i + "tag1", "commonTag1", "commonTag2"
                });
            }

            CharacterFactory characterFactory = new CharacterFactory(randomNumberGenerator, itemFactory, tagFactory, characterNameGenerator, characterSafeCodeGenerator);
            List <Character> characters       = characterFactory.GenerateCharactersForGame(5);

            Assert.AreEqual(5, characters.Count);
            Assert.AreEqual(5, characters[0].LikeTags.Count);

            Console.WriteLine("Characters:\n");
            foreach (Character character in characters)
            {
                Console.WriteLine(character);
            }
        }
示例#2
0
        public void it_should_create_a_tag_by_name()
        {
            RandomNumberGenerator randomNumberGenerator = new SystemRandomNumberGenerator();
            TagFactory            tagFactory            = new TagFactory(randomNumberGenerator);
            Tag tag = tagFactory.GetTagByName("Test Tag");

            Assert.AreEqual(new Tag("Test Tag"), tag);
        }
示例#3
0
        public void it_should_be_able_to_generate_a_room_of_items()
        {
            for (int k = 0; k < 1000; k++)
            {
                RandomNumberGenerator randomNumberGenerator = new SystemRandomNumberGenerator();

                TagFactory tagFactory = new TagFactory(randomNumberGenerator);

                ItemFactory itemFactory = new ItemFactory(tagFactory);

                CharacterNameGenerator     characterNameGenerator     = new CharacterNameGenerator(randomNumberGenerator);
                CharacterSafeCodeGenerator characterSafeCodeGenerator = new CharacterSafeCodeGenerator(randomNumberGenerator);

                for (int i = 1; i < 51; i++)
                {
                    itemFactory.CreateItem("item" + i, "", "", "", new List <String> {
                        "item" + i + "tag1", "common"
                    });
                }

                CharacterFactory characterFactory = new CharacterFactory(
                    randomNumberGenerator,
                    itemFactory,
                    tagFactory,
                    characterNameGenerator,
                    characterSafeCodeGenerator
                    );

                List <Character> characters = characterFactory.GenerateCharactersForGame(5);

                RoomFactory roomFactory = new RoomFactory(
                    characterFactory,
                    itemFactory,
                    randomNumberGenerator
                    );

                Room room = roomFactory.GenerateRoomForCharacter(characters[1]);
                //Assert.AreEqual(10, room.Items.Count);

                foreach (Tag tag in characters[1].DislikeTags)
                {
                    foreach (Item item in room.Items)
                    {
                        Console.WriteLine(tag.Name);
                        Assert.False(item.Tags.Contains(tag));
                    }
                }

                Console.WriteLine("Characters:");
                foreach (Character c in characters)
                {
                    Console.WriteLine(c + "\n");
                }
                Console.Write("Room:\n" + room);
            }
        }
示例#4
0
        public void it_should_create_an_item_with_tags()
        {
            RandomNumberGenerator randomNumberGenerator = new SystemRandomNumberGenerator();
            TagFactory            tagFactory            = new TagFactory(randomNumberGenerator);
            ItemFactory           itemFactory           = new ItemFactory(tagFactory);
            Item item = itemFactory.CreateItem("Test Item", "", "", "", new List <string>(new String [] { "tag1", "tag2", "tag1" }));

            Assert.AreEqual("Test Item", item.Name);
            Assert.AreEqual(2, item.Tags.Count);
            Assert.AreEqual(new Tag("tag1"), item.Tags[0]);
            Assert.AreEqual(new Tag("tag2"), item.Tags[1]);
            Assert.AreEqual(1, itemFactory.GetItems().Count);
            Assert.AreEqual(item, itemFactory.GetItems()[0]);
        }
示例#5
0
        public void it_should_maintain_a_unique_list_of_created_tags()
        {
            RandomNumberGenerator randomNumberGenerator = new SystemRandomNumberGenerator();
            TagFactory            tagFactory            = new TagFactory(randomNumberGenerator);

            tagFactory.GetTagByName("Test Tag");
            tagFactory.GetTagByName("Test Tag 2");
            tagFactory.GetTagByName("Test Tag");
            List <Tag> tags = tagFactory.GetAllTags();

            Assert.AreEqual(2, tags.Count);
            Assert.AreEqual(new Tag("Test Tag"), tags[0]);
            Assert.AreEqual(new Tag("Test Tag 2"), tags[1]);
        }
示例#6
0
        public void it_should_support_fetch_by_tag()
        {
            RandomNumberGenerator randomNumberGenerator = new SystemRandomNumberGenerator();
            TagFactory            tagFactory            = new TagFactory(randomNumberGenerator);
            ItemFactory           itemFactory           = new ItemFactory(tagFactory);

            itemFactory.CreateItem("Test Item", "", "", "", new List <string>(new String[] { "tag1", "tag2", "tag1" }));
            itemFactory.CreateItem("Test Item 2", "", "", "", new List <string>(new String[] { "tag1", "tag4", "tag5" }));
            List <Item> tag1Items = itemFactory.FetchItemsByTagName("tag1");

            Assert.AreEqual(2, tag1Items.Count);
            Assert.AreEqual("Test Item", tag1Items[0].Name);
            Assert.AreEqual("Test Item 2", tag1Items[1].Name);
            List <Item> tag4Items = itemFactory.FetchItemsByTagName("tag4");

            Assert.AreEqual(1, tag4Items.Count);
            Assert.AreEqual("Test Item 2", tag1Items[0].Name);
        }
示例#7
0
        public void it_should_be_able_to_fetch_random_excluding_some()
        {
            RandomNumberGenerator randomNumberGenerator = new SystemRandomNumberGenerator();
            TagFactory            tagFactory            = new TagFactory(randomNumberGenerator);
            ItemFactory           itemFactory           = new ItemFactory(tagFactory);

            tagFactory.GetTagByName("Tag 1");
            tagFactory.GetTagByName("Tag 2");
            tagFactory.GetTagByName("Tag 3");
            tagFactory.GetTagByName("Tag 4");
            tagFactory.GetTagByName("Tag 5");
            List <Tag> excludedTags = new List <Tag> {
                new Tag("Tag 1")
            };
            List <Tag> randomTags = tagFactory.GetRandomTags(5, excludedTags, itemFactory, false);

            Assert.False(randomTags.Contains(new Tag("Tag 1")));
        }
示例#8
0
        public void it_should_be_able_to_deserialize_a_collection_of_items()
        {
            String json = @"[{
              'name': 'Test1',
              'uiBinding':'someUiCode1',
              'imageFilenamePrefix':'test1_image',
              'soundFilenamePrefix':'test1_sound',
              'tags': [
                'tag1',
                'tag2'
              ]
            },
            {
              'name': 'Test2',
              'uiBinding':'someUiCode2',
              'tags': [
                'tag3',
                'tag4'
              ]
            }]";

            RandomNumberGenerator randomNumberGenerator = new SystemRandomNumberGenerator();
            TagFactory            tagFactory            = new TagFactory(randomNumberGenerator);
            ItemFactory           itemFactory           = new ItemFactory(tagFactory);
            JsonItemListFactory   jsonItemListFactory   = new JsonItemListFactory(itemFactory);
            List <Item>           itemList = jsonItemListFactory.GetItems(json);

            Assert.AreEqual(2, itemList.Count);
            Assert.AreEqual("Test1", itemList[0].Name);
            Assert.AreEqual("test1_image", itemList[0].ImageFileNamePrefix);
            Assert.AreEqual("test1_sound", itemList[0].SoundFileNamePrefix);
            Assert.AreEqual("someUiCode1", itemList[0].UiBinding);
            Assert.AreEqual("tag1", itemList[0].Tags[0].Name);
            Assert.AreEqual("tag2", itemList[0].Tags[1].Name);
            Assert.AreEqual("Test2", itemList[1].Name);
            Assert.AreEqual("test2", itemList[1].ImageFileNamePrefix);
            Assert.AreEqual("test2", itemList[1].SoundFileNamePrefix);
            Assert.AreEqual("someUiCode2", itemList[1].UiBinding);
            Assert.AreEqual("tag3", itemList[1].Tags[0].Name);
            Assert.AreEqual("tag4", itemList[1].Tags[1].Name);
        }
示例#9
0
        public void it_should_be_able_to_fetch_random_tags()
        {
            RandomNumberGenerator randomNumberGenerator = new SystemRandomNumberGenerator();
            TagFactory            tagFactory            = new TagFactory(randomNumberGenerator);
            ItemFactory           itemFactory           = new ItemFactory(tagFactory);

            tagFactory.GetTagByName("Tag 1");
            tagFactory.GetTagByName("Tag 2");
            tagFactory.GetTagByName("Tag 3");
            tagFactory.GetTagByName("Tag 4");
            tagFactory.GetTagByName("Tag 5");
            tagFactory.GetTagByName("Tag 6");
            tagFactory.GetTagByName("Tag 7");
            tagFactory.GetTagByName("Tag 8");
            tagFactory.GetTagByName("Tag 9");
            tagFactory.GetTagByName("Tag 10");
            tagFactory.GetTagByName("Tag 11");
            tagFactory.GetTagByName("Tag 12");
            tagFactory.GetTagByName("Tag 13");
            tagFactory.GetTagByName("Tag 14");
            tagFactory.GetTagByName("Tag 15");
            List <Tag> excludedTags = new List <Tag>();
            List <Tag> randomTags   = tagFactory.GetRandomTags(5, excludedTags, itemFactory, false);
        }