Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Xunit.Sdk.ArgumentFormatter.FormatComplexValue
- // to see the real values of expectedStates, actualStates
- string FormatComplexValue(object value, Type type)
- {
- var fields = type.GetRuntimeFields()
- .Where(f => f.IsPublic && !f.IsStatic)
- .Select(f => new { name = f.Name, value = f.GetValue(value) });
- var properties = type.GetRuntimeProperties()
- .Where(p => p.GetMethod != null && p.GetMethod.IsPublic)
- .Select(p => new { name = p.Name, value = p.GetValue(value) });
- var parameters = fields.Concat(properties)
- .OrderBy(p => p.name)
- .ToList();
- if (parameters.Count == 0)
- {
- return $"{type.Name} {{ }}";
- }
- var formattedParameters = string.Join(", ", parameters
- .Select(p => $"{p.name} = {p.value}"));
- return $"{type.Name} {{ {formattedParameters} }}";
- }
- void LogEnumerable(string name, IEnumerable<object> enumerable)
- {
- _output.WriteLine(
- "{0} is {1}",
- name,
- string.Join(
- ", ",
- enumerable.Select((x, i) =>
- (i % 3 == 0 ? "\n" : string.Empty) +
- FormatComplexValue(x, x.GetType()))));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement