Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/Tokenizer/ITokenDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ namespace Tokens;
/// Defines a class that can modify the matching or transformation of text
/// on a <see cref="Token"/>.
/// </summary>
public interface ITokenDecorator
{
}
public interface ITokenDecorator;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void GivenFrontMatter_WhenParsing_ThenSetsOptions()
Assert.Equal(StringComparison.InvariantCulture, template.Options.TokenStringComparison);
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];
Assert.Equal("Preamble\n", token.Preamble);
Assert.Equal("TokenName", token.Name);
}
Expand All @@ -37,7 +37,7 @@ public void GivenFrontMatterWithWindowsLineEndings_WhenParsing_ThenSetsOptions()
Assert.Equal(StringComparison.InvariantCultureIgnoreCase, template.Options.TokenStringComparison);
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];
Assert.Equal("Preamble\n", token.Preamble);
Assert.Equal("TokenName", token.Name);
}
Expand All @@ -51,7 +51,7 @@ public void GivenFrontMatterWithName_WhenParsing_ThenSetsTemplateName()
// Assert
Assert.Equal("My Template", template.Name);

var token = template.Tokens.First();
var token = template.Tokens[0];
Assert.Equal("Preamble\n", token.Preamble);
Assert.Equal("TokenName", token.Name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public void GivenEntries_WhenBuildingBlock_ThenPreservesOrder()

// Assert
Assert.Equal(2, block.Entries.Count);
Assert.Same(e1, block.Entries.First());
Assert.Same(e2, block.Entries.Last());
Assert.Same(e1, block.Entries[0]);
Assert.Same(e2, block.Entries[^1]);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void GivenSingleToken_WhenParsing_ThenReturnsCorrectToken()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -59,15 +59,15 @@ public void GivenTwoTokens_WhenParsing_ThenReturnsBothTokens()
// Assert
Assert.Equal(2, template.Tokens.Count);

var token1 = template.Tokens.First();
var token1 = template.Tokens[0];

Assert.Equal("This is the preamble", token1.Preamble);
Assert.Equal("TokenName", token1.Name);
Assert.False(token1.IsOptional);
Assert.False(token1.TerminateOnNewLine);
Assert.False(token1.IsRepeating);

var token2 = template.Tokens.ElementAt(1);
var token2 = template.Tokens[1];

Assert.Equal("Preamble 2 ", token2.Preamble);
Assert.Equal("TokenName2", token2.Name);
Expand All @@ -85,7 +85,7 @@ public void GivenTokenWithNewLineTerminator_WhenParsing_ThenSetsTerminateOnNewLi
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("Preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -110,7 +110,7 @@ public void GivenTokenWithOptionalTerminator_WhenParsing_ThenSetsOptional()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("Preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -129,7 +129,7 @@ public void GivenTokenWithRequiredTerminator_WhenParsing_ThenSetsRequired()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("Preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand Down Expand Up @@ -163,7 +163,7 @@ public void GivenTokenWithOptionalAndNewLineTerminator_WhenParsing_ThenSetsBothF
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("Preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -181,7 +181,7 @@ public void GivenTokenWithDecorator_WhenParsing_ThenAddsDecorator()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("Preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -190,7 +190,7 @@ public void GivenTokenWithDecorator_WhenParsing_ThenAddsDecorator()
Assert.False(token.IsRepeating);
Assert.Single(token.Decorators);

var decorator = token.Decorators.First();
var decorator = token.Decorators[0];

Assert.Equal("ToDateTime", decorator.Name);
}
Expand All @@ -204,7 +204,7 @@ public void GivenTokenWithMultipleDecorators_WhenParsing_ThenAddsAllDecorators()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("Preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -213,11 +213,11 @@ public void GivenTokenWithMultipleDecorators_WhenParsing_ThenAddsAllDecorators()
Assert.False(token.IsRepeating);
Assert.Equal(2, token.Decorators.Count);

var decorator1 = token.Decorators.First();
var decorator1 = token.Decorators[0];

Assert.Equal("Trim", decorator1.Name);

var decorator2 = token.Decorators.ElementAt(1);
var decorator2 = token.Decorators[1];

Assert.Equal("IsNotNullOrEmpty", decorator2.Name);
}
Expand All @@ -231,13 +231,13 @@ public void GivenTokenWithDecoratorWithArgument_WhenParsing_ThenAddsDecoratorWit
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var decorator = token.Decorators.First();
var token = template.Tokens[0];
var decorator = token.Decorators[0];

Assert.Equal("ToDateTime", decorator.Name);

Assert.Single(decorator.Args);
Assert.Equal("yyyy-MM-dd", decorator.Args.First());
Assert.Equal("yyyy-MM-dd", decorator.Args[0]);
}

[Fact]
Expand All @@ -249,13 +249,13 @@ public void GivenTokenWithDecoratorWithSingleQuotedArgument_WhenParsing_ThenAdds
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var decorator = token.Decorators.First();
var token = template.Tokens[0];
var decorator = token.Decorators[0];

Assert.Equal("ToDateTime", decorator.Name);

Assert.Single(decorator.Args);
Assert.Equal("yyyy-MM-dd", decorator.Args.First());
Assert.Equal("yyyy-MM-dd", decorator.Args[0]);
}

[Fact]
Expand All @@ -267,13 +267,13 @@ public void GivenTokenWithDecoratorWithDoubleQuotedArgument_WhenParsing_ThenAdds
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var decorator = token.Decorators.First();
var token = template.Tokens[0];
var decorator = token.Decorators[0];

Assert.Equal("ToDateTime", decorator.Name);

Assert.Single(decorator.Args);
Assert.Equal("yyyy-MM-dd", decorator.Args.First());
Assert.Equal("yyyy-MM-dd", decorator.Args[0]);
}

