Ejemplo n.º 1
0
    public void ShouldIgnoreForNoKey()
    {
        var exception = Assert.Throws <SnippetReadingException>(() =>
                                                                StartEndTester.IsStartRegion("#region ", "file", out _));

        Assert.Equal("No Key could be derived. Line: '#region '.", exception.Message);
    }
    public void ShouldThrowForKeyStartingWithSymbol()
    {
        var exception = Assert.Throws <SnippetReadingException>(() =>
                                                                StartEndTester.IsStartRegion("#region _key", out _, out _));

        Assert.Equal("Key should not start or end with symbols. Key: _key", exception.Message);
    }
    public Task ShouldThrowForKeyStartingWithSymbol()
    {
        var exception = Assert.Throws <SnippetReadingException>(() =>
                                                                StartEndTester.IsStartRegion("#region _key", "file", out _));

        return(Verify(exception.Message));
    }
    public void CanExtractWithDifferentEndComments()
    {
        var isBeginSnippet = StartEndTester.IsBeginSnippet("/* begin-snippet: CodeKey */", "file", out var key);

        Assert.True(isBeginSnippet);
        Assert.Equal("codekey", key);
    }
    public Task ShouldIgnoreForNoKey()
    {
        var exception = Assert.Throws <SnippetReadingException>(() =>
                                                                StartEndTester.IsStartRegion("#region ", "file", out _));

        return(Verify(exception.Message));
    }
Ejemplo n.º 6
0
    public void ShouldThrowForKeyEndingWithSymbol()
    {
        var exception = Assert.Throws <SnippetReadingException>(() =>
                                                                StartEndTester.IsStartRegion("#region key_ ", "file", out _));

        Approvals.Verify(exception.Message);
    }
    public void CanExtractWithDifferentEndComments()
    {
        var isStartCode = StartEndTester.IsStartCode("/* startcode CodeKey */", "file", out var key);

        Assert.True(isStartCode);
        Assert.Equal("CodeKey", key);
    }
    public void CanExtractWithNoTrailingCharacters()
    {
        var isBeginSnippet = StartEndTester.IsBeginSnippet("<!-- begin-snippet: CodeKey", "file", out var key);

        Assert.True(isBeginSnippet);
        Assert.Equal("codekey", key);
    }
    public void CanExtractFromXml()
    {
        var isStartCode = StartEndTester.IsStartCode("<!-- startcode CodeKey -->", "file", out var key);

        Assert.True(isStartCode);
        Assert.Equal("CodeKey", key);
    }
    public void CanExtractWithUnderScores()
    {
        var isStartCode = StartEndTester.IsStartCode("<!-- startcode Code_Key -->", "file", out var key);

        Assert.True(isStartCode);
        Assert.Equal("Code_Key", key);
    }
    public void ShouldThrowForKeyStartingWithSymbol()
    {
        var exception = Assert.Throws <SnippetReadingException>(() =>
                                                                StartEndTester.IsStartCode("<!-- startcode _key-->", "file", out _));

        Approvals.Verify(exception.Message);
    }
        static (string text, int lineCount) ReadNonStartEndLines(string file)
        {
            var cleanedLines = File.ReadAllLines(file)
                               .Where(x => !StartEndTester.IsStartOrEnd(x.TrimStart())).ToList();

            return(string.Join(Environment.NewLine, cleanedLines), cleanedLines.Count);
        }
    public void CanExtractWithNoTrailingCharacters()
    {
        var isStartCode = StartEndTester.IsStartCode("<!-- startcode CodeKey", "file", out var key);

        Assert.True(isStartCode);
        Assert.Equal("CodeKey", key);
    }
    public Task ShouldThrowForKeyEndingWithSymbol()
    {
        var exception = Assert.Throws <SnippetReadingException>(() =>
                                                                StartEndTester.IsBeginSnippet("<!-- begin-snippet: key_ -->", "file", out _));

        return(Verify(exception.Message));
    }
    public void CanExtractWithDashes()
    {
        var isBeginSnippet = StartEndTester.IsBeginSnippet("<!-- begin-snippet: Code-Key -->", "file", out var key);

        Assert.True(isBeginSnippet);
        Assert.Equal("code-key", key);
    }
    public void CanExtractFromXmlWithExtraSpaces()
    {
        var isBeginSnippet = StartEndTester.IsBeginSnippet("<!--  begin-snippet:  CodeKey  -->", "file", out var key);

        Assert.True(isBeginSnippet);
        Assert.Equal("codekey", key);
    }
    public void ShouldThrowForKeyEndingWithSymbol()
    {
        var exception = Assert.Throws <SnippetReadingException>(() =>
                                                                StartEndTester.IsStartCode("<!-- startcode key_ -->", out _, out _));

        Assert.Equal("Key should not start or end with symbols. Key: key_", exception.Message);
    }
    public void ShouldThrowForNoKey()
    {
        string fake;
        var    exception = Assert.Throws <Exception>(() => StartEndTester.IsStartCode("<!-- startcode -->", out fake, out fake));

        Assert.AreEqual("No Key could be derived. Line: '<!-- startcode -->'.", exception.Message);
    }
    public void CanExtractWithDifferentEndCommentsAndNoSpaces()
    {
        var isStartCode = StartEndTester.IsStartCode("/*startcode CodeKey 5*/", out var key, out var suffix);

        Assert.True(isStartCode);
        Assert.Equal("CodeKey", key);
        Assert.Equal("5", suffix);
    }
