Skip to content

Commit

Permalink
fix minor formatting issues before pull into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kentico-timothyf committed Aug 20, 2019
1 parent 7614ddc commit f965956
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
8 changes: 5 additions & 3 deletions KenticoInspector.Core.Tests/SimpleTokenExpressionTests.cs
Expand Up @@ -545,17 +545,19 @@ public static IEnumerable<TestCaseData> InvalidExpressionsWithOneSegment()

private static TestCaseData GetValidTestCaseWhen(object tokenValues, string returns)
{
//TODO: SetName($"\"{tokenExpression}\" with {tokenValues} returns \"{returns}\"") once NUnit fixes https://github.com/nunit/nunit3-vs-adapter/issues/607
// TODO: add SetName($"\"{tokenExpression}\" with {tokenValues} returns \"{returns}\"") once NUnit fixes https://github.com/nunit/nunit3-vs-adapter/issues/607

return new TestCaseData(tokenExpression, tokenValues)
.Returns(returns)
.SetCategory($"Token expression with {category}");
}

private static TestCaseData GetInvalidTestCaseWhen(object tokenValues, Type throws)
{
//TODO: SetName($"\"{tokenExpression}\" with {tokenValues} throws \"{throws.Name}\"") once NUnit fixes https://github.com/nunit/nunit3-vs-adapter/issues/607
//TODO: add SetName($"\"{tokenExpression}\" with {tokenValues} throws \"{throws.Name}\"") once NUnit fixes https://github.com/nunit/nunit3-vs-adapter/issues/607

return new TestCaseData(tokenExpression, tokenValues, throws)
.SetCategory($"Token expression that is {category}");
}
}
}
}
3 changes: 2 additions & 1 deletion KenticoInspector.Core/Models/ReportMetadata.cs
Expand Up @@ -6,6 +6,7 @@ public class ReportMetadata<T> where T : new()
{
public ReportDetails Details { get; set; } = new ReportDetails();

[JsonIgnore]
public T Terms { get; set; } = new T();
}
}
}
2 changes: 1 addition & 1 deletion KenticoInspector.Core/Tokens/Constants.cs
Expand Up @@ -11,4 +11,4 @@ internal class Constants
public const char Question = '?';
public const char Period = '.';
}
}
}
2 changes: 1 addition & 1 deletion KenticoInspector.Core/Tokens/ITokenExpression.cs
Expand Up @@ -6,4 +6,4 @@ internal interface ITokenExpression
{
string Resolve(string tokenExpression, IDictionary<string, object> tokenDictionary);
}
}
}
22 changes: 17 additions & 5 deletions KenticoInspector.Core/Tokens/SimpleTokenExpression.cs
Expand Up @@ -43,13 +43,19 @@ public string Resolve(string tokenExpression, IDictionary<string, object> tokenD
return expression.defaultValue ?? string.Empty;
}

private (string token, IEnumerable<(string value, char operation, string result)> cases, string defaultValue) GetExpression(string tokenExpression)
private (
string token,
IEnumerable<(string value, char operation, string result)> cases,
string defaultValue
) GetExpression(string tokenExpression)
{
if (string.IsNullOrEmpty(tokenExpression)) throw new ArgumentException($"'{tokenExpression}' looks like a simple token expression but does not contain a token.");
if (string.IsNullOrEmpty(tokenExpression))
throw new ArgumentException($"'{tokenExpression}' looks like a simple token expression but does not contain a token.");

var segments = tokenExpression.Split(Constants.Pipe);

if (segments[0].Contains(Constants.Colon)) throw new FormatException($"Simple token expression token '{segments[0]}' must not contain a {Constants.Colon}.");
if (segments[0].Contains(Constants.Colon))
throw new FormatException($"Simple token expression token '{segments[0]}' must not contain a {Constants.Colon}.");

var cases = new List<(string, char, string)>();

Expand Down Expand Up @@ -107,7 +113,13 @@ private static (string, char, string) GetCase(string expressionCase)
return (pair.first.Substring(1), operation, pair.second);
}

public bool TryResolveToken(object token, string expressionCaseValue, char operation, string expressionCaseResult, out string resolvedValue)
public bool TryResolveToken(
object token,
string expressionCaseValue,
char operation,
string expressionCaseResult,
out string resolvedValue
)
{
var resolved = false;
resolvedValue = null;
Expand Down Expand Up @@ -195,4 +207,4 @@ private static bool TryResolveStringToken(string token, string expressionCaseVal
return false;
}
}
}
}
2 changes: 1 addition & 1 deletion KenticoInspector.Core/Tokens/TokenExpressionResolver.cs
Expand Up @@ -135,4 +135,4 @@ private static (char?, string, char?) GetSplitExpression(string tokenExpression)
return (leadingChar, tokenExpression.TrimStart(leadingChars).TrimEnd(trailingChars), trailingChar);
}
}
}
}
Expand Up @@ -92,8 +92,10 @@ private static T DeserializeYaml<T>(string path)
var mergedMetadata = new ReportMetadata<T>();

mergedMetadata.Details.Name = overrideMetadata.Details.Name ?? defaultMetadata.Details.Name;
mergedMetadata.Details.ShortDescription = overrideMetadata.Details.ShortDescription ?? defaultMetadata.Details.ShortDescription;
mergedMetadata.Details.LongDescription = overrideMetadata.Details.LongDescription ?? defaultMetadata.Details.LongDescription;
mergedMetadata.Details.ShortDescription =
overrideMetadata.Details.ShortDescription ?? defaultMetadata.Details.ShortDescription;
mergedMetadata.Details.LongDescription =
overrideMetadata.Details.LongDescription ?? defaultMetadata.Details.LongDescription;

RecursivelySetPropertyValues(
typeof(T),
Expand Down Expand Up @@ -141,4 +143,4 @@ private static T DeserializeYaml<T>(string path)
}
}
}
}
}

0 comments on commit f965956

Please sign in to comment.