diff --git a/Source/aweXpect.Reflection/Formatting/FormattableMember.cs b/Source/aweXpect.Reflection/Formatting/FormattableMember.cs new file mode 100644 index 00000000..e2fc3c16 --- /dev/null +++ b/Source/aweXpect.Reflection/Formatting/FormattableMember.cs @@ -0,0 +1,59 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace aweXpect.Reflection.Formatting; + +/// +/// Wraps a constructor, event, field, method or property, so that the formatters of this package format it. +/// +/// +/// The formatter is registered for this type instead of the reflection types, which this package does not own, so +/// that formatting them outside of this package does not depend on whether a test used this package before. +/// +internal sealed class FormattableMember +{ + private static readonly IValueFormatter[] Formatters = + [ + new ConstructorFormatter(), new EventFormatter(), new FieldFormatter(), new MethodFormatter(), + new PropertyFormatter(), + ]; + + private readonly MemberInfo _member; + + private FormattableMember(MemberInfo member) + { + _member = member; + } + + /// + /// Wraps the if it is a constructor, event, field, method or property, otherwise + /// returns it unchanged. + /// + public static object? From(object? value) + => value is ConstructorInfo or EventInfo or FieldInfo or MethodInfo or PropertyInfo + ? new FormattableMember((MemberInfo)value) + : value; + + /// + /// Wraps each of the with . + /// + /// + /// A collection is copied, so that a truncated message still names the number of remaining items; any other + /// sequence stays lazy. + /// + public static IEnumerable FromAll(IEnumerable values) + { + IEnumerable wrapped = values.Select(value => From(value)); + return values is ICollection or ICollection or IReadOnlyCollection ? wrapped.ToArray() : wrapped; + } + + internal sealed class MemberFormatter : IValueFormatter + { + public bool TryFormat(StringBuilder stringBuilder, object value, FormattingOptions? options) + => value is FormattableMember formattableMember && + Formatters.Any(formatter => formatter.TryFormat(stringBuilder, formattableMember._member, options)); + } +} diff --git a/Source/aweXpect.Reflection/Formatting/FormatterRegistration.cs b/Source/aweXpect.Reflection/Formatting/FormatterRegistration.cs index d0999e83..d50d2a00 100644 --- a/Source/aweXpect.Reflection/Formatting/FormatterRegistration.cs +++ b/Source/aweXpect.Reflection/Formatting/FormatterRegistration.cs @@ -5,23 +5,17 @@ namespace aweXpect.Reflection.Formatting; internal static class FormatterRegistration { /// - /// Registers the reflection value formatters when the assembly is loaded. + /// Registers the formatter for the when the assembly is loaded. /// /// /// A module initializer keeps the registration reachable without reflection, so it survives trimming and /// Native AOT - which is why CA2255 (discouraging module initializers in libraries) is suppressed here. - /// The registrations intentionally last for the lifetime of the process, hence the - /// handles returned by are discarded. + /// The registration intentionally lasts for the lifetime of the process, hence the + /// handle returned by is discarded. /// #pragma warning disable CA2255 [ModuleInitializer] internal static void Initialize() - { - ValueFormatter.Register(new ConstructorFormatter()); - ValueFormatter.Register(new EventFormatter()); - ValueFormatter.Register(new FieldFormatter()); - ValueFormatter.Register(new MethodFormatter()); - ValueFormatter.Register(new PropertyFormatter()); - } + => ValueFormatter.Register(new FormattableMember.MemberFormatter()); #pragma warning restore CA2255 } diff --git a/Source/aweXpect.Reflection/Helpers/CollectionConstraintResult.cs b/Source/aweXpect.Reflection/Helpers/CollectionConstraintResult.cs index 948a6947..db9699b2 100644 --- a/Source/aweXpect.Reflection/Helpers/CollectionConstraintResult.cs +++ b/Source/aweXpect.Reflection/Helpers/CollectionConstraintResult.cs @@ -7,6 +7,7 @@ using aweXpect.Core; using aweXpect.Core.Constraints; using aweXpect.Core.EvaluationContext; +using aweXpect.Reflection.Formatting; namespace aweXpect.Reflection.Helpers; @@ -261,7 +262,7 @@ public override void AppendContexts(ResultContextCollector contexts) /// state that is captured when this method is called. /// protected virtual Func FormatItems(T[] items) - => () => Formatter.Format(items, FormattingOptions.MultipleLines); + => () => Formatter.Format(FormattableMember.FromAll(items), FormattingOptions.MultipleLines); /// public override bool TryGetStoredValue(out TValue? value) where TValue : default diff --git a/Source/aweXpect.Reflection/Helpers/MemberViolationRenderer.cs b/Source/aweXpect.Reflection/Helpers/MemberViolationRenderer.cs index 0bfab96a..4723ffc5 100644 --- a/Source/aweXpect.Reflection/Helpers/MemberViolationRenderer.cs +++ b/Source/aweXpect.Reflection/Helpers/MemberViolationRenderer.cs @@ -3,6 +3,7 @@ using System.Reflection; using System.Text; using aweXpect.Core; +using aweXpect.Reflection.Formatting; namespace aweXpect.Reflection.Helpers; @@ -25,7 +26,8 @@ public static void AddMembersContext(this ResultContextCollector contexts, strin if (members.Length > 0) { contexts.Add(new ResultContext.SyncCallback(title, - () => Formatter.Format(members, FormattingOptions.MultipleLines), int.MaxValue)); + () => Formatter.Format(FormattableMember.FromAll(members), FormattingOptions.MultipleLines), + int.MaxValue)); } } @@ -52,7 +54,7 @@ public static string FormatTypesWithViolatingMembers( if (type is not null && violations.TryGetValue(type, out MemberInfo[]? members)) { - stringBuilder.Append(memberHeader).Append(Formatter.Format(members)); + stringBuilder.Append(memberHeader).Append(Formatter.Format(FormattableMember.FromAll(members))); } if (index < types.Count - 1) diff --git a/Source/aweXpect.Reflection/In.cs b/Source/aweXpect.Reflection/In.cs index ba30365c..96d2434f 100644 --- a/Source/aweXpect.Reflection/In.cs +++ b/Source/aweXpect.Reflection/In.cs @@ -4,6 +4,7 @@ using System.Reflection; using aweXpect.Customization; using aweXpect.Reflection.Collections; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; // ReSharper disable PossibleMultipleEnumeration @@ -90,29 +91,29 @@ public static Filtered.Types Types(params IEnumerable types) /// Defines expectations on the given . /// public static Filtered.Constructors Constructors(params IEnumerable constructors) - => new(constructors, $"in the constructors {Formatter.Format(constructors)}"); + => new(constructors, $"in the constructors {Formatter.Format(FormattableMember.FromAll(constructors))}"); /// /// Defines expectations on the given . /// public static Filtered.Events Events(params IEnumerable events) - => new(events, $"in the events {Formatter.Format(events)}"); + => new(events, $"in the events {Formatter.Format(FormattableMember.FromAll(events))}"); /// /// Defines expectations on the given . /// public static Filtered.Fields Fields(params IEnumerable fields) - => new(fields, $"in the fields {Formatter.Format(fields)}"); + => new(fields, $"in the fields {Formatter.Format(FormattableMember.FromAll(fields))}"); /// /// Defines expectations on the given . /// public static Filtered.Methods Methods(params IEnumerable methods) - => new(methods, $"in the methods {Formatter.Format(methods)}"); + => new(methods, $"in the methods {Formatter.Format(FormattableMember.FromAll(methods))}"); /// /// Defines expectations on the given . /// public static Filtered.Properties Properties(params IEnumerable properties) - => new(properties, $"in the properties {Formatter.Format(properties)}"); + => new(properties, $"in the properties {Formatter.Format(FormattableMember.FromAll(properties))}"); } diff --git a/Source/aweXpect.Reflection/ThatConstructor.Has.cs b/Source/aweXpect.Reflection/ThatConstructor.Has.cs index 6ed8e111..a16f6189 100644 --- a/Source/aweXpect.Reflection/ThatConstructor.Has.cs +++ b/Source/aweXpect.Reflection/ThatConstructor.Has.cs @@ -4,6 +4,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Reflection.Options; using aweXpect.Reflection.Results; @@ -70,7 +71,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -79,7 +80,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatConstructor.IsStatic.cs b/Source/aweXpect.Reflection/ThatConstructor.IsStatic.cs index a2256587..a3c47714 100644 --- a/Source/aweXpect.Reflection/ThatConstructor.IsStatic.cs +++ b/Source/aweXpect.Reflection/ThatConstructor.IsStatic.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatEvent.Has.cs b/Source/aweXpect.Reflection/ThatEvent.Has.cs index cb968654..8e95b0fa 100644 --- a/Source/aweXpect.Reflection/ThatEvent.Has.cs +++ b/Source/aweXpect.Reflection/ThatEvent.Has.cs @@ -4,6 +4,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Reflection.Options; using aweXpect.Reflection.Results; @@ -78,7 +79,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -87,7 +88,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatEvent.IsAbstract.cs b/Source/aweXpect.Reflection/ThatEvent.IsAbstract.cs index 132db5ce..fa983454 100644 --- a/Source/aweXpect.Reflection/ThatEvent.IsAbstract.cs +++ b/Source/aweXpect.Reflection/ThatEvent.IsAbstract.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-abstract "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was abstract "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatEvent.IsNullable.cs b/Source/aweXpect.Reflection/ThatEvent.IsNullable.cs index 9795b1f5..a8e6983e 100644 --- a/Source/aweXpect.Reflection/ThatEvent.IsNullable.cs +++ b/Source/aweXpect.Reflection/ThatEvent.IsNullable.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -55,7 +56,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-nullable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -64,7 +65,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was nullable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatEvent.IsSealed.cs b/Source/aweXpect.Reflection/ThatEvent.IsSealed.cs index 96adf227..dd4788c5 100644 --- a/Source/aweXpect.Reflection/ThatEvent.IsSealed.cs +++ b/Source/aweXpect.Reflection/ThatEvent.IsSealed.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-sealed "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was sealed "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatEvent.IsStatic.cs b/Source/aweXpect.Reflection/ThatEvent.IsStatic.cs index 6d616128..10d45551 100644 --- a/Source/aweXpect.Reflection/ThatEvent.IsStatic.cs +++ b/Source/aweXpect.Reflection/ThatEvent.IsStatic.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatEvent.IsVirtual.cs b/Source/aweXpect.Reflection/ThatEvent.IsVirtual.cs index 3cac950e..0d475ded 100644 --- a/Source/aweXpect.Reflection/ThatEvent.IsVirtual.cs +++ b/Source/aweXpect.Reflection/ThatEvent.IsVirtual.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-virtual "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was virtual "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatEvent.Overrides.cs b/Source/aweXpect.Reflection/ThatEvent.Overrides.cs index bfdd880c..c4cd10d5 100644 --- a/Source/aweXpect.Reflection/ThatEvent.Overrides.cs +++ b/Source/aweXpect.Reflection/ThatEvent.Overrides.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not override a base event "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did override a base event "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatField.Has.cs b/Source/aweXpect.Reflection/ThatField.Has.cs index 7561092a..82631df6 100644 --- a/Source/aweXpect.Reflection/ThatField.Has.cs +++ b/Source/aweXpect.Reflection/ThatField.Has.cs @@ -4,6 +4,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Reflection.Options; using aweXpect.Reflection.Results; @@ -69,7 +70,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -78,7 +79,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatField.IsConstant.cs b/Source/aweXpect.Reflection/ThatField.IsConstant.cs index 912a5cef..2cc95d59 100644 --- a/Source/aweXpect.Reflection/ThatField.IsConstant.cs +++ b/Source/aweXpect.Reflection/ThatField.IsConstant.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-constant "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was constant "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatField.IsNullable.cs b/Source/aweXpect.Reflection/ThatField.IsNullable.cs index 71892bf5..f634b98b 100644 --- a/Source/aweXpect.Reflection/ThatField.IsNullable.cs +++ b/Source/aweXpect.Reflection/ThatField.IsNullable.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -55,7 +56,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-nullable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -64,7 +65,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was nullable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatField.IsReadOnly.cs b/Source/aweXpect.Reflection/ThatField.IsReadOnly.cs index 1d66d1de..4693a100 100644 --- a/Source/aweXpect.Reflection/ThatField.IsReadOnly.cs +++ b/Source/aweXpect.Reflection/ThatField.IsReadOnly.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-read-only "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was read-only "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatField.IsRequired.cs b/Source/aweXpect.Reflection/ThatField.IsRequired.cs index 20cf32df..9deebe49 100644 --- a/Source/aweXpect.Reflection/ThatField.IsRequired.cs +++ b/Source/aweXpect.Reflection/ThatField.IsRequired.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-required "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was required "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatField.IsStatic.cs b/Source/aweXpect.Reflection/ThatField.IsStatic.cs index 8df0e479..65bb0a66 100644 --- a/Source/aweXpect.Reflection/ThatField.IsStatic.cs +++ b/Source/aweXpect.Reflection/ThatField.IsStatic.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMember.IsObsolete.cs b/Source/aweXpect.Reflection/ThatMember.IsObsolete.cs index 34b4262a..a4f86229 100644 --- a/Source/aweXpect.Reflection/ThatMember.IsObsolete.cs +++ b/Source/aweXpect.Reflection/ThatMember.IsObsolete.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -55,7 +56,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-obsolete "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -64,7 +65,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was obsolete "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMembers.HaveName.cs b/Source/aweXpect.Reflection/ThatMembers.HaveName.cs index 70282a7a..4a285a09 100644 --- a/Source/aweXpect.Reflection/ThatMembers.HaveName.cs +++ b/Source/aweXpect.Reflection/ThatMembers.HaveName.cs @@ -9,6 +9,7 @@ using aweXpect.Core.Constraints; using aweXpect.Core.EvaluationContext; using aweXpect.Options; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -197,7 +198,7 @@ private string FormatMismatches(TMember[] items) isFirst = false; stringBuilder.AppendLine().Append(" ") - .Append(Formatter.Format(memberInfo)) + .Append(Formatter.Format(FormattableMember.From(memberInfo))) .Append(" with name ").Append(Formatter.Format(memberInfo?.Name)) .Append(" instead of ").Append(Formatter.Format(UserCode.Invoke(expectedNameSelector, memberInfo, "the name selector"))); } diff --git a/Source/aweXpect.Reflection/ThatMethod.Has.cs b/Source/aweXpect.Reflection/ThatMethod.Has.cs index 94638302..0cef4a1c 100644 --- a/Source/aweXpect.Reflection/ThatMethod.Has.cs +++ b/Source/aweXpect.Reflection/ThatMethod.Has.cs @@ -4,6 +4,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Reflection.Options; using aweXpect.Reflection.Results; @@ -78,7 +79,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -87,7 +88,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMethod.IsAbstract.cs b/Source/aweXpect.Reflection/ThatMethod.IsAbstract.cs index c161cc29..8cc6bbe7 100644 --- a/Source/aweXpect.Reflection/ThatMethod.IsAbstract.cs +++ b/Source/aweXpect.Reflection/ThatMethod.IsAbstract.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-abstract "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was abstract "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMethod.IsAnExtensionMethod.cs b/Source/aweXpect.Reflection/ThatMethod.IsAnExtensionMethod.cs index 98374fbd..9ce0b7ed 100644 --- a/Source/aweXpect.Reflection/ThatMethod.IsAnExtensionMethod.cs +++ b/Source/aweXpect.Reflection/ThatMethod.IsAnExtensionMethod.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -48,7 +49,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not an extension method "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -57,7 +58,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was an extension method "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMethod.IsAnOperator.cs b/Source/aweXpect.Reflection/ThatMethod.IsAnOperator.cs index d809c409..35acc9bf 100644 --- a/Source/aweXpect.Reflection/ThatMethod.IsAnOperator.cs +++ b/Source/aweXpect.Reflection/ThatMethod.IsAnOperator.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -70,7 +71,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not an operator "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -79,7 +80,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was an operator "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } @@ -102,7 +103,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not the operator ").Append(_name).Append(' '); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -111,7 +112,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was the operator ").Append(_name).Append(' '); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMethod.IsAsync.cs b/Source/aweXpect.Reflection/ThatMethod.IsAsync.cs index abc92e38..b3ed1860 100644 --- a/Source/aweXpect.Reflection/ThatMethod.IsAsync.cs +++ b/Source/aweXpect.Reflection/ThatMethod.IsAsync.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -47,7 +48,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-async "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -56,7 +57,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was async "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMethod.IsGeneric.cs b/Source/aweXpect.Reflection/ThatMethod.IsGeneric.cs index e4258f2b..b1df0c2f 100644 --- a/Source/aweXpect.Reflection/ThatMethod.IsGeneric.cs +++ b/Source/aweXpect.Reflection/ThatMethod.IsGeneric.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Reflection.Options; using aweXpect.Reflection.Results; @@ -76,7 +77,7 @@ protected override void AppendNormalResult(StringBuilder stringBuilder, string? stringBuilder.Append(It).Append(" was non-generic "); } - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -85,7 +86,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was generic "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMethod.IsSealed.cs b/Source/aweXpect.Reflection/ThatMethod.IsSealed.cs index 09d38f07..e8425c03 100644 --- a/Source/aweXpect.Reflection/ThatMethod.IsSealed.cs +++ b/Source/aweXpect.Reflection/ThatMethod.IsSealed.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-sealed "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was sealed "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMethod.IsStatic.cs b/Source/aweXpect.Reflection/ThatMethod.IsStatic.cs index 2dba561a..ad95426f 100644 --- a/Source/aweXpect.Reflection/ThatMethod.IsStatic.cs +++ b/Source/aweXpect.Reflection/ThatMethod.IsStatic.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMethod.IsVirtual.cs b/Source/aweXpect.Reflection/ThatMethod.IsVirtual.cs index 330823ee..8367a7b4 100644 --- a/Source/aweXpect.Reflection/ThatMethod.IsVirtual.cs +++ b/Source/aweXpect.Reflection/ThatMethod.IsVirtual.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-virtual "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was virtual "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatMethod.Overrides.cs b/Source/aweXpect.Reflection/ThatMethod.Overrides.cs index 11da4d78..9130818d 100644 --- a/Source/aweXpect.Reflection/ThatMethod.Overrides.cs +++ b/Source/aweXpect.Reflection/ThatMethod.Overrides.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not override a base method "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did override a base method "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.Has.cs b/Source/aweXpect.Reflection/ThatProperty.Has.cs index 9b6a5ee6..7c3aa40b 100644 --- a/Source/aweXpect.Reflection/ThatProperty.Has.cs +++ b/Source/aweXpect.Reflection/ThatProperty.Has.cs @@ -4,6 +4,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Reflection.Options; using aweXpect.Reflection.Results; @@ -79,7 +80,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -88,7 +89,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did in "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.HasAGetter.cs b/Source/aweXpect.Reflection/ThatProperty.HasAGetter.cs index 5e324aab..538de1ba 100644 --- a/Source/aweXpect.Reflection/ThatProperty.HasAGetter.cs +++ b/Source/aweXpect.Reflection/ThatProperty.HasAGetter.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -36,7 +37,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not have a getter "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -45,7 +46,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" had a getter "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.HasASetter.cs b/Source/aweXpect.Reflection/ThatProperty.HasASetter.cs index ac0ab13e..a26f9275 100644 --- a/Source/aweXpect.Reflection/ThatProperty.HasASetter.cs +++ b/Source/aweXpect.Reflection/ThatProperty.HasASetter.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -36,7 +37,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not have a setter "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -45,7 +46,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" had a setter "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.HasAnInitSetter.cs b/Source/aweXpect.Reflection/ThatProperty.HasAnInitSetter.cs index c9c8d5ef..ebede0ea 100644 --- a/Source/aweXpect.Reflection/ThatProperty.HasAnInitSetter.cs +++ b/Source/aweXpect.Reflection/ThatProperty.HasAnInitSetter.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -36,7 +37,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not have an init setter "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -45,7 +46,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" had an init setter "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsAbstract.cs b/Source/aweXpect.Reflection/ThatProperty.IsAbstract.cs index b31abcb8..30ed235e 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsAbstract.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsAbstract.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-abstract "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was abstract "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsAnExtensionProperty.cs b/Source/aweXpect.Reflection/ThatProperty.IsAnExtensionProperty.cs index dd03e6af..8978a5e1 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsAnExtensionProperty.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsAnExtensionProperty.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -48,7 +49,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not an extension property "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -57,7 +58,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was an extension property "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsAnIndexer.cs b/Source/aweXpect.Reflection/ThatProperty.IsAnIndexer.cs index bf834b04..ac17631f 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsAnIndexer.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsAnIndexer.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not an indexer "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was an indexer "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsNullable.cs b/Source/aweXpect.Reflection/ThatProperty.IsNullable.cs index 55abd0c9..82542b0b 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsNullable.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsNullable.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -55,7 +56,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-nullable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -64,7 +65,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was nullable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsReadOnly.cs b/Source/aweXpect.Reflection/ThatProperty.IsReadOnly.cs index 70f98d3a..706bca49 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsReadOnly.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsReadOnly.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -36,7 +37,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not read-only "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -45,7 +46,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was read-only "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsReadWrite.cs b/Source/aweXpect.Reflection/ThatProperty.IsReadWrite.cs index f5702386..59157062 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsReadWrite.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsReadWrite.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -36,7 +37,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not read-write "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -45,7 +46,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was read-write "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsReadable.cs b/Source/aweXpect.Reflection/ThatProperty.IsReadable.cs index 9a56a4da..88811c87 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsReadable.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsReadable.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -36,7 +37,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not readable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -45,7 +46,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was readable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsRequired.cs b/Source/aweXpect.Reflection/ThatProperty.IsRequired.cs index 0069894d..907ae93c 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsRequired.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsRequired.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-required "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was required "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsSealed.cs b/Source/aweXpect.Reflection/ThatProperty.IsSealed.cs index 54a04555..f7f76e15 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsSealed.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsSealed.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-sealed "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was sealed "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsStatic.cs b/Source/aweXpect.Reflection/ThatProperty.IsStatic.cs index 96855e3a..f698a066 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsStatic.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsStatic.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was static "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsVirtual.cs b/Source/aweXpect.Reflection/ThatProperty.IsVirtual.cs index 8e550795..d3598b40 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsVirtual.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsVirtual.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was non-virtual "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was virtual "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsWritable.cs b/Source/aweXpect.Reflection/ThatProperty.IsWritable.cs index d8947993..aa5579d6 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsWritable.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsWritable.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -36,7 +37,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not writable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -45,7 +46,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was writable "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.IsWriteOnly.cs b/Source/aweXpect.Reflection/ThatProperty.IsWriteOnly.cs index 4c139535..c109ebf7 100644 --- a/Source/aweXpect.Reflection/ThatProperty.IsWriteOnly.cs +++ b/Source/aweXpect.Reflection/ThatProperty.IsWriteOnly.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -36,7 +37,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was not write-only "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -45,7 +46,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" was write-only "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Source/aweXpect.Reflection/ThatProperty.Overrides.cs b/Source/aweXpect.Reflection/ThatProperty.Overrides.cs index e9c2b637..b1ac2dac 100644 --- a/Source/aweXpect.Reflection/ThatProperty.Overrides.cs +++ b/Source/aweXpect.Reflection/ThatProperty.Overrides.cs @@ -2,6 +2,7 @@ using System.Text; using aweXpect.Core; using aweXpect.Core.Constraints; +using aweXpect.Reflection.Formatting; using aweXpect.Reflection.Helpers; using aweXpect.Results; @@ -46,7 +47,7 @@ protected override void AppendNormalExpectation(StringBuilder stringBuilder, str protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did not override a base property "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) @@ -55,7 +56,7 @@ protected override void AppendNegatedExpectation(StringBuilder stringBuilder, st protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) { stringBuilder.Append(It).Append(" did override a base property "); - Formatter.Format(stringBuilder, Actual); + Formatter.Format(stringBuilder, FormattableMember.From(Actual)); } } } diff --git a/Tests/Aot/aweXpect.Reflection.Aot/Checks.cs b/Tests/Aot/aweXpect.Reflection.Aot/Checks.cs index 2c278dc5..39b3ce88 100644 --- a/Tests/Aot/aweXpect.Reflection.Aot/Checks.cs +++ b/Tests/Aot/aweXpect.Reflection.Aot/Checks.cs @@ -55,7 +55,8 @@ internal static class Checks => await That(typeof(Customer).GetProperty(nameof(Customer.Nickname))).IsNullable())), new("a non-nullable property fails to be nullable", () => ShouldFailOrFailLoudly(async () - => await That(typeof(Order).GetProperty(nameof(Order.Customer))).IsNullable(), "is nullable")), + => await That(typeof(Order).GetProperty(nameof(Order.Customer))).IsNullable(), + "it was non-nullable public Customer Order.Customer { get; }")), new("named types are sealed", () => ShouldPass(async () => await That(In.Types()).AreSealed())), new("the types of a namespace fail when one is not sealed", diff --git a/Tests/aweXpect.Reflection.Internal.Tests/Formatting/FormattableMemberTests.cs b/Tests/aweXpect.Reflection.Internal.Tests/Formatting/FormattableMemberTests.cs new file mode 100644 index 00000000..f1f86d60 --- /dev/null +++ b/Tests/aweXpect.Reflection.Internal.Tests/Formatting/FormattableMemberTests.cs @@ -0,0 +1,115 @@ +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using aweXpect.Formatting; +using aweXpect.Reflection.Formatting; +using aweXpect.Reflection.Internal.Tests.TestHelpers; + +namespace aweXpect.Reflection.Internal.Tests.Formatting; + +public class FormattableMemberTests +{ + [Fact] + public async Task From_WithConstructorInfo_ShouldFormatItWithTheConstructorFormatter() + { + ConstructorInfo constructorInfo = typeof(ConstructorFormatterTests.MyTestClass).GetConstructors().First(); + + string result = Format.Formatter.Format(FormattableMember.From(constructorInfo)); + + await That(result).IsEqualTo(new ConstructorFormatter().GetString(constructorInfo)); + } + + [Fact] + public async Task From_WithEventInfo_ShouldFormatItWithTheEventFormatter() + { + EventInfo eventInfo = typeof(EventFormatterTests.MyTestClass).GetEvents().First(); + + string result = Format.Formatter.Format(FormattableMember.From(eventInfo)); + + await That(result).IsEqualTo(new EventFormatter().GetString(eventInfo)); + } + + [Fact] + public async Task From_WithFieldInfo_ShouldFormatItWithTheFieldFormatter() + { + FieldInfo fieldInfo = typeof(FieldFormatterTests.MyTestClass).GetFields().First(); + + string result = Format.Formatter.Format(FormattableMember.From(fieldInfo)); + + await That(result).IsEqualTo(new FieldFormatter().GetString(fieldInfo)); + } + + [Fact] + public async Task From_WithMethodInfo_ShouldFormatItWithTheMethodFormatter() + { + MethodInfo methodInfo = typeof(MethodFormatterTests.MyTestClass).GetMethods().First(); + + string result = Format.Formatter.Format(FormattableMember.From(methodInfo)); + + await That(result).IsEqualTo(new MethodFormatter().GetString(methodInfo)); + } + + [Fact] + public async Task From_WithPropertyInfo_ShouldFormatItWithThePropertyFormatter() + { + PropertyInfo propertyInfo = typeof(PropertyFormatterTests.MyTestClass).GetProperties().First(); + + string result = Format.Formatter.Format(FormattableMember.From(propertyInfo)); + + await That(result).IsEqualTo(new PropertyFormatter().GetString(propertyInfo)); + } + + [Fact] + public async Task From_WithNull_ShouldReturnNull() + { + object? result = FormattableMember.From(null); + + await That(result).IsNull(); + } + + [Fact] + public async Task From_WithType_ShouldReturnTheType() + { + Type type = typeof(MethodFormatterTests.MyTestClass); + + object? result = FormattableMember.From(type); + + await That(result).IsSameAs(type) + .Because("a type is formatted by aweXpect.Core itself"); + } + + [Fact] + public async Task FromAll_ShouldFormatEachMember() + { + MethodInfo[] methods = typeof(MethodFormatterTests.MyTestClass).GetMethods().Take(2).ToArray(); + + string result = Format.Formatter.Format(FormattableMember.FromAll(methods)); + + await That(result).IsEqualTo( + $"[{new MethodFormatter().GetString(methods[0])}, {new MethodFormatter().GetString(methods[1])}]"); + } + + [Fact] + public async Task FromAll_WithCollection_ShouldKeepTheNumberOfItems() + { + MethodInfo methodInfo = typeof(MethodFormatterTests.MyTestClass).GetMethods().First(); + List methods = Enumerable.Repeat(methodInfo, 25).ToList(); + + string result = Format.Formatter.Format(FormattableMember.FromAll(methods)); + + await That(result).IsEqualTo(Format.Formatter.Format(methods.Select(FormattableMember.From).ToList())) + .Because("a truncated collection names the number of remaining items"); + } + + [Fact] + public async Task FromAll_WithLazySequence_ShouldNotKnowTheNumberOfItems() + { + MethodInfo methodInfo = typeof(MethodFormatterTests.MyTestClass).GetMethods().First(); + IEnumerable methods = Enumerable.Repeat(methodInfo, 25).Where(_ => true); + + string result = Format.Formatter.Format(FormattableMember.FromAll(methods)); + + await That(result).IsEqualTo(Format.Formatter.Format(methods.Select(FormattableMember.From))) + .Because("a lazy sequence does not know the number of remaining items"); + } +} diff --git a/Tests/aweXpect.Reflection.Internal.Tests/Formatting/FormatterRegistrationTests.cs b/Tests/aweXpect.Reflection.Internal.Tests/Formatting/FormatterRegistrationTests.cs index 44581dec..a5ae2877 100644 --- a/Tests/aweXpect.Reflection.Internal.Tests/Formatting/FormatterRegistrationTests.cs +++ b/Tests/aweXpect.Reflection.Internal.Tests/Formatting/FormatterRegistrationTests.cs @@ -1,65 +1,70 @@ using System.Linq; using System.Reflection; +using System.Runtime.CompilerServices; using aweXpect.Formatting; using aweXpect.Reflection.Formatting; -using aweXpect.Reflection.Internal.Tests.TestHelpers; namespace aweXpect.Reflection.Internal.Tests.Formatting; public class FormatterRegistrationTests { + public FormatterRegistrationTests() + { + RuntimeHelpers.RunModuleConstructor(typeof(FormattableMember).Module.ModuleHandle); + } + [Fact] - public async Task ModuleInitializer_ShouldRegisterFormatterForConstructorInfo() + public async Task ModuleInitializer_ShouldNotChangeHowConstructorInfoIsFormatted() { ConstructorInfo constructorInfo = typeof(ConstructorFormatterTests.MyTestClass).GetConstructors().First(); string result = Format.Formatter.Format(constructorInfo); - await That(result).IsEqualTo(new ConstructorFormatter().GetString(constructorInfo)) - .Because("the module initializer must have registered the ConstructorFormatter globally"); + await That(result).IsEqualTo(constructorInfo.ToString()) + .Because("the package must not register a formatter for the ConstructorInfo it does not own"); } [Fact] - public async Task ModuleInitializer_ShouldRegisterFormatterForEventInfo() + public async Task ModuleInitializer_ShouldNotChangeHowEventInfoIsFormatted() { EventInfo eventInfo = typeof(EventFormatterTests.MyTestClass).GetEvents().First(); string result = Format.Formatter.Format(eventInfo); - await That(result).IsEqualTo(new EventFormatter().GetString(eventInfo)) - .Because("the module initializer must have registered the EventFormatter globally"); + await That(result).IsEqualTo(eventInfo.ToString()) + .Because("the package must not register a formatter for the EventInfo it does not own"); } [Fact] - public async Task ModuleInitializer_ShouldRegisterFormatterForFieldInfo() + public async Task ModuleInitializer_ShouldNotChangeHowFieldInfoIsFormatted() { FieldInfo fieldInfo = typeof(FieldFormatterTests.MyTestClass).GetFields().First(); string result = Format.Formatter.Format(fieldInfo); - await That(result).IsEqualTo(new FieldFormatter().GetString(fieldInfo)) - .Because("the module initializer must have registered the FieldFormatter globally"); + await That(result).IsEqualTo(fieldInfo.ToString()) + .Because("the package must not register a formatter for the FieldInfo it does not own"); } [Fact] - public async Task ModuleInitializer_ShouldRegisterFormatterForMethodInfo() + public async Task ModuleInitializer_ShouldNotChangeHowMethodInfoIsFormatted() { MethodInfo methodInfo = typeof(MethodFormatterTests.MyTestClass).GetMethods().First(); string result = Format.Formatter.Format(methodInfo); - await That(result).IsEqualTo(new MethodFormatter().GetString(methodInfo)) - .Because("the module initializer must have registered the MethodFormatter globally"); + await That(result).IsEqualTo(methodInfo.ToString()) + .Because("the package must not register a formatter for the MethodInfo it does not own"); } [Fact] - public async Task ModuleInitializer_ShouldRegisterFormatterForPropertyInfo() + public async Task ModuleInitializer_ShouldNotChangeHowPropertyInfoIsFormatted() { PropertyInfo propertyInfo = typeof(PropertyFormatterTests.MyTestClass).GetProperties().First(); string result = Format.Formatter.Format(propertyInfo); - await That(result).IsEqualTo(new PropertyFormatter().GetString(propertyInfo)) - .Because("the module initializer must have registered the PropertyFormatter globally"); + await That(result).IsEqualTo(propertyInfo.ToString()) + .Because("the package must not register a formatter for the PropertyInfo it does not own"); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsNotObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsNotObsolete.Tests.cs index ff9add2b..3e7d1b6b 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsNotObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsNotObsolete.Tests.cs @@ -57,10 +57,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete ClassWithObsoleteMembers() """); } } @@ -82,10 +82,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete ClassWithObsoleteMembers(int value) """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsNotStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsNotStatic.Tests.cs index 04bd1c88..c7e98af3 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsNotStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsNotStatic.Tests.cs @@ -53,10 +53,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static TestClassWithStaticMembers() """); } } @@ -74,10 +74,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static TestClassWithStaticMembers() """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsObsolete.Tests.cs index 9cebdac8..f96aa37c 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsObsolete.Tests.cs @@ -25,10 +25,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete ClassWithObsoleteMembers(int value) """); } @@ -96,10 +96,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete ClassWithObsoleteMembers() """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsStatic.Tests.cs index ae7258e1..bebef5f4 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatConstructor.IsStatic.Tests.cs @@ -21,10 +21,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static TestClassWithStaticMembers() """); } @@ -88,10 +88,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static TestClassWithStaticMembers() """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.DoesNotOverride.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.DoesNotOverride.Tests.cs index 0f25e467..ae9457d2 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.DoesNotOverride.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.DoesNotOverride.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject does not override a base event, - but it did override a base event {Formatter.Format(subject)} + but it did override a base event event EventHandler ClassWithSealedMembers.VirtualEvent """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsAbstract.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsAbstract.Tests.cs index 16af9713..7616ad6b 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsAbstract.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsAbstract.Tests.cs @@ -36,10 +36,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is abstract, - but it was non-abstract {Formatter.Format(subject)} + but it was non-abstract event EventHandler AbstractClassWithMembers.VirtualEvent """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotAbstract.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotAbstract.Tests.cs index a31dc7d5..e41c58bd 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotAbstract.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotAbstract.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not abstract, - but it was abstract {Formatter.Format(subject)} + but it was abstract event EventHandler AbstractClassWithMembers.AbstractEvent """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotNullable.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotNullable.Tests.cs index e357df00..5bf7fe39 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotNullable.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotNullable.Tests.cs @@ -81,10 +81,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable event EventHandler ClassWithNullableEvents.NullableEvent """); } @@ -100,10 +100,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable event EventHandler ClassWithNullableEvents.NullableGenericEvent """); } @@ -119,10 +119,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable event EventHandler ClassWithCustomNullableEvent.NullableCustomEvent """); } @@ -155,10 +155,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable event EventHandler ClassWithNonNullableEvents.NonNullableEvent """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotObsolete.Tests.cs index 54490d0b..7804a04d 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotObsolete.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete event EventHandler ClassWithObsoleteMembers.ObsoleteEvent """); } } @@ -76,10 +76,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete event EventHandler ClassWithObsoleteMembers.NonObsoleteEvent """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotSealed.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotSealed.Tests.cs index f15e2cd8..9c7f9904 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotSealed.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotSealed.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not sealed, - but it was sealed {Formatter.Format(subject)} + but it was sealed event EventHandler ClassWithSealedMembers.VirtualEvent """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotStatic.Tests.cs index 9d7b7451..13b6c44e 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotStatic.Tests.cs @@ -53,10 +53,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static event EventHandler TestClassWithStaticMembers.StaticEvent """); } } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static event EventHandler TestClassWithStaticMembers.NonStaticEvent """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotVirtual.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotVirtual.Tests.cs index c0daf715..0bbd1d47 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotVirtual.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNotVirtual.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not virtual, - but it was virtual {Formatter.Format(subject)} + but it was virtual event EventHandler AbstractClassWithMembers.VirtualEvent """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNullable.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNullable.Tests.cs index 375d37c9..f25f0b09 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNullable.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsNullable.Tests.cs @@ -21,10 +21,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable event EventHandler ClassWithNonNullableEvents.NonNullableEvent """); } @@ -40,10 +40,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable event EventHandler ClassWithNonNullableEvents.NonNullableGenericEvent """); } @@ -59,10 +59,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable event EventHandler ClassWithMixedNullableEvents.NonNullableEvent """); } @@ -78,10 +78,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable event EventHandler ClassWithCustomNonNullableEvent.NonNullableCustomEvent """); } @@ -171,10 +171,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable event EventHandler ClassWithObliviousEvents.ObliviousEvent """); } } @@ -207,10 +207,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable event EventHandler ClassWithNullableEvents.NullableEvent """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsObsolete.Tests.cs index 6456788b..3a600dbb 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsObsolete.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete event EventHandler ClassWithObsoleteMembers.NonObsoleteEvent """); } @@ -90,10 +90,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete event EventHandler ClassWithObsoleteMembers.ObsoleteEvent """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsSealed.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsSealed.Tests.cs index ba439ac1..7379c500 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsSealed.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsSealed.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is sealed, - but it was non-sealed {Formatter.Format(subject)} + but it was non-sealed event EventHandler AbstractClassWithMembers.VirtualEvent """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsStatic.Tests.cs index 1ccc71dc..c9176ea6 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsStatic.Tests.cs @@ -21,10 +21,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static event EventHandler TestClassWithStaticMembers.NonStaticEvent """); } @@ -89,10 +89,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static event EventHandler TestClassWithStaticMembers.StaticEvent """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsVirtual.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsVirtual.Tests.cs index 175c2f44..49efa8ae 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.IsVirtual.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.IsVirtual.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is virtual, - but it was non-virtual {Formatter.Format(subject)} + but it was non-virtual event EventHandler BaseClassWithMembers.BaseEvent """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatEvent.Overrides.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatEvent.Overrides.Tests.cs index 51720f5f..2f08d113 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatEvent.Overrides.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatEvent.Overrides.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject overrides a base event, - but it did not override a base event {Formatter.Format(subject)} + but it did not override a base event event EventHandler AbstractClassWithMembers.VirtualEvent """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsConstant.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsConstant.Tests.cs index 93296025..ddf27214 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsConstant.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsConstant.Tests.cs @@ -35,10 +35,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is constant, - but it was non-constant {Formatter.Format(subject)} + but it was non-constant int TestClassWithFieldModifiers.MutableField """); } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not constant, - but it was constant {Formatter.Format(subject)} + but it was constant int TestClassWithFieldModifiers.ConstantField """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotConstant.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotConstant.Tests.cs index a76503d4..40829da4 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotConstant.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotConstant.Tests.cs @@ -21,10 +21,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not constant, - but it was constant {Formatter.Format(subject)} + but it was constant int TestClassWithFieldModifiers.ConstantField """); } @@ -89,10 +89,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is constant, - but it was non-constant {Formatter.Format(subject)} + but it was non-constant int TestClassWithFieldModifiers.MutableField """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotNullable.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotNullable.Tests.cs index 3e832a3e..1c921d8c 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotNullable.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotNullable.Tests.cs @@ -67,10 +67,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable string ClassWithNullableMembers.NullableField """); } @@ -86,10 +86,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable int? ClassWithNullableMembers.NullableValueField """); } @@ -122,10 +122,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable string ClassWithNonNullableMembers.NonNullableField """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotObsolete.Tests.cs index 33ca6da3..eb926ca2 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotObsolete.Tests.cs @@ -55,10 +55,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete int ClassWithObsoleteMembers.ObsoleteField """); } } @@ -77,10 +77,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete int ClassWithObsoleteMembers.NonObsoleteField """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotReadOnly.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotReadOnly.Tests.cs index 5a4e03d8..73300a72 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotReadOnly.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotReadOnly.Tests.cs @@ -53,10 +53,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not read-only, - but it was read-only {Formatter.Format(subject)} + but it was read-only int TestClassWithFieldModifiers.ReadOnlyField """); } } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is read-only, - but it was non-read-only {Formatter.Format(subject)} + but it was non-read-only int TestClassWithFieldModifiers.MutableField """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotRequired.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotRequired.Tests.cs index c2324042..44440d95 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotRequired.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotRequired.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not required, - but it was required {Formatter.Format(subject)} + but it was required string ClassWithRequiredMembers.RequiredField """); } } @@ -76,10 +76,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is required, - but it was non-required {Formatter.Format(subject)} + but it was non-required string ClassWithRequiredMembers.OptionalField """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotStatic.Tests.cs index 8b778e07..2aeae612 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsNotStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsNotStatic.Tests.cs @@ -53,10 +53,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static string TestClassWithStaticMembers.StaticField """); } } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static string TestClassWithStaticMembers.NonStaticField """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsNullable.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsNullable.Tests.cs index e0348810..10a6f5e2 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsNullable.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsNullable.Tests.cs @@ -21,10 +21,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable List ClassWithNonNullableMembers.NonNullableGenericField """); } @@ -40,10 +40,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable string ClassWithMostlyNullableMembers.NonNullableField """); } @@ -59,10 +59,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable string ClassWithNonNullableMembers.NonNullableField """); } @@ -78,10 +78,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable int ClassWithNonNullableMembers.NonNullableValueField """); } @@ -171,10 +171,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable string ClassWithObliviousMembers.ObliviousField """); } } @@ -207,10 +207,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable string ClassWithNullableMembers.NullableField """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsObsolete.Tests.cs index 2afc0a2c..21c56178 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsObsolete.Tests.cs @@ -23,10 +23,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete int ClassWithObsoleteMembers.NonObsoleteField """); } @@ -91,10 +91,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete int ClassWithObsoleteMembers.ObsoleteField """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsReadOnly.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsReadOnly.Tests.cs index 84409786..0b8f7326 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsReadOnly.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsReadOnly.Tests.cs @@ -21,10 +21,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is read-only, - but it was non-read-only {Formatter.Format(subject)} + but it was non-read-only int TestClassWithFieldModifiers.MutableField """); } @@ -89,10 +89,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not read-only, - but it was read-only {Formatter.Format(subject)} + but it was read-only int TestClassWithFieldModifiers.ReadOnlyField """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsRequired.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsRequired.Tests.cs index c215ac5b..c1135ca9 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsRequired.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsRequired.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is required, - but it was non-required {Formatter.Format(subject)} + but it was non-required string ClassWithRequiredMembers.OptionalField """); } @@ -90,10 +90,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not required, - but it was required {Formatter.Format(subject)} + but it was required string ClassWithRequiredMembers.RequiredField """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatField.IsStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatField.IsStatic.Tests.cs index b0aac6d6..f35c802d 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatField.IsStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatField.IsStatic.Tests.cs @@ -21,10 +21,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static string TestClassWithStaticMembers.NonStaticField """); } @@ -89,10 +89,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static string TestClassWithStaticMembers.StaticField """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.DoesNotOverride.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.DoesNotOverride.Tests.cs index 7cdad375..31bca1e6 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.DoesNotOverride.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.DoesNotOverride.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject does not override a base method, - but it did override a base method {Formatter.Format(subject)} + but it did override a base method void ClassWithSealedMembers.VirtualMethod() """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAbstract.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAbstract.Tests.cs index 0ea043b8..be6b98ec 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAbstract.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAbstract.Tests.cs @@ -36,10 +36,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is abstract, - but it was non-abstract {Formatter.Format(subject)} + but it was non-abstract void AbstractClassWithMembers.VirtualMethod() """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnExtensionMethod.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnExtensionMethod.Tests.cs index 77818052..d030dd4e 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnExtensionMethod.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnExtensionMethod.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an extension method, - but it was not an extension method {Formatter.Format(subject)} + but it was not an extension method void .Dynamic() """); } @@ -57,10 +57,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an extension method, - but it was not an extension method {Formatter.Format(subject)} + but it was not an extension method void StaticClassWithExtensionMethods.RegularStaticMethod() """); } @@ -98,10 +98,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an extension method, - but it was an extension method {Formatter.Format(subject)} + but it was an extension method bool StaticClassWithExtensionMethods.IsPositive(int value) """); } @@ -182,10 +182,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an extension method, - but it was not an extension method {Formatter.Format(subject)} + but it was not an extension method void StaticClassWithNewExtensionMethods.RegularStaticMethod() """); } @@ -202,10 +202,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an extension method, - but it was not an extension method {Formatter.Format(subject)} + but it was not an extension method string StaticClassWithNewExtensionMethods.Create(int unused) """); } @@ -222,10 +222,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an extension method, - but it was not an extension method {Formatter.Format(subject)} + but it was not an extension method string StaticClassWithNewExtensionMethods.Combine(string value) """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnOperator.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnOperator.Tests.cs index 2545e432..89e837b8 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnOperator.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnOperator.Tests.cs @@ -36,10 +36,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an operator, - but it was not an operator {Formatter.Format(subject)} + but it was not an operator int ClassWithOperators.get_Value() """); } @@ -56,10 +56,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an operator, - but it was not an operator {Formatter.Format(subject)} + but it was not an operator void ClassWithOperators.RegularMethod() """); } @@ -96,10 +96,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an operator, - but it was an operator {Formatter.Format(subject)} + but it was an operator ClassWithOperators ClassWithOperators.op_Addition(ClassWithOperators left, ClassWithOperators right) """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnOperator.WithOperator.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnOperator.WithOperator.Tests.cs index a01cceee..0ec28ff6 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnOperator.WithOperator.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAnOperator.WithOperator.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is the operator Addition, - but it was not the operator Addition {Formatter.Format(subject)} + but it was not the operator Addition ClassWithOperators ClassWithOperators.op_Subtraction(ClassWithOperators left, ClassWithOperators right) """); } @@ -42,10 +42,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is the operator Addition, - but it was not the operator Addition {Formatter.Format(subject)} + but it was not the operator Addition void ClassWithOperators.RegularMethod() """); } @@ -110,10 +110,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not the operator Addition, - but it was the operator Addition {Formatter.Format(subject)} + but it was the operator Addition ClassWithOperators ClassWithOperators.op_Addition(ClassWithOperators left, ClassWithOperators right) """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAsync.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAsync.Tests.cs index 21bdebe2..9c38bf70 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAsync.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsAsync.Tests.cs @@ -50,10 +50,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is async, - but it was non-async {Formatter.Format(subject)} + but it was non-async void ClassWithAsyncMembers.RegularMethod() """); } @@ -87,10 +87,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is async, - but it was non-async {Formatter.Format(subject)} + but it was non-async Task ClassWithAsyncMembers.NonAsyncTaskMethod() """); } } @@ -109,10 +109,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not async, - but it was async {Formatter.Format(subject)} + but it was async Task ClassWithAsyncMembers.AsyncMethod() """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAbstract.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAbstract.Tests.cs index e8058401..f8a27d93 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAbstract.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAbstract.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not abstract, - but it was abstract {Formatter.Format(subject)} + but it was abstract void AbstractClassWithMembers.AbstractMethod() """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnExtensionMethod.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnExtensionMethod.Tests.cs index e91b4db5..ba212909 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnExtensionMethod.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnExtensionMethod.Tests.cs @@ -26,10 +26,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an extension method, - but it was an extension method {Formatter.Format(subject)} + but it was an extension method bool StaticClassWithExtensionMethods.IsPositive(int value) """); } @@ -97,10 +97,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an extension method, - but it was not an extension method {Formatter.Format(subject)} + but it was not an extension method void StaticClassWithExtensionMethods.RegularStaticMethod() """); } } @@ -121,10 +121,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an extension method, - but it was an extension method {Formatter.Format(subject)} + but it was an extension method string StaticClassWithNewExtensionMethods.Create() """); } @@ -141,10 +141,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an extension method, - but it was an extension method {Formatter.Format(subject)} + but it was an extension method bool StaticClassWithNewExtensionMethods.IsLongText(string text) """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnOperator.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnOperator.Tests.cs index 8c692643..55d09e51 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnOperator.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnOperator.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an operator, - but it was an operator {Formatter.Format(subject)} + but it was an operator ClassWithOperators ClassWithOperators.op_Addition(ClassWithOperators left, ClassWithOperators right) """); } @@ -92,10 +92,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an operator, - but it was not an operator {Formatter.Format(subject)} + but it was not an operator void ClassWithOperators.RegularMethod() """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnOperator.WithOperator.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnOperator.WithOperator.Tests.cs index 7069f2d4..49902e1d 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnOperator.WithOperator.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAnOperator.WithOperator.Tests.cs @@ -69,10 +69,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not the operator Addition, - but it was the operator Addition {Formatter.Format(subject)} + but it was the operator Addition ClassWithOperators ClassWithOperators.op_Addition(ClassWithOperators left, ClassWithOperators right) """); } } @@ -91,10 +91,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is the operator Addition, - but it was not the operator Addition {Formatter.Format(subject)} + but it was not the operator Addition ClassWithOperators ClassWithOperators.op_Subtraction(ClassWithOperators left, ClassWithOperators right) """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAsync.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAsync.Tests.cs index 81b89d6c..7a8f8ded 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAsync.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotAsync.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not async, - but it was async {Formatter.Format(subject)} + but it was async Task ClassWithAsyncMembers.AsyncMethod() """); } @@ -104,10 +104,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is async, - but it was non-async {Formatter.Format(subject)} + but it was non-async void ClassWithAsyncMembers.RegularMethod() """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotObsolete.Tests.cs index db0c73ab..c5f2ca01 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotObsolete.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete void ClassWithObsoleteMembers.ObsoleteMethod() """); } } @@ -76,10 +76,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete void ClassWithObsoleteMembers.NonObsoleteMethod() """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotSealed.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotSealed.Tests.cs index db9aaf6f..0e487bda 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotSealed.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotSealed.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not sealed, - but it was sealed {Formatter.Format(subject)} + but it was sealed void ClassWithSealedMembers.VirtualMethod() """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotStatic.Tests.cs index ae797058..71e34778 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotStatic.Tests.cs @@ -53,10 +53,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static void TestClassWithStaticMembers.StaticMethod() """); } } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static void TestClassWithStaticMembers.NonStaticMethod() """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotVirtual.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotVirtual.Tests.cs index 867cb35e..73e62bb4 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotVirtual.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsNotVirtual.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not virtual, - but it was virtual {Formatter.Format(subject)} + but it was virtual void AbstractClassWithMembers.VirtualMethod() """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsObsolete.Tests.cs index 3daa9c3c..403f7dda 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsObsolete.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete void ClassWithObsoleteMembers.NonObsoleteMethod() """); } @@ -90,10 +90,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete void ClassWithObsoleteMembers.ObsoleteMethod() """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsSealed.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsSealed.Tests.cs index d83e971f..5736d5b4 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsSealed.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsSealed.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is sealed, - but it was non-sealed {Formatter.Format(subject)} + but it was non-sealed void AbstractClassWithMembers.VirtualMethod() """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsStatic.Tests.cs index cc1e2df9..f588aba5 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsStatic.Tests.cs @@ -21,10 +21,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static void TestClassWithStaticMembers.NonStaticMethod() """); } @@ -89,10 +89,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static void TestClassWithStaticMembers.StaticMethod() """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsVirtual.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsVirtual.Tests.cs index fb2dc8fb..843ddb1b 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.IsVirtual.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.IsVirtual.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is virtual, - but it was non-virtual {Formatter.Format(subject)} + but it was non-virtual void AbstractClassWithMembers.RegularMethod() """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatMethod.Overrides.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatMethod.Overrides.Tests.cs index cffd1880..3e405e5f 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatMethod.Overrides.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatMethod.Overrides.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject overrides a base method, - but it did not override a base method {Formatter.Format(subject)} + but it did not override a base method void AbstractClassWithMembers.VirtualMethod() """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.DoesNotOverride.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.DoesNotOverride.Tests.cs index fd73f267..a250dbb3 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.DoesNotOverride.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.DoesNotOverride.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject does not override a base property, - but it did override a base property {Formatter.Format(subject)} + but it did override a base property public string ClassWithSealedMembers.VirtualProperty { get; set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.HasAGetter.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.HasAGetter.Tests.cs index e607b568..f899cb85 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.HasAGetter.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.HasAGetter.Tests.cs @@ -35,10 +35,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject has a getter, - but it did not have a getter {Formatter.Format(subject)} + but it did not have a getter public string TestClassWithPropertyAccessors.WithSetterOnly { set; } """); } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject does not have a getter, - but it had a getter {Formatter.Format(subject)} + but it had a getter public string TestClassWithPropertyAccessors.WithGetterOnly { get; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.HasASetter.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.HasASetter.Tests.cs index 09da811c..8e430659 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.HasASetter.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.HasASetter.Tests.cs @@ -35,10 +35,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject has a setter, - but it did not have a setter {Formatter.Format(subject)} + but it did not have a setter public string TestClassWithPropertyAccessors.WithGetterAndInitSetter { get; set; } """); } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject does not have a setter, - but it had a setter {Formatter.Format(subject)} + but it had a setter public string TestClassWithPropertyAccessors.WithGetterAndSetter { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.HasAnInitSetter.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.HasAnInitSetter.Tests.cs index 9a25434a..2f82ee8b 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.HasAnInitSetter.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.HasAnInitSetter.Tests.cs @@ -35,10 +35,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject has an init setter, - but it did not have an init setter {Formatter.Format(subject)} + but it did not have an init setter public string TestClassWithPropertyAccessors.WithGetterAndSetter { get; set; } """); } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject does not have an init setter, - but it had an init setter {Formatter.Format(subject)} + but it had an init setter public string TestClassWithPropertyAccessors.WithGetterAndInitSetter { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAbstract.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAbstract.Tests.cs index 85355e66..ba8261a3 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAbstract.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAbstract.Tests.cs @@ -36,10 +36,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is abstract, - but it was non-abstract {Formatter.Format(subject)} + but it was non-abstract public string AbstractClassWithMembers.VirtualProperty { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAnExtensionProperty.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAnExtensionProperty.Tests.cs index 4db9bb34..595c4b7b 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAnExtensionProperty.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAnExtensionProperty.Tests.cs @@ -25,10 +25,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an extension property, - but it was not an extension property {Formatter.Format(subject)} + but it was not an extension property public string ClassWithRequiredMembers.OptionalProperty { get; set; } """); } @@ -97,10 +97,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an extension property, - but it was an extension property {Formatter.Format(subject)} + but it was an extension property public bool StaticClassWithNewExtensionProperties.$34505F560D9EACF86A87F3ED1F85E448.IsBlankText { get; } """); } @@ -131,10 +131,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an extension property, - but it was not an extension property {Formatter.Format(subject)} + but it was not an extension property public int StaticClassWithNewExtensionProperties.RegularProperty { get; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAnIndexer.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAnIndexer.Tests.cs index 7468f7dd..10b0390f 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAnIndexer.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsAnIndexer.Tests.cs @@ -35,10 +35,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an indexer, - but it was not an indexer {Formatter.Format(subject)} + but it was not an indexer public string TestClassWithIndexers.RegularProperty { get; set; } """); } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an indexer, - but it was an indexer {Formatter.Format(subject)} + but it was an indexer public string TestClassWithIndexers.Item { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAbstract.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAbstract.Tests.cs index 66e9a019..1366425f 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAbstract.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAbstract.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not abstract, - but it was abstract {Formatter.Format(subject)} + but it was abstract public string AbstractClassWithMembers.AbstractProperty { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAnExtensionProperty.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAnExtensionProperty.Tests.cs index 3a5bce1e..fdf44a85 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAnExtensionProperty.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAnExtensionProperty.Tests.cs @@ -60,10 +60,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an extension property, - but it was not an extension property {Formatter.Format(subject)} + but it was not an extension property public string ClassWithRequiredMembers.OptionalProperty { get; set; } """); } } @@ -83,10 +83,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an extension property, - but it was an extension property {Formatter.Format(subject)} + but it was an extension property public bool StaticClassWithNewExtensionProperties.$34505F560D9EACF86A87F3ED1F85E448.IsBlankText { get; } """); } @@ -102,10 +102,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an extension property, - but it was an extension property {Formatter.Format(subject)} + but it was an extension property public string StaticClassWithNewExtensionProperties.$34505F560D9EACF86A87F3ED1F85E448.DefaultValue { get; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAnIndexer.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAnIndexer.Tests.cs index 4e183099..6bcb5f79 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAnIndexer.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotAnIndexer.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not an indexer, - but it was an indexer {Formatter.Format(subject)} + but it was an indexer public string TestClassWithIndexers.Item { get; set; } """); } @@ -90,10 +90,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is an indexer, - but it was not an indexer {Formatter.Format(subject)} + but it was not an indexer public string TestClassWithIndexers.RegularProperty { get; set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotNullable.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotNullable.Tests.cs index 4cf8b8a1..fc117c2e 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotNullable.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotNullable.Tests.cs @@ -67,10 +67,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable public string ClassWithNullableMembers.NullableProperty { get; set; } """); } @@ -86,10 +86,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable public int? ClassWithNullableMembers.NullableValueProperty { get; set; } """); } @@ -122,10 +122,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable public string ClassWithNonNullableMembers.NonNullableProperty { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotObsolete.Tests.cs index 737e240d..9eb0b544 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotObsolete.Tests.cs @@ -55,10 +55,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete public int ClassWithObsoleteMembers.ObsoleteProperty { get; set; } """); } } @@ -77,10 +77,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete public int ClassWithObsoleteMembers.NonObsoleteProperty { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotRequired.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotRequired.Tests.cs index 1db27bfa..bdebaa57 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotRequired.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotRequired.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not required, - but it was required {Formatter.Format(subject)} + but it was required public string ClassWithRequiredMembers.RequiredProperty { get; set; } """); } } @@ -76,10 +76,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is required, - but it was non-required {Formatter.Format(subject)} + but it was non-required public string ClassWithRequiredMembers.OptionalProperty { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotSealed.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotSealed.Tests.cs index ba53bfbd..bc4c2244 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotSealed.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotSealed.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not sealed, - but it was sealed {Formatter.Format(subject)} + but it was sealed public string ClassWithSealedMembers.VirtualProperty { get; set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotStatic.Tests.cs index 935aac35..ebb946e6 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotStatic.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static public string TestClassWithStaticMembers.StaticProperty { get; set; } """); } } @@ -77,10 +77,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static public string TestClassWithStaticMembers.NonStaticProperty { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotVirtual.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotVirtual.Tests.cs index 992ecffa..64e1b660 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotVirtual.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNotVirtual.Tests.cs @@ -54,10 +54,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not virtual, - but it was virtual {Formatter.Format(subject)} + but it was virtual public string AbstractClassWithMembers.VirtualProperty { get; set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNullable.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNullable.Tests.cs index 016c6dd9..4fe3faf0 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNullable.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsNullable.Tests.cs @@ -21,10 +21,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable public List ClassWithNonNullableMembers.NonNullableGenericProperty { get; set; } """); } @@ -40,10 +40,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable public string ClassWithMostlyNullableMembers.NonNullableProperty { get; set; } """); } @@ -59,10 +59,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable public string ClassWithNonNullableMembers.NonNullableProperty { get; set; } """); } @@ -78,10 +78,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable public int ClassWithNonNullableMembers.NonNullableValueProperty { get; set; } """); } @@ -171,10 +171,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is nullable, - but it was non-nullable {Formatter.Format(subject)} + but it was non-nullable public string ClassWithObliviousMembers.ObliviousProperty { get; set; } """); } @@ -221,10 +221,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not nullable, - but it was nullable {Formatter.Format(subject)} + but it was nullable public string ClassWithNullableMembers.NullableProperty { get; set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsObsolete.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsObsolete.Tests.cs index 9e632fc9..8aa0882c 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsObsolete.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsObsolete.Tests.cs @@ -23,10 +23,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is obsolete, - but it was non-obsolete {Formatter.Format(subject)} + but it was non-obsolete public int ClassWithObsoleteMembers.NonObsoleteProperty { get; set; } """); } @@ -91,10 +91,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not obsolete, - but it was obsolete {Formatter.Format(subject)} + but it was obsolete public int ClassWithObsoleteMembers.ObsoleteProperty { get; set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadOnly.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadOnly.Tests.cs index c2caaa3d..58c05e97 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadOnly.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadOnly.Tests.cs @@ -53,10 +53,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is read-only, - but it was not read-only {Formatter.Format(subject)} + but it was not read-only public string TestClassWithReadWriteProperties.ReadWriteProperty { get; set; } """); } } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not read-only, - but it was read-only {Formatter.Format(subject)} + but it was read-only public string TestClassWithReadWriteProperties.ReadOnlyProperty { get; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadWrite.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadWrite.Tests.cs index 9bddc379..90cf6814 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadWrite.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadWrite.Tests.cs @@ -39,10 +39,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is read-write, - but it was not read-write {Formatter.Format(subject)} + but it was not read-write public string TestClassWithReadWriteProperties.ReadOnlyProperty { get; } """); } @@ -89,10 +89,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not read-write, - but it was read-write {Formatter.Format(subject)} + but it was read-write public string TestClassWithReadWriteProperties.ReadWriteProperty { get; set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadable.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadable.Tests.cs index 5c66b27f..94900af3 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadable.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsReadable.Tests.cs @@ -53,10 +53,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is readable, - but it was not readable {Formatter.Format(subject)} + but it was not readable public string TestClassWithReadWriteProperties.WriteOnlyProperty { set; } """); } } @@ -75,10 +75,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not readable, - but it was readable {Formatter.Format(subject)} + but it was readable public string TestClassWithReadWriteProperties.ReadOnlyProperty { get; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsRequired.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsRequired.Tests.cs index 6797a358..578fc995 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsRequired.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsRequired.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is required, - but it was non-required {Formatter.Format(subject)} + but it was non-required public string ClassWithRequiredMembers.OptionalProperty { get; set; } """); } @@ -90,10 +90,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not required, - but it was required {Formatter.Format(subject)} + but it was required public string ClassWithRequiredMembers.RequiredProperty { get; set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsSealed.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsSealed.Tests.cs index 86f6d2e8..f7b801fc 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsSealed.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsSealed.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is sealed, - but it was non-sealed {Formatter.Format(subject)} + but it was non-sealed public string AbstractClassWithMembers.VirtualProperty { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsStatic.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsStatic.Tests.cs index ce755e0f..cbde9996 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsStatic.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsStatic.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is static, - but it was non-static {Formatter.Format(subject)} + but it was non-static public string TestClassWithStaticMembers.NonStaticProperty { get; set; } """); } @@ -91,10 +91,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not static, - but it was static {Formatter.Format(subject)} + but it was static public string TestClassWithStaticMembers.StaticProperty { get; set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsVirtual.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsVirtual.Tests.cs index cf4ed608..75e29bf4 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsVirtual.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsVirtual.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is virtual, - but it was non-virtual {Formatter.Format(subject)} + but it was non-virtual public int BaseClassWithMembers.BaseProperty { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsWritable.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsWritable.Tests.cs index 03183615..d32d8d67 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsWritable.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsWritable.Tests.cs @@ -39,10 +39,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is writable, - but it was not writable {Formatter.Format(subject)} + but it was not writable public string TestClassWithReadWriteProperties.ReadOnlyProperty { get; } """); } @@ -89,10 +89,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not writable, - but it was writable {Formatter.Format(subject)} + but it was writable public string TestClassWithReadWriteProperties.WriteOnlyProperty { set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsWriteOnly.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsWriteOnly.Tests.cs index e2a95cf4..a87bffd4 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.IsWriteOnly.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.IsWriteOnly.Tests.cs @@ -39,10 +39,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is write-only, - but it was not write-only {Formatter.Format(subject)} + but it was not write-only public string TestClassWithReadWriteProperties.ReadWriteProperty { get; set; } """); } @@ -89,10 +89,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject is not write-only, - but it was write-only {Formatter.Format(subject)} + but it was write-only public string TestClassWithReadWriteProperties.WriteOnlyProperty { set; } """); } } diff --git a/Tests/aweXpect.Reflection.Tests/ThatProperty.Overrides.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatProperty.Overrides.Tests.cs index a9b11c85..c6864656 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatProperty.Overrides.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatProperty.Overrides.Tests.cs @@ -22,10 +22,10 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject overrides a base property, - but it did not override a base property {Formatter.Format(subject)} + but it did not override a base property public string AbstractClassWithMembers.VirtualProperty { get; set; } """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatType.OnlyHasNonNullableMembers.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatType.OnlyHasNonNullableMembers.Tests.cs index 3673ed56..28b6699a 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatType.OnlyHasNonNullableMembers.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatType.OnlyHasNonNullableMembers.Tests.cs @@ -1,5 +1,4 @@ -using System.Reflection; -using aweXpect.Reflection.Tests.TestHelpers.Types; +using aweXpect.Reflection.Tests.TestHelpers.Types; namespace aweXpect.Reflection.Tests; @@ -49,8 +48,6 @@ async Task Act() public async Task WhenTypeHasNullableMembers_ShouldFail() { Type subject = typeof(ClassWithSingleNullableProperty); - PropertyInfo property = subject - .GetProperty(nameof(ClassWithSingleNullableProperty.NullableProperty))!; async Task Act() { @@ -58,14 +55,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only has non-nullable members, but it contained nullable members Nullable members: [ - {Formatter.Format(property)} + public string ClassWithSingleNullableProperty.NullableProperty { get; set; } ] """); } @@ -74,8 +71,6 @@ but it contained nullable members public async Task WhenTypeHasNullableEvent_ShouldFail() { Type subject = typeof(ClassWithSingleNullableEvent); - EventInfo @event = subject - .GetEvent(nameof(ClassWithSingleNullableEvent.NullableEvent))!; async Task Act() { @@ -83,14 +78,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only has non-nullable members, but it contained nullable members Nullable members: [ - {Formatter.Format(@event)} + event EventHandler ClassWithSingleNullableEvent.NullableEvent ] """); } @@ -142,11 +137,6 @@ async Task Act() [Fact] public async Task WhenUsedInThatAll_ShouldListTheNullableMembersOfEachFailure() { - PropertyInfo property = typeof(ClassWithSingleNullableProperty) - .GetProperty(nameof(ClassWithSingleNullableProperty.NullableProperty))!; - EventInfo @event = typeof(ClassWithSingleNullableEvent) - .GetEvent(nameof(ClassWithSingleNullableEvent.NullableEvent))!; - async Task Act() { await ThatAll( @@ -155,7 +145,7 @@ await ThatAll( } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected all of the following to succeed: [01] Expected that typeof(ClassWithSingleNullableProperty) only has non-nullable members [02] Expected that typeof(ClassWithSingleNullableEvent) only has non-nullable members @@ -165,12 +155,12 @@ [02] it contained nullable members [01] Nullable members: [ - {Formatter.Format(property)} + public string ClassWithSingleNullableProperty.NullableProperty { get; set; } ] [02] Nullable members: [ - {Formatter.Format(@event)} + event EventHandler ClassWithSingleNullableEvent.NullableEvent ] """); } @@ -213,8 +203,6 @@ async Task Act() public async Task WhenTypeOnlyHasNonNullableMembers_ShouldFail() { Type subject = typeof(ClassWithSingleNonNullableProperty); - PropertyInfo property = subject - .GetProperty(nameof(ClassWithSingleNonNullableProperty.NonNullableProperty))!; async Task Act() { @@ -222,14 +210,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject does not only have non-nullable members, but it only contained non-nullable members Non-nullable members: [ - {Formatter.Format(property)} + public string ClassWithSingleNonNullableProperty.NonNullableProperty { get; set; } ] """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatType.OnlyHasNullableMembers.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatType.OnlyHasNullableMembers.Tests.cs index 3aed1669..f1023991 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatType.OnlyHasNullableMembers.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatType.OnlyHasNullableMembers.Tests.cs @@ -1,5 +1,4 @@ -using System.Reflection; -using aweXpect.Reflection.Collections; +using aweXpect.Reflection.Collections; using aweXpect.Reflection.Tests.TestHelpers.Types; namespace aweXpect.Reflection.Tests; @@ -76,8 +75,6 @@ async Task Act() public async Task WhenTypeHasNonNullableMembers_ShouldFail() { Type subject = typeof(ClassWithSingleNonNullableProperty); - PropertyInfo property = subject - .GetProperty(nameof(ClassWithSingleNonNullableProperty.NonNullableProperty))!; async Task Act() { @@ -85,14 +82,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only has nullable members, but it contained non-nullable members Non-nullable members: [ - {Formatter.Format(property)} + public string ClassWithSingleNonNullableProperty.NonNullableProperty { get; set; } ] """); } @@ -101,8 +98,6 @@ but it contained non-nullable members public async Task WhenTypeHasNonNullableEvent_ShouldFail() { Type subject = typeof(ClassWithSingleNonNullableEvent); - EventInfo @event = subject - .GetEvent(nameof(ClassWithSingleNonNullableEvent.NonNullableEvent))!; async Task Act() { @@ -110,14 +105,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only has nullable members, but it contained non-nullable members Non-nullable members: [ - {Formatter.Format(@event)} + event EventHandler ClassWithSingleNonNullableEvent.NonNullableEvent ] """); } @@ -174,8 +169,6 @@ public async Task WhenUsedForItems_ShouldListTheNonNullableMembersOfTheFailingIt typeof(ClassWithNullableMembers), typeof(ClassWithSingleNonNullableProperty), typeof(ClassWithSingleNonNullableEvent), ]; - PropertyInfo property = typeof(ClassWithSingleNonNullableProperty) - .GetProperty(nameof(ClassWithSingleNonNullableProperty.NonNullableProperty))!; async Task Act() { @@ -183,7 +176,7 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only has nullable members for all items, but only 1 of 3 did @@ -203,7 +196,7 @@ but only 1 of 3 did Non-nullable members (item [1]): [ - {Formatter.Format(property)} + public string ClassWithSingleNonNullableProperty.NonNullableProperty { get; set; } ] """); } @@ -212,8 +205,6 @@ but only 1 of 3 did public async Task WithIncludingInherited_WhenBaseTypeHasNonNullableEvent_ShouldFail() { Type subject = typeof(DerivedClassWithNullableEvent); - EventInfo @event = subject - .GetEvent(nameof(ClassWithSingleNonNullableEvent.NonNullableEvent))!; async Task Act() { @@ -221,14 +212,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only has nullable members, but it contained non-nullable members Non-nullable members: [ - {Formatter.Format(@event)} + event EventHandler ClassWithSingleNonNullableEvent.NonNullableEvent ] """); } @@ -273,8 +264,6 @@ async Task Act() public async Task WithIncludingInherited_WhenBaseTypeHasPrivateNonNullableEvent_ShouldFail() { Type subject = typeof(DerivedClassWithPrivateNonNullableBaseEvent); - EventInfo @event = typeof(BaseClassWithPrivateNonNullableEvent) - .GetEvent("PrivateNonNullableEvent", BindingFlags.NonPublic | BindingFlags.Instance)!; async Task Act() { @@ -282,14 +271,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only has nullable members, but it contained non-nullable members Non-nullable members: [ - {Formatter.Format(@event)} + event EventHandler BaseClassWithPrivateNonNullableEvent.PrivateNonNullableEvent ] """); } @@ -332,8 +321,6 @@ async Task Act() public async Task WhenTypeOnlyHasNullableMembers_ShouldFail() { Type subject = typeof(ClassWithSingleNullableProperty); - PropertyInfo property = subject - .GetProperty(nameof(ClassWithSingleNullableProperty.NullableProperty))!; async Task Act() { @@ -341,14 +328,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject does not only have nullable members, but it only contained nullable members Nullable members: [ - {Formatter.Format(property)} + public string ClassWithSingleNullableProperty.NullableProperty { get; set; } ] """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatTypes.OnlyHaveNonNullableMembers.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatTypes.OnlyHaveNonNullableMembers.Tests.cs index 7c96a38b..6fcb7310 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatTypes.OnlyHaveNonNullableMembers.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatTypes.OnlyHaveNonNullableMembers.Tests.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Reflection; using aweXpect.Reflection.Tests.TestHelpers.Types; #if NET8_0_OR_GREATER using aweXpect.Reflection.Tests.TestHelpers; @@ -66,8 +65,6 @@ public async Task WhenTypesContainTypeWithNullableMembers_ShouldFail() typeof(ClassWithNonNullableMembers), typeof(ClassWithSingleNullableProperty), ]; - PropertyInfo property = typeof(ClassWithSingleNullableProperty) - .GetProperty(nameof(ClassWithSingleNullableProperty.NullableProperty))!; async Task Act() { @@ -75,14 +72,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only have non-nullable members, but it contained types with nullable members Not matching items: [ - ClassWithSingleNullableProperty with nullable members [{Formatter.Format(property)}] + ClassWithSingleNullableProperty with nullable members [public string ClassWithSingleNullableProperty.NullableProperty { get; set; }] ] """); } diff --git a/Tests/aweXpect.Reflection.Tests/ThatTypes.OnlyHaveNullableMembers.Tests.cs b/Tests/aweXpect.Reflection.Tests/ThatTypes.OnlyHaveNullableMembers.Tests.cs index 2496aeed..db6ae371 100644 --- a/Tests/aweXpect.Reflection.Tests/ThatTypes.OnlyHaveNullableMembers.Tests.cs +++ b/Tests/aweXpect.Reflection.Tests/ThatTypes.OnlyHaveNullableMembers.Tests.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Reflection; using aweXpect.Reflection.Tests.TestHelpers.Types; #if NET8_0_OR_GREATER using aweXpect.Reflection.Tests.TestHelpers; @@ -66,8 +65,6 @@ public async Task WhenMultipleTypesDoNotComply_ShouldListAllWithComma() typeof(ClassWithSingleNonNullableProperty), null, ]; - PropertyInfo property = typeof(ClassWithSingleNonNullableProperty) - .GetProperty(nameof(ClassWithSingleNonNullableProperty.NonNullableProperty))!; async Task Act() { @@ -75,14 +72,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only have nullable members, but it contained types with non-nullable members Not matching items: [ - ClassWithSingleNonNullableProperty with non-nullable members [{Formatter.Format(property)}], + ClassWithSingleNonNullableProperty with non-nullable members [public string ClassWithSingleNonNullableProperty.NonNullableProperty { get; set; }], ] """); @@ -96,8 +93,6 @@ public async Task WhenTypesContainTypeWithNonNullableMembers_ShouldFail() typeof(ClassWithNullableMembers), typeof(ClassWithSingleNonNullableProperty), ]; - PropertyInfo property = typeof(ClassWithSingleNonNullableProperty) - .GetProperty(nameof(ClassWithSingleNonNullableProperty.NonNullableProperty))!; async Task Act() { @@ -105,14 +100,14 @@ async Task Act() } await That(Act).Throws() - .WithMessage($""" + .WithMessage(""" Expected that subject only have nullable members, but it contained types with non-nullable members Not matching items: [ - ClassWithSingleNonNullableProperty with non-nullable members [{Formatter.Format(property)}] + ClassWithSingleNonNullableProperty with non-nullable members [public string ClassWithSingleNonNullableProperty.NonNullableProperty { get; set; }] ] """); }