public void ThrowsForUnterminatedShortcode(string input)
            {
                // Given
                Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(input));
                IShortcodeCollection shortcodeCollection = new TestShortcodeCollection();

                shortcodeCollection.Add("foo", typeof(TestShortcode));
                shortcodeCollection.Add("bar", typeof(TestShortcode));
                ShortcodeParser parser = new ShortcodeParser(
                    ShortcodeParser.DefaultStartDelimiter,
                    ShortcodeParser.DefaultEndDelimiter,
                    shortcodeCollection);

                // When, Then
                Should.Throw <ShortcodeParserException>(() => parser.Parse(stream));
            }
            public void DoesNotRemoveShortcodeStringForTypeParam()
            {
                // Given
                TestShortcodeCollection shortcodes = new TestShortcodeCollection();

                // When
                shortcodes.Add <BazShortcodeFoo>();

                // Then
                shortcodes.Keys.ShouldBe(new[] { "BazShortcodeFoo" });
            }
            public void RemovesLowercaseShortcodeSuffixForTypeParam()
            {
                // Given
                TestShortcodeCollection shortcodes = new TestShortcodeCollection();

                // When
                shortcodes.Add <Barshortcode>();

                // Then
                shortcodes.Keys.ShouldBe(new[] { "Bar" });
            }
            public void RemovesShortcodeSuffixForTypeParam()
            {
                // Given
                TestShortcodeCollection shortcodes = new TestShortcodeCollection();

                // When
                shortcodes.Add <FooShortcode>();

                // Then
                shortcodes.Keys.ShouldBe(new[] { "Foo" });
            }
            public void ThrowsForExtraClosingContent()
            {
                // Given
                Stream stream = new MemoryStream(Encoding.UTF8.GetBytes("<?# foo ?>abc<?#/ foo bar ?>"));
                IShortcodeCollection shortcodeCollection = new TestShortcodeCollection();

                shortcodeCollection.Add("foo", typeof(TestShortcode));
                ShortcodeParser parser = new ShortcodeParser(
                    ShortcodeParser.DefaultStartDelimiter,
                    ShortcodeParser.DefaultEndDelimiter,
                    shortcodeCollection);

                // When, Then
                Should.Throw <ShortcodeParserException>(() => parser.Parse(stream));
            }
            public void ThrowsForUnregisteredShortcodeName()
            {
                // Given
                Stream stream = new MemoryStream(Encoding.UTF8.GetBytes("<?# foo ?>abc<?#/ foo ?>"));
                IShortcodeCollection shortcodeCollection = new TestShortcodeCollection();

                shortcodeCollection.Add("bar", typeof(TestShortcode));
                ShortcodeParser parser = new ShortcodeParser(
                    ShortcodeParser.DefaultPostRenderStartDelimiter,
                    ShortcodeParser.DefaultPostRenderEndDelimiter,
                    shortcodeCollection);

                // When, Then
                Should.Throw <ShortcodeParserException>(() => parser.Parse(stream));
            }
            public void TrimsWildcardProcessingInstructionFromContent(string input, string content)
            {
                // Given
                Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(input));
                IShortcodeCollection shortcodeCollection = new TestShortcodeCollection();

                shortcodeCollection.Add("name", typeof(TestShortcode));
                ShortcodeParser parser = new ShortcodeParser(
                    ShortcodeParser.DefaultStartDelimiter,
                    ShortcodeParser.DefaultEndDelimiter,
                    shortcodeCollection);

                // When
                List <ShortcodeLocation> result = parser.Parse(stream);

                // Then
                result.Single().Content.ShouldBe(content);
            }
            public void FindsClosingShortcode(string input, int firstIndex, int lastIndex)
            {
                // Given
                Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(input));
                IShortcodeCollection shortcodeCollection = new TestShortcodeCollection();

                shortcodeCollection.Add("name", typeof(TestShortcode));
                ShortcodeParser parser = new ShortcodeParser(
                    ShortcodeParser.DefaultStartDelimiter,
                    ShortcodeParser.DefaultEndDelimiter,
                    shortcodeCollection);

                // When
                List <ShortcodeLocation> result = parser.Parse(stream);

                // Then
                result.Single().FirstIndex.ShouldBe(firstIndex);
                result.Single().LastIndex.ShouldBe(lastIndex);
            }