static RawToken NewTokenIfNecessary(List<RawToken> tokens, RawToken lastToken, RawTokenType curTokenType, int position) { if (lastToken == null || lastToken.TokenType != curTokenType || curTokenType == RawTokenType.Symbol) // for symbol always let it be by itself { lastToken = new RawToken(curTokenType, position); tokens.Add(lastToken); } return lastToken; }
public void DoubleWithApplicableToken_DoublesUpTheQuantity(RawTokenType type) { _outcome.Tokens.Add(new RawTokenResult { Type = type }); var results = new DoubleApplication(_outcome, 1).Get(); Assert.Single(results); Assert.Single(results[0].Tokens); Assert.Equal(2, results[0].Tokens[0].Quantity); }
public void DoubleWithOneOtherNonApplicableToken_AddsOpenDouble(RawTokenType type) { _outcome.Tokens.Add(new RawTokenResult { Type = type }); var results = new DoubleApplication(_outcome, 1).Get(); Assert.Single(results); Assert.Equal(2, results[0].Tokens.Count); Assert.Equal(RawTokenType.OpenDouble, results[0].Tokens[1].Type); }
public void TacticsWithOneOtherToken_CorrectType(RawTokenType existingTokenType, RawTokenType expectedTacticsType, bool wasTactics) { _outcome.Tokens.Add(new RawTokenResult { Type = existingTokenType }); var results = new TacticsApplication(_outcome, 1).Get(); Assert.Single(results); Assert.Equal(2, results[0].Tokens.Count); Assert.Equal(expectedTacticsType, results[0].Tokens[1].Type); Assert.Equal(wasTactics, results[0].Tokens[1].WasTactics); }
/// <summary> /// Initializes a new instance of the <see cref="RawToken"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="position">The position.</param> internal RawToken(RawTokenType type, int position) { TokenType = type; Position = position; ValueBuilder = new StringBuilder(); }
static RawToken NewTokenIfNecessary(List <RawToken> tokens, RawToken lastToken, RawTokenType curTokenType, int position) { if (lastToken == null || lastToken.TokenType != curTokenType || curTokenType == RawTokenType.Symbol) // for symbol always let it be by itself { lastToken = new RawToken(curTokenType, position); tokens.Add(lastToken); } return(lastToken); }