[Fact]
Expand All @@ -285,8 +285,8 @@ public void GivenTokenWithDecoratorWithThreeArguments_WhenParsing_ThenAddsDecora
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var decorator = token.Decorators.First();
var token = template.Tokens[0];
var decorator = token.Decorators[0];

Assert.Equal("Decorator", decorator.Name);

Expand All @@ -305,7 +305,7 @@ public void GivenTokenWithTrailingText_WhenParsing_ThenCreatesSecondToken()
// Assert
Assert.Equal(2, template.Tokens.Count);

var token = template.Tokens.First();
var token = template.Tokens[0];
Assert.Equal("TokenName", token.Name);

var second = template.Tokens[1];
Expand All @@ -322,7 +322,7 @@ public void GivenTokenWithWindowsLineEndings_WhenParsing_ThenConvertsToUnixLineE
// Assert
Assert.Equal(2, template.Tokens.Count);

var token = template.Tokens.First();
var token = template.Tokens[0];
Assert.Equal("Preamble\n", token.Preamble);
Assert.Equal("TokenName", token.Name);

Expand All @@ -340,7 +340,7 @@ public void GivenTokenWithUnixLineEndings_WhenParsing_ThenPreservesUnixLineEndin
// Assert
Assert.Equal(2, template.Tokens.Count);

var token = template.Tokens.First();
var token = template.Tokens[0];
Assert.Equal("Preamble\n", token.Preamble);
Assert.Equal("TokenName", token.Name);

Expand All @@ -359,7 +359,7 @@ public void GivenFrontMatter_WhenParsing_ThenSetsOptions()
Assert.Equal(StringComparison.InvariantCulture, template.Options.TokenStringComparison);
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];
Assert.Equal("Preamble\n", token.Preamble);
Assert.Equal("TokenName", token.Name);
}
Expand All @@ -374,7 +374,7 @@ public void GivenFrontMatterWithWindowsLineEndings_WhenParsing_ThenSetsOptions()
Assert.Equal(StringComparison.InvariantCultureIgnoreCase, template.Options.TokenStringComparison);
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];
Assert.Equal("Preamble\n", token.Preamble);
Assert.Equal("TokenName", token.Name);
}
Expand All @@ -388,7 +388,7 @@ public void GivenFrontMatterWithName_WhenParsing_ThenSetsTemplateName()
// Assert
Assert.Equal("My Template", template.Name);

var token = template.Tokens.First();
var token = template.Tokens[0];
Assert.Equal("Preamble\n", token.Preamble);
Assert.Equal("TokenName", token.Name);
}
Expand Down Expand Up @@ -440,7 +440,7 @@ public void GivenTokenWithEscapedBrackets_WhenParsing_ThenUnescapesBrackets()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This {is} the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand Down Expand Up @@ -475,7 +475,7 @@ public void GivenTokenWithWhitespace_WhenParsing_ThenAllowsWhitespace()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand Down Expand Up @@ -535,7 +535,7 @@ public void GivenTokenWithRequiredLonghand_WhenParsing_ThenSetsRequired()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -552,7 +552,7 @@ public void GivenTokenWithOptionalLonghand_WhenParsing_ThenSetsOptional()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -569,7 +569,7 @@ public void GivenTokenWithRepeatingLonghand_WhenParsing_ThenSetsRepeating()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -586,7 +586,7 @@ public void GivenTokenWithNewLineLonghand_WhenParsing_ThenSetsTerminateOnNewLine
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand Down Expand Up @@ -626,7 +626,7 @@ public void GivenTokenWithSetValue_WhenParsing_ThenSetsValue()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -643,7 +643,7 @@ public void GivenTokenWithSetValueAndDecorator_WhenParsing_ThenSetsValueAndDecor
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand Down Expand Up @@ -675,7 +675,7 @@ public void GivenTokenWithSetValueInDoubleQuotes_WhenParsing_ThenSetsValue()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -692,7 +692,7 @@ public void GivenTokenWithSetValueInSingleQuotes_WhenParsing_ThenSetsValue()
// Assert
Assert.Single(template.Tokens);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand All @@ -709,7 +709,7 @@ public void GivenTokenWithSetValueInSingleQuotesAndDecorator_WhenParsing_ThenSet
// Assert
Assert.Equal(2, template.Tokens.Count);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("TokenName", token.Name);
Expand Down Expand Up @@ -903,7 +903,7 @@ public void GivenNullToken_WhenParsing_ThenSetsIsNull()
// Assert
Assert.Equal(2, template.Tokens.Count);

var token = template.Tokens.First();
var token = template.Tokens[0];

Assert.Equal("This is the preamble", token.Preamble);
Assert.Equal("Null", token.Name);
Expand Down
Loading
Loading