Ejemplo n.º 20
0
    public void ShouldIgnoreForNoKey()
    {
        string fake;
        var    exception = Assert.Throws <Exception>(() =>
                                                     StartEndTester.IsStartRegion("#region ", out fake, out fake));

        Assert.AreEqual("No Key could be derived. Line: '#region '.", exception.Message);
    }
    public void CanExtractFromXmlWithMissingSpaces()
    {
        var isStartCode = StartEndTester.IsStartCode("<!--startcode CodeKey-->", out var key, out var suffix);

        Assert.True(isStartCode);
        Assert.Equal("CodeKey", key);
        Assert.Null(suffix);
    }
    public void CanExtractWithDashesWithVersion()
    {
        var isStartCode = StartEndTester.IsStartCode("<!-- startcode Code-Key 5 -->", out var key, out var suffix);

        Assert.True(isStartCode);
        Assert.Equal("Code-Key", key);
        Assert.Equal("5", suffix);
    }
    public void ShouldThrowForKeyEndingWithSymbol()
    {
        string fake;
        var    exception = Assert.Throws <Exception>(() =>
                                                     StartEndTester.IsStartCode("<!-- startcode key_ -->", out fake, out fake));

        Assert.AreEqual("Key should not start or end with symbols. Key: key_", exception.Message);
    }
    public void CanExtractFromXmlWithSuffix()
    {
        var isStartCode = StartEndTester.IsStartCode("<!-- startcode CodeKey 5 -->", out var key, out var suffix);

        Assert.True(isStartCode);
        Assert.Equal("CodeKey", key);
        Assert.Equal("5", suffix);
    }
    public void CanExtractWithNoTrailingCharactersWithVersion()
    {
        var isStartCode = StartEndTester.IsStartCode("<!-- startcode CodeKey 5", out var key, out var suffix);

        Assert.True(isStartCode);
        Assert.Equal("CodeKey", key);
        Assert.Equal("5", suffix);
    }
    public void CanExtractFromXmlWithExtraSpacesWithVersion()
    {
        var isStartCode = StartEndTester.IsStartCode("<!--  startcode  CodeKey  v5  -->", out var key, out var suffix);

        Assert.True(isStartCode);
        Assert.Equal("CodeKey", key);
        Assert.Equal("v5", suffix);
    }
Ejemplo n.º 27
0
    public void ShouldThrowForKeyStartingWithSymbol()
    {
        string fake;
        var    exception = Assert.Throws <Exception>(() =>
                                                     StartEndTester.IsStartRegion("#region _key", out fake, out fake));

        Assert.AreEqual("Key should not start or end with symbols. Key: _key", exception.Message);
    }
Ejemplo n.º 28
0
    public void CanExtractFromXmlWithExtraSpacesWithSuffix1()
    {
        string key;
        string suffix;

        StartEndTester.IsStartRegion("#region  CodeKey  v5    ", out key, out suffix);
        Assert.AreEqual("CodeKey", key);
        Assert.AreEqual("v5", suffix);
    }
Ejemplo n.º 29
0
    public void CanExtractFromXml()
    {
        string key;
        string suffix;

        StartEndTester.IsStartRegion("#region CodeKey", out key, out suffix);
        Assert.AreEqual("CodeKey", key);
        Assert.IsNull(suffix);
    }
Ejemplo n.º 30
0
    public void CanExtractWithDashesWithVersion()
    {
        string key;
        string suffix;

        StartEndTester.IsStartRegion("#region Code-Key 5", out key, out suffix);
        Assert.AreEqual("Code-Key", key);
        Assert.AreEqual("5", suffix);
    }