Esempio n. 1
0
        public void NameWithApostropheTest()
        {
            // arrange
            var          filenames           = new string[] { "100-I'll-have-you-know.png" };
            const string expectedDescription = "I'll Have You Know";

            // act
            var memes = new MemeConfiguration();

            MemeConfig.AutoRegisterMemesByFile(memes, filenames);

            // assert
            Assert.AreEqual(1, memes.GetMemes().Count);
            var meme = memes.GetMemes()[0];

            Assert.AreEqual(expectedDescription, meme.Description);
        }
Esempio n. 2
0
        public void NameWithTwoCharacterExtensionTest()
        {
            // arrange
            var          filenames           = new string[] { "100-file.jp" };
            const string expectedDescription = "File";

            // act
            var memes = new MemeConfiguration();

            MemeConfig.AutoRegisterMemesByFile(memes, filenames);

            // assert
            Assert.AreEqual(1, memes.GetMemes().Count);
            var meme = memes.GetMemes()[0];

            Assert.AreEqual(expectedDescription, meme.Description);
        }
        public void InitialismWithSingleCharacterWordsTest()
        {
            // arrange
            var          filenames     = new string[] { "01-y-u-no.png" };
            const string expectedAlias = "yun";

            // act
            var memes = new MemeConfiguration();

            MemeConfig.AutoRegisterMemesByFile(memes, filenames);

            // assert
            Assert.AreEqual(1, memes.GetMemes().Count);
            var meme = memes.GetMemes()[0];

            Assert.IsTrue(meme.Aliases.Contains(expectedAlias));
        }
Esempio n. 4
0
        public void TitleCaseTest()
        {
            // arrange
            var          filenames           = new string[] { "100-success-kid.png" };
            const string expectedDescription = "Success Kid";

            // act
            var memes = new MemeConfiguration();

            MemeConfig.AutoRegisterMemesByFile(memes, filenames);

            // assert
            Assert.AreEqual(1, memes.GetMemes().Count);
            var meme = memes.GetMemes()[0];

            Assert.AreEqual(expectedDescription, meme.Description);
        }
        public void InitialismWithApostropheTest()
        {
            // arrange
            var          filenames     = new string[] { "01-I'll-have-you-know.png" };
            const string expectedAlias = "ihyk";

            // act
            var memes = new MemeConfiguration();

            MemeConfig.AutoRegisterMemesByFile(memes, filenames);

            // assert
            Assert.AreEqual(1, memes.GetMemes().Count);
            var meme = memes.GetMemes()[0];

            Assert.IsTrue(meme.Aliases.Contains(expectedAlias));
        }
        public void InitialismMixedCaseTest()
        {
            // arrange
            var          filenames     = new string[] { "01-Success-Kid.png" };
            const string expectedAlias = "sk";

            // act
            var memes = new MemeConfiguration();

            MemeConfig.AutoRegisterMemesByFile(memes, filenames);

            // assert
            Assert.AreEqual(1, memes.GetMemes().Count);
            var meme = memes.GetMemes()[0];

            Assert.IsTrue(meme.Aliases.Contains(expectedAlias));
        }
        public void InitialismOneWordTest()
        {
            // arrange
            var          filenames     = new string[] { "01-Fry.png" };
            const string expectedAlias = "fry"; // no single character aliases are allowed

            // act
            var memes = new MemeConfiguration();

            MemeConfig.AutoRegisterMemesByFile(memes, filenames);

            // assert
            Assert.AreEqual(1, memes.GetMemes().Count);
            var meme = memes.GetMemes()[0];

            Assert.IsTrue(meme.Aliases.Contains(expectedAlias));
        }
        public void InitialismWithNumberPrefix()
        {
            // arrange
            var          filenames     = new string[] { "01-1950s-guy.png" };
            const string expectedAlias = "1950g";

            // act
            var memes = new MemeConfiguration();

            MemeConfig.AutoRegisterMemesByFile(memes, filenames);

            // assert
            Assert.AreEqual(1, memes.GetMemes().Count);
            var meme = memes.GetMemes()[0];

            Assert.IsTrue(meme.Aliases.Contains(expectedAlias));
        }
Esempio n. 9
0
        public static Meme FindMeme(MemeConfiguration memes, string memeName)
        {
            var sanitizedName = "";

            if (!String.IsNullOrEmpty(memeName))
            {
                sanitizedName = memeName.Replace("-", "");
            }

            if (string.IsNullOrEmpty(sanitizedName))
            {
                return(null);
            }

            var meme = memes[sanitizedName]
                       ?? memes.GetMemes().FirstOrDefault(m => m.Aliases.Any(a => a.StartsWith(sanitizedName)))
                       ?? memes.GetMemes().FirstOrDefault(m => m.Aliases.Any(a => a.EndsWith(sanitizedName)))
                       ?? memes.GetMemes().FirstOrDefault(m => m.Aliases.Any(a => sanitizedName.StartsWith(a)))
                       ?? memes.GetMemes().FirstOrDefault(m => m.Aliases.Any(a => sanitizedName.EndsWith(a)));


            return(meme);
        }