{"repo_name": "AwesomeAssertions", "file_name": "/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/XAttributeEquivalencyStep.cs", "inference_info": {"prefix_code": "using System.Xml.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class XAttributeEquivalencyStep : EquivalencyStep\n{\n ", "suffix_code": "\n}\n", "middle_code": "protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subject = (XAttribute)comparands.Subject;\n var expectation = (XAttribute)comparands.Expectation;\n AssertionChain.GetOrCreate().For(context).ReuseOnce();\n subject.Should().Be(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n return EquivalencyResult.EquivalencyProven;\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "c_sharp", "sub_task_type": null}, "context_code": [["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/XDocumentEquivalencyStep.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class XDocumentEquivalencyStep : EquivalencyStep\n{\n protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subject = (XDocument)comparands.Subject;\n var expectation = (XDocument)comparands.Expectation;\n\n AssertionChain.GetOrCreate().For(context).ReuseOnce();\n\n subject.Should().BeEquivalentTo(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n\n return EquivalencyResult.EquivalencyProven;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/XElementEquivalencyStep.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class XElementEquivalencyStep : EquivalencyStep\n{\n protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subject = (XElement)comparands.Subject;\n var expectation = (XElement)comparands.Expectation;\n\n AssertionChain.GetOrCreate().For(context).ReuseOnce();\n\n subject.Should().BeEquivalentTo(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n\n return EquivalencyResult.EquivalencyProven;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/StringEqualityEquivalencyStep.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class StringEqualityEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n Type expectationType = comparands.GetExpectedType(context.Options);\n\n if (expectationType is null || expectationType != typeof(string))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (!ValidateAgainstNulls(assertionChain, comparands, context.CurrentNode))\n {\n return EquivalencyResult.EquivalencyProven;\n }\n\n bool subjectIsString = ValidateSubjectIsString(assertionChain, comparands, context.CurrentNode);\n\n if (subjectIsString)\n {\n string subject = (string)comparands.Subject;\n string expectation = (string)comparands.Expectation;\n\n assertionChain.ReuseOnce();\n subject.Should()\n .Be(expectation, CreateOptions(context.Options), context.Reason.FormattedMessage, context.Reason.Arguments);\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static Func, EquivalencyOptions>\n CreateOptions(IEquivalencyOptions existingOptions) =>\n o =>\n {\n if (existingOptions is EquivalencyOptions equivalencyOptions)\n {\n return equivalencyOptions;\n }\n\n if (existingOptions.IgnoreLeadingWhitespace)\n {\n o.IgnoringLeadingWhitespace();\n }\n\n if (existingOptions.IgnoreTrailingWhitespace)\n {\n o.IgnoringTrailingWhitespace();\n }\n\n if (existingOptions.IgnoreCase)\n {\n o.IgnoringCase();\n }\n\n if (existingOptions.IgnoreNewlineStyle)\n {\n o.IgnoringNewlineStyle();\n }\n\n return o;\n };\n\n private static bool ValidateAgainstNulls(AssertionChain assertionChain, Comparands comparands, INode currentNode)\n {\n object expected = comparands.Expectation;\n object subject = comparands.Subject;\n\n bool onlyOneNull = expected is null != subject is null;\n\n if (onlyOneNull)\n {\n assertionChain.FailWith(\n $\"Expected {currentNode.Subject.Description.EscapePlaceholders()} to be {{0}}{{reason}}, but found {{1}}.\", expected, subject);\n\n return false;\n }\n\n return true;\n }\n\n private static bool ValidateSubjectIsString(AssertionChain assertionChain, Comparands comparands, INode currentNode)\n {\n if (comparands.Subject is string)\n {\n return true;\n }\n\n assertionChain.FailWith(\n $\"Expected {currentNode} to be {{0}}, but found {{1}}.\",\n comparands.RuntimeType, comparands.Subject.GetType());\n\n return assertionChain.Succeeded;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/DictionaryEquivalencyStep.cs", "using System.Collections;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class DictionaryEquivalencyStep : EquivalencyStep\n{\n [SuppressMessage(\"ReSharper\", \"PossibleNullReferenceException\")]\n protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subject = comparands.Subject as IDictionary;\n var expectation = comparands.Expectation as IDictionary;\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (PreconditionsAreMet(expectation, subject, assertionChain) && expectation is not null)\n {\n foreach (object key in expectation.Keys)\n {\n if (context.Options.IsRecursive)\n {\n context.Tracer.WriteLine(member =>\n Invariant($\"Recursing into dictionary item {key} at {member.Expectation}\"));\n\n nestedValidator.AssertEquivalencyOf(new Comparands(subject[key], expectation[key], typeof(object)), context.AsDictionaryItem(key));\n }\n else\n {\n context.Tracer.WriteLine(member =>\n Invariant(\n $\"Comparing dictionary item {key} at {member.Expectation} between subject and expectation\"));\n\n assertionChain.WithCallerPostfix($\"[{key.ToFormattedString()}]\").ReuseOnce();\n subject[key].Should().Be(expectation[key], context.Reason.FormattedMessage, context.Reason.Arguments);\n }\n }\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static bool PreconditionsAreMet(IDictionary expectation, IDictionary subject, AssertionChain assertionChain)\n {\n return AssertIsDictionary(subject, assertionChain)\n && AssertEitherIsNotNull(expectation, subject, assertionChain)\n && AssertSameLength(expectation, subject, assertionChain);\n }\n\n private static bool AssertEitherIsNotNull(IDictionary expectation, IDictionary subject, AssertionChain assertionChain)\n {\n assertionChain\n .ForCondition((expectation is null && subject is null) || expectation is not null)\n .FailWith(\"Expected {context:subject} to be {0}{reason}, but found {1}.\", null, subject);\n\n return assertionChain.Succeeded;\n }\n\n private static bool AssertIsDictionary(IDictionary subject, AssertionChain assertionChain)\n {\n assertionChain\n .ForCondition(subject is not null)\n .FailWith(\"Expected {context:subject} to be a dictionary, but it is not.\");\n\n return assertionChain.Succeeded;\n }\n\n private static bool AssertSameLength(IDictionary expectation, IDictionary subject, AssertionChain assertionChain)\n {\n assertionChain\n .ForCondition(expectation is null || subject.Keys.Count == expectation.Keys.Count)\n .FailWith(\"Expected {context:subject} to be a dictionary with {0} item(s), but it only contains {1} item(s).\",\n expectation?.Keys.Count, subject?.Keys.Count);\n\n return assertionChain.Succeeded;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/ValueTypeEquivalencyStep.cs", "using System;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Ensures that types that are marked as value types are treated as such.\n/// \npublic class ValueTypeEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n Type expectationType = comparands.GetExpectedType(context.Options);\n EqualityStrategy strategy = context.Options.GetEqualityStrategy(expectationType);\n\n bool canHandle = strategy is EqualityStrategy.Equals or EqualityStrategy.ForceEquals;\n\n if (canHandle)\n {\n context.Tracer.WriteLine(member =>\n {\n string strategyName = strategy == EqualityStrategy.Equals\n ? $\"{expectationType} overrides Equals\"\n : \"we are forced to use Equals\";\n\n return $\"Treating {member.Expectation.Description} as a value type because {strategyName}.\";\n });\n\n AssertionChain.GetOrCreate()\n .For(context)\n .ReuseOnce();\n\n comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EqualityComparerEquivalencyStep.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class EqualityComparerEquivalencyStep : IEquivalencyStep\n{\n private readonly IEqualityComparer comparer;\n\n public EqualityComparerEquivalencyStep(IEqualityComparer comparer)\n {\n this.comparer = comparer ?? throw new ArgumentNullException(nameof(comparer));\n }\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n var expectedType = context.Options.UseRuntimeTyping ? comparands.RuntimeType : comparands.CompileTimeType;\n\n if (expectedType != typeof(T))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (comparands.Subject is null || comparands.Expectation is null)\n {\n // The later check for `comparands.Subject is T` leads to a failure even if the expectation is null.\n return EquivalencyResult.ContinueWithNext;\n }\n\n AssertionChain.GetOrCreate()\n .For(context)\n .BecauseOf(context.Reason.FormattedMessage, context.Reason.Arguments)\n .ForCondition(comparands.Subject is T)\n .FailWith(\"Expected {context:object} to be of type {0}{because}, but found {1}\", typeof(T), comparands.Subject)\n .Then\n .Given(() => comparer.Equals((T)comparands.Subject, (T)comparands.Expectation))\n .ForCondition(isEqual => isEqual)\n .FailWith(\"Expected {context:object} to be equal to {1} according to {0}{because}, but {2} was not.\",\n comparer.ToString(), comparands.Expectation, comparands.Subject);\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n public override string ToString()\n {\n return $\"Use {comparer} for objects of type {typeof(T).ToFormattedString()}\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/SimpleEqualityEquivalencyStep.cs", "using AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class SimpleEqualityEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!context.Options.IsRecursive && !context.CurrentNode.IsRoot)\n {\n AssertionChain.GetOrCreate()\n .For(context)\n .ReuseOnce();\n\n comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/StructuralEqualityEquivalencyStep.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class StructuralEqualityEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!context.CurrentNode.IsRoot && !context.Options.IsRecursive)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (comparands.Expectation is null)\n {\n assertionChain\n .BecauseOf(context.Reason)\n .FailWith(\n \"Expected {context:subject} to be {reason}, but found {0}.\",\n comparands.Subject);\n }\n else if (comparands.Subject is null)\n {\n assertionChain\n .BecauseOf(context.Reason)\n .FailWith(\n \"Expected {context:object} to be {0}{reason}, but found {1}.\",\n comparands.Expectation,\n comparands.Subject);\n }\n else\n {\n IMember[] selectedMembers = GetMembersFromExpectation(context.CurrentNode, comparands, context.Options).ToArray();\n\n if (context.CurrentNode.IsRoot && selectedMembers.Length == 0)\n {\n throw new InvalidOperationException(\n \"No members were found for comparison. \" +\n \"Please specify some members to include in the comparison or choose a more meaningful assertion.\");\n }\n\n foreach (IMember selectedMember in selectedMembers)\n {\n AssertMemberEquality(comparands, context, valueChildNodes, selectedMember, context.Options);\n }\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static void AssertMemberEquality(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency parent, IMember selectedMember, IEquivalencyOptions options)\n {\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n IMember matchingMember = FindMatchFor(selectedMember, context.CurrentNode, comparands.Subject, options, assertionChain);\n if (matchingMember is not null)\n {\n var nestedComparands = new Comparands\n {\n Subject = matchingMember.GetValue(comparands.Subject),\n Expectation = selectedMember.GetValue(comparands.Expectation),\n CompileTimeType = selectedMember.Type\n };\n\n // In case the matching process selected a different member on the subject,\n // adjust the current member so that assertion failures report the proper name.\n selectedMember.AdjustForRemappedSubject(matchingMember);\n\n parent.AssertEquivalencyOf(nestedComparands, context.AsNestedMember(selectedMember));\n }\n }\n\n private static IMember FindMatchFor(IMember selectedMember, INode currentNode, object subject,\n IEquivalencyOptions config, AssertionChain assertionChain)\n {\n IEnumerable query =\n from rule in config.MatchingRules\n let match = rule.Match(selectedMember, subject, currentNode, config, assertionChain)\n where match is not null\n select match;\n\n if (config.IgnoreNonBrowsableOnSubject)\n {\n query = query.Where(member => member.IsBrowsable);\n }\n\n return query.FirstOrDefault();\n }\n\n private static IEnumerable GetMembersFromExpectation(INode currentNode, Comparands comparands,\n IEquivalencyOptions options)\n {\n IEnumerable members = [];\n\n foreach (IMemberSelectionRule rule in options.SelectionRules)\n {\n members = rule.SelectMembers(currentNode, members,\n new MemberSelectionContext(comparands.CompileTimeType, comparands.RuntimeType, options));\n }\n\n return members;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class GenericDictionaryEquivalencyStep : IEquivalencyStep\n{\n#pragma warning disable SA1110 // Allow opening parenthesis on new line to reduce line length\n private static readonly MethodInfo AssertDictionaryEquivalenceMethod =\n new Action, IDictionary>\n (AssertDictionaryEquivalence).GetMethodInfo().GetGenericMethodDefinition();\n#pragma warning restore SA1110\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expectation is null)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n Type expectationType = comparands.GetExpectedType(context.Options);\n\n if (DictionaryInterfaceInfo.FindFrom(expectationType, \"expectation\") is not { } expectedDictionary)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (IsNonGenericDictionary(comparands.Subject))\n {\n // Because we handle non-generic dictionaries later\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (IsNotNull(assertionChain, comparands.Subject)\n && EnsureSubjectIsOfTheExpectedDictionaryType(assertionChain, comparands, expectedDictionary) is { } actualDictionary)\n {\n AssertDictionaryEquivalence(comparands, assertionChain, context, valueChildNodes, actualDictionary,\n expectedDictionary);\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static bool IsNonGenericDictionary(object subject)\n {\n if (subject is not IDictionary)\n {\n return false;\n }\n\n return !subject.GetType().GetInterfaces().Any(@interface =>\n @interface.IsGenericType && @interface.GetGenericTypeDefinition() == typeof(IDictionary<,>));\n }\n\n private static bool IsNotNull(AssertionChain assertionChain, object subject)\n {\n assertionChain\n .ForCondition(subject is not null)\n .FailWith(\"Expected {context:Subject} not to be {0}{reason}.\", new object[] { null });\n\n return assertionChain.Succeeded;\n }\n\n private static DictionaryInterfaceInfo EnsureSubjectIsOfTheExpectedDictionaryType(AssertionChain assertionChain,\n Comparands comparands,\n DictionaryInterfaceInfo expectedDictionary)\n {\n var actualDictionary = DictionaryInterfaceInfo.FindFromWithKey(comparands.Subject.GetType(), \"subject\",\n expectedDictionary.Key);\n\n if (actualDictionary is null && expectedDictionary.ConvertFrom(comparands.Subject) is { } convertedSubject)\n {\n comparands.Subject = convertedSubject;\n actualDictionary = DictionaryInterfaceInfo.FindFrom(comparands.Subject.GetType(), \"subject\");\n }\n\n if (actualDictionary is null)\n {\n assertionChain.FailWith(\n \"Expected {context:subject} to be a dictionary or collection of key-value pairs that is keyed to \" +\n \"type {0}.\", expectedDictionary.Key);\n }\n\n return actualDictionary;\n }\n\n private static void FailWithLengthDifference(\n IDictionary subject,\n IDictionary expectation,\n AssertionChain assertionChain)\n\n // Type constraint of TExpectedKey is asymmetric in regards to TSubjectKey\n // but it is valid. This constraint is implicitly enforced by the dictionary interface info which is called before\n // the AssertSameLength method.\n where TExpectedKey : TSubjectKey\n {\n KeyDifference keyDifference = CalculateKeyDifference(subject, expectation);\n\n bool hasMissingKeys = keyDifference.MissingKeys.Count > 0;\n bool hasAdditionalKeys = keyDifference.AdditionalKeys.Count > 0;\n\n assertionChain\n .WithExpectation(\"Expected {context:subject} to be a dictionary with {0} item(s){reason}, \", expectation.Count,\n chain => chain\n .ForCondition(!hasMissingKeys || hasAdditionalKeys)\n .FailWith(\"but it misses key(s) {0}\", keyDifference.MissingKeys)\n .Then\n .ForCondition(hasMissingKeys || !hasAdditionalKeys)\n .FailWith(\"but has additional key(s) {0}\", keyDifference.AdditionalKeys)\n .Then\n .ForCondition(!hasMissingKeys || !hasAdditionalKeys)\n .FailWith(\"but it misses key(s) {0} and has additional key(s) {1}\", keyDifference.MissingKeys,\n keyDifference.AdditionalKeys));\n }\n\n private static KeyDifference CalculateKeyDifference(IDictionary subject,\n IDictionary expectation)\n where TExpectedKey : TSubjectKey\n {\n var missingKeys = new List();\n var presentKeys = new HashSet();\n\n foreach (TExpectedKey expectationKey in expectation.Keys)\n {\n if (subject.ContainsKey(expectationKey))\n {\n presentKeys.Add(expectationKey);\n }\n else\n {\n missingKeys.Add(expectationKey);\n }\n }\n\n var additionalKeys = new List();\n\n foreach (TSubjectKey subjectKey in subject.Keys)\n {\n if (!presentKeys.Contains(subjectKey))\n {\n additionalKeys.Add(subjectKey);\n }\n }\n\n return new KeyDifference(missingKeys, additionalKeys);\n }\n\n private static void AssertDictionaryEquivalence(Comparands comparands, AssertionChain assertionChain,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency parent, DictionaryInterfaceInfo actualDictionary,\n DictionaryInterfaceInfo expectedDictionary)\n {\n AssertDictionaryEquivalenceMethod\n .MakeGenericMethod(actualDictionary.Key, actualDictionary.Value, expectedDictionary.Key, expectedDictionary.Value)\n .Invoke(null, [assertionChain, context, parent, context.Options, comparands.Subject, comparands.Expectation]);\n }\n\n private static void AssertDictionaryEquivalence(\n AssertionChain assertionChain,\n EquivalencyValidationContext context,\n IValidateChildNodeEquivalency parent,\n IEquivalencyOptions options,\n IDictionary subject,\n IDictionary expectation)\n where TExpectedKey : TSubjectKey\n {\n if (subject.Count != expectation.Count)\n {\n FailWithLengthDifference(subject, expectation, assertionChain);\n }\n else\n {\n foreach (TExpectedKey key in expectation.Keys)\n {\n if (subject.TryGetValue(key, out TSubjectValue subjectValue))\n {\n if (options.IsRecursive)\n {\n // Run the child assertion without affecting the current context\n using (new AssertionScope())\n {\n var nestedComparands = new Comparands(subject[key], expectation[key], typeof(TExpectedValue));\n\n parent.AssertEquivalencyOf(nestedComparands, context.AsDictionaryItem(key));\n }\n }\n else\n {\n assertionChain.ReuseOnce();\n subjectValue.Should().Be(expectation[key], context.Reason.FormattedMessage, context.Reason.Arguments);\n }\n }\n else\n {\n assertionChain\n .BecauseOf(context.Reason)\n .FailWith(\"Expected {context:subject} to contain key {0}{reason}.\", key);\n }\n }\n }\n }\n\n private sealed class KeyDifference\n {\n public KeyDifference(List missingKeys, List additionalKeys)\n {\n MissingKeys = missingKeys;\n AdditionalKeys = additionalKeys;\n }\n\n public List MissingKeys { get; }\n\n public List AdditionalKeys { get; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyValidator.cs", "using System;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Is responsible for validating the equivalency of a subject with another object.\n/// \ninternal class EquivalencyValidator : IValidateChildNodeEquivalency\n{\n private const int MaxDepth = 10;\n\n public void AssertEquality(Comparands comparands, EquivalencyValidationContext context)\n {\n using var scope = new AssertionScope();\n\n RecursivelyAssertEquivalencyOf(comparands, context);\n\n if (context.TraceWriter is not null)\n {\n scope.AppendTracing(context.TraceWriter.ToString());\n }\n }\n\n private void RecursivelyAssertEquivalencyOf(Comparands comparands, IEquivalencyValidationContext context)\n {\n AssertEquivalencyOf(comparands, context);\n }\n\n public void AssertEquivalencyOf(Comparands comparands, IEquivalencyValidationContext context)\n {\n var assertionChain = AssertionChain.GetOrCreate()\n .For(context)\n .BecauseOf(context.Reason);\n\n if (ShouldContinueThisDeep(context.CurrentNode, context.Options, assertionChain))\n {\n if (!context.IsCyclicReference(comparands.Expectation))\n {\n TryToProveNodesAreEquivalent(comparands, context);\n }\n else if (context.Options.CyclicReferenceHandling == CyclicReferenceHandling.ThrowException)\n {\n assertionChain.FailWith(\"Expected {context:subject} to be {0}{reason}, but it contains a cyclic reference.\", comparands.Expectation);\n }\n else\n {\n AssertEquivalencyForCyclicReference(comparands, assertionChain);\n }\n }\n }\n\n private static bool ShouldContinueThisDeep(INode currentNode, IEquivalencyOptions options,\n AssertionChain assertionChain)\n {\n bool shouldRecurse = options.AllowInfiniteRecursion || currentNode.Depth <= MaxDepth;\n\n if (!shouldRecurse)\n {\n // This will throw, unless we're inside an AssertionScope\n assertionChain.FailWith($\"The maximum recursion depth of {MaxDepth} was reached. \");\n }\n\n return shouldRecurse;\n }\n\n private static void AssertEquivalencyForCyclicReference(Comparands comparands, AssertionChain assertionChain)\n {\n // We know that at this point the expectation is a non-null cyclic reference, so we don't want to continue the recursion.\n // We still want to compare the subject with the expectation though.\n\n // If they point at the same object, then equality is proven, and it doesn't matter that there's a cyclic reference.\n if (ReferenceEquals(comparands.Subject, comparands.Expectation))\n {\n return;\n }\n\n // If the expectation is non-null and the subject isn't, they would never be equivalent, regardless of how we deal with cyclic references,\n // so we can just throw an exception here.\n if (comparands.Subject is null)\n {\n assertionChain.ReuseOnce();\n comparands.Subject.Should().BeSameAs(comparands.Expectation);\n }\n\n // If they point at different objects, and the expectation is a cyclic reference, we would never be\n // able to prove that they are equal. And since we're supposed to ignore cyclic references, we can just return here.\n }\n\n private void TryToProveNodesAreEquivalent(Comparands comparands, IEquivalencyValidationContext context)\n {\n using var _ = context.Tracer.WriteBlock(node => node.Expectation.Description);\n\n foreach (IEquivalencyStep step in AssertionConfiguration.Current.Equivalency.Plan)\n {\n var result = step.Handle(comparands, context, this);\n\n if (result == EquivalencyResult.EquivalencyProven)\n {\n context.Tracer.WriteLine(GetMessage(step));\n\n static GetTraceMessage GetMessage(IEquivalencyStep step) =>\n _ => $\"Equivalency was proven by {step.GetType().Name}\";\n\n return;\n }\n }\n\n throw new NotSupportedException(\n $\"Do not know how to compare {comparands.Subject} and {comparands.Expectation}. Please report an issue through https://awesomeassertions.org.\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EnumEqualityStep.cs", "#region\n\nusing System;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\n#endregion\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class EnumEqualityStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!comparands.GetExpectedType(context.Options).IsEnum)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n assertionChain\n .ForCondition(comparands.Subject?.GetType().IsEnum == true)\n .BecauseOf(context.Reason)\n .FailWith(() =>\n {\n decimal? expectationsUnderlyingValue = ExtractDecimal(comparands.Expectation);\n string expectationName = GetDisplayNameForEnumComparison(comparands.Expectation, expectationsUnderlyingValue);\n\n return new FailReason(\n $\"Expected {{context:enum}} to be equivalent to {expectationName}{{reason}}, but found {{0}}.\",\n comparands.Subject);\n });\n\n if (assertionChain.Succeeded)\n {\n switch (context.Options.EnumEquivalencyHandling)\n {\n case EnumEquivalencyHandling.ByValue:\n HandleByValue(assertionChain, comparands, context.Reason);\n break;\n\n case EnumEquivalencyHandling.ByName:\n HandleByName(assertionChain, comparands, context.Reason);\n break;\n\n default:\n throw new InvalidOperationException($\"Do not know how to handle {context.Options.EnumEquivalencyHandling}\");\n }\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static void HandleByValue(AssertionChain assertionChain, Comparands comparands, Reason reason)\n {\n decimal? subjectsUnderlyingValue = ExtractDecimal(comparands.Subject);\n decimal? expectationsUnderlyingValue = ExtractDecimal(comparands.Expectation);\n\n assertionChain\n .ForCondition(subjectsUnderlyingValue == expectationsUnderlyingValue)\n .BecauseOf(reason)\n .FailWith(() =>\n {\n string subjectsName = GetDisplayNameForEnumComparison(comparands.Subject, subjectsUnderlyingValue);\n string expectationName = GetDisplayNameForEnumComparison(comparands.Expectation, expectationsUnderlyingValue);\n\n return new FailReason(\n $\"Expected {{context:enum}} to equal {expectationName} by value{{reason}}, but found {subjectsName}.\");\n });\n }\n\n private static void HandleByName(AssertionChain assertionChain, Comparands comparands, Reason reason)\n {\n string subject = comparands.Subject.ToString();\n string expected = comparands.Expectation.ToString();\n\n assertionChain\n .ForCondition(subject == expected)\n .BecauseOf(reason)\n .FailWith(() =>\n {\n decimal? subjectsUnderlyingValue = ExtractDecimal(comparands.Subject);\n decimal? expectationsUnderlyingValue = ExtractDecimal(comparands.Expectation);\n\n string subjectsName = GetDisplayNameForEnumComparison(comparands.Subject, subjectsUnderlyingValue);\n string expectationName = GetDisplayNameForEnumComparison(comparands.Expectation, expectationsUnderlyingValue);\n\n return new FailReason(\n $\"Expected {{context:enum}} to equal {expectationName} by name{{reason}}, but found {subjectsName}.\");\n });\n }\n\n private static string GetDisplayNameForEnumComparison(object o, decimal? v)\n {\n if (o is null || v is null)\n {\n return \"\";\n }\n\n string typePart = o.GetType().Name;\n string namePart = o.ToString().Replace(\", \", \"|\", StringComparison.Ordinal);\n string valuePart = v.Value.ToString(CultureInfo.InvariantCulture);\n return $\"{typePart}.{namePart} {{{{value: {valuePart}}}}}\";\n }\n\n private static decimal? ExtractDecimal(object o)\n {\n return o is not null ? Convert.ToDecimal(o, CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/AssertionRuleEquivalencyStep.cs", "using System;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class AssertionRuleEquivalencyStep : IEquivalencyStep\n{\n private readonly Func predicate;\n private readonly string description;\n private readonly Action> assertionAction;\n private readonly AutoConversionStep converter = new();\n\n public AssertionRuleEquivalencyStep(\n Expression> predicate,\n Action> assertionAction)\n {\n this.predicate = predicate.Compile();\n this.assertionAction = assertionAction;\n description = predicate.ToString();\n }\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n bool success = false;\n\n using (var scope = new AssertionScope())\n {\n // Try without conversion\n if (AppliesTo(comparands, context.CurrentNode))\n {\n success = ExecuteAssertion(comparands, context);\n }\n\n bool converted = false;\n\n if (!success && context.Options.ConversionSelector.RequiresConversion(comparands, context.CurrentNode))\n {\n // Convert into a child context\n context = context.Clone();\n converter.Handle(comparands, context, valueChildNodes);\n converted = true;\n }\n\n if (converted && AppliesTo(comparands, context.CurrentNode))\n {\n // Try again after conversion\n success = ExecuteAssertion(comparands, context);\n if (success)\n {\n // If the assertion succeeded after conversion, discard the failures from\n // the previous attempt. If it didn't, let the scope throw with those failures.\n scope.Discard();\n }\n }\n }\n\n return success ? EquivalencyResult.EquivalencyProven : EquivalencyResult.ContinueWithNext;\n }\n\n private bool AppliesTo(Comparands comparands, INode currentNode) => predicate(new ObjectInfo(comparands, currentNode));\n\n private bool ExecuteAssertion(Comparands comparands, IEquivalencyValidationContext context)\n {\n bool subjectIsNull = comparands.Subject is null;\n bool expectationIsNull = comparands.Expectation is null;\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n assertionChain\n .ForCondition(subjectIsNull || comparands.Subject.GetType().IsSameOrInherits(typeof(TSubject)))\n .FailWith(\"Expected \" + context.CurrentNode.Subject + \" from subject to be a {0}{reason}, but found a {1}.\",\n typeof(TSubject), comparands.Subject?.GetType())\n .Then\n .ForCondition(expectationIsNull || comparands.Expectation.GetType().IsSameOrInherits(typeof(TSubject)))\n .FailWith(\n \"Expected \" + context.CurrentNode.Subject + \" from expectation to be a {0}{reason}, but found a {1}.\",\n typeof(TSubject), comparands.Expectation?.GetType());\n\n if (assertionChain.Succeeded)\n {\n if ((subjectIsNull || expectationIsNull) && !CanBeNull())\n {\n return false;\n }\n\n // Caller identitification should not get confused about invoking a Should within the assertion action\n string callerIdentifier = context.CurrentNode.Subject.ToString();\n assertionChain.OverrideCallerIdentifier(() => callerIdentifier);\n assertionChain.ReuseOnce();\n\n assertionAction(AssertionContext.CreateFrom(comparands, context));\n return true;\n }\n\n return false;\n }\n\n private static bool CanBeNull() => !typeof(T).IsValueType || Nullable.GetUnderlyingType(typeof(T)) is not null;\n\n /// \n /// Returns a string that represents the current object.\n /// \n /// \n /// A string that represents the current object.\n /// \n /// 2\n public override string ToString()\n {\n return \"Invoke Action<\" + typeof(TSubject).Name + \"> when \" + description;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/GenericEnumerableEquivalencyStep.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class GenericEnumerableEquivalencyStep : IEquivalencyStep\n{\n#pragma warning disable SA1110 // Allow opening parenthesis on new line to reduce line length\n private static readonly MethodInfo HandleMethod = new Action>\n (HandleImpl).GetMethodInfo().GetGenericMethodDefinition();\n#pragma warning restore SA1110\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n Type expectedType = comparands.GetExpectedType(context.Options);\n\n if (comparands.Expectation is null || !IsGenericCollection(expectedType))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n Type[] interfaceTypes = GetIEnumerableInterfaces(expectedType);\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n assertionChain\n .ForCondition(interfaceTypes.Length == 1)\n .FailWith(() => new FailReason(\"{context:Expectation} implements {0}, so cannot determine which one \" +\n \"to use for asserting the equivalency of the collection. \",\n interfaceTypes.Select(type => \"IEnumerable<\" + type.GetGenericArguments().Single() + \">\")));\n\n if (AssertSubjectIsCollection(assertionChain, comparands.Subject))\n {\n var validator = new EnumerableEquivalencyValidator(assertionChain, valueChildNodes, context)\n {\n Recursive = context.CurrentNode.IsRoot || context.Options.IsRecursive,\n OrderingRules = context.Options.OrderingRules\n };\n\n Type typeOfEnumeration = GetTypeOfEnumeration(expectedType);\n\n var subjectAsArray = EnumerableEquivalencyStep.ToArray(comparands.Subject);\n\n try\n {\n HandleMethod.MakeGenericMethod(typeOfEnumeration)\n .Invoke(null, [validator, subjectAsArray, comparands.Expectation]);\n }\n catch (TargetInvocationException e)\n {\n e.Unwrap().Throw();\n }\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static void HandleImpl(EnumerableEquivalencyValidator validator, object[] subject, IEnumerable expectation) =>\n validator.Execute(subject, ToArray(expectation));\n\n private static bool AssertSubjectIsCollection(AssertionChain assertionChain, object subject)\n {\n assertionChain\n .ForCondition(subject is not null)\n .FailWith(\"Expected {context:subject} not to be {0}.\", new object[] { null });\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(IsCollection(subject.GetType()))\n .FailWith(\"Expected {context:subject} to be a collection, but it was a {0}\", subject.GetType());\n }\n\n return assertionChain.Succeeded;\n }\n\n private static bool IsCollection(Type type)\n {\n return !typeof(string).IsAssignableFrom(type) && typeof(IEnumerable).IsAssignableFrom(type);\n }\n\n private static bool IsGenericCollection(Type type)\n {\n Type[] enumerableInterfaces = GetIEnumerableInterfaces(type);\n\n return !typeof(string).IsAssignableFrom(type) && enumerableInterfaces.Length > 0;\n }\n\n private static Type[] GetIEnumerableInterfaces(Type type)\n {\n // Avoid expensive calculation when the type in question can't possibly implement IEnumerable<>.\n if (Type.GetTypeCode(type) != TypeCode.Object)\n {\n return [];\n }\n\n Type soughtType = typeof(IEnumerable<>);\n\n return type.GetClosedGenericInterfaces(soughtType);\n }\n\n private static Type GetTypeOfEnumeration(Type enumerableType)\n {\n Type interfaceType = GetIEnumerableInterfaces(enumerableType).Single();\n\n return interfaceType.GetGenericArguments().Single();\n }\n\n private static T[] ToArray(IEnumerable value)\n {\n try\n {\n return value?.ToArray();\n }\n catch (InvalidOperationException) when (value.GetType().Name.Equals(\"ImmutableArray`1\", StringComparison.Ordinal))\n {\n // This is probably a default ImmutableArray\n return [];\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MultiDimensionalArrayEquivalencyStep.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Supports recursively comparing two multi-dimensional arrays for equivalency using strict order for the array items\n/// themselves.\n/// \ninternal class MultiDimensionalArrayEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expectation is not Array expectationAsArray || expectationAsArray.Rank == 1)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (AreComparable(comparands, expectationAsArray, AssertionChain.GetOrCreate().For(context)))\n {\n if (expectationAsArray.Length == 0)\n {\n return EquivalencyResult.EquivalencyProven;\n }\n\n Digit digit = BuildDigitsRepresentingAllIndices(expectationAsArray);\n\n do\n {\n int[] indices = digit.GetIndices();\n object subject = ((Array)comparands.Subject).GetValue(indices);\n string listOfIndices = string.Join(\",\", indices);\n object expectation = expectationAsArray.GetValue(indices);\n\n IEquivalencyValidationContext itemContext = context.AsCollectionItem(listOfIndices);\n\n valueChildNodes.AssertEquivalencyOf(new Comparands(subject, expectation, typeof(object)),\n itemContext);\n }\n while (digit.Increment());\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static Digit BuildDigitsRepresentingAllIndices(Array subjectAsArray)\n {\n return Enumerable\n .Range(0, subjectAsArray.Rank)\n .Reverse()\n .Aggregate((Digit)null, (next, rank) => new Digit(subjectAsArray.GetLength(rank), next));\n }\n\n private static bool AreComparable(Comparands comparands, Array expectationAsArray, AssertionChain assertionChain)\n {\n return\n IsArray(comparands.Subject, assertionChain) &&\n HaveSameRank(comparands.Subject, expectationAsArray, assertionChain) &&\n HaveSameDimensions(comparands.Subject, expectationAsArray, assertionChain);\n }\n\n private static bool IsArray(object type, AssertionChain assertionChain)\n {\n assertionChain\n .ForCondition(type is not null)\n .FailWith(\"Cannot compare a multi-dimensional array to .\")\n .Then\n .ForCondition(type is Array)\n .FailWith(\"Cannot compare a multi-dimensional array to something else.\");\n\n return assertionChain.Succeeded;\n }\n\n private static bool HaveSameDimensions(object subject, Array expectation, AssertionChain assertionChain)\n {\n bool sameDimensions = true;\n\n for (int dimension = 0; dimension < expectation.Rank; dimension++)\n {\n int actualLength = ((Array)subject).GetLength(dimension);\n int expectedLength = expectation.GetLength(dimension);\n\n assertionChain\n .ForCondition(expectedLength == actualLength)\n .FailWith(\"Expected dimension {0} to contain {1} item(s), but found {2}.\", dimension, expectedLength,\n actualLength);\n\n sameDimensions &= assertionChain.Succeeded;\n }\n\n return sameDimensions;\n }\n\n private static bool HaveSameRank(object subject, Array expectation, AssertionChain assertionChain)\n {\n var subjectAsArray = (Array)subject;\n\n assertionChain\n .ForCondition(subjectAsArray.Rank == expectation.Rank)\n .FailWith(\"Expected {context:array} to have {0} dimension(s), but it has {1}.\", expectation.Rank,\n subjectAsArray.Rank);\n\n return assertionChain.Succeeded;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EnumerableEquivalencyStep.cs", "using System;\nusing System.Collections;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class EnumerableEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!IsCollection(comparands.GetExpectedType(context.Options)))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (AssertSubjectIsCollection(assertionChain, comparands.Subject))\n {\n var validator = new EnumerableEquivalencyValidator(assertionChain, valueChildNodes, context)\n {\n Recursive = context.CurrentNode.IsRoot || context.Options.IsRecursive,\n OrderingRules = context.Options.OrderingRules\n };\n\n validator.Execute(ToArray(comparands.Subject), ToArray(comparands.Expectation));\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static bool AssertSubjectIsCollection(AssertionChain assertionChain, object subject)\n {\n assertionChain\n .ForCondition(subject is not null)\n .FailWith(\"Expected a collection, but {context:Subject} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(IsCollection(subject.GetType()))\n .FailWith(\"Expected a collection, but {context:Subject} is of a non-collection type.\");\n }\n\n return assertionChain.Succeeded;\n }\n\n private static bool IsCollection(Type type)\n {\n return !typeof(string).IsAssignableFrom(type) && typeof(IEnumerable).IsAssignableFrom(type);\n }\n\n internal static object[] ToArray(object value)\n {\n if (value == null)\n {\n return null;\n }\n\n try\n {\n return ((IEnumerable)value).Cast().ToArray();\n }\n catch (InvalidOperationException) when (IsIgnorableArrayLikeType(value))\n {\n // This is probably a default ImmutableArray or an empty ArraySegment.\n return [];\n }\n }\n\n private static bool IsIgnorableArrayLikeType(object value)\n {\n var type = value.GetType();\n return type.Name.Equals(\"ImmutableArray`1\", StringComparison.Ordinal) ||\n (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(ArraySegment<>));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/AutoConversionStep.cs", "using System;\nusing System.Globalization;\nusing AwesomeAssertions.Common;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Attempts to convert the subject's property value to the expected type.\n/// \n/// \n/// Whether or not the conversion is attempted depends on the .\n/// \npublic class AutoConversionStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!context.Options.ConversionSelector.RequiresConversion(comparands, context.CurrentNode))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (comparands.Expectation is null || comparands.Subject is null)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n Type subjectType = comparands.Subject.GetType();\n Type expectationType = comparands.Expectation.GetType();\n\n if (subjectType.IsSameOrInherits(expectationType))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (TryChangeType(comparands.Subject, expectationType, out object convertedSubject))\n {\n context.Tracer.WriteLine(member =>\n Invariant($\"Converted subject {comparands.Subject} at {member.Subject} to {expectationType}\"));\n\n comparands.Subject = convertedSubject;\n }\n else\n {\n context.Tracer.WriteLine(member =>\n Invariant($\"Subject {comparands.Subject} at {member.Subject} could not be converted to {expectationType}\"));\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n\n private static bool TryChangeType(object subject, Type expectationType, out object conversionResult)\n {\n conversionResult = null;\n\n try\n {\n if (expectationType.IsEnum)\n {\n if (subject is sbyte or byte or short or ushort or int or uint or long or ulong)\n {\n conversionResult = Enum.ToObject(expectationType, subject);\n return Enum.IsDefined(expectationType, conversionResult);\n }\n\n return false;\n }\n\n conversionResult = Convert.ChangeType(subject, expectationType, CultureInfo.InvariantCulture);\n return true;\n }\n catch (FormatException)\n {\n }\n catch (InvalidCastException)\n {\n }\n\n return false;\n }\n\n public override string ToString()\n {\n return string.Empty;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/ExtensibilitySpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\n/// \n/// Test Class containing specs over the extensibility points of Should().BeEquivalentTo\n/// \npublic class ExtensibilitySpecs\n{\n #region Selection Rules\n\n [Fact]\n public void When_a_selection_rule_is_added_it_should_be_evaluated_after_all_existing_rules()\n {\n // Arrange\n var subject = new\n {\n NameId = \"123\",\n SomeValue = \"hello\"\n };\n\n var expected = new\n {\n SomeValue = \"hello\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new ExcludeForeignKeysSelectionRule()));\n }\n\n [Fact]\n public void When_a_selection_rule_is_added_it_should_appear_in_the_exception_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"123\",\n };\n\n var expected = new\n {\n SomeValue = \"hello\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new ExcludeForeignKeysSelectionRule()));\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*{nameof(ExcludeForeignKeysSelectionRule)}*\");\n }\n\n internal class ExcludeForeignKeysSelectionRule : IMemberSelectionRule\n {\n public bool OverridesStandardIncludeRules\n {\n get { return false; }\n }\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return selectedMembers.Where(pi => !pi.Subject.Name.EndsWith(\"Id\", StringComparison.Ordinal)).ToArray();\n }\n\n bool IMemberSelectionRule.IncludesMembers\n {\n get { return OverridesStandardIncludeRules; }\n }\n }\n\n #endregion\n\n #region Matching Rules\n\n [Fact]\n public void When_a_matching_rule_is_added_it_should_precede_all_existing_rules()\n {\n // Arrange\n var subject = new\n {\n Name = \"123\",\n SomeValue = \"hello\"\n };\n\n var expected = new\n {\n NameId = \"123\",\n SomeValue = \"hello\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new ForeignKeyMatchingRule()));\n }\n\n [Fact]\n public void When_a_matching_rule_is_added_it_should_appear_in_the_exception_message()\n {\n // Arrange\n var subject = new\n {\n NameId = \"123\",\n SomeValue = \"hello\"\n };\n\n var expected = new\n {\n Name = \"1234\",\n SomeValue = \"hello\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new ForeignKeyMatchingRule()));\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*{nameof(ForeignKeyMatchingRule)}*\");\n }\n\n internal class ForeignKeyMatchingRule : IMemberMatchingRule\n {\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options,\n AssertionChain assertionChain)\n {\n string name = expectedMember.Subject.Name;\n\n if (name.EndsWith(\"Id\", StringComparison.Ordinal))\n {\n name = name.Replace(\"Id\", \"\");\n }\n\n PropertyInfo runtimeProperty = subject.GetType().GetRuntimeProperty(name);\n return runtimeProperty is not null ? new Property(runtimeProperty, parent) : null;\n }\n }\n\n #endregion\n\n #region Ordering Rules\n\n [Fact]\n public void When_an_ordering_rule_is_added_it_should_be_evaluated_after_all_existing_rules()\n {\n // Arrange\n string[] subject = [\"First\", \"Second\"];\n string[] expected = [\"First\", \"Second\"];\n\n // Act / Assert\n subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new StrictOrderingRule()));\n }\n\n [Fact]\n public void When_an_ordering_rule_is_added_it_should_appear_in_the_exception_message()\n {\n // Arrange\n string[] subject = [\"First\", \"Second\"];\n string[] expected = [\"Second\", \"First\"];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new StrictOrderingRule()));\n\n act.Should().Throw()\n .WithMessage($\"*{nameof(StrictOrderingRule)}*\");\n }\n\n internal class StrictOrderingRule : IOrderingRule\n {\n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n return OrderStrictness.Strict;\n }\n }\n\n #endregion\n\n #region Assertion Rules\n\n [Fact]\n public void When_property_of_other_is_incompatible_with_generic_type_the_message_should_include_generic_type()\n {\n // Arrange\n var subject = new\n {\n Id = \"foo\",\n };\n\n var other = new\n {\n Id = 0.5d,\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Id*from expectation*string*double*\");\n }\n\n [Fact]\n public void Can_exclude_all_properties_of_the_parent_type()\n {\n // Arrange\n var subject = new\n {\n Id = \"foo\",\n };\n\n var expectation = new\n {\n Id = \"bar\",\n };\n\n // Act\n subject.Should().BeEquivalentTo(expectation,\n o => o\n .Using(c => c.Subject.Should().HaveLength(c.Expectation.Length))\n .When(si => si.ParentType == expectation.GetType() && si.Path.EndsWith(\"Id\", StringComparison.Ordinal)));\n }\n\n [Fact]\n public void When_property_of_subject_is_incompatible_with_generic_type_the_message_should_include_generic_type()\n {\n // Arrange\n var subject = new\n {\n Id = 0.5d,\n };\n\n var other = new\n {\n Id = \"foo\",\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Id*from subject*string*double*\");\n }\n\n [Fact]\n public void When_equally_named_properties_are_both_incompatible_with_generic_type_the_message_should_include_generic_type()\n {\n // Arrange\n var subject = new\n {\n Id = 0.5d,\n };\n\n var other = new\n {\n Id = 0.5d,\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Id*from subject*string*double*\");\n }\n\n [Fact]\n public void When_property_of_other_is_null_the_failure_message_should_not_complain_about_its_type()\n {\n // Arrange\n var subject = new\n {\n Id = \"foo\",\n };\n\n var other = new\n {\n Id = null as double?,\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should()\n .Contain(\"Expected property subject.Id to be , but found \\\"foo\\\"\")\n .And.NotContain(\"from expectation\");\n }\n\n [Fact]\n public void When_property_of_subject_is_null_the_failure_message_should_not_complain_about_its_type()\n {\n // Arrange\n var subject = new\n {\n Id = null as double?,\n };\n\n var expectation = new\n {\n Id = \"bar\",\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should()\n .Contain(\"Expected property subject.Id to be \\\"bar\\\", but found \")\n .And.NotContain(\"from subject\");\n }\n\n [Fact]\n public void When_equally_named_properties_are_both_null_it_should_succeed()\n {\n // Arrange\n var subject = new\n {\n Id = null as double?,\n };\n\n var other = new\n {\n Id = null as string,\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n }\n\n [Fact]\n public void When_equally_named_properties_are_type_incompatible_and_assertion_rule_exists_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Type = typeof(string),\n };\n\n var other = new\n {\n Type = typeof(string).AssemblyQualifiedName,\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => ((Type)c.Subject).AssemblyQualifiedName.Should().Be((string)c.Expectation))\n .When(si => si.Path == \"Type\"));\n }\n\n [Fact]\n public void When_an_assertion_is_overridden_for_a_predicate_it_should_use_the_provided_action()\n {\n // Arrange\n var subject = new\n {\n Date = 14.July(2012).At(12, 59, 59)\n };\n\n var expectation = new\n {\n Date = 14.July(2012).At(13, 0)\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .Using(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, 1.Seconds()))\n .When(info => info.Path.EndsWith(\"Date\", StringComparison.Ordinal)));\n }\n\n [Fact]\n public void When_an_assertion_is_overridden_for_all_types_it_should_use_the_provided_action_for_all_properties()\n {\n // Arrange\n var subject = new\n {\n Date = 21.July(2012).At(11, 8, 59),\n Nested = new\n {\n NestedDate = 14.July(2012).At(12, 59, 59)\n }\n };\n\n var expectation = new\n {\n Date = 21.July(2012).At(11, 9),\n Nested = new\n {\n NestedDate = 14.July(2012).At(13, 0)\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options =>\n options\n .Using(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, 1.Seconds()))\n .WhenTypeIs());\n }\n\n [InlineData(null, 0)]\n [InlineData(0, null)]\n [Theory]\n public void When_subject_or_expectation_is_null_it_should_not_match_a_non_nullable_type(int? subjectValue, int? expectedValue)\n {\n // Arrange\n var actual = new { Value = subjectValue };\n var expected = new { Value = expectedValue };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().NotBe(c.Expectation))\n .WhenTypeIs());\n\n // Assert\n act.Should().Throw();\n }\n\n [InlineData(null, 0)]\n [InlineData(0, null)]\n [Theory]\n public void When_subject_or_expectation_is_null_it_should_match_a_nullable_type(int? subjectValue, int? expectedValue)\n {\n // Arrange\n var actual = new { Value = subjectValue };\n var expected = new { Value = expectedValue };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().NotBe(c.Expectation))\n .WhenTypeIs());\n }\n\n [InlineData(null, null)]\n [InlineData(0, 0)]\n [Theory]\n public void When_types_are_nullable_it_should_match_a_nullable_type(int? subjectValue, int? expectedValue)\n {\n // Arrange\n var actual = new { Value = subjectValue };\n var expected = new { Value = expectedValue };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().NotBe(c.Expectation))\n .WhenTypeIs());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_overriding_with_custom_assertion_it_should_be_chainable()\n {\n // Arrange\n var actual = new { Nullable = (int?)1, NonNullable = 2 };\n var expected = new { Nullable = (int?)3, NonNullable = 3 };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().BeCloseTo(c.Expectation, 1))\n .WhenTypeIs()\n .Using(c => c.Subject.Should().NotBe(c.Expectation))\n .WhenTypeIs());\n }\n\n [Fact]\n public void When_a_nullable_property_is_overridden_with_a_custom_assertion_it_should_use_it()\n {\n // Arrange\n var actual = new SimpleWithNullable\n {\n NullableIntegerProperty = 1,\n StringProperty = \"I haz a string!\"\n };\n\n var expected = new SimpleWithNullable\n {\n StringProperty = \"I haz a string!\"\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().BeInRange(0, 10))\n .WhenTypeIs());\n }\n\n internal class SimpleWithNullable\n {\n public long? NullableIntegerProperty { get; set; }\n\n public string StringProperty { get; set; }\n }\n\n [Fact]\n public void When_an_assertion_rule_is_added_it_should_precede_all_existing_rules()\n {\n // Arrange\n var subject = new\n {\n Created = 8.July(2012).At(22, 9)\n };\n\n var expected = new\n {\n Created = 8.July(2012).At(22, 10)\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new RelaxingDateTimeEquivalencyStep()));\n }\n\n [Fact]\n public void When_an_assertion_rule_is_added_it_appear_in_the_exception_message()\n {\n // Arrange\n var subject = new\n {\n Property = 8.July(2012).At(22, 9)\n };\n\n var expected = new\n {\n Property = 8.July(2012).At(22, 11)\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new RelaxingDateTimeEquivalencyStep()));\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*{nameof(RelaxingDateTimeEquivalencyStep)}*\");\n }\n\n [Fact]\n public void When_multiple_steps_are_added_they_should_be_evaluated_first_to_last()\n {\n // Arrange\n var subject = new\n {\n Created = 8.July(2012).At(22, 9)\n };\n\n var expected = new\n {\n Created = 8.July(2012).At(22, 10)\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opts => opts\n .Using(new RelaxingDateTimeEquivalencyStep())\n .Using(new AlwaysFailOnDateTimesEquivalencyStep()));\n\n // Assert\n act.Should().NotThrow(\n \"a different assertion rule should handle the comparison before the exception throwing assertion rule is hit\");\n }\n\n private class AlwaysFailOnDateTimesEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expectation is DateTime)\n {\n throw new Exception(\"Failed\");\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n }\n\n private class RelaxingDateTimeEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expectation is DateTime time)\n {\n ((DateTime)comparands.Subject).Should().BeCloseTo(time, 1.Minutes());\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n }\n\n [Fact]\n public void When_multiple_assertion_rules_are_added_with_the_fluent_api_they_should_be_executed_from_right_to_left()\n {\n // Arrange\n var subject = new ClassWithOnlyAProperty();\n var expected = new ClassWithOnlyAProperty();\n\n // Act\n Action act =\n () =>\n subject.Should().BeEquivalentTo(expected,\n opts =>\n opts.Using(_ => throw new Exception())\n .When(_ => true)\n .Using(_ => { })\n .When(_ => true));\n\n // Assert\n act.Should().NotThrow(\n \"a different assertion rule should handle the comparison before the exception throwing assertion rule is hit\");\n }\n\n [Fact]\n public void When_using_a_nested_equivalency_api_in_a_custom_assertion_rule_it_should_honor_the_rule()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties\n {\n Property1 = \"value1\",\n Property2 = \"value2\"\n };\n\n var expectation = new ClassWithSomeFieldsAndProperties\n {\n Property1 = \"value1\",\n Property2 = \"value3\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .Using(ctx =>\n ctx.Subject.Should().BeEquivalentTo(ctx.Expectation, nestedOptions => nestedOptions.Excluding(x => x.Property2)))\n .WhenTypeIs());\n }\n\n [Fact]\n public void When_a_predicate_matches_after_auto_conversion_it_should_execute_the_assertion()\n {\n // Arrange\n var expectation = new\n {\n ThisIsMyDateTime = DateTime.Now\n };\n\n var actual = new\n {\n ThisIsMyDateTime = expectation.ThisIsMyDateTime.ToString(CultureInfo.InvariantCulture)\n };\n\n // Assert\n actual.Should().BeEquivalentTo(expectation,\n options => options\n .WithAutoConversion()\n .Using(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, 1.Seconds()))\n .WhenTypeIs());\n }\n\n #endregion\n\n #region Equivalency Steps\n\n [Fact]\n public void When_an_equivalency_step_handles_the_comparison_later_equivalency_steps_should_not_be_ran()\n {\n // Arrange\n var subject = new ClassWithOnlyAProperty();\n var expected = new ClassWithOnlyAProperty();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n opts =>\n opts.Using(new AlwaysHandleEquivalencyStep())\n .Using(new ThrowExceptionEquivalencyStep()));\n }\n\n [Fact]\n public void When_a_user_equivalency_step_is_registered_it_should_run_before_the_built_in_steps()\n {\n // Arrange\n var actual = new\n {\n Property = 123\n };\n\n var expected = new\n {\n Property = \"123\"\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options\n .Using(new EqualityEquivalencyStep()));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*123*123*\");\n }\n\n [Fact]\n public void When_an_equivalency_does_not_handle_the_comparison_later_equivalency_steps_should_still_be_ran()\n {\n // Arrange\n var subject = new ClassWithOnlyAProperty();\n var expected = new ClassWithOnlyAProperty();\n\n // Act\n Action act =\n () =>\n subject.Should().BeEquivalentTo(expected,\n opts =>\n opts.Using(new NeverHandleEquivalencyStep())\n .Using(new ThrowExceptionEquivalencyStep()));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_multiple_equivalency_steps_are_added_they_should_be_executed_in_registration_order()\n {\n // Arrange\n var subject = new ClassWithOnlyAProperty();\n var expected = new ClassWithOnlyAProperty();\n\n // Act\n Action act =\n () =>\n subject.Should().BeEquivalentTo(expected,\n opts =>\n opts.Using(new ThrowExceptionEquivalencyStep())\n .Using(new ThrowExceptionEquivalencyStep()));\n\n // Assert\n act.Should().Throw();\n }\n\n private class ThrowExceptionEquivalencyStep : IEquivalencyStep\n where TException : Exception, new()\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n throw new TException();\n }\n }\n\n private class AlwaysHandleEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n private class NeverHandleEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n }\n\n private class EqualityEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n internal class DoEquivalencyStep : IEquivalencyStep\n {\n private readonly Action doAction;\n\n public DoEquivalencyStep(Action doAction)\n {\n this.doAction = doAction;\n }\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n doAction();\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n [Fact]\n public void Can_compare_null_against_null_with_custom_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(new ClassWithNullableStructProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_null_against_not_null_with_custom_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty();\n var unexpected = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(unexpected, o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_null_with_custom_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new ClassWithNullableStructProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_not_null_with_custom_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n var expected = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_null_against_null_with_custom_nullable_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(new ClassWithNullableStructProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_null_against_not_null_with_custom_nullable_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty();\n var unexpected = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(unexpected, o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_null_with_custom_nullable_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new ClassWithNullableStructProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_not_null_with_custom_nullable_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n var expected = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, o => o\n .Using()\n );\n }\n\n private class ClassWithNullableStructProperty\n {\n [UsedImplicitly]\n public StructWithProperties? Value { get; set; }\n }\n\n private struct StructWithProperties\n {\n // ReSharper disable once UnusedAutoPropertyAccessor.Local\n public int Value { get; set; }\n }\n\n private class StructWithPropertiesComparer : IEqualityComparer, IEqualityComparer\n {\n public bool Equals(StructWithProperties x, StructWithProperties y) => Equals(x.Value, y.Value);\n\n public int GetHashCode(StructWithProperties obj) => obj.Value;\n\n public bool Equals(StructWithProperties? x, StructWithProperties? y) => Equals(x?.Value, y?.Value);\n\n public int GetHashCode(StructWithProperties? obj) => obj?.Value ?? 0;\n }\n\n [Fact]\n public void Can_compare_null_against_null_with_custom_comparer_for_property()\n {\n // Arrange\n var subject = new ClassWithClassProperty();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(new ClassWithClassProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_null_against_not_null_with_custom_comparer_for_property()\n {\n // Arrange\n var subject = new ClassWithClassProperty();\n var unexpected = new ClassWithClassProperty\n {\n Value = new ClassProperty\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(unexpected, o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_null_with_custom_comparer_for_property()\n {\n // Arrange\n var subject = new ClassWithClassProperty\n {\n Value = new ClassProperty\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new ClassWithClassProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_not_null_with_custom_comparer_for_property()\n {\n // Arrange\n var subject = new ClassWithClassProperty\n {\n Value = new ClassProperty\n {\n Value = 42\n },\n };\n var expected = new ClassWithClassProperty\n {\n Value = new ClassProperty\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, o => o\n .Using()\n );\n }\n\n private class ClassWithClassProperty\n {\n // ReSharper disable once UnusedAutoPropertyAccessor.Local\n public ClassProperty Value { get; set; }\n }\n\n public class ClassProperty\n {\n public int Value { get; set; }\n }\n\n private class ClassPropertyComparer : IEqualityComparer\n {\n public bool Equals(ClassProperty x, ClassProperty y) => Equals(x?.Value, y?.Value);\n\n public int GetHashCode(ClassProperty obj) => obj.Value;\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyStep.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Convenient implementation of that will only invoke\n/// \npublic abstract class EquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!typeof(T).IsAssignableFrom(comparands.GetExpectedType(context.Options)))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n return OnHandle(comparands, context, valueChildNodes);\n }\n\n /// \n /// Implements , but only gets called when the expected type matches .\n /// \n protected abstract EquivalencyResult OnHandle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/ReferenceEqualityEquivalencyStep.cs", "namespace AwesomeAssertions.Equivalency.Steps;\n\npublic class ReferenceEqualityEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n return ReferenceEquals(comparands.Subject, comparands.Expectation)\n ? EquivalencyResult.EquivalencyProven\n : EquivalencyResult.ContinueWithNext;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/RunAllUserStepsEquivalencyStep.cs", "namespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Represents a composite equivalency step that passes the execution to all user-supplied steps that can handle the\n/// current context.\n/// \npublic class RunAllUserStepsEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n foreach (IEquivalencyStep step in context.Options.UserEquivalencySteps)\n {\n if (step.Handle(comparands, context, valueChildNodes) == EquivalencyResult.EquivalencyProven)\n {\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/AssertionContext.cs", "using System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\ninternal sealed class AssertionContext : IAssertionContext\n{\n private AssertionContext(INode currentNode, TSubject subject, TSubject expectation,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n {\n SelectedNode = currentNode;\n Subject = subject;\n Expectation = expectation;\n Because = because;\n BecauseArgs = becauseArgs;\n }\n\n public INode SelectedNode { get; }\n\n public TSubject Subject { get; }\n\n public TSubject Expectation { get; }\n\n public string Because { get; set; }\n\n public object[] BecauseArgs { get; set; }\n\n internal static AssertionContext CreateFrom(Comparands comparands, IEquivalencyValidationContext context)\n {\n return new AssertionContext(\n context.CurrentNode,\n (TSubject)comparands.Subject,\n (TSubject)comparands.Expectation,\n context.Reason.FormattedMessage,\n context.Reason.Arguments);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IEquivalencyStep.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Defines a step in the process of comparing two object graphs for structural equivalency.\n/// \npublic interface IEquivalencyStep\n{\n /// \n /// Executes an operation such as an equivalency assertion on the provided .\n /// \n /// \n /// Should return if the subject matches the expectation or if no additional assertions\n /// have to be executed. Should return otherwise.\n /// \n /// \n /// May throw when preconditions are not met or if it detects mismatching data.\n /// \n EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/EquivalencyOptionsSpecs.cs", "using System;\nusing System.Collections;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Equivalency.Steps;\nusing AwesomeAssertions.Execution;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\npublic class EquivalencyOptionsSpecs\n{\n [Fact]\n public void When_injecting_a_null_configurer_it_should_throw()\n {\n // Arrange / Act\n var action = () => AssertionConfiguration.Current.Equivalency.Modify(configureOptions: null);\n\n // Assert\n action.Should().ThrowExactly()\n .WithParameterName(\"configureOptions\");\n }\n\n [Fact]\n public void When_concurrently_getting_equality_strategy_it_should_not_throw()\n {\n // Arrange / Act\n var action = () =>\n {\n#pragma warning disable CA1859 // https://github.com/dotnet/roslyn-analyzers/issues/6704\n IEquivalencyOptions equivalencyOptions = new EquivalencyOptions();\n#pragma warning restore CA1859\n\n return () => Parallel.For(0, 10_000, new ParallelOptions { MaxDegreeOfParallelism = 8 },\n _ => equivalencyOptions.GetEqualityStrategy(typeof(IEnumerable))\n );\n };\n\n // Assert\n action.Should().NotThrow();\n }\n\n [Collection(\"ConfigurationSpecs\")]\n public sealed class Given_temporary_global_assertion_options : IDisposable\n {\n [Fact]\n public void When_modifying_global_reference_type_settings_a_previous_assertion_should_not_have_any_effect_it_should_try_to_compare_the_classes_by_member_semantics_and_thus_throw()\n {\n // Arrange\n // Trigger a first equivalency check using the default global settings\n new MyValueType { Value = 1 }.Should().BeEquivalentTo(new MyValueType { Value = 2 });\n\n AssertionConfiguration.Current.Equivalency.Modify(o => o.ComparingByMembers());\n\n // Act\n Action act = () => new MyValueType { Value = 1 }.Should().BeEquivalentTo(new MyValueType { Value = 2 });\n\n // Assert\n act.Should().Throw();\n }\n\n internal class MyValueType\n {\n [UsedImplicitly]\n public int Value { get; set; }\n\n public override bool Equals(object obj) => true;\n\n public override int GetHashCode() => 0;\n }\n\n [Fact]\n public void When_modifying_global_value_type_settings_a_previous_assertion_should_not_have_any_effect_it_should_try_to_compare_the_classes_by_value_semantics_and_thus_throw()\n {\n // Arrange\n // Trigger a first equivalency check using the default global settings\n new MyClass { Value = 1 }.Should().BeEquivalentTo(new MyClass { Value = 1 });\n\n AssertionConfiguration.Current.Equivalency.Modify(o => o.ComparingByValue());\n\n // Act\n Action act = () => new MyClass() { Value = 1 }.Should().BeEquivalentTo(new MyClass { Value = 1 });\n\n // Assert\n act.Should().Throw();\n }\n\n internal class MyClass\n {\n [UsedImplicitly]\n public int Value { get; set; }\n }\n\n [Fact]\n public void When_modifying_record_settings_globally_it_should_use_the_global_settings_for_comparing_records()\n {\n // Arrange\n AssertionConfiguration.Current.Equivalency.Modify(o => o.ComparingByValue(typeof(Position)));\n\n // Act / Assert\n new Position(123).Should().BeEquivalentTo(new Position(123));\n }\n\n private record Position\n {\n [UsedImplicitly]\n private readonly int value;\n\n public Position(int value)\n {\n this.value = value;\n }\n }\n\n [Fact]\n public void When_assertion_doubles_should_always_allow_small_deviations_then_it_should_ignore_small_differences_without_the_need_of_local_options()\n {\n // Arrange\n AssertionConfiguration.Current.Equivalency.Modify(options => options\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.01))\n .WhenTypeIs());\n\n var actual = new\n {\n Value = 1D / 3D\n };\n\n var expected = new\n {\n Value = 0.33D\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_local_similar_options_are_used_then_they_should_override_the_global_options()\n {\n // Arrange\n AssertionConfiguration.Current.Equivalency.Modify(options => options\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.01))\n .WhenTypeIs());\n\n var actual = new\n {\n Value = 1D / 3D\n };\n\n var expected = new\n {\n Value = 0.33D\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options\n .Using(ctx => ctx.Subject.Should().Be(ctx.Expectation))\n .WhenTypeIs());\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*\");\n }\n\n [Fact]\n public void When_local_similar_options_are_used_then_they_should_not_affect_any_other_assertions()\n {\n // Arrange\n AssertionConfiguration.Current.Equivalency.Modify(options => options\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.01))\n .WhenTypeIs());\n\n var actual = new\n {\n Value = 1D / 3D\n };\n\n var expected = new\n {\n Value = 0.33D\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n public void Dispose() =>\n AssertionConfiguration.Current.Equivalency.Modify(_ => new EquivalencyOptions());\n }\n\n [Collection(\"ConfigurationSpecs\")]\n public sealed class Given_self_resetting_equivalency_plan : IDisposable\n {\n private static EquivalencyPlan Plan => AssertionConfiguration.Current.Equivalency.Plan;\n\n [Fact]\n public void When_inserting_a_step_then_it_should_precede_all_other_steps()\n {\n // Arrange / Act\n Plan.Insert();\n\n // Assert\n var addedStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n\n Plan.Should().StartWith(addedStep);\n }\n\n [Fact]\n public void When_inserting_a_step_before_another_then_it_should_precede_that_particular_step()\n {\n // Arrange / Act\n Plan.InsertBefore();\n\n // Assert\n var addedStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n var successor = Plan.LastOrDefault(s => s is DictionaryEquivalencyStep);\n\n Plan.Should().HaveElementPreceding(successor, addedStep);\n }\n\n [Fact]\n public void When_appending_a_step_then_it_should_precede_the_final_builtin_step()\n {\n // Arrange / Act\n Plan.Add();\n\n // Assert\n var equivalencyStep = Plan.LastOrDefault(s => s is SimpleEqualityEquivalencyStep);\n var subjectStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n\n Plan.Should().HaveElementPreceding(equivalencyStep, subjectStep);\n }\n\n [Fact]\n public void When_appending_a_step_after_another_then_it_should_precede_the_final_builtin_step()\n {\n // Arrange / Act\n Plan.AddAfter();\n\n // Assert\n var addedStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n var predecessor = Plan.LastOrDefault(s => s is DictionaryEquivalencyStep);\n\n Plan.Should().HaveElementSucceeding(predecessor, addedStep);\n }\n\n [Fact]\n public void When_appending_a_step_and_no_builtin_steps_are_there_then_it_should_precede_the_simple_equality_step()\n {\n // Arrange / Act\n Plan.Clear();\n Plan.Add();\n\n // Assert\n var subjectStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n Plan.Should().EndWith(subjectStep);\n }\n\n [Fact]\n public void When_removing_a_specific_step_then_it_should_precede_the_simple_equality_step()\n {\n // Arrange / Act\n Plan.Remove();\n\n // Assert\n Plan.Should().NotContain(s => s is SimpleEqualityEquivalencyStep);\n }\n\n [Fact]\n public void When_removing_a_specific_step_that_doesnt_exist_Then_it_should_precede_the_simple_equality_step()\n {\n // Arrange / Act\n var action = () => Plan.Remove();\n\n // Assert\n action.Should().NotThrow();\n }\n\n private class MyEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n AssertionChain.GetOrCreate().For(context).FailWith(GetType().FullName);\n\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n public void Dispose() => Plan.Reset();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EnumerableEquivalencyValidator.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Executes a single equivalency assertion on two collections, optionally recursive and with or without strict ordering.\n/// \ninternal class EnumerableEquivalencyValidator\n{\n private const int FailedItemsFastFailThreshold = 10;\n\n #region Private Definitions\n\n private readonly AssertionChain assertionChain;\n private readonly IValidateChildNodeEquivalency parent;\n private readonly IEquivalencyValidationContext context;\n\n #endregion\n\n public EnumerableEquivalencyValidator(AssertionChain assertionChain, IValidateChildNodeEquivalency parent,\n IEquivalencyValidationContext context)\n {\n this.assertionChain = assertionChain;\n this.parent = parent;\n this.context = context;\n Recursive = false;\n }\n\n public bool Recursive { get; init; }\n\n public OrderingRuleCollection OrderingRules { get; init; }\n\n public void Execute(object[] subject, T[] expectation)\n {\n if (AssertIsNotNull(expectation, subject) && AssertCollectionsHaveSameCount(subject, expectation))\n {\n if (Recursive)\n {\n using var _ = context.Tracer.WriteBlock(member =>\n Invariant($\"Structurally comparing {subject} and expectation {expectation} at {member.Expectation}\"));\n\n AssertElementGraphEquivalency(subject, expectation, context.CurrentNode);\n }\n else\n {\n using var _ = context.Tracer.WriteBlock(member =>\n Invariant(\n $\"Comparing subject {subject} and expectation {expectation} at {member.Expectation} using simple value equality\"));\n\n subject.Should().BeEquivalentTo(expectation);\n }\n }\n }\n\n private bool AssertIsNotNull(object expectation, object[] subject)\n {\n assertionChain\n .ForCondition(expectation is not null)\n .FailWith(\"Expected {context:subject} to be , but found {0}.\", [subject]);\n\n return assertionChain.Succeeded;\n }\n\n private bool AssertCollectionsHaveSameCount(ICollection subject, ICollection expectation)\n {\n assertionChain\n .AssertEitherCollectionIsNotEmpty(subject, expectation)\n .Then\n .AssertCollectionHasEnoughItems(subject, expectation)\n .Then\n .AssertCollectionHasNotTooManyItems(subject, expectation);\n\n return assertionChain.Succeeded;\n }\n\n private void AssertElementGraphEquivalency(object[] subjects, T[] expectations, INode currentNode)\n {\n unmatchedSubjectIndexes = Enumerable.Range(0, subjects.Length).ToList();\n\n if (OrderingRules.IsOrderingStrictFor(new ObjectInfo(new Comparands(subjects, expectations, typeof(T[])), currentNode)))\n {\n AssertElementGraphEquivalencyWithStrictOrdering(subjects, expectations);\n }\n else\n {\n AssertElementGraphEquivalencyWithLooseOrdering(subjects, expectations);\n }\n }\n\n private void AssertElementGraphEquivalencyWithStrictOrdering(object[] subjects, T[] expectations)\n {\n int failedCount = 0;\n\n foreach (int index in Enumerable.Range(0, expectations.Length))\n {\n T expectation = expectations[index];\n\n using var _ = context.Tracer.WriteBlock(member =>\n Invariant(\n $\"Strictly comparing expectation {expectation} at {member.Expectation} to item with index {index} in {subjects}\"));\n\n bool succeeded = StrictlyMatchAgainst(subjects, expectation, index);\n if (!succeeded)\n {\n failedCount++;\n if (failedCount >= FailedItemsFastFailThreshold)\n {\n context.Tracer.WriteLine(member =>\n $\"Aborting strict order comparison of collections after {FailedItemsFastFailThreshold} items failed at {member.Expectation}\");\n\n break;\n }\n }\n }\n }\n\n private void AssertElementGraphEquivalencyWithLooseOrdering(object[] subjects, T[] expectations)\n {\n int failedCount = 0;\n\n foreach (int index in Enumerable.Range(0, expectations.Length))\n {\n T expectation = expectations[index];\n\n using var _ = context.Tracer.WriteBlock(member =>\n Invariant(\n $\"Finding the best match of {expectation} within all items in {subjects} at {member.Expectation}[{index}]\"));\n\n bool succeeded = LooselyMatchAgainst(subjects, expectation, index);\n\n if (!succeeded)\n {\n failedCount++;\n\n if (failedCount >= FailedItemsFastFailThreshold)\n {\n context.Tracer.WriteLine(member =>\n $\"Fail failing loose order comparison of collection after {FailedItemsFastFailThreshold} items failed at {member.Expectation}\");\n\n break;\n }\n }\n }\n }\n\n private List unmatchedSubjectIndexes;\n\n private bool LooselyMatchAgainst(IList subjects, T expectation, int expectationIndex)\n {\n var results = new AssertionResultSet();\n int index = 0;\n\n GetTraceMessage getMessage = member =>\n $\"Comparing subject at {member.Subject}[{index}] with the expectation at {member.Expectation}[{expectationIndex}]\";\n\n int indexToBeRemoved = -1;\n\n for (var metaIndex = 0; metaIndex < unmatchedSubjectIndexes.Count; metaIndex++)\n {\n index = unmatchedSubjectIndexes[metaIndex];\n object subject = subjects[index];\n\n using var _ = context.Tracer.WriteBlock(getMessage);\n string[] failures = TryToMatch(subject, expectation, expectationIndex);\n\n results.AddSet(index, failures);\n\n if (results.ContainsSuccessfulSet())\n {\n context.Tracer.WriteLine(_ => \"It's a match\");\n indexToBeRemoved = metaIndex;\n break;\n }\n\n context.Tracer.WriteLine(_ => $\"Contained {failures.Length} failures\");\n }\n\n if (indexToBeRemoved != -1)\n {\n unmatchedSubjectIndexes.RemoveAt(indexToBeRemoved);\n }\n\n foreach (string failure in results.GetTheFailuresForTheSetWithTheFewestFailures(expectationIndex))\n {\n assertionChain.AddPreFormattedFailure(failure);\n }\n\n return indexToBeRemoved != -1;\n }\n\n private string[] TryToMatch(object subject, T expectation, int expectationIndex)\n {\n using var scope = new AssertionScope();\n\n parent.AssertEquivalencyOf(new Comparands(subject, expectation, typeof(T)), context.AsCollectionItem(expectationIndex));\n\n return scope.Discard();\n }\n\n private bool StrictlyMatchAgainst(object[] subjects, T expectation, int expectationIndex)\n {\n using var scope = new AssertionScope();\n object subject = subjects[expectationIndex];\n IEquivalencyValidationContext equivalencyValidationContext = context.AsCollectionItem(expectationIndex);\n\n parent.AssertEquivalencyOf(new Comparands(subject, expectation, typeof(T)), equivalencyValidationContext);\n\n bool failed = scope.HasFailures();\n return !failed;\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/UsersOfGetClosedGenericInterfaces.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Equivalency.Steps;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Engines;\nusing Bogus;\n\nnamespace Benchmarks;\n\n[SimpleJob(RunStrategy.Throughput, warmupCount: 3, iterationCount: 20)]\npublic class UsersOfGetClosedGenericInterfaces\n{\n private const int ValueCount = 100_000;\n\n private object[] values;\n\n private GenericDictionaryEquivalencyStep dictionaryStep;\n private GenericEnumerableEquivalencyStep enumerableStep;\n\n private IEquivalencyValidationContext context;\n\n private class Context : IEquivalencyValidationContext\n {\n public INode CurrentNode { get; }\n\n public Reason Reason { get; }\n\n public Tracer Tracer { get; }\n\n public IEquivalencyOptions Options { get; internal set; }\n\n public bool IsCyclicReference(object expectation) => throw new NotImplementedException();\n\n public IEquivalencyValidationContext AsNestedMember(IMember expectationMember) => throw new NotImplementedException();\n\n public IEquivalencyValidationContext AsCollectionItem(string index) => throw new NotImplementedException();\n\n public IEquivalencyValidationContext AsDictionaryItem(TKey key) =>\n throw new NotImplementedException();\n\n public IEquivalencyValidationContext Clone() => throw new NotImplementedException();\n }\n\n private class Config : IEquivalencyOptions\n {\n public IEnumerable SelectionRules => throw new NotImplementedException();\n\n public IEnumerable MatchingRules => throw new NotImplementedException();\n\n public bool IsRecursive => throw new NotImplementedException();\n\n public bool AllowInfiniteRecursion => throw new NotImplementedException();\n\n public CyclicReferenceHandling CyclicReferenceHandling => throw new NotImplementedException();\n\n public OrderingRuleCollection OrderingRules => throw new NotImplementedException();\n\n public ConversionSelector ConversionSelector => throw new NotImplementedException();\n\n public EnumEquivalencyHandling EnumEquivalencyHandling => throw new NotImplementedException();\n\n public IEnumerable UserEquivalencySteps => throw new NotImplementedException();\n\n public bool UseRuntimeTyping => false;\n\n public MemberVisibility IncludedProperties => throw new NotImplementedException();\n\n public MemberVisibility IncludedFields => throw new NotImplementedException();\n\n public bool IgnoreNonBrowsableOnSubject => throw new NotImplementedException();\n\n public bool ExcludeNonBrowsableOnExpectation => throw new NotImplementedException();\n\n public bool? CompareRecordsByValue => throw new NotImplementedException();\n\n public ITraceWriter TraceWriter => throw new NotImplementedException();\n\n public EqualityStrategy GetEqualityStrategy(Type type) => throw new NotImplementedException();\n\n public bool IgnoreLeadingWhitespace => throw new NotImplementedException();\n\n public bool IgnoreTrailingWhitespace => throw new NotImplementedException();\n\n public bool IgnoreCase => throw new NotImplementedException();\n\n public bool IgnoreNewlineStyle => throw new NotImplementedException();\n }\n\n [Params(typeof(DBNull), typeof(bool), typeof(char), typeof(sbyte), typeof(byte), typeof(short), typeof(ushort),\n typeof(int), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal), typeof(DateTime),\n typeof(string), typeof(TimeSpan), typeof(Guid), typeof(Dictionary), typeof(IEnumerable))]\n public Type DataType { get; set; }\n\n [GlobalSetup]\n [SuppressMessage(\"Style\", \"IDE0055:Fix formatting\", Justification = \"Big long list of one-liners\")]\n public void GlobalSetup()\n {\n dictionaryStep = new GenericDictionaryEquivalencyStep();\n enumerableStep = new GenericEnumerableEquivalencyStep();\n\n var faker = new Faker\n {\n Random = new Randomizer(localSeed: 1)\n };\n\n values = Enumerable.Range(0, ValueCount).Select(_ => CreateValue(faker)).ToArray();\n\n context = new Context\n {\n Options = new Config()\n };\n }\n\n private object CreateValue(Faker faker) => Type.GetTypeCode(DataType) switch\n {\n TypeCode.DBNull => DBNull.Value,\n TypeCode.Boolean => faker.Random.Bool(),\n TypeCode.Char => faker.Lorem.Letter().Single(),\n TypeCode.SByte => faker.Random.SByte(),\n TypeCode.Byte => faker.Random.Byte(),\n TypeCode.Int16 => faker.Random.Short(),\n TypeCode.UInt16 => faker.Random.UShort(),\n TypeCode.Int32 => faker.Random.Int(),\n TypeCode.UInt32 => faker.Random.UInt(),\n TypeCode.Int64 => faker.Random.Long(),\n TypeCode.UInt64 => faker.Random.ULong(),\n TypeCode.Single => faker.Random.Float(),\n TypeCode.Double => faker.Random.Double(),\n TypeCode.Decimal => faker.Random.Decimal(),\n TypeCode.DateTime => faker.Date.Between(DateTime.UtcNow.AddDays(-30), DateTime.UtcNow.AddDays(+30)),\n TypeCode.String => faker.Lorem.Lines(1),\n _ => CustomValue(faker),\n };\n\n private object CustomValue(Faker faker)\n {\n if (DataType == typeof(TimeSpan))\n {\n return faker.Date.Future() - faker.Date.Future();\n }\n else if (DataType == typeof(Guid))\n {\n return faker.Random.Guid();\n }\n else if (DataType == typeof(Dictionary))\n {\n return new Dictionary { { faker.Random.Int(), faker.Random.Int() } };\n }\n else if (DataType == typeof(IEnumerable))\n {\n return new[] { faker.Random.Int(), faker.Random.Int() };\n }\n\n throw new Exception(\"Unable to populate data of type \" + DataType);\n }\n\n [Benchmark]\n public void GenericDictionaryEquivalencyStep_CanHandle()\n {\n for (int i = 0; i < values.Length; i++)\n {\n dictionaryStep.Handle(new Comparands(values[i], values[0], typeof(object)), context, null);\n }\n }\n\n [Benchmark]\n public void GenericEnumerableEquivalencyStep_CanHandle()\n {\n for (int i = 0; i < values.Length; i++)\n {\n enumerableStep.Handle(new Comparands(values[i], values[0], typeof(object)), context, null);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IValidateChildNodeEquivalency.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic interface IValidateChildNodeEquivalency\n{\n /// \n /// Runs a deep recursive equivalency assertion on the provided .\n /// \n void AssertEquivalencyOf(Comparands comparands, IEquivalencyValidationContext context);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyValidationContext.cs", "using AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides information on a particular property during an assertion for structural equality of two object graphs.\n/// \npublic class EquivalencyValidationContext : IEquivalencyValidationContext\n{\n private Tracer tracer;\n\n public EquivalencyValidationContext(INode root, IEquivalencyOptions options)\n {\n Options = options;\n CurrentNode = root;\n CyclicReferenceDetector = new CyclicReferenceDetector();\n }\n\n public INode CurrentNode { get; }\n\n public Reason Reason { get; set; }\n\n public Tracer Tracer => tracer ??= new Tracer(CurrentNode, TraceWriter);\n\n public IEquivalencyOptions Options { get; }\n\n private CyclicReferenceDetector CyclicReferenceDetector { get; set; }\n\n public IEquivalencyValidationContext AsNestedMember(IMember expectationMember)\n {\n return new EquivalencyValidationContext(expectationMember, Options)\n {\n Reason = Reason,\n TraceWriter = TraceWriter,\n CyclicReferenceDetector = CyclicReferenceDetector\n };\n }\n\n public IEquivalencyValidationContext AsCollectionItem(string index)\n {\n return new EquivalencyValidationContext(Node.FromCollectionItem(index, CurrentNode), Options)\n {\n Reason = Reason,\n TraceWriter = TraceWriter,\n CyclicReferenceDetector = CyclicReferenceDetector\n };\n }\n\n public IEquivalencyValidationContext AsDictionaryItem(TKey key)\n {\n return new EquivalencyValidationContext(Node.FromDictionaryItem(key, CurrentNode), Options)\n {\n Reason = Reason,\n TraceWriter = TraceWriter,\n CyclicReferenceDetector = CyclicReferenceDetector\n };\n }\n\n public IEquivalencyValidationContext Clone()\n {\n return new EquivalencyValidationContext(CurrentNode, Options)\n {\n Reason = Reason,\n TraceWriter = TraceWriter,\n CyclicReferenceDetector = CyclicReferenceDetector\n };\n }\n\n public bool IsCyclicReference(object expectation)\n {\n bool compareByMembers = expectation is not null && Options.GetEqualityStrategy(expectation.GetType())\n is EqualityStrategy.Members or EqualityStrategy.ForceMembers;\n\n var reference = new ObjectReference(expectation, CurrentNode.Subject.PathAndName, compareByMembers);\n return CyclicReferenceDetector.IsCyclicReference(reference);\n }\n\n public ITraceWriter TraceWriter { get; set; }\n\n public override string ToString()\n {\n return Invariant($\"{{Path=\\\"{CurrentNode.Subject.PathAndName}\\\"}}\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/StringCollectionAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Collections;\n\npublic class StringCollectionAssertions : StringCollectionAssertions>\n{\n /// \n /// Initializes a new instance of the class.\n /// \n public StringCollectionAssertions(IEnumerable actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n }\n}\n\npublic class StringCollectionAssertions\n : StringCollectionAssertions>\n where TCollection : IEnumerable\n{\n /// \n /// Initializes a new instance of the class.\n /// \n public StringCollectionAssertions(TCollection actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n }\n}\n\npublic class StringCollectionAssertions : GenericCollectionAssertions\n where TCollection : IEnumerable\n where TAssertions : StringCollectionAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public StringCollectionAssertions(TCollection actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Expects the current collection to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their . To ignore\n /// the element order, use instead.\n /// \n /// An with the expected elements.\n public new AndConstraint Equal(params string[] expected)\n {\n return base.Equal(expected.AsEnumerable());\n }\n\n /// \n /// Expects the current collection to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their . To ignore\n /// the element order, use instead.\n /// \n /// An with the expected elements.\n public AndConstraint Equal(IEnumerable expected)\n {\n return base.Equal(expected);\n }\n\n /// \n /// Asserts that a collection of string is equivalent to another collection of strings.\n /// \n /// \n /// The two collections are equivalent when they both contain the same strings in any order. To assert that the elements\n /// are in the same order, use instead.\n /// \n public AndConstraint BeEquivalentTo(params string[] expectation)\n {\n return BeEquivalentTo(expectation, config => config);\n }\n\n /// \n /// Asserts that a collection of objects is equivalent to another collection of objects.\n /// \n /// \n /// The two collections are equivalent when they both contain the same strings in any order. To assert that the elements\n /// are in the same order, use instead.\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(IEnumerable expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection of objects is equivalent to another collection of objects.\n /// \n /// \n /// The two collections are equivalent when they both contain the same strings in any order. To assert that the elements\n /// are in the same order, use instead.\n /// \n /// An with the expected elements.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults can be modified through\n /// .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(IEnumerable expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions>\n options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults()).AsCollection();\n\n var context =\n new EquivalencyValidationContext(Node.From>(() => CurrentAssertionChain.CallerIdentifier), options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(IEnumerable),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that all strings in a collection of strings are equal to the given string.\n /// \n /// An expected .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint AllBe(string expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return AllBe(expectation, options => options, because, becauseArgs);\n }\n\n /// \n /// Asserts that all strings in a collection of strings are equal to the given string.\n /// \n /// An expected .\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllBe(string expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n string[] repeatedExpectation = RepeatAsManyAs(expectation, Subject).ToArray();\n\n // Because we have just manually created the collection based on single element\n // we are sure that we can force strict ordering, because ordering does not matter in terms\n // of correctness. On the other hand we do not want to change ordering rules for nested objects\n // in case user needs to use them. Strict ordering improves algorithmic complexity\n // from O(n^2) to O(n). For bigger tables it is necessary in order to achieve acceptable\n // execution times.\n Func, EquivalencyOptions> forceStringOrderingConfig =\n x => config(x).WithStrictOrderingFor(s => string.IsNullOrEmpty(s.Path));\n\n return BeEquivalentTo(repeatedExpectation, forceStringOrderingConfig, because, becauseArgs);\n }\n\n /// \n /// Asserts that the collection contains at least one string that matches the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndWhichConstraint ContainMatch(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match strings in collection against . Provide a wildcard pattern or use the Contain method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match strings in collection against an empty string. Provide a wildcard pattern or use the Contain method.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain a match of {0}{reason}, but found .\", wildcardPattern);\n\n string[] matches = [];\n\n int? firstMatch = null;\n\n if (assertionChain.Succeeded)\n {\n (matches, firstMatch) = AllThatMatch(wildcardPattern);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(matches.Length > 0)\n .FailWith(\"Expected {context:collection} {0} to contain a match of {1}{reason}.\", Subject, wildcardPattern);\n }\n\n return new AndWhichConstraint((TAssertions)this, matches, assertionChain, \"[\" + firstMatch + \"]\");\n }\n\n private (string[] MatchingItems, int? FirstMatchingIndex) AllThatMatch(string wildcardPattern)\n {\n int? firstMatchingIndex = null;\n\n var matches = Subject.Where((item, index) =>\n {\n using var scope = new AssertionScope();\n\n item.Should().Match(wildcardPattern);\n\n if (scope.Discard().Length == 0)\n {\n firstMatchingIndex ??= index;\n return true;\n }\n\n return false;\n });\n\n return (matches.ToArray(), firstMatchingIndex);\n }\n\n /// \n /// Asserts that the collection does not contain any string that matches the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint NotContainMatch(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match strings in collection against . Provide a wildcard pattern or use the NotContain method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match strings in collection against an empty string. Provide a wildcard pattern or use the NotContain method.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Did not expect {context:collection} to contain a match of {0}{reason}, but found .\",\n wildcardPattern);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(NotContainsMatch(wildcardPattern))\n .FailWith(\"Did not expect {context:collection} {0} to contain a match of {1}{reason}.\", Subject, wildcardPattern);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n private bool NotContainsMatch(string wildcardPattern)\n {\n using var scope = new AssertionScope();\n\n return Subject.All(item =>\n {\n item.Should().NotMatch(wildcardPattern);\n return scope.Discard().Length == 0;\n });\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/SelfReferenceEquivalencyOptions.cs", "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.Linq.Expressions;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Matching;\nusing AwesomeAssertions.Equivalency.Ordering;\nusing AwesomeAssertions.Equivalency.Selection;\nusing AwesomeAssertions.Equivalency.Steps;\nusing AwesomeAssertions.Equivalency.Tracing;\n\nnamespace AwesomeAssertions.Equivalency;\n\n#pragma warning disable CA1033 //An unsealed externally visible type provides an explicit method implementation of a public interface and does not provide an alternative externally visible method that has the same name.\n\n/// \n/// Represents the run-time behavior of a structural equivalency assertion.\n/// \npublic abstract class SelfReferenceEquivalencyOptions : IEquivalencyOptions\n where TSelf : SelfReferenceEquivalencyOptions\n{\n #region Private Definitions\n\n private readonly EqualityStrategyProvider equalityStrategyProvider;\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private readonly List selectionRules = [];\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private readonly List matchingRules = [];\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private readonly List userEquivalencySteps = [];\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private CyclicReferenceHandling cyclicReferenceHandling = CyclicReferenceHandling.ThrowException;\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n protected OrderingRuleCollection OrderingRules { get; } = [];\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private bool isRecursive;\n\n private bool allowInfiniteRecursion;\n\n private EnumEquivalencyHandling enumEquivalencyHandling;\n\n private bool useRuntimeTyping;\n\n private MemberVisibility includedProperties;\n private MemberVisibility includedFields;\n private bool ignoreNonBrowsableOnSubject;\n private bool excludeNonBrowsableOnExpectation;\n\n private IEqualityComparer stringComparer;\n\n #endregion\n\n private protected SelfReferenceEquivalencyOptions()\n {\n equalityStrategyProvider = new EqualityStrategyProvider();\n\n AddMatchingRule(new MustMatchByNameRule());\n\n OrderingRules.Add(new ByteArrayOrderingRule());\n }\n\n /// \n /// Creates an instance of the equivalency assertions options based on defaults previously configured by the caller.\n /// \n protected SelfReferenceEquivalencyOptions(IEquivalencyOptions defaults)\n {\n equalityStrategyProvider = new EqualityStrategyProvider(defaults.GetEqualityStrategy)\n {\n CompareRecordsByValue = defaults.CompareRecordsByValue\n };\n\n isRecursive = defaults.IsRecursive;\n cyclicReferenceHandling = defaults.CyclicReferenceHandling;\n allowInfiniteRecursion = defaults.AllowInfiniteRecursion;\n enumEquivalencyHandling = defaults.EnumEquivalencyHandling;\n useRuntimeTyping = defaults.UseRuntimeTyping;\n includedProperties = defaults.IncludedProperties;\n includedFields = defaults.IncludedFields;\n ignoreNonBrowsableOnSubject = defaults.IgnoreNonBrowsableOnSubject;\n excludeNonBrowsableOnExpectation = defaults.ExcludeNonBrowsableOnExpectation;\n IgnoreLeadingWhitespace = defaults.IgnoreLeadingWhitespace;\n IgnoreTrailingWhitespace = defaults.IgnoreTrailingWhitespace;\n IgnoreCase = defaults.IgnoreCase;\n IgnoreNewlineStyle = defaults.IgnoreNewlineStyle;\n\n ConversionSelector = defaults.ConversionSelector.Clone();\n\n selectionRules.AddRange(defaults.SelectionRules);\n userEquivalencySteps.AddRange(defaults.UserEquivalencySteps);\n matchingRules.AddRange(defaults.MatchingRules);\n OrderingRules = new OrderingRuleCollection(defaults.OrderingRules);\n\n TraceWriter = defaults.TraceWriter;\n\n RemoveSelectionRule();\n RemoveSelectionRule();\n }\n\n /// \n /// Gets an ordered collection of selection rules that define what members are included.\n /// \n IEnumerable IEquivalencyOptions.SelectionRules\n {\n get\n {\n bool hasConflictingRules = selectionRules.Exists(rule => rule.IncludesMembers);\n\n if (includedProperties.HasFlag(MemberVisibility.Public) && !hasConflictingRules)\n {\n yield return new AllPropertiesSelectionRule();\n }\n\n if (includedFields.HasFlag(MemberVisibility.Public) && !hasConflictingRules)\n {\n yield return new AllFieldsSelectionRule();\n }\n\n if (excludeNonBrowsableOnExpectation)\n {\n yield return new ExcludeNonBrowsableMembersRule();\n }\n\n foreach (IMemberSelectionRule rule in selectionRules)\n {\n yield return rule;\n }\n }\n }\n\n /// \n /// Gets an ordered collection of matching rules that determine which subject members are matched with which\n /// expectation members.\n /// \n IEnumerable IEquivalencyOptions.MatchingRules => matchingRules;\n\n /// \n /// Gets an ordered collection of Equivalency steps how a subject is compared with the expectation.\n /// \n IEnumerable IEquivalencyOptions.UserEquivalencySteps => userEquivalencySteps;\n\n public ConversionSelector ConversionSelector { get; } = new();\n\n /// \n /// Gets an ordered collection of rules that determine whether or not the order of collections is important. By\n /// default,\n /// ordering is irrelevant.\n /// \n OrderingRuleCollection IEquivalencyOptions.OrderingRules => OrderingRules;\n\n /// \n /// Gets value indicating whether the equality check will include nested collections and complex types.\n /// \n bool IEquivalencyOptions.IsRecursive => isRecursive;\n\n bool IEquivalencyOptions.AllowInfiniteRecursion => allowInfiniteRecursion;\n\n /// \n /// Gets value indicating how cyclic references should be handled. By default, it will throw an exception.\n /// \n CyclicReferenceHandling IEquivalencyOptions.CyclicReferenceHandling => cyclicReferenceHandling;\n\n EnumEquivalencyHandling IEquivalencyOptions.EnumEquivalencyHandling => enumEquivalencyHandling;\n\n bool IEquivalencyOptions.UseRuntimeTyping => useRuntimeTyping;\n\n MemberVisibility IEquivalencyOptions.IncludedProperties => includedProperties;\n\n MemberVisibility IEquivalencyOptions.IncludedFields => includedFields;\n\n bool IEquivalencyOptions.IgnoreNonBrowsableOnSubject => ignoreNonBrowsableOnSubject;\n\n bool IEquivalencyOptions.ExcludeNonBrowsableOnExpectation => excludeNonBrowsableOnExpectation;\n\n public bool? CompareRecordsByValue => equalityStrategyProvider.CompareRecordsByValue;\n\n EqualityStrategy IEquivalencyOptions.GetEqualityStrategy(Type type)\n => equalityStrategyProvider.GetEqualityStrategy(type);\n\n public bool IgnoreLeadingWhitespace { get; private set; }\n\n public bool IgnoreTrailingWhitespace { get; private set; }\n\n public bool IgnoreCase { get; private set; }\n\n public bool IgnoreNewlineStyle { get; private set; }\n\n public ITraceWriter TraceWriter { get; private set; }\n\n /// \n /// Causes inclusion of only public properties of the subject as far as they are defined on the declared type.\n /// \n /// \n /// This clears all previously registered selection rules.\n /// \n public TSelf IncludingAllDeclaredProperties()\n {\n PreferringDeclaredMemberTypes();\n\n ExcludingFields();\n IncludingProperties();\n\n WithoutSelectionRules();\n\n return (TSelf)this;\n }\n\n /// \n /// Causes inclusion of only public properties of the subject based on its run-time type rather than its declared type.\n /// \n /// \n /// This clears all previously registered selection rules.\n /// \n public TSelf IncludingAllRuntimeProperties()\n {\n PreferringRuntimeMemberTypes();\n\n ExcludingFields();\n IncludingProperties();\n\n WithoutSelectionRules();\n\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to include public fields.\n /// \n /// \n /// This is part of the default behavior.\n /// \n public TSelf IncludingFields()\n {\n includedFields = MemberVisibility.Public;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to include public and internal fields.\n /// \n public TSelf IncludingInternalFields()\n {\n includedFields = MemberVisibility.Public | MemberVisibility.Internal;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to exclude fields.\n /// \n /// \n /// This does not preclude use of `Including`.\n /// \n public TSelf ExcludingFields()\n {\n includedFields = MemberVisibility.None;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to include public properties.\n /// \n /// \n /// This is part of the default behavior.\n /// \n public TSelf IncludingProperties()\n {\n includedProperties = MemberVisibility.Public | MemberVisibility.ExplicitlyImplemented |\n MemberVisibility.DefaultInterfaceProperties;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to include public and internal properties.\n /// \n public TSelf IncludingInternalProperties()\n {\n includedProperties = MemberVisibility.Public | MemberVisibility.Internal | MemberVisibility.ExplicitlyImplemented |\n MemberVisibility.DefaultInterfaceProperties;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to exclude properties.\n /// \n /// \n /// This does not preclude use of `Including`.\n /// \n public TSelf ExcludingProperties()\n {\n includedProperties = MemberVisibility.None;\n return (TSelf)this;\n }\n\n /// \n /// Excludes properties that are explicitly implemented from the equivalency comparison.\n /// \n public TSelf ExcludingExplicitlyImplementedProperties()\n {\n includedProperties &= ~MemberVisibility.ExplicitlyImplemented;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to exclude non-browsable members in the expectation (members set to\n /// ). It is not required that they be marked non-browsable in the subject. Use\n /// to ignore non-browsable members in the subject.\n /// \n public TSelf ExcludingNonBrowsableMembers()\n {\n excludeNonBrowsableOnExpectation = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to treat non-browsable members in the subject as though they do not exist. If you need to\n /// ignore non-browsable members in the expectation, use .\n /// \n public TSelf IgnoringNonBrowsableMembersOnSubject()\n {\n ignoreNonBrowsableOnSubject = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the structural equality comparison to use the run-time types\n /// of the members to drive the assertion.\n /// \n public TSelf PreferringRuntimeMemberTypes()\n {\n useRuntimeTyping = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the structural equality comparison to prefer the declared types\n /// of the members when executing assertions.\n /// \n /// \n /// In reality, the declared types of the members are only known for the members of the root object,\n /// or the objects in a root collection. Beyond that, AwesomeAssertions only knows the run-time types of the members.\n /// \n public TSelf PreferringDeclaredMemberTypes()\n {\n useRuntimeTyping = false;\n return (TSelf)this;\n }\n\n /// \n /// Excludes a (nested) property based on a predicate from the structural equality check.\n /// \n public TSelf Excluding(Expression> predicate)\n {\n AddSelectionRule(new ExcludeMemberByPredicateSelectionRule(predicate));\n return (TSelf)this;\n }\n\n /// \n /// Includes the specified member in the equality check.\n /// \n /// \n /// This overrides the default behavior of including all declared members.\n /// \n public TSelf Including(Expression> predicate)\n {\n AddSelectionRule(new IncludeMemberByPredicateSelectionRule(predicate));\n return (TSelf)this;\n }\n\n /// \n /// Tries to match the members of the expectation with equally named members on the subject. Ignores those\n /// members that don't exist on the subject and previously registered matching rules.\n /// \n public TSelf ExcludingMissingMembers()\n {\n matchingRules.RemoveAll(x => x is MustMatchByNameRule);\n matchingRules.Add(new TryMatchByNameRule());\n return (TSelf)this;\n }\n\n /// \n /// Requires the subject to have members which are equally named to members on the expectation.\n /// \n public TSelf ThrowingOnMissingMembers()\n {\n matchingRules.RemoveAll(x => x is TryMatchByNameRule);\n matchingRules.Add(new MustMatchByNameRule());\n return (TSelf)this;\n }\n\n /// \n /// Overrides the comparison of subject and expectation to use provided \n /// when the predicate is met.\n /// \n /// \n /// The assertion to execute when the predicate is met.\n /// \n public Restriction Using(Action> action)\n {\n return new Restriction((TSelf)this, action);\n }\n\n /// \n /// Causes the structural equality comparison to recursively traverse the object graph and compare the fields and\n /// properties of any nested objects and objects in collections.\n /// \n /// \n /// This is the default behavior. You can override this using .\n /// \n public TSelf IncludingNestedObjects()\n {\n isRecursive = true;\n return (TSelf)this;\n }\n\n /// \n /// Stops the structural equality check from recursively comparing the members of any nested objects.\n /// \n /// \n /// If a property or field points to a complex type or collection, a simple call will\n /// be done instead of recursively looking at the members of the nested object.\n /// \n public TSelf WithoutRecursing()\n {\n isRecursive = false;\n return (TSelf)this;\n }\n\n /// \n /// Causes the structural equality check to ignore any cyclic references.\n /// \n /// \n /// By default, cyclic references within the object graph will cause an exception to be thrown.\n /// \n public TSelf IgnoringCyclicReferences()\n {\n cyclicReferenceHandling = CyclicReferenceHandling.Ignore;\n return (TSelf)this;\n }\n\n /// \n /// Disables limitations on recursion depth when the structural equality check is configured to include nested objects\n /// \n public TSelf AllowingInfiniteRecursion()\n {\n allowInfiniteRecursion = true;\n return (TSelf)this;\n }\n\n /// \n /// Clears all selection rules, including those that were added by default.\n /// \n public TSelf WithoutSelectionRules()\n {\n selectionRules.Clear();\n return (TSelf)this;\n }\n\n /// \n /// Clears all matching rules, including those that were added by default.\n /// \n public TSelf WithoutMatchingRules()\n {\n matchingRules.Clear();\n return (TSelf)this;\n }\n\n /// \n /// Adds a selection rule to the ones already added by default, and which is evaluated after all existing rules.\n /// \n public TSelf Using(IMemberSelectionRule selectionRule)\n {\n return AddSelectionRule(selectionRule);\n }\n\n /// \n /// Adds a matching rule to the ones already added by default, and which is evaluated before all existing rules.\n /// \n public TSelf Using(IMemberMatchingRule matchingRule)\n {\n return AddMatchingRule(matchingRule);\n }\n\n /// \n /// Adds an ordering rule to the ones already added by default, and which is evaluated after all existing rules.\n /// \n public TSelf Using(IOrderingRule orderingRule)\n {\n return AddOrderingRule(orderingRule);\n }\n\n /// \n /// Adds an equivalency step rule to the ones already added by default, and which is evaluated before previous\n /// user-registered steps\n /// \n public TSelf Using(IEquivalencyStep equivalencyStep)\n {\n return AddEquivalencyStep(equivalencyStep);\n }\n\n /// \n /// Ensures the equivalency comparison will create and use an instance of \n /// that implements , any time\n /// when a property is of type .\n /// \n public TSelf Using()\n where TEqualityComparer : IEqualityComparer, new()\n {\n return Using(new TEqualityComparer());\n }\n\n /// \n /// Ensures the equivalency comparison will use the specified implementation of \n /// any time when a property is of type .\n /// \n public TSelf Using(IEqualityComparer comparer)\n {\n userEquivalencySteps.Insert(0, new EqualityComparerEquivalencyStep(comparer));\n\n return (TSelf)this;\n }\n\n /// \n /// Ensures the equivalency comparison will use the specified implementation of \n /// any time when a property is a .\n /// \n public TSelf Using(IEqualityComparer comparer)\n {\n userEquivalencySteps.Insert(0, new EqualityComparerEquivalencyStep(comparer));\n stringComparer = comparer;\n\n return (TSelf)this;\n }\n\n /// \n /// Causes all collections to be compared in the order in which the items appear in the expectation.\n /// \n public TSelf WithStrictOrdering()\n {\n OrderingRules.Clear();\n OrderingRules.Add(new MatchAllOrderingRule());\n return (TSelf)this;\n }\n\n /// \n /// Causes the collection identified by the provided to be compared in the order\n /// in which the items appear in the expectation.\n /// \n public TSelf WithStrictOrderingFor(Expression> predicate)\n {\n OrderingRules.Add(new PredicateBasedOrderingRule(predicate));\n return (TSelf)this;\n }\n\n /// \n /// Causes all collections - except bytes - to be compared ignoring the order in which the items appear in the expectation.\n /// \n public TSelf WithoutStrictOrdering()\n {\n OrderingRules.Clear();\n OrderingRules.Add(new ByteArrayOrderingRule());\n return (TSelf)this;\n }\n\n /// \n /// Causes the collection identified by the provided to be compared ignoring the order\n /// in which the items appear in the expectation.\n /// \n public TSelf WithoutStrictOrderingFor(Expression> predicate)\n {\n OrderingRules.Add(new PredicateBasedOrderingRule(predicate)\n {\n Invert = true\n });\n\n return (TSelf)this;\n }\n\n /// \n /// Causes to compare Enum properties using the result of their ToString method.\n /// \n /// \n /// By default, enums are compared by value.\n /// \n public TSelf ComparingEnumsByName()\n {\n enumEquivalencyHandling = EnumEquivalencyHandling.ByName;\n return (TSelf)this;\n }\n\n /// \n /// Causes to compare Enum members using their underlying value only.\n /// \n /// \n /// This is the default.\n /// \n public TSelf ComparingEnumsByValue()\n {\n enumEquivalencyHandling = EnumEquivalencyHandling.ByValue;\n return (TSelf)this;\n }\n\n /// \n /// Ensures records by default are compared by value instead of their members.\n /// \n public TSelf ComparingRecordsByValue()\n {\n equalityStrategyProvider.CompareRecordsByValue = true;\n return (TSelf)this;\n }\n\n /// \n /// Ensures records by default are compared by their members even though they override\n /// the method.\n /// \n /// \n /// This is the default.\n /// \n public TSelf ComparingRecordsByMembers()\n {\n equalityStrategyProvider.CompareRecordsByValue = false;\n return (TSelf)this;\n }\n\n /// \n /// Marks the as a type that should be compared by its members even though it may override\n /// the method.\n /// \n public TSelf ComparingByMembers() => ComparingByMembers(typeof(T));\n\n /// \n /// Marks as a type that should be compared by its members even though it may override\n /// the method.\n /// \n /// is .\n public TSelf ComparingByMembers(Type type)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n if (type.IsPrimitive)\n {\n throw new InvalidOperationException($\"Cannot compare a primitive type such as {type.ToFormattedString()} by its members\");\n }\n\n if (!equalityStrategyProvider.AddReferenceType(type))\n {\n throw new InvalidOperationException(\n $\"Can't compare {type.Name} by its members if it already setup to be compared by value\");\n }\n\n return (TSelf)this;\n }\n\n /// \n /// Marks the as a value type which must be compared using its\n /// method, regardless of it overriding it or not.\n /// \n public TSelf ComparingByValue() => ComparingByValue(typeof(T));\n\n /// \n /// Marks as a value type which must be compared using its\n /// method, regardless of it overriding it or not.\n /// \n /// is .\n public TSelf ComparingByValue(Type type)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n if (!equalityStrategyProvider.AddValueType(type))\n {\n throw new InvalidOperationException(\n $\"Can't compare {type.Name} by value if it already setup to be compared by its members\");\n }\n\n return (TSelf)this;\n }\n\n /// \n /// Enables tracing the steps the equivalency validation followed to compare two graphs.\n /// \n public TSelf WithTracing(ITraceWriter writer = null)\n {\n TraceWriter = writer ?? new StringBuilderTraceWriter();\n return (TSelf)this;\n }\n\n /// \n /// Instructs the equivalency comparison to try to convert the values of\n /// matching properties before running any of the other steps.\n /// \n public TSelf WithAutoConversion()\n {\n ConversionSelector.IncludeAll();\n return (TSelf)this;\n }\n\n /// \n /// Instructs the equivalency comparison to try to convert the value of\n /// a specific member on the expectation object before running any of the other steps.\n /// \n public TSelf WithAutoConversionFor(Expression> predicate)\n {\n ConversionSelector.Include(predicate);\n return (TSelf)this;\n }\n\n /// \n /// Instructs the equivalency comparison to prevent trying to convert the value of\n /// a specific member on the expectation object before running any of the other steps.\n /// \n public TSelf WithoutAutoConversionFor(Expression> predicate)\n {\n ConversionSelector.Exclude(predicate);\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to ignore leading whitespace when comparing s.\n /// \n /// \n /// Note: This affects the index of first mismatch, as the removed whitespace is also ignored for the index calculation!\n /// \n public TSelf IgnoringLeadingWhitespace()\n {\n IgnoreLeadingWhitespace = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to ignore trailing whitespace when comparing s.\n /// \n public TSelf IgnoringTrailingWhitespace()\n {\n IgnoreTrailingWhitespace = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to compare s case-insensitive.\n /// \n public TSelf IgnoringCase()\n {\n IgnoreCase = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to ignore the newline style when comparing s.\n /// \n /// \n /// Enabling this option will replace all occurences of \\r\\n and \\r with \\n in the strings before comparing them.\n /// \n public TSelf IgnoringNewlineStyle()\n {\n IgnoreNewlineStyle = true;\n return (TSelf)this;\n }\n\n /// \n /// Returns the comparer for strings, which is either an explicitly specified comparer via or an ordinal comparer depending on .\n /// \n internal IEqualityComparer GetStringComparerOrDefault()\n {\n return stringComparer ?? (IgnoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);\n }\n\n /// \n /// Returns a string that represents the current object.\n /// \n /// \n /// A string that represents the current object.\n /// \n /// 2\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\")]\n public override string ToString()\n {\n var builder = new StringBuilder();\n\n builder.Append(\"- Prefer the \")\n .Append(useRuntimeTyping ? \"runtime\" : \"declared\")\n .AppendLine(\" type of the members\");\n\n if (ignoreNonBrowsableOnSubject)\n {\n builder.AppendLine(\"- Do not consider members marked non-browsable on the subject\");\n }\n\n if (isRecursive && allowInfiniteRecursion)\n {\n builder.AppendLine(\"- Recurse indefinitely\");\n }\n\n builder.AppendFormat(CultureInfo.InvariantCulture,\n \"- Compare enums by {0}\" + Environment.NewLine,\n enumEquivalencyHandling == EnumEquivalencyHandling.ByName ? \"name\" : \"value\");\n\n if (cyclicReferenceHandling == CyclicReferenceHandling.Ignore)\n {\n builder.AppendLine(\"- Ignoring cyclic references\");\n }\n\n builder\n .AppendLine(\"- Compare tuples by their properties\")\n .AppendLine(\"- Compare anonymous types by their properties\")\n .Append(equalityStrategyProvider);\n\n if (excludeNonBrowsableOnExpectation)\n {\n builder.AppendLine(\"- Exclude non-browsable members\");\n }\n else\n {\n builder.AppendLine(\"- Include non-browsable members\");\n }\n\n foreach (IMemberSelectionRule rule in selectionRules)\n {\n builder.Append(\"- \").AppendLine(rule.ToString());\n }\n\n foreach (IMemberMatchingRule rule in matchingRules)\n {\n builder.Append(\"- \").AppendLine(rule.ToString());\n }\n\n foreach (IEquivalencyStep step in userEquivalencySteps)\n {\n builder.Append(\"- \").AppendLine(step.ToString());\n }\n\n foreach (IOrderingRule rule in OrderingRules)\n {\n builder.Append(\"- \").AppendLine(rule.ToString());\n }\n\n builder.Append(\"- \").AppendLine(ConversionSelector.ToString());\n\n return builder.ToString();\n }\n\n /// \n /// Defines additional overrides when used with \n /// \n public class Restriction\n {\n private readonly Action> action;\n private readonly TSelf options;\n\n public Restriction(TSelf options, Action> action)\n {\n this.options = options;\n this.action = action;\n }\n\n /// \n /// Allows overriding the way structural equality is applied to (nested) objects of type\n /// \n /// \n public TSelf WhenTypeIs()\n where TMemberType : TMember\n {\n When(info => info.RuntimeType.IsSameOrInherits(typeof(TMemberType)));\n return options;\n }\n\n /// \n /// Allows overriding the way structural equality is applied to particular members.\n /// \n /// \n /// A predicate based on the of the subject that is used to identify the property for which\n /// the\n /// override applies.\n /// \n public TSelf When(Expression> predicate)\n {\n options.userEquivalencySteps.Insert(0,\n new AssertionRuleEquivalencyStep(predicate, action));\n\n return options;\n }\n }\n\n #region Non-fluent API\n\n private void RemoveSelectionRule()\n where T : IMemberSelectionRule\n {\n selectionRules.RemoveAll(selectionRule => selectionRule is T);\n }\n\n protected internal TSelf AddSelectionRule(IMemberSelectionRule selectionRule)\n {\n selectionRules.Add(selectionRule);\n return (TSelf)this;\n }\n\n protected TSelf AddMatchingRule(IMemberMatchingRule matchingRule)\n {\n matchingRules.Insert(0, matchingRule);\n return (TSelf)this;\n }\n\n private TSelf AddOrderingRule(IOrderingRule orderingRule)\n {\n OrderingRules.Add(orderingRule);\n return (TSelf)this;\n }\n\n private TSelf AddEquivalencyStep(IEquivalencyStep equivalencyStep)\n {\n userEquivalencySteps.Add(equivalencyStep);\n return (TSelf)this;\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/ObjectAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \npublic class ObjectAssertions : ObjectAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public ObjectAssertions(object value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a value equals using the provided .\n /// \n /// The expected value\n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Be(TExpectation expected, IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is TExpectation subject && comparer.Equals(subject, expected))\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that a value does not equal using the provided .\n /// \n /// The unexpected value\n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBe(TExpectation unexpected, IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .ForCondition(Subject is not TExpectation subject || !comparer.Equals(subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Did not expect {context} to be equal to {0}{reason}.\", unexpected);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that a value is one of the specified using the provided .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndConstraint BeOneOf(IEnumerable validValues,\n IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(validValues);\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .ForCondition(Subject is TExpectation subject && validValues.Contains(subject, comparer))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint(this);\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class ObjectAssertions : ReferenceTypeAssertions\n where TAssertions : ObjectAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public ObjectAssertions(TSubject value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a value equals using its implementation.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TSubject expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(ObjectExtensions.GetComparer()(Subject, expected))\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value equals using the provided .\n /// \n /// The expected value\n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Be(TSubject expected, IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(comparer.Equals(Subject, expected))\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value does not equal using its method.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TSubject unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!ObjectExtensions.GetComparer()(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Did not expect {context} to be equal to {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value does not equal using the provided .\n /// \n /// The unexpected value\n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBe(TSubject unexpected, IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .ForCondition(!comparer.Equals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Did not expect {context} to be equal to {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object is equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that an object is equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(TExpectation expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var context = new EquivalencyValidationContext(Node.From(() =>\n CurrentAssertionChain.CallerIdentifier), options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object is not equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The unexpected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(\n TExpectation unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotBeEquivalentTo(unexpected, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that an object is not equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// \n /// The unexpected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeEquivalentTo(\n TExpectation unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n bool hasMismatches;\n\n using (var scope = new AssertionScope())\n {\n BeEquivalentTo(unexpected, config);\n hasMismatches = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(hasMismatches)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} not to be equivalent to {0}{reason}, but they are.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params TSubject[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndConstraint BeOneOf(IEnumerable validValues,\n IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(validValues);\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .ForCondition(validValues.Contains(Subject, comparer))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() or BeSameAs() instead?\");\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"object\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyPlan.cs", "#region\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency.Steps;\n\n#endregion\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a mutable collection of equivalency steps that can be reordered and/or amended with additional\n/// custom equivalency steps.\n/// \npublic class EquivalencyPlan : IEnumerable\n{\n private List steps = GetDefaultSteps();\n\n public IEnumerator GetEnumerator()\n {\n return steps.GetEnumerator();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n /// \n /// Adds a new after any of the built-in steps, with the exception of the final\n /// .\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Add()\n where TStep : IEquivalencyStep, new()\n {\n InsertBefore();\n }\n\n /// \n /// Adds a new right after the specified .\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void AddAfter()\n where TStep : IEquivalencyStep, new()\n {\n int insertIndex = Math.Max(steps.Count - 1, 0);\n\n IEquivalencyStep predecessor = steps.LastOrDefault(s => s is TPredecessor);\n\n if (predecessor is not null)\n {\n insertIndex = Math.Min(insertIndex, steps.LastIndexOf(predecessor) + 1);\n }\n\n steps.Insert(insertIndex, new TStep());\n }\n\n /// \n /// Inserts a new before any of the built-in steps.\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Insert()\n where TStep : IEquivalencyStep, new()\n {\n steps.Insert(0, new TStep());\n }\n\n /// \n /// Inserts a new just before the .\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void InsertBefore()\n where TStep : IEquivalencyStep, new()\n {\n int insertIndex = Math.Max(steps.Count - 1, 0);\n\n IEquivalencyStep equalityStep = steps.LastOrDefault(s => s is TSuccessor);\n\n if (equalityStep is not null)\n {\n insertIndex = steps.LastIndexOf(equalityStep);\n }\n\n steps.Insert(insertIndex, new TStep());\n }\n\n /// \n /// Removes all instances of the specified from the current step.\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Remove()\n where TStep : IEquivalencyStep\n {\n steps.RemoveAll(s => s is TStep);\n }\n\n /// \n /// Removes each and every built-in .\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Clear()\n {\n steps.Clear();\n }\n\n /// \n /// Removes all custom s.\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Reset()\n {\n steps = GetDefaultSteps();\n }\n\n private static List GetDefaultSteps()\n {\n return\n [\n new RunAllUserStepsEquivalencyStep(),\n new AutoConversionStep(),\n new ReferenceEqualityEquivalencyStep(),\n new GenericDictionaryEquivalencyStep(),\n new XDocumentEquivalencyStep(),\n new XElementEquivalencyStep(),\n new XAttributeEquivalencyStep(),\n new DictionaryEquivalencyStep(),\n new MultiDimensionalArrayEquivalencyStep(),\n new GenericEnumerableEquivalencyStep(),\n new EnumerableEquivalencyStep(),\n new StringEqualityEquivalencyStep(),\n new EnumEqualityStep(),\n new ValueTypeEquivalencyStep(),\n new StructuralEqualityEquivalencyStep(),\n new SimpleEqualityEquivalencyStep(),\n ];\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/ConversionSelector.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Equivalency.Steps;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Collects the members that need to be converted by the .\n/// \npublic class ConversionSelector\n{\n private sealed class ConversionSelectorRule\n {\n public Func Predicate { get; }\n\n public string Description { get; }\n\n public ConversionSelectorRule(Func predicate, string description)\n {\n Predicate = predicate;\n Description = description;\n }\n }\n\n private readonly List inclusions;\n private readonly List exclusions;\n\n public ConversionSelector()\n : this([], [])\n {\n }\n\n private ConversionSelector(List inclusions, List exclusions)\n {\n this.inclusions = inclusions;\n this.exclusions = exclusions;\n }\n\n public void IncludeAll()\n {\n inclusions.Add(new ConversionSelectorRule(_ => true, \"Try conversion of all members. \"));\n }\n\n /// \n /// Instructs the equivalency comparison to try to convert the value of\n /// a specific member on the expectation object before running any of the other steps.\n /// \n /// is .\n public void Include(Expression> predicate)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n inclusions.Add(new ConversionSelectorRule(\n predicate.Compile(),\n $\"Try conversion of member {predicate.Body}. \"));\n }\n\n /// \n /// Instructs the equivalency comparison to prevent trying to convert the value of\n /// a specific member on the expectation object before running any of the other steps.\n /// \n /// is .\n public void Exclude(Expression> predicate)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n exclusions.Add(new ConversionSelectorRule(\n predicate.Compile(),\n $\"Do not convert member {predicate.Body}.\"));\n }\n\n public bool RequiresConversion(Comparands comparands, INode currentNode)\n {\n if (inclusions.Count == 0)\n {\n return false;\n }\n\n var objectInfo = new ObjectInfo(comparands, currentNode);\n\n return inclusions.Exists(p => p.Predicate(objectInfo)) && !exclusions.Exists(p => p.Predicate(objectInfo));\n }\n\n public override string ToString()\n {\n if (inclusions.Count == 0 && exclusions.Count == 0)\n {\n return \"Without automatic conversion.\";\n }\n\n var descriptionBuilder = new StringBuilder();\n\n foreach (ConversionSelectorRule inclusion in inclusions)\n {\n descriptionBuilder.Append(inclusion.Description);\n }\n\n foreach (ConversionSelectorRule exclusion in exclusions)\n {\n descriptionBuilder.Append(exclusion.Description);\n }\n\n return descriptionBuilder.ToString();\n }\n\n public ConversionSelector Clone()\n {\n return new ConversionSelector(new List(inclusions), new List(exclusions));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyOptions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Equivalency.Matching;\nusing AwesomeAssertions.Equivalency.Ordering;\nusing AwesomeAssertions.Equivalency.Selection;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents the run-time type-specific behavior of a structural equivalency assertion.\n/// \npublic class EquivalencyOptions\n : SelfReferenceEquivalencyOptions>\n{\n public EquivalencyOptions()\n {\n }\n\n public EquivalencyOptions(IEquivalencyOptions defaults)\n : base(defaults)\n {\n }\n\n /// \n /// Excludes the specified (nested) member from the structural equality check.\n /// \n public EquivalencyOptions Excluding(Expression> expression)\n {\n foreach (var memberPath in expression.GetMemberPaths())\n {\n AddSelectionRule(new ExcludeMemberByPathSelectionRule(memberPath));\n }\n\n return this;\n }\n\n /// \n /// Selects a collection to define exclusions at.\n /// Allows to navigate deeper by using .\n /// \n public NestedExclusionOptionBuilder For(\n Expression>> expression)\n {\n return new NestedExclusionOptionBuilder(\n this, new ExcludeMemberByPathSelectionRule(expression.GetMemberPath()));\n }\n\n /// \n /// Includes the specified member in the equality check.\n /// \n /// \n /// This overrides the default behavior of including all declared members.\n /// \n public EquivalencyOptions Including(Expression> expression)\n {\n foreach (var memberPath in expression.GetMemberPaths())\n {\n AddSelectionRule(new IncludeMemberByPathSelectionRule(memberPath));\n }\n\n return this;\n }\n\n /// \n /// Causes the collection identified by to be compared in the order\n /// in which the items appear in the expectation.\n /// \n public EquivalencyOptions WithStrictOrderingFor(\n Expression> expression)\n {\n string expressionMemberPath = expression.GetMemberPath().ToString();\n OrderingRules.Add(new PathBasedOrderingRule(expressionMemberPath));\n return this;\n }\n\n /// \n /// Causes the collection identified by to be compared ignoring the order\n /// in which the items appear in the expectation.\n /// \n public EquivalencyOptions WithoutStrictOrderingFor(\n Expression> expression)\n {\n string expressionMemberPath = expression.GetMemberPath().ToString();\n\n OrderingRules.Add(new PathBasedOrderingRule(expressionMemberPath)\n {\n Invert = true\n });\n\n return this;\n }\n\n /// \n /// Creates a new set of options based on the current instance which acts on a a collection of the .\n /// \n public EquivalencyOptions> AsCollection()\n {\n return new EquivalencyOptions>(\n new CollectionMemberOptionsDecorator(this));\n }\n\n /// \n /// Maps a (nested) property or field of type to\n /// a (nested) property or field of using lambda expressions.\n /// \n /// A field or property expression indicating the (nested) member to map from.\n /// A field or property expression indicating the (nested) member to map to.\n /// \n /// The members of the subject and the expectation must have the same parent. Also, indexes in collections are ignored.\n /// If the types of the members are different, the usual logic applies depending or not if conversion options were specified.\n /// Fields can be mapped to properties and vice-versa.\n /// \n public EquivalencyOptions WithMapping(\n Expression> expectationMemberPath,\n Expression> subjectMemberPath)\n {\n return WithMapping(\n expectationMemberPath.GetMemberPath().ToString().WithoutSpecificCollectionIndices(),\n subjectMemberPath.GetMemberPath().ToString().WithoutSpecificCollectionIndices());\n }\n\n /// \n /// Maps a (nested) property or field of the expectation to a (nested) property or field of the subject using a path string.\n /// \n /// \n /// A field or property path indicating the (nested) member to map from in the format Parent.Child.Collection[].Member.\n /// \n /// \n /// A field or property path indicating the (nested) member to map to in the format Parent.Child.Collection[].Member.\n /// \n /// \n /// The members of the subject and the expectation must have the same parent. Also, indexes in collections are not allowed\n /// and must be written as \"[]\". If the types of the members are different, the usual logic applies depending or not\n /// if conversion options were specified.\n /// Fields can be mapped to properties and vice-versa.\n /// \n public EquivalencyOptions WithMapping(\n string expectationMemberPath,\n string subjectMemberPath)\n {\n AddMatchingRule(new MappedPathMatchingRule(expectationMemberPath, subjectMemberPath));\n\n return this;\n }\n\n /// \n /// Maps a direct property or field of type to\n /// a direct property or field of using lambda expressions.\n /// \n /// A field or property expression indicating the member to map from.\n /// A field or property expression indicating the member to map to.\n /// \n /// Only direct members of and can be\n /// mapped to each other. Those types can appear anywhere in the object graphs that are being compared.\n /// If the types of the members are different, the usual logic applies depending or not if conversion options were specified.\n /// Fields can be mapped to properties and vice-versa.\n /// \n public EquivalencyOptions WithMapping(\n Expression> expectationMember,\n Expression> subjectMember)\n {\n return WithMapping(\n expectationMember.GetMemberPath().ToString(),\n subjectMember.GetMemberPath().ToString());\n }\n\n /// \n /// Maps a direct property or field of type to\n /// a direct property or field of using member names.\n /// \n /// A field or property name indicating the member to map from.\n /// A field or property name indicating the member to map to.\n /// \n /// Only direct members of and can be\n /// mapped to each other, so no . or [] are allowed.\n /// Those types can appear anywhere in the object graphs that are being compared.\n /// If the types of the members are different, the usual logic applies depending or not if conversion options were specified.\n /// Fields can be mapped to properties and vice-versa.\n /// \n public EquivalencyOptions WithMapping(\n string expectationMemberName,\n string subjectMemberName)\n {\n AddMatchingRule(new MappedMemberMatchingRule(\n expectationMemberName,\n subjectMemberName));\n\n return this;\n }\n}\n\n/// \n/// Represents the run-time type-agnostic behavior of a structural equivalency assertion.\n/// \npublic class EquivalencyOptions : SelfReferenceEquivalencyOptions\n{\n public EquivalencyOptions()\n {\n IncludingNestedObjects();\n\n IncludingFields();\n IncludingProperties();\n\n PreferringDeclaredMemberTypes();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/AssertionChainExtensions.cs", "using AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal static class AssertionChainExtensions\n{\n /// \n /// Updates the with the relevant information from the current , including the correct\n /// caller identification path.\n /// \n public static AssertionChain For(this AssertionChain chain, IEquivalencyValidationContext context)\n {\n chain.OverrideCallerIdentifier(() => context.CurrentNode.Subject.Description);\n\n return chain\n .WithReportable(\"configuration\", () => context.Options.ToString())\n .BecauseOf(context.Reason);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/ComparableTypeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class ComparableTypeAssertions : ComparableTypeAssertions>\n{\n public ComparableTypeAssertions(IComparable value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class ComparableTypeAssertions : ReferenceTypeAssertions, TAssertions>\n where TAssertions : ComparableTypeAssertions\n{\n private const int Equal = 0;\n private readonly AssertionChain assertionChain;\n\n public ComparableTypeAssertions(IComparable value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that an object equals another object using its implementation.
\n /// Verification whether returns 0 is not done here, you should use\n /// to verify this.\n ///
\n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Equals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be equal to {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object is equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that an object is equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(TExpectation expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var context = new EquivalencyValidationContext(\n Node.From(() => CurrentAssertionChain.CallerIdentifier), options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object does not equal another object using its method.
\n /// Verification whether returns non-zero is not done here, you should use\n /// to verify this.\n ///
\n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(T unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Equals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:object} to be equal to {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is ranked equal to another object. I.e. the result of returns 0.\n /// To verify whether the objects are equal you must use .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeRankedEquallyTo(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) == Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be ranked as equal to {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is not ranked equal to another object. I.e. the result of returns non-zero.\n /// To verify whether the objects are not equal according to you must use .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeRankedEquallyTo(T unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(unexpected) != Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} not to be ranked as equal to {1}{reason}.\", Subject, unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is less than another object according to its implementation of .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThan(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) < Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be less than {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is less than or equal to another object according to its implementation of .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThanOrEqualTo(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) <= Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be less than or equal to {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is greater than another object according to its implementation of .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThan(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) > Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be greater than {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is greater than or equal to another object according to its implementation of .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThanOrEqualTo(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) >= Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be greater than or equal to {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is within a range.\n /// \n /// \n /// Where the range is continuous or incremental depends on the actual type of the value.\n /// \n /// \n /// The minimum valid value of the range.\n /// \n /// \n /// The maximum valid value of the range.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeInRange(T minimumValue, T maximumValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(minimumValue) >= Equal && Subject.CompareTo(maximumValue) <= Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be between {0} and {1}{reason}, but found {2}.\",\n minimumValue, maximumValue, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is not within a range.\n /// \n /// \n /// Where the range is continuous or incremental depends on the actual type of the value.\n /// \n /// \n /// The minimum valid value of the range.\n /// \n /// \n /// The maximum valid value of the range.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeInRange(T minimumValue, T maximumValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!(Subject.CompareTo(minimumValue) >= Equal && Subject.CompareTo(maximumValue) <= Equal))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to not be between {0} and {1}{reason}, but found {2}.\",\n minimumValue, maximumValue, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params T[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(validValues.Any(val => Equals(Subject, val)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"object\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/ObjectAssertionsExtensions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.IO;\nusing System.Runtime.Serialization;\nusing System.Xml.Serialization;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions;\n\npublic static class ObjectAssertionsExtensions\n{\n /// \n /// Asserts that an object can be serialized and deserialized using the data contract serializer and that it stills retains\n /// the values of all members.\n /// \n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint BeDataContractSerializable(this ObjectAssertions assertions,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeDataContractSerializable(assertions, options => options, because, becauseArgs);\n }\n\n /// \n /// Asserts that an object can be serialized and deserialized using the data contract serializer and that it stills retains\n /// the values of all members.\n /// \n /// \n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public static AndConstraint BeDataContractSerializable(this ObjectAssertions assertions,\n Func, EquivalencyOptions> options,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(options);\n\n try\n {\n var deserializedObject = CreateCloneUsingDataContractSerializer(assertions.Subject);\n\n EquivalencyOptions defaultOptions = AssertionConfiguration.Current.Equivalency.CloneDefaults()\n .PreferringRuntimeMemberTypes().IncludingFields().IncludingProperties();\n\n ((T)deserializedObject).Should().BeEquivalentTo((T)assertions.Subject, _ => options(defaultOptions));\n }\n catch (Exception exc)\n {\n assertions.CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0} to be serializable{reason}, but serialization failed with:\"\n + Environment.NewLine + Environment.NewLine + \"{1}.\",\n assertions.Subject,\n exc.Message);\n }\n\n return new AndConstraint(assertions);\n }\n\n private static object CreateCloneUsingDataContractSerializer(object subject)\n {\n using var stream = new MemoryStream();\n var serializer = new DataContractSerializer(subject.GetType());\n serializer.WriteObject(stream, subject);\n stream.Position = 0;\n return serializer.ReadObject(stream);\n }\n\n /// \n /// Asserts that an object can be serialized and deserialized using the XML serializer and that it stills retains\n /// the values of all members.\n /// \n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint BeXmlSerializable(this ObjectAssertions assertions,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n try\n {\n object deserializedObject = CreateCloneUsingXmlSerializer(assertions.Subject);\n\n deserializedObject.Should().BeEquivalentTo(assertions.Subject,\n options => options.PreferringRuntimeMemberTypes().IncludingFields().IncludingProperties());\n }\n catch (Exception exc)\n {\n assertions.CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0} to be serializable{reason}, but serialization failed with:\"\n + Environment.NewLine + Environment.NewLine + \"{1}.\",\n assertions.Subject,\n exc.Message);\n }\n\n return new AndConstraint(assertions);\n }\n\n private static object CreateCloneUsingXmlSerializer(object subject)\n {\n using var stream = new MemoryStream();\n var serializer = new XmlSerializer(subject.GetType());\n serializer.Serialize(stream, subject);\n\n stream.Position = 0;\n return serializer.Deserialize(stream);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IEquivalencyOptions.cs", "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing AwesomeAssertions.Equivalency.Tracing;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides the run-time details of the class.\n/// \npublic interface IEquivalencyOptions\n{\n /// \n /// Gets an ordered collection of selection rules that define what members (e.g. properties or fields) are included.\n /// \n IEnumerable SelectionRules { get; }\n\n /// \n /// Gets an ordered collection of matching rules that determine which subject members are matched with which\n /// expectation properties.\n /// \n IEnumerable MatchingRules { get; }\n\n /// \n /// Gets a value indicating whether or not the assertion must perform a deep comparison.\n /// \n bool IsRecursive { get; }\n\n /// \n /// Gets a value indicating whether recursion is allowed to continue indefinitely.\n /// \n bool AllowInfiniteRecursion { get; }\n\n /// \n /// Gets value indicating how cyclic references should be handled. By default, it will throw an exception.\n /// \n CyclicReferenceHandling CyclicReferenceHandling { get; }\n\n /// \n /// Gets an ordered collection of rules that determine whether or not the order of collections is important. By default,\n /// ordering is irrelevant.\n /// \n OrderingRuleCollection OrderingRules { get; }\n\n /// \n /// Contains the rules for what properties to run an auto-conversion.\n /// \n ConversionSelector ConversionSelector { get; }\n\n /// \n /// Gets value indicating how the enums should be compared.\n /// \n EnumEquivalencyHandling EnumEquivalencyHandling { get; }\n\n /// \n /// Gets an ordered collection of Equivalency steps how a subject is compared with the expectation.\n /// \n IEnumerable UserEquivalencySteps { get; }\n\n /// \n /// Gets a value indicating whether the runtime type of the expectation should be used rather than the declared type.\n /// \n bool UseRuntimeTyping { get; }\n\n /// \n /// Gets a value indicating whether and which properties should be considered.\n /// \n MemberVisibility IncludedProperties { get; }\n\n /// \n /// Gets a value indicating whether and which fields should be considered.\n /// \n MemberVisibility IncludedFields { get; }\n\n /// \n /// Gets a value indicating whether members on the subject marked with []\n /// and should be treated as though they don't exist.\n /// \n bool IgnoreNonBrowsableOnSubject { get; }\n\n /// \n /// Gets a value indicating whether members on the expectation marked with []\n /// and should be excluded.\n /// \n bool ExcludeNonBrowsableOnExpectation { get; }\n\n /// \n /// Gets a value indicating whether records should be compared by value instead of their members\n /// \n bool? CompareRecordsByValue { get; }\n\n /// \n /// Gets the currently configured tracer, or if no tracing was configured.\n /// \n ITraceWriter TraceWriter { get; }\n\n /// \n /// Determines the right strategy for evaluating the equality of objects of this type.\n /// \n EqualityStrategy GetEqualityStrategy(Type type);\n\n /// \n /// Gets a value indicating whether leading whitespace is ignored when comparing s.\n /// \n bool IgnoreLeadingWhitespace { get; }\n\n /// \n /// Gets a value indicating whether trailing whitespace is ignored when comparing s.\n /// \n bool IgnoreTrailingWhitespace { get; }\n\n /// \n /// Gets a value indicating whether a case-insensitive comparer is used when comparing s.\n /// \n bool IgnoreCase { get; }\n\n /// \n /// Gets a value indicating whether the newline style is ignored when comparing s.\n /// \n /// \n /// Enabling this option will replace all occurrences of \\r\\n and \\r with \\n in the strings before comparing them.\n /// \n bool IgnoreNewlineStyle { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/NestedExclusionOptionBuilder.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Selection;\n\nnamespace AwesomeAssertions.Equivalency;\n\npublic class NestedExclusionOptionBuilder\n{\n /// \n /// The selected path starting at the first .\n /// \n private readonly ExcludeMemberByPathSelectionRule currentPathSelectionRule;\n\n private readonly EquivalencyOptions capturedOptions;\n\n internal NestedExclusionOptionBuilder(EquivalencyOptions capturedOptions,\n ExcludeMemberByPathSelectionRule currentPathSelectionRule)\n {\n this.capturedOptions = capturedOptions;\n this.currentPathSelectionRule = currentPathSelectionRule;\n }\n\n /// \n /// Selects a nested property to exclude. This ends the chain.\n /// \n public EquivalencyOptions Exclude(Expression> expression)\n {\n var currentSelectionPath = currentPathSelectionRule.CurrentPath;\n\n foreach (var path in expression.GetMemberPaths())\n {\n var newPath = currentSelectionPath.AsParentCollectionOf(path);\n capturedOptions.AddSelectionRule(new ExcludeMemberByPathSelectionRule(newPath));\n }\n\n return capturedOptions;\n }\n\n /// \n /// Adds the selected collection to the chain.\n /// \n public NestedExclusionOptionBuilder For(\n Expression>> expression)\n {\n var nextPath = expression.GetMemberPath();\n currentPathSelectionRule.AppendPath(nextPath);\n return new NestedExclusionOptionBuilder(capturedOptions, currentPathSelectionRule);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IEquivalencyValidationContext.cs", "using AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides information on a particular property or field during an assertion for structural equality of two object graphs.\n/// \npublic interface IEquivalencyValidationContext\n{\n /// \n /// Gets the of the member that returned the current object, or if the current\n /// object represents the root object.\n /// \n INode CurrentNode { get; }\n\n /// \n /// A formatted phrase and the placeholder values explaining why the assertion is needed.\n /// \n public Reason Reason { get; }\n\n /// \n /// Gets an object that can be used by the equivalency algorithm to provide a trace when the\n /// option is used.\n /// \n Tracer Tracer { get; }\n\n IEquivalencyOptions Options { get; }\n\n /// \n /// Determines whether the specified object reference is a cyclic reference to the same object earlier in the\n /// equivalency validation.\n /// \n public bool IsCyclicReference(object expectation);\n\n /// \n /// Creates a context from the current object intended to assert the equivalency of a nested member.\n /// \n IEquivalencyValidationContext AsNestedMember(IMember expectationMember);\n\n /// \n /// Creates a context from the current object intended to assert the equivalency of a collection item identified by .\n /// \n IEquivalencyValidationContext AsCollectionItem(string index);\n\n /// \n /// Creates a context from the current object intended to assert the equivalency of a collection item identified by .\n /// \n IEquivalencyValidationContext AsDictionaryItem(TKey key);\n\n /// \n /// Creates a deep clone of the current context.\n /// \n IEquivalencyValidationContext Clone();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EquivalencyValidationContextExtensions.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\ninternal static class EquivalencyValidationContextExtensions\n{\n public static IEquivalencyValidationContext AsCollectionItem(this IEquivalencyValidationContext context,\n int index) =>\n context.AsCollectionItem(index.ToString(CultureInfo.InvariantCulture));\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringComparisonSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Specs.CultureAwareTesting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n[Collection(nameof(StringComparisonSpecs))]\npublic class StringComparisonSpecs\n{\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_the_Turkish_letter_i_it_should_differ_by_dottedness(string subject, string expected)\n {\n // Act\n bool ordinal = string.Equals(subject, expected, StringComparison.OrdinalIgnoreCase);\n#pragma warning disable CA1309 // Verifies that test data behaves differently in current vs invariant culture\n bool currentCulture = string.Equals(subject, expected, StringComparison.CurrentCultureIgnoreCase);\n#pragma warning restore CA1309\n\n // Assert\n ordinal.Should().NotBe(currentCulture, \"Turkish distinguishes between a dotted and a non-dotted 'i'\");\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_the_same_digit_from_different_cultures_they_should_be_equal(string subject, string expected)\n {\n // Act\n bool ordinal = string.Equals(subject, expected, StringComparison.Ordinal);\n#pragma warning disable CA1309 // Verifies that test data behaves differently in current vs invariant culture\n bool currentCulture = string.Equals(subject, expected, StringComparison.CurrentCulture);\n#pragma warning restore CA1309\n\n // Assert\n ordinal.Should().NotBe(currentCulture,\n \"These two symbols happened to be culturewise identical on both ICU (net5.0, linux, macOS) and NLS (netfx and netcoreapp on windows)\");\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_equivalency_it_should_ignore_culture(string subject, string expected)\n {\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_equality_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_having_prefix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().StartWith(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_having_prefix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotStartWith(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_having_equivalent_prefix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().StartWithEquivalentOf(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_not_having_equivalent_prefix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotStartWithEquivalentOf(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_having_suffix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().EndWith(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_having_suffix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotEndWith(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_having_equivalent_suffix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().EndWithEquivalentOf(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_not_having_equivalent_suffix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotEndWithEquivalentOf(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_containing_equivalent_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().ContainEquivalentOf(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_not_containing_equivalent_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotContainEquivalentOf(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_containing_equal_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().Contain(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_containing_all_equals_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().ContainAll(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_containing_any_equals_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().ContainAny(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_containing_one_equal_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().Contain(expected, Exactly.Once());\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_containing_one_equivalent_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().ContainEquivalentOf(expected, Exactly.Once());\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_containing_equal_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotContain(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_containing_all_equals_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotContainAll(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_containing_any_equals_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotContainAny(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedFact(\"tr-TR\")]\n public void When_formatting_reason_arguments_it_should_ignore_culture()\n {\n // Act\n Action act = () => 1.Should().Be(2, \"{0}\", 1.234);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*1.234*\", \"it should always use . as decimal separator\");\n }\n\n [CulturedFact(\"tr-TR\")]\n public void When_stringifying_an_object_it_should_ignore_culture()\n {\n // Arrange\n var obj = new ObjectReference(1.234, string.Empty);\n\n // Act\n var str = obj.ToString();\n\n // Assert\n str.Should().Match(\"*1.234*\", \"it should always use . as decimal separator\");\n }\n\n [CulturedFact(\"tr-TR\")]\n public void When_stringifying_a_validation_context_it_should_ignore_culture()\n {\n // Arrange\n var comparands = new Comparands\n {\n Subject = 1.234,\n Expectation = 5.678\n };\n\n // Act\n var str = comparands.ToString();\n\n // Assert\n str.Should().Match(\"*1.234*5.678*\", \"it should always use . as decimal separator\");\n }\n\n [CulturedFact(\"tr-TR\")]\n public void When_formatting_the_context_it_should_ignore_culture()\n {\n // Arrange\n var context = new Dictionary\n {\n [\"FOO\"] = 1.234\n };\n\n var strategy = new CollectingAssertionStrategy();\n strategy.HandleFailure(string.Empty);\n\n // Act\n Action act = () => strategy.ThrowIfAny(context);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*1.234*\", \"it should always use . as decimal separator\");\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void Matching_strings_for_equivalence_ignores_the_culture(string subject, string expected)\n {\n // Assert\n subject.Should().MatchEquivalentOf(expected);\n }\n\n [CulturedFact(\"en-US\")]\n public void Culture_is_ignored_when_sorting_strings()\n {\n using var _ = new AssertionScope();\n\n new[] { \"A\", \"a\" }.Should().BeInAscendingOrder()\n .And.BeInAscendingOrder(e => e)\n .And.ThenBeInAscendingOrder(e => e)\n .And.NotBeInDescendingOrder()\n .And.NotBeInDescendingOrder(e => e);\n\n new[] { \"a\", \"A\" }.Should().BeInDescendingOrder()\n .And.BeInDescendingOrder(e => e)\n .And.ThenBeInDescendingOrder(e => e)\n .And.NotBeInAscendingOrder()\n .And.NotBeInAscendingOrder(e => e);\n }\n\n private const string LowerCaseI = \"i\";\n private const string UpperCaseI = \"I\";\n\n public static TheoryData EquivalencyData => new()\n {\n { LowerCaseI, UpperCaseI }\n };\n\n private const string SinhalaLithDigitEight = \"෮\";\n private const string MyanmarTaiLaingDigitEight = \"꧸\";\n\n public static TheoryData EqualityData => new()\n {\n { SinhalaLithDigitEight, MyanmarTaiLaingDigitEight }\n };\n}\n\n// Due to CulturedTheory changing CultureInfo\n[CollectionDefinition(nameof(StringComparisonSpecs), DisableParallelization = true)]\npublic class StringComparisonDefinition;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Matching/MappedPathMatchingRule.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Matching;\n\n/// \n/// Allows mapping a member (property or field) of the expectation to a differently named member\n/// of the subject-under-test using a nested member path in the form of \"Parent.NestedCollection[].Member\"\n/// \ninternal class MappedPathMatchingRule : IMemberMatchingRule\n{\n private readonly MemberPath expectationPath;\n private readonly MemberPath subjectPath;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// is .\n /// is empty.\n /// is .\n /// is empty.\n public MappedPathMatchingRule(string expectationMemberPath, string subjectMemberPath)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(expectationMemberPath,\n nameof(expectationMemberPath), \"A member path cannot be null\");\n\n Guard.ThrowIfArgumentIsNullOrEmpty(subjectMemberPath,\n nameof(subjectMemberPath), \"A member path cannot be null\");\n\n expectationPath = new MemberPath(expectationMemberPath);\n subjectPath = new MemberPath(subjectMemberPath);\n\n if (expectationPath.GetContainsSpecificCollectionIndex() || subjectPath.GetContainsSpecificCollectionIndex())\n {\n throw new ArgumentException(\n \"Mapping properties containing a collection index must use the [] format without specific index.\");\n }\n\n if (!expectationPath.HasSameParentAs(subjectPath))\n {\n throw new ArgumentException(\"The member paths must have the same parent.\");\n }\n }\n\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain)\n {\n MemberPath path = expectationPath;\n\n if (expectedMember.RootIsCollection)\n {\n path = path.WithCollectionAsRoot();\n }\n\n if (path.IsEquivalentTo(expectedMember.Expectation.PathAndName))\n {\n var member = MemberFactory.Find(subject, subjectPath.MemberName, parent);\n\n if (member is null)\n {\n throw new MissingMemberException(\n $\"Subject of type {subject?.GetType().Name} does not have member {subjectPath.MemberName}\");\n }\n\n return member;\n }\n\n return null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Matching/MappedMemberMatchingRule.cs", "using System;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Matching;\n\n/// \n/// Allows mapping a member (property or field) of the expectation to a differently named member\n/// of the subject-under-test using a member name and the target type.\n/// \ninternal class MappedMemberMatchingRule : IMemberMatchingRule\n{\n private readonly string expectationMemberName;\n private readonly string subjectMemberName;\n\n public MappedMemberMatchingRule(string expectationMemberName, string subjectMemberName)\n {\n if (Regex.IsMatch(expectationMemberName, @\"[\\.\\[\\]]\"))\n {\n throw new ArgumentException(\"The expectation's member name cannot be a nested path\", nameof(expectationMemberName));\n }\n\n if (Regex.IsMatch(subjectMemberName, @\"[\\.\\[\\]]\"))\n {\n throw new ArgumentException(\"The subject's member name cannot be a nested path\", nameof(subjectMemberName));\n }\n\n this.expectationMemberName = expectationMemberName;\n this.subjectMemberName = subjectMemberName;\n }\n\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain)\n {\n if (parent.Type.IsSameOrInherits(typeof(TExpectation)) && subject is TSubject &&\n expectedMember.Subject.Name == expectationMemberName)\n {\n var member = MemberFactory.Find(subject, subjectMemberName, parent);\n\n return member ?? throw new MissingMemberException(\n $\"Subject of type {typeof(TSubject).ToFormattedString()} does not have member {subjectMemberName}\");\n }\n\n return null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Matching/MustMatchByNameRule.cs", "using System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Matching;\n\n/// \n/// Requires the subject to have a member with the exact same name as the expectation has.\n/// \ninternal class MustMatchByNameRule : IMemberMatchingRule\n{\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain)\n {\n IMember subjectMember = null;\n\n if (options.IncludedProperties != MemberVisibility.None)\n {\n PropertyInfo propertyInfo = subject.GetType().FindProperty(\n expectedMember.Subject.Name,\n options.IncludedProperties | MemberVisibility.ExplicitlyImplemented | MemberVisibility.DefaultInterfaceProperties);\n\n subjectMember = propertyInfo is not null && !propertyInfo.IsIndexer() ? new Property(propertyInfo, parent) : null;\n }\n\n if (subjectMember is null && options.IncludedFields != MemberVisibility.None)\n {\n FieldInfo fieldInfo = subject.GetType().FindField(\n expectedMember.Subject.Name,\n options.IncludedFields);\n\n subjectMember = fieldInfo is not null ? new Field(fieldInfo, parent) : null;\n }\n\n if (subjectMember is null)\n {\n assertionChain.FailWith(\n $\"Expectation has {expectedMember.Expectation} that the other object does not have.\");\n }\n else if (options.IgnoreNonBrowsableOnSubject && !subjectMember.IsBrowsable)\n {\n assertionChain.FailWith(\n $\"Expectation has {expectedMember.Expectation} that is non-browsable in the other object, and non-browsable \" +\n \"members on the subject are ignored with the current configuration\");\n }\n else\n {\n // Everything is fine\n }\n\n return subjectMember;\n }\n\n /// \n /// 2\n public override string ToString()\n {\n return \"Match member by name (or throw)\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Execution/CollectionMemberOptionsDecorator.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency.Ordering;\nusing AwesomeAssertions.Equivalency.Selection;\nusing AwesomeAssertions.Equivalency.Tracing;\n\nnamespace AwesomeAssertions.Equivalency.Execution;\n\n/// \n/// Ensures that all the rules remove the collection index from the path before processing it further.\n/// \ninternal class CollectionMemberOptionsDecorator : IEquivalencyOptions\n{\n private readonly IEquivalencyOptions inner;\n\n public CollectionMemberOptionsDecorator(IEquivalencyOptions inner)\n {\n this.inner = inner;\n }\n\n public IEnumerable SelectionRules\n {\n get\n {\n return inner.SelectionRules.Select(rule => new CollectionMemberSelectionRuleDecorator(rule)).ToArray();\n }\n }\n\n public IEnumerable MatchingRules\n {\n get { return inner.MatchingRules.ToArray(); }\n }\n\n public OrderingRuleCollection OrderingRules\n {\n get\n {\n return new OrderingRuleCollection(inner.OrderingRules.Select(rule =>\n new CollectionMemberOrderingRuleDecorator(rule)));\n }\n }\n\n public ConversionSelector ConversionSelector => inner.ConversionSelector;\n\n public IEnumerable UserEquivalencySteps\n {\n get { return inner.UserEquivalencySteps; }\n }\n\n public bool IsRecursive => inner.IsRecursive;\n\n public bool AllowInfiniteRecursion => inner.AllowInfiniteRecursion;\n\n public CyclicReferenceHandling CyclicReferenceHandling => inner.CyclicReferenceHandling;\n\n public EnumEquivalencyHandling EnumEquivalencyHandling => inner.EnumEquivalencyHandling;\n\n public bool UseRuntimeTyping => inner.UseRuntimeTyping;\n\n public MemberVisibility IncludedProperties => inner.IncludedProperties;\n\n public MemberVisibility IncludedFields => inner.IncludedFields;\n\n public bool IgnoreNonBrowsableOnSubject => inner.IgnoreNonBrowsableOnSubject;\n\n public bool ExcludeNonBrowsableOnExpectation => inner.ExcludeNonBrowsableOnExpectation;\n\n public bool? CompareRecordsByValue => inner.CompareRecordsByValue;\n\n public EqualityStrategy GetEqualityStrategy(Type type)\n {\n return inner.GetEqualityStrategy(type);\n }\n\n public bool IgnoreLeadingWhitespace => inner.IgnoreLeadingWhitespace;\n\n public bool IgnoreTrailingWhitespace => inner.IgnoreTrailingWhitespace;\n\n public bool IgnoreCase => inner.IgnoreCase;\n\n public bool IgnoreNewlineStyle => inner.IgnoreNewlineStyle;\n\n public ITraceWriter TraceWriter => inner.TraceWriter;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Comparands.cs", "using System;\nusing AwesomeAssertions.Common;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency;\n\npublic class Comparands\n{\n private Type compileTimeType;\n\n public Comparands()\n {\n }\n\n public Comparands(object subject, object expectation, Type compileTimeType)\n {\n this.compileTimeType = compileTimeType;\n Subject = subject;\n Expectation = expectation;\n }\n\n /// \n /// Gets the value of the subject object graph.\n /// \n public object Subject { get; set; }\n\n /// \n /// Gets the value of the expected object graph.\n /// \n public object Expectation { get; set; }\n\n public Type CompileTimeType\n {\n get\n {\n return compileTimeType != typeof(object) || Expectation is null ? compileTimeType : RuntimeType;\n }\n\n // SMELL: Do we really need this? Can we replace it by making Comparands generic or take a constructor parameter?\n set => compileTimeType = value;\n }\n\n /// \n /// Gets the run-time type of the current expectation object.\n /// \n public Type RuntimeType\n {\n get\n {\n if (Expectation is not null)\n {\n return Expectation.GetType();\n }\n\n return CompileTimeType;\n }\n }\n\n /// \n /// Returns either the run-time or compile-time type of the expectation based on the options provided by the caller.\n /// \n /// \n /// If the expectation is a nullable type, it should return the type of the wrapped object.\n /// \n public Type GetExpectedType(IEquivalencyOptions options)\n {\n Type type = options.UseRuntimeTyping ? RuntimeType : CompileTimeType;\n\n return type.NullableOrActualType();\n }\n\n public override string ToString()\n {\n return Invariant($\"{{Subject={Subject}, Expectation={Expectation}}}\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Matching/TryMatchByNameRule.cs", "using System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Matching;\n\n/// \n/// Finds a member of the expectation with the exact same name, but doesn't require it.\n/// \ninternal class TryMatchByNameRule : IMemberMatchingRule\n{\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain)\n {\n if (options.IncludedProperties != MemberVisibility.None)\n {\n PropertyInfo property = subject.GetType().FindProperty(expectedMember.Expectation.Name,\n options.IncludedProperties | MemberVisibility.ExplicitlyImplemented);\n\n if (property is not null && !property.IsIndexer())\n {\n return new Property(property, parent);\n }\n }\n\n FieldInfo field = subject.GetType()\n .FindField(expectedMember.Expectation.Name, options.IncludedFields);\n\n return field is not null ? new Field(field, parent) : null;\n }\n\n /// \n /// 2\n public override string ToString()\n {\n return \"Try to match member by name\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EnumerableEquivalencyValidatorExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\ninternal static class EnumerableEquivalencyValidatorExtensions\n{\n public static Continuation AssertEitherCollectionIsNotEmpty(this AssertionChain assertionChain,\n ICollection subject,\n ICollection expectation)\n {\n return assertionChain\n .WithExpectation(\"Expected {context:subject} to be a collection with {0} item(s){reason}\", expectation.Count,\n chain => chain\n .ForCondition(subject.Count > 0 || expectation.Count == 0)\n .FailWith(\", but found an empty collection.\")\n .Then\n .ForCondition(subject.Count == 0 || expectation.Count > 0)\n .FailWith($\", but {{0}}{Environment.NewLine}contains {{1}} item(s).\",\n subject,\n subject.Count));\n }\n\n public static Continuation AssertCollectionHasEnoughItems(this AssertionChain assertionChain, ICollection subject,\n ICollection expectation)\n {\n return assertionChain\n .WithExpectation(\"Expected {context:subject} to be a collection with {0} item(s){reason}\", expectation.Count,\n chain => chain\n .ForCondition(subject.Count >= expectation.Count)\n .FailWith($\", but {{0}}{Environment.NewLine}contains {{1}} item(s) less than{Environment.NewLine}{{2}}.\",\n subject,\n expectation.Count - subject.Count,\n expectation));\n }\n\n public static Continuation AssertCollectionHasNotTooManyItems(this AssertionChain assertionChain,\n ICollection subject,\n ICollection expectation)\n {\n return assertionChain\n .WithExpectation(\"Expected {context:subject} to be a collection with {0} item(s){reason}\", expectation.Count,\n chain => chain\n .ForCondition(subject.Count <= expectation.Count)\n .FailWith($\", but {{0}}{Environment.NewLine}contains {{1}} item(s) more than{Environment.NewLine}{{2}}.\",\n subject,\n subject.Count - expectation.Count,\n expectation));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Execution/ObjectInfo.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency.Execution;\n\ninternal class ObjectInfo : IObjectInfo\n{\n public ObjectInfo(Comparands comparands, INode currentNode)\n {\n Type = currentNode.Type;\n ParentType = currentNode.ParentType;\n Path = currentNode.Expectation.PathAndName;\n CompileTimeType = comparands.CompileTimeType;\n RuntimeType = comparands.RuntimeType;\n }\n\n public Type Type { get; }\n\n public Type ParentType { get; }\n\n public string Path { get; set; }\n\n public Type CompileTimeType { get; }\n\n public Type RuntimeType { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/GenericCollectionAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Collections.MaximumMatching;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Collections;\n\n[DebuggerNonUserCode]\npublic class GenericCollectionAssertions : GenericCollectionAssertions, T, GenericCollectionAssertions>\n{\n public GenericCollectionAssertions(IEnumerable actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n }\n}\n\n[DebuggerNonUserCode]\npublic class GenericCollectionAssertions\n : GenericCollectionAssertions>\n where TCollection : IEnumerable\n{\n public GenericCollectionAssertions(TCollection actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n\n[DebuggerNonUserCode]\npublic class GenericCollectionAssertions : ReferenceTypeAssertions\n where TCollection : IEnumerable\n where TAssertions : GenericCollectionAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public GenericCollectionAssertions(TCollection actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"collection\";\n\n /// \n /// Asserts that all items in the collection are of the specified type \n /// \n /// The expected type of the objects\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint> AllBeAssignableTo(\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be {0}{reason}, but found {context:the collection} is .\",\n typeof(TExpectation));\n\n IEnumerable matches = [];\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type to be {0}{reason}, \", typeof(TExpectation), chain => chain\n .ForCondition(Subject!.All(x => x is not null))\n .FailWith(\"but found a null element.\")\n .Then\n .ForCondition(Subject.All(x => typeof(TExpectation).IsAssignableFrom(GetType(x))))\n .FailWith(\"but found {0}.\", Subject.Select(GetType)));\n\n matches = Subject!.OfType();\n }\n\n return new AndWhichConstraint>((TAssertions)this, matches);\n }\n\n /// \n /// Asserts that all items in the collection are of the specified type \n /// \n /// The expected type of the objects\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllBeAssignableTo(Type expectedType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type to be {0}{reason}, \", expectedType, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found {context:collection} is .\")\n .Then\n .ForCondition(subject => subject.All(x => x is not null))\n .FailWith(\"but found a null element.\")\n .Then\n .ForCondition(subject => subject.All(x => expectedType.IsAssignableFrom(GetType(x))))\n .FailWith(\"but found {0}.\", subject => subject.Select(GetType)));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that all elements in a collection of objects are equivalent to a given object.\n /// \n /// \n /// Objects within the collection are equivalent to given object when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint AllBeEquivalentTo(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return AllBeEquivalentTo(expectation, options => options, because, becauseArgs);\n }\n\n /// \n /// Asserts that all elements in a collection of objects are equivalent to a given object.\n /// \n /// \n /// Objects within the collection are equivalent to given object when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllBeEquivalentTo(TExpectation expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n TExpectation[] repeatedExpectation = RepeatAsManyAs(expectation, Subject).ToArray();\n\n // Because we have just manually created the collection based on single element\n // we are sure that we can force strict ordering, because ordering does not matter in terms\n // of correctness. On the other hand we do not want to change ordering rules for nested objects\n // in case user needs to use them. Strict ordering improves algorithmic complexity\n // from O(n^2) to O(n). For bigger tables it is necessary in order to achieve acceptable\n // execution times.\n Func, EquivalencyOptions> forceStrictOrderingConfig =\n x => config(x).WithStrictOrderingFor(s => string.IsNullOrEmpty(s.Path));\n\n return BeEquivalentTo(repeatedExpectation, forceStrictOrderingConfig, because, becauseArgs);\n }\n\n /// \n /// Asserts that all items in the collection are of the exact specified type \n /// \n /// The expected type of the objects\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint> AllBeOfType(\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be {0}{reason}, but found {context:collection} is .\",\n typeof(TExpectation));\n\n IEnumerable matches = [];\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type to be {0}{reason}, \", typeof(TExpectation), chain => chain\n .ForCondition(Subject!.All(x => x is not null))\n .FailWith(\"but found a null element.\")\n .Then\n .ForCondition(Subject.All(x => typeof(TExpectation) == GetType(x)))\n .FailWith(\"but found {0}.\", () => Subject.Select(GetType)));\n\n matches = Subject!.OfType();\n }\n\n return new AndWhichConstraint>((TAssertions)this, matches);\n }\n\n /// \n /// Asserts that all items in the collection are of the exact specified type \n /// \n /// The expected type of the objects\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllBeOfType(Type expectedType, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type to be {0}{reason}, \", expectedType, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found {context:collection} is .\")\n .Then\n .ForCondition(subject => subject.All(x => x is not null))\n .FailWith(\"but found a null element.\")\n .Then\n .ForCondition(subject => subject.All(x => expectedType == GetType(x)))\n .FailWith(\"but found {0}.\", subject => subject.Select(GetType)));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any items.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var singleItemArray = Subject?.Take(1).ToArray();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to be empty{reason}, \", chain => chain\n .Given(() => singleItemArray)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(subject => subject.Length == 0)\n .FailWith(\"but found at least one item {0}.\", singleItemArray));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection of objects is equivalent to another collection of objects.\n /// \n /// \n /// Objects within the collections are equivalent when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(IEnumerable expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection of objects is equivalent to another collection of objects.\n /// \n /// \n /// Objects within the collections are equivalent when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// An with the expected elements.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(IEnumerable expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions> options =\n config(AssertionConfiguration.Current.Equivalency.CloneDefaults()).AsCollection();\n\n var context =\n new EquivalencyValidationContext(\n Node.From>(() => CallerIdentifier.DetermineCallerIdentity()),\n options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter,\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(IEnumerable),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection is ordered in ascending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInAscendingOrder(\n Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeInAscendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in ascending order according to the value of the specified\n /// implementation.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> BeInAscendingOrder(\n IComparer comparer, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return BeInOrder(comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in ascending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> BeInAscendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return BeOrderedBy(propertyExpression, comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to have all elements in ascending order. Elements are compared\n /// using their implementation.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInAscendingOrder(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeInAscendingOrder(GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to have all elements in ascending order. Elements are compared\n /// using the given lambda expression.\n /// \n /// \n /// A lambda expression that should be used to determine the expected ordering between two objects.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInAscendingOrder(Func comparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return BeInOrder(Comparer.Create((x, y) => comparison(x, y)), SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in descending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInDescendingOrder(\n Expression> propertyExpression, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return BeInDescendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in descending order according to the value of the specified\n /// implementation.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> BeInDescendingOrder(\n IComparer comparer, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return BeInOrder(comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in descending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> BeInDescendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return BeOrderedBy(propertyExpression, comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to have all elements in descending order. Elements are compared\n /// using their implementation.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInDescendingOrder(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeInDescendingOrder(GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to have all elements in descending order. Elements are compared\n /// using the given lambda expression.\n /// \n /// \n /// A lambda expression that should be used to determine the expected ordering between two objects.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInDescendingOrder(Func comparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeInOrder(Comparer.Create((x, y) => comparison(x, y)), SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts that the collection is null or does not contain any items.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNullOrEmpty(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var singleItemArray = Subject?.Take(1).ToArray();\n var nullOrEmpty = singleItemArray is null || singleItemArray.Length == 0;\n\n assertionChain.ForCondition(nullOrEmpty)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to be null or empty{reason}, but found at least one item {0}.\",\n singleItemArray);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection is a subset of the .\n /// \n /// An with the expected superset.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeSubsetOf(IEnumerable expectedSuperset,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedSuperset, nameof(expectedSuperset),\n \"Cannot verify a subset against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to be a subset of {0}{reason}, \", expectedSuperset, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Except(expectedSuperset))\n .ForCondition(excessItems => !excessItems.Any())\n .FailWith(\"but items {0} are not part of the superset.\", excessItems => excessItems));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection contains the specified item.\n /// \n /// The expectation item.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint Contain(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0}{reason}, but found .\", expected);\n\n IEnumerable matches = [];\n\n if (assertionChain.Succeeded)\n {\n ICollection collection = Subject.ConvertOrCastToCollection();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(collection.Contains(expected))\n .FailWith(\"Expected {context:collection} {0} to contain {1}{reason}.\", collection, expected);\n\n matches = collection.Where(item => EqualityComparer.Default.Equals(item, expected));\n }\n\n return new AndWhichConstraint((TAssertions)this, matches);\n }\n\n /// \n /// Asserts that the collection contains at least one item that matches the predicate.\n /// \n /// A predicate to match the items in the collection against.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint Contain(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0}{reason}, but found .\", predicate.Body);\n\n IEnumerable matches = [];\n\n int? firstMatchingIndex = null;\n if (assertionChain.Succeeded)\n {\n Func func = predicate.Compile();\n\n foreach (var (item, index) in Subject!.Select((item, index) => (item, index)))\n {\n if (func(item))\n {\n firstMatchingIndex = index;\n break;\n }\n }\n\n assertionChain\n .ForCondition(firstMatchingIndex.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to have an item matching {1}{reason}.\", Subject, predicate.Body);\n\n matches = Subject.Where(func);\n }\n\n assertionChain.WithCallerPostfix($\"[{firstMatchingIndex}]\").ReuseOnce();\n\n return new AndWhichConstraint((TAssertions)this, matches);\n }\n\n /// \n /// Expects the current collection to contain the specified elements in any order. Elements are compared\n /// using their implementation.\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint Contain(IEnumerable expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify containment against a collection\");\n\n ICollection expectedObjects = expected.ConvertOrCastToCollection();\n Guard.ThrowIfArgumentIsEmpty(expectedObjects, nameof(expected), \"Cannot verify containment against an empty collection\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0}{reason}, but found .\", expectedObjects);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable missingItems = expectedObjects.Except(Subject!);\n\n if (missingItems.Any())\n {\n if (expectedObjects.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to contain {1}{reason}, but could not find {2}.\",\n Subject, expectedObjects, missingItems);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to contain {1}{reason}.\",\n Subject, expectedObjects.Single());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that at least one element in the collection is equivalent to .\n /// \n /// \n /// \n /// Important: You cannot use this method to assert whether a subset of the collection is equivalent to the .\n /// This usually means that the expectation is meant to be a single item.\n /// \n /// \n /// By default, objects within the collection are seen as equivalent to the expected object when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint ContainEquivalentOf(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return ContainEquivalentOf(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that at least one element in the collection is equivalent to .\n /// \n /// \n /// \n /// Important: You cannot use this method to assert whether a subset of the collection is equivalent to the .\n /// This usually means that the expectation is meant to be a single item.\n /// \n /// \n /// By default, objects within the collection are seen as equivalent to the expected object when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint ContainEquivalentOf(TExpectation expectation,\n Func,\n EquivalencyOptions> config, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain equivalent of {0}{reason}, but found .\", expectation);\n\n if (assertionChain.Succeeded)\n {\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n using var scope = new AssertionScope();\n assertionChain.AddReportable(\"configuration\", () => options.ToString());\n\n foreach ((T actualItem, int index) in Subject!.Select((item, index) => (item, index)))\n {\n var context =\n new EquivalencyValidationContext(Node.From(() => CurrentAssertionChain.CallerIdentifier),\n options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = actualItem,\n Expectation = expectation,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n string[] failures = scope.Discard();\n\n if (failures.Length == 0)\n {\n return new AndWhichConstraint((TAssertions)this, actualItem, assertionChain, $\"[{index}]\");\n }\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to contain equivalent of {1}{reason}.\", Subject, expectation);\n }\n\n return new AndWhichConstraint((TAssertions)this, default(T));\n }\n\n /// \n /// Expects the current collection to contain the specified elements in the exact same order, not necessarily consecutive.\n /// using their implementation.\n /// \n /// An with the expected elements.\n public AndConstraint ContainInOrder(params T[] expected)\n {\n return ContainInOrder(expected, string.Empty);\n }\n\n /// \n /// Expects the current collection to contain the specified elements in the exact same order, not necessarily consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint ContainInOrder(IEnumerable expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify ordered containment against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0} in order{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n IList expectedItems = expected.ConvertOrCastToList();\n IList actualItems = Subject.ConvertOrCastToList();\n\n int subjectIndex = 0;\n\n for (int index = 0; index < expectedItems.Count; index++)\n {\n T expectedItem = expectedItems[index];\n subjectIndex = IndexOf(actualItems, expectedItem, startIndex: subjectIndex);\n\n if (subjectIndex == -1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} to contain items {1} in order{reason}\" +\n \", but {2} (index {3}) did not appear (in the right order).\",\n Subject, expected, expectedItem, index);\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection to contain the specified elements in the exact same order, and to be consecutive.\n /// using their implementation.\n /// \n /// An with the expected elements.\n public AndConstraint ContainInConsecutiveOrder(params T[] expected)\n {\n return ContainInConsecutiveOrder(expected, string.Empty);\n }\n\n /// \n /// Expects the current collection to contain the specified elements in the exact same order, and to be consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint ContainInConsecutiveOrder(IEnumerable expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify ordered containment against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0} in order{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n IList expectedItems = expected.ConvertOrCastToList();\n\n if (expectedItems.Count == 0)\n {\n return new AndConstraint((TAssertions)this);\n }\n\n IList actualItems = Subject.ConvertOrCastToList();\n\n int subjectIndex = 0;\n int highestIndex = 0;\n\n while (subjectIndex != -1)\n {\n subjectIndex = IndexOf(actualItems, expectedItems[0], startIndex: subjectIndex);\n\n if (subjectIndex != -1)\n {\n int consecutiveItems = ConsecutiveItemCount(actualItems, expectedItems, startIndex: subjectIndex);\n\n if (consecutiveItems == expectedItems.Count)\n {\n return new AndConstraint((TAssertions)this);\n }\n\n highestIndex = Math.Max(highestIndex, consecutiveItems);\n subjectIndex++;\n }\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} to contain items {1} in order{reason}\" +\n \", but {2} (index {3}) did not appear (in the right consecutive order).\",\n Subject, expected, expectedItems[highestIndex], highestIndex);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection contains at least one element that is assignable to the type .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint ContainItemsAssignableTo(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain at least one element assignable to type {0}{reason}, \",\n typeof(TExpectation), chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(() => Subject.ConvertOrCastToCollection())\n .ForCondition(subject => subject.Any(x => typeof(TExpectation).IsAssignableFrom(GetType(x))))\n .FailWith(\"but found {0}.\", subject => subject.Select(x => GetType(x))));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection does not contain any elements that are assignable to the type .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint\n NotContainItemsAssignableTo(string because = \"\", params object[] becauseArgs) =>\n NotContainItemsAssignableTo(typeof(TExpectation), because, becauseArgs);\n\n /// \n /// Asserts that the current collection does not contain any elements that are assignable to the given type.\n /// \n /// \n /// Object type that should not be in collection\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainItemsAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to not contain any elements assignable to type {0}{reason}, \",\n type, chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(() => Subject.ConvertOrCastToCollection())\n .ForCondition(subject => subject.All(x => !type.IsAssignableFrom(GetType(x))))\n .FailWith(\"but found {0}.\", subject => subject.Select(x => GetType(x))));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection to contain only a single item.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint ContainSingle(string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain a single item{reason}, but found .\");\n\n T match = default;\n\n if (assertionChain.Succeeded)\n {\n ICollection actualItems = Subject.ConvertOrCastToCollection();\n\n switch (actualItems.Count)\n {\n case 0: // Fail, Collection is empty\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to contain a single item{reason}, but the collection is empty.\");\n\n break;\n case 1: // Success Condition\n match = actualItems.Single();\n break;\n default: // Fail, Collection contains more than a single item\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to contain a single item{reason}, but found {0}.\", Subject);\n\n break;\n }\n }\n\n return new AndWhichConstraint((TAssertions)this, match, assertionChain, \"[0]\");\n }\n\n /// \n /// Expects the current collection to contain only a single item matching the specified .\n /// \n /// The predicate that will be used to find the matching items.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint ContainSingle(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n const string expectationPrefix =\n \"Expected {context:collection} to contain a single item matching {0}{reason}, \";\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(expectationPrefix + \"but found .\", predicate);\n\n T[] matches = [];\n\n if (assertionChain.Succeeded)\n {\n ICollection actualItems = Subject.ConvertOrCastToCollection();\n\n assertionChain\n .ForCondition(actualItems.Count > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(expectationPrefix + \"but the collection is empty.\", predicate);\n\n matches = actualItems.Where(predicate.Compile()).ToArray();\n int count = matches.Length;\n\n if (count == 0)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(expectationPrefix + \"but no such item was found.\", predicate);\n }\n else if (count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n expectationPrefix + \"but \" + count.ToString(CultureInfo.InvariantCulture) + \" such items were found.\",\n predicate);\n }\n else\n {\n // Can never happen\n }\n }\n\n return new AndWhichConstraint((TAssertions)this, matches, assertionChain, \"[0]\");\n }\n\n /// \n /// Asserts that the current collection ends with same elements in the same order as the collection identified by\n /// . Elements are compared using their .\n /// \n /// \n /// A collection of expected elements.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint EndWith(IEnumerable expectation, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return EndWith(expectation, (a, b) => EqualityComparer.Default.Equals(a, b), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current collection ends with same elements in the same order as the collection identified by\n /// . Elements are compared using .\n /// \n /// \n /// A collection of expected elements.\n /// \n /// \n /// A equality comparison the is used to determine whether two objects should be treated as equal.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint EndWith(\n IEnumerable expectation, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectation, nameof(expectation), \"Cannot compare collection with .\");\n\n AssertCollectionEndsWith(Subject, expectation.ConvertOrCastToCollection(), equalityComparison, because, becauseArgs);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection ends with the specified .\n /// \n /// \n /// The element that is expected to appear at the end of the collection. The object's \n /// is used to compare the element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint EndWith(T element, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return EndWith([element], ObjectExtensions.GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their method.\n /// \n /// A params array with the expected elements.\n public AndConstraint Equal(params T[] elements)\n {\n AssertSubjectEquality(elements, ObjectExtensions.GetComparer(), string.Empty);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that two collections contain the same items in the same order, where equality is determined using a\n /// .\n /// \n /// \n /// The collection to compare the subject with.\n /// \n /// \n /// A equality comparison the is used to determine whether two objects should be treated as equal.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Equal(\n IEnumerable expectation, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n AssertSubjectEquality(expectation, equalityComparison, because, becauseArgs);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their .\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Equal(IEnumerable expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n AssertSubjectEquality(expected, ObjectExtensions.GetComparer(), because, becauseArgs);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection matches the supplied amount.\n /// \n /// The expected number of items in the collection.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCount(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0} item(s){reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n int actualCount = Subject!.Count();\n\n assertionChain\n .ForCondition(actualCount == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to contain {0} item(s){reason}, but found {1}: {2}.\",\n expected, actualCount, Subject);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection matches a condition stated by the .\n /// \n /// A predicate that yields the number of items that is expected to be in the collection.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint HaveCount(Expression> countPredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(countPredicate, nameof(countPredicate),\n \"Cannot compare collection count against a predicate.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0} items{reason}, but found .\", countPredicate.Body);\n\n if (assertionChain.Succeeded)\n {\n Func compiledPredicate = countPredicate.Compile();\n\n int actualCount = Subject!.Count();\n\n if (!compiledPredicate(actualCount))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to have a count {0}{reason}, but count is {1}: {2}.\",\n countPredicate.Body, actualCount, Subject);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection is greater than or equal to the supplied amount.\n /// \n /// The number to which the actual number items in the collection will be compared.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCountGreaterThanOrEqualTo(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain at least {0} item(s){reason}, \", expected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount >= expected)\n .FailWith(\"but found {0}: {1}.\", actualCount => actualCount, _ => Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection is greater than the supplied amount.\n /// \n /// The number to which the actual number items in the collection will be compared.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCountGreaterThan(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain more than {0} item(s){reason}, \", expected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount > expected)\n .FailWith(\"but found {0}: {1}.\", actualCount => actualCount, _ => Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection is less than or equal to the supplied amount.\n /// \n /// The number to which the actual number items in the collection will be compared.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCountLessThanOrEqualTo(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain at most {0} item(s){reason}, \", expected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount <= expected)\n .FailWith(\"but found {0}: {1}.\", actualCount => actualCount, _ => Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection is less than the supplied amount.\n /// \n /// The number to which the actual number items in the collection will be compared.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCountLessThan(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain fewer than {0} item(s){reason}, \", expected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount < expected)\n .FailWith(\"but found {0}: {1}.\", actualCount => actualCount, _ => Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection has the supplied at the\n /// supplied .\n /// \n /// The index where the element is expected\n /// The expected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementAt(int index, T element,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to have element at index {0}{reason}, but found .\", index);\n\n T actual = default;\n\n if (assertionChain.Succeeded)\n {\n if (index < Subject!.Count())\n {\n actual = Subject.ElementAt(index);\n\n assertionChain\n .ForCondition(ObjectExtensions.GetComparer()(actual, element))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0} at index {1}{reason}, but found {2}.\", element, index, actual);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0} at index {1}{reason}, but found no element.\", element, index);\n }\n }\n\n return new AndWhichConstraint((TAssertions)this, actual, assertionChain, $\"[{index}]\");\n }\n\n /// \n /// Asserts that the element directly precedes the .\n /// \n /// The element that should succeed .\n /// The expected element that should precede .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveElementPreceding(T successor, T expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to have {0} precede {1}{reason}, \", expectation, successor, chain =>\n chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but the collection is .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\"but the collection is empty.\")\n .Then\n .ForCondition(subject => HasPredecessor(successor, subject))\n .FailWith(\"but found nothing.\")\n .Then\n .Given(subject => PredecessorOf(successor, subject))\n .ForCondition(predecessor => ObjectExtensions.GetComparer()(predecessor, expectation))\n .FailWith(\"but found {0}.\", predecessor => predecessor));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the element directly succeeds the .\n /// \n /// The element that should precede .\n /// The element that should succeed .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveElementSucceeding(T predecessor, T expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to have {0} succeed {1}{reason}, \", expectation, predecessor,\n chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but the collection is .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\"but the collection is empty.\")\n .Then\n .ForCondition(subject => HasSuccessor(predecessor, subject))\n .FailWith(\"but found nothing.\")\n .Then\n .Given(subject => SuccessorOf(predecessor, subject))\n .ForCondition(successor => ObjectExtensions.GetComparer()(successor, expectation))\n .FailWith(\"but found {0}.\", successor => successor));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Assert that the current collection has the same number of elements as .\n /// \n /// The other collection with the same expected number of elements\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint HaveSameCount(IEnumerable otherCollection,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(otherCollection, nameof(otherCollection), \"Cannot verify count against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to have \", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"the same count as {0}{reason}, but found .\", otherCollection)\n .Then\n .Given(subject => (actual: subject.Count(), expected: otherCollection.Count()))\n .ForCondition(count => count.actual == count.expected)\n .FailWith(\"{0} item(s){reason}, but found {1}.\", count => count.expected, count => count.actual));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection shares one or more items with the specified .\n /// \n /// The with the expected shared items.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint IntersectWith(IEnumerable otherCollection,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(otherCollection, nameof(otherCollection),\n \"Cannot verify intersection against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to intersect with {0}{reason}, but found .\", otherCollection);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable sharedItems = Subject!.Intersect(otherCollection);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(sharedItems.Any())\n .FailWith(\n \"Expected {context:collection} to intersect with {0}{reason}, but {1} does not contain any shared items.\",\n otherCollection, Subject);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection contains at least 1 item.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEmpty(string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} not to be empty{reason}\", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\".\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection not to contain all elements of the collection identified by ,\n /// regardless of the order. Elements are compared using their .\n /// \n /// An with the unexpected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeEquivalentTo(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot verify inequivalence against a collection.\");\n\n if (Subject is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} not to be equivalent{reason}, but found .\");\n }\n\n if (ReferenceEquals(Subject, unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} not to be equivalent with collection {1}{reason}, but they both reference the same object.\",\n Subject,\n unexpected);\n }\n\n return NotBeEquivalentTo(unexpected.ConvertOrCastToList(), config => config, because, becauseArgs);\n }\n\n /// \n /// Expects the current collection not to contain all elements of the collection identified by ,\n /// regardless of the order. Elements are compared using their .\n /// \n /// An with the unexpected elements.\n /// /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(IEnumerable unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot verify inequivalence against a collection.\");\n\n if (Subject is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} not to be equivalent{reason}, but found .\");\n }\n\n string[] failures;\n\n using (var scope = new AssertionScope())\n {\n BeEquivalentTo(unexpected, config);\n\n failures = scope.Discard();\n }\n\n assertionChain\n .ForCondition(failures.Length > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} not to be equivalent to collection {1}{reason}.\", Subject,\n unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection is not ordered in ascending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInAscendingOrder(\n Expression> propertyExpression, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeInAscendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in ascending order according to the value of the specified\n /// implementation.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint NotBeInAscendingOrder(\n IComparer comparer, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return NotBeInOrder(comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in ascending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint NotBeInAscendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return NotBeOrderedBy(propertyExpression, comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts the current collection does not have all elements in ascending order. Elements are compared\n /// using their implementation.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInAscendingOrder(string because = \"\", params object[] becauseArgs)\n {\n return NotBeInAscendingOrder(GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in ascending order according to the provided lambda expression.\n /// \n /// \n /// A lambda expression that should be used to determine the expected ordering between two objects.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInAscendingOrder(Func comparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeInOrder(Comparer.Create((x, y) => comparison(x, y)), SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in descending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInDescendingOrder(\n Expression> propertyExpression, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeInDescendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in descending order according to the value of the specified\n /// implementation.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint NotBeInDescendingOrder(\n IComparer comparer, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return NotBeInOrder(comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection not is ordered in descending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint NotBeInDescendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return NotBeOrderedBy(propertyExpression, comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts the current collection does not have all elements in descending order. Elements are compared\n /// using their implementation.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInDescendingOrder(string because = \"\", params object[] becauseArgs)\n {\n return NotBeInDescendingOrder(GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in descending order according to the provided lambda expression.\n /// \n /// \n /// A lambda expression that should be used to determine the expected ordering between two objects.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInDescendingOrder(Func comparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeInOrder(Comparer.Create((x, y) => comparison(x, y)), SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts that the collection is not null and contains at least 1 item.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNullOrEmpty(string because = \"\", params object[] becauseArgs)\n {\n return NotBeNull(because, becauseArgs)\n .And.NotBeEmpty(because, becauseArgs);\n }\n\n /// \n /// Asserts that the collection is not a subset of the .\n /// \n /// An with the unexpected superset.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSubsetOf(IEnumerable unexpectedSuperset,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Cannot assert a collection against a subset.\");\n\n if (assertionChain.Succeeded)\n {\n if (ReferenceEquals(Subject, unexpectedSuperset))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:collection} {0} to be a subset of {1}{reason}, but they both reference the same object.\",\n Subject,\n unexpectedSuperset);\n }\n\n ICollection actualItems = Subject.ConvertOrCastToCollection();\n\n if (actualItems.Intersect(unexpectedSuperset).Count() == actualItems.Count)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:collection} {0} to be a subset of {1}{reason}.\", actualItems,\n unexpectedSuperset);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection does not contain the supplied item.\n /// \n /// The element that is not expected to be in the collection\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContain(T unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to not contain {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded)\n {\n ICollection collection = Subject.ConvertOrCastToCollection();\n\n if (collection.Contains(unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to not contain {1}{reason}.\", collection, unexpected);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any items that match the predicate.\n /// \n /// A predicate to match the items in the collection against.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotContain(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} not to contain {0}{reason}, but found .\", predicate.Body);\n\n if (assertionChain.Succeeded)\n {\n Func compiledPredicate = predicate.Compile();\n IEnumerable unexpectedItems = Subject!.Where(item => compiledPredicate(item));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!unexpectedItems.Any())\n .FailWith(\"Expected {context:collection} {0} to not have any items matching {1}{reason}, but found {2}.\",\n Subject, predicate, unexpectedItems);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection does not contain the supplied items. Elements are compared\n /// using their implementation.\n /// \n /// An with the unexpected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotContain(IEnumerable unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot verify non-containment against a collection\");\n\n ICollection unexpectedObjects = unexpected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(unexpectedObjects, nameof(unexpected),\n \"Cannot verify non-containment against an empty collection\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to not contain {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable foundItems = unexpectedObjects.Intersect(Subject!);\n\n if (foundItems.Any())\n {\n if (unexpectedObjects.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to not contain {1}{reason}, but found {2}.\", Subject,\n unexpected, foundItems);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to not contain {1}{reason}.\",\n Subject, unexpectedObjects.First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that no element in the collection is equivalent to .\n /// \n /// \n /// \n /// Important: You cannot use this method to assert whether a subset of the collection is not equivalent to the .\n /// This usually means that the expectation is meant to be a single item.\n /// \n /// \n /// By default, objects within the collection are seen as not equivalent to the expected object when both object graphs have unequally named properties with the same\n /// value, irrespective of the type of those objects.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// \n /// The unexpected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainEquivalentOf(TExpectation unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotContainEquivalentOf(unexpected, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that no element in the collection is equivalent to .\n /// \n /// \n /// \n /// Important: You cannot use this method to assert whether a subset of the collection is not equivalent to the .\n /// This usually means that the expectation is meant to be a single item.\n /// \n /// \n /// By default, objects within the collection are seen as not equivalent to the expected object when both object graphs have unequally named properties with the same\n /// value, irrespective of the type of those objects.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// \n /// The unexpected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\", Justification = \"Needs refactoring\")]\n public AndConstraint NotContainEquivalentOf(TExpectation unexpected,\n Func,\n EquivalencyOptions> config, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} not to contain equivalent of {0}{reason}, but collection is .\",\n unexpected);\n\n if (assertionChain.Succeeded)\n {\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var foundIndices = new List();\n\n using (var scope = new AssertionScope())\n {\n int index = 0;\n\n foreach (T actualItem in Subject!)\n {\n var context =\n new EquivalencyValidationContext(Node.From(() => CurrentAssertionChain.CallerIdentifier),\n options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = actualItem,\n Expectation = unexpected,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n string[] failures = scope.Discard();\n\n if (failures.Length == 0)\n {\n foundIndices.Add(index);\n }\n\n index++;\n }\n }\n\n if (foundIndices.Count > 0)\n {\n using (new AssertionScope())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithReportable(\"configuration\", () => options.ToString())\n .WithExpectation(\"Expected {context:collection} {0} not to contain equivalent of {1}{reason}, \", Subject,\n unexpected, chain =>\n {\n if (foundIndices.Count == 1)\n {\n chain.FailWith(\"but found one at index {0}.\", foundIndices[0]);\n }\n else\n {\n chain.FailWith(\"but found several at indices {0}.\", foundIndices);\n }\n });\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts the current collection does not contain the specified elements in the exact same order, not necessarily consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// A with the unexpected elements.\n /// is .\n public AndConstraint NotContainInOrder(params T[] unexpected)\n {\n return NotContainInOrder(unexpected, string.Empty);\n }\n\n /// \n /// Asserts the current collection does not contain the specified elements in the exact same order, not necessarily consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// An with the unexpected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotContainInOrder(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected),\n \"Cannot verify absence of ordered containment against a collection.\");\n\n if (Subject is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Cannot verify absence of ordered containment in a collection.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n IList unexpectedItems = unexpected.ConvertOrCastToList();\n\n if (unexpectedItems.Any())\n {\n IList actualItems = Subject.ConvertOrCastToList();\n int subjectIndex = 0;\n\n foreach (var unexpectedItem in unexpectedItems)\n {\n subjectIndex = IndexOf(actualItems, unexpectedItem, startIndex: subjectIndex);\n\n if (subjectIndex == -1)\n {\n return new AndConstraint((TAssertions)this);\n }\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} to not contain items {1} in order{reason}, \" +\n \"but items appeared in order ending at index {2}.\",\n Subject, unexpected, subjectIndex - 1);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts the current collection does not contain the specified elements in the exact same order and are consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// A with the unexpected elements.\n /// is .\n public AndConstraint NotContainInConsecutiveOrder(params T[] unexpected)\n {\n return NotContainInConsecutiveOrder(unexpected, string.Empty);\n }\n\n /// \n /// Asserts the current collection does not contain the specified elements in the exact same order and consecutively.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// An with the unexpected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotContainInConsecutiveOrder(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected),\n \"Cannot verify absence of ordered containment against a collection.\");\n\n if (Subject is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Cannot verify absence of ordered containment in a collection.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n IList unexpectedItems = unexpected.ConvertOrCastToList();\n\n if (unexpectedItems.Any())\n {\n IList actualItems = Subject.ConvertOrCastToList();\n\n if (unexpectedItems.Count > actualItems.Count)\n {\n return new AndConstraint((TAssertions)this);\n }\n\n int subjectIndex = 0;\n\n while (subjectIndex != -1)\n {\n subjectIndex = IndexOf(actualItems, unexpectedItems[0], startIndex: subjectIndex);\n\n if (subjectIndex != -1)\n {\n int consecutiveItems = ConsecutiveItemCount(actualItems, unexpectedItems, startIndex: subjectIndex);\n\n if (consecutiveItems == unexpectedItems.Count)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} to not contain items {1} in consecutive order{reason}, \" +\n \"but items appeared in order ending at index {2}.\",\n Subject, unexpectedItems, (subjectIndex + consecutiveItems) - 2);\n }\n\n subjectIndex++;\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any items.\n /// \n /// The predicate when evaluated should not be null.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotContainNulls(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TKey : class\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} not to contain s{reason}, but collection is .\");\n\n if (assertionChain.Succeeded)\n {\n Func compiledPredicate = predicate.Compile();\n\n T[] values = Subject!\n .Where(e => compiledPredicate(e) is null)\n .ToArray();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(values.Length == 0)\n .FailWith(\"Expected {context:collection} not to contain s on {0}{reason}, but found {1}.\",\n predicate.Body, values);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any items.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainNulls(string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} not to contain s{reason}, but collection is .\");\n\n if (assertionChain.Succeeded)\n {\n int[] indices = Subject!\n .Select((item, index) => (Item: item, Index: index))\n .Where(e => e.Item is null)\n .Select(e => e.Index)\n .ToArray();\n\n if (indices.Length > 0)\n {\n if (indices.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} not to contain s{reason}, but found several at indices {0}.\",\n indices);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} not to contain s{reason}, but found one at index {0}.\",\n indices[0]);\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection not to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their .\n /// \n /// An with the elements that are not expected.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEqual(IEnumerable unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare collection with .\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected collections not to be equal{reason}, \", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(subject => !ReferenceEquals(subject, unexpected))\n .FailWith(\"but they both reference the same object.\"))\n .Then\n .Given(() => Subject.ConvertOrCastToCollection())\n .ForCondition(actualItems => !actualItems.SequenceEqual(unexpected))\n .FailWith(\"Did not expect collections {0} and {1} to be equal{reason}.\", _ => unexpected,\n actualItems => actualItems);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection does not match the supplied amount.\n /// \n /// The unexpected number of items in the collection.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveCount(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to not contain {0} item(s){reason}, \", unexpected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount != unexpected)\n .FailWith(\"but found {0}.\", actualCount => actualCount));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Assert that the current collection does not have the same number of elements as .\n /// \n /// The other collection with the unexpected number of elements\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotHaveSameCount(IEnumerable otherCollection,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(otherCollection, nameof(otherCollection), \"Cannot verify count against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\n \"Expected {context:collection} to not have the same count as {0}{reason}, but found .\",\n otherCollection)\n .Then\n .ForCondition(subject => !ReferenceEquals(subject, otherCollection))\n .FailWith(\n \"Expected {context:collection} {0} to not have the same count as {1}{reason}, but they both reference the same object.\",\n subject => subject, _ => otherCollection)\n .Then\n .Given(subject => (actual: subject.Count(), expected: otherCollection.Count()))\n .ForCondition(count => count.actual != count.expected)\n .FailWith(\n \"Expected {context:collection} to not have {0} item(s){reason}, but found {1}.\",\n count => count.expected, count => count.actual);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not share any items with the specified .\n /// \n /// The to compare to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotIntersectWith(IEnumerable otherCollection,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(otherCollection, nameof(otherCollection),\n \"Cannot verify intersection against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\n \"Did not expect {context:collection} to intersect with {0}{reason}, but found .\",\n otherCollection)\n .Then\n .ForCondition(subject => !ReferenceEquals(subject, otherCollection))\n .FailWith(\n \"Did not expect {context:collection} {0} to intersect with {1}{reason}, but they both reference the same object.\",\n subject => subject, _ => otherCollection)\n .Then\n .Given(subject => subject.Intersect(otherCollection))\n .ForCondition(sharedItems => !sharedItems.Any())\n .FailWith(\n \"Did not expect {context:collection} to intersect with {0}{reason}, but found the following shared items {1}.\",\n _ => otherCollection, sharedItems => sharedItems);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection only contains items that match a predicate.\n /// \n /// A predicate to match the items in the collection against.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint OnlyContain(\n Expression> predicate, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n Func compiledPredicate = predicate.Compile();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain only items matching {0}{reason}, \", predicate.Body,\n chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but the collection is .\")\n .Then\n .Given(subject => subject.ConvertOrCastToCollection().Where(item => !compiledPredicate(item)))\n .ForCondition(mismatchingItems => !mismatchingItems.Any())\n .FailWith(\"but {0} do(es) not match.\", mismatchingItems => mismatchingItems));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any duplicate items.\n /// \n /// The predicate to group the items by.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint OnlyHaveUniqueItems(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to only have unique items{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n Func compiledPredicate = predicate.Compile();\n\n IGrouping[] groupWithMultipleItems = Subject!\n .GroupBy(compiledPredicate)\n .Where(g => g.Count() > 1)\n .ToArray();\n\n if (groupWithMultipleItems.Length > 0)\n {\n if (groupWithMultipleItems.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to only have unique items on {0}{reason}, but items {1} are not unique.\",\n predicate.Body,\n groupWithMultipleItems.SelectMany(g => g));\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to only have unique items on {0}{reason}, but item {1} is not unique.\",\n predicate.Body,\n groupWithMultipleItems[0].First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any duplicate items.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint OnlyHaveUniqueItems(string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to only have unique items{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n T[] groupWithMultipleItems = Subject!\n .GroupBy(o => o)\n .Where(g => g.Count() > 1)\n .Select(g => g.Key)\n .ToArray();\n\n if (groupWithMultipleItems.Length > 0)\n {\n if (groupWithMultipleItems.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to only have unique items{reason}, but items {0} are not unique.\",\n groupWithMultipleItems);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to only have unique items{reason}, but item {0} is not unique.\",\n groupWithMultipleItems[0]);\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection contains only items which meet\n /// the criteria provided by the inspector.\n /// \n /// \n /// The element inspector, which inspects each element in turn.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllSatisfy(Action expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify against a inspector\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain only items satisfying the inspector{reason}, \",\n chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but collection is .\"));\n\n if (assertionChain.Succeeded)\n {\n string[] failuresFromInspectors;\n\n using (CallerIdentifier.OverrideStackSearchUsingCurrentScope())\n {\n var elementInspectors = Subject.Select(_ => expected);\n failuresFromInspectors = CollectFailuresFromInspectors(elementInspectors);\n }\n\n if (failuresFromInspectors.Length > 0)\n {\n string failureMessage = Environment.NewLine\n + string.Join(Environment.NewLine, failuresFromInspectors.Select(x => x.IndentLines()));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain only items satisfying the inspector{reason}:\",\n chain => chain\n .FailWithPreFormatted(failureMessage));\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection contains exactly a given number of elements, which meet\n /// the criteria provided by the element inspectors.\n /// \n /// \n /// The element inspectors, which inspect each element in turn. The\n /// total number of element inspectors must exactly match the number of elements in the collection.\n /// \n /// is .\n /// is empty.\n public AndConstraint SatisfyRespectively(params Action[] elementInspectors)\n {\n return SatisfyRespectively(elementInspectors, string.Empty);\n }\n\n /// \n /// Asserts that a collection contains exactly a given number of elements, which meet\n /// the criteria provided by the element inspectors.\n /// \n /// \n /// The element inspectors, which inspect each element in turn. The\n /// total number of element inspectors must exactly match the number of elements in the collection.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint SatisfyRespectively(IEnumerable> expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify against a collection of inspectors\");\n\n ICollection> elementInspectors = expected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(elementInspectors, nameof(expected),\n \"Cannot verify against an empty collection of inspectors\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to satisfy all inspectors{reason}, \", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but collection is .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\"but collection is empty.\"))\n .Then\n .Given(() => (elements: Subject.Count(), inspectors: elementInspectors.Count))\n .ForCondition(count => count.elements == count.inspectors)\n .FailWith(\n \"Expected {context:collection} to contain exactly {0} items{reason}, but it contains {1} items\",\n count => count.inspectors, count => count.elements);\n\n if (assertionChain.Succeeded)\n {\n string[] failuresFromInspectors;\n\n using (CallerIdentifier.OverrideStackSearchUsingCurrentScope())\n {\n failuresFromInspectors = CollectFailuresFromInspectors(elementInspectors);\n }\n\n if (failuresFromInspectors.Length > 0)\n {\n string failureMessage = Environment.NewLine\n + string.Join(Environment.NewLine, failuresFromInspectors.Select(x => x.IndentLines()));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\n \"Expected {context:collection} to satisfy all inspectors{reason}, but some inspectors are not satisfied:\",\n chain => chain\n .FailWithPreFormatted(failureMessage));\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection contains exactly a given number of elements which meet\n /// the criteria provided by the element predicates. Assertion fails if it is not possible\n /// to find a one-to-one mapping between the elements of the collection and the predicates.\n /// The order of the predicates does not need to match the order of the elements.\n /// \n /// \n /// The predicates that the elements of the collection must match.\n /// The total number of predicates must exactly match the number of elements in the collection.\n /// \n /// is .\n /// is empty.\n public AndConstraint Satisfy(params Expression>[] predicates)\n {\n return Satisfy(predicates, because: string.Empty);\n }\n\n /// \n /// Asserts that a collection contains exactly a given number of elements which meet\n /// the criteria provided by the element predicates. Assertion fails if it is not possible\n /// to find a one-to-one mapping between the elements of the collection and the predicates.\n /// \n /// \n /// The predicates that the elements of the collection must match.\n /// The total number of predicates must exactly match the number of elements in the collection.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint Satisfy(IEnumerable>> predicates,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicates, nameof(predicates), \"Cannot verify against a collection of predicates\");\n\n IList>> predicatesList = predicates.ConvertOrCastToList();\n\n Guard.ThrowIfArgumentIsEmpty(predicatesList, nameof(predicates),\n \"Cannot verify against an empty collection of predicates\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"Expected {context:collection} to satisfy all predicates{reason}, but collection is .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\"Expected {context:collection} to satisfy all predicates{reason}, but collection is empty.\");\n\n if (assertionChain.Succeeded)\n {\n MaximumMatchingSolution maximumMatchingSolution = new MaximumMatchingProblem(predicatesList, Subject).Solve();\n\n if (maximumMatchingSolution.UnmatchedPredicatesExist || maximumMatchingSolution.UnmatchedElementsExist)\n {\n string message = string.Empty;\n var doubleNewLine = Environment.NewLine + Environment.NewLine;\n\n List> unmatchedPredicates = maximumMatchingSolution.GetUnmatchedPredicates();\n\n if (unmatchedPredicates.Count > 0)\n {\n message += doubleNewLine + \"The following predicates did not have matching elements:\";\n\n message += doubleNewLine +\n string.Join(Environment.NewLine,\n unmatchedPredicates.Select(predicate => Formatter.ToString(predicate.Expression)));\n }\n\n List> unmatchedElements = maximumMatchingSolution.GetUnmatchedElements();\n\n if (unmatchedElements.Count > 0)\n {\n message += doubleNewLine + \"The following elements did not match any predicate:\";\n\n IEnumerable elementDescriptions = unmatchedElements\n .Select(element => $\"Index: {element.Index}, Element: {Formatter.ToString(element.Value)}\");\n\n message += doubleNewLine + string.Join(doubleNewLine, elementDescriptions);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to satisfy all predicates{reason}, but:\", chain => chain\n .FailWithPreFormatted(message));\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection starts with same elements in the same order as the collection identified by\n /// . Elements are compared using their .\n /// \n /// \n /// A collection of expected elements.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWith(IEnumerable expectation, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return StartWith(expectation, (a, b) => EqualityComparer.Default.Equals(a, b), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current collection starts with same elements in the same order as the collection identified by\n /// . Elements are compared using .\n /// \n /// \n /// A collection of expected elements.\n /// \n /// \n /// A equality comparison the is used to determine whether two objects should be treated as equal.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWith(\n IEnumerable expectation, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectation, nameof(expectation), \"Cannot compare collection with .\");\n\n AssertCollectionStartsWith(Subject, expectation.ConvertOrCastToCollection(), equalityComparison, because, becauseArgs);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection starts with the specified .\n /// \n /// \n /// The element that is expected to appear at the start of the collection. The object's \n /// is used to compare the element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint StartWith(T element, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return StartWith([element], ObjectExtensions.GetComparer(), because, becauseArgs);\n }\n\n internal AndConstraint> BeOrderedBy(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n string because,\n object[] becauseArgs)\n {\n if (IsValidProperty(propertyExpression, because, becauseArgs))\n {\n ICollection unordered = Subject.ConvertOrCastToCollection();\n\n IOrderedEnumerable expectation = GetOrderedEnumerable(\n propertyExpression,\n comparer,\n direction,\n unordered);\n\n assertionChain\n .ForCondition(unordered.SequenceEqual(expectation))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to be ordered {1}{reason} and result in {2}.\",\n () => Subject, () => GetExpressionOrderString(propertyExpression), () => expectation);\n\n return new AndConstraint>(\n new SubsequentOrderingAssertions(Subject, expectation, assertionChain));\n }\n\n return new AndConstraint>(\n new SubsequentOrderingAssertions(Subject, EmptyOrderedEnumerable, assertionChain));\n }\n\n internal virtual IOrderedEnumerable GetOrderedEnumerable(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n ICollection unordered)\n {\n Func keySelector = propertyExpression.Compile();\n\n IOrderedEnumerable expectation = direction == SortOrder.Ascending\n ? unordered.OrderBy(keySelector, comparer)\n : unordered.OrderByDescending(keySelector, comparer);\n\n return expectation;\n }\n\n protected static IEnumerable RepeatAsManyAs(TExpectation value, IEnumerable enumerable)\n {\n if (enumerable is null)\n {\n return [];\n }\n\n return RepeatAsManyAsIterator(value, enumerable);\n }\n\n protected void AssertCollectionEndsWith(IEnumerable actual,\n ICollection expected, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(equalityComparison);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to end with {0}{reason}, \", expected, chain => chain\n .Given(() => actual)\n .AssertCollectionIsNotNull()\n .Then\n .AssertCollectionHasEnoughItems(expected.Count)\n .Then\n .AssertCollectionsHaveSameItems(expected, (a, e) =>\n {\n int firstIndexToCompare = a.Count - e.Count;\n int index = a.Skip(firstIndexToCompare).IndexOfFirstDifferenceWith(e, equalityComparison);\n return index >= 0 ? index + firstIndexToCompare : index;\n }));\n }\n\n protected void AssertCollectionStartsWith(IEnumerable actualItems,\n ICollection expected, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(equalityComparison);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to start with {0}{reason}, \", expected, chain => chain\n .Given(() => actualItems)\n .AssertCollectionIsNotNull()\n .Then\n .AssertCollectionHasEnoughItems(expected.Count)\n .Then\n .AssertCollectionsHaveSameItems(expected,\n (a, e) => a.Take(e.Count).IndexOfFirstDifferenceWith(e, equalityComparison)));\n }\n\n protected void AssertSubjectEquality(IEnumerable expectation,\n Func equalityComparison, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(equalityComparison);\n\n bool subjectIsNull = Subject is null;\n bool expectationIsNull = expectation is null;\n\n if (subjectIsNull && expectationIsNull)\n {\n return;\n }\n\n Guard.ThrowIfArgumentIsNull(expectation, nameof(expectation), \"Cannot compare collection with .\");\n\n ICollection expectedItems = expectation.ConvertOrCastToCollection();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!subjectIsNull)\n .FailWith(\"Expected {context:collection} to be equal to {0}{reason}, but found .\", expectedItems)\n .Then\n .WithExpectation(\"Expected {context:collection} to be equal to {0}{reason}, \", expectedItems, chain => chain\n .Given(() => Subject.ConvertOrCastToCollection())\n .AssertCollectionsHaveSameCount(expectedItems.Count)\n .Then\n .AssertCollectionsHaveSameItems(expectedItems, (a, e) => a.IndexOfFirstDifferenceWith(e, equalityComparison)));\n }\n\n private static string GetExpressionOrderString(Expression> propertyExpression)\n {\n string orderString = propertyExpression.GetMemberPath().ToString();\n\n return orderString is \"\\\"\\\"\" ? string.Empty : \"by \" + orderString;\n }\n\n private static Type GetType(TType o)\n {\n return o is Type t ? t : o.GetType();\n }\n\n private static bool HasPredecessor(T successor, TCollection subject)\n {\n return !ReferenceEquals(subject.First(), successor);\n }\n\n private static bool HasSuccessor(T predecessor, TCollection subject)\n {\n return !ReferenceEquals(subject.Last(), predecessor);\n }\n\n private static T PredecessorOf(T successor, TCollection subject)\n {\n IList collection = subject.ConvertOrCastToList();\n int index = collection.IndexOf(successor);\n return index > 0 ? collection[index - 1] : default;\n }\n\n private static IEnumerable RepeatAsManyAsIterator(TExpectation value, IEnumerable enumerable)\n {\n using IEnumerator enumerator = enumerable.GetEnumerator();\n\n while (enumerator.MoveNext())\n {\n yield return value;\n }\n }\n\n private static T SuccessorOf(T predecessor, TCollection subject)\n {\n IList collection = subject.ConvertOrCastToList();\n int index = collection.IndexOf(predecessor);\n return index < (collection.Count - 1) ? collection[index + 1] : default;\n }\n\n private string[] CollectFailuresFromInspectors(IEnumerable> elementInspectors)\n {\n string[] collectionFailures;\n\n using (var collectionScope = new AssertionScope())\n {\n int index = 0;\n\n foreach ((T element, Action inspector) in Subject.Zip(elementInspectors,\n (element, inspector) => (element, inspector)))\n {\n string[] inspectorFailures;\n\n using (var itemScope = new AssertionScope())\n {\n inspector(element);\n inspectorFailures = itemScope.Discard();\n }\n\n if (inspectorFailures.Length > 0)\n {\n // Adding one tab and removing trailing dot to allow nested SatisfyRespectively\n string failures = string.Join(Environment.NewLine,\n inspectorFailures.Select(x => x.IndentLines().TrimEnd('.')));\n\n collectionScope.AddPreFormattedFailure($\"At index {index}:{Environment.NewLine}{failures}\");\n }\n\n index++;\n }\n\n collectionFailures = collectionScope.Discard();\n }\n\n return collectionFailures;\n }\n\n private bool IsValidProperty(Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because,\n object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(propertyExpression, nameof(propertyExpression),\n \"Cannot assert collection ordering without specifying a property.\");\n\n propertyExpression.ValidateMemberPath();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to be ordered by {0}{reason} but found .\",\n () => propertyExpression.GetMemberPath());\n\n return assertionChain.Succeeded;\n }\n\n private AndConstraint NotBeOrderedBy(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n string because,\n object[] becauseArgs)\n {\n if (IsValidProperty(propertyExpression, because, becauseArgs))\n {\n ICollection unordered = Subject.ConvertOrCastToCollection();\n\n IOrderedEnumerable expectation = GetOrderedEnumerable(\n propertyExpression,\n comparer,\n direction,\n unordered);\n\n assertionChain\n .ForCondition(!unordered.SequenceEqual(expectation))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to not be ordered {1}{reason} and not result in {2}.\",\n () => Subject, () => GetExpressionOrderString(propertyExpression), () => expectation);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection to have all elements in the specified .\n /// Elements are compared using their implementation.\n /// \n private AndConstraint> BeInOrder(\n IComparer comparer, SortOrder expectedOrder, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n string sortOrder = expectedOrder == SortOrder.Ascending ? \"ascending\" : \"descending\";\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:collection}} to be in {sortOrder} order{{reason}}, but found .\");\n\n IOrderedEnumerable ordering = EmptyOrderedEnumerable;\n\n if (assertionChain.Succeeded)\n {\n IList actualItems = Subject.ConvertOrCastToList();\n\n ordering = expectedOrder == SortOrder.Ascending\n ? actualItems.OrderBy(item => item, comparer)\n : actualItems.OrderByDescending(item => item, comparer);\n\n T[] orderedItems = ordering.ToArray();\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n for (int index = 0; index < orderedItems.Length; index++)\n {\n if (!areSameOrEqual(actualItems[index], orderedItems[index]))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to be in \" + sortOrder +\n \" order{reason}, but found {0} where item at index {1} is in wrong order.\",\n actualItems, index);\n\n return new AndConstraint>(\n new SubsequentOrderingAssertions(Subject, EmptyOrderedEnumerable, assertionChain));\n }\n }\n }\n\n return new AndConstraint>(\n new SubsequentOrderingAssertions(Subject, ordering, assertionChain));\n }\n\n /// \n /// Asserts the current collection does not have all elements in ascending order. Elements are compared\n /// using their implementation.\n /// \n private AndConstraint NotBeInOrder(IComparer comparer, SortOrder order,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n string sortOrder = order == SortOrder.Ascending ? \"ascending\" : \"descending\";\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Did not expect {{context:collection}} to be in {sortOrder} order{{reason}}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n IList actualItems = Subject.ConvertOrCastToList();\n\n T[] orderedItems = order == SortOrder.Ascending\n ? actualItems.OrderBy(item => item, comparer).ToArray()\n : actualItems.OrderByDescending(item => item, comparer).ToArray();\n\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n bool itemsAreUnordered = actualItems\n .Where((actualItem, index) => !areSameOrEqual(actualItem, orderedItems[index]))\n .Any();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(itemsAreUnordered)\n .FailWith(\n \"Did not expect {context:collection} to be in \" + sortOrder + \" order{reason}, but found {0}.\",\n actualItems);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\n \"Equals is not part of Awesome Assertions. Did you mean BeSameAs(), Equal(), or BeEquivalentTo() instead?\");\n\n private static int IndexOf(IList items, T item, int startIndex)\n {\n Func comparer = ObjectExtensions.GetComparer();\n\n for (; startIndex < items.Count; startIndex++)\n {\n if (comparer(items[startIndex], item))\n {\n startIndex++;\n return startIndex;\n }\n }\n\n return -1;\n }\n\n private static int ConsecutiveItemCount(IList actualItems, IList expectedItems, int startIndex)\n {\n for (var index = 1; index < expectedItems.Count; index++)\n {\n T unexpectedItem = expectedItems[index];\n\n int previousSubjectIndex = startIndex;\n startIndex = IndexOf(actualItems, unexpectedItem, startIndex: startIndex);\n\n if (startIndex == -1 || !previousSubjectIndex.IsConsecutiveTo(startIndex))\n {\n return index;\n }\n }\n\n return expectedItems.Count;\n }\n\n private protected static IComparer GetComparer() =>\n typeof(TItem) == typeof(string) ? (IComparer)StringComparer.Ordinal : Comparer.Default;\n\n private static IOrderedEnumerable EmptyOrderedEnumerable =>\n#if NET8_0_OR_GREATER\n Enumerable.Empty().Order();\n#else\n Enumerable.Empty().OrderBy(x => x);\n#endif\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.cs", "using System;\nusing AwesomeAssertions.Equivalency.Matching;\nusing AwesomeAssertions.Equivalency.Ordering;\nusing AwesomeAssertions.Equivalency.Selection;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n [Fact]\n public void Public_methods_follow_fluent_syntax()\n {\n // Arrange\n var subject = new Root();\n var expected = new RootDto();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .AllowingInfiniteRecursion()\n .ComparingByMembers(typeof(Root))\n .ComparingByMembers()\n .ComparingByValue(typeof(Customer))\n .ComparingByValue()\n .ComparingEnumsByName()\n .ComparingEnumsByValue()\n .ComparingRecordsByMembers()\n .ComparingRecordsByValue()\n .Excluding(r => r.Level)\n .ExcludingFields()\n .ExcludingMissingMembers()\n .WithoutRecursing()\n .ExcludingNonBrowsableMembers()\n .ExcludingProperties()\n .IgnoringCyclicReferences()\n .IgnoringNonBrowsableMembersOnSubject()\n .Including(r => r.Level)\n .IncludingAllDeclaredProperties()\n .IncludingAllRuntimeProperties()\n .IncludingFields()\n .IncludingInternalFields()\n .IncludingInternalProperties()\n .IncludingNestedObjects()\n .IncludingProperties()\n .PreferringDeclaredMemberTypes()\n .PreferringRuntimeMemberTypes()\n .ThrowingOnMissingMembers()\n .Using(new ExtensibilitySpecs.DoEquivalencyStep(() => { }))\n .Using(new MustMatchByNameRule())\n .Using(new AllFieldsSelectionRule())\n .Using(new ByteArrayOrderingRule())\n .Using(StringComparer.OrdinalIgnoreCase)\n .WithAutoConversion()\n .WithAutoConversionFor(_ => false)\n .WithoutAutoConversionFor(_ => true)\n .WithoutMatchingRules()\n .WithoutSelectionRules()\n .WithoutStrictOrdering()\n .WithoutStrictOrderingFor(r => r.Level)\n .WithStrictOrdering()\n .WithStrictOrderingFor(r => r.Level)\n .WithTracing()\n );\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/XmlReaderValidator.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Xml;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Xml.Equivalency;\n\ninternal class XmlReaderValidator\n{\n private readonly AssertionChain assertionChain;\n private readonly XmlReader subjectReader;\n private readonly XmlReader expectationReader;\n private XmlIterator subjectIterator;\n private XmlIterator expectationIterator;\n private Node currentNode = Node.CreateRoot();\n\n public XmlReaderValidator(AssertionChain assertionChain, XmlReader subjectReader, XmlReader expectationReader, string because, object[] becauseArgs)\n {\n this.assertionChain = assertionChain;\n assertionChain.BecauseOf(because, becauseArgs);\n\n this.subjectReader = subjectReader;\n this.expectationReader = expectationReader;\n }\n\n public void Validate(bool shouldBeEquivalent)\n {\n Failure failure = Validate();\n\n if (shouldBeEquivalent && failure is not null)\n {\n assertionChain.FailWith(failure.FormatString, failure.FormatParams);\n }\n\n if (!shouldBeEquivalent && failure is null)\n {\n assertionChain.FailWith(\"Did not expect {context:subject} to be equivalent{reason}, but it is.\");\n }\n }\n\n#pragma warning disable MA0051\n private Failure Validate()\n#pragma warning restore MA0051\n {\n if (subjectReader is null && expectationReader is null)\n {\n return null;\n }\n\n Failure failure = ValidateAgainstNulls();\n\n if (failure is not null)\n {\n return failure;\n }\n\n subjectIterator = new XmlIterator(subjectReader);\n expectationIterator = new XmlIterator(expectationReader);\n\n while (!subjectIterator.IsEndOfDocument && !expectationIterator.IsEndOfDocument)\n {\n if (subjectIterator.NodeType != expectationIterator.NodeType)\n {\n var expectation = expectationIterator.NodeType == XmlNodeType.Text\n ? $\"content \\\"{expectationIterator.Value}\\\"\"\n : $\"{expectationIterator.NodeType} \\\"{expectationIterator.LocalName}\\\"\";\n\n var subject = subjectIterator.NodeType == XmlNodeType.Text\n ? $\"content \\\"{subjectIterator.Value}\\\"\"\n : $\"{subjectIterator.NodeType} \\\"{subjectIterator.LocalName}\\\"\";\n\n return new Failure(\n $\"Expected {expectation} in {{context:subject}} at {{0}}{{reason}}, but found {subject}.\",\n currentNode.GetXPath());\n }\n\n#pragma warning disable IDE0010 // The default case handles the many missing cases\n switch (expectationIterator.NodeType)\n#pragma warning restore IDE0010\n {\n case XmlNodeType.Element:\n failure = ValidateStartElement();\n\n if (failure is not null)\n {\n return failure;\n }\n\n // starting new element, add local name to location stack\n // to build XPath info\n currentNode = currentNode.Push(expectationIterator.LocalName);\n\n failure = ValidateAttributes();\n\n if (expectationIterator.IsEmptyElement)\n {\n // The element is already complete. (We will NOT get an EndElement node.)\n // Update node information.\n currentNode = currentNode.Parent;\n }\n\n // check whether empty element and self-closing element needs to be synchronized\n if (subjectIterator.IsEmptyElement && !expectationIterator.IsEmptyElement)\n {\n expectationIterator.MoveToEndElement();\n }\n else if (expectationIterator.IsEmptyElement && !subjectIterator.IsEmptyElement)\n {\n subjectIterator.MoveToEndElement();\n }\n\n break;\n\n case XmlNodeType.EndElement:\n // No need to verify end element, if it doesn't match\n // the start element it isn't valid XML, so the parser\n // would handle that.\n currentNode.Pop();\n currentNode = currentNode.Parent;\n break;\n\n case XmlNodeType.Text:\n failure = ValidateText();\n break;\n\n default:\n throw new NotSupportedException(\n $\"{expectationIterator.NodeType} found at {currentNode.GetXPath()} is not supported for equivalency comparison.\");\n }\n\n if (failure is not null)\n {\n return failure;\n }\n\n subjectIterator.Read();\n expectationIterator.Read();\n }\n\n if (!expectationIterator.IsEndOfDocument)\n {\n return new Failure(\n \"Expected {0} in {context:subject}{reason}, but found end of document.\",\n expectationIterator.LocalName);\n }\n\n if (!subjectIterator.IsEndOfDocument)\n {\n return new Failure(\n \"Expected end of document in {context:subject}{reason}, but found {0}.\",\n subjectIterator.LocalName);\n }\n\n return null;\n }\n\n private Failure ValidateAttributes()\n {\n IList expectedAttributes = expectationIterator.GetAttributes();\n IList subjectAttributes = subjectIterator.GetAttributes();\n\n foreach (AttributeData subjectAttribute in subjectAttributes)\n {\n AttributeData expectedAttribute = expectedAttributes.SingleOrDefault(\n ea => ea.NamespaceUri == subjectAttribute.NamespaceUri\n && ea.LocalName == subjectAttribute.LocalName);\n\n if (expectedAttribute is null)\n {\n return new Failure(\n \"Did not expect to find attribute {0} in {context:subject} at {1}{reason}.\",\n subjectAttribute.QualifiedName, currentNode.GetXPath());\n }\n\n if (subjectAttribute.Value != expectedAttribute.Value)\n {\n return new Failure(\n \"Expected attribute {0} in {context:subject} at {1} to have value {2}{reason}, but found {3}.\",\n subjectAttribute.LocalName, currentNode.GetXPath(), expectedAttribute.Value, subjectAttribute.Value);\n }\n }\n\n if (subjectAttributes.Count != expectedAttributes.Count)\n {\n AttributeData missingAttribute = expectedAttributes.First(ea =>\n !subjectAttributes.Any(sa =>\n ea.NamespaceUri == sa.NamespaceUri\n && sa.LocalName == ea.LocalName));\n\n return new Failure(\n \"Expected attribute {0} in {context:subject} at {1}{reason}, but found none.\",\n missingAttribute.LocalName, currentNode.GetXPath());\n }\n\n return null;\n }\n\n private Failure ValidateStartElement()\n {\n if (subjectIterator.LocalName != expectationIterator.LocalName)\n {\n return new Failure(\n \"Expected local name of element in {context:subject} at {0} to be {1}{reason}, but found {2}.\",\n currentNode.GetXPath(), expectationIterator.LocalName, subjectIterator.LocalName);\n }\n\n if (subjectIterator.NamespaceUri != expectationIterator.NamespaceUri)\n {\n return new Failure(\n \"Expected namespace of element {0} in {context:subject} at {1} to be {2}{reason}, but found {3}.\",\n subjectIterator.LocalName, currentNode.GetXPath(), expectationIterator.NamespaceUri,\n subjectIterator.NamespaceUri);\n }\n\n return null;\n }\n\n private Failure ValidateText()\n {\n string subject = subjectIterator.Value;\n string expected = expectationIterator.Value;\n\n if (subject != expected)\n {\n return new Failure(\n \"Expected content to be {0} in {context:subject} at {1}{reason}, but found {2}.\",\n expected, currentNode.GetXPath(), subject);\n }\n\n return null;\n }\n\n private Failure ValidateAgainstNulls()\n {\n if (expectationReader is null != subjectReader is null)\n {\n return new Failure(\n \"Expected {context:subject} to be equivalent to {0}{reason}, but found {1}.\",\n subjectReader, expectationReader);\n }\n\n return null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyResult.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic enum EquivalencyResult\n{\n ContinueWithNext,\n EquivalencyProven\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/SelectMemberByPathSelectionRule.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\ninternal abstract class SelectMemberByPathSelectionRule : IMemberSelectionRule\n{\n public virtual bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n var currentPath = RemoveRootIndexQualifier(currentNode.Expectation.PathAndName);\n var members = selectedMembers.ToList();\n AddOrRemoveMembersFrom(members, currentNode, currentPath, context);\n\n return members;\n }\n\n protected abstract void AddOrRemoveMembersFrom(List selectedMembers,\n INode parent, string parentPath,\n MemberSelectionContext context);\n\n private static string RemoveRootIndexQualifier(string path)\n {\n Match match = new Regex(@\"^\\[[0-9]+]\").Match(path);\n\n if (match.Success)\n {\n path = path.Substring(match.Length);\n }\n\n return path;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Configuration/GlobalEquivalencyOptions.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Configuration;\n\npublic class GlobalEquivalencyOptions\n{\n private EquivalencyOptions defaults = new();\n\n /// \n /// Represents a mutable plan consisting of steps that are executed while asserting a (collection of) object(s)\n /// is structurally equivalent to another (collection of) object(s).\n /// \n /// \n /// Members on this property are not thread-safe and should not be invoked from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public EquivalencyPlan Plan { get; } = new();\n\n /// \n /// Allows configuring the defaults used during a structural equivalency assertion.\n /// \n /// \n /// This method is not thread-safe and should not be invoked from within a unit test.\n /// See the docs on how to safely use it.\n /// \n /// \n /// An action that is used to configure the defaults.\n /// \n /// is .\n public void Modify(Func configureOptions)\n {\n Guard.ThrowIfArgumentIsNull(configureOptions);\n\n defaults = configureOptions(defaults);\n }\n\n /// \n /// Creates a clone of the default options and allows the caller to modify them.\n /// \n /// \n /// Can be used by external packages like AwesomeAssertions.DataSets to create a copy of the default equivalency options.\n /// \n [PublicAPI]\n public EquivalencyOptions CloneDefaults()\n {\n return new EquivalencyOptions(defaults);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/IncludeMemberByPathSelectionRule.cs", "using System.Collections.Generic;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that includes a particular property in the structural comparison.\n/// \ninternal class IncludeMemberByPathSelectionRule : SelectMemberByPathSelectionRule\n{\n private readonly MemberPath memberToInclude;\n\n public IncludeMemberByPathSelectionRule(MemberPath pathToInclude)\n {\n memberToInclude = pathToInclude;\n }\n\n public override bool IncludesMembers => true;\n\n protected override void AddOrRemoveMembersFrom(List selectedMembers, INode parent, string parentPath,\n MemberSelectionContext context)\n {\n foreach (MemberInfo memberInfo in context.Type.GetMembers(MemberKind.Public | MemberKind.Internal))\n {\n var memberPath = new MemberPath(context.Type, memberInfo.DeclaringType, parentPath.Combine(memberInfo.Name));\n\n if (memberToInclude.IsSameAs(memberPath) || memberToInclude.IsParentOrChildOf(memberPath))\n {\n selectedMembers.Add(MemberFactory.Create(memberInfo, parent));\n }\n }\n }\n\n public override string ToString()\n {\n return \"Include member root.\" + memberToInclude;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class StringAssertions : StringAssertions\n{\n /// \n /// Initializes a new instance of the class.\n /// \n public StringAssertions(string value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class StringAssertions : ReferenceTypeAssertions\n where TAssertions : StringAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public StringAssertions(string value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a string is exactly the same as another string, including the casing and any leading or trailing whitespace.\n /// \n /// The expected string.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var stringEqualityValidator = new StringValidator(assertionChain,\n new StringEqualityStrategy(StringComparer.Ordinal, \"be\"),\n because, becauseArgs);\n\n stringEqualityValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params string[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is exactly the same as another string, including any leading or trailing whitespace, with\n /// the exception of the casing.\n /// \n /// \n /// The string that the subject is expected to be equivalent to.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var expectation = new StringValidator(assertionChain,\n new StringEqualityStrategy(StringComparer.OrdinalIgnoreCase, \"be equivalent to\"),\n because, becauseArgs);\n\n expectation.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is exactly the same as another string, using the provided .\n /// \n /// \n /// The string that the subject is expected to be equivalent to.\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var expectation = new StringValidator(assertionChain,\n new StringEqualityStrategy(options.GetStringComparerOrDefault(), \"be equivalent to\"),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n expectation.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is not exactly the same as another string, including any leading or trailing whitespace, with\n /// the exception of the casing.\n /// \n /// \n /// The string that the subject is not expected to be equivalent to.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n BeEquivalentTo(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be equivalent to {0}{reason}, but they are.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is not exactly the same as another string, using the provided .\n /// \n /// \n /// The string that the subject is not expected to be equivalent to.\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(string unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().BeEquivalentTo(unexpected, config);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be equivalent to {0}{reason}, but they are.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n#if NET8_0_OR_GREATER\n\n /// \n /// Asserts that a string is parsable into something else, which is implementing .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The type to what the should parsed to.\n public AndWhichConstraint BeParsableInto(string because = \"\", params object[] becauseArgs)\n where T : IParsable\n {\n return BeParsableInto(null, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string is parsable into something else, which is implementing ,\n /// with additionally respecting an , e.g. a different .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The type to what the should parsed to.\n public AndWhichConstraint BeParsableInto(IFormatProvider formatProvider, string because = \"\",\n params object[] becauseArgs)\n where T : IParsable\n {\n T parsed = default;\n var canBeParsed = true;\n string exceptionMessage = null;\n\n try\n {\n parsed = T.Parse(Subject, formatProvider);\n }\n catch (Exception ex)\n {\n canBeParsed = false;\n exceptionMessage = ex.Message.FirstCharToLower();\n }\n\n CurrentAssertionChain\n .WithExpectation(\"Expected {context:the subject} with value {0} to be parsable into {1}{reason}, \",\n Subject, typeof(T),\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(canBeParsed)\n .FailWith($\"but it could not, because {exceptionMessage}\"));\n\n return new AndWhichConstraint((TAssertions)this, parsed);\n }\n\n /// \n /// Asserts that a string isn't parsable into something else, which is implementing .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The type to what the should parsed to.\n public AndConstraint NotBeParsableInto(string because = \"\", params object[] becauseArgs)\n where T : IParsable\n {\n return NotBeParsableInto(null, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string isn't parsable into something else, which is implementing ,\n /// with additionally respecting an , e.g. a different .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The type to what the should parsed to.\n public AndConstraint NotBeParsableInto(IFormatProvider formatProvider, string because = \"\",\n params object[] becauseArgs)\n where T : IParsable\n {\n CurrentAssertionChain\n .WithExpectation(\"Expected {context:the subject} with value {0} to be not parsable into {1}{reason}, \",\n Subject, typeof(T),\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!T.TryParse(Subject, formatProvider, out _))\n .FailWith(\"but it could.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n#endif\n\n /// \n /// Asserts that a string is not exactly the same as the specified ,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is not expected to be equivalent to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint Match(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the BeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.\");\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy(),\n because, becauseArgs);\n\n stringWildcardMatchingValidator.Validate(Subject, wildcardPattern);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not match the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination literal text and wildcard of\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint NotMatch(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.\");\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n Negate = true\n },\n because, becauseArgs);\n\n stringWildcardMatchingValidator.Validate(Subject, wildcardPattern);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint MatchEquivalentOf(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the BeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.\");\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n IgnoreCase = true,\n IgnoreAllNewlines = true\n },\n because, becauseArgs);\n\n stringWildcardMatchingValidator.Validate(Subject, wildcardPattern);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches the , using the provided .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint MatchEquivalentOf(string wildcardPattern,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the BeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.\");\n\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n IgnoreCase = options.IgnoreCase,\n IgnoreNewlineStyle = options.IgnoreNewlineStyle,\n },\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n wildcardPattern = ApplyStringSettings(wildcardPattern, options);\n\n stringWildcardMatchingValidator.Validate(subject, wildcardPattern);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not match the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint NotMatchEquivalentOf(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.\");\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n IgnoreCase = true,\n IgnoreAllNewlines = true,\n Negate = true\n },\n because, becauseArgs);\n\n stringWildcardMatchingValidator.Validate(Subject, wildcardPattern);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not match the , using the provided .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint NotMatchEquivalentOf(string wildcardPattern,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.\");\n\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n IgnoreCase = options.IgnoreCase,\n IgnoreNewlineStyle = options.IgnoreNewlineStyle,\n Negate = true\n },\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n wildcardPattern = ApplyStringSettings(wildcardPattern, options);\n\n stringWildcardMatchingValidator.Validate(subject, wildcardPattern);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches a regular expression with expected occurrence\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A constraint specifying the expected amount of times a regex should match a string.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint MatchRegex([RegexPattern][StringSyntax(\"Regex\")] string regularExpression,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the BeNull method.\");\n\n Regex regex;\n\n try\n {\n regex = new Regex(regularExpression);\n }\n catch (ArgumentException)\n {\n assertionChain.FailWith(\"Cannot match {context:string} against {0} because it is not a valid regular expression.\",\n regularExpression);\n\n return new AndConstraint((TAssertions)this);\n }\n\n return MatchRegex(regex, occurrenceConstraint, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string matches a regular expression.\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint MatchRegex([RegexPattern][StringSyntax(\"Regex\")] string regularExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the BeNull method.\");\n\n Regex regex;\n\n try\n {\n regex = new Regex(regularExpression);\n }\n catch (ArgumentException)\n {\n assertionChain.FailWith(\"Cannot match {context:string} against {0} because it is not a valid regular expression.\",\n regularExpression);\n\n return new AndConstraint((TAssertions)this);\n }\n\n return MatchRegex(regex, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string matches a regular expression with expected occurrence\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A constraint specifying the expected amount of times a regex should match a string.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint MatchRegex(Regex regularExpression,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the BeNull method.\");\n\n var regexStr = regularExpression.ToString();\n\n Guard.ThrowIfArgumentIsEmpty(regexStr, nameof(regularExpression),\n \"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .UsingLineBreaks\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to match regex {0}{reason}, but it was .\", regexStr);\n\n if (assertionChain.Succeeded)\n {\n int actual = regularExpression.Matches(Subject!).Count;\n\n assertionChain\n .ForConstraint(occurrenceConstraint, actual)\n .UsingLineBreaks\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} {0} to match regex {1} {expectedOccurrence}{reason}, \" +\n $\"but found it {actual.Times()}.\",\n Subject, regexStr);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches a regular expression.\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint MatchRegex(Regex regularExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the BeNull method.\");\n\n var regexStr = regularExpression.ToString();\n\n Guard.ThrowIfArgumentIsEmpty(regexStr, nameof(regularExpression),\n \"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .UsingLineBreaks\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to match regex {0}{reason}, but it was .\", regexStr);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(regularExpression.IsMatch(Subject!))\n .BecauseOf(because, becauseArgs)\n .UsingLineBreaks\n .FailWith(\"Expected {context:string} to match regex {0}{reason}, but {1} does not match.\", regexStr, Subject);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not match a regular expression.\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotMatchRegex([RegexPattern][StringSyntax(\"Regex\")] string regularExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the NotBeNull method.\");\n\n Regex regex;\n\n try\n {\n regex = new Regex(regularExpression);\n }\n catch (ArgumentException)\n {\n assertionChain.FailWith(\"Cannot match {context:string} against {0} because it is not a valid regular expression.\",\n regularExpression);\n\n return new AndConstraint((TAssertions)this);\n }\n\n return NotMatchRegex(regex, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string does not match a regular expression.\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotMatchRegex(Regex regularExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the NotBeNull method.\");\n\n var regexStr = regularExpression.ToString();\n\n Guard.ThrowIfArgumentIsEmpty(regexStr, nameof(regularExpression),\n \"Cannot match string against an empty regex pattern. Provide a regex pattern or use the NotBeEmpty method.\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .UsingLineBreaks\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to not match regex {0}{reason}, but it was .\", regexStr);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(!regularExpression.IsMatch(Subject!))\n .BecauseOf(because, becauseArgs)\n .UsingLineBreaks\n .FailWith(\"Did not expect {context:string} to match regex {0}{reason}, but {1} matches.\", regexStr, Subject);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string starts exactly with the specified value,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is expected to start with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWith(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare start of string with .\");\n\n var stringStartValidator = new StringValidator(assertionChain,\n new StringStartStrategy(StringComparer.Ordinal, \"start with\"),\n because, becauseArgs);\n\n stringStartValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not start with the specified value,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is not expected to start with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotStartWith(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare start of string with .\");\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().StartWith(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to start with {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string starts with the specified ,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is expected to start with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWithEquivalentOf(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string start equivalence with .\");\n\n var stringStartValidator = new StringValidator(assertionChain,\n new StringStartStrategy(StringComparer.OrdinalIgnoreCase, \"start with equivalent of\"),\n because, becauseArgs);\n\n stringStartValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string starts with the specified , using the provided .\n /// \n /// The string that the subject is expected to start with.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWithEquivalentOf(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string start equivalence with .\");\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringStartValidator = new StringValidator(assertionChain,\n new StringStartStrategy(options.GetStringComparerOrDefault(), \"start with equivalent of\"),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n stringStartValidator.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not start with the specified value,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is not expected to start with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotStartWithEquivalentOf(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare start of string with .\");\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().StartWithEquivalentOf(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to start with equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not start with the specified value, using the provided .\n /// \n /// The string that the subject is not expected to start with.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotStartWithEquivalentOf(string unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare start of string with .\");\n Guard.ThrowIfArgumentIsNull(config);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().StartWithEquivalentOf(unexpected, config);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to start with equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string ends exactly with the specified ,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is expected to end with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint EndWith(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string end with .\");\n\n var stringEndValidator = new StringValidator(assertionChain,\n new StringEndStrategy(StringComparer.Ordinal, \"end with\"),\n because, becauseArgs);\n\n stringEndValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not end exactly with the specified ,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is not expected to end with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEndWith(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare end of string with .\");\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().EndWith(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to end with {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string ends with the specified ,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is expected to end with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint EndWithEquivalentOf(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string end equivalence with .\");\n\n var stringEndValidator = new StringValidator(assertionChain,\n new StringEndStrategy(StringComparer.OrdinalIgnoreCase, \"end with equivalent of\"),\n because, becauseArgs);\n\n stringEndValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string ends with the specified , using the provided .\n /// \n /// The string that the subject is expected to end with.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint EndWithEquivalentOf(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string end equivalence with .\");\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringEndValidator = new StringValidator(assertionChain,\n new StringEndStrategy(options.GetStringComparerOrDefault(), \"end with equivalent of\"),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n stringEndValidator.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not end with the specified ,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is not expected to end with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEndWithEquivalentOf(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare end of string with .\");\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().EndWithEquivalentOf(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to end with equivalent of {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not end with the specified , using the provided .\n /// \n /// The string that the subject is not expected to end with.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEndWithEquivalentOf(string unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare end of string with .\");\n Guard.ThrowIfArgumentIsNull(config);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().EndWithEquivalentOf(unexpected, config);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to end with equivalent of {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains another (fragment of a) string.\n /// \n /// \n /// The (fragment of a) string that the current string should contain.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint Contain(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n\n assertionChain\n .ForCondition(Contains(Subject, expected, StringComparison.Ordinal))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} {0} to contain {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains another (fragment of a) string a set amount of times.\n /// \n /// \n /// The (fragment of a) string that the current string should contain.\n /// \n /// \n /// A constraint specifying the amount of times a substring should be present within the test subject.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint Contain(string expected, OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n\n int actual = Subject.CountSubstring(expected, StringComparer.Ordinal);\n\n assertionChain\n .ForConstraint(occurrenceConstraint, actual)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n $\"Expected {{context:string}} {{0}} to contain {{1}} {{expectedOccurrence}}{{reason}}, but found it {actual.Times()}.\",\n Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains the specified ,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is expected to contain.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainEquivalentOf(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n\n var stringContainValidator = new StringValidatorSupportingNull(assertionChain,\n new StringContainsStrategy(StringComparer.OrdinalIgnoreCase, AtLeast.Once()),\n because, becauseArgs);\n\n stringContainValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains the specified , using the provided .\n /// \n /// The string that the subject is expected to contain.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainEquivalentOf(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return ContainEquivalentOf(expected, AtLeast.Once(), config, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string contains the specified , using the provided .\n /// \n /// The string that the subject is expected to contain.\n /// \n /// A constraint specifying the amount of times a substring should be present within the test subject.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainEquivalentOf(string expected,\n OccurrenceConstraint occurrenceConstraint,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n Guard.ThrowIfArgumentIsNull(occurrenceConstraint);\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringContainValidator = new StringValidatorSupportingNull(assertionChain,\n new StringContainsStrategy(options.GetStringComparerOrDefault(), occurrenceConstraint),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n stringContainValidator.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains the specified a set amount of times,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// \n /// The (fragment of a) string that the current string should contain.\n /// \n /// \n /// A constraint specifying the amount of times a substring should be present within the test subject.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainEquivalentOf(string expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n Guard.ThrowIfArgumentIsNull(occurrenceConstraint);\n\n var stringContainValidator = new StringValidatorSupportingNull(assertionChain,\n new StringContainsStrategy(StringComparer.OrdinalIgnoreCase, occurrenceConstraint),\n because, becauseArgs);\n\n stringContainValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains all values present in .\n /// \n /// \n /// The values that should all be present in the string\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint ContainAll(IEnumerable values,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ThrowIfValuesNullOrEmpty(values);\n\n IEnumerable missing = values.Where(v => !Contains(Subject, v, StringComparison.Ordinal));\n\n assertionChain\n .ForCondition(values.All(v => Contains(Subject, v, StringComparison.Ordinal)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} {0} to contain the strings: {1}{reason}.\", Subject, missing);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains all values present in .\n /// \n /// \n /// The values that should all be present in the string\n /// \n public AndConstraint ContainAll(params string[] values)\n {\n return ContainAll(values, because: string.Empty);\n }\n\n /// \n /// Asserts that a string contains at least one value present in ,.\n /// \n /// \n /// The values that should will be tested against the string\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint ContainAny(IEnumerable values,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ThrowIfValuesNullOrEmpty(values);\n\n assertionChain\n .ForCondition(values.Any(v => Contains(Subject, v, StringComparison.Ordinal)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} {0} to contain at least one of the strings: {1}{reason}.\", Subject, values);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains at least one value present in ,.\n /// \n /// \n /// The values that should will be tested against the string\n /// \n public AndConstraint ContainAny(params string[] values)\n {\n return ContainAny(values, because: string.Empty);\n }\n\n /// \n /// Asserts that a string does not contain another (fragment of a) string.\n /// \n /// \n /// The (fragment of a) string that the current string should not contain.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotContain(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(unexpected, nameof(unexpected), \"Cannot assert string containment against an empty string.\");\n\n assertionChain\n .ForCondition(!Contains(Subject, unexpected, StringComparison.Ordinal))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} {0} to contain {1}{reason}.\", Subject, unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not contain all of the strings provided in . The string\n /// may contain some subset of the provided values.\n /// \n /// \n /// The values that should not be present in the string\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainAll(IEnumerable values,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ThrowIfValuesNullOrEmpty(values);\n\n var matches = values.Count(v => Contains(Subject, v, StringComparison.Ordinal));\n\n assertionChain\n .ForCondition(matches != values.Count())\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} {0} to contain all of the strings: {1}{reason}.\", Subject, values);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not contain all of the strings provided in . The string\n /// may contain some subset of the provided values.\n /// \n /// \n /// The values that should not be present in the string\n /// \n public AndConstraint NotContainAll(params string[] values)\n {\n return NotContainAll(values, because: string.Empty);\n }\n\n /// \n /// Asserts that a string does not contain any of the strings provided in .\n /// \n /// \n /// The values that should not be present in the string\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainAny(IEnumerable values,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ThrowIfValuesNullOrEmpty(values);\n\n IEnumerable matches = values.Where(v => Contains(Subject, v, StringComparison.Ordinal));\n\n assertionChain\n .ForCondition(!matches.Any())\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} {0} to contain any of the strings: {1}{reason}.\", Subject, matches);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not contain any of the strings provided in .\n /// \n /// \n /// The values that should not be present in the string\n /// \n public AndConstraint NotContainAny(params string[] values)\n {\n return NotContainAny(values, because: string.Empty);\n }\n\n /// \n /// Asserts that a string does not contain the specified string,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is not expected to contain.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainEquivalentOf(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!string.IsNullOrEmpty(unexpected) && Subject != null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to contain the equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().ContainEquivalentOf(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to contain the equivalent of {0}{reason} but found {1}.\", unexpected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not contain the specified string, using the provided .\n /// \n /// The string that the subject is not expected to contain.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainEquivalentOf(string unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n assertionChain\n .ForCondition(!string.IsNullOrEmpty(unexpected) && Subject != null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to contain the equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().ContainEquivalentOf(unexpected, config);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to contain the equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject?.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to be empty{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is null || Subject.Length > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to be empty{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string has the specified length.\n /// \n /// The expected length of the string\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveLength(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:string} with length {0}{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.Length == expected)\n .FailWith(\"Expected {context:string} with length {0}{reason}, but found string {1} with length {2}.\",\n expected, Subject, Subject.Length);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is neither nor .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNullOrEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!string.IsNullOrEmpty(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be or empty{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is either or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNullOrEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(string.IsNullOrEmpty(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to be or empty{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is neither nor nor white space\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNullOrWhiteSpace([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!string.IsNullOrWhiteSpace(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be or whitespace{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is either or or white space\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNullOrWhiteSpace([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(string.IsNullOrWhiteSpace(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to be or whitespace{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that all cased characters in a string are upper-case. That is, that the string could be the result of a call to\n /// .\n /// \n /// \n /// Numbers, special characters, and many Asian characters don't have casing, so \n /// will ignore these and will fail only in the presence of lower-case characters.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeUpperCased([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null && !Subject.Any(char.IsLower))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected all alphabetic characters in {context:string} to be upper-case{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that of all the cased characters in a string, some are not upper-case. That is, the string could not be\n /// the result of a call to .\n /// \n /// \n /// Numbers, special characters, and many Asian characters don't have casing, so \n /// will ignore these and will fail only if the string contains cased characters and they are all upper-case.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeUpperCased([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is null || HasMixedOrNoCase(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected some characters in {context:string} to be lower-case{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that all cased characters in a string are lower-case. That is, that the string could be the result of a call to\n /// ,\n /// \n /// \n /// Numbers, special characters, and many Asian characters don't have casing, so \n /// will ignore these and will fail only in the presence of upper-case characters.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLowerCased([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null && !Subject.Any(char.IsUpper))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected all alphabetic characters in {context:string} to be lower cased{reason}, but found {0}.\",\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that of all the cased characters in a string, some are not lower-case. That is, the string could not be\n /// the result of a call to .\n /// \n /// \n /// Numbers, special characters, and many Asian characters don't have casing, so \n /// will ignore these and will fail only if the string contains cased characters and they are all lower-case.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeLowerCased([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is null || HasMixedOrNoCase(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected some characters in {context:string} to be upper-case{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n private static bool HasMixedOrNoCase(string value)\n {\n var hasUpperCase = false;\n var hasLowerCase = false;\n\n foreach (var ch in value)\n {\n hasUpperCase |= char.IsUpper(ch);\n hasLowerCase |= char.IsLower(ch);\n\n if (hasUpperCase && hasLowerCase)\n {\n return true;\n }\n }\n\n return !hasUpperCase && !hasLowerCase;\n }\n\n internal AndConstraint Be(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var expectation = new StringValidator(assertionChain,\n new StringEqualityStrategy(options.GetStringComparerOrDefault(), \"be\"),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n expectation.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n private static bool Contains(string actual, string expected, StringComparison comparison)\n {\n return (actual ?? string.Empty).Contains(expected ?? string.Empty, comparison);\n }\n\n private static void ThrowIfValuesNullOrEmpty(IEnumerable values)\n {\n Guard.ThrowIfArgumentIsNull(values, nameof(values), \"Cannot assert string containment of values in null collection\");\n\n if (!values.Any())\n {\n throw new ArgumentException(\"Cannot assert string containment of values in empty collection\", nameof(values));\n }\n }\n\n /// \n /// Applies the string-specific to the .\n /// \n /// \n /// When is set, whitespace is removed from the start of the .
\n /// When is set, whitespace is removed from the end of the .
\n /// When is set, all newlines (\\r\\n and \\r) are replaced with \\n in the .
\n ///
\n private static string ApplyStringSettings(string value, IEquivalencyOptions options)\n {\n if (options.IgnoreLeadingWhitespace)\n {\n value = value.TrimStart();\n }\n\n if (options.IgnoreTrailingWhitespace)\n {\n value = value.TrimEnd();\n }\n\n if (options.IgnoreNewlineStyle)\n {\n value = value.RemoveNewlineStyle();\n }\n\n return value;\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"string\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Node.cs", "using System;\nusing System.Collections;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal class Node : INode\n{\n private static readonly Regex MatchFirstIndex = new(@\"^\\[[0-9]+\\]$\");\n\n private GetSubjectId subjectIdProvider;\n\n private string cachedSubjectId;\n private Pathway subject;\n\n public GetSubjectId GetSubjectId\n {\n get => () => cachedSubjectId ??= subjectIdProvider();\n protected init => subjectIdProvider = value;\n }\n\n public Type Type { get; protected set; }\n\n public Type ParentType { get; protected set; }\n\n public Pathway Subject\n {\n get => subject;\n set\n {\n subject = value;\n\n if (Expectation is null)\n {\n Expectation = value;\n }\n }\n }\n\n public Pathway Expectation { get; protected set; }\n\n public bool IsRoot\n {\n get\n {\n // If the root is a collection, we need treat the objects in that collection as the root of the graph because all options\n // refer to the type of the collection items.\n return Subject.PathAndName.Length == 0 || (RootIsCollection && IsFirstIndex);\n }\n }\n\n private bool IsFirstIndex => MatchFirstIndex.IsMatch(Subject.PathAndName);\n\n public bool RootIsCollection { get; protected set; }\n\n public void AdjustForRemappedSubject(IMember subjectMember)\n {\n if (subject.Name != subjectMember.Subject.Name)\n {\n subject.Name = subjectMember.Subject.Name;\n }\n }\n\n public int Depth\n {\n get\n {\n const char memberSeparator = '.';\n return Subject.PathAndName.Count(chr => chr == memberSeparator);\n }\n }\n\n private static bool IsCollection(Type type)\n {\n return !typeof(string).IsAssignableFrom(type) && typeof(IEnumerable).IsAssignableFrom(type);\n }\n\n public static INode From(GetSubjectId getSubjectId)\n {\n return new Node\n {\n subjectIdProvider = () => getSubjectId() ?? \"root\",\n Subject = new Pathway(string.Empty, string.Empty, _ => getSubjectId()),\n Type = typeof(T),\n ParentType = null,\n RootIsCollection = IsCollection(typeof(T))\n };\n }\n\n public static INode FromCollectionItem(string index, INode parent)\n {\n Pathway.GetDescription getDescription = pathAndName => parent.GetSubjectId().Combine(pathAndName);\n\n string itemName = \"[\" + index + \"]\";\n\n return new Node\n {\n Type = typeof(T),\n ParentType = parent.Type,\n Subject = new Pathway(parent.Subject, itemName, getDescription),\n Expectation = new Pathway(parent.Expectation, itemName, getDescription),\n GetSubjectId = parent.GetSubjectId,\n RootIsCollection = parent.RootIsCollection\n };\n }\n\n public static INode FromDictionaryItem(object key, INode parent)\n {\n Pathway.GetDescription getDescription = pathAndName => parent.GetSubjectId().Combine(pathAndName);\n\n string itemName = \"[\" + key + \"]\";\n\n return new Node\n {\n Type = typeof(T),\n ParentType = parent.Type,\n Subject = new Pathway(parent.Subject, itemName, getDescription),\n Expectation = new Pathway(parent.Expectation, itemName, getDescription),\n GetSubjectId = parent.GetSubjectId,\n RootIsCollection = parent.RootIsCollection\n };\n }\n\n public override bool Equals(object obj)\n {\n if (obj is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n if (obj.GetType() != GetType())\n {\n return false;\n }\n\n return Equals((Node)obj);\n }\n\n private bool Equals(Node other) => (Type, Subject.Name, Subject.Path) == (other.Type, other.Subject.Name, other.Subject.Path);\n\n public override int GetHashCode()\n {\n unchecked\n {\n#pragma warning disable CA1307\n int hashCode = Type.GetHashCode();\n hashCode = (hashCode * 397) + Subject.Path.GetHashCode();\n hashCode = (hashCode * 397) + Subject.Name.GetHashCode();\n return hashCode;\n }\n }\n\n public override string ToString() => Subject.Description;\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/XmlSpecs.cs", "using System;\nusing System.Xml.Linq;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class XmlSpecs\n{\n [Fact]\n public void\n When_asserting_a_xml_selfclosing_document_is_equivalent_to_a_different_xml_document_with_same_structure_it_should_succeed()\n {\n // Arrange\n var subject = new\n {\n Document = XDocument.Parse(\"\")\n };\n\n var expectation = new\n {\n Document = XDocument.Parse(\"\")\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equivalent_to_a_xml_document_with_elements_missing_it_should_fail()\n {\n var subject = new\n {\n Document = XDocument.Parse(\"\")\n };\n\n var expectation = new\n {\n Document = XDocument.Parse(\"\")\n };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in property subject.Document at \\\"/parent\\\", but found Element \\\"child2\\\".*\");\n }\n\n [Fact]\n public void When_xml_elements_are_equivalent_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Element = XElement.Parse(\"\")\n };\n\n var expectation = new\n {\n Element = XElement.Parse(\"\")\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_an_xml_element_property_is_equivalent_to_an_xml_element_with_elements_missing_it_should_fail()\n {\n // Arrange\n var subject = new\n {\n Element = XElement.Parse(\"\")\n };\n\n var expectation = new\n {\n Element = XElement.Parse(\"\")\n };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in property subject.Element at \\\"/parent\\\", but found Element \\\"child2\\\"*\");\n }\n\n [Fact]\n public void When_asserting_an_xml_attribute_is_equal_to_the_same_xml_attribute_it_should_succeed()\n {\n var subject = new\n {\n Attribute = new XAttribute(\"name\", \"value\")\n };\n\n var expectation = new\n {\n Attribute = new XAttribute(\"name\", \"value\")\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_asserting_an_xml_attribute_is_equal_to_a_different_xml_attribute_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var subject = new\n {\n Attribute = new XAttribute(\"name\", \"value\")\n };\n\n var expectation = new\n {\n Attribute = new XAttribute(\"name2\", \"value\")\n };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expectation, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected property subject.Attribute to be name2=\\\"value\\\" because we want to test the failure message, but found name=\\\"value\\\"*\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/CyclicReferencesSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class CyclicReferencesSpecs\n{\n [Fact]\n public void Graphs_up_to_the_maximum_depth_are_supported()\n {\n // Arrange\n var actual = new ClassWithFiniteRecursiveProperty(recursiveDepth: 10);\n var expectation = new ClassWithFiniteRecursiveProperty(recursiveDepth: 10);\n\n // Act/Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Graphs_deeper_than_the_maximum_depth_are_not_supported()\n {\n // Arrange\n var actual = new ClassWithFiniteRecursiveProperty(recursiveDepth: 11);\n var expectation = new ClassWithFiniteRecursiveProperty(recursiveDepth: 11);\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\"*maximum*depth*10*\");\n }\n\n [Fact]\n public void By_default_cyclic_references_are_not_valid()\n {\n // Arrange\n var cyclicRoot = new CyclicRoot\n {\n Text = \"Root\"\n };\n\n cyclicRoot.Level = new CyclicLevel1\n {\n Text = \"Level1\",\n Root = cyclicRoot\n };\n\n var cyclicRootDto = new CyclicRootDto\n {\n Text = \"Root\"\n };\n\n cyclicRootDto.Level = new CyclicLevel1Dto\n {\n Text = \"Level1\",\n Root = cyclicRootDto\n };\n\n // Act\n Action act = () => cyclicRoot.Should().BeEquivalentTo(cyclicRootDto);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected property cyclicRoot.Level.Root to be*but it contains a cyclic reference*\");\n }\n\n [Fact]\n public void The_cyclic_reference_itself_will_be_compared_using_simple_equality()\n {\n // Arrange\n var expectedChild = new Child\n {\n Stuff = 1\n };\n\n var expectedParent = new Parent\n {\n Child1 = expectedChild\n };\n\n expectedChild.Parent = expectedParent;\n\n var actualChild = new Child\n {\n Stuff = 1\n };\n\n var actualParent = new Parent\n {\n Child1 = actualChild\n };\n\n // Act\n var act = () => actualParent.Should().BeEquivalentTo(expectedParent, options => options.IgnoringCyclicReferences());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property actualParent.Child1.Parent to refer to*but found*null*\");\n }\n\n [Fact]\n public void The_cyclic_reference_can_be_ignored_if_the_comparands_point_to_the_same_object()\n {\n // Arrange\n var expectedChild = new Child\n {\n Stuff = 1\n };\n\n var expectedParent = new Parent\n {\n Child1 = expectedChild\n };\n\n expectedChild.Parent = expectedParent;\n\n var actualChild = new Child\n {\n Stuff = 1\n };\n\n var actualParent = new Parent\n {\n Child1 = actualChild\n };\n\n // Connect this child to the same parent as the expectation child\n actualChild.Parent = expectedParent;\n\n // Act\n actualParent.Should().BeEquivalentTo(expectedParent, options => options.IgnoringCyclicReferences());\n }\n\n [Fact]\n public void Two_graphs_with_ignored_cyclic_references_can_be_compared()\n {\n // Arrange\n var actual = new Parent();\n actual.Child1 = new Child(actual, 1);\n actual.Child2 = new Child(actual);\n\n var expected = new Parent();\n expected.Child1 = new Child(expected);\n expected.Child2 = new Child(expected);\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, x => x\n .Excluding(y => y.Child1)\n .IgnoringCyclicReferences());\n }\n\n private class Parent\n {\n public Child Child1 { get; set; }\n\n [UsedImplicitly]\n public Child Child2 { get; set; }\n }\n\n private class Child\n {\n public Child(Parent parent = null, int stuff = 0)\n {\n Parent = parent;\n Stuff = stuff;\n }\n\n [UsedImplicitly]\n public Parent Parent { get; set; }\n\n [UsedImplicitly]\n public int Stuff { get; set; }\n }\n\n [Fact]\n public void Nested_properties_that_are_null_are_not_treated_as_cyclic_references()\n {\n // Arrange\n var actual = new CyclicRoot\n {\n Text = null,\n Level = new CyclicLevel1\n {\n Text = null,\n Root = null\n }\n };\n\n var expectation = new CyclicRootDto\n {\n Text = null,\n Level = new CyclicLevel1Dto\n {\n Text = null,\n Root = null\n }\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Equivalent_value_objects_are_not_treated_as_cyclic_references()\n {\n // Arrange\n var actual = new CyclicRootWithValueObject\n {\n Value = new ValueObject(\"MyValue\"),\n Level = new CyclicLevelWithValueObject\n {\n Value = new ValueObject(\"MyValue\"),\n Root = null\n }\n };\n\n var expectation = new CyclicRootWithValueObject\n {\n Value = new ValueObject(\"MyValue\"),\n Level = new CyclicLevelWithValueObject\n {\n Value = new ValueObject(\"MyValue\"),\n Root = null\n }\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Cyclic_references_do_not_trigger_stack_overflows()\n {\n // Arrange\n var recursiveClass1 = new ClassWithInfinitelyRecursiveProperty();\n var recursiveClass2 = new ClassWithInfinitelyRecursiveProperty();\n\n // Act\n Action act =\n () => recursiveClass1.Should().BeEquivalentTo(recursiveClass2);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Cyclic_references_can_be_ignored_in_equivalency_assertions()\n {\n // Arrange\n var recursiveClass1 = new ClassWithFiniteRecursiveProperty(15);\n var recursiveClass2 = new ClassWithFiniteRecursiveProperty(15);\n\n // Act / Assert\n recursiveClass1.Should().BeEquivalentTo(recursiveClass2, options => options.AllowingInfiniteRecursion());\n }\n\n [Fact]\n public void Allowing_infinite_recursion_is_reported_in_the_failure_message()\n {\n // Arrange\n var recursiveClass1 = new ClassWithFiniteRecursiveProperty(1);\n var recursiveClass2 = new ClassWithFiniteRecursiveProperty(2);\n\n // Act\n Action act = () => recursiveClass1.Should().BeEquivalentTo(recursiveClass2,\n options => options.AllowingInfiniteRecursion());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Recurse indefinitely*\");\n }\n\n [Fact]\n public void Can_ignore_cyclic_references_for_inequivalency_assertions()\n {\n // Arrange\n var recursiveClass1 = new ClassWithFiniteRecursiveProperty(15);\n var recursiveClass2 = new ClassWithFiniteRecursiveProperty(16);\n\n // Act / Assert\n recursiveClass1.Should().NotBeEquivalentTo(recursiveClass2,\n options => options.AllowingInfiniteRecursion());\n }\n\n [Fact]\n public void Can_detect_cyclic_references_in_enumerables()\n {\n // Act\n var instance1 = new SelfReturningEnumerable();\n var instance2 = new SelfReturningEnumerable();\n\n var actual = new List\n {\n instance1,\n instance2\n };\n\n // Assert\n Action act = () => actual.Should().BeEquivalentTo(\n [new SelfReturningEnumerable(), new SelfReturningEnumerable()],\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*we want to test the failure message*cyclic reference*\");\n }\n\n public class SelfReturningEnumerable : IEnumerable\n {\n public IEnumerator GetEnumerator()\n {\n yield return this;\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n }\n\n [Fact]\n public void Can_detect_cyclic_references_in_nested_objects_referring_to_the_root()\n {\n // Arrange\n var company1 = new MyCompany\n {\n Name = \"Company\"\n };\n\n var user1 = new MyUser\n {\n Name = \"User\",\n Company = company1\n };\n\n var logo1 = new MyCompanyLogo\n {\n Url = \"blank\",\n Company = company1,\n CreatedBy = user1\n };\n\n company1.Logo = logo1;\n\n var company2 = new MyCompany\n {\n Name = \"Company\"\n };\n\n var user2 = new MyUser\n {\n Name = \"User\",\n Company = company2\n };\n\n var logo2 = new MyCompanyLogo\n {\n Url = \"blank\",\n Company = company2,\n CreatedBy = user2\n };\n\n company2.Logo = logo2;\n\n // Act / Assert\n company1.Should().BeEquivalentTo(company2, o => o.IgnoringCyclicReferences());\n }\n\n [Fact]\n public void Allow_ignoring_cyclic_references_in_value_types_compared_by_members()\n {\n // Arrange\n var expectation = new ValueTypeCircularDependency\n {\n Title = \"First\"\n };\n\n var second = new ValueTypeCircularDependency\n {\n Title = \"Second\",\n Previous = expectation\n };\n\n expectation.Next = second;\n\n var subject = new ValueTypeCircularDependency\n {\n Title = \"First\"\n };\n\n var secondCopy = new ValueTypeCircularDependency\n {\n Title = \"SecondDifferent\",\n Previous = subject\n };\n\n subject.Next = secondCopy;\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .ComparingByMembers()\n .IgnoringCyclicReferences());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*subject.Next.Title*SecondDifferent*Second*\")\n .Which.Message.Should().NotContain(\"maximum recursion depth was reached\");\n }\n\n private class ValueTypeCircularDependency\n {\n public string Title { get; set; }\n\n public ValueTypeCircularDependency Previous { get; set; }\n\n public ValueTypeCircularDependency Next { get; set; }\n\n public override bool Equals(object obj)\n {\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n return obj is ValueTypeCircularDependency baseObj && baseObj.Title == Title;\n }\n\n public override int GetHashCode()\n {\n return Title.GetHashCode();\n }\n }\n\n private class ClassWithInfinitelyRecursiveProperty\n {\n public ClassWithInfinitelyRecursiveProperty Self\n {\n get { return new ClassWithInfinitelyRecursiveProperty(); }\n }\n }\n\n private class ClassWithFiniteRecursiveProperty\n {\n private readonly int depth;\n\n public ClassWithFiniteRecursiveProperty(int recursiveDepth)\n {\n depth = recursiveDepth;\n }\n\n public ClassWithFiniteRecursiveProperty Self\n {\n get\n {\n return depth > 0\n ? new ClassWithFiniteRecursiveProperty(depth - 1)\n : null;\n }\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Property.cs", "using System;\nusing System.ComponentModel;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// A specialized type of that represents a property of an object in a structural equivalency assertion.\n/// \n#pragma warning disable CA1716\ninternal class Property : Node, IMember\n{\n private readonly PropertyInfo propertyInfo;\n private bool? isBrowsable;\n\n public Property(PropertyInfo propertyInfo, INode parent)\n : this(propertyInfo.ReflectedType, propertyInfo, parent)\n {\n }\n\n public Property(Type reflectedType, PropertyInfo propertyInfo, INode parent)\n {\n ReflectedType = reflectedType;\n this.propertyInfo = propertyInfo;\n DeclaringType = propertyInfo.DeclaringType;\n Subject = new Pathway(parent.Subject.PathAndName, propertyInfo.Name, pathAndName => $\"property {parent.GetSubjectId().Combine(pathAndName)}\");\n Expectation = new Pathway(parent.Expectation.PathAndName, propertyInfo.Name, pathAndName => $\"property {pathAndName}\");\n Type = propertyInfo.PropertyType;\n ParentType = propertyInfo.DeclaringType;\n GetSubjectId = parent.GetSubjectId;\n RootIsCollection = parent.RootIsCollection;\n }\n\n public object GetValue(object obj)\n {\n return propertyInfo.GetValue(obj);\n }\n\n public Type DeclaringType { get; }\n\n public Type ReflectedType { get; }\n\n public CSharpAccessModifier GetterAccessibility => propertyInfo.GetGetMethod(nonPublic: true).GetCSharpAccessModifier();\n\n public CSharpAccessModifier SetterAccessibility => propertyInfo.GetSetMethod(nonPublic: true).GetCSharpAccessModifier();\n\n public bool IsBrowsable\n {\n get\n {\n isBrowsable ??=\n propertyInfo.GetCustomAttribute() is not { State: EditorBrowsableState.Never };\n\n return isBrowsable.Value;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/GenericDictionaryAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Collections;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class GenericDictionaryAssertions\n : GenericDictionaryAssertions>\n where TCollection : IEnumerable>\n{\n public GenericDictionaryAssertions(TCollection keyValuePairs, AssertionChain assertionChain)\n : base(keyValuePairs, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class GenericDictionaryAssertions\n : GenericCollectionAssertions, TAssertions>\n where TCollection : IEnumerable>\n where TAssertions : GenericDictionaryAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public GenericDictionaryAssertions(TCollection keyValuePairs, AssertionChain assertionChain)\n : base(keyValuePairs, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n #region Equal\n\n /// \n /// Asserts that the current dictionary contains all the same key-value pairs as the\n /// specified dictionary. Keys and values are compared using\n /// their implementation.\n /// \n /// The expected dictionary\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Equal(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : IEnumerable>\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare dictionary with .\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to be equal to {0}{reason}, but found {1}.\", expected, Subject);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable subjectKeys = GetKeys(Subject);\n IEnumerable expectedKeys = GetKeys(expected);\n IEnumerable missingKeys = expectedKeys.Except(subjectKeys);\n IEnumerable additionalKeys = subjectKeys.Except(expectedKeys);\n\n if (missingKeys.Any())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to be equal to {0}{reason}, but could not find keys {1}.\", expected,\n missingKeys);\n }\n\n if (additionalKeys.Any())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to be equal to {0}{reason}, but found additional keys {1}.\",\n expected,\n additionalKeys);\n }\n\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n foreach (var key in expectedKeys)\n {\n assertionChain\n .ForCondition(areSameOrEqual(GetValue(Subject, key), GetValue(expected, key)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to be equal to {0}{reason}, but {1} differs at key {2}.\",\n expected, Subject, key);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts the current dictionary not to contain all the same key-value pairs as the\n /// specified dictionary. Keys and values are compared using\n /// their implementation.\n /// \n /// The unexpected dictionary\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEqual(T unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : IEnumerable>\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare dictionary with .\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected dictionaries not to be equal{reason}, but found {0}.\", Subject);\n\n if (assertionChain.Succeeded)\n {\n if (ReferenceEquals(Subject, unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected dictionaries not to be equal{reason}, but they both reference the same object.\");\n }\n\n IEnumerable subjectKeys = GetKeys(Subject);\n IEnumerable unexpectedKeys = GetKeys(unexpected);\n IEnumerable missingKeys = unexpectedKeys.Except(subjectKeys);\n IEnumerable additionalKeys = subjectKeys.Except(unexpectedKeys);\n\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n bool foundDifference = missingKeys.Any()\n || additionalKeys.Any()\n || subjectKeys.Any(key => !areSameOrEqual(GetValue(Subject, key), GetValue(unexpected, key)));\n\n if (!foundDifference)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect dictionaries {0} and {1} to be equal{reason}.\", unexpected, Subject);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n /// \n /// Asserts that two dictionaries are equivalent.\n /// \n /// \n /// The values within the dictionaries are equivalent when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of the values in the dictionaries are ignored as long as both dictionaries contain the same keys and\n /// the values for each key are structurally equivalent. Notice that actual behavior is determined by the global\n /// defaults managed by the class.\n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, options => options, because, becauseArgs);\n }\n\n /// \n /// Asserts that two dictionaries are equivalent.\n /// \n /// \n /// The values within the dictionaries are equivalent when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of the values in the dictionaries are ignored as long as both dictionaries contain the same keys and\n /// the values for each key are structurally equivalent. Notice that actual behavior is determined by the global\n /// defaults managed by the class.\n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(TExpectation expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var context =\n new EquivalencyValidationContext(Node.From(() => CurrentAssertionChain.CallerIdentifier), options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n #region ContainKey\n\n /// \n /// Asserts that the dictionary contains the specified key.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The expected key\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public WhoseValueConstraint ContainKey(TKey expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n AndConstraint andConstraint = ContainKeys([expected], because, becauseArgs);\n\n _ = TryGetValue(Subject, expected, out TValue value);\n\n return new WhoseValueConstraint(andConstraint.And, value);\n }\n\n /// \n /// Asserts that the dictionary contains all of the specified keys.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The expected keys\n public AndConstraint ContainKeys(params TKey[] expected)\n {\n return ContainKeys(expected, string.Empty);\n }\n\n /// \n /// Asserts that the dictionary contains all of the specified keys.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The expected keys\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainKeys(IEnumerable expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot verify key containment against a collection of keys\");\n\n ICollection expectedKeys = expected.ConvertOrCastToCollection();\n Guard.ThrowIfArgumentIsEmpty(expectedKeys, nameof(expected), \"Cannot verify key containment against an empty sequence\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain keys {0}{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable missingKeys = expectedKeys.Where(key => !ContainsKey(Subject, key));\n\n if (missingKeys.Any())\n {\n if (expectedKeys.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to contain keys {1}{reason}, but could not find {2}.\",\n Subject,\n expected, missingKeys);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to contain key {1}{reason}.\", Subject,\n expected.First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region NotContainKey\n\n /// \n /// Asserts that the current dictionary does not contain the specified key.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The unexpected key\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainKey(TKey unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} not to contain key {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded && ContainsKey(Subject, unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} not to contain key {1}{reason}, but found it anyhow.\", Subject,\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the dictionary does not contain any of the specified keys.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The unexpected keys\n public AndConstraint NotContainKeys(params TKey[] unexpected)\n {\n return NotContainKeys(unexpected, string.Empty);\n }\n\n /// \n /// Asserts that the dictionary does not contain any of the specified keys.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The unexpected keys\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotContainKeys(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected),\n \"Cannot verify key containment against a collection of keys\");\n\n ICollection unexpectedKeys = unexpected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(unexpectedKeys, nameof(unexpected),\n \"Cannot verify key containment against an empty sequence\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to not contain keys {0}{reason}, but found .\", unexpectedKeys);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable foundKeys = unexpectedKeys.Where(key => ContainsKey(Subject, key));\n\n if (foundKeys.Any())\n {\n if (unexpectedKeys.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to not contain keys {1}{reason}, but found {2}.\", Subject,\n unexpectedKeys, foundKeys);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to not contain key {1}{reason}.\", Subject,\n unexpectedKeys.First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region ContainValue\n\n /// \n /// Asserts that the dictionary contains the specified value. Values are compared using\n /// their implementation.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint ContainValue(TValue expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n AndWhichConstraint> result =\n ContainValues([expected], because, becauseArgs);\n\n return new AndWhichConstraint(result.And, result.Subject);\n }\n\n /// \n /// Asserts that the dictionary contains all of the specified values. Values are compared using\n /// their implementation.\n /// \n /// The expected values\n public AndWhichConstraint> ContainValues(params TValue[] expected)\n {\n return ContainValues(expected, string.Empty);\n }\n\n /// \n /// Asserts that the dictionary contains all the specified values. Values are compared using\n /// their implementation.\n /// \n /// The expected values\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint> ContainValues(IEnumerable expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot verify value containment against a collection of values\");\n\n ICollection expectedValues = expected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(expectedValues, nameof(expected),\n \"Cannot verify value containment against an empty sequence\");\n\n var missingValues = new List(expectedValues);\n\n Dictionary matches = new();\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain values {0}{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n foreach (var pair in Subject!)\n {\n if (missingValues.Contains(pair.Value))\n {\n matches.Add(pair.Key, pair.Value);\n missingValues.Remove(pair.Value);\n }\n }\n\n if (missingValues.Count > 0)\n {\n if (expectedValues.Count == 1)\n {\n assertionChain.FailWith(\n \"Expected {context:dictionary} {0} to contain value {1}{reason}.\",\n Subject, expectedValues.Single());\n }\n else\n {\n assertionChain.FailWith(\n \"Expected {context:dictionary} {0} to contain values {1}{reason}, but could not find {2}.\",\n Subject, expectedValues, missingValues.Count == 1 ? missingValues.Single() : missingValues);\n }\n }\n }\n\n string postfix = matches.Count > 0 ? \"[\" + string.Join(\" and \", matches.Keys) + \"]\" : \"\";\n\n return new AndWhichConstraint>((TAssertions)this, matches.Values, assertionChain, postfix);\n }\n\n #endregion\n\n #region NotContainValue\n\n /// \n /// Asserts that the current dictionary does not contain the specified value.\n /// Values are compared using their implementation.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainValue(TValue unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} not to contain value {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded && GetValues(Subject).Contains(unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} not to contain value {1}{reason}, but found it anyhow.\", Subject,\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the dictionary does not contain any of the specified values. Values are compared using\n /// their implementation.\n /// \n /// The unexpected values\n public AndConstraint NotContainValues(params TValue[] unexpected)\n {\n return NotContainValues(unexpected, string.Empty);\n }\n\n /// \n /// Asserts that the dictionary does not contain any of the specified values. Values are compared using\n /// their implementation.\n /// \n /// The unexpected values\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotContainValues(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected),\n \"Cannot verify value containment against a collection of values\");\n\n ICollection unexpectedValues = unexpected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(unexpectedValues, nameof(unexpected),\n \"Cannot verify value containment with an empty sequence\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to not contain values {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable foundValues = unexpectedValues.Intersect(GetValues(Subject));\n\n if (foundValues.Any())\n {\n if (unexpectedValues.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to not contain value {1}{reason}, but found {2}.\",\n Subject,\n unexpected, foundValues);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to not contain value {1}{reason}.\", Subject,\n unexpected.First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region Contain\n\n /// \n /// Asserts that the current dictionary contains the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The expected key/value pairs.\n public AndConstraint Contain(params KeyValuePair[] expected)\n {\n return Contain(expected, string.Empty);\n }\n\n /// \n /// Asserts that the current dictionary contains the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The expected key/value pairs.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\", Justification = \"Needs refactoring\")]\n public new AndConstraint Contain(IEnumerable> expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare dictionary with .\");\n\n ICollection> expectedKeyValuePairs = expected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(expectedKeyValuePairs, nameof(expected),\n \"Cannot verify key containment against an empty collection of key/value pairs\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain key/value pairs {0}{reason}, but dictionary is .\",\n expected);\n\n if (assertionChain.Succeeded)\n {\n TKey[] expectedKeys = expectedKeyValuePairs.Select(keyValuePair => keyValuePair.Key).ToArray();\n IEnumerable missingKeys = expectedKeys.Where(key => !ContainsKey(Subject, key));\n\n if (missingKeys.Any())\n {\n if (expectedKeyValuePairs.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to contain key(s) {1}{reason}, but could not find keys {2}.\",\n Subject,\n expectedKeys, missingKeys);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to contain key {1}{reason}.\", Subject,\n expectedKeys[0]);\n }\n }\n\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n KeyValuePair[] keyValuePairsNotSameOrEqualInSubject = expectedKeyValuePairs\n .Where(keyValuePair => !areSameOrEqual(GetValue(Subject, keyValuePair.Key), keyValuePair.Value)).ToArray();\n\n if (keyValuePairsNotSameOrEqualInSubject.Length > 0)\n {\n if (keyValuePairsNotSameOrEqualInSubject.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:dictionary} to contain {0}{reason}, but {context:dictionary} differs at keys {1}.\",\n expectedKeyValuePairs, keyValuePairsNotSameOrEqualInSubject.Select(keyValuePair => keyValuePair.Key));\n }\n else\n {\n KeyValuePair expectedKeyValuePair = keyValuePairsNotSameOrEqualInSubject[0];\n TValue actual = GetValue(Subject, expectedKeyValuePair.Key);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain value {0} at key {1}{reason}, but found {2}.\",\n expectedKeyValuePair.Value, expectedKeyValuePair.Key, actual);\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current dictionary contains the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The expected \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public new AndConstraint Contain(KeyValuePair expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return Contain(expected.Key, expected.Value, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current dictionary contains the specified for the supplied\n /// .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The key for which to validate the value\n /// The value to validate\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Contain(TKey key, TValue value,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain value {0} at key {1}{reason}, but dictionary is .\",\n value, key);\n\n if (assertionChain.Succeeded)\n {\n if (TryGetValue(Subject, key, out TValue actual))\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n assertionChain\n .ForCondition(areSameOrEqual(actual, value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain value {0} at key {1}{reason}, but found {2}.\", value, key,\n actual);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain value {0} at key {1}{reason}, but the key was not found.\",\n value,\n key);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region NotContain\n\n /// \n /// Asserts that the current dictionary does not contain the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The unexpected key/value pairs\n public AndConstraint NotContain(params KeyValuePair[] items)\n {\n return NotContain(items, string.Empty);\n }\n\n /// \n /// Asserts that the current dictionary does not contain the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The unexpected key/value pairs\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public new AndConstraint NotContain(IEnumerable> items,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(items, nameof(items), \"Cannot compare dictionary with .\");\n\n ICollection> keyValuePairs = items.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(keyValuePairs, nameof(items),\n \"Cannot verify key containment against an empty collection of key/value pairs\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to not contain key/value pairs {0}{reason}, but dictionary is .\",\n items);\n\n if (assertionChain.Succeeded)\n {\n KeyValuePair[] keyValuePairsFound =\n keyValuePairs.Where(keyValuePair => ContainsKey(Subject, keyValuePair.Key)).ToArray();\n\n if (keyValuePairsFound.Length > 0)\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n KeyValuePair[] keyValuePairsSameOrEqualInSubject = keyValuePairsFound\n .Where(keyValuePair => areSameOrEqual(GetValue(Subject, keyValuePair.Key), keyValuePair.Value)).ToArray();\n\n if (keyValuePairsSameOrEqualInSubject.Length > 0)\n {\n if (keyValuePairsSameOrEqualInSubject.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:dictionary} to not contain key/value pairs {0}{reason}, but found them anyhow.\",\n keyValuePairs);\n }\n else\n {\n KeyValuePair keyValuePair = keyValuePairsSameOrEqualInSubject[0];\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:dictionary} to not contain value {0} at key {1}{reason}, but found it anyhow.\",\n keyValuePair.Value, keyValuePair.Key);\n }\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current dictionary does not contain the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The unexpected \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public new AndConstraint NotContain(KeyValuePair item,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotContain(item.Key, item.Value, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current dictionary does not contain the specified for the\n /// supplied .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The key for which to validate the value\n /// The value to validate\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContain(TKey key, TValue value,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} not to contain value {0} at key {1}{reason}, but dictionary is .\",\n value, key);\n\n if (assertionChain.Succeeded && TryGetValue(Subject, key, out TValue actual))\n {\n assertionChain\n .ForCondition(!ObjectExtensions.GetComparer()(actual, value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} not to contain value {0} at key {1}{reason}, but found it anyhow.\",\n value, key);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"dictionary\";\n\n private static IEnumerable GetKeys(TCollection collection) =>\n collection.GetKeys();\n\n private static IEnumerable GetKeys(T collection)\n where T : IEnumerable> =>\n collection.GetKeys();\n\n private static IEnumerable GetValues(TCollection collection) =>\n collection.GetValues();\n\n private static bool ContainsKey(TCollection collection, TKey key) =>\n collection.ContainsKey(key);\n\n private static bool TryGetValue(TCollection collection, TKey key, out TValue value) =>\n collection.TryGetValue(key, out value);\n\n private static TValue GetValue(TCollection collection, TKey key) =>\n collection.GetValue(key);\n\n private static TValue GetValue(T collection, TKey key)\n where T : IEnumerable> =>\n collection.GetValue(key);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Field.cs", "using System;\nusing System.ComponentModel;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// A specialized type of that represents a field of an object in a structural equivalency assertion.\n/// \ninternal class Field : Node, IMember\n{\n private readonly FieldInfo fieldInfo;\n private bool? isBrowsable;\n\n public Field(FieldInfo fieldInfo, INode parent)\n {\n this.fieldInfo = fieldInfo;\n DeclaringType = fieldInfo.DeclaringType;\n ReflectedType = fieldInfo.ReflectedType;\n Subject = new Pathway(parent.Subject.PathAndName, fieldInfo.Name, pathAndName => $\"field {parent.GetSubjectId().Combine(pathAndName)}\");\n Expectation = new Pathway(parent.Expectation.PathAndName, fieldInfo.Name, pathAndName => $\"field {pathAndName}\");\n GetSubjectId = parent.GetSubjectId;\n Type = fieldInfo.FieldType;\n ParentType = fieldInfo.DeclaringType;\n RootIsCollection = parent.RootIsCollection;\n }\n\n public Type ReflectedType { get; }\n\n public object GetValue(object obj)\n {\n return fieldInfo.GetValue(obj);\n }\n\n public Type DeclaringType { get; set; }\n\n public CSharpAccessModifier GetterAccessibility => fieldInfo.GetCSharpAccessModifier();\n\n public CSharpAccessModifier SetterAccessibility => fieldInfo.GetCSharpAccessModifier();\n\n public bool IsBrowsable =>\n isBrowsable ??= fieldInfo.GetCustomAttribute() is not { State: EditorBrowsableState.Never };\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/Formatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Xml;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Provides services for formatting an object being used in an assertion in a human-readable format.\n/// \npublic static class Formatter\n{\n #region Private Definitions\n\n private static readonly List CustomFormatters = [];\n\n private static readonly List DefaultFormatters =\n [\n new XmlReaderValueFormatter(),\n new XmlNodeFormatter(),\n new AttributeBasedFormatter(),\n new AggregateExceptionValueFormatter(),\n new XDocumentValueFormatter(),\n new XElementValueFormatter(),\n new XAttributeValueFormatter(),\n new PropertyInfoFormatter(),\n new MethodInfoFormatter(),\n new NullValueFormatter(),\n new GuidValueFormatter(),\n new DateTimeOffsetValueFormatter(),\n#if NET6_0_OR_GREATER\n new DateOnlyValueFormatter(),\n new TimeOnlyValueFormatter(),\n#endif\n new TimeSpanValueFormatter(),\n new Int32ValueFormatter(),\n new Int64ValueFormatter(),\n new DoubleValueFormatter(),\n new SingleValueFormatter(),\n new DecimalValueFormatter(),\n new ByteValueFormatter(),\n new UInt32ValueFormatter(),\n new UInt64ValueFormatter(),\n new Int16ValueFormatter(),\n new UInt16ValueFormatter(),\n new SByteValueFormatter(),\n new StringValueFormatter(),\n new TaskFormatter(),\n new PredicateLambdaExpressionValueFormatter(),\n new ExpressionValueFormatter(),\n new ExceptionValueFormatter(),\n new MultidimensionalArrayFormatter(),\n new DictionaryValueFormatter(),\n new EnumerableValueFormatter(),\n new EnumValueFormatter(),\n new TypeValueFormatter(),\n new DefaultValueFormatter(),\n ];\n\n /// \n /// Is used to detect recursive calls by implementations.\n /// \n [ThreadStatic]\n private static bool isReentry;\n\n #endregion\n\n /// \n /// A list of objects responsible for formatting the objects represented by placeholders.\n /// \n public static IEnumerable Formatters =>\n AssertionScope.Current.FormattingOptions.ScopedFormatters\n .Concat(CustomFormatters)\n .Concat(DefaultFormatters);\n\n /// \n /// Returns a human-readable representation of a particular object.\n /// \n /// The value for which to create a .\n /// \n /// Indicates whether the formatter should use line breaks when the specific supports it.\n /// \n /// \n /// A that represents this instance.\n /// \n public static string ToString(object value, FormattingOptions options = null)\n {\n options ??= new FormattingOptions();\n\n try\n {\n if (isReentry)\n {\n throw new InvalidOperationException(\n $\"Use the {nameof(FormatChild)} delegate inside a {nameof(IValueFormatter)} to recursively format children\");\n }\n\n isReentry = true;\n\n var graph = new ObjectGraph(value);\n\n var context = new FormattingContext\n {\n UseLineBreaks = options.UseLineBreaks\n };\n\n FormattedObjectGraph output = new(options.MaxLines);\n\n try\n {\n Format(value, output, context,\n (path, childValue, childOutput)\n => FormatChild(path, childValue, childOutput, context, options, graph));\n }\n catch (MaxLinesExceededException)\n {\n }\n\n return output.ToString();\n }\n finally\n {\n isReentry = false;\n }\n }\n\n private static void FormatChild(string path, object value, FormattedObjectGraph output, FormattingContext context,\n FormattingOptions options, ObjectGraph graph)\n {\n try\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(path, nameof(path), \"Formatting a child value requires a path\");\n\n if (!graph.TryPush(path, value))\n {\n output.AddFragment(\"{Cyclic reference to type \");\n TypeValueFormatter.FormatType(value.GetType(), output.AddFragment);\n output.AddFragment(\" detected}\");\n }\n else if (graph.Depth > options.MaxDepth)\n {\n output.AddLine($\"Maximum recursion depth of {options.MaxDepth} was reached. \" +\n $\" Increase {nameof(FormattingOptions.MaxDepth)} on {nameof(AssertionScope)} or {nameof(AssertionConfiguration)} to get more details.\");\n }\n else\n {\n using (output.WithIndentation())\n {\n Format(value, output, context, (childPath, childValue, nestedOutput) =>\n FormatChild(childPath, childValue, nestedOutput, context, options, graph));\n }\n }\n }\n finally\n {\n graph.Pop();\n }\n }\n\n private static void Format(object value, FormattedObjectGraph output, FormattingContext context, FormatChild formatChild)\n {\n IValueFormatter firstFormatterThatCanHandleValue = Formatters.First(f => f.CanHandle(value));\n firstFormatterThatCanHandleValue.Format(value, output, context, formatChild);\n }\n\n /// \n /// Removes a custom formatter that was previously added through .\n /// \n /// \n /// This method is not thread-safe and should not be invoked from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public static void RemoveFormatter(IValueFormatter formatter)\n {\n CustomFormatters.Remove(formatter);\n }\n\n /// \n /// Ensures a custom formatter is included in the chain, just before the default formatter is executed.\n /// \n /// \n /// This method is not thread-safe and should not be invoked from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public static void AddFormatter(IValueFormatter formatter)\n {\n if (!CustomFormatters.Contains(formatter))\n {\n CustomFormatters.Insert(0, formatter);\n }\n }\n\n /// \n /// Tracks the objects that were formatted as well as the path in the object graph of\n /// that object.\n /// \n /// \n /// Is used to detect the maximum recursion depth as well as cyclic references in the graph.\n /// \n private sealed class ObjectGraph\n {\n private readonly CyclicReferenceDetector tracker;\n private readonly Stack pathStack;\n\n public ObjectGraph(object rootObject)\n {\n tracker = new CyclicReferenceDetector();\n pathStack = new Stack();\n TryPush(\"root\", rootObject);\n }\n\n public bool TryPush(string path, object value)\n {\n pathStack.Push(path);\n\n string fullPath = GetFullPath();\n var reference = new ObjectReference(value, fullPath);\n return !tracker.IsCyclicReference(reference);\n }\n\n private string GetFullPath() => string.Join(\".\", pathStack.Reverse());\n\n public void Pop()\n {\n pathStack.Pop();\n }\n\n public int Depth => pathStack.Count - 1;\n\n public override string ToString()\n {\n return string.Join(\".\", pathStack.Reverse());\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/AllPropertiesSelectionRule.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that adds all public properties of the expectation.\n/// \ninternal class AllPropertiesSelectionRule : IMemberSelectionRule\n{\n public bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n MemberVisibility visibility = context.IncludedProperties;\n\n IEnumerable selectedProperties = context.Type\n .GetProperties(visibility.ToMemberKind())\n .Where(property => property.GetMethod?.IsPrivate == false)\n .Select(info => new Property(context.Type, info, currentNode));\n\n return selectedMembers.Union(selectedProperties).ToList();\n }\n\n /// \n /// Returns a string that represents the current object.\n /// \n /// \n /// A string that represents the current object.\n /// \n /// 2\n public override string ToString()\n {\n return \"Include all non-private properties\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XmlNodeAssertions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Xml;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Xml.Equivalency;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XmlNodeAssertions : XmlNodeAssertions\n{\n public XmlNodeAssertions(XmlNode xmlNode, AssertionChain assertionChain)\n : base(xmlNode, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XmlNodeAssertions : ReferenceTypeAssertions\n where TSubject : XmlNode\n where TAssertions : XmlNodeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public XmlNodeAssertions(TSubject xmlNode, AssertionChain assertionChain)\n : base(xmlNode, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current is equivalent to the node.\n /// \n /// The expected node\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(XmlNode expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (var subjectReader = new XmlNodeReader(Subject))\n using (var expectedReader = new XmlNodeReader(expected))\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, expectedReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: true);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not equivalent to\n /// the node.\n /// \n /// The unexpected node\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(XmlNode unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (var subjectReader = new XmlNodeReader(Subject))\n using (var unexpectedReader = new XmlNodeReader(unexpected))\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, unexpectedReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: false);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"XML node\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/XmlIterator.cs", "using System.Collections.Generic;\nusing System.Xml;\n\nnamespace AwesomeAssertions.Xml.Equivalency;\n\ninternal class XmlIterator\n{\n private readonly XmlReader reader;\n private bool skipOnce;\n\n public XmlIterator(XmlReader reader)\n {\n this.reader = reader;\n\n this.reader.MoveToContent();\n }\n\n public XmlNodeType NodeType => reader.NodeType;\n\n public string LocalName => reader.LocalName;\n\n public string NamespaceUri => reader.NamespaceURI;\n\n public string Value => reader.Value;\n\n public bool IsEmptyElement => reader.IsEmptyElement;\n\n public bool IsEndOfDocument => reader.EOF;\n\n public void Read()\n {\n if (skipOnce)\n {\n skipOnce = false;\n return;\n }\n\n if (reader.Read())\n {\n reader.MoveToContent();\n }\n }\n\n public void MoveToEndElement()\n {\n reader.Read();\n\n if (reader.NodeType != XmlNodeType.EndElement)\n {\n // advancing failed\n // skip reading on next attempt to \"simulate\" rewind reader\n skipOnce = true;\n }\n\n reader.MoveToContent();\n }\n\n public IList GetAttributes()\n {\n var attributes = new List();\n\n if (reader.MoveToFirstAttribute())\n {\n do\n {\n if (reader.NamespaceURI != \"http://www.w3.org/2000/xmlns/\")\n {\n attributes.Add(new AttributeData(reader.NamespaceURI, reader.LocalName, reader.Value, reader.Prefix));\n }\n }\n while (reader.MoveToNextAttribute());\n\n reader.MoveToElement();\n }\n\n return attributes;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/ObjectReferenceSpecs.cs", "using AwesomeAssertions.Equivalency.Execution;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class ObjectReferenceSpecs\n{\n [Theory]\n [InlineData(\"\", \"\", false)]\n [InlineData(\"[a]\", \"\", true)]\n [InlineData(\"[a]\", \"[b]\", false)]\n [InlineData(\"[a]\", \"[a][b]\", true)]\n [InlineData(\"[a][a]\", \"[b][a]\", false)]\n [InlineData(\"[a][b][c][d][e][a]\", \"[a]\", true)]\n [InlineData(\"[a][b][c][d][e][a]\", \"[a][b][c]\", true)]\n public void Equals_should_be_symmetrical(string xPath, string yPath, bool expectedResult)\n {\n /*\n From the .NET documentation:\n\n The following statements must be true for all implementations of the Equals(Object) method.\n [..]\n\n x.Equals(y) returns the same value as y.Equals(x).\n\n Earlier implementations of ObjectReference.Equals were not symmetrical.\n */\n\n // Arrange\n var obj = new object();\n\n var x = new ObjectReference(obj, xPath);\n var y = new ObjectReference(obj, yPath);\n\n // Act\n var forwardResult = x.Equals(y);\n var backwardResult = y.Equals(x);\n\n // Assert\n forwardResult.Should().Be(backwardResult, \"because the contract for Equals specifies symmetry\");\n forwardResult.Should().Be(expectedResult, \"because of the semantics of ObjectReference.Equals (sanity check)\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/AllFieldsSelectionRule.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that adds all public fields of the expectation\n/// \ninternal class AllFieldsSelectionRule : IMemberSelectionRule\n{\n public bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n IEnumerable selectedFields = context.Type\n .GetFields(context.IncludedFields.ToMemberKind())\n .Select(info => new Field(info, currentNode));\n\n return selectedMembers.Union(selectedFields).ToList();\n }\n\n /// \n /// Returns a string that represents the current object.\n /// \n /// \n /// A string that represents the current object.\n /// \n /// 2\n public override string ToString()\n {\n return \"Include all non-private fields\";\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/BasicSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Net;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class BasicSpecs\n{\n [Fact]\n public void A_null_configuration_is_invalid()\n {\n // Arrange\n var actual = new { };\n var expectation = new { };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void A_null_as_the_configuration_is_not_valid_for_inequivalency_assertions()\n {\n // Arrange\n var actual = new { };\n var expectation = new { };\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expectation, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_expectation_is_null_it_should_throw()\n {\n // Arrange\n var subject = new { };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be , but found { }*\");\n }\n\n [Fact]\n public void When_comparing_nested_collection_with_a_null_value_it_should_fail_with_the_correct_message()\n {\n // Arrange\n MyClass[] subject = [new MyClass { Items = [\"a\"] }];\n\n MyClass[] expectation = [new MyClass()];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*subject[0].Items*null*, but found*\\\"a\\\"*\");\n }\n\n public class MyClass\n {\n public IEnumerable Items { get; set; }\n }\n\n [Fact]\n public void When_subject_is_null_it_should_throw()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(new { });\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject*to be*, but found *\");\n }\n\n [Fact]\n public void When_subject_and_expectation_are_null_it_should_not_throw()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(null);\n }\n\n [Fact]\n public void When_subject_and_expectation_are_compared_for_equivalence_it_should_allow_chaining()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(null)\n .And.BeNull();\n }\n\n [Fact]\n public void When_subject_and_expectation_are_compared_for_equivalence_with_config_it_should_allow_chaining()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(null, opt => opt)\n .And.BeNull();\n }\n\n [Fact]\n public void When_subject_and_expectation_are_compared_for_non_equivalence_it_should_allow_chaining()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new { })\n .And.BeNull();\n }\n\n [Fact]\n public void When_subject_and_expectation_are_compared_for_non_equivalence_with_config_it_should_allow_chaining()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new { }, opt => opt)\n .And.BeNull();\n }\n\n [Fact]\n public void When_asserting_equivalence_on_a_value_type_from_system_it_should_not_do_a_structural_comparision()\n {\n // Arrange\n\n // DateTime is used as an example because the current implementation\n // would hit the recursion-depth limit if structural equivalence were attempted.\n var date1 = new { Property = 1.January(2011) };\n\n var date2 = new { Property = 1.January(2011) };\n\n // Act / Assert\n date1.Should().BeEquivalentTo(date2);\n }\n\n [Fact]\n public void When_an_object_hides_object_equals_it_should_be_compared_using_its_members()\n {\n // Arrange\n var actual = new VirtualClassOverride { Property = \"Value\", OtherProperty = \"Actual\" };\n\n var expected = new VirtualClassOverride { Property = \"Value\", OtherProperty = \"Expected\" };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw(\"*OtherProperty*Expected*Actual*\");\n }\n\n public class VirtualClass\n {\n public string Property { get; set; }\n\n public new virtual bool Equals(object obj)\n {\n return obj is VirtualClass other && other.Property == Property;\n }\n }\n\n public class VirtualClassOverride : VirtualClass\n {\n public string OtherProperty { get; set; }\n }\n\n [Fact]\n public void When_treating_a_value_type_in_a_collection_as_a_complex_type_it_should_compare_them_by_members()\n {\n // Arrange\n ClassWithValueSemanticsOnSingleProperty[] subject = [new() { Key = \"SameKey\", NestedProperty = \"SomeValue\" }];\n ClassWithValueSemanticsOnSingleProperty[] expected = [new() { Key = \"SameKey\", NestedProperty = \"OtherValue\" }];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected,\n options => options.ComparingByMembers());\n\n // Assert\n act.Should().Throw().WithMessage(\"*NestedProperty*SomeValue*OtherValue*\");\n }\n\n [Fact]\n public void When_treating_a_value_type_as_a_complex_type_it_should_compare_them_by_members()\n {\n // Arrange\n var subject = new ClassWithValueSemanticsOnSingleProperty { Key = \"SameKey\", NestedProperty = \"SomeValue\" };\n\n var expected = new ClassWithValueSemanticsOnSingleProperty { Key = \"SameKey\", NestedProperty = \"OtherValue\" };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected,\n options => options.ComparingByMembers());\n\n // Assert\n act.Should().Throw().WithMessage(\"*NestedProperty*SomeValue*OtherValue*\");\n }\n\n [Fact]\n public void When_treating_a_type_as_value_type_but_it_was_already_marked_as_reference_type_it_should_throw()\n {\n // Arrange\n var subject = new ClassWithValueSemanticsOnSingleProperty { Key = \"Don't care\" };\n\n var expected = new ClassWithValueSemanticsOnSingleProperty { Key = \"Don't care\" };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, options => options\n .ComparingByMembers()\n .ComparingByValue());\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"*compare {nameof(ClassWithValueSemanticsOnSingleProperty)}*value*already*members*\");\n }\n\n [Fact]\n public void When_treating_a_type_as_reference_type_but_it_was_already_marked_as_value_type_it_should_throw()\n {\n // Arrange\n var subject = new ClassWithValueSemanticsOnSingleProperty { Key = \"Don't care\" };\n\n var expected = new ClassWithValueSemanticsOnSingleProperty { Key = \"Don't care\" };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, options => options\n .ComparingByValue()\n .ComparingByMembers());\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"*compare {nameof(ClassWithValueSemanticsOnSingleProperty)}*members*already*value*\");\n }\n\n [Fact]\n public void When_treating_a_complex_type_in_a_collection_as_a_value_type_it_should_compare_them_by_value()\n {\n // Arrange\n var subject = new[] { new { Address = IPAddress.Parse(\"1.2.3.4\"), Word = \"a\" } };\n\n var expected = new[] { new { Address = IPAddress.Parse(\"1.2.3.4\"), Word = \"a\" } };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.ComparingByValue());\n }\n\n [Fact]\n public void When_treating_a_complex_type_as_a_value_type_it_should_compare_them_by_value()\n {\n // Arrange\n var subject = new { Address = IPAddress.Parse(\"1.2.3.4\"), Word = \"a\" };\n\n var expected = new { Address = IPAddress.Parse(\"1.2.3.4\"), Word = \"a\" };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.ComparingByValue());\n }\n\n [Fact]\n public void When_treating_a_null_type_as_value_type_it_should_throw()\n {\n // Arrange\n var subject = new object();\n var expected = new object();\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByValue(null));\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"type\");\n }\n\n [Fact]\n public void When_treating_a_null_type_as_reference_type_it_should_throw()\n {\n // Arrange\n var subject = new object();\n var expected = new object();\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers(null));\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"type\");\n }\n\n [Fact]\n public void When_comparing_an_open_type_by_members_it_should_succeed()\n {\n // Arrange\n var subject = new Option([1, 3, 2]);\n var expected = new Option([1, 2, 3]);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers(typeof(Option<>)));\n }\n\n [Fact]\n public void When_treating_open_type_as_reference_type_and_a_closed_type_as_value_type_it_should_compare_by_value()\n {\n // Arrange\n var subject = new Option([1, 3, 2]);\n var expected = new Option([1, 2, 3]);\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers(typeof(Option<>))\n .ComparingByValue>());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_treating_open_type_as_value_type_and_a_closed_type_as_reference_type_it_should_compare_by_members()\n {\n // Arrange\n var subject = new Option([1, 3, 2]);\n var expected = new Option([1, 2, 3]);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByValue(typeof(Option<>))\n .ComparingByMembers>());\n }\n\n private readonly struct Option : IEquatable>\n where T : class\n {\n public T Value { get; }\n\n public Option(T value)\n {\n Value = value;\n }\n\n public bool Equals(Option other) =>\n EqualityComparer.Default.Equals(Value, other.Value);\n\n public override bool Equals(object obj) =>\n obj is Option other && Equals(other);\n\n public override int GetHashCode() => Value?.GetHashCode() ?? 0;\n }\n\n [Fact]\n public void When_treating_any_type_as_reference_type_it_should_exclude_primitive_types()\n {\n // Arrange\n var subject = new { Value = 1 };\n var expected = new { Value = 2 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be 2*found 1*\");\n }\n\n [Fact]\n public void When_treating_an_open_type_as_reference_type_it_should_exclude_primitive_types()\n {\n // Arrange\n var subject = new { Value = 1 };\n var expected = new { Value = 2 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers(typeof(IEquatable<>)));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be 2*found 1*\");\n }\n\n [Fact]\n public void When_treating_a_primitive_type_as_a_reference_type_it_should_throw()\n {\n // Arrange\n var subject = new { Value = 1 };\n var expected = new { Value = 2 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Cannot compare a primitive type* int *\");\n }\n\n [Fact]\n public void When_a_type_originates_from_the_System_namespace_it_should_be_treated_as_a_value_type()\n {\n // Arrange\n var subject = new { UriBuilder = new UriBuilder(\"http://localhost:9001/api\"), };\n\n var expected = new { UriBuilder = new UriBuilder(\"https://localhost:9002/bapi\"), };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*UriBuilder* to be https://localhost:9002/bapi, but found http://localhost:9001/api*\");\n }\n\n [Fact]\n public void When_asserting_equivalence_on_a_string_it_should_use_string_specific_failure_messages()\n {\n // Arrange\n string s1 = \"hello\";\n string s2 = \"good-bye\";\n\n // Act\n Action act = () => s1.Should().BeEquivalentTo(s2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\"\"*be equivalent to *differ at index 0:*(actual)*\"hello\"*\"good-bye\"*(expected).\"\"\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_strings_typed_as_objects_it_should_compare_them_as_strings()\n {\n // Arrange\n\n // The convoluted construction is so the compiler does not optimize the two objects to be the same.\n object s1 = new string('h', 2);\n object s2 = \"hh\";\n\n // Act / Assert\n s1.Should().BeEquivalentTo(s2);\n }\n\n [Fact]\n public void When_asserting_equivalence_of_ints_typed_as_objects_it_should_use_the_runtime_type()\n {\n // Arrange\n object s1 = 1;\n object s2 = 1;\n\n // Act\n s1.Should().BeEquivalentTo(s2);\n }\n\n [Fact]\n public void When_all_field_of_the_object_are_equal_equivalency_should_pass()\n {\n // Arrange\n var object1 = new ClassWithOnlyAField { Value = 1 };\n var object2 = new ClassWithOnlyAField { Value = 1 };\n\n // Act / Assert\n object1.Should().BeEquivalentTo(object2);\n }\n\n [Fact]\n public void When_number_values_are_convertible_it_should_treat_them_as_equivalent()\n {\n // Arrange\n var actual = new Dictionary { [\"001\"] = 1L, [\"002\"] = 2L };\n\n var expected = new Dictionary { [\"001\"] = 1, [\"002\"] = 2 };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_all_field_of_the_object_are_not_equal_equivalency_should_fail()\n {\n // Arrange\n var object1 = new ClassWithOnlyAField { Value = 1 };\n var object2 = new ClassWithOnlyAField { Value = 101 };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_field_on_the_subject_matches_a_property_the_members_should_match_for_equivalence()\n {\n // Arrange\n var onlyAField = new ClassWithOnlyAField { Value = 1 };\n var onlyAProperty = new ClassWithOnlyAProperty { Value = 101 };\n\n // Act\n Action act = () => onlyAField.Should().BeEquivalentTo(onlyAProperty);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property onlyAField.Value*to be 101, but found 1.*\");\n }\n\n [Fact]\n public void When_asserting_equivalence_including_only_fields_it_should_not_match_properties()\n {\n // Arrange\n var onlyAField = new ClassWithOnlyAField { Value = 1 };\n object onlyAProperty = new ClassWithOnlyAProperty { Value = 101 };\n\n // Act\n Action act = () => onlyAProperty.Should().BeEquivalentTo(onlyAField, opts => opts.ExcludingProperties());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectation has field Value that the other object does not have.*\");\n }\n\n [Fact]\n public void When_asserting_equivalence_including_only_properties_it_should_not_match_fields()\n {\n // Arrange\n var onlyAField = new ClassWithOnlyAField { Value = 1 };\n var onlyAProperty = new ClassWithOnlyAProperty { Value = 101 };\n\n // Act\n Action act = () => onlyAField.Should().BeEquivalentTo(onlyAProperty, opts => opts.IncludingAllDeclaredProperties());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectation has property Value that the other object does not have*\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_objects_including_enumerables_it_should_print_the_failure_message_only_once()\n {\n // Arrange\n var record = new { Member1 = \"\", Member2 = new[] { \"\", \"\" } };\n\n var record2 = new { Member1 = \"different\", Member2 = new[] { \"\", \"\" } };\n\n // Act\n Action act = () => record.Should().BeEquivalentTo(record2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"\"\"Expected property record.Member1 to be the same string* differ at index 0:*(actual)*\"\"*\"different\"*(expected).*\"\"\");\n }\n\n [Fact]\n public void When_asserting_object_equivalence_against_a_null_value_it_should_properly_throw()\n {\n // Act\n Action act = () => ((object)null).Should().BeEquivalentTo(\"foo\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*foo*null*\");\n }\n\n [Fact]\n public void When_the_graph_contains_guids_it_should_properly_format_them()\n {\n // Arrange\n var actual =\n new[] { new { Id = Guid.NewGuid(), Name = \"Name\" } };\n\n var expected =\n new[] { new { Id = Guid.NewGuid(), Name = \"Name\" } };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property actual[0].Id*to be *-*, but found *-*\");\n }\n\n [Fact]\n public void Empty_array_segments_can_be_compared_for_equivalency()\n {\n // Arrange\n var actual = new ClassWithArraySegment();\n var expected = new ClassWithArraySegment();\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n private class ClassWithArraySegment\n {\n public ArraySegment Segment { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/DictionarySpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.Collections.Specialized;\nusing System.Globalization;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing Newtonsoft.Json;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class DictionarySpecs\n{\n private class NonGenericDictionary : IDictionary\n {\n private readonly IDictionary dictionary = new Dictionary();\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public void CopyTo(Array array, int index)\n {\n dictionary.CopyTo(array, index);\n }\n\n public int Count => dictionary.Count;\n\n public bool IsSynchronized => dictionary.IsSynchronized;\n\n public object SyncRoot => dictionary.SyncRoot;\n\n public void Add(object key, object value)\n {\n dictionary.Add(key, value);\n }\n\n public void Clear()\n {\n dictionary.Clear();\n }\n\n public bool Contains(object key)\n {\n return dictionary.Contains(key);\n }\n\n public IDictionaryEnumerator GetEnumerator()\n {\n return dictionary.GetEnumerator();\n }\n\n public void Remove(object key)\n {\n dictionary.Remove(key);\n }\n\n public bool IsFixedSize => dictionary.IsFixedSize;\n\n public bool IsReadOnly => dictionary.IsReadOnly;\n\n public object this[object key]\n {\n get => dictionary[key];\n set => dictionary[key] = value;\n }\n\n public ICollection Keys => dictionary.Keys;\n\n public ICollection Values => dictionary.Values;\n }\n\n private class GenericDictionaryNotImplementingIDictionary : IDictionary\n {\n private readonly Dictionary dictionary = [];\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public IEnumerator> GetEnumerator()\n {\n return dictionary.GetEnumerator();\n }\n\n void ICollection>.Add(KeyValuePair item)\n {\n ((ICollection>)dictionary).Add(item);\n }\n\n public void Clear()\n {\n dictionary.Clear();\n }\n\n bool ICollection>.Contains(KeyValuePair item)\n {\n return ((ICollection>)dictionary).Contains(item);\n }\n\n void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex)\n {\n ((ICollection>)dictionary).CopyTo(array, arrayIndex);\n }\n\n bool ICollection>.Remove(KeyValuePair item)\n {\n return ((ICollection>)dictionary).Remove(item);\n }\n\n public int Count => dictionary.Count;\n\n public bool IsReadOnly => ((ICollection>)dictionary).IsReadOnly;\n\n public bool ContainsKey(TKey key)\n {\n return dictionary.ContainsKey(key);\n }\n\n public void Add(TKey key, TValue value)\n {\n dictionary.Add(key, value);\n }\n\n public bool Remove(TKey key)\n {\n return dictionary.Remove(key);\n }\n\n public bool TryGetValue(TKey key, out TValue value)\n {\n return dictionary.TryGetValue(key, out value);\n }\n\n public TValue this[TKey key]\n {\n get => dictionary[key];\n set => dictionary[key] = value;\n }\n\n public ICollection Keys => dictionary.Keys;\n\n public ICollection Values => dictionary.Values;\n }\n\n /// \n /// FakeItEasy can probably handle this in a couple lines, but then it would not be portable.\n /// \n private class ClassWithTwoDictionaryImplementations : Dictionary, IDictionary\n {\n IEnumerator> IEnumerable>.GetEnumerator()\n {\n return\n ((ICollection>)this).Select(\n item =>\n new KeyValuePair(\n item.Key.ToString(CultureInfo.InvariantCulture),\n item.Value)).GetEnumerator();\n }\n\n public void Add(KeyValuePair item)\n {\n ((ICollection>)this).Add(new KeyValuePair(Parse(item.Key), item.Value));\n }\n\n public bool Contains(KeyValuePair item)\n {\n return\n ((ICollection>)this).Contains(\n new KeyValuePair(Parse(item.Key), item.Value));\n }\n\n public void CopyTo(KeyValuePair[] array, int arrayIndex)\n {\n ((ICollection>)this).Select(\n item =>\n new KeyValuePair(item.Key.ToString(CultureInfo.InvariantCulture), item.Value))\n .ToArray()\n .CopyTo(array, arrayIndex);\n }\n\n public bool Remove(KeyValuePair item)\n {\n return\n ((ICollection>)this).Remove(\n new KeyValuePair(Parse(item.Key), item.Value));\n }\n\n bool ICollection>.IsReadOnly =>\n ((ICollection>)this).IsReadOnly;\n\n public bool ContainsKey(string key)\n {\n return ContainsKey(Parse(key));\n }\n\n public void Add(string key, object value)\n {\n Add(Parse(key), value);\n }\n\n public bool Remove(string key)\n {\n return Remove(Parse(key));\n }\n\n public bool TryGetValue(string key, out object value)\n {\n return TryGetValue(Parse(key), out value);\n }\n\n public object this[string key]\n {\n get => this[Parse(key)];\n set => this[Parse(key)] = value;\n }\n\n ICollection IDictionary.Keys =>\n Keys.Select(key => key.ToString(CultureInfo.InvariantCulture)).ToList();\n\n ICollection IDictionary.Values => Values;\n\n private int Parse(string key)\n {\n return int.Parse(key, CultureInfo.InvariantCulture);\n }\n }\n\n public class UserRolesLookupElement\n {\n private readonly Dictionary> innerRoles = [];\n\n public virtual Dictionary> Roles =>\n innerRoles.ToDictionary(x => x.Key, y => y.Value.Select(z => z));\n\n public void Add(Guid userId, params string[] roles)\n {\n innerRoles[userId] = roles.ToList();\n }\n }\n\n public class ClassWithMemberDictionary\n {\n public Dictionary Dictionary { get; set; }\n }\n\n public class SomeBaseKeyClass : IEquatable\n {\n public SomeBaseKeyClass(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n\n public override int GetHashCode()\n {\n return Id;\n }\n\n public bool Equals(SomeBaseKeyClass other)\n {\n if (other is null)\n {\n return false;\n }\n\n return Id == other.Id;\n }\n\n public override bool Equals(object obj)\n {\n return Equals(obj as SomeBaseKeyClass);\n }\n\n public override string ToString()\n {\n return $\"BaseKey {Id}\";\n }\n }\n\n public class SomeDerivedKeyClass : SomeBaseKeyClass\n {\n public SomeDerivedKeyClass(int id)\n : base(id)\n {\n }\n }\n\n [Fact]\n public void When_a_dictionary_does_not_implement_the_dictionary_interface_it_should_still_be_treated_as_a_dictionary()\n {\n // Arrange\n IDictionary dictionary = new GenericDictionaryNotImplementingIDictionary\n {\n [\"hi\"] = 1\n };\n\n ICollection> collection =\n new List> { new(\"hi\", 1) };\n\n // Act / Assert\n dictionary.Should().BeEquivalentTo(collection);\n }\n\n [Fact]\n public void When_a_read_only_dictionary_matches_the_expectation_it_should_succeed()\n {\n // Arrange\n IReadOnlyDictionary> dictionary =\n new ReadOnlyDictionary>(\n new Dictionary>\n {\n [\"Key2\"] = [\"Value2\"],\n [\"Key1\"] = [\"Value1\"]\n });\n\n // Act / Assert\n dictionary.Should().BeEquivalentTo(new Dictionary>\n {\n [\"Key1\"] = [\"Value1\"],\n [\"Key2\"] = [\"Value2\"]\n });\n }\n\n [Fact]\n public void When_a_read_only_dictionary_does_not_match_the_expectation_it_should_throw()\n {\n // Arrange\n IReadOnlyDictionary> dictionary =\n new ReadOnlyDictionary>(\n new Dictionary>\n {\n [\"Key2\"] = [\"Value2\"],\n [\"Key1\"] = [\"Value1\"]\n });\n\n // Act\n Action act = () => dictionary.Should().BeEquivalentTo(new Dictionary>\n {\n [\"Key2\"] = [\"Value3\"],\n [\"Key1\"] = [\"Value1\"]\n });\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected dictionary[Key2][0]*Value2*Value3*\");\n }\n\n [Fact]\n public void When_a_dictionary_is_compared_to_null_it_should_not_throw_a_NullReferenceException()\n {\n // Arrange\n Dictionary subject = null;\n Dictionary expectation = [];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, \"because we do expect a valid dictionary\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*not to be*null*valid dictionary*\");\n }\n\n [Fact]\n public void When_a_null_dictionary_is_compared_to_null_it_should_not_throw()\n {\n // Arrange\n Dictionary subject = null;\n Dictionary expectation = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_a_dictionary_is_compared_to_a_dictionary_it_should_allow_chaining()\n {\n // Arrange\n Dictionary subject = new() { [42] = 1337 };\n\n Dictionary expectation = new() { [42] = 1337 };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation)\n .And.ContainKey(42);\n }\n\n [Fact]\n public void When_a_dictionary_is_compared_to_a_dictionary_with_a_config_it_should_allow_chaining()\n {\n // Arrange\n Dictionary subject = new() { [42] = 1337 };\n\n Dictionary expectation = new() { [42] = 1337 };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opt => opt)\n .And.ContainKey(42);\n }\n\n [Fact]\n public void When_a_dictionary_property_is_detected_it_should_ignore_the_order_of_the_pairs()\n {\n // Arrange\n var expected = new\n {\n Customers = new Dictionary\n {\n [\"Key2\"] = \"Value2\",\n [\"Key1\"] = \"Value1\"\n }\n };\n\n var subject = new\n {\n Customers = new Dictionary\n {\n [\"Key1\"] = \"Value1\",\n [\"Key2\"] = \"Value2\"\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_collection_of_key_value_pairs_is_equivalent_to_the_dictionary_it_should_succeed()\n {\n // Arrange\n var collection = new List> { new(\"hi\", 1) };\n\n // Act / Assert\n Action act = () => collection.Should().BeEquivalentTo(new Dictionary\n {\n { \"hi\", 2 }\n });\n\n act.Should().Throw().WithMessage(\"Expected collection[hi]*to be 2, but found 1.*\");\n }\n\n [Fact]\n public void\n When_a_generic_dictionary_is_typed_as_object_and_runtime_typing_has_is_specified_it_should_use_the_runtime_type()\n {\n // Arrange\n object object1 = new Dictionary { [\"greeting\"] = \"hello\" };\n object object2 = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().NotThrow(\"the runtime type is a dictionary and the dictionaries are equivalent\");\n }\n\n [Fact]\n public void When_a_generic_dictionary_is_typed_as_object_it_should_respect_the_runtime_typed()\n {\n // Arrange\n object object1 = new Dictionary { [\"greeting\"] = \"hello\" };\n object object2 = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act / Assert\n object1.Should().BeEquivalentTo(object2);\n }\n\n [Fact]\n public void\n When_a_non_generic_dictionary_is_typed_as_object_and_runtime_typing_is_specified_the_runtime_type_should_be_respected()\n {\n // Arrange\n object object1 = new NonGenericDictionary { [\"greeting\"] = \"hello\" };\n object object2 = new NonGenericDictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().NotThrow(\"the runtime type is a dictionary and the dictionaries are equivalent\");\n }\n\n [Fact]\n public void\n When_a_non_generic_dictionary_is_decided_to_be_equivalent_to_expected_trace_is_still_written()\n {\n // Arrange\n object object1 = new NonGenericDictionary { [\"greeting\"] = \"hello\" };\n object object2 = new NonGenericDictionary { [\"greeting\"] = \"hello\" };\n var traceWriter = new StringBuilderTraceWriter();\n\n // Act\n object1.Should().BeEquivalentTo(object2, opts => opts.PreferringRuntimeMemberTypes().WithTracing(traceWriter));\n\n // Assert\n string trace = traceWriter.ToString();\n trace.Should().Contain(\"Recursing into dictionary item greeting at object1\");\n }\n\n [Fact]\n public void When_a_non_generic_dictionary_is_typed_as_object_it_should_respect_the_runtime_type()\n {\n // Arrange\n object object1 = new NonGenericDictionary();\n object object2 = new NonGenericDictionary();\n\n // Act / Assert\n object1.Should().BeEquivalentTo(object2);\n }\n\n [Fact]\n public void When_an_object_implements_two_IDictionary_interfaces_it_should_fail_descriptively()\n {\n // Arrange\n var object1 = (object)new ClassWithTwoDictionaryImplementations();\n var object2 = (object)new ClassWithTwoDictionaryImplementations();\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*expectation*implements multiple dictionary types*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_dictionaries_and_configured_to_respect_runtime_type_it_should_respect_the_runtime_type()\n {\n // Arrange\n IDictionary dictionary1 = new NonGenericDictionary { [2001] = new Car() };\n IDictionary dictionary2 = new NonGenericDictionary { [2001] = new Customer() };\n\n // Act\n Action act =\n () =>\n dictionary1.Should().BeEquivalentTo(dictionary2,\n opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw(\"the types have different properties\");\n }\n\n [Fact]\n public void Can_compare_non_generic_dictionaries_without_recursing()\n {\n // Arrange\n var expected = new NonGenericDictionary\n {\n [\"Key2\"] = \"Value2\",\n [\"Key1\"] = \"Value1\"\n };\n\n var subject = new NonGenericDictionary\n {\n [\"Key1\"] = \"Value1\",\n [\"Key3\"] = \"Value2\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, options => options.WithoutRecursing());\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected subject[\\\"Key2\\\"] to be \\\"Value2\\\", but found *\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_dictionaries_it_should_respect_the_declared_type()\n {\n // Arrange\n var actual = new Dictionary { [0] = new(\"123\") };\n var expectation = new Dictionary { [0] = new DerivedCustomerType(\"123\") };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().NotThrow(\"because it should ignore the properties of the derived type\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_it_should_throw()\n {\n // Arrange\n var actual = new Dictionary();\n var expectation = new Dictionary();\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_generic_dictionaries_and_configured_to_use_runtime_properties_it_should_respect_the_runtime_type()\n {\n // Arrange\n var actual = new Dictionary { [0] = new(\"123\") };\n var expectation = new Dictionary { [0] = new DerivedCustomerType(\"123\") };\n\n // Act\n Action act =\n () =>\n actual.Should().BeEquivalentTo(expectation, opts => opts\n .PreferringRuntimeMemberTypes()\n .ComparingByMembers()\n );\n\n // Assert\n act.Should().Throw(\"the runtime types have different properties\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_generic_dictionaries_and_the_expectation_key_type_is_assignable_from_the_subjects_it_should_fail_if_incompatible()\n {\n // Arrange\n var actual = new Dictionary { [new object()] = \"hello\" };\n var expected = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual*to contain key \\\"greeting\\\"*\");\n }\n\n [Fact]\n public void When_the_subjects_key_type_is_compatible_with_the_expected_key_type_it_should_match()\n {\n // Arrange\n var dictionary1 = new Dictionary { [\"greeting\"] = \"hello\" };\n var dictionary2 = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n act.Should().NotThrow(\"the keys are still strings\");\n }\n\n [Fact]\n public void When_the_subjects_key_type_is_not_compatible_with_the_expected_key_type_it_should_throw()\n {\n // Arrange\n var actual = new Dictionary { [1234] = \"hello\" };\n var expectation = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected actual to be a dictionary or collection of key-value pairs that is keyed to type string*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_generic_dictionaries_the_type_information_should_be_preserved_for_other_equivalency_steps()\n {\n // Arrange\n var userId = Guid.NewGuid();\n\n var dictionary1 = new Dictionary> { [userId] = new List { \"Admin\", \"Special\" } };\n var dictionary2 = new Dictionary> { [userId] = new List { \"Admin\", \"Other\" } };\n\n // Act\n Action act = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_non_generic_dictionaries_the_lack_of_type_information_should_be_preserved_for_other_equivalency_steps()\n {\n // Arrange\n var userId = Guid.NewGuid();\n\n var dictionary1 = new NonGenericDictionary { [userId] = new List { \"Admin\", \"Special\" } };\n var dictionary2 = new NonGenericDictionary { [userId] = new List { \"Admin\", \"Other\" } };\n\n // Act\n Action act = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Special*Other*\");\n }\n\n [Fact]\n public void When_asserting_the_equivalence_of_generic_dictionaries_it_should_respect_the_declared_type()\n {\n // Arrange\n var actual = new Dictionary\n {\n [0] = new DerivedCustomerType(\"123\")\n };\n\n var expectation = new Dictionary { [0] = new(\"123\") };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().NotThrow(\"the objects are equivalent according to the members on the declared type\");\n }\n\n [Fact]\n public void When_the_both_properties_are_null_it_should_not_throw()\n {\n // Arrange\n var expected = new ClassWithMemberDictionary\n {\n Dictionary = null\n };\n\n var subject = new ClassWithMemberDictionary\n {\n Dictionary = null\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void\n When_the_dictionary_values_are_handled_by_the_enumerable_equivalency_step_the_type_information_should_be_preserved()\n {\n // Arrange\n var userId = Guid.NewGuid();\n\n var actual = new UserRolesLookupElement();\n actual.Add(userId, \"Admin\", \"Special\");\n\n var expected = new UserRolesLookupElement();\n expected.Add(userId, \"Admin\", \"Other\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*Roles[*][1]*Special*Other*\");\n }\n\n [Fact]\n public void When_the_other_dictionary_does_not_contain_enough_items_it_should_throw()\n {\n // Arrange\n var expected = new\n {\n Customers = new Dictionary\n {\n [\"Key1\"] = \"Value1\",\n [\"Key2\"] = \"Value2\"\n }\n };\n\n var subject = new\n {\n Customers = new Dictionary\n {\n [\"Key1\"] = \"Value1\"\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, \"because we are expecting two keys\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Customers*dictionary*2 item(s)*expecting two keys*but*misses*\");\n }\n\n [Fact]\n public void When_the_other_property_is_not_a_dictionary_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n Customers = \"I am a string\"\n };\n\n var expected = new\n {\n Customers = new Dictionary\n {\n [\"Key2\"] = \"Value2\",\n [\"Key1\"] = \"Value1\"\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property subject.Customers to be a dictionary or collection of key-value pairs that is keyed to type string*\");\n }\n\n [Fact]\n public void When_the_other_property_is_null_it_should_throw()\n {\n // Arrange\n var subject = new ClassWithMemberDictionary\n {\n Dictionary = new Dictionary\n {\n [\"Key2\"] = \"Value2\",\n [\"Key1\"] = \"Value1\"\n }\n };\n\n var expected = new ClassWithMemberDictionary\n {\n Dictionary = null\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, \"because we are not expecting anything\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*property*Dictionary*to be because we are not expecting anything, but found *{*}*\");\n }\n\n [Fact]\n public void When_subject_dictionary_asserted_to_be_equivalent_have_less_elements_fails_describing_missing_keys()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [\"greeting\"] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [\"greeting\"] = \"hello\",\n [\"farewell\"] = \"goodbye\"\n };\n\n // Act\n Action action = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected dictionary1*to be a dictionary with 2 item(s), but it misses key(s) {\\\"farewell\\\"}*\");\n }\n\n [Fact]\n public void\n When_subject_dictionary_with_class_keys_asserted_to_be_equivalent_have_less_elements_other_dictionary_derived_class_keys_fails_describing_missing_keys()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [new SomeDerivedKeyClass(1)] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [new SomeDerivedKeyClass(1)] = \"hello\",\n [new SomeDerivedKeyClass(2)] = \"hello\"\n };\n\n // Act\n Action action = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*to be a dictionary with 2 item(s), but*misses key(s) {BaseKey 2}*\");\n }\n\n [Fact]\n public void When_subject_dictionary_asserted_to_be_equivalent_have_more_elements_fails_describing_additional_keys()\n {\n // Arrange\n var expectation = new Dictionary\n {\n [\"greeting\"] = \"hello\"\n };\n\n var subject = new Dictionary\n {\n [\"greeting\"] = \"hello\",\n [\"farewell\"] = \"goodbye\"\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, \"because we expect one pair\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject*to be a dictionary with 1 item(s) because we expect one pair, but*additional key(s) {\\\"farewell\\\"}*\");\n }\n\n [Fact]\n public void\n When_subject_dictionary_with_class_keys_asserted_to_be_equivalent_and_other_dictionary_derived_class_keys_fails_because_of_types_incompatibility()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [new SomeDerivedKeyClass(1)] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [new SomeDerivedKeyClass(1)] = \"hello\",\n [new SomeDerivedKeyClass(2)] = \"hello\"\n };\n\n // Act\n Action action = () => dictionary2.Should().BeEquivalentTo(dictionary1);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary2 to be a dictionary or collection of key-value pairs that is keyed to type AwesomeAssertions.Equivalency.Specs.DictionarySpecs+SomeBaseKeyClass.*\");\n }\n\n [Fact]\n public void\n When_subject_dictionary_asserted_to_be_equivalent_have_less_elements_but_some_missing_and_some_additional_elements_fails_describing_missing_and_additional_keys()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [\"GREETING\"] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [\"greeting\"] = \"hello\",\n [\"farewell\"] = \"goodbye\"\n };\n\n // Act\n Action action = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected*to be a dictionary with 2 item(s), but*misses key(s)*{\\\"greeting\\\", \\\"farewell\\\"}*additional key(s) {\\\"GREETING\\\"}*\");\n }\n\n [Fact]\n public void\n When_subject_dictionary_asserted_to_be_equivalent_have_more_elements_but_some_missing_and_some_additional_elements_fails_describing_missing_and_additional_keys()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [\"GREETING\"] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [\"greeting\"] = \"hello\",\n [\"farewell\"] = \"goodbye\"\n };\n\n // Act\n Action action = () => dictionary2.Should().BeEquivalentTo(dictionary1);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected*to be a dictionary with 1 item(s), but*misses key(s) {\\\"GREETING\\\"}*additional key(s) {\\\"greeting\\\", \\\"farewell\\\"}*\");\n }\n\n [Fact]\n public void When_two_equivalent_dictionaries_are_compared_directly_as_if_it_is_a_collection_it_should_succeed()\n {\n // Arrange\n var result = new Dictionary\n {\n [\"C\"] = null,\n [\"B\"] = 0,\n [\"A\"] = 0\n };\n\n // Act / Assert\n result.Should().BeEquivalentTo(new Dictionary\n {\n [\"A\"] = 0,\n [\"B\"] = 0,\n [\"C\"] = null\n });\n }\n\n [Fact]\n public void When_two_equivalent_dictionaries_are_compared_directly_it_should_succeed()\n {\n // Arrange\n var result = new Dictionary\n {\n [\"C\"] = 0,\n [\"B\"] = 0,\n [\"A\"] = 0\n };\n\n // Act / Assert\n result.Should().BeEquivalentTo(new Dictionary\n {\n [\"A\"] = 0,\n [\"B\"] = 0,\n [\"C\"] = 0\n });\n }\n\n [Fact]\n public void When_two_nested_dictionaries_contain_null_values_it_should_not_crash()\n {\n // Arrange\n var projection = new\n {\n ReferencedEquipment = new Dictionary\n {\n [1] = null\n }\n };\n\n var persistedProjection = new\n {\n ReferencedEquipment = new Dictionary\n {\n [1] = null\n }\n };\n\n // Act / Assert\n persistedProjection.Should().BeEquivalentTo(projection);\n }\n\n [Fact]\n public void When_two_nested_dictionaries_do_not_match_it_should_throw()\n {\n // Arrange\n var projection = new\n {\n ReferencedEquipment = new Dictionary\n {\n [1] = \"Bla1\"\n }\n };\n\n var persistedProjection = new\n {\n ReferencedEquipment = new Dictionary\n {\n [1] = \"Bla2\"\n }\n };\n\n // Act\n Action act = () => persistedProjection.Should().BeEquivalentTo(projection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*ReferencedEquipment[1]*Bla2*Bla1*\");\n }\n\n [Fact]\n public void When_a_dictionary_is_missing_a_key_it_should_report_the_specific_key()\n {\n // Arrange\n var actual = new Dictionary\n {\n { \"a\", \"x\" },\n { \"b\", \"x\" },\n };\n\n var expected = new Dictionary\n {\n { \"a\", \"x\" },\n { \"c\", \"x\" }, // key mismatch\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, \"because we're expecting {0}\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual*key*c*because we're expecting c*\");\n }\n\n [Fact]\n public void When_a_nested_dictionary_value_doesnt_match_it_should_throw()\n {\n // Arrange\n const string json =\n \"\"\"\n {\n \"NestedDictionary\": {\n \"StringProperty\": \"string\",\n \"IntProperty\": 123\n }\n }\n \"\"\";\n\n var expectedResult = new Dictionary\n {\n [\"NestedDictionary\"] = new Dictionary\n {\n [\"StringProperty\"] = \"string\",\n [\"IntProperty\"] = 123\n }\n };\n\n // Act\n var result = JsonConvert.DeserializeObject>(json);\n Action act = () => result.Should().BeEquivalentTo(expectedResult);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*String*JValue*\");\n }\n\n [Fact]\n public void When_a_custom_rule_is_applied_on_a_dictionary_it_should_apply_it_on_the_values()\n {\n // Arrange\n var dictOne = new Dictionary\n {\n { \"a\", 1.2345 },\n { \"b\", 2.4567 },\n { \"c\", 5.6789 },\n { \"s\", 3.333 }\n };\n\n var dictTwo = new Dictionary\n {\n { \"a\", 1.2348 },\n { \"b\", 2.4561 },\n { \"c\", 5.679 },\n { \"s\", 3.333 }\n };\n\n // Act / Assert\n dictOne.Should().BeEquivalentTo(dictTwo, options => options\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.1))\n .WhenTypeIs()\n );\n }\n\n [Fact]\n public void Passing_the_reason_to_the_inner_equivalency_assertion_works()\n {\n var subject = new Dictionary\n {\n [\"a\"] = new List()\n };\n\n var expected = new Dictionary\n {\n [\"a\"] = new List { 42 }\n };\n\n Action act = () => subject.Should().BeEquivalentTo(expected, \"FOO {0}\", \"BAR\");\n\n act.Should().Throw().WithMessage(\"*FOO BAR*\");\n }\n\n [Fact]\n public void A_non_generic_subject_can_be_compared_with_a_generic_expectation()\n {\n var subject = new ListDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n var expected = new Dictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void A_non_generic_subject_which_is_null_can_be_compared_with_a_generic_expectation()\n {\n var subject = (ListDictionary)null;\n\n var expected = new Dictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n act.Should().Throw().WithMessage(\"**\");\n }\n\n [Fact]\n public void Excluding_nested_objects_when_dictionary_is_equivalent()\n {\n var subject = new Dictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n var expected = new Dictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n subject.Should().BeEquivalentTo(expected, opt => opt.WithoutRecursing());\n }\n\n [Fact]\n public void Custom_types_which_implementing_dictionaries_pass()\n {\n var subject = new NonGenericChildDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n var expected = new Specs.NonGenericDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void Custom_types_which_implementing_dictionaries_pass_with_swapped_subject_expectation()\n {\n var subject = new Specs.NonGenericDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n var expected = new NonGenericChildDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void A_subject_string_key_with_curly_braces_is_formatted_correctly_in_failure_message()\n {\n // Arrange\n var actual = new Dictionary { [\"{}\"] = \"\" };\n var expected = new Dictionary { [\"{}\"] = null };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected actual[{}] to be *, but found *.\");\n }\n\n [Fact]\n public void A_subject_key_with_braces_in_string_representation_is_formatted_correctly_in_failure_message()\n {\n // Arrange\n var actual = new Dictionary { [new()] = \"\" };\n var expected = new Dictionary { [new()] = null };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected actual[RecordStruct { }] to be *, but found *.\");\n }\n\n private record struct RecordStruct();\n}\n\ninternal class NonGenericChildDictionary : Dictionary\n{\n public new void Add(string key, int value)\n {\n base.Add(key, value);\n }\n}\n\ninternal class NonGenericDictionary : IDictionary\n{\n private readonly Dictionary innerDictionary = [];\n\n public int this[string key]\n {\n get => innerDictionary[key];\n set => innerDictionary[key] = value;\n }\n\n public ICollection Keys => innerDictionary.Keys;\n\n public ICollection Values => innerDictionary.Values;\n\n public int Count => innerDictionary.Count;\n\n public bool IsReadOnly => false;\n\n public void Add(string key, int value) => innerDictionary.Add(key, value);\n\n public void Add(KeyValuePair item) => innerDictionary.Add(item.Key, item.Value);\n\n public void Clear() => innerDictionary.Clear();\n\n public bool Contains(KeyValuePair item) => innerDictionary.Contains(item);\n\n public bool ContainsKey(string key) => innerDictionary.ContainsKey(key);\n\n public void CopyTo(KeyValuePair[] array, int arrayIndex) =>\n ((ICollection>)innerDictionary).CopyTo(array, arrayIndex);\n\n public IEnumerator> GetEnumerator() => innerDictionary.GetEnumerator();\n\n public bool Remove(string key) => innerDictionary.Remove(key);\n\n public bool Remove(KeyValuePair item) => innerDictionary.Remove(item.Key);\n\n public bool TryGetValue(string key, out int value) => innerDictionary.TryGetValue(key, out value);\n\n IEnumerator IEnumerable.GetEnumerator() => innerDictionary.GetEnumerator();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/AssertionResultSet.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Represents a collection of assertion results obtained through a .\n/// \ninternal class AssertionResultSet\n{\n private readonly Dictionary set = [];\n\n /// \n /// Adds the failures (if any) resulting from executing an assertion within a\n /// identified by a key.\n /// \n public void AddSet(object key, string[] failures)\n {\n set[key] = failures;\n }\n\n /// \n /// Returns the closest match compared to the set identified by the provided or\n /// an empty array if one of the results represents a successful assertion.\n /// \n /// \n /// The closest match is the set that contains the least amount of failures, or no failures at all, and preferably\n /// the set that is identified by the .\n /// \n public string[] GetTheFailuresForTheSetWithTheFewestFailures(object key = null)\n {\n if (ContainsSuccessfulSet())\n {\n return [];\n }\n\n KeyValuePair[] bestResultSets = GetBestResultSets();\n\n KeyValuePair bestMatch = Array.Find(bestResultSets, r => r.Key.Equals(key));\n\n if ((bestMatch.Key, bestMatch.Value) == default)\n {\n return bestResultSets[0].Value;\n }\n\n return bestMatch.Value;\n }\n\n private KeyValuePair[] GetBestResultSets()\n {\n int fewestFailures = set.Values.Min(r => r.Length);\n return set.Where(r => r.Value.Length == fewestFailures).ToArray();\n }\n\n /// \n /// Gets a value indicating whether this collection contains a set without any failures at all.\n /// \n public bool ContainsSuccessfulSet() => set.Values.Any(v => v.Length == 0);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XElementAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Xml;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Xml.Equivalency;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XElementAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public XElementAssertions(XElement xElement, AssertionChain assertionChain)\n : base(xElement, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current equals the\n /// element, by using\n /// \n /// \n /// The expected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(XElement expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(XNode.DeepEquals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:subject} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not equal the\n /// element, using\n /// .\n /// \n /// The unexpected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(XElement unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition((Subject is null && unexpected is not null) || !XNode.DeepEquals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:subject} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is equivalent to the\n /// element, using a semantic equivalency\n /// comparison.\n /// \n /// The expected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(XElement expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (XmlReader subjectReader = Subject?.CreateReader())\n using (XmlReader expectedReader = expected?.CreateReader())\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, expectedReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: true);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not equivalent to\n /// the element, using a semantic\n /// equivalency comparison.\n /// \n /// The unexpected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(XElement unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (XmlReader subjectReader = Subject?.CreateReader())\n using (XmlReader otherReader = unexpected?.CreateReader())\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, otherReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: false);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the element to have value {0}{reason}, but {context:member} is .\", expected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(Subject!.Value == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} '{0}' to have value {1}{reason}, but found {2}.\",\n Subject.Name, expected, Subject.Value);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an attribute with the specified .\n /// \n /// The name of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint HaveAttribute(string expectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(expectedName);\n\n return HaveAttribute(XNamespace.None + expectedName, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an attribute with the specified .\n /// \n /// The name of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint HaveAttribute(XName expectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedName);\n\n string expectedText = expectedName.ToString();\n\n assertionChain\n .WithExpectation(\"Expected attribute {0} in element to exist {reason}, \", expectedText,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n \"but {context:member} is .\"))\n .Then\n .WithExpectation(\"Expected {context:subject} to have attribute {0}{reason}, \", expectedText,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attribute(expectedName))\n .ForCondition(attribute => attribute is not null)\n .FailWith(\"but found no such attribute in {0}.\", Subject));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current doesn't have an attribute with the specified .\n /// \n /// The name of the unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotHaveAttribute(string unexpectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(unexpectedName);\n\n return NotHaveAttribute(XNamespace.None + unexpectedName, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current doesn't have an attribute with the specified .\n /// \n /// The name of the unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotHaveAttribute(XName unexpectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedName);\n\n string unexpectedText = unexpectedName.ToString();\n\n assertionChain\n .WithExpectation(\"Did not expect attribute {0} in element to exist{reason}, \", unexpectedText,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n \"but {context:member} is .\",\n unexpectedText))\n .Then\n .WithExpectation(\"Did not expect {context:subject} to have attribute {0}{reason}, \", unexpectedText,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attribute(unexpectedName))\n .ForCondition(attribute => attribute is null)\n .FailWith(\"but found such attribute in {0}.\", Subject));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an attribute with the specified \n /// and .\n /// \n /// The name of the expected attribute\n /// The value of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint HaveAttributeWithValue(string expectedName, string expectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(expectedName);\n\n return HaveAttributeWithValue(XNamespace.None + expectedName, expectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an attribute with the specified \n /// and .\n /// \n /// The name of the expected attribute\n /// The value of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint HaveAttributeWithValue(XName expectedName, string expectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedName);\n\n string expectedText = expectedName.ToString();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected attribute {0} in element to have value {1}{reason}, \",\n expectedText, expectedValue,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but {context:member} is .\"))\n .Then\n .WithExpectation(\"Expected {context:subject} to have attribute {0} with value {1}{reason}, \",\n expectedText, expectedValue,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attribute(expectedName))\n .ForCondition(attr => attr is not null)\n .FailWith(\"but found no such attribute in {0}\", Subject))\n .Then\n .WithExpectation(\"Expected attribute {0} in {context:subject} to have value {1}{reason}, \",\n expectedText, expectedValue,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attribute(expectedName))\n .ForCondition(attr => attr!.Value == expectedValue)\n .FailWith(\"but found {0}.\", attr => attr.Value));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current doesn't have an attribute with the specified \n /// and/or .\n /// \n /// The name of the unexpected attribute\n /// The value of the unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotHaveAttributeWithValue(string unexpectedName, string unexpectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(unexpectedName, nameof(unexpectedName));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n return NotHaveAttributeWithValue(XNamespace.None + unexpectedName, unexpectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current doesn't have an attribute with the specified \n /// and/or .\n /// \n /// The name of the unexpected attribute\n /// The value of the unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotHaveAttributeWithValue(XName unexpectedName, string unexpectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedName, nameof(unexpectedName));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n string unexpectedText = unexpectedName.ToString();\n\n assertionChain\n .WithExpectation(\"Did not expect attribute {0} in element to have value {1}{reason}, \",\n unexpectedText, unexpectedValue,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"but {context:member} is .\"))\n .Then\n .WithExpectation(\"Did not expect {context:subject} to have attribute {0} with value {1}{reason}, \",\n unexpectedText, unexpectedValue,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attributes()\n .FirstOrDefault(a => a.Name == unexpectedName && a.Value == unexpectedValue))\n .ForCondition(attribute => attribute is null)\n .FailWith(\"but found such attribute in {0}.\", Subject));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a direct child element with the specified\n /// name.\n /// \n /// The name of the expected child element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint HaveElement(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(expected);\n\n return HaveElement(XNamespace.None + expected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has a direct child element with the specified\n /// name.\n /// \n /// The name of the expected child element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveElement(XName expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n \"Expected the element to have child element {0}{reason}, but {context:member} is .\",\n expected.ToString().EscapePlaceholders());\n\n XElement xElement = null;\n\n if (assertionChain.Succeeded)\n {\n xElement = Subject!.Element(expected);\n\n assertionChain\n .ForCondition(xElement is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have child element {0}{reason}, but no such child element was found.\",\n expected.ToString().EscapePlaceholders());\n }\n\n return new AndWhichConstraint(this, xElement, assertionChain, \"/\" + expected);\n }\n\n /// \n /// Asserts that the of the current has the specified occurrence of\n /// child elements with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// A constraint specifying the number of times the specified elements should appear.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint> HaveElement(XName expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the element has an element count if the element name is .\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have an element with count of {0}{reason}, but the element itself is .\",\n expected.ToString());\n\n IEnumerable xElements = [];\n\n if (assertionChain.Succeeded)\n {\n xElements = Subject!.Elements(expected);\n int actual = xElements.Count();\n\n assertionChain\n .ForConstraint(occurrenceConstraint, actual)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have an element {0} {expectedOccurrence}\" +\n $\"{{reason}}, but found it {actual.Times()}.\",\n expected.ToString());\n }\n\n return new AndWhichConstraint>(this, xElements, assertionChain, \"/\" + expected);\n }\n\n /// \n /// Asserts that the of the current has the specified occurrence of\n /// child elements with the specified name.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// A constraint specifying the number of times the specified elements should appear.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint> HaveElement(string expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the element has an element if the expected name is .\");\n\n return HaveElement(XNamespace.None + expected, occurrenceConstraint, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current doesn't have the specified child element.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElement(string unexpectedElement,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n\n return NotHaveElement(XNamespace.None + unexpectedElement, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current doesn't have the specified child element.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElement(XName unexpectedElement,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:subject} to have an element {0}{reason}, but the element itself is .\",\n unexpectedElement.ToString());\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.Elements(unexpectedElement).Any())\n .FailWith(\"Did not expect {context:subject} to have an element {0}{reason}, \" +\n \"but the element {0} was found.\", unexpectedElement);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the of the current has the specified child element\n /// with the specified name.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// The expected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithValue(string expectedElement,\n string expectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedElement, nameof(expectedElement));\n Guard.ThrowIfArgumentIsNull(expectedValue, nameof(expectedValue));\n\n return HaveElementWithValue(XNamespace.None + expectedElement, expectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current has the specified child element\n /// with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// The expected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithValue(XName expectedElement,\n string expectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedElement, nameof(expectedElement));\n Guard.ThrowIfArgumentIsNull(expectedValue, nameof(expectedValue));\n\n IEnumerable xElements = [];\n\n assertionChain\n .WithExpectation(\"Expected {context:subject} to have an element {0} with value {1}{reason}, \",\n expectedElement.ToString(), expectedValue,\n chain => chain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"but the element itself is .\"))\n .Then\n .WithExpectation(\"Expected {context:subject} to have an element {0} with value {1}{reason}, \",\n expectedElement, expectedValue, chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() =>\n {\n xElements = Subject!.Elements(expectedElement);\n\n return xElements;\n })\n .ForCondition(elements => elements.Any())\n .FailWith(\"but the element {0} isn't found.\", expectedElement)\n .Then\n .ForCondition(elements => elements.Any(e => e.Value == expectedValue))\n .FailWith(\"but the element {0} does not have such a value.\", expectedElement));\n\n return new AndWhichConstraint(this, xElements.FirstOrDefault());\n }\n\n /// \n /// Asserts that the of the current either doesn't have the\n /// specified child element or doesn't have the specified .\n /// \n /// \n /// The name of the unexpected child element of the current element's .\n /// \n /// \n /// The unexpected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElementWithValue(string unexpectedElement,\n string unexpectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n return NotHaveElementWithValue(XNamespace.None + unexpectedElement, unexpectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current either doesn't have the\n /// specified child element or doesn't have the specified .\n /// \n /// \n /// he full name of the unexpected child element of the current element's .\n /// \n /// \n /// The unexpected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElementWithValue(XName unexpectedElement,\n string unexpectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n assertionChain\n .WithExpectation(\"Did not expect {context:subject} to have an element {0} with value {1}{reason}, \",\n unexpectedElement.ToString(), unexpectedValue,\n chain => chain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"but the element itself is .\")\n .Then\n .ForCondition(!Subject!.Elements(unexpectedElement)\n .Any(e => e.Value == unexpectedValue))\n .FailWith(\"but the element {0} does have this value.\", unexpectedElement));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"XML element\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Tracing/Tracer.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency.Tracing;\n\n/// \n/// Exposes tracing capabilities that can be used by the implementation of the equivalency algorithm\n/// when an is provided.\n/// \npublic class Tracer\n{\n private readonly INode currentNode;\n private readonly ITraceWriter traceWriter;\n\n internal Tracer(INode currentNode, ITraceWriter traceWriter)\n {\n this.currentNode = currentNode;\n this.traceWriter = traceWriter;\n }\n\n /// \n /// Writes a single line to the currently configured .\n /// \n /// \n /// If no tracer has been configured, the call will be ignored.\n /// \n public void WriteLine(GetTraceMessage getTraceMessage)\n {\n traceWriter?.AddSingle(getTraceMessage(currentNode));\n }\n\n /// \n /// Starts a block that scopes an operation that will be written to the currently configured \n /// after the returned disposable is disposed.\n /// \n /// \n /// If no tracer has been configured for the , the call will be ignored.\n /// \n public IDisposable WriteBlock(GetTraceMessage getTraceMessage)\n {\n if (traceWriter is not null)\n {\n return traceWriter.AddBlock(getTraceMessage(currentNode));\n }\n\n return new Disposable(() => { });\n }\n\n public override string ToString() => traceWriter is not null ? traceWriter.ToString() : string.Empty;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/IncludeMemberByPredicateSelectionRule.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that includes a particular member in the structural comparison.\n/// \ninternal class IncludeMemberByPredicateSelectionRule : IMemberSelectionRule\n{\n private readonly Func predicate;\n private readonly string description;\n\n public IncludeMemberByPredicateSelectionRule(Expression> predicate)\n {\n description = predicate.Body.ToString();\n this.predicate = predicate.Compile();\n }\n\n public bool IncludesMembers => true;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n var members = new List(selectedMembers);\n\n foreach (MemberInfo memberInfo in currentNode.Type.GetMembers(MemberKind.Public |\n MemberKind.Internal))\n {\n IMember member = MemberFactory.Create(memberInfo, currentNode);\n\n if (predicate(new MemberToMemberInfoAdapter(member)) && !members.Exists(p => p.IsEquivalentTo(member)))\n {\n members.Add(member);\n }\n }\n\n return members;\n }\n\n /// \n /// 2\n public override string ToString()\n {\n return \"Include member when \" + description;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IMemberMatchingRule.cs", "using AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a rule that defines how to map the selected members of the expectation object to the properties\n/// of the subject.\n/// \npublic interface IMemberMatchingRule\n{\n /// \n /// Attempts to find a member on the subject that should be compared with the\n /// during a structural equality.\n /// \n /// \n /// Whether or not a match is required or optional is up to the specific rule. If no match is found and this is not an issue,\n /// simply return .\n /// \n /// \n /// The of the subject's member for which a match must be found. Can never\n /// be .\n /// \n /// \n /// The subject object for which a matching member must be returned. Can never be .\n /// \n /// \n /// \n /// \n /// \n /// Returns the of the property with which to compare the subject with, or \n /// if no match was found.\n /// \n IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/ExcludeMemberByPathSelectionRule.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that removes a particular property from the structural comparison.\n/// \ninternal class ExcludeMemberByPathSelectionRule : SelectMemberByPathSelectionRule\n{\n private MemberPath memberToExclude;\n\n public ExcludeMemberByPathSelectionRule(MemberPath pathToExclude)\n {\n memberToExclude = pathToExclude;\n }\n\n protected override void AddOrRemoveMembersFrom(List selectedMembers, INode parent, string parentPath,\n MemberSelectionContext context)\n {\n selectedMembers.RemoveAll(member =>\n memberToExclude.IsSameAs(new MemberPath(member, parentPath)));\n }\n\n public void AppendPath(MemberPath nextPath)\n {\n memberToExclude = memberToExclude.AsParentCollectionOf(nextPath);\n }\n\n public MemberPath CurrentPath => memberToExclude;\n\n public override string ToString()\n {\n return \"Exclude member \" + memberToExclude;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/CollectionMemberSelectionRuleDecorator.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\ninternal class CollectionMemberSelectionRuleDecorator : IMemberSelectionRule\n{\n private readonly IMemberSelectionRule selectionRule;\n\n public CollectionMemberSelectionRuleDecorator(IMemberSelectionRule selectionRule)\n {\n this.selectionRule = selectionRule;\n }\n\n public bool IncludesMembers => selectionRule.IncludesMembers;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return selectionRule.SelectMembers(currentNode, selectedMembers, context);\n }\n\n public override string ToString()\n {\n return selectionRule.ToString();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/AssertionRuleSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class AssertionRuleSpecs\n{\n [Fact]\n public void When_two_objects_have_the_same_property_values_it_should_succeed()\n {\n // Arrange\n var subject = new { Age = 36, Birthdate = new DateTime(1973, 9, 20), Name = \"Dennis\" };\n\n var other = new { Age = 36, Birthdate = new DateTime(1973, 9, 20), Name = \"Dennis\" };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_two_objects_have_the_same_nullable_property_values_it_should_succeed()\n {\n // Arrange\n var subject = new { Age = 36, Birthdate = (DateTime?)new DateTime(1973, 9, 20), Name = \"Dennis\" };\n\n var other = new { Age = 36, Birthdate = (DateTime?)new DateTime(1973, 9, 20), Name = \"Dennis\" };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_two_objects_have_the_same_properties_but_a_different_value_it_should_throw()\n {\n // Arrange\n var subject = new { Age = 36 };\n\n var expectation = new { Age = 37 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, \"because {0} are the same\", \"they\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Age*to be 37 because they are the same, but found 36*\");\n }\n\n [Fact]\n public void\n When_subject_has_a_valid_property_that_is_compared_with_a_null_property_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var subject = new { Name = \"Dennis\" };\n\n var other = new { Name = (string)null };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected property subject.Name to be *we want to test the failure message*, but found \\\"Dennis\\\"*\");\n }\n\n [Fact]\n public void When_two_collection_properties_dont_match_it_should_throw_and_specify_the_difference()\n {\n // Arrange\n var subject = new { Values = new[] { 1, 2, 3 } };\n\n var other = new { Values = new[] { 1, 4, 3 } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Values[1]*to be 4, but found 2*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_two_string_properties_do_not_match_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject = new { Name = \"Dennes\" };\n\n var other = new { Name = \"Dennis\" };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other, options => options.Including(d => d.Name));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Name to be*index 4*\\\"Dennes\\\"*\\\"Dennis\\\"*\");\n }\n\n [Fact]\n public void When_two_properties_are_of_derived_types_but_are_equal_it_should_succeed()\n {\n // Arrange\n var subject = new { Type = new DerivedCustomerType(\"123\") };\n\n var other = new { Type = new CustomerType(\"123\") };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void\n When_two_properties_have_the_same_declared_type_but_different_runtime_types_and_are_equivalent_according_to_the_declared_type_it_should_succeed()\n {\n // Arrange\n var subject = new { Type = (CustomerType)new DerivedCustomerType(\"123\") };\n\n var other = new { Type = new CustomerType(\"123\") };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_a_nested_property_is_equal_based_on_equality_comparer_it_should_not_throw()\n {\n // Arrange\n var subject = new { Timestamp = 22.March(2020).At(19, 30) };\n\n var expectation = new { Timestamp = 1.January(2020).At(7, 31) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using());\n }\n\n [Fact]\n public void When_a_nested_property_is_unequal_based_on_equality_comparer_it_should_throw()\n {\n // Arrange\n var subject = new { Timestamp = 22.March(2020) };\n\n var expectation = new { Timestamp = 1.January(2021) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(new DateTimeByYearComparer()));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*equal*2021*DateTimeByYearComparer*2020*\");\n }\n\n [Fact]\n public void When_the_subjects_property_type_is_different_from_the_equality_comparer_it_should_throw()\n {\n // Arrange\n var subject = new { Timestamp = 1L };\n\n var expectation = new { Timestamp = 1.January(2021) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(new DateTimeByYearComparer()));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*Timestamp*1L*\");\n }\n\n private class DateTimeByYearComparer : IEqualityComparer\n {\n public bool Equals(DateTime x, DateTime y)\n {\n return x.Year == y.Year;\n }\n\n public int GetHashCode(DateTime obj) => obj.GetHashCode();\n }\n\n [Fact]\n public void When_an_invalid_equality_comparer_is_provided_it_should_throw()\n {\n // Arrange\n var subject = new { Timestamp = 22.March(2020) };\n\n var expectation = new { Timestamp = 1.January(2021) };\n\n IEqualityComparer equalityComparer = null;\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(equalityComparer));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*comparer*\");\n }\n\n [Fact]\n public void When_the_compile_time_type_does_not_match_the_equality_comparer_type_it_should_use_the_default_mechanics()\n {\n // Arrange\n var subject = new { Property = (IInterface)new ConcreteClass(\"SomeString\") };\n\n var expectation = new { Property = (IInterface)new ConcreteClass(\"SomeOtherString\") };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opt =>\n opt.Using());\n }\n\n [Fact]\n public void When_the_runtime_type_does_match_the_equality_comparer_type_it_should_use_the_default_mechanics()\n {\n // Arrange\n var subject = new { Property = (IInterface)new ConcreteClass(\"SomeString\") };\n\n var expectation = new { Property = (IInterface)new ConcreteClass(\"SomeOtherString\") };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opt => opt\n .PreferringRuntimeMemberTypes()\n .Using());\n\n // Assert\n act.Should().Throw().WithMessage(\"*ConcreteClassEqualityComparer*\");\n }\n\n [Fact]\n public void When_several_properties_do_not_match_they_are_all_reported_after_an_other_successful_assertion()\n {\n // Arrange\n var test = new Test\n {\n Id = 42,\n Text = \"some-text\",\n };\n var actualTest = new Test\n {\n Id = 32,\n Text = \"some-other-text\",\n };\n\n // Act\n Action act = () =>\n {\n actualTest.Text.Should().Be(\"some-other-text\");\n actualTest.Should().BeEquivalentTo(test);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected property actualTest.Id to be*{Environment.NewLine}\" +\n \"*Expected property actualTest.Text to be*\"\n );\n }\n\n private sealed class Test\n {\n public int Id { get; set; }\n\n public string Text { get; set; }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void An_equality_comparer_of_non_nullable_type_is_not_invoked_on_nullable_member()\n {\n // Arrange\n var subject = new { Timestamp = (DateTime?)22.March(2020) };\n\n var expectation = new { Timestamp = (DateTime?)1.January(2020) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(new DateTimeByYearComparer()));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Timestamp*2020*\");\n }\n\n [Fact]\n public void An_equality_comparer_of_nullable_type_is_not_invoked_on_non_nullable_member()\n {\n // Arrange\n var subject = new { Timestamp = 22.March(2020) };\n\n var expectation = new { Timestamp = 1.January(2020) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(new NullableDateTimeByYearComparer()));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Timestamp*2020*\");\n }\n\n [Fact]\n public void An_equality_comparer_of_non_nullable_type_is_invoked_on_non_nullable_data()\n {\n // Arrange\n var subject = new { Timestamp = (DateTime?)22.March(2020) };\n\n var expectation = new { Timestamp = (DateTime?)1.January(2020) };\n\n // Act\n subject.Should().BeEquivalentTo(expectation, opt => opt\n .PreferringRuntimeMemberTypes()\n .Using(new DateTimeByYearComparer()));\n }\n\n [Fact]\n public void An_equality_comparer_of_nullable_type_is_not_invoked_on_non_nullable_data()\n {\n // Arrange\n var subject = new { Timestamp = (DateTime?)22.March(2020) };\n\n var expectation = new { Timestamp = (DateTime?)1.January(2020) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opt => opt\n .PreferringRuntimeMemberTypes()\n .Using(new NullableDateTimeByYearComparer()));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Timestamp*2020*\");\n }\n }\n\n private interface IInterface;\n\n private class ConcreteClass : IInterface\n {\n private readonly string property;\n\n public ConcreteClass(string propertyValue)\n {\n property = propertyValue;\n }\n\n public string GetProperty() => property;\n }\n\n private class ConcreteClassEqualityComparer : IEqualityComparer\n {\n public bool Equals(ConcreteClass x, ConcreteClass y)\n {\n return x.GetProperty() == y.GetProperty();\n }\n\n public int GetHashCode(ConcreteClass obj) => obj.GetProperty().GetHashCode();\n }\n\n private class NullableDateTimeByYearComparer : IEqualityComparer\n {\n public bool Equals(DateTime? x, DateTime? y)\n {\n return x?.Year == y?.Year;\n }\n\n public int GetHashCode(DateTime? obj) => obj?.GetHashCode() ?? 0;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/ExcludeNonBrowsableMembersRule.cs", "using System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\ninternal class ExcludeNonBrowsableMembersRule : IMemberSelectionRule\n{\n public bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return selectedMembers.Where(member => member.IsBrowsable).ToList();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/MemberToMemberInfoAdapter.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Represents a selection context of a nested property\n/// \ninternal class MemberToMemberInfoAdapter : IMemberInfo\n{\n private readonly IMember member;\n\n public MemberToMemberInfoAdapter(IMember member)\n {\n this.member = member;\n DeclaringType = member.DeclaringType;\n Name = member.Expectation.Name;\n Type = member.Type;\n Path = member.Expectation.PathAndName;\n }\n\n public string Name { get; }\n\n public Type Type { get; }\n\n public Type DeclaringType { get; }\n\n public string Path { get; set; }\n\n public CSharpAccessModifier GetterAccessibility => member.GetterAccessibility;\n\n public CSharpAccessModifier SetterAccessibility => member.SetterAccessibility;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/ExceptionAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Steps;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an is in the correct state.\n/// \n[DebuggerNonUserCode]\npublic class ExceptionAssertions : ReferenceTypeAssertions, ExceptionAssertions>\n where TException : Exception\n{\n private readonly AssertionChain assertionChain;\n\n public ExceptionAssertions(IEnumerable exceptions, AssertionChain assertionChain)\n : base(exceptions, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Gets the exception object of the exception thrown.\n /// \n public TException And => SingleSubject;\n\n /// \n /// Gets the exception object of the exception thrown.\n /// \n public TException Which => And;\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"exception\";\n\n /// \n /// Asserts that the thrown exception has a message that matches .\n /// \n /// \n /// The pattern to match against the exception message. This parameter can contain a combination of literal text and\n /// wildcard (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n public virtual ExceptionAssertions WithMessage(string expectedWildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .UsingLineBreaks\n .ForCondition(Subject.Any())\n .FailWith(\"Expected exception with message {0}{reason}, but no exception was thrown.\", expectedWildcardPattern);\n\n AssertExceptionMessage(Subject.Select(exc => exc.Message), expectedWildcardPattern, because,\n becauseArgs);\n\n return this;\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of type .\n /// \n /// The expected type of the inner exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public virtual ExceptionAssertions WithInnerException(string because = \"\",\n params object[] becauseArgs)\n where TInnerException : Exception\n {\n var expectedInnerExceptions = AssertInnerExceptions(typeof(TInnerException), because, becauseArgs);\n return new ExceptionAssertions(expectedInnerExceptions.Cast(), assertionChain);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of type .\n /// \n /// The expected type of the inner exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public ExceptionAssertions WithInnerException(Type innerException,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(innerException);\n\n return new ExceptionAssertions(AssertInnerExceptions(innerException, because, becauseArgs), assertionChain);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of the exact type (and not a derived exception type).\n /// \n /// The expected type of the inner exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public virtual ExceptionAssertions WithInnerExceptionExactly(string because = \"\",\n params object[] becauseArgs)\n where TInnerException : Exception\n {\n var exceptionExpression = AssertInnerExceptionExactly(typeof(TInnerException), because, becauseArgs);\n return new ExceptionAssertions(exceptionExpression.Cast(), assertionChain);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of the exact type (and not a derived exception type).\n /// \n /// The expected type of the inner exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public ExceptionAssertions WithInnerExceptionExactly(Type innerException,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(innerException);\n\n return new ExceptionAssertions(AssertInnerExceptionExactly(innerException, because, becauseArgs), assertionChain);\n }\n\n /// \n /// Asserts that the exception matches a particular condition.\n /// \n /// \n /// The condition that the exception must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public ExceptionAssertions Where(Expression> exceptionExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(exceptionExpression);\n\n Func condition = exceptionExpression.Compile();\n\n assertionChain\n .ForCondition(condition(SingleSubject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected exception where {0}{reason}, but the condition was not met by:\"\n + Environment.NewLine + Environment.NewLine + \"{1}.\",\n exceptionExpression, Subject);\n\n return this;\n }\n\n private IEnumerable AssertInnerExceptionExactly(Type innerException, string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.Any(e => e.InnerException is not null))\n .FailWith(\"Expected inner {0}{reason}, but the thrown exception has no inner exception.\", innerException);\n\n Exception[] expectedExceptions = Subject\n .Select(e => e.InnerException)\n .Where(e => e?.GetType() == innerException).ToArray();\n\n assertionChain\n .ForCondition(expectedExceptions.Length > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected inner {0}{reason}, but found {1}.\", innerException, SingleSubject.InnerException);\n\n return expectedExceptions;\n }\n\n private IEnumerable AssertInnerExceptions(Type innerException, string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.Any(e => e.InnerException is not null))\n .FailWith(\"Expected inner {0}{reason}, but the thrown exception has no inner exception.\", innerException);\n\n Exception[] expectedInnerExceptions = Subject\n .Select(e => e.InnerException)\n .Where(e => e != null && e.GetType().IsSameOrInherits(innerException))\n .ToArray();\n\n assertionChain\n .ForCondition(expectedInnerExceptions.Length > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected inner {0}{reason}, but found {1}.\", innerException, SingleSubject.InnerException);\n\n return expectedInnerExceptions;\n }\n\n private TException SingleSubject\n {\n get\n {\n if (Subject.Count() > 1)\n {\n string thrownExceptions = BuildExceptionsString(Subject);\n\n AssertionEngine.TestFramework.Throw(\n $\"More than one exception was thrown. AwesomeAssertions cannot determine which Exception was meant.{Environment.NewLine}{thrownExceptions}\");\n }\n\n return Subject.Single();\n }\n }\n\n private static string BuildExceptionsString(IEnumerable exceptions)\n {\n return string.Join(Environment.NewLine,\n exceptions.Select(\n exception =>\n \"\\t\" + Formatter.ToString(exception)));\n }\n\n private void AssertExceptionMessage(IEnumerable messages, string expectation, string because, params object[] becauseArgs)\n {\n var results = new AssertionResultSet();\n\n foreach (string message in messages)\n {\n using (var scope = new AssertionScope())\n {\n var chain = AssertionChain.GetOrCreate();\n chain.OverrideCallerIdentifier(() => \"exception message\");\n chain.ReuseOnce();\n\n message.Should().MatchEquivalentOf(expectation, because, becauseArgs);\n\n results.AddSet(message, scope.Discard());\n }\n\n if (results.ContainsSuccessfulSet())\n {\n break;\n }\n }\n\n foreach (string failure in results.GetTheFailuresForTheSetWithTheFewestFailures())\n {\n string replacedCurlyBraces =\n failure.EscapePlaceholders();\n\n assertionChain.FailWith(replacedCurlyBraces);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MemberSelectionContext.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides contextual information to an .\n/// \npublic class MemberSelectionContext\n{\n private readonly Type compileTimeType;\n private readonly Type runtimeType;\n private readonly IEquivalencyOptions options;\n\n public MemberSelectionContext(Type compileTimeType, Type runtimeType, IEquivalencyOptions options)\n {\n this.runtimeType = runtimeType;\n this.compileTimeType = compileTimeType;\n this.options = options;\n }\n\n /// \n /// Gets a value indicating whether and which properties should be considered.\n /// \n public MemberVisibility IncludedProperties => options.IncludedProperties;\n\n /// \n /// Gets a value indicating whether and which fields should be considered.\n /// \n public MemberVisibility IncludedFields => options.IncludedFields;\n\n /// \n /// Gets either the compile-time or run-time type depending on the options provided by the caller.\n /// \n public Type Type\n {\n get\n {\n Type type = options.UseRuntimeTyping ? runtimeType : compileTimeType;\n\n return type.NullableOrActualType();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/MemberLessObjectsSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class MemberLessObjectsSpecs\n{\n [Fact]\n public void When_asserting_instances_of_an_anonymous_type_having_no_members_are_equivalent_it_should_fail()\n {\n // Arrange / Act\n Action act = () => new { }.Should().BeEquivalentTo(new { });\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_instances_of_a_class_having_no_members_are_equivalent_it_should_fail()\n {\n // Arrange / Act\n Action act = () => new ClassWithNoMembers().Should().BeEquivalentTo(new ClassWithNoMembers());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_instances_of_Object_are_equivalent_it_should_fail()\n {\n // Arrange / Act\n Action act = () => new object().Should().BeEquivalentTo(new object());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_instance_of_object_is_equivalent_to_null_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n object actual = new();\n object expected = null;\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Expected*to be *we want to test the failure message*, but found System.Object*\");\n }\n\n [Fact]\n public void When_asserting_null_is_equivalent_to_instance_of_object_it_should_fail()\n {\n // Arrange\n object actual = null;\n object expected = new();\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Expected*to be System.Object*but found *\");\n }\n\n [Fact]\n public void When_an_type_only_exposes_fields_but_fields_are_ignored_in_the_equivalence_comparision_it_should_fail()\n {\n // Arrange\n var object1 = new ClassWithOnlyAField { Value = 1 };\n var object2 = new ClassWithOnlyAField { Value = 101 };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2, opts => opts.IncludingAllDeclaredProperties());\n\n // Assert\n act.Should().Throw(\"the objects have no members to compare.\");\n }\n\n [Fact]\n public void\n When_an_type_only_exposes_properties_but_properties_are_ignored_in_the_equivalence_comparision_it_should_fail()\n {\n // Arrange\n var object1 = new ClassWithOnlyAProperty { Value = 1 };\n var object2 = new ClassWithOnlyAProperty { Value = 101 };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2, opts => opts.ExcludingProperties());\n\n // Assert\n act.Should().Throw(\"the objects have no members to compare.\");\n }\n\n [Fact]\n public void When_asserting_instances_of_arrays_of_types_in_System_are_equivalent_it_should_respect_the_runtime_type()\n {\n // Arrange\n object actual = new int[0];\n object expectation = new int[0];\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_throwing_on_missing_members_and_there_are_no_missing_members_should_not_throw()\n {\n // Arrange\n var subject = new { Version = 2, Age = 36, };\n\n var expectation = new { Version = 2, Age = 36 };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n options => options.ThrowingOnMissingMembers());\n }\n\n [Fact]\n public void When_throwing_on_missing_members_and_there_is_a_missing_member_should_throw()\n {\n // Arrange\n var subject = new { Version = 2 };\n\n var expectation = new { Version = 2, Age = 36 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.ThrowingOnMissingMembers());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectation has property Age that the other object does not have*\");\n }\n\n [Fact]\n public void When_throwing_on_missing_members_and_there_is_an_additional_property_on_subject_should_not_throw()\n {\n // Arrange\n var subject = new { Version = 2, Age = 36, Additional = 13 };\n\n var expectation = new { Version = 2, Age = 36 };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n options => options.ThrowingOnMissingMembers());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/ExcludeMemberByPredicateSelectionRule.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that removes a particular member from the structural comparison based on a predicate.\n/// \ninternal class ExcludeMemberByPredicateSelectionRule : IMemberSelectionRule\n{\n private readonly Func predicate;\n private readonly string description;\n\n public ExcludeMemberByPredicateSelectionRule(Expression> predicate)\n {\n description = predicate.Body.ToString();\n this.predicate = predicate.Compile();\n }\n\n public bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return selectedMembers.Where(p => !predicate(new MemberToMemberInfoAdapter(p))).ToArray();\n }\n\n /// \n /// 2\n public override string ToString()\n {\n return \"Exclude member when \" + description;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/CollectionMemberObjectInfo.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency.Ordering;\n\ninternal class CollectionMemberObjectInfo : IObjectInfo\n{\n public CollectionMemberObjectInfo(IObjectInfo context)\n {\n Path = GetAdjustedPropertyPath(context.Path);\n\n#pragma warning disable CS0618\n Type = context.Type;\n#pragma warning restore CS0618\n\n ParentType = context.ParentType;\n RuntimeType = context.RuntimeType;\n CompileTimeType = context.CompileTimeType;\n }\n\n private static string GetAdjustedPropertyPath(string propertyPath)\n {\n return propertyPath.Substring(propertyPath.IndexOf('.', StringComparison.Ordinal) + 1);\n }\n\n public Type Type { get; }\n\n public Type ParentType { get; }\n\n public string Path { get; set; }\n\n public Type CompileTimeType { get; }\n\n public Type RuntimeType { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/TypeExtensions.cs", "using System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing AwesomeAssertions.Equivalency;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class TypeExtensions\n{\n private const BindingFlags PublicInstanceMembersFlag =\n BindingFlags.Public | BindingFlags.Instance;\n\n private const BindingFlags AllStaticAndInstanceMembersFlag =\n PublicInstanceMembersFlag | BindingFlags.NonPublic | BindingFlags.Static;\n\n private static readonly ConcurrentDictionary HasValueSemanticsCache = new();\n private static readonly ConcurrentDictionary TypeIsRecordCache = new();\n\n public static bool IsDecoratedWith(this Type type)\n where TAttribute : Attribute\n {\n return type.IsDefined(typeof(TAttribute), inherit: false);\n }\n\n public static bool IsDecoratedWith(this MemberInfo type)\n where TAttribute : Attribute\n {\n // Do not use MemberInfo.IsDefined\n // There is an issue with PropertyInfo and EventInfo preventing the inherit option to work.\n // https://github.com/dotnet/runtime/issues/30219\n return Attribute.IsDefined(type, typeof(TAttribute), inherit: false);\n }\n\n public static bool IsDecoratedWithOrInherit(this Type type)\n where TAttribute : Attribute\n {\n return type.IsDefined(typeof(TAttribute), inherit: true);\n }\n\n public static bool IsDecoratedWithOrInherit(this MemberInfo type)\n where TAttribute : Attribute\n {\n // Do not use MemberInfo.IsDefined\n // There is an issue with PropertyInfo and EventInfo preventing the inherit option to work.\n // https://github.com/dotnet/runtime/issues/30219\n return Attribute.IsDefined(type, typeof(TAttribute), inherit: true);\n }\n\n public static bool IsDecoratedWith(this Type type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate).Any();\n }\n\n public static bool IsDecoratedWith(this MemberInfo type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate).Any();\n }\n\n public static bool IsDecoratedWithOrInherit(this Type type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate, inherit: true).Any();\n }\n\n public static IEnumerable GetMatchingAttributes(this Type type)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type);\n }\n\n public static IEnumerable GetMatchingAttributes(this Type type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate);\n }\n\n public static IEnumerable GetMatchingOrInheritedAttributes(this Type type)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, inherit: true);\n }\n\n public static IEnumerable GetMatchingOrInheritedAttributes(this Type type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate, inherit: true);\n }\n\n public static IEnumerable GetCustomAttributes(this MemberInfo type, bool inherit = false)\n where TAttribute : Attribute\n {\n // Do not use MemberInfo.GetCustomAttributes.\n // There is an issue with PropertyInfo and EventInfo preventing the inherit option to work.\n // https://github.com/dotnet/runtime/issues/30219\n return CustomAttributeExtensions.GetCustomAttributes(type, inherit);\n }\n\n private static IEnumerable GetCustomAttributes(MemberInfo type,\n Expression> isMatchingAttributePredicate, bool inherit = false)\n where TAttribute : Attribute\n {\n Func isMatchingAttribute = isMatchingAttributePredicate.Compile();\n return GetCustomAttributes(type, inherit).Where(isMatchingAttribute);\n }\n\n private static TAttribute[] GetCustomAttributes(this Type type, bool inherit = false)\n where TAttribute : Attribute\n {\n return (TAttribute[])type.GetCustomAttributes(typeof(TAttribute), inherit);\n }\n\n private static IEnumerable GetCustomAttributes(Type type,\n Expression> isMatchingAttributePredicate, bool inherit = false)\n where TAttribute : Attribute\n {\n Func isMatchingAttribute = isMatchingAttributePredicate.Compile();\n return GetCustomAttributes(type, inherit).Where(isMatchingAttribute);\n }\n\n /// \n /// Determines whether two objects refer to the same\n /// member.\n /// \n public static bool IsEquivalentTo(this IMember property, IMember otherProperty)\n {\n return (property.DeclaringType.IsSameOrInherits(otherProperty.DeclaringType) ||\n otherProperty.DeclaringType.IsSameOrInherits(property.DeclaringType)) &&\n property.Expectation.Name == otherProperty.Expectation.Name;\n }\n\n /// \n /// Returns the interfaces that the implements that are concrete\n /// versions of the .\n /// \n public static Type[] GetClosedGenericInterfaces(this Type type, Type openGenericType)\n {\n if (type.IsGenericType && type.GetGenericTypeDefinition() == openGenericType)\n {\n return [type];\n }\n\n Type[] interfaces = type.GetInterfaces();\n\n return\n interfaces\n .Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == openGenericType)\n .ToArray();\n }\n\n public static bool OverridesEquals(this Type type)\n {\n MethodInfo method = type\n .GetMethod(\"Equals\", [typeof(object)]);\n\n return method is not null\n && method.GetBaseDefinition().DeclaringType != method.DeclaringType;\n }\n\n /// \n /// Finds the property by a case-sensitive name and with a certain visibility.\n /// \n /// \n /// If both a normal property and one that was implemented through an explicit interface implementation with the same name exist,\n /// then the normal property will be returned.\n /// \n /// \n /// Returns if no such property exists.\n /// \n public static PropertyInfo FindProperty(this Type type, string propertyName, MemberVisibility memberVisibility)\n {\n var properties = type.GetProperties(memberVisibility.ToMemberKind());\n\n return Array.Find(properties, p =>\n p.Name == propertyName || p.Name.EndsWith(\".\" + propertyName, StringComparison.Ordinal));\n }\n\n /// \n /// Finds the field by a case-sensitive name.\n /// \n /// \n /// Returns if no such field exists.\n /// \n public static FieldInfo FindField(this Type type, string fieldName, MemberVisibility memberVisibility)\n {\n var fields = type.GetFields(memberVisibility.ToMemberKind());\n\n return Array.Find(fields, p => p.Name == fieldName);\n }\n\n /// \n /// Check if the type is declared as abstract.\n /// \n /// Type to be checked\n public static bool IsCSharpAbstract(this Type type)\n {\n return type.IsAbstract && !type.IsSealed;\n }\n\n /// \n /// Check if the type is declared as sealed.\n /// \n /// Type to be checked\n public static bool IsCSharpSealed(this Type type)\n {\n return type.IsSealed && !type.IsAbstract;\n }\n\n /// \n /// Check if the type is declared as static.\n /// \n /// Type to be checked\n public static bool IsCSharpStatic(this Type type)\n {\n return type.IsSealed && type.IsAbstract;\n }\n\n public static MethodInfo GetMethod(this Type type, string methodName, IEnumerable parameterTypes)\n {\n return type.GetMethods(AllStaticAndInstanceMembersFlag)\n .SingleOrDefault(m =>\n m.Name == methodName && m.GetParameters().Select(p => p.ParameterType).SequenceEqual(parameterTypes));\n }\n\n public static bool HasMethod(this Type type, string methodName, IEnumerable parameterTypes)\n {\n return type.GetMethod(methodName, parameterTypes) is not null;\n }\n\n public static MethodInfo GetParameterlessMethod(this Type type, string methodName)\n {\n return type.GetMethod(methodName, Enumerable.Empty());\n }\n\n public static PropertyInfo FindPropertyByName(this Type type, string propertyName)\n {\n return type.GetProperty(propertyName, AllStaticAndInstanceMembersFlag);\n }\n\n public static bool HasExplicitlyImplementedProperty(this Type type, Type interfaceType, string propertyName)\n {\n bool hasGetter = type.HasParameterlessMethod($\"{interfaceType.FullName}.get_{propertyName}\");\n\n bool hasSetter = type.GetMethods(AllStaticAndInstanceMembersFlag)\n .SingleOrDefault(m =>\n m.Name == $\"{interfaceType.FullName}.set_{propertyName}\" &&\n m.GetParameters().Length == 1) is not null;\n\n return hasGetter || hasSetter;\n }\n\n private static bool HasParameterlessMethod(this Type type, string methodName)\n {\n return type.GetParameterlessMethod(methodName) is not null;\n }\n\n public static PropertyInfo GetIndexerByParameterTypes(this Type type, IEnumerable parameterTypes)\n {\n return type.GetProperties(AllStaticAndInstanceMembersFlag)\n .SingleOrDefault(p =>\n p.IsIndexer() && p.GetIndexParameters().Select(i => i.ParameterType).SequenceEqual(parameterTypes));\n }\n\n public static bool IsIndexer(this PropertyInfo member)\n {\n return member.GetIndexParameters().Length != 0;\n }\n\n public static ConstructorInfo GetConstructor(this Type type, IEnumerable parameterTypes)\n {\n const BindingFlags allInstanceMembersFlag =\n BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;\n\n return type\n .GetConstructors(allInstanceMembersFlag)\n .SingleOrDefault(m => m.GetParameters().Select(p => p.ParameterType).SequenceEqual(parameterTypes));\n }\n\n private static IEnumerable GetConversionOperators(this Type type, Type sourceType, Type targetType,\n Func predicate)\n {\n return type\n .GetMethods()\n .Where(m =>\n m.IsPublic\n && m.IsStatic\n && m.IsSpecialName\n && m.ReturnType == targetType\n && predicate(m.Name)\n && m.GetParameters() is { Length: 1 } parameters\n && parameters[0].ParameterType == sourceType);\n }\n\n public static bool IsAssignableToOpenGeneric(this Type type, Type definition)\n {\n // The CLR type system does not consider anything to be assignable to an open generic type.\n // For the purposes of test assertions, the user probably means that the subject type is\n // assignable to any generic type based on the given generic type definition.\n if (definition.IsInterface)\n {\n return type.IsImplementationOfOpenGeneric(definition);\n }\n\n return type == definition || type.IsDerivedFromOpenGeneric(definition);\n }\n\n private static bool IsImplementationOfOpenGeneric(this Type type, Type definition)\n {\n // check subject against definition\n if (type.IsInterface && type.IsGenericType &&\n type.GetGenericTypeDefinition() == definition)\n {\n return true;\n }\n\n // check subject's interfaces against definition\n return type.GetInterfaces()\n .Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == definition);\n }\n\n public static bool IsDerivedFromOpenGeneric(this Type type, Type definition)\n {\n if (type == definition)\n {\n // do not consider a type to be derived from itself\n return false;\n }\n\n // check subject and its base types against definition\n for (Type baseType = type;\n baseType is not null;\n baseType = baseType.BaseType)\n {\n if (baseType.IsGenericType && baseType.GetGenericTypeDefinition() == definition)\n {\n return true;\n }\n }\n\n return false;\n }\n\n public static bool IsUnderNamespace(this Type type, string @namespace)\n {\n return IsGlobalNamespace()\n || IsExactNamespace()\n || IsParentNamespace();\n\n bool IsGlobalNamespace() => @namespace is null;\n bool IsExactNamespace() => IsNamespacePrefix() && type.Namespace.Length == @namespace.Length;\n bool IsParentNamespace() => IsNamespacePrefix() && type.Namespace[@namespace.Length] is '.';\n bool IsNamespacePrefix() => type.Namespace?.StartsWith(@namespace, StringComparison.Ordinal) == true;\n }\n\n public static bool IsSameOrInherits(this Type actualType, Type expectedType)\n {\n return actualType == expectedType ||\n expectedType.IsAssignableFrom(actualType);\n }\n\n public static MethodInfo GetExplicitConversionOperator(this Type type, Type sourceType, Type targetType)\n {\n return type\n .GetConversionOperators(sourceType, targetType, name => name is \"op_Explicit\")\n .SingleOrDefault();\n }\n\n public static MethodInfo GetImplicitConversionOperator(this Type type, Type sourceType, Type targetType)\n {\n return type\n .GetConversionOperators(sourceType, targetType, name => name is \"op_Implicit\")\n .SingleOrDefault();\n }\n\n public static bool HasValueSemantics(this Type type)\n {\n return HasValueSemanticsCache.GetOrAdd(type, static t =>\n t.OverridesEquals() &&\n !t.IsAnonymous() &&\n !t.IsTuple() &&\n !IsKeyValuePair(t));\n }\n\n private static bool IsTuple(this Type type)\n {\n if (!type.IsGenericType)\n {\n return false;\n }\n\n#if !(NET47 || NETSTANDARD2_0)\n return typeof(ITuple).IsAssignableFrom(type);\n#else\n Type openType = type.GetGenericTypeDefinition();\n\n return openType == typeof(ValueTuple<>)\n || openType == typeof(ValueTuple<,>)\n || openType == typeof(ValueTuple<,,>)\n || openType == typeof(ValueTuple<,,,>)\n || openType == typeof(ValueTuple<,,,,>)\n || openType == typeof(ValueTuple<,,,,,>)\n || openType == typeof(ValueTuple<,,,,,,>)\n || (openType == typeof(ValueTuple<,,,,,,,>) && IsTuple(type.GetGenericArguments()[7]))\n || openType == typeof(Tuple<>)\n || openType == typeof(Tuple<,>)\n || openType == typeof(Tuple<,,>)\n || openType == typeof(Tuple<,,,>)\n || openType == typeof(Tuple<,,,,>)\n || openType == typeof(Tuple<,,,,,>)\n || openType == typeof(Tuple<,,,,,,>)\n || (openType == typeof(Tuple<,,,,,,,>) && IsTuple(type.GetGenericArguments()[7]));\n#endif\n }\n\n private static bool IsAnonymous(this Type type)\n {\n bool nameContainsAnonymousType = type.FullName.Contains(\"AnonymousType\", StringComparison.Ordinal);\n\n if (!nameContainsAnonymousType)\n {\n return false;\n }\n\n bool hasCompilerGeneratedAttribute =\n type.IsDecoratedWith();\n\n return hasCompilerGeneratedAttribute;\n }\n\n public static bool IsRecord(this Type type)\n {\n return TypeIsRecordCache.GetOrAdd(type, static t => t.IsRecordClass() || t.IsRecordStruct());\n }\n\n private static bool IsRecordClass(this Type type)\n {\n return type.GetMethod(\"$\", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) is { } &&\n type.GetProperty(\"EqualityContract\", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)?\n .GetMethod?.IsDecoratedWith() == true;\n }\n\n private static bool IsRecordStruct(this Type type)\n {\n // As noted here: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/record-structs#open-questions\n // recognizing record structs from metadata is an open point. The following check is based on common sense\n // and heuristic testing, apparently giving good results but not supported by official documentation.\n return type.BaseType == typeof(ValueType) &&\n type.GetMethod(\"PrintMembers\", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly, null,\n [typeof(StringBuilder)], null) is { } &&\n type.GetMethod(\"op_Equality\", BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly, null,\n [type, type], null)?\n .IsDecoratedWith() == true;\n }\n\n private static bool IsKeyValuePair(Type type)\n {\n return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(KeyValuePair<,>);\n }\n\n /// \n /// If the type provided is a nullable type, gets the underlying type. Returns the type itself otherwise.\n /// \n public static Type NullableOrActualType(this Type type)\n {\n if (type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))\n {\n type = type.GetGenericArguments()[0];\n }\n\n return type;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/NonEquivalencySpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class NonEquivalencySpecs\n{\n [Fact]\n public void When_asserting_inequivalence_of_equal_ints_as_object_it_should_fail()\n {\n // Arrange\n object i1 = 1;\n object i2 = 1;\n\n // Act\n Action act = () => i1.Should().NotBeEquivalentTo(i2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_unequal_ints_as_object_it_should_succeed()\n {\n // Arrange\n object i1 = 1;\n object i2 = 2;\n\n // Act / Assert\n i1.Should().NotBeEquivalentTo(i2);\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_equal_strings_as_object_it_should_fail()\n {\n // Arrange\n object s1 = \"A\";\n object s2 = \"A\";\n\n // Act\n Action act = () => s1.Should().NotBeEquivalentTo(s2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_unequal_strings_as_object_it_should_succeed()\n {\n // Arrange\n object s1 = \"A\";\n object s2 = \"B\";\n\n // Act / Assert\n s1.Should().NotBeEquivalentTo(s2);\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_equal_classes_it_should_fail()\n {\n // Arrange\n var o1 = new { Name = \"A\" };\n var o2 = new { Name = \"A\" };\n\n // Act\n Action act = () => o1.Should().NotBeEquivalentTo(o2, \"some {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*some reason*\");\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_unequal_classes_it_should_succeed()\n {\n // Arrange\n var o1 = new { Name = \"A\" };\n var o2 = new { Name = \"B\" };\n\n // Act / Assert\n o1.Should().NotBeEquivalentTo(o2);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/MemberConversionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class MemberConversionSpecs\n{\n [Fact]\n public void When_two_objects_have_the_same_properties_with_convertable_values_it_should_succeed()\n {\n // Arrange\n var subject = new { Age = \"37\", Birthdate = \"1973-09-20\" };\n\n var other = new { Age = 37, Birthdate = new DateTime(1973, 9, 20) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other, o => o.WithAutoConversion());\n }\n\n [Fact]\n public void When_a_string_is_declared_equivalent_to_an_int_representing_the_numerals_it_should_pass()\n {\n // Arrange\n var actual = new { Property = \"32\" };\n\n var expectation = new { Property = 32 };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation,\n options => options.WithAutoConversion());\n }\n\n [Fact]\n public void When_an_int_is_compared_equivalent_to_a_string_representing_the_number_it_should_pass()\n {\n // Arrange\n var subject = new { Property = 32 };\n var expectation = new { Property = \"32\" };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n }\n\n [Fact]\n public void Numbers_can_be_converted_to_enums()\n {\n // Arrange\n var expectation = new { Property = EnumFour.Three };\n var subject = new { Property = 3UL };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n }\n\n [Fact]\n public void Enums_are_not_converted_to_enums_of_different_type()\n {\n // Arrange\n var expectation = new { Property = EnumTwo.Two };\n var subject = new { Property = EnumThree.Two };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n }\n\n [Fact]\n public void Strings_are_not_converted_to_enums()\n {\n // Arrange\n var expectation = new { Property = EnumTwo.Two };\n var subject = new { Property = \"Two\" };\n\n // Act / Assert\n var act = () => subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n\n act.Should().Throw();\n }\n\n [Fact]\n public void Numbers_that_are_out_of_range_cannot_be_converted_to_enums()\n {\n // Arrange\n var expectation = new { Property = EnumFour.Three };\n var subject = new { Property = 4 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*subject*Property*EnumFour*\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_WithAutoConversionFor_it_should_throw()\n {\n // Arrange\n var subject = new object();\n\n var expectation = new object();\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.WithAutoConversionFor(predicate: null));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_only_a_single_property_is_and_can_be_converted_but_the_other_one_doesnt_match_it_should_throw()\n {\n // Arrange\n var subject = new { Age = 32, Birthdate = \"1973-09-20\" };\n\n var expectation = new { Age = \"32\", Birthdate = new DateTime(1973, 9, 20) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.WithAutoConversionFor(x => x.Path.Contains(\"Birthdate\")));\n\n // Assert\n act.Should().Throw().WithMessage(\"*Age*String*int*\");\n }\n\n [Fact]\n public void When_only_a_single_property_is_converted_and_the_other_matches_it_should_succeed()\n {\n // Arrange\n var subject = new { Age = 32, Birthdate = \"1973-09-20\" };\n\n var expectation = new { Age = 32, Birthdate = new DateTime(1973, 9, 20) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .WithAutoConversionFor(x => x.Path.Contains(\"Birthdate\")));\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_WithoutAutoConversionFor_it_should_throw()\n {\n // Arrange\n var subject = new object();\n\n var expectation = new object();\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.WithoutAutoConversionFor(predicate: null));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_a_specific_mismatching_property_is_excluded_from_conversion_it_should_throw()\n {\n // Arrange\n var subject = new { Age = 32, Birthdate = \"1973-09-20\" };\n\n var expectation = new { Age = 32, Birthdate = new DateTime(1973, 9, 20) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, options => options\n .WithAutoConversion()\n .WithoutAutoConversionFor(x => x.Path.Contains(\"Birthdate\")));\n\n // Assert\n act.Should().Throw().Which.Message\n .Should().Match(\"Expected*<1973-09-20>*\\\"1973-09-20\\\"*\", \"{0} field is of mismatched type\",\n nameof(expectation.Birthdate))\n .And.Subject.Should().Match(\"*Try conversion of all members*\", \"conversion description should be present\")\n .And.Subject.Should().NotMatch(\"*Try conversion of all members*Try conversion of all members*\",\n \"conversion description should not be duplicated\");\n }\n\n [Fact]\n public void When_declaring_equivalent_a_convertable_object_that_is_equivalent_once_converted_it_should_pass()\n {\n // Arrange\n string str = \"This is a test\";\n CustomConvertible obj = new(str);\n\n // Act / Assert\n obj.Should().BeEquivalentTo(str, options => options.WithAutoConversion());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/Node.cs", "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\n\nnamespace AwesomeAssertions.Xml.Equivalency;\n\ninternal sealed class Node\n{\n private readonly List children = [];\n private readonly string name;\n private int count;\n\n public static Node CreateRoot() => new(null, null);\n\n private Node(Node parent, string name)\n {\n Parent = parent;\n this.name = name;\n }\n\n public string GetXPath()\n {\n var resultBuilder = new StringBuilder();\n\n foreach (Node location in GetPath().Reverse())\n {\n if (location.count > 1)\n {\n resultBuilder.AppendFormat(CultureInfo.InvariantCulture, \"/{0}[{1}]\", location.name, location.count);\n }\n else\n {\n resultBuilder.AppendFormat(CultureInfo.InvariantCulture, \"/{0}\", location.name);\n }\n }\n\n if (resultBuilder.Length == 0)\n {\n return \"/\";\n }\n\n return resultBuilder.ToString();\n }\n\n private IEnumerable GetPath()\n {\n Node current = this;\n\n while (current.Parent is not null)\n {\n yield return current;\n current = current.Parent;\n }\n }\n\n public Node Parent { get; }\n\n public Node Push(string localName)\n {\n Node node = children.Find(e => e.name == localName)\n ?? AddChildNode(localName);\n\n node.count++;\n\n return node;\n }\n\n public void Pop()\n {\n children.Clear();\n }\n\n private Node AddChildNode(string name)\n {\n var node = new Node(this, name);\n children.Add(node);\n return node;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XAttributeAssertions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XAttributeAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public XAttributeAssertions(XAttribute attribute, AssertionChain assertionChain)\n : base(attribute, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current equals the attribute.\n /// \n /// The expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(XAttribute expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject?.Name == expected?.Name && Subject?.Value == expected?.Value)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not equal the attribute,\n /// using its implementation.\n /// \n /// The unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(XAttribute unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!(Subject?.Name == unexpected?.Name && Subject?.Value == unexpected?.Value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the attribute to have value {0}{reason}, but {context:member} is .\", expected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(Subject!.Value == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} \\\"{0}\\\" to have value {1}{reason}, but found {2}.\",\n Subject.Name, expected, Subject.Value);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"XML attribute\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IMemberSelectionRule.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a rule that defines which members of the expectation to include while comparing\n/// two objects for structural equality.\n/// \npublic interface IMemberSelectionRule\n{\n /// \n /// Gets a value indicating whether this rule should override the default selection rules that include all members.\n /// \n bool IncludesMembers { get; }\n\n /// \n /// Adds or removes properties or fields to/from the collection of members that must be included while\n /// comparing two objects for structural equality.\n /// \n /// \n /// The node within the graph from which to select members.\n /// \n /// \n /// A collection of members that was pre-populated by other selection rules. Can be empty.\n /// Provides auxiliary information such as the configuration and such.\n /// \n /// The collection of members after applying this rule. Can contain less or more than was passed in.\n /// \n IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XDocumentAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Xml;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Xml.Equivalency;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XDocumentAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public XDocumentAssertions(XDocument document, AssertionChain assertionChain)\n : base(document, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current equals the document,\n /// using its implementation.\n /// \n /// The expected document\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(XDocument expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Equals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:subject} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not equal the document,\n /// using its implementation.\n /// \n /// The unexpected document\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(XDocument unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Equals(Subject, unexpected))\n .FailWith(\"Did not expect {context:subject} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is equivalent to the document,\n /// using its implementation.\n /// \n /// The expected document\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(XDocument expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (XmlReader subjectReader = Subject?.CreateReader())\n using (XmlReader otherReader = expected?.CreateReader())\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, otherReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: true);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not equivalent to the document,\n /// using its implementation.\n /// \n /// The unexpected document\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(XDocument unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (XmlReader subjectReader = Subject?.CreateReader())\n using (XmlReader otherReader = unexpected?.CreateReader())\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, otherReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: false);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a root element with the specified\n /// name.\n /// \n /// The name of the expected root element of the current document.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveRoot(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has a root element if the expected name is .\");\n\n return HaveRoot(XNamespace.None + expected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has a root element with the specified\n /// name.\n /// \n /// The full name of the expected root element of the current document.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveRoot(XName expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (Subject is null)\n {\n throw new InvalidOperationException(\n \"Cannot assert the document has a root element if the document itself is .\");\n }\n\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has a root element if the expected name is .\");\n\n XElement root = Subject.Root;\n\n assertionChain\n .ForCondition(root is not null && root.Name == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have root element {0}{reason}, but found {1}.\",\n expected.ToString(), Subject);\n\n return new AndWhichConstraint(this, root, assertionChain, $\"/{expected}\");\n }\n\n /// \n /// Asserts that the element of the current has a direct\n /// child element with the specified name.\n /// \n /// \n /// The name of the expected child element of the current document's element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveElement(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has an element if the expected name is .\");\n\n return HaveElement(XNamespace.None + expected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the element of the current has the specified occurrence of\n /// child elements with the specified name.\n /// \n /// \n /// The name of the expected child element of the current document's element.\n /// \n /// \n /// A constraint specifying the number of times the specified elements should appear.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint> HaveElement(string expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has an element if the expected name is .\");\n\n return HaveElement(XNamespace.None + expected, occurrenceConstraint, because, becauseArgs);\n }\n\n /// \n /// Asserts that the element of the current has a direct\n /// child element with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current document's element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveElement(XName expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (Subject is null)\n {\n throw new InvalidOperationException(\"Cannot assert the document has an element if the document itself is .\");\n }\n\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has an element if the expected name is .\");\n\n assertionChain\n .ForCondition(Subject.Root is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have root element with child {0}{reason}, but it has no root element.\",\n expected.ToString());\n\n XElement xElement = null;\n\n if (assertionChain.Succeeded)\n {\n xElement = Subject.Root!.Element(expected);\n\n assertionChain\n .ForCondition(xElement is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have root element with child {0}{reason}, but no such child element was found.\",\n expected.ToString());\n }\n\n return new AndWhichConstraint(this, xElement, assertionChain, \"/\" + expected);\n }\n\n /// \n /// Asserts that the element of the current has the specified occurrence of\n /// child elements with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current document's element.\n /// \n /// \n /// A constraint specifying the number of times the specified elements should appear.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint> HaveElement(XName expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has an element count if the element name is .\");\n\n IEnumerable xElements = [];\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Cannot assert the count if the document itself is .\")\n .Then\n .WithExpectation(\"Expected {context:subject} to have a root element containing a child {0}\",\n expected.ToString(), chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject.Root)\n .ForCondition(root => root is not null)\n .FailWith(\"{reason}, but it has no root element.\", expected.ToString())\n .Then\n .Given(root =>\n {\n xElements = root.Elements(expected);\n return xElements.Count();\n })\n .ForConstraint(occurrenceConstraint, actual => actual)\n .FailWith(actual => $\"{{expectedOccurrence}}{{reason}}, but found it {actual.Times()}.\"));\n\n return new AndWhichConstraint>(this, xElements, assertionChain,\n \"/\" + expected);\n }\n\n /// \n /// Asserts that the of the current doesn't have the specified child element.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElement(string unexpectedElement,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n\n return NotHaveElement(XNamespace.None + unexpectedElement, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current doesn't have the specified child element.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElement(XName unexpectedElement,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:subject} to have an element {0}{reason}, \", unexpectedElement, chain =>\n chain\n .ForCondition(Subject is not null)\n .FailWith(\"but the element itself is .\")\n .Then\n .ForCondition(!Subject!.Root!.Elements(unexpectedElement).Any())\n .FailWith(\" but the element {0} was found.\", unexpectedElement));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the of the current has the specified child element\n /// with the specified name.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// The expected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithValue(string expectedElement,\n string expectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedElement, nameof(expectedElement));\n Guard.ThrowIfArgumentIsNull(expectedValue, nameof(expectedValue));\n\n return HaveElementWithValue(XNamespace.None + expectedElement, expectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current has the specified child element\n /// with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// The expected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithValue(XName expectedElement,\n string expectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedElement, nameof(expectedElement));\n Guard.ThrowIfArgumentIsNull(expectedValue, nameof(expectedValue));\n\n IEnumerable xElements = [];\n\n assertionChain\n .WithExpectation(\"Expected {context:subject} to have an element {0} with value {1}{reason}, \",\n expectedElement.ToString(), expectedValue, chain => chain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"but the element itself is .\",\n expectedElement.ToString(), expectedValue)\n .Then\n .Given(() =>\n {\n xElements = Subject!.Root!.Elements(expectedElement).ToList();\n\n return xElements;\n })\n .ForCondition(collection => collection.Any())\n .FailWith(\"but the element {0} isn't found.\", expectedElement)\n .Then\n .ForCondition(collection => collection.Any(e => e.Value == expectedValue))\n .FailWith(\"but the element {0} does not have such a value.\", expectedElement));\n\n return new AndWhichConstraint(this, xElements.FirstOrDefault());\n }\n\n /// \n /// Asserts that the of the current either doesn't have the\n /// specified child element or doesn't have the specified .\n /// \n /// \n /// The name of the unexpected child element of the current element's .\n /// \n /// \n /// The unexpected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElementWithValue(string unexpectedElement,\n string unexpectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n return NotHaveElementWithValue(XNamespace.None + unexpectedElement, unexpectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current either doesn't have the\n /// specified child element or doesn't have the specified .\n /// \n /// \n /// he full name of the unexpected child element of the current element's .\n /// \n /// \n /// The unexpected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElementWithValue(XName unexpectedElement,\n string unexpectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:subject} to have an element {0} with value {1}{reason}, \",\n unexpectedElement, unexpectedValue, chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but the element itself is .\")\n .Then\n .ForCondition(!Subject!.Root!.Elements(unexpectedElement)\n .Any(e => e.Value == unexpectedValue))\n .FailWith(\"but the element {0} does have this value.\", unexpectedElement));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"XML document\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/XAttributeValueFormatter.cs", "using System.Xml.Linq;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class XAttributeValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is XAttribute;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((XAttribute)value).ToString());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Execution/ObjectReference.cs", "using System;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing AwesomeAssertions.Common;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency.Execution;\n\n/// \n/// Represents an object tracked by the including it's location within an object graph.\n/// \ninternal class ObjectReference\n{\n private readonly object @object;\n private readonly string path;\n private readonly bool? compareByMembers;\n private string[] pathElements;\n\n public ObjectReference(object @object, string path, bool? compareByMembers = null)\n {\n this.@object = @object;\n this.path = path;\n this.compareByMembers = compareByMembers;\n }\n\n /// \n /// Determines whether the specified is equal to the current .\n /// \n /// \n /// true if the specified is equal to the current ; otherwise, false.\n /// \n /// The to compare with the current . \n /// 2\n public override bool Equals(object obj)\n {\n return obj is ObjectReference other\n && ReferenceEquals(@object, other.@object) && IsParentOrChildOf(other);\n }\n\n private string[] GetPathElements() => pathElements\n ??= path.ToUpperInvariant().Replace(\"][\", \"].[\", StringComparison.Ordinal)\n .Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);\n\n private bool IsParentOrChildOf(ObjectReference other)\n {\n string[] elements = GetPathElements();\n string[] otherPath = other.GetPathElements();\n\n int commonElements = Math.Min(elements.Length, otherPath.Length);\n int longerPathAdditionalElements = Math.Max(elements.Length, otherPath.Length) - commonElements;\n\n return longerPathAdditionalElements > 0 && otherPath.Take(commonElements).SequenceEqual(elements.Take(commonElements));\n }\n\n /// \n /// Serves as a hash function for a particular type.\n /// \n /// \n /// A hash code for the current .\n /// \n /// 2\n public override int GetHashCode()\n {\n return RuntimeHelpers.GetHashCode(@object);\n }\n\n public override string ToString()\n {\n return Invariant($\"{{\\\"{path}\\\", {@object}}}\");\n }\n\n public bool CompareByMembers => compareByMembers ?? @object?.GetType().OverridesEquals() == false;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EnumEquivalencyHandling.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic enum EnumEquivalencyHandling\n{\n ByValue,\n ByName\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Configuration/GlobalConfiguration.cs", "namespace AwesomeAssertions.Configuration;\n\npublic class GlobalConfiguration\n{\n private TestFramework? testFramework;\n\n /// \n /// Provides access to the formatting defaults for all assertions.\n /// \n public GlobalFormattingOptions Formatting { get; set; } = new();\n\n /// \n /// Provides access to the defaults used by the structural equivalency assertions.\n /// \n public GlobalEquivalencyOptions Equivalency { get; set; } = new();\n\n /// \n /// Sets a specific test framework to be used by AwesomeAssertions when throwing assertion exceptions.\n /// \n /// \n /// If set to , the test framework will be automatically detected by scanning the appdomain.\n /// \n public TestFramework? TestFramework\n {\n get => testFramework;\n set\n {\n testFramework = value;\n AssertionEngine.TestFramework = null;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MemberFactory.cs", "using System;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\npublic static class MemberFactory\n{\n public static IMember Create(MemberInfo memberInfo, INode parent)\n {\n return memberInfo.MemberType switch\n {\n MemberTypes.Field => new Field((FieldInfo)memberInfo, parent),\n MemberTypes.Property => new Property((PropertyInfo)memberInfo, parent),\n _ => throw new NotSupportedException($\"Don't know how to deal with a {memberInfo.MemberType}\")\n };\n }\n\n internal static IMember Find(object target, string memberName, INode parent)\n {\n PropertyInfo property = target.GetType().FindProperty(memberName, MemberVisibility.Public | MemberVisibility.ExplicitlyImplemented);\n\n if (property is not null && !property.IsIndexer())\n {\n return new Property(property, parent);\n }\n\n FieldInfo field = target.GetType().FindField(memberName, MemberVisibility.Public);\n return field is not null ? new Field(field, parent) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/INode.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a node in the object graph that is being compared as part of a structural equivalency check.\n/// This can be the root object, a collection item, a dictionary element, a property or a field.\n/// \npublic interface INode\n{\n /// \n /// The name of the variable on which a structural equivalency assertion is executed or\n /// the default if reflection failed.\n /// \n GetSubjectId GetSubjectId { get; }\n\n /// \n /// Gets the type of this node, e.g. the type of the field or property, or the type of the collection item.\n /// \n Type Type { get; }\n\n /// \n /// Gets the type of the parent node, e.g. the type that declares a property or field.\n /// \n /// \n /// Is for the root object.\n /// \n Type ParentType { get; }\n\n /// \n /// Gets the path from the root of the subject upto and including the current node.\n /// \n Pathway Subject { get; internal set; }\n\n /// \n /// Gets the path from the root of the expectation upto and including the current node.\n /// \n Pathway Expectation { get; }\n\n /// \n /// Gets a zero-based number representing the depth within the object graph\n /// \n /// \n /// The root object has a depth of 0, the next nested object a depth of 1, etc.\n /// See also this article\n /// \n int Depth { get; }\n\n /// \n /// Gets a value indicating whether the current node is the root.\n /// \n bool IsRoot { get; }\n\n /// \n /// Gets a value indicating if the root of this graph is a collection.\n /// \n bool RootIsCollection { get; }\n\n /// \n /// Adjusts the current node to reflect a remapped subject member during a structural equivalency check.\n /// Ensures that assertion failures report the correct subject member name when the matching process selects\n /// a different member in the subject compared to the expectation.\n /// \n /// \n /// The specific member in the subject that the current node should be remapped to.\n /// \n void AdjustForRemappedSubject(IMember subjectMember);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedTheoryAttributeDiscoverer.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedTheoryAttributeDiscoverer : TheoryDiscoverer\n{\n public CulturedTheoryAttributeDiscoverer(IMessageSink diagnosticMessageSink)\n : base(diagnosticMessageSink)\n {\n }\n\n protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions,\n ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow)\n {\n var cultures = GetCultures(theoryAttribute);\n\n return cultures.Select(culture => new CulturedXunitTestCase(DiagnosticMessageSink,\n discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, culture,\n dataRow)).ToList();\n }\n\n protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions,\n ITestMethod testMethod, IAttributeInfo theoryAttribute)\n {\n var cultures = GetCultures(theoryAttribute);\n\n return cultures.Select(culture => new CulturedXunitTheoryTestCase(DiagnosticMessageSink,\n discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, culture))\n .ToList();\n }\n\n private static string[] GetCultures(IAttributeInfo culturedTheoryAttribute)\n {\n var ctorArgs = culturedTheoryAttribute.GetConstructorArguments().ToArray();\n var cultures = Reflector.ConvertArguments(ctorArgs, [typeof(string[])]).Cast().Single();\n\n if (cultures is null || cultures.Length == 0)\n {\n cultures = [\"en-US\", \"fr-FR\"];\n }\n\n return cultures;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AssertionExtensionsSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Numeric;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Specialized;\nusing AwesomeAssertions.Types;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class AssertionExtensionsSpecs\n{\n [Fact]\n public void Assertions_classes_override_equals()\n {\n // Arrange / Act\n var equalsOverloads = AllTypes.From(typeof(AwesomeAssertions.AssertionExtensions).Assembly)\n .ThatAreClasses()\n .Where(t => t.IsPublic && t.Name.TrimEnd('`', '1', '2', '3').EndsWith(\"Assertions\", StringComparison.Ordinal))\n .Select(e => GetMostParentType(e))\n .Distinct()\n .Select(t => (type: t, overridesEquals: OverridesEquals(t)))\n .ToList();\n\n // Assert\n equalsOverloads.Should().OnlyContain(e => e.overridesEquals);\n }\n\n private static bool OverridesEquals(Type t)\n {\n MethodInfo equals = t.GetMethod(\"Equals\", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public,\n null, [typeof(object)], null);\n\n return equals is not null;\n }\n\n public static TheoryData ClassesWithGuardEquals =>\n [\n new ObjectAssertions(default, AssertionChain.GetOrCreate()),\n new BooleanAssertions(default, AssertionChain.GetOrCreate()),\n new DateTimeAssertions(default, AssertionChain.GetOrCreate()),\n new DateTimeRangeAssertions(default, AssertionChain.GetOrCreate(), default, default, default),\n new DateTimeOffsetAssertions(default, AssertionChain.GetOrCreate()),\n new DateTimeOffsetRangeAssertions(default, AssertionChain.GetOrCreate(), default, default, default),\n new ExecutionTimeAssertions(new ExecutionTime(() => { }, () => new StopwatchTimer()), AssertionChain.GetOrCreate()),\n new GuidAssertions(default, AssertionChain.GetOrCreate()),\n new MethodInfoSelectorAssertions(AssertionChain.GetOrCreate()),\n new NumericAssertions>(default, AssertionChain.GetOrCreate()),\n new PropertyInfoSelectorAssertions(AssertionChain.GetOrCreate()),\n new SimpleTimeSpanAssertions(default, AssertionChain.GetOrCreate()),\n new TaskCompletionSourceAssertions(default, AssertionChain.GetOrCreate()),\n new TypeSelectorAssertions(AssertionChain.GetOrCreate()),\n new EnumAssertions>(default, AssertionChain.GetOrCreate()),\n#if NET6_0_OR_GREATER\n new DateOnlyAssertions(default, AssertionChain.GetOrCreate()),\n new TimeOnlyAssertions(default, AssertionChain.GetOrCreate()),\n#endif\n ];\n\n [Theory]\n [MemberData(nameof(ClassesWithGuardEquals))]\n public void Guarding_equals_throws(object obj)\n {\n // Act\n Action act = () => obj.Equals(null);\n\n // Assert\n act.Should().ThrowExactly();\n }\n\n [Theory]\n [InlineData(typeof(ReferenceTypeAssertions))]\n [InlineData(typeof(BooleanAssertions))]\n [InlineData(typeof(DateTimeAssertions))]\n [InlineData(typeof(DateTimeRangeAssertions))]\n [InlineData(typeof(DateTimeOffsetAssertions))]\n [InlineData(typeof(DateTimeOffsetRangeAssertions))]\n [InlineData(typeof(ExecutionTimeAssertions))]\n [InlineData(typeof(GuidAssertions))]\n [InlineData(typeof(MethodInfoSelectorAssertions))]\n [InlineData(typeof(PropertyInfoSelectorAssertions))]\n [InlineData(typeof(SimpleTimeSpanAssertions))]\n [InlineData(typeof(TaskCompletionSourceAssertionsBase))]\n [InlineData(typeof(TypeSelectorAssertions))]\n [InlineData(typeof(EnumAssertions>))]\n#if NET6_0_OR_GREATER\n [InlineData(typeof(DateOnlyAssertions))]\n [InlineData(typeof(TimeOnlyAssertions))]\n#endif\n public void Fake_should_method_throws(Type type)\n {\n // Arrange\n MethodInfo fakeOverload = AllTypes.From(typeof(AwesomeAssertions.AssertionExtensions).Assembly)\n .ThatAreClasses()\n .ThatAreStatic()\n .Where(t => t.IsPublic)\n .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public))\n .Single(m => m.Name == \"Should\" && IsGuardOverload(m)\n && m.GetParameters().Single().ParameterType.Name == type.Name);\n\n if (type.IsConstructedGenericType)\n {\n fakeOverload = fakeOverload.MakeGenericMethod(type.GenericTypeArguments);\n }\n\n // Act\n Action act = () => fakeOverload.Invoke(null, [null]);\n\n // Assert\n act.Should()\n .ThrowExactly()\n .WithInnerExceptionExactly()\n .WithMessage(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'.\");\n }\n\n [Fact]\n public void Should_methods_have_a_matching_overload_to_guard_against_chaining_and_constraints()\n {\n // Arrange / Act\n List shouldOverloads = AllTypes.From(typeof(AwesomeAssertions.AssertionExtensions).Assembly)\n .ThatAreClasses()\n .ThatAreStatic()\n .Where(t => t.IsPublic)\n .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public))\n .Where(m => m.Name == \"Should\")\n .ToList();\n\n List realOverloads =\n [\n ..shouldOverloads\n .Where(m => !IsGuardOverload(m))\n .Select(t => GetMostParentType(t.ReturnType))\n .Distinct(),\n\n // @jnyrup: DateTimeRangeAssertions and DateTimeOffsetRangeAssertions are manually added here,\n // because they expose AndConstraints,\n // and hence should have a guarding Should(DateTimeRangeAssertions _) overloads,\n // but they do not have a regular Should() overload,\n // as they are always constructed through the fluent API.\n typeof(DateTimeRangeAssertions<>),\n typeof(DateTimeOffsetRangeAssertions<>)\n ];\n\n List fakeOverloads = shouldOverloads\n .Where(m => IsGuardOverload(m))\n .Select(e => e.GetParameters()[0].ParameterType)\n .ToList();\n\n // Assert\n fakeOverloads.Should().BeEquivalentTo(realOverloads, opt => opt\n .Using(ctx => ctx.Subject.Name.Should().Be(ctx.Expectation.Name))\n .WhenTypeIs(),\n \"AssertionExtensions.cs should have a guard overload of Should calling InvalidShouldCall()\");\n }\n\n [Theory]\n [MemberData(nameof(GetShouldMethods), true)]\n public void Should_methods_returning_reference_type_assertions_are_annotated_with_not_null_attribute(MethodInfo method)\n {\n var notNullAttribute = method.GetParameters().Single().GetCustomAttribute();\n notNullAttribute.Should().NotBeNull();\n }\n\n [Theory]\n [MemberData(nameof(GetShouldMethods), false)]\n public void Should_methods_not_returning_reference_type_assertions_are_not_annotated_with_not_null_attribute(MethodInfo method)\n {\n var notNullAttribute = method.GetParameters().Single().GetCustomAttribute();\n notNullAttribute.Should().BeNull();\n }\n\n public static TheoryData GetShouldMethods(bool referenceTypes)\n {\n return new(AllTypes.From(typeof(AwesomeAssertions.AssertionExtensions).Assembly)\n .ThatAreClasses()\n .ThatAreStatic()\n .Where(t => t.IsPublic)\n .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public))\n .Where(m => m.Name == \"Should\"\n && !IsGuardOverload(m)\n && m.GetParameters().Length == 1\n && (referenceTypes ? ReturnsReferenceTypeAssertions(m) : !ReturnsReferenceTypeAssertions(m))));\n }\n\n private static bool ReturnsReferenceTypeAssertions(MethodInfo m) =>\n m.ReturnType.IsAssignableToOpenGeneric(typeof(ReferenceTypeAssertions<,>));\n\n private static bool IsGuardOverload(MethodInfo m) =>\n m.ReturnType == typeof(void) && m.IsDefined(typeof(ObsoleteAttribute));\n\n private static Type GetMostParentType(Type type)\n {\n while (type.BaseType != typeof(object))\n {\n type = type.BaseType;\n }\n\n if (type.IsGenericType)\n {\n type = type.GetGenericTypeDefinition();\n }\n\n return type;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/OrderingRuleCollection.cs", "using System.Collections;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Equivalency.Ordering;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Collection of s.\n/// \npublic class OrderingRuleCollection : IEnumerable\n{\n private readonly List rules = [];\n\n /// \n /// Initializes a new collection of ordering rules.\n /// \n public OrderingRuleCollection()\n {\n }\n\n /// \n /// Initializes a new collection of ordering rules based on an existing collection of ordering rules.\n /// \n public OrderingRuleCollection(IEnumerable orderingRules)\n {\n rules.AddRange(orderingRules);\n }\n\n /// \n /// Returns an enumerator that iterates through the collection.\n /// \n /// \n /// A that can be used to iterate through the collection.\n /// \n /// 1\n public IEnumerator GetEnumerator()\n {\n return rules.GetEnumerator();\n }\n\n /// \n /// Returns an enumerator that iterates through a collection.\n /// \n /// \n /// An object that can be used to iterate through the collection.\n /// \n /// 2\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public void Add(IOrderingRule rule)\n {\n rules.Add(rule);\n }\n\n internal void Clear()\n {\n rules.Clear();\n }\n\n /// \n /// Determines whether the rules in this collection dictate strict ordering during the equivalency assertion on\n /// the collection pointed to by .\n /// \n public bool IsOrderingStrictFor(IObjectInfo objectInfo)\n {\n List results = rules.ConvertAll(r => r.Evaluate(objectInfo));\n return results.Contains(OrderStrictness.Strict) && !results.Contains(OrderStrictness.NotStrict);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MemberVisibilityExtensions.cs", "using System;\nusing System.Collections.Concurrent;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal static class MemberVisibilityExtensions\n{\n private static readonly ConcurrentDictionary Cache = new();\n\n public static MemberKind ToMemberKind(this MemberVisibility visibility)\n {\n return Cache.GetOrAdd(visibility, static v =>\n {\n MemberKind result = MemberKind.None;\n\n#if NET6_0_OR_GREATER\n var flags = Enum.GetValues();\n#else\n var flags = (MemberVisibility[])Enum.GetValues(typeof(MemberVisibility));\n#endif\n foreach (MemberVisibility flag in flags)\n {\n if (v.HasFlag(flag))\n {\n var convertedFlag = flag switch\n {\n MemberVisibility.None => MemberKind.None,\n MemberVisibility.Internal => MemberKind.Internal,\n MemberVisibility.Public => MemberKind.Public,\n MemberVisibility.ExplicitlyImplemented => MemberKind.ExplicitlyImplemented,\n MemberVisibility.DefaultInterfaceProperties => MemberKind.DefaultInterfaceProperties,\n _ => throw new ArgumentOutOfRangeException(nameof(v), v, null)\n };\n\n result |= convertedFlag;\n }\n }\n\n return result;\n });\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/MemberPath.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Encapsulates a dotted candidate to a (nested) member of a type as well as the\n/// declaring type of the deepest member.\n/// \ninternal class MemberPath\n{\n private readonly string dottedPath;\n private readonly Type reflectedType;\n private readonly Type declaringType;\n\n private string[] segments;\n\n private static readonly MemberPathSegmentEqualityComparer MemberPathSegmentEqualityComparer = new();\n\n public MemberPath(IMember member, string parentPath)\n : this(member.ReflectedType, member.DeclaringType, parentPath.Combine(member.Expectation.Name))\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// is .\n public MemberPath(Type reflectedType, Type declaringType, string dottedPath)\n : this(dottedPath)\n {\n this.reflectedType = reflectedType;\n this.declaringType = declaringType;\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// is .\n public MemberPath(string dottedPath)\n {\n Guard.ThrowIfArgumentIsNull(\n dottedPath, nameof(dottedPath),\n \"A member path cannot be null\");\n\n this.dottedPath = dottedPath;\n }\n\n /// \n /// Gets a value indicating whether the current object represents a child member of the \n /// or that it is the parent of that candidate.\n /// \n public bool IsParentOrChildOf(MemberPath candidate)\n {\n return IsParentOf(candidate) || IsChildOf(candidate);\n }\n\n public bool IsSameAs(MemberPath candidate)\n {\n if (declaringType == candidate.declaringType || declaringType?.IsAssignableFrom(candidate.reflectedType) == true)\n {\n string[] candidateSegments = candidate.Segments;\n\n return candidateSegments.SequenceEqual(Segments, MemberPathSegmentEqualityComparer);\n }\n\n return false;\n }\n\n private bool IsParentOf(MemberPath candidate)\n {\n string[] candidateSegments = candidate.Segments;\n\n return candidateSegments.Length > Segments.Length &&\n candidateSegments.Take(Segments.Length).SequenceEqual(Segments, MemberPathSegmentEqualityComparer);\n }\n\n private bool IsChildOf(MemberPath candidate)\n {\n string[] candidateSegments = candidate.Segments;\n\n return candidateSegments.Length < Segments.Length\n && candidateSegments.SequenceEqual(Segments.Take(candidateSegments.Length),\n MemberPathSegmentEqualityComparer);\n }\n\n public MemberPath AsParentCollectionOf(MemberPath nextPath)\n {\n var extendedDottedPath = dottedPath.Combine(nextPath.dottedPath, \"[]\");\n return new MemberPath(nextPath.reflectedType, nextPath.declaringType, extendedDottedPath);\n }\n\n /// \n /// Determines whether the current path is the same as when ignoring any specific indexes.\n /// \n public bool IsEquivalentTo(string path)\n {\n return path.WithoutSpecificCollectionIndices() == dottedPath.WithoutSpecificCollectionIndices();\n }\n\n public bool HasSameParentAs(MemberPath path)\n {\n return Segments.Length == path.Segments.Length\n && GetParentSegments().SequenceEqual(path.GetParentSegments(), MemberPathSegmentEqualityComparer);\n }\n\n private IEnumerable GetParentSegments() => Segments.Take(Segments.Length - 1);\n\n /// \n /// Gets a value indicating whether the current path contains an indexer like `[1]` instead of `[]`.\n /// \n public bool GetContainsSpecificCollectionIndex() => dottedPath.ContainsSpecificCollectionIndex();\n\n private string[] Segments =>\n segments ??= dottedPath\n .Replace(\"[]\", \"[*]\", StringComparison.Ordinal)\n .Split(new[] { '.', '[', ']' }, StringSplitOptions.RemoveEmptyEntries);\n\n /// \n /// Returns a copy of the current object as if it represented an un-indexed item in a collection.\n /// \n public MemberPath WithCollectionAsRoot()\n {\n return new MemberPath(reflectedType, declaringType, \"[].\" + dottedPath);\n }\n\n /// \n /// Returns the name of the member the current path points to without its parent path.\n /// \n public string MemberName => Segments[^1];\n\n public override string ToString()\n {\n return dottedPath;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IMember.cs", "using System;\nusing System.ComponentModel;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Exposes information about an object's member\n/// \npublic interface IMember : INode\n{\n /// \n /// Gets the type that declares the current member.\n /// \n Type DeclaringType { get; }\n\n /// \n /// Gets the type that was used to determine this member.\n /// \n Type ReflectedType { get; }\n\n /// \n /// Gets the value of the member from the provided \n /// \n object GetValue(object obj);\n\n /// \n /// Gets the access modifier for the getter of this member.\n /// \n CSharpAccessModifier GetterAccessibility { get; }\n\n /// \n /// Gets the access modifier for the setter of this member.\n /// \n CSharpAccessModifier SetterAccessibility { get; }\n\n /// \n /// Gets a value indicating whether the member is browsable in the source code editor. This is controlled with\n /// .\n /// \n bool IsBrowsable { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/PredicateBasedOrderingRule.cs", "using System;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Equivalency.Ordering;\n\ninternal class PredicateBasedOrderingRule : IOrderingRule\n{\n private readonly Func predicate;\n private readonly string description;\n\n public PredicateBasedOrderingRule(Expression> predicate)\n {\n description = predicate.Body.ToString();\n this.predicate = predicate.Compile();\n }\n\n public bool Invert { get; init; }\n\n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n if (predicate(objectInfo))\n {\n return Invert ? OrderStrictness.NotStrict : OrderStrictness.Strict;\n }\n\n return OrderStrictness.Irrelevant;\n }\n\n public override string ToString()\n {\n return $\"Be {(Invert ? \"not strict\" : \"strict\")} about the order of collections when {description}\";\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.MemberHiding.cs", "using System;\nusing JetBrains.Annotations;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class MemberHiding\n {\n [Fact]\n public void Ignores_properties_hidden_by_the_derived_class()\n {\n // Arrange\n var subject = new SubclassAHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithProperty)subject).Property = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((AnotherBaseWithProperty)expectation).Property = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Ignores_properties_of_the_same_runtime_types_hidden_by_the_derived_class()\n {\n // Arrange\n var subject = new SubclassHidingStringProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithStringProperty)subject).Property = \"ActualBaseValue\";\n\n var expectation = new SubclassHidingStringProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithStringProperty)expectation).Property = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Includes_hidden_property_of_the_base_when_using_a_reference_to_the_base()\n {\n // Arrange\n BaseWithProperty subject = new SubclassAHidingProperty\n {\n Property = \"ActualDerivedValue\"\n };\n\n // AA doesn't know the compile-time type of the subject, so even though we pass a reference to the base-class,\n // at run-time, it'll start finding the property on the subject starting from the run-time type, and thus ignore the\n // hidden base-class field\n ((SubclassAHidingProperty)subject).Property = \"BaseValue\";\n\n AnotherBaseWithProperty expectation = new SubclassBHidingProperty\n {\n Property = \"ExpectedDerivedValue\"\n };\n\n expectation.Property = \"BaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Run_type_typing_ignores_hidden_properties_even_when_using_a_reference_to_the_base_class()\n {\n // Arrange\n var subject = new SubclassAHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithProperty)subject).Property = \"ActualBaseValue\";\n\n AnotherBaseWithProperty expectation = new SubclassBHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n expectation.Property = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o.PreferringRuntimeMemberTypes());\n }\n\n [Fact]\n public void Including_the_derived_property_excludes_the_hidden_property()\n {\n // Arrange\n var subject = new SubclassAHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithProperty)subject).Property = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((AnotherBaseWithProperty)expectation).Property = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opt => opt\n .Including(o => o.Property));\n }\n\n [Fact]\n public void Excluding_the_property_hiding_the_base_class_one_does_not_reveal_the_latter()\n {\n // Arrange\n var subject = new SubclassAHidingProperty();\n\n ((BaseWithProperty)subject).Property = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingProperty();\n\n ((AnotherBaseWithProperty)expectation).Property = \"ExpectedBaseValue\";\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, o => o\n .Excluding(b => b.Property));\n\n // Assert\n act.Should().Throw().WithMessage(\"*No members were found *\");\n }\n\n private class BaseWithProperty\n {\n [UsedImplicitly]\n public object Property { get; set; }\n }\n\n private class SubclassAHidingProperty : BaseWithProperty\n {\n [UsedImplicitly]\n public new T Property { get; set; }\n }\n\n private class BaseWithStringProperty\n {\n [UsedImplicitly]\n public string Property { get; set; }\n }\n\n private class SubclassHidingStringProperty : BaseWithStringProperty\n {\n [UsedImplicitly]\n public new string Property { get; set; }\n }\n\n private class AnotherBaseWithProperty\n {\n [UsedImplicitly]\n public object Property { get; set; }\n }\n\n private class SubclassBHidingProperty : AnotherBaseWithProperty\n {\n public new T Property\n {\n get;\n set;\n }\n }\n\n [Fact]\n public void Ignores_fields_hidden_by_the_derived_class()\n {\n // Arrange\n var subject = new SubclassAHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((BaseWithField)subject).Field = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((AnotherBaseWithField)expectation).Field = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.IncludingFields());\n }\n\n [Fact]\n public void Includes_hidden_field_of_the_base_when_using_a_reference_to_the_base()\n {\n // Arrange\n BaseWithField subject = new SubclassAHidingField\n {\n Field = \"BaseValueFromSubject\"\n };\n\n // AA doesn't know the compile-time type of the subject, so even though we pass a reference to the base-class,\n // at run-time, it'll start finding the field on the subject starting from the run-time type, and thus ignore the\n // hidden base-class field\n ((SubclassAHidingField)subject).Field = \"BaseValueFromExpectation\";\n\n AnotherBaseWithField expectation = new SubclassBHidingField\n {\n Field = \"ExpectedDerivedValue\"\n };\n\n expectation.Field = \"BaseValueFromExpectation\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.IncludingFields());\n }\n\n [Fact]\n public void Run_type_typing_ignores_hidden_fields_even_when_using_a_reference_to_the_base_class()\n {\n // Arrange\n var subject = new SubclassAHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((BaseWithField)subject).Field = \"ActualBaseValue\";\n\n AnotherBaseWithField expectation = new SubclassBHidingField\n {\n Field = \"DerivedValue\"\n };\n\n expectation.Field = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.IncludingFields().PreferringRuntimeMemberTypes());\n }\n\n [Fact]\n public void Including_the_derived_field_excludes_the_hidden_field()\n {\n // Arrange\n var subject = new SubclassAHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((BaseWithField)subject).Field = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((AnotherBaseWithField)expectation).Field = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .IncludingFields()\n .Including(o => o.Field));\n }\n\n [Fact]\n public void Excluding_the_field_hiding_the_base_class_one_does_not_reveal_the_latter()\n {\n // Arrange\n var subject = new SubclassAHidingField();\n\n ((BaseWithField)subject).Field = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingField();\n\n ((AnotherBaseWithField)expectation).Field = \"ExpectedBaseValue\";\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, options => options\n .IncludingFields()\n .Excluding(b => b.Field));\n\n // Assert\n act.Should().Throw().WithMessage(\"*No members were found *\");\n }\n\n private class BaseWithField\n {\n [UsedImplicitly]\n public string Field;\n }\n\n private class SubclassAHidingField : BaseWithField\n {\n [UsedImplicitly]\n public new string Field;\n }\n\n private class AnotherBaseWithField\n {\n [UsedImplicitly]\n public string Field;\n }\n\n private class SubclassBHidingField : AnotherBaseWithField\n {\n [UsedImplicitly]\n public new string Field;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Covariance.cs", "#if NET5_0_OR_GREATER\n\nusing System;\nusing JetBrains.Annotations;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Covariance\n {\n [Fact]\n public void Excluding_a_covariant_property_should_work()\n {\n // Arrange\n var actual = new DerivedWithCovariantOverride(new DerivedWithProperty\n {\n DerivedProperty = \"a\",\n BaseProperty = \"a_base\"\n })\n {\n OtherProp = \"other\"\n };\n\n var expectation = new DerivedWithCovariantOverride(new DerivedWithProperty\n {\n DerivedProperty = \"b\",\n BaseProperty =\n \"b_base\"\n })\n {\n OtherProp = \"other\"\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(d => d.Property));\n }\n\n [Fact]\n public void Excluding_a_covariant_property_through_the_base_class_excludes_the_base_class_property()\n {\n // Arrange\n var actual = new DerivedWithCovariantOverride(new DerivedWithProperty\n {\n DerivedProperty = \"a\",\n BaseProperty = \"a_base\"\n })\n {\n OtherProp = \"other\"\n };\n\n BaseWithAbstractProperty expectation = new DerivedWithCovariantOverride(new DerivedWithProperty\n {\n DerivedProperty =\n \"b\",\n BaseProperty = \"b_base\"\n })\n {\n OtherProp = \"other\"\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(d => d.Property));\n\n // Assert\n act.Should().Throw().WithMessage(\"No members*\");\n }\n\n private class BaseWithProperty\n {\n [UsedImplicitly]\n public string BaseProperty { get; set; }\n }\n\n private class DerivedWithProperty : BaseWithProperty\n {\n [UsedImplicitly]\n public string DerivedProperty { get; set; }\n }\n\n private abstract class BaseWithAbstractProperty\n {\n public abstract BaseWithProperty Property { get; }\n }\n\n private sealed class DerivedWithCovariantOverride : BaseWithAbstractProperty\n {\n public override DerivedWithProperty Property { get; }\n\n [UsedImplicitly]\n public string OtherProp { get; set; }\n\n public DerivedWithCovariantOverride(DerivedWithProperty prop)\n {\n Property = prop;\n }\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IAssertionContext.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides the required information for executing an equality assertion between a subject and an expectation.\n/// \n/// The type of the subject.\npublic interface IAssertionContext\n{\n /// \n /// Gets the of the member that returned the current object, or if the current\n /// object represents the root object.\n /// \n INode SelectedNode { get; }\n\n /// \n /// Gets the value of the \n /// \n TSubject Subject { get; }\n\n /// \n /// Gets the value of the expectation object that was matched with the subject using a .\n /// \n TSubject Expectation { get; }\n\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n string Because { get; set; }\n\n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n object[] BecauseArgs { get; set; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/EnumSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class EnumSpecs\n{\n [Fact]\n public void When_asserting_the_same_enum_member_is_equivalent_it_should_succeed()\n {\n // Arrange\n object subject = EnumOne.One;\n object expectation = EnumOne.One;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_the_actual_enum_value_is_null_it_should_report_that_properly()\n {\n // Arrange\n var subject = new { NullableEnum = (DayOfWeek?)null };\n\n var expectation = new { NullableEnum = DayOfWeek.Friday };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*5*null*\");\n }\n\n [Fact]\n public void When_the_actual_enum_name_is_null_it_should_report_that_properly()\n {\n // Arrange\n var subject = new { NullableEnum = (DayOfWeek?)null };\n\n var expectation = new { NullableEnum = DayOfWeek.Friday };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, o => o.ComparingEnumsByValue());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*5*null*\");\n }\n\n [Fact]\n public void When_asserting_different_enum_members_are_equivalent_it_should_fail()\n {\n // Arrange\n object subject = EnumOne.One;\n object expectation = EnumOne.Two;\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected *EnumOne.Two {value: 3}*but*EnumOne.One {value: 0}*\");\n }\n\n [Fact]\n public void Comparing_collections_of_enums_by_value_includes_custom_message()\n {\n // Arrange\n EnumOne[] subject = [EnumOne.One];\n EnumOne[] expectation = [EnumOne.Two];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, \"some {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected *EnumOne.Two {value: 3}*some reason*but*EnumOne.One {value: 0}*\");\n }\n\n [Fact]\n public void Comparing_collections_of_enums_by_name_includes_custom_message()\n {\n // Arrange\n EnumOne[] subject = [EnumOne.Two];\n EnumFour[] expectation = [EnumFour.Three];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByName(),\n \"some {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to equal EnumFour.Three {value: 3} by name*some reason*but found EnumOne.Two {value: 3}*\");\n }\n\n [Fact]\n public void Comparing_collections_of_numerics_with_collections_of_enums_includes_custom_message()\n {\n // Arrange\n int[] actual = [1];\n\n TestEnum[] expected = [TestEnum.First];\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByValue(),\n \"some {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*some reason*\");\n }\n\n [Fact]\n public void When_asserting_members_from_different_enum_types_are_equivalent_it_should_compare_by_value_by_default()\n {\n // Arrange\n var subject = new ClassWithEnumOne();\n var expectation = new ClassWithEnumTwo();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_asserting_members_from_different_enum_types_are_equivalent_by_value_it_should_succeed()\n {\n // Arrange\n var subject = new ClassWithEnumOne { Enum = EnumOne.One };\n var expectation = new ClassWithEnumThree { Enum = EnumThree.ValueZero };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByValue());\n }\n\n [Fact]\n public void When_asserting_members_from_different_enum_types_are_equivalent_by_string_value_it_should_succeed()\n {\n // Arrange\n var subject = new ClassWithEnumOne { Enum = EnumOne.Two };\n\n var expectation = new ClassWithEnumThree { Enum = EnumThree.Two };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByName());\n }\n\n [Fact]\n public void\n When_asserting_members_from_different_enum_types_are_equivalent_by_value_but_comparing_by_name_it_should_throw()\n {\n // Arrange\n var subject = new ClassWithEnumOne { Enum = EnumOne.Two };\n var expectation = new ClassWithEnumFour { Enum = EnumFour.Three };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByName());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to equal EnumFour.Three {value: 3} by name, but found EnumOne.Two {value: 3}*\");\n }\n\n [Fact]\n public void When_asserting_members_from_different_char_enum_types_are_equivalent_by_value_it_should_succeed()\n {\n // Arrange\n var subject = new ClassWithEnumCharOne { Enum = EnumCharOne.B };\n var expectation = new ClassWithEnumCharTwo { Enum = EnumCharTwo.ValueB };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByValue());\n }\n\n [Fact]\n public void When_asserting_enums_typed_as_object_are_equivalent_it_should_succeed()\n {\n // Arrange\n object e1 = EnumOne.One;\n object e2 = EnumOne.One;\n\n // Act / Assert\n e1.Should().BeEquivalentTo(e2);\n }\n\n [Fact]\n public void When_a_numeric_member_is_compared_with_an_enum_it_should_throw()\n {\n // Arrange\n var actual = new { Property = 1 };\n\n var expected = new { Property = TestEnum.First };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByValue());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_string_member_is_compared_with_an_enum_it_should_throw()\n {\n // Arrange\n var actual = new { Property = \"First\" };\n\n var expected = new { Property = TestEnum.First };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByName());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_null_enum_members_are_compared_by_name_it_should_succeed()\n {\n // Arrange\n var actual = new { Property = null as TestEnum? };\n\n var expected = new { Property = null as TestEnum? };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByName());\n }\n\n [Fact]\n public void When_null_enum_members_are_compared_by_value_it_should_succeed()\n {\n // Arrange\n var actual = new { Property = null as TestEnum? };\n\n var expected = new { Property = null as TestEnum? };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByValue());\n }\n\n [Fact]\n public void When_zero_and_null_enum_are_compared_by_value_it_should_throw()\n {\n // Arrange\n var actual = new { Property = (TestEnum)0 };\n\n var expected = new { Property = null as TestEnum? };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByValue());\n\n // Assert\n act.Should().Throw();\n }\n\n public enum TestEnum\n {\n First = 1\n }\n\n [Fact]\n public void When_subject_is_null_and_enum_has_some_value_it_should_throw()\n {\n // Arrange\n object subject = null;\n object expectedEnum = EnumULong.UInt64Max;\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expectedEnum, x => x.ComparingEnumsByName(), \"comparing enums should throw\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected*to be equivalent to EnumULong.UInt64Max {value: 18446744073709551615} because comparing enums should throw, but found *\");\n }\n\n [Fact]\n public void When_expectation_is_null_and_subject_enum_has_some_value_it_should_throw_with_a_useful_message()\n {\n // Arrange\n object subjectEnum = EnumULong.UInt64Max;\n object expected = null;\n\n // Act\n Action act = () =>\n subjectEnum.Should().BeEquivalentTo(expected, x => x.ComparingEnumsByName(), \"comparing enums should throw\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to be because comparing enums should throw, but found EnumULong.UInt64Max*\");\n }\n\n [Fact]\n public void When_both_enums_are_equal_and_greater_than_max_long_it_should_not_throw()\n {\n // Arrange\n object enumOne = EnumULong.UInt64Max;\n object enumTwo = EnumULong.UInt64Max;\n\n // Act / Assert\n enumOne.Should().BeEquivalentTo(enumTwo);\n }\n\n [Fact]\n public void When_both_enums_are_equal_and_of_different_underlying_types_it_should_not_throw()\n {\n // Arrange\n object enumOne = EnumLong.Int64Max;\n object enumTwo = EnumULong.Int64Max;\n\n // Act / Assert\n enumOne.Should().BeEquivalentTo(enumTwo);\n }\n\n [Fact]\n public void When_both_enums_are_large_and_not_equal_it_should_throw()\n {\n // Arrange\n object subjectEnum = EnumLong.Int64LessOne;\n object expectedEnum = EnumULong.UInt64Max;\n\n // Act\n Action act = () => subjectEnum.Should().BeEquivalentTo(expectedEnum, \"comparing enums should throw\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected subjectEnum*to equal EnumULong.UInt64Max {value: 18446744073709551615} by value because comparing enums should throw, but found EnumLong.Int64LessOne {value: 9223372036854775806}*\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/DateTimePropertiesSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class DateTimePropertiesSpecs\n{\n [Fact]\n public void When_two_properties_are_datetime_and_both_are_nullable_and_both_are_null_it_should_succeed()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)null };\n\n var other =\n new { Time = (DateTime?)null };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_two_properties_are_datetime_and_both_are_nullable_and_are_equal_it_should_succeed()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void\n When_two_properties_are_datetime_and_both_are_nullable_and_expectation_is_null_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = (DateTime?)null };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Time to be , but found <2013-12-09 15:58:00>.*\");\n }\n\n [Fact]\n public void\n When_two_properties_are_datetime_and_both_are_nullable_and_subject_is_null_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)null };\n\n var other =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Time*to be <2013-12-09 15:58:00>, but found .*\");\n }\n\n [Fact]\n public void When_two_properties_are_datetime_and_expectation_is_nullable_and_are_equal_it_should_succeed()\n {\n // Arrange\n var subject =\n new { Time = new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void\n When_two_properties_are_datetime_and_expectation_is_nullable_and_expectation_is_null_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject =\n new { Time = new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = (DateTime?)null };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Time*to be , but found <2013-12-09 15:58:00>.*\");\n }\n\n [Fact]\n public void When_two_properties_are_datetime_and_subject_is_nullable_and_are_equal_it_should_succeed()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void\n When_two_properties_are_datetime_and_subject_is_nullable_and_subject_is_null_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)null };\n\n var other =\n new { Time = new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Time*to be <2013-12-09 15:58:00>, but found .*\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/PathBasedOrderingRule.cs", "using System;\nusing System.Text.RegularExpressions;\n\nnamespace AwesomeAssertions.Equivalency.Ordering;\n\n/// \n/// Represents a rule for determining whether or not a certain collection within the object graph should be compared using\n/// strict ordering.\n/// \ninternal class PathBasedOrderingRule : IOrderingRule\n{\n private readonly string path;\n\n public PathBasedOrderingRule(string path)\n {\n this.path = path;\n }\n\n public bool Invert { get; init; }\n\n /// \n /// Determines if ordering of the member referred to by the current is relevant.\n /// \n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n string currentPropertyPath = objectInfo.Path;\n\n if (!ContainsIndexingQualifiers(path))\n {\n currentPropertyPath = RemoveInitialIndexQualifier(currentPropertyPath);\n }\n\n if (currentPropertyPath.Equals(path, StringComparison.OrdinalIgnoreCase))\n {\n return Invert ? OrderStrictness.NotStrict : OrderStrictness.Strict;\n }\n\n return OrderStrictness.Irrelevant;\n }\n\n private static bool ContainsIndexingQualifiers(string path)\n {\n return path.Contains('[', StringComparison.Ordinal) && path.Contains(']', StringComparison.Ordinal);\n }\n\n private string RemoveInitialIndexQualifier(string sourcePath)\n {\n var indexQualifierRegex = new Regex(@\"^\\[[0-9]+]\\.\");\n\n if (!indexQualifierRegex.IsMatch(path))\n {\n Match match = indexQualifierRegex.Match(sourcePath);\n\n if (match.Success)\n {\n sourcePath = sourcePath.Substring(match.Length);\n }\n }\n\n return sourcePath;\n }\n\n public override string ToString()\n {\n return $\"Be {(Invert ? \"not strict\" : \"strict\")} about the order of collection items when path is \" + path;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Tracing/StringBuilderTraceWriter.cs", "using System;\nusing System.Text;\n\nnamespace AwesomeAssertions.Equivalency.Tracing;\n\npublic class StringBuilderTraceWriter : ITraceWriter\n{\n private readonly StringBuilder builder = new();\n private int depth = 1;\n\n public void AddSingle(string trace)\n {\n WriteLine(trace);\n }\n\n public IDisposable AddBlock(string trace)\n {\n WriteLine(trace);\n WriteLine(\"{\");\n depth++;\n\n return new Disposable(() =>\n {\n depth--;\n WriteLine(\"}\");\n });\n }\n\n private void WriteLine(string trace)\n {\n foreach (string traceLine in trace.Split([Environment.NewLine], StringSplitOptions.RemoveEmptyEntries))\n {\n builder.Append(new string(' ', depth * 2)).AppendLine(traceLine);\n }\n }\n\n public override string ToString()\n {\n return builder.ToString();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/DictionaryInterfaceInfo.cs", "using System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Provides Reflection-backed meta-data information about a type implementing the interface.\n/// \ninternal sealed class DictionaryInterfaceInfo\n{\n // ReSharper disable once PossibleNullReferenceException\n private static readonly MethodInfo ConvertToDictionaryMethod =\n new Func>, Dictionary>(ConvertToDictionaryInternal)\n .GetMethodInfo().GetGenericMethodDefinition();\n\n private static readonly ConcurrentDictionary Cache = new();\n\n private DictionaryInterfaceInfo(Type key, Type value)\n {\n Key = key;\n Value = value;\n }\n\n public Type Value { get; }\n\n public Type Key { get; }\n\n /// \n /// Tries to reflect on the provided and returns an instance of the \n /// representing the single dictionary interface. Will throw if the target implements more than one dictionary interface.\n /// \n /// >\n /// The is used to describe the in failure messages.\n /// \n public static DictionaryInterfaceInfo FindFrom(Type target, string role)\n {\n var interfaces = GetDictionaryInterfacesFrom(target);\n\n if (interfaces.Length > 1)\n {\n throw new ArgumentException(\n $\"The {role} implements multiple dictionary types. It is not known which type should be \" +\n $\"use for equivalence.{Environment.NewLine}The following IDictionary interfaces are implemented: \" +\n $\"{string.Join(\", \", (IEnumerable)interfaces)}\", nameof(role));\n }\n\n if (interfaces.Length == 0)\n {\n return null;\n }\n\n return interfaces[0];\n }\n\n /// \n /// Tries to reflect on the provided and returns an instance of the \n /// representing the single dictionary interface keyed to .\n /// Will throw if the target implements more than one dictionary interface.\n /// \n /// >\n /// The is used to describe the in failure messages.\n /// \n public static DictionaryInterfaceInfo FindFromWithKey(Type target, string role, Type key)\n {\n var suitableDictionaryInterfaces = GetDictionaryInterfacesFrom(target)\n .Where(info => info.Key.IsAssignableFrom(key))\n .ToArray();\n\n if (suitableDictionaryInterfaces.Length > 1)\n {\n throw new InvalidOperationException(\n $\"The {role} implements multiple IDictionary interfaces taking a key of {key}. \");\n }\n\n if (suitableDictionaryInterfaces.Length == 0)\n {\n return null;\n }\n\n return suitableDictionaryInterfaces[0];\n }\n\n private static DictionaryInterfaceInfo[] GetDictionaryInterfacesFrom(Type target)\n {\n return Cache.GetOrAdd(target, static key =>\n {\n if (Type.GetTypeCode(key) != TypeCode.Object)\n {\n return [];\n }\n\n return key\n .GetClosedGenericInterfaces(typeof(IDictionary<,>))\n .Select(@interface => @interface.GetGenericArguments())\n .Select(arguments => new DictionaryInterfaceInfo(arguments[0], arguments[1]))\n .ToArray();\n });\n }\n\n /// \n /// Tries to convert an object into a dictionary typed to the and of the current .\n /// \n /// \n /// if the conversion succeeded or otherwise.\n /// \n public object ConvertFrom(object convertable)\n {\n Type[] enumerables = convertable.GetType().GetClosedGenericInterfaces(typeof(IEnumerable<>));\n\n var suitableKeyValuePairCollection = enumerables\n .Select(enumerable => enumerable.GenericTypeArguments[0])\n .Where(itemType => itemType.IsGenericType && itemType.GetGenericTypeDefinition() == typeof(KeyValuePair<,>))\n .SingleOrDefault(itemType => itemType.GenericTypeArguments[0] == Key);\n\n if (suitableKeyValuePairCollection != null)\n {\n Type pairValueType = suitableKeyValuePairCollection.GenericTypeArguments[^1];\n\n var methodInfo = ConvertToDictionaryMethod.MakeGenericMethod(Key, pairValueType);\n return methodInfo.Invoke(null, [convertable]);\n }\n\n return null;\n }\n\n private static Dictionary ConvertToDictionaryInternal(\n IEnumerable> collection)\n {\n return collection.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);\n }\n\n public override string ToString() => $\"IDictionary<{Key}, {Value}>\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Execution/CyclicReferenceDetector.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Execution;\n\n/// \n/// Keeps track of objects and their location within an object graph so that cyclic references can be detected\n/// and handled upon.\n/// \ninternal class CyclicReferenceDetector : ICloneable2\n{\n #region Private Definitions\n\n private HashSet observedReferences = [];\n\n #endregion\n\n /// \n /// Determines whether the specified object reference is a cyclic reference to the same object earlier in the\n /// equivalency validation.\n /// \n public bool IsCyclicReference(ObjectReference reference)\n {\n bool isCyclic = false;\n\n if (reference.CompareByMembers)\n {\n isCyclic = !observedReferences.Add(reference);\n }\n\n return isCyclic;\n }\n\n /// \n /// Creates a new object that is a copy of the current instance.\n /// \n /// \n /// A new object that is a copy of this instance.\n /// \n public object Clone()\n {\n return new CyclicReferenceDetector\n {\n observedReferences = new HashSet(observedReferences)\n };\n }\n}\n"], ["/AwesomeAssertions/Build/Build.cs", "using System;\nusing System.Linq;\nusing LibGit2Sharp;\nusing Nuke.Common;\nusing Nuke.Common.CI.GitHubActions;\nusing Nuke.Common.Execution;\nusing Nuke.Common.Git;\nusing Nuke.Common.IO;\nusing Nuke.Common.ProjectModel;\nusing Nuke.Common.Tooling;\nusing Nuke.Common.Tools.DotNet;\nusing Nuke.Common.Tools.GitVersion;\nusing Nuke.Common.Tools.ReportGenerator;\nusing Nuke.Common.Tools.Xunit;\nusing Nuke.Common.Utilities;\nusing Nuke.Common.Utilities.Collections;\nusing static Nuke.Common.Tools.DotNet.DotNetTasks;\nusing static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;\nusing static Nuke.Common.Tools.Xunit.XunitTasks;\nusing static Serilog.Log;\nusing static CustomNpmTasks;\n\n[UnsetVisualStudioEnvironmentVariables]\n[DotNetVerbosityMapping]\nclass Build : NukeBuild\n{\n /* Support plugins are available for:\n - JetBrains ReSharper https://nuke.build/resharper\n - JetBrains Rider https://nuke.build/rider\n - Microsoft VisualStudio https://nuke.build/visualstudio\n - Microsoft VSCode https://nuke.build/vscode\n */\n\n public static int Main() => Execute(x => x.SpellCheck, x => x.Push);\n\n GitHubActions GitHubActions => GitHubActions.Instance;\n\n string BranchSpec => GitHubActions?.Ref;\n\n string BuildNumber => GitHubActions?.RunNumber.ToString();\n\n string PullRequestBase => GitHubActions?.BaseRef;\n\n [Parameter(\"The solution configuration to build. Default is 'Debug' (local) or 'CI' (server).\")]\n readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.CI;\n\n [Parameter(\"Use this parameter if you encounter build problems in any way, \" +\n \"to generate a .binlog file which holds some useful information.\")]\n readonly bool? GenerateBinLog;\n\n [Parameter(\"The key to push to Nuget\")]\n [Secret]\n readonly string NuGetApiKey;\n\n [Solution(GenerateProjects = true)]\n readonly Solution Solution;\n\n [Required]\n [GitVersion(Framework = \"net8.0\", NoCache = true, NoFetch = true)]\n readonly GitVersion GitVersion;\n\n [Required]\n [GitRepository]\n readonly GitRepository GitRepository;\n AbsolutePath ArtifactsDirectory => RootDirectory / \"Artifacts\";\n\n AbsolutePath TestResultsDirectory => RootDirectory / \"TestResults\";\n\n string SemVer;\n\n Target Clean => _ => _\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n ArtifactsDirectory.CreateOrCleanDirectory();\n TestResultsDirectory.CreateOrCleanDirectory();\n });\n\n Target CalculateNugetVersion => _ => _\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n SemVer = GitVersion.SemVer;\n\n if (IsPullRequest)\n {\n Information(\n \"Branch spec {branchspec} is a pull request. Adding build number {buildnumber}\",\n BranchSpec, BuildNumber);\n\n SemVer = string.Join('.', GitVersion.SemVer.Split('.').Take(3).Union([BuildNumber]));\n }\n\n Information(\"SemVer = {semver}\", SemVer);\n });\n\n bool IsPullRequest => GitHubActions?.IsPullRequest ?? false;\n\n Target Restore => _ => _\n .DependsOn(Clean)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n DotNetRestore(s => s\n .SetProjectFile(Solution)\n .EnableNoCache()\n .SetConfigFile(RootDirectory / \"nuget.config\"));\n });\n\n Target Compile => _ => _\n .DependsOn(Restore)\n .DependsOn(CalculateNugetVersion)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n ReportSummary(s => s\n .WhenNotNull(SemVer, (summary, semVer) => summary\n .AddPair(\"Version\", semVer)));\n\n DotNetBuild(s => s\n .SetProjectFile(Solution)\n .SetConfiguration(Configuration)\n .When(_ => GenerateBinLog is true, c => c\n .SetBinaryLog(ArtifactsDirectory / $\"{Solution.Core.AwesomeAssertions.Name}.binlog\")\n )\n .EnableNoLogo()\n .EnableNoRestore()\n .SetVersion(SemVer)\n .SetAssemblyVersion(GitVersion.AssemblySemVer)\n .SetFileVersion(GitVersion.AssemblySemFileVer)\n .SetInformationalVersion(GitVersion.InformationalVersion));\n });\n\n Target ApiChecks => _ => _\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n Project project = Solution.Specs.Approval_Tests;\n\n DotNetTest(s => s\n .SetConfiguration(Configuration == Configuration.Debug ? \"Debug\" : \"Release\")\n .SetProcessEnvironmentVariable(\"DOTNET_CLI_UI_LANGUAGE\", \"en-US\")\n .EnableNoBuild()\n .SetResultsDirectory(TestResultsDirectory)\n .CombineWith(cc => cc\n .SetProjectFile(project)\n .AddLoggers($\"trx;LogFileName={project.Name}.trx\")), completeOnFailure: true);\n });\n\n Project[] Projects =>\n [\n Solution.Specs.AwesomeAssertions_Specs,\n Solution.Specs.AwesomeAssertions_Equivalency_Specs,\n Solution.Specs.AwesomeAssertions_Extensibility_Specs,\n Solution.Specs.FSharp_Specs,\n Solution.Specs.VB_Specs\n ];\n\n Target UnitTestsNet47 => _ => _\n .Unlisted()\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => EnvironmentInfo.IsWin && (RunAllTargets || HasSourceChanges))\n .Executes(() =>\n {\n string[] testAssemblies = Projects\n .SelectMany(project => project.Directory.GlobFiles(\"bin/Debug/net47/*.Specs.dll\"))\n .Select(p => p.ToString())\n .ToArray();\n\n Assert.NotEmpty(testAssemblies.ToList());\n\n Xunit2(s => s\n .SetFramework(\"net47\")\n .AddTargetAssemblies(testAssemblies)\n );\n });\n\n Target UnitTestsNet6OrGreater => _ => _\n .Unlisted()\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n const string net47 = \"net47\";\n\n DotNetTest(s => s\n .SetConfiguration(Configuration.Debug)\n .SetProcessEnvironmentVariable(\"DOTNET_CLI_UI_LANGUAGE\", \"en-US\")\n .EnableNoBuild()\n .SetDataCollector(\"XPlat Code Coverage\")\n .SetResultsDirectory(TestResultsDirectory)\n .AddRunSetting(\n \"DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DoesNotReturnAttribute\",\n \"DoesNotReturnAttribute\")\n .CombineWith(\n Projects,\n (settings, project) => settings\n .SetProjectFile(project)\n .CombineWith(\n project.GetTargetFrameworks().Except([net47]),\n (frameworkSettings, framework) => frameworkSettings\n .SetFramework(framework)\n .AddLoggers($\"trx;LogFileName={project.Name}_{framework}.trx\")\n )\n ), completeOnFailure: true\n );\n });\n\n Target UnitTests => _ => _\n .DependsOn(UnitTestsNet47)\n .DependsOn(UnitTestsNet6OrGreater);\n\n Target CodeCoverage => _ => _\n .DependsOn(TestFrameworks)\n .DependsOn(UnitTests)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n ReportGenerator(s => s\n .SetProcessToolPath(NuGetToolPathResolver.GetPackageExecutable(\"ReportGenerator\", \"ReportGenerator.dll\",\n framework: \"net8.0\"))\n .SetTargetDirectory(TestResultsDirectory / \"reports\")\n .AddReports(TestResultsDirectory / \"**/coverage.cobertura.xml\")\n .AddReportTypes(\n ReportTypes.lcov,\n ReportTypes.HtmlInline_AzurePipelines_Dark)\n .AddFileFilters(\"-*.g.cs\")\n .AddFileFilters(\"-*.nuget*\")\n .SetAssemblyFilters(\"+AwesomeAssertions\"));\n\n string link = TestResultsDirectory / \"reports\" / \"index.html\";\n Information($\"Code coverage report: \\x1b]8;;file://{link.Replace('\\\\', '/')}\\x1b\\\\{link}\\x1b]8;;\\x1b\\\\\");\n });\n\n Target VSTestFrameworks => _ => _\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n Project[] projects =\n [\n Solution.TestFrameworks.MSpec_Specs,\n Solution.TestFrameworks.MSTestV2_Specs,\n Solution.TestFrameworks.NUnit3_Specs,\n Solution.TestFrameworks.NUnit4_Specs,\n Solution.TestFrameworks.XUnit2_Specs,\n Solution.TestFrameworks.XUnit3_Specs,\n Solution.TestFrameworks.XUnit3Core_Specs,\n ];\n\n var testCombinations =\n from project in projects\n let frameworks = project.GetTargetFrameworks()\n let supportedFrameworks = EnvironmentInfo.IsWin ? frameworks : frameworks.Except([\"net47\"])\n from framework in supportedFrameworks\n select new { project, framework };\n\n DotNetTest(s => s\n .SetConfiguration(Configuration.Debug)\n .SetProcessEnvironmentVariable(\"DOTNET_CLI_UI_LANGUAGE\", \"en-US\")\n .EnableNoBuild()\n .SetDataCollector(\"XPlat Code Coverage\")\n .SetResultsDirectory(TestResultsDirectory)\n .AddRunSetting(\n \"DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DoesNotReturnAttribute\",\n \"DoesNotReturnAttribute\")\n .CombineWith(\n testCombinations,\n (settings, v) => settings\n .SetProjectFile(v.project)\n .SetFramework(v.framework)\n .AddLoggers($\"trx;LogFileName={v.project.Name}_{v.framework}.trx\")), completeOnFailure: true);\n });\n\n Target TestingPlatformFrameworks => _ => _\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n Project[] projects =\n [\n Solution.TestFrameworks.TUnit_Specs\n ];\n\n var testCombinations =\n from project in projects\n let frameworks = project.GetTargetFrameworks()\n from framework in frameworks\n select new { project, framework };\n\n DotNetTest(s => s\n .SetConfiguration(Configuration.Debug)\n .SetProcessEnvironmentVariable(\"DOTNET_CLI_UI_LANGUAGE\", \"en-US\")\n .EnableNoBuild()\n .CombineWith(\n testCombinations,\n (settings, v) => settings\n .SetProjectFile(v.project)\n .SetFramework(v.framework)\n .SetProcessAdditionalArguments(\n \"--\",\n \"--coverage\",\n \"--report-trx\",\n $\"--report-trx-filename {v.project.Name}_{v.framework}.trx\",\n $\"--results-directory {TestResultsDirectory}\"\n )\n )\n );\n });\n\n Target TestFrameworks => _ => _\n .DependsOn(VSTestFrameworks)\n .DependsOn(TestingPlatformFrameworks);\n\n Target Pack => _ => _\n .DependsOn(ApiChecks)\n .DependsOn(TestFrameworks)\n .DependsOn(UnitTests)\n .DependsOn(CodeCoverage)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n ReportSummary(s => s\n .WhenNotNull(SemVer, (c, semVer) => c\n .AddPair(\"Packed version\", semVer)));\n\n DotNetPack(s => s\n .SetProject(Solution.Core.AwesomeAssertions)\n .SetOutputDirectory(ArtifactsDirectory)\n .SetConfiguration(Configuration == Configuration.Debug ? \"Debug\" : \"Release\")\n .EnableNoLogo()\n .EnableNoRestore()\n .EnableContinuousIntegrationBuild() // Necessary for deterministic builds\n .SetVersion(SemVer));\n });\n\n Target Push => _ => _\n .DependsOn(Pack)\n .OnlyWhenDynamic(() => IsTag)\n .ProceedAfterFailure()\n .Executes(() =>\n {\n var packages = ArtifactsDirectory.GlobFiles(\"*.nupkg\");\n\n Assert.NotEmpty(packages);\n\n DotNetNuGetPush(s => s\n .SetApiKey(NuGetApiKey)\n .EnableSkipDuplicate()\n .SetSource(\"https://api.nuget.org/v3/index.json\")\n .EnableNoSymbols()\n .CombineWith(packages,\n (v, path) => v.SetTargetPath(path)));\n });\n\n Target SpellCheck => _ => _\n .OnlyWhenDynamic(() => RunAllTargets || HasDocumentationChanges)\n .DependsOn(InstallNode)\n .ProceedAfterFailure()\n .Executes(() =>\n {\n NpmInstall(silent: true, workingDirectory: RootDirectory);\n NpmRun(\"cspell\", silent: true);\n });\n\n Target InstallNode => _ => _\n .OnlyWhenDynamic(() => RunAllTargets || HasDocumentationChanges)\n .ProceedAfterFailure()\n .Executes(() =>\n {\n Initialize(RootDirectory);\n\n NpmFetchRuntime();\n\n ReportSummary(conf =>\n {\n if (HasCachedNodeModules)\n {\n conf.AddPair(\"Skipped\", \"Downloading and extracting\");\n }\n\n return conf;\n });\n });\n\n bool HasDocumentationChanges => Changes.Any(x => IsDocumentation(x));\n\n bool HasSourceChanges => Changes.Any(x => !IsDocumentation(x));\n\n static bool IsDocumentation(string x) =>\n x.StartsWith(\"docs\") ||\n x.StartsWith(\"CONTRIBUTING.md\") ||\n x.StartsWith(\"cSpell.json\") ||\n x.StartsWith(\"LICENSE\") ||\n x.StartsWith(\"package.json\") ||\n x.StartsWith(\"package-lock.json\") ||\n x.StartsWith(\"NodeVersion\") ||\n x.StartsWith(\"README.md\");\n\n string[] Changes =>\n Repository.Diff\n .Compare(TargetBranch, SourceBranch)\n .Where(x => x.Exists)\n .Select(x => x.Path)\n .ToArray();\n\n Repository Repository => new(GitRepository.LocalDirectory);\n\n Tree TargetBranch => Repository.Branches[PullRequestBase].Tip.Tree;\n\n Tree SourceBranch => Repository.Branches[Repository.Head.FriendlyName].Tip.Tree;\n\n bool RunAllTargets => string.IsNullOrWhiteSpace(PullRequestBase) || Changes.Any(x => x.StartsWith(\"Build\"));\n\n bool IsTag => BranchSpec != null && BranchSpec.Contains(\"refs/tags\", StringComparison.OrdinalIgnoreCase);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/AssertionChain.cs", "using System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Threading;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Provides a fluent API to build simple or composite assertions, and which can flow from one assertion to another.\n/// \n/// \n/// This is the core engine of many of the assertion APIs in this library. When combined with ,\n/// you can run multiple assertions which failure messages will be collected until the scope is disposed.\n/// \npublic sealed class AssertionChain\n{\n private readonly Func getCurrentScope;\n private readonly ContextDataDictionary contextData = new();\n private string fallbackIdentifier = \"object\";\n private Func getCallerIdentifier;\n private Func reason;\n private bool? succeeded;\n\n // We need to keep track of this because we don't want the second successful assertion hide the first unsuccessful assertion\n private Func expectation;\n private string callerPostfix = string.Empty;\n\n private static readonly AsyncLocal Instance = new();\n\n /// \n /// Ensures that the next call to will reuse the current instance.\n /// \n public void ReuseOnce()\n {\n Instance.Value = this;\n }\n\n /// \n /// Indicates whether the previous assertion in the chain was successful.\n /// \n /// \n /// This property is used internally to determine if subsequent assertions\n /// should be evaluated based on the result of the previous assertion.\n /// \n internal bool PreviousAssertionSucceeded { get; private set; } = true;\n\n /// \n /// Indicates whether the caller identifier has been manually overridden.\n /// \n /// \n /// This property is used to track if the caller identifier has been customized using the\n /// method or similar methods that modify the identifier.\n /// \n public bool HasOverriddenCallerIdentifier { get; private set; }\n\n /// \n /// Either starts a new assertion chain, or, when was called, for once, will return\n /// an existing instance.\n /// \n public static AssertionChain GetOrCreate()\n {\n if (Instance.Value != null)\n {\n AssertionChain assertionChain = Instance.Value;\n Instance.Value = null;\n return assertionChain;\n }\n\n return new AssertionChain(() => AssertionScope.Current,\n () => AwesomeAssertions.CallerIdentifier.DetermineCallerIdentity());\n }\n\n private AssertionChain(Func getCurrentScope, Func getCallerIdentifier)\n {\n this.getCurrentScope = getCurrentScope;\n\n this.getCallerIdentifier = () =>\n {\n var scopeName = getCurrentScope().Name();\n var callerIdentifier = getCallerIdentifier();\n\n if (scopeName is null)\n {\n return callerIdentifier;\n }\n else if (callerIdentifier is null)\n {\n return scopeName;\n }\n else\n {\n return $\"{scopeName}/{callerIdentifier}\";\n }\n };\n }\n\n /// \n /// The effective caller identifier including any prefixes and postfixes configured through\n /// .\n /// \n /// \n /// Can be overridden with .\n /// \n public string CallerIdentifier => getCallerIdentifier() + callerPostfix;\n\n /// \n /// Adds an explanation of why the assertion is supposed to succeed to the scope.\n /// \n /// \n /// An object containing a formatted phrase as is supported by explaining why the assertion\n /// is needed, as well as zero or more objects to format the placeholders.\n /// If the phrase does not start with the word because, it is prepended automatically.explaining why the assertion is needed.\n /// \n public AssertionChain BecauseOf(Reason reason)\n {\n return BecauseOf(reason.FormattedMessage, reason.Arguments);\n }\n\n /// \n /// Adds an explanation of why the assertion is supposed to succeed to the scope.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AssertionChain BecauseOf(string because, params object[] becauseArgs)\n {\n reason = () =>\n {\n try\n {\n string becauseOrEmpty = because ?? string.Empty;\n\n return becauseArgs?.Length > 0\n ? string.Format(CultureInfo.InvariantCulture, becauseOrEmpty, becauseArgs)\n : becauseOrEmpty;\n }\n catch (FormatException formatException)\n {\n return\n $\"**WARNING** because message '{because}' could not be formatted with string.Format{Environment.NewLine}{formatException.StackTrace}\";\n }\n };\n\n return this;\n }\n\n public AssertionChain ForCondition(bool condition)\n {\n if (PreviousAssertionSucceeded)\n {\n succeeded = condition;\n }\n\n return this;\n }\n\n public AssertionChain ForConstraint(OccurrenceConstraint constraint, int actualOccurrences)\n {\n if (PreviousAssertionSucceeded)\n {\n constraint.RegisterContextData((key, value) => contextData.Add(\n new ContextDataDictionary.DataItem(key, value, reportable: false, requiresFormatting: false)));\n\n succeeded = constraint.Assert(actualOccurrences);\n }\n\n return this;\n }\n\n public Continuation WithExpectation(string message, object arg1, Action chain)\n {\n return WithExpectation(message, chain, arg1);\n }\n\n public Continuation WithExpectation(string message, object arg1, object arg2, Action chain)\n {\n return WithExpectation(message, chain, arg1, arg2);\n }\n\n public Continuation WithExpectation(string message, Action chain)\n {\n return WithExpectation(message, chain, []);\n }\n\n private Continuation WithExpectation(string message, Action chain, params object[] args)\n {\n if (PreviousAssertionSucceeded)\n {\n expectation = () =>\n {\n var formatter = new FailureMessageFormatter(getCurrentScope().FormattingOptions)\n .WithReason(reason?.Invoke() ?? string.Empty)\n .WithContext(contextData)\n .WithIdentifier(CallerIdentifier)\n .WithFallbackIdentifier(fallbackIdentifier);\n\n return formatter.Format(message, args);\n };\n\n chain(this);\n\n expectation = null;\n }\n\n return new Continuation(this);\n }\n\n public AssertionChain WithDefaultIdentifier(string identifier)\n {\n fallbackIdentifier = identifier;\n return this;\n }\n\n public GivenSelector Given(Func selector)\n {\n return new GivenSelector(selector, this);\n }\n\n internal Continuation FailWithPreFormatted(string formattedFailReason)\n {\n return FailWith(() => formattedFailReason);\n }\n\n public Continuation FailWith(string message)\n {\n return FailWith(() => new FailReason(message));\n }\n\n public Continuation FailWith(string message, params object[] args)\n {\n return FailWith(() => new FailReason(message, args));\n }\n\n public Continuation FailWith(string message, params Func[] argProviders)\n {\n return FailWith(\n () => new FailReason(\n message,\n argProviders.Select(a => a()).ToArray()));\n }\n\n public Continuation FailWith(Func getFailureReason)\n {\n return FailWith(() =>\n {\n var formatter = new FailureMessageFormatter(getCurrentScope().FormattingOptions)\n .WithReason(reason?.Invoke() ?? string.Empty)\n .WithContext(contextData)\n .WithIdentifier(CallerIdentifier)\n .WithFallbackIdentifier(fallbackIdentifier);\n\n FailReason failReason = getFailureReason();\n\n return formatter.Format(failReason.Message, failReason.Args);\n });\n }\n\n private Continuation FailWith(Func getFailureReason)\n {\n if (PreviousAssertionSucceeded)\n {\n PreviousAssertionSucceeded = succeeded is true;\n\n if (succeeded is not true)\n {\n string failure = getFailureReason();\n\n if (expectation is not null)\n {\n failure = expectation() + failure;\n }\n\n getCurrentScope().AddPreFormattedFailure(failure.Capitalize().RemoveTrailingWhitespaceFromLines());\n }\n }\n\n // Reset the state for successive assertions on this object\n succeeded = null;\n\n return new Continuation(this);\n }\n\n /// \n /// Allows overriding the caller identifier for the next call to one of the `FailWith` overloads instead\n /// of relying on the automatic behavior that extracts the variable names from the C# code.\n /// \n public void OverrideCallerIdentifier(Func getCallerIdentifier)\n {\n this.getCallerIdentifier = getCallerIdentifier;\n HasOverriddenCallerIdentifier = true;\n }\n\n /// \n /// Adds a postfix such as [0] to the caller identifier detected by the library.\n /// \n /// \n /// Can be used by an assertion that uses to return an object or\n /// collection on which another assertion is executed, and which wants to amend the automatically detected caller\n /// identifier with a postfix.\n /// \n public AssertionChain WithCallerPostfix(string postfix)\n {\n callerPostfix = postfix;\n HasOverriddenCallerIdentifier = true;\n\n return this;\n }\n\n /// \n /// Adds some information to the assertion that will be included in the message\n /// that is emitted if an assertion fails.\n /// \n public void AddReportable(string key, string value)\n {\n getCurrentScope().AddReportable(key, value);\n }\n\n /// \n /// Adds some information to the assertion that will be included in the message\n /// that is emitted if an assertion fails. The value is only calculated on failure.\n /// \n public void AddReportable(string key, Func getValue)\n {\n getCurrentScope().AddReportable(key, getValue);\n }\n\n /// \n /// Fluent alternative for \n /// \n public AssertionChain WithReportable(string name, Func content)\n {\n getCurrentScope().AddReportable(name, content);\n return this;\n }\n\n /// \n /// Registers a failure in the chain that doesn't need any parsing or formatting anymore.\n /// \n internal void AddPreFormattedFailure(string failure)\n {\n getCurrentScope().AddPreFormattedFailure(failure);\n }\n\n /// \n /// Gets a value indicating whether all assertions in the have succeeded.\n /// \n public bool Succeeded => PreviousAssertionSucceeded && succeeded is null or true;\n\n public AssertionChain UsingLineBreaks\n {\n get\n {\n getCurrentScope().FormattingOptions.UseLineBreaks = true;\n return this;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/ComparableSpecs.cs", "using System;\nusing System.Globalization;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic class ComparableSpecs\n{\n public class Be\n {\n [Fact]\n public void When_two_instances_are_equal_it_should_succeed()\n {\n // Arrange\n var subject = new EquatableOfInt(1);\n var other = new EquatableOfInt(1);\n\n // Act / Assert\n subject.Should().Be(other);\n }\n\n [Fact]\n public void When_two_instances_are_the_same_reference_but_are_not_considered_equal_it_should_succeed()\n {\n // Arrange\n var subject = new SameInstanceIsNotEqualClass();\n var other = subject;\n\n // Act\n Action act = () => subject.Should().Be(other);\n\n // Assert\n act.Should().NotThrow(\n \"This is inconsistent with the behavior ObjectAssertions.Be but is how ComparableTypeAssertions.Be has always worked.\");\n }\n\n [Fact]\n public void When_two_instances_are_not_equal_it_should_throw()\n {\n // Arrange\n var subject = new EquatableOfInt(1);\n var other = new EquatableOfInt(2);\n\n // Act\n Action act = () => subject.Should().Be(other, \"they have the same property values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected*2*because they have the same property values, but found*1*.\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_two_references_to_the_same_instance_are_not_equal_it_should_throw()\n {\n // Arrange\n var subject = new SameInstanceIsNotEqualClass();\n var other = subject;\n\n // Act\n Action act = () => subject.Should().NotBe(other);\n\n // Assert\n act.Should().Throw(\n \"This is inconsistent with the behavior ObjectAssertions.Be but is how ComparableTypeAssertions.Be has always worked.\");\n }\n\n [Fact]\n public void When_two_equal_objects_should_not_be_equal_it_should_throw()\n {\n // Arrange\n var subject = new EquatableOfInt(1);\n var other = new EquatableOfInt(1);\n\n // Act\n Action act = () => subject.Should().NotBe(other, \"they represent different things\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*Did not expect subject to be equal to*1*because they represent different things.*\");\n }\n\n [Fact]\n public void When_two_unequal_objects_should_not_be_equal_it_should_not_throw()\n {\n // Arrange\n var subject = new EquatableOfInt(1);\n var other = new EquatableOfInt(2);\n\n // Act / Assert\n subject.Should().NotBe(other);\n }\n }\n\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_equal_to_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n var value = new EquatableOfInt(3);\n\n // Act\n Action act = () => value.Should().BeOneOf(new[] { new EquatableOfInt(4), new EquatableOfInt(5) },\n \"because those are the valid {0}\", \"values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be one of {4, 5} because those are the valid values, but found 3.\");\n }\n\n [Fact]\n public void When_two_instances_are_the_same_reference_but_are_not_considered_equal_it_should_succeed()\n {\n // Arrange\n var subject = new SameInstanceIsNotEqualClass();\n var other = subject;\n\n // Act\n Action act = () => subject.Should().BeOneOf(other);\n\n // Assert\n act.Should().NotThrow(\n \"This is inconsistent with the behavior ObjectAssertions.Be but is how ComparableTypeAssertions.Be has always worked.\");\n }\n\n [Fact]\n public void When_a_value_is_equal_to_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n var value = new EquatableOfInt(4);\n\n // Act / Assert\n value.Should().BeOneOf(new EquatableOfInt(4), new EquatableOfInt(5));\n }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void When_two_instances_are_equivalent_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n var expected = new CustomerDto(42);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_two_instances_are_compared_it_should_allow_chaining()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n var expected = new CustomerDto(42);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected)\n .And.NotBeNull();\n }\n\n [Fact]\n public void When_two_instances_are_compared_with_config_it_should_allow_chaining()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n var expected = new CustomerDto(42);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt)\n .And.NotBeNull();\n }\n\n [Fact]\n public void When_two_instances_are_equivalent_due_to_exclusion_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n\n var expected = new AnotherCustomerDto(42)\n {\n SomeOtherProperty = 1337\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.Excluding(x => x.SomeOtherProperty),\n \"they have the same property values\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_it_should_throw()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n var expected = new AnotherCustomerDto(42);\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_two_instances_are_not_equivalent_it_should_throw()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n\n var expected = new AnotherCustomerDto(42)\n {\n SomeOtherProperty = 1337\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, \"they have the same property values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expectation has property SomeOtherProperty*that the other object does not have*\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_assertion_an_instance_to_be_null_and_it_is_null_it_should_succeed()\n {\n // Arrange\n ComparableOfString subject = null;\n\n // Act / Assert\n subject.Should().BeNull();\n }\n\n [Fact]\n public void When_assertion_an_instance_to_be_null_and_it_is_not_null_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"\");\n\n // Act\n Action action = () =>\n subject.Should().BeNull();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject to be , but found*\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_assertion_an_instance_not_to_be_null_and_it_is_not_null_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableOfString(\"\");\n\n // Act / Assert\n subject.Should().NotBeNull();\n }\n\n [Fact]\n public void When_assertion_an_instance_not_to_be_null_and_it_is_null_it_should_throw()\n {\n // Arrange\n ComparableOfString subject = null;\n\n // Act\n Action action = () =>\n subject.Should().NotBeNull();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject not to be .\");\n }\n }\n\n public class BeInRange\n {\n [Fact]\n public void When_assertion_an_instance_to_be_in_a_certain_range_and_it_is_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableOfInt(1);\n\n // Act / Assert\n subject.Should().BeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n }\n\n [Fact]\n public void When_asserting_an_instance_to_be_in_a_certain_range_and_it_is_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableOfInt(2);\n\n // Act / Assert\n subject.Should().BeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n }\n\n [Fact]\n public void When_assertion_an_instance_to_be_in_a_certain_range_but_it_is_not_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfInt(3);\n\n // Act\n Action action = () =>\n subject.Should().BeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject to be between*and*, but found *.\");\n }\n }\n\n public class NotBeInRange\n {\n [Fact]\n public void When_assertion_an_instance_to_not_be_in_a_certain_range_and_it_is_not_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableOfInt(3);\n\n // Act / Assert\n subject.Should().NotBeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n }\n\n [Fact]\n public void When_assertion_an_instance_to_not_be_in_a_certain_range_but_it_is_not_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfInt(2);\n\n // Act\n Action action = () =>\n subject.Should().NotBeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject to not be between*and*, but found *.\");\n }\n\n [Fact]\n public void When_asserting_an_instance_to_not_be_in_a_certain_range_but_it_is_not_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfInt(1);\n\n // Act\n Action action = () =>\n subject.Should().NotBeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class BeRankedEquallyTo\n {\n [Fact]\n public void When_subect_is_ranked_equal_to_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"Hello\");\n var other = new ComparableOfString(\"Hello\");\n\n // Act / Assert\n subject.Should().BeRankedEquallyTo(other);\n }\n\n [Fact]\n public void When_subject_is_not_ranked_equal_to_another_subject_but_that_is_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"42\");\n var other = new ComparableOfString(\"Forty two\");\n\n // Act\n Action act = () => subject.Should().BeRankedEquallyTo(other, \"they represent the same number\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected subject*42*to be ranked as equal to*Forty two*because they represent the same number.\");\n }\n }\n\n public class NotBeRankedEquallyTo\n {\n [Fact]\n public void When_subect_is_not_ranked_equal_to_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"Hello\");\n var other = new ComparableOfString(\"Hi\");\n\n // Act / Assert\n subject.Should().NotBeRankedEquallyTo(other);\n }\n\n [Fact]\n public void When_subject_is_ranked_equal_to_another_subject_but_that_is_not_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"Lead\");\n var other = new ComparableOfString(\"Lead\");\n\n // Act\n Action act = () => subject.Should().NotBeRankedEquallyTo(other, \"they represent different concepts\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected subject*Lead*not to be ranked as equal to*Lead*because they represent different concepts.\");\n }\n }\n\n public class BeLessThan\n {\n [Fact]\n public void When_subject_is_less_than_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"City\");\n var other = new ComparableOfString(\"World\");\n\n // Act / Assert\n subject.Should().BeLessThan(other);\n }\n\n [Fact]\n public void When_subject_is_not_less_than_another_subject_but_that_is_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"World\");\n var other = new ComparableOfString(\"City\");\n\n // Act\n Action act = () => subject.Should().BeLessThan(other, \"a city is smaller than the world\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected subject*World*to be less than*City*because a city is smaller than the world.\");\n }\n\n [Fact]\n public void When_subject_is_equal_to_another_subject_and_expected_to_be_less_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"City\");\n var other = new ComparableOfString(\"City\");\n\n // Act\n Action act = () => subject.Should().BeLessThan(other);\n\n // Assert\n act.Should().Throw();\n }\n }\n\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void When_subject_is_greater_than_another_subject_and_that_is_not_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"World\");\n var other = new ComparableOfString(\"City\");\n\n // Act\n Action act = () => subject.Should().BeLessThanOrEqualTo(other, \"we want to order them\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected subject*World*to be less than or equal to*City*because we want to order them.\");\n }\n\n [Fact]\n public void When_subject_is_equal_to_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"World\");\n var other = new ComparableOfString(\"World\");\n\n // Act / Assert\n subject.Should().BeLessThanOrEqualTo(other);\n }\n\n [Fact]\n public void When_subject_is_less_than_another_subject_and_less_than_or_equal_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"City\");\n var other = new ComparableOfString(\"World\");\n\n // Act / Assert\n subject.Should().BeLessThanOrEqualTo(other);\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var subject = new ComparableOfString(\"World\");\n var other = new ComparableOfString(\"World\");\n\n // Act / Assert\n subject.Should().BeLessThanOrEqualTo(other).And.NotBeNull();\n }\n }\n\n public class BeGreaterThan\n {\n [Fact]\n public void When_subject_is_greater_than_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"efg\");\n var other = new ComparableOfString(\"abc\");\n\n // Act / Assert\n subject.Should().BeGreaterThan(other);\n }\n\n [Fact]\n public void When_subject_is_equal_to_another_subject_and_expected_to_be_greater_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"efg\");\n var other = new ComparableOfString(\"efg\");\n\n // Act\n Action act = () => subject.Should().BeGreaterThan(other);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_is_not_greater_than_another_subject_but_that_is_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"abc\");\n var other = new ComparableOfString(\"def\");\n\n // Act\n Action act = () => subject.Should().BeGreaterThan(other, \"'a' is smaller then 'e'\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected subject*abc*to be greater than*def*because 'a' is smaller then 'e'.\");\n }\n }\n\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void When_subject_is_less_than_another_subject_and_that_is_not_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"abc\");\n var other = new ComparableOfString(\"def\");\n\n // Act\n Action act = () => subject.Should().BeGreaterThanOrEqualTo(other, \"'d' is bigger then 'a'\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected subject*abc*to be greater than or equal to*def*because 'd' is bigger then 'a'.\");\n }\n\n [Fact]\n public void When_subject_is_equal_to_another_subject_and_that_is_equal_or_greater_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"def\");\n var other = new ComparableOfString(\"def\");\n\n // Act / Assert\n subject.Should().BeGreaterThanOrEqualTo(other);\n }\n\n [Fact]\n public void When_subject_is_greater_than_another_subject_and_greater_than_or_equal_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"xyz\");\n var other = new ComparableOfString(\"abc\");\n\n // Act / Assert\n subject.Should().BeGreaterThanOrEqualTo(other);\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var subject = new ComparableOfString(\"def\");\n var other = new ComparableOfString(\"def\");\n\n // Act / Assert\n subject.Should().BeGreaterThanOrEqualTo(other).And.NotBeNull();\n }\n }\n}\n\npublic class ComparableOfString : IComparable\n{\n public string Value { get; set; }\n\n public ComparableOfString(string value)\n {\n Value = value;\n }\n\n public int CompareTo(ComparableOfString other)\n {\n return string.CompareOrdinal(Value, other.Value);\n }\n\n public override string ToString()\n {\n return Value;\n }\n}\n\npublic class SameInstanceIsNotEqualClass : IComparable\n{\n public override bool Equals(object obj)\n {\n return false;\n }\n\n public override int GetHashCode()\n {\n return 1;\n }\n\n int IComparable.CompareTo(SameInstanceIsNotEqualClass other) =>\n throw new NotSupportedException(\"This type is meant for assertions using Equals()\");\n}\n\npublic class EquatableOfInt : IComparable\n{\n public int Value { get; set; }\n\n public EquatableOfInt(int value)\n {\n Value = value;\n }\n\n public override bool Equals(object obj)\n {\n return Value == ((EquatableOfInt)obj).Value;\n }\n\n public override int GetHashCode()\n {\n return Value.GetHashCode();\n }\n\n public override string ToString()\n {\n return Value.ToString(CultureInfo.InvariantCulture);\n }\n\n int IComparable.CompareTo(EquatableOfInt other) =>\n throw new NotSupportedException(\"This type is meant for assertions using Equals()\");\n}\n\npublic class ComparableOfInt : IComparable\n{\n public int Value { get; set; }\n\n public ComparableOfInt(int value)\n {\n Value = value;\n }\n\n public int CompareTo(ComparableOfInt other)\n {\n return Value.CompareTo(other.Value);\n }\n\n public override string ToString()\n {\n return Value.ToString(CultureInfo.InvariantCulture);\n }\n}\n\npublic class ComparableCustomer : IComparable\n{\n public ComparableCustomer(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n\n public int CompareTo(ComparableCustomer other)\n {\n return Id.CompareTo(other.Id);\n }\n}\n\npublic class CustomerDto\n{\n public CustomerDto(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n}\n\npublic class AnotherCustomerDto\n{\n public AnotherCustomerDto(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n\n public int SomeOtherProperty { get; set; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/TupleSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class TupleSpecs\n{\n [Fact]\n public void When_a_nested_member_is_a_tuple_it_should_compare_its_property_for_equivalence()\n {\n // Arrange\n var actual = new { Tuple = (new[] { \"string1\" }, new[] { \"string2\" }) };\n\n var expected = new { Tuple = (new[] { \"string1\" }, new[] { \"string2\" }) };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_tuple_is_compared_it_should_compare_its_components()\n {\n // Arrange\n var actual = Tuple.Create(\"Hello\", true, new[] { 3, 2, 1 });\n var expected = Tuple.Create(\"Hello\", true, new[] { 1, 2, 3 });\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Interfaces.cs", "using System;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Interfaces\n {\n [Fact]\n public void When_an_interface_hierarchy_is_used_it_should_include_all_inherited_properties()\n {\n // Arrange\n ICar subject = new Car\n {\n VehicleId = 1,\n Wheels = 4\n };\n\n ICar expected = new Car\n {\n VehicleId = 99999,\n Wheels = 4\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Expected*VehicleId*99999*but*1*\");\n }\n\n [Fact]\n public void When_a_reference_to_an_interface_is_provided_it_should_only_include_those_properties()\n {\n // Arrange\n IVehicle expected = new Car\n {\n VehicleId = 1,\n Wheels = 4\n };\n\n IVehicle subject = new Car\n {\n VehicleId = 1,\n Wheels = 99999\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_reference_to_an_explicit_interface_impl_is_provided_it_should_only_include_those_properties()\n {\n // Arrange\n IVehicle expected = new ExplicitCar\n {\n Wheels = 4\n };\n\n IVehicle subject = new ExplicitCar\n {\n Wheels = 99999\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void Explicitly_implemented_subject_properties_are_ignored_if_a_normal_property_exists_with_the_same_name()\n {\n // Arrange\n IVehicle expected = new Vehicle\n {\n VehicleId = 1\n };\n\n IVehicle subject = new ExplicitVehicle\n {\n VehicleId = 2 // normal property\n };\n\n subject.VehicleId = 1; // explicitly implemented property\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Explicitly_implemented_read_only_subject_properties_are_ignored_if_a_normal_property_exists_with_the_same_name()\n {\n // Arrange\n IReadOnlyVehicle subject = new ExplicitReadOnlyVehicle(explicitValue: 1)\n {\n VehicleId = 2 // normal property\n };\n\n var expected = new Vehicle\n {\n VehicleId = 1\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Explicitly_implemented_subject_properties_are_ignored_if_only_fields_are_included()\n {\n // Arrange\n var expected = new VehicleWithField\n {\n VehicleId = 1 // A field named like a property\n };\n\n var subject = new ExplicitVehicle\n {\n VehicleId = 2 // A real property\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .IncludingFields()\n .ExcludingProperties());\n\n // Assert\n action.Should().Throw().WithMessage(\"*field*VehicleId*other*\");\n }\n\n [Fact]\n public void Explicitly_implemented_subject_properties_are_ignored_if_only_fields_are_included_and_they_may_be_missing()\n {\n // Arrange\n var expected = new VehicleWithField\n {\n VehicleId = 1 // A field named like a property\n };\n\n var subject = new ExplicitVehicle\n {\n VehicleId = 2 // A real property\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt\n .IncludingFields()\n .ExcludingProperties()\n .ExcludingMissingMembers());\n }\n\n [Fact]\n public void Excluding_missing_members_does_not_affect_how_explicitly_implemented_subject_properties_are_dealt_with()\n {\n // Arrange\n IVehicle expected = new Vehicle\n {\n VehicleId = 1\n };\n\n IVehicle subject = new ExplicitVehicle\n {\n VehicleId = 2 // instance member\n };\n\n subject.VehicleId = 1; // interface member\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingMissingMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_respecting_declared_types_explicit_interface_member_on_interfaced_expectation_should_be_used()\n {\n // Arrange\n IVehicle expected = new ExplicitVehicle\n {\n VehicleId = 2 // instance member\n };\n\n expected.VehicleId = 1; // interface member\n\n IVehicle subject = new Vehicle\n {\n VehicleId = 1\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.PreferringDeclaredMemberTypes());\n }\n\n [Fact]\n public void When_respecting_runtime_types_explicit_interface_member_on_interfaced_subject_should_not_be_used()\n {\n // Arrange\n IVehicle expected = new Vehicle\n {\n VehicleId = 1\n };\n\n IVehicle subject = new ExplicitVehicle\n {\n VehicleId = 2 // instance member\n };\n\n subject.VehicleId = 1; // interface member\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected, opt => opt.PreferringRuntimeMemberTypes());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_respecting_runtime_types_explicit_interface_member_on_interfaced_expectation_should_not_be_used()\n {\n // Arrange\n IVehicle expected = new ExplicitVehicle\n {\n VehicleId = 2 // instance member\n };\n\n expected.VehicleId = 1; // interface member\n\n IVehicle subject = new Vehicle\n {\n VehicleId = 1\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected, opt => opt.PreferringRuntimeMemberTypes());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_respecting_declared_types_explicit_interface_member_on_expectation_should_not_be_used()\n {\n // Arrange\n var expected = new ExplicitVehicle\n {\n VehicleId = 2\n };\n\n ((IVehicle)expected).VehicleId = 1;\n\n var subject = new Vehicle\n {\n VehicleId = 1\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Can_find_explicitly_implemented_property_on_the_subject()\n {\n // Arrange\n IPerson person = new Person();\n person.Name = \"Bob\";\n\n // Act / Assert\n person.Should().BeEquivalentTo(new { Name = \"Bob\" });\n }\n\n [Fact]\n public void Can_exclude_explicitly_implemented_properties()\n {\n // Arrange\n var subject = new Person\n {\n NormalProperty = \"Normal\",\n };\n\n ((IPerson)subject).Name = \"Bob\";\n\n var expectation = new Person\n {\n NormalProperty = \"Normal\",\n };\n\n ((IPerson)expectation).Name = \"Jim\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.ExcludingExplicitlyImplementedProperties());\n }\n\n private interface IPerson\n {\n string Name { get; set; }\n }\n\n private class Person : IPerson\n {\n [UsedImplicitly]\n public string NormalProperty { get; set; }\n\n string IPerson.Name { get; set; }\n }\n\n [Fact]\n public void Excluding_an_interface_property_through_inheritance_should_work()\n {\n // Arrange\n IInterfaceWithTwoProperties[] actual =\n [\n new DerivedClassImplementingInterface\n {\n Value1 = 1,\n Value2 = 2\n }\n ];\n\n IInterfaceWithTwoProperties[] expected =\n [\n new DerivedClassImplementingInterface\n {\n Value1 = 999,\n Value2 = 2\n }\n ];\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, options => options\n .Excluding(a => a.Value1)\n .PreferringRuntimeMemberTypes());\n }\n\n [Fact]\n public void Including_an_interface_property_through_inheritance_should_work()\n {\n // Arrange\n IInterfaceWithTwoProperties[] actual =\n [\n new DerivedClassImplementingInterface\n {\n Value1 = 1,\n Value2 = 2\n }\n ];\n\n IInterfaceWithTwoProperties[] expected =\n [\n new DerivedClassImplementingInterface\n {\n Value1 = 999,\n Value2 = 2\n }\n ];\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, options => options\n .Including(a => a.Value2)\n .PreferringRuntimeMemberTypes());\n }\n\n public interface IInterfaceWithTwoProperties\n {\n int Value1 { get; set; }\n\n int Value2 { get; set; }\n }\n\n public class BaseProvidingSamePropertiesAsInterface\n {\n public int Value1 { get; set; }\n\n public int Value2 { get; set; }\n }\n\n public class DerivedClassImplementingInterface : BaseProvidingSamePropertiesAsInterface, IInterfaceWithTwoProperties;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/CollectionSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Immutable;\nusing System.Collections.ObjectModel;\nusing System.Linq;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class CollectionSpecs\n{\n public interface IInterface\n {\n int InterfaceProperty { get; set; }\n }\n\n public class MyClass : IInterface\n {\n public int InterfaceProperty { get; set; }\n\n public int ClassProperty { get; set; }\n }\n\n public class SubDummy\n {\n public SubDummy(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n\n public override bool Equals(object obj)\n {\n return obj is SubDummy subDummy\n && Id == subDummy.Id;\n }\n\n public override int GetHashCode()\n {\n return Id.GetHashCode();\n }\n }\n\n public class TestDummy\n {\n public TestDummy(SubDummy sd)\n {\n Sd = sd;\n }\n\n public SubDummy Sd { get; }\n }\n\n private class NonGenericCollection : ICollection\n {\n private readonly IList inner;\n\n public NonGenericCollection(IList inner)\n {\n this.inner = inner;\n }\n\n public IEnumerator GetEnumerator()\n {\n foreach (var @object in inner)\n {\n yield return @object;\n }\n }\n\n public void CopyTo(Array array, int index)\n {\n ((ICollection)inner).CopyTo(array, index);\n }\n\n public int Count => inner.Count;\n\n public object SyncRoot => ((ICollection)inner).SyncRoot;\n\n public bool IsSynchronized => ((ICollection)inner).IsSynchronized;\n }\n\n private class EnumerableOfStringAndObject : IEnumerable, IEnumerable\n {\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public IEnumerator GetEnumerator()\n {\n yield return string.Empty;\n }\n }\n\n public class MyObject\n {\n public string MyString { get; set; }\n\n public ClassIdentifiedById Child { get; set; }\n }\n\n public class ClassIdentifiedById\n {\n public int Id { get; set; }\n\n public string MyChildString { get; set; }\n\n public override bool Equals(object obj)\n {\n return obj is ClassIdentifiedById other && other.Id == Id;\n }\n\n public override int GetHashCode()\n {\n return Id.GetHashCode();\n }\n }\n\n private class SelectPropertiesSelectionRule : IMemberSelectionRule\n {\n public bool OverridesStandardIncludeRules => throw new NotImplementedException();\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return context.Type.GetProperties().Select(pi => new Property(pi, currentNode));\n }\n\n bool IMemberSelectionRule.IncludesMembers => OverridesStandardIncludeRules;\n }\n\n private class SelectNoMembersSelectionRule : IMemberSelectionRule\n {\n public bool OverridesStandardIncludeRules => true;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return [];\n }\n\n bool IMemberSelectionRule.IncludesMembers => OverridesStandardIncludeRules;\n }\n\n public class UserRolesLookupElement\n {\n private readonly Dictionary> innerRoles = [];\n\n public virtual Dictionary> Roles\n => innerRoles.ToDictionary(x => x.Key, y => y.Value.Select(z => z));\n\n public void Add(Guid userId, params string[] roles)\n {\n innerRoles[userId] = roles.ToList();\n }\n }\n\n public class ExceptionThrowingClass\n {\n#pragma warning disable CA1065 // this is for testing purposes.\n public object ExceptionThrowingProperty => throw new NotImplementedException();\n#pragma warning restore CA1065\n }\n\n [Fact]\n public void When_the_expectation_is_an_array_of_interface_type_it_should_respect_declared_types()\n {\n // Arrange\n var actual = new IInterface[]\n {\n new MyClass { InterfaceProperty = 1, ClassProperty = 42 }\n };\n\n var expected = new IInterface[]\n {\n new MyClass { InterfaceProperty = 1, ClassProperty = 1337 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().NotThrow(\"it should respect the declared types on IInterface\");\n }\n\n [Fact]\n public void When_the_expectation_has_fewer_dimensions_than_a_multi_dimensional_subject_it_should_fail()\n {\n // Arrange\n object objectA = new();\n object objectB = new();\n\n object[][] actual = [[objectA, objectB]];\n var expected = actual[0];\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be a collection with 2 item(s)*contains 1 item(s) less than*\",\n \"adding a `params object[]` overload cannot distinguish 'an array of objects' from 'an element which is an array of objects'\");\n }\n\n [Fact]\n public void When_the_expectation_is_an_array_of_anonymous_types_it_should_respect_runtime_types()\n {\n // Arrange\n var actual = new[] { new { A = 1, B = 2 }, new { A = 1, B = 2 } };\n var expected = new object[] { new { A = 1 }, new { B = 2 } };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_byte_array_does_not_match_strictly_it_should_throw()\n {\n // Arrange\n var subject = new byte[] { 1, 2, 3, 4, 5, 6 };\n\n var expectation = new byte[] { 6, 5, 4, 3, 2, 1 };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*subject[0]*6*1*\");\n }\n\n [Fact]\n public void When_a_byte_array_does_not_match_strictly_and_order_is_not_strict_it_should_throw()\n {\n // Arrange\n var subject = new byte[] { 1, 2, 3, 4, 5, 6 };\n\n var expectation = new byte[] { 6, 5, 4, 3, 2, 1 };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options.WithoutStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*subject[0]*6*1*\");\n }\n\n [Fact]\n public void\n When_a_collection_property_is_a_byte_array_which_does_not_match_strictly_and_order_is_not_strict_it_should_throw()\n {\n // Arrange\n var subject = new { bytes = new byte[] { 1, 2, 3, 4, 5, 6 } };\n\n var expectation = new { bytes = new byte[] { 6, 5, 4, 3, 2, 1 } };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options.WithoutStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected *bytes[0]*6*1*\");\n }\n\n [Fact]\n public void When_a_collection_does_not_match_it_should_include_items_in_message()\n {\n // Arrange\n int[] subject = [1, 2];\n\n int[] expectation = [3, 2, 1];\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*but*{1, 2}*1 item(s) less than*{3, 2, 1}*\");\n }\n\n [Fact]\n public void When_collection_of_same_count_does_not_match_it_should_include_at_most_10_items_in_message()\n {\n // Arrange\n // Subjects contains different values, because we want to distinguish them in the assertion message\n var subject = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\n var expectation = Enumerable.Repeat(20, subject.Length).ToArray();\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw().Which\n .Message.Should().Contain(\"[9]\").And.NotContain(\"[10]\");\n }\n\n [Fact]\n public void When_a_nullable_collection_does_not_match_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n Values = (ImmutableArray?)ImmutableArray.Create(1, 2, 3)\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(new\n {\n Values = (ImmutableArray?)ImmutableArray.Create(1, 2, 4)\n });\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Values[2]*to be 4, but found 3*\");\n }\n\n [Fact]\n public void\n When_a_collection_contains_a_reference_to_an_object_that_is_also_in_its_parent_it_should_not_be_treated_as_a_cyclic_reference()\n {\n // Arrange\n var logbook = new LogbookCode(\"SomeKey\");\n\n var logbookEntry = new LogbookEntryProjection\n {\n Logbook = logbook,\n LogbookRelations = [new LogbookRelation { Logbook = logbook }]\n };\n\n var equivalentLogbookEntry = new LogbookEntryProjection\n {\n Logbook = logbook,\n LogbookRelations = [new LogbookRelation { Logbook = logbook }]\n };\n\n // Act / Assert\n logbookEntry.Should().BeEquivalentTo(equivalentLogbookEntry);\n }\n\n [Fact]\n public void When_a_collection_contains_less_items_than_expected_it_should_throw()\n {\n // Arrange\n var expected = new\n {\n Customers = new[]\n {\n new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" },\n new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"Jane\" }\n }\n };\n\n var subject = new\n {\n Customers = new[] { new CustomerDto { Age = 24, Birthdate = 21.September(1973), Name = \"John\" } }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*Customers*to be a collection with 2 item(s), but*contains 1 item(s) less than*\");\n }\n\n [Fact]\n public void When_a_collection_contains_more_items_than_expected_it_should_throw()\n {\n // Arrange\n var expected = new { Customers = new[] { new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" } } };\n\n var subject = new\n {\n Customers = new[]\n {\n new CustomerDto { Age = 38, Birthdate = 20.September(1973), Name = \"Jane\" },\n new CustomerDto { Age = 24, Birthdate = 21.September(1973), Name = \"John\" }\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*Customers*to be a collection with 1 item(s), but*contains 1 item(s) more than*\");\n }\n\n [Fact]\n public void When_a_collection_property_contains_objects_with_matching_properties_in_any_order_it_should_not_throw()\n {\n // Arrange\n var expected = new\n {\n Customers = new[]\n {\n new Customer { Age = 32, Birthdate = 31.July(1978), Name = \"Jane\" },\n new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" }\n }\n };\n\n var subject = new\n {\n Customers = new[]\n {\n new CustomerDto { Age = 38, Birthdate = 20.September(1973), Name = \"John\" },\n new CustomerDto { Age = 32, Birthdate = 31.July(1978), Name = \"Jane\" }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, o => o.ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_two_deeply_nested_collections_are_equivalent_while_ignoring_the_order_it_should_not_throw()\n {\n // Arrange\n int[][] subject = [[], [42]];\n int[][] expectation = [[42], []];\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_a_collection_property_contains_objects_with_mismatching_properties_it_should_throw()\n {\n // Arrange\n var expected = new { Customers = new[] { new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" } } };\n\n var subject = new\n {\n Customers = new[] { new CustomerDto { Age = 38, Birthdate = 20.September(1973), Name = \"Jane\" } }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Customers[0].Name*Jane*John*\");\n }\n\n [Fact]\n public void When_the_subject_is_a_non_generic_collection_it_should_still_work()\n {\n // Arrange\n object item = new();\n object[] array = [item];\n IList readOnlyList = ArrayList.ReadOnly(array);\n\n // Act / Assert\n readOnlyList.Should().BeEquivalentTo(array);\n }\n\n [Fact]\n public void When_a_collection_property_was_expected_but_the_property_is_not_a_collection_it_should_throw()\n {\n // Arrange\n var subject = new { Customers = \"Jane, John\" };\n\n var expected = new { Customers = new[] { new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" } } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected*Customers*collection*String*\");\n }\n\n [Fact]\n public void When_a_complex_object_graph_with_collections_matches_expectations_it_should_not_throw()\n {\n // Arrange\n var subject = new { Bytes = new byte[] { 1, 2, 3, 4 }, Object = new { A = 1, B = 2 } };\n\n var expected = new { Bytes = new byte[] { 1, 2, 3, 4 }, Object = new { A = 1, B = 2 } };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_deeply_nested_property_of_a_collection_with_an_invalid_value_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Text = \"Root\",\n Level = new\n {\n Text = \"Level1\",\n Level = new { Text = \"Level2\" },\n Collection = new[] { new { Number = 1, Text = \"Text\" }, new { Number = 2, Text = \"Actual\" } }\n }\n };\n\n var expected = new\n {\n Text = \"Root\",\n Level = new\n {\n Text = \"Level1\",\n Level = new { Text = \"Level2\" },\n Collection = new[] { new { Number = 1, Text = \"Text\" }, new { Number = 2, Text = \"Expected\" } }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.Excluding(x => x.Level.Collection[1].Number).Excluding(x => x.Level.Collection[1].Text));\n }\n\n public class For\n {\n [Fact]\n public void When_property_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 3,\n Text = \"Actual\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection)\n .Exclude(x => x.Number));\n }\n\n [Fact]\n public void When_property_in_collection_is_excluded_it_should_not_throw_if_root_is_a_collection()\n {\n // Arrange\n var subject = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 3,\n Text = \"Actual\"\n }\n }\n }\n };\n\n // Act / Assert\n new[] { subject }.Should().BeEquivalentTo([expected],\n options => options\n .For(x => x.Level.Collection)\n .Exclude(x => x.Number));\n }\n\n [Fact]\n public void When_collection_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n NextCollection = new[]\n {\n new\n {\n Text = \"Text\"\n }\n }\n },\n new\n {\n Number = 2,\n NextCollection = new[]\n {\n new\n {\n Text = \"Actual\"\n }\n }\n }\n }\n }\n };\n\n var expected = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n NextCollection = new[]\n {\n new\n {\n Text = \"Text\"\n }\n }\n },\n new\n {\n Number = 2,\n NextCollection = new[]\n {\n new\n {\n Text = \"Expected\"\n }\n }\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection)\n .Exclude(x => x.NextCollection));\n }\n\n [Fact]\n public void When_property_in_collection_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Text = \"Text\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n NextCollection = new[]\n {\n new\n {\n Text = \"Text\"\n }\n }\n },\n new\n {\n Number = 2,\n NextCollection = new[]\n {\n new\n {\n Text = \"Actual\"\n }\n }\n }\n }\n }\n };\n\n var expected = new\n {\n Text = \"Text\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n NextCollection = new[]\n {\n new\n {\n Text = \"Text\"\n }\n }\n },\n new\n {\n Number = 2,\n NextCollection = new[]\n {\n new\n {\n Text = \"Expected\"\n }\n }\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection)\n .For(x => x.NextCollection)\n .Exclude(x => x.Text)\n );\n }\n\n [Fact]\n public void When_property_in_object_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Text = \"Expected\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Collection)\n .Exclude(x => x.Level.Text)\n );\n }\n\n [Fact]\n public void When_property_in_object_in_collection_in_object_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Text = \"Actual\"\n }\n }\n }\n }\n }\n }\n };\n\n var expected = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Text = \"Expected\"\n }\n }\n }\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Collection)\n .For(x => x.Level.Collection)\n .Exclude(x => x.Level)\n );\n }\n\n [Fact]\n public void A_nested_exclusion_can_be_followed_by_a_root_level_exclusion()\n {\n // Arrange\n var subject = new\n {\n Text = \"Actual\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Text = \"Expected\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Expected\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection).Exclude(x => x.Text)\n .Excluding(x => x.Text));\n }\n\n [Fact]\n public void A_nested_exclusion_can_be_preceded_by_a_root_level_exclusion()\n {\n // Arrange\n var subject = new\n {\n Text = \"Actual\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Text = \"Expected\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Expected\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .Excluding(x => x.Text)\n .For(x => x.Level.Collection).Exclude(x => x.Text));\n }\n\n [Fact]\n public void A_nested_exclusion_can_be_followed_by_a_nested_exclusion()\n {\n // Arrange\n var subject = new\n {\n Text = \"Actual\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Text = \"Actual\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 3,\n Text = \"Expected\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection).Exclude(x => x.Text)\n .For(x => x.Level.Collection).Exclude(x => x.Number));\n }\n }\n\n [Fact]\n public void When_a_dictionary_property_is_detected_it_should_ignore_the_order_of_the_pairs()\n {\n // Arrange\n var expected = new { Customers = new Dictionary { [\"Key2\"] = \"Value2\", [\"Key1\"] = \"Value1\" } };\n\n var subject = new { Customers = new Dictionary { [\"Key1\"] = \"Value1\", [\"Key2\"] = \"Value2\" } };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_injecting_a_null_config_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = new EnumerableOfStringAndObject();\n IEnumerable collection2 = new EnumerableOfStringAndObject();\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void\n When_a_object_implements_multiple_IEnumerable_interfaces_but_the_declared_type_is_assignable_to_only_one_and_runtime_checking_is_configured_it_should_fail()\n {\n // Arrange\n IEnumerable collection1 = new EnumerableOfStringAndObject();\n IEnumerable collection2 = new EnumerableOfStringAndObject();\n\n // Act\n Action act =\n () => collection1.Should().BeEquivalentTo(collection2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw(\"the runtime type is assignable to two IEnumerable interfaces\")\n .WithMessage(\"*cannot determine which one*\");\n }\n\n [Fact]\n public void When_a_specific_property_is_included_it_should_ignore_the_rest_of_the_properties()\n {\n // Arrange\n var result = new[] { new { A = \"aaa\", B = \"bbb\" } };\n\n var expected = new { A = \"aaa\", B = \"ccc\" };\n\n // Act / Assert\n result.Should().BeEquivalentTo([expected], options => options.Including(x => x.A));\n }\n\n [Fact]\n public void\n When_a_strongly_typed_collection_is_declared_as_an_untyped_collection_and_runtime_checking_is_configured_is_should_use_the_runtime_type()\n {\n // Arrange\n ICollection collection1 = new List { new() };\n ICollection collection2 = new List { new() };\n\n // Act\n Action act =\n () => collection1.Should().BeEquivalentTo(collection2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw(\"the items have different runtime types\");\n }\n\n [Fact]\n public void When_all_strings_in_the_collection_are_equal_to_the_expected_string_it_should_succeed()\n {\n // Arrange\n var subject = new List { \"one\", \"one\", \"one\" };\n\n // Act / Assert\n subject.Should().AllBe(\"one\");\n }\n\n [Fact]\n public void When_all_strings_in_the_collection_are_equal_to_the_expected_string_it_should_allow_chaining()\n {\n // Arrange\n var subject = new List { \"one\", \"one\", \"one\" };\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\").And.HaveCount(3);\n }\n\n [Fact]\n public void When_some_string_in_the_collection_is_not_equal_to_the_expected_string_it_should_throw()\n {\n // Arrange\n string[] subject = [\"one\", \"two\", \"six\"];\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\");\n\n // Assert\n action.Should().Throw().WithMessage(\"\"\"\n Expected subject[1]*to be *\"two\"*\"one\"*\n Expected subject[2]*to be *\"six\"*\"one\"*\n \"\"\");\n }\n\n [Fact]\n public void When_some_string_in_the_collection_is_in_different_case_than_expected_string_it_should_throw()\n {\n // Arrange\n string[] subject = [\"one\", \"One\", \"ONE\"];\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\");\n\n // Assert\n action.Should().Throw().WithMessage(\"\"\"\n Expected subject[1]*to be *\"One\"*\"one\"*\n Expected subject[2]*to be *\"ONE\"*\"one\"*\n \"\"\");\n }\n\n [Fact]\n public void When_more_than_10_strings_in_the_collection_are_not_equal_to_expected_string_only_10_are_reported()\n {\n // Arrange\n var subject = Enumerable.Repeat(\"two\", 11);\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\");\n\n // Assert\n action.Should().Throw().Which\n .Message.Should().Contain(\"\"\"\n subject[9] to be the same string, but they differ at index 0:\n ↓ (actual)\n \"two\"\n \"one\"\n ↑ (expected).\n \"\"\")\n .And.NotContain(\"subject[10]\");\n }\n\n [Fact]\n public void\n When_some_strings_in_the_collection_are_not_equal_to_expected_string_for_huge_table_execution_time_should_still_be_short()\n {\n // Arrange\n const int N = 100000;\n var subject = new List(N) { \"one\" };\n\n for (int i = 1; i < N; i++)\n {\n subject.Add(\"two\");\n }\n\n // Act\n Action action = () =>\n {\n try\n {\n subject.Should().AllBe(\"one\");\n }\n catch\n {\n // ignored, we only care about execution time\n }\n };\n\n // Assert\n action.ExecutionTime().Should().BeLessThan(1.Seconds());\n }\n\n [Fact]\n public void When_all_subject_items_are_equivalent_to_expectation_object_it_should_succeed()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"someDto\", Age = 1 },\n new() { Name = \"someDto\", Age = 1 },\n new() { Name = \"someDto\", Age = 1 }\n };\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo(new\n {\n Name = \"someDto\",\n Age = 1,\n Birthdate = default(DateTime)\n });\n }\n\n [Fact]\n public void When_all_subject_items_are_equivalent_to_expectation_object_it_should_allow_chaining()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"someDto\", Age = 1 },\n new() { Name = \"someDto\", Age = 1 },\n new() { Name = \"someDto\", Age = 1 }\n };\n var expectation = new\n {\n Name = \"someDto\",\n Age = 1,\n Birthdate = default(DateTime)\n };\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo(expectation).And.HaveCount(3);\n }\n\n [Fact]\n public void When_some_subject_items_are_not_equivalent_to_expectation_object_it_should_throw()\n {\n // Arrange\n int[] subject = [1, 2, 3];\n\n // Act\n Action action = () => subject.Should().AllBeEquivalentTo(1);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected subject[1]*to be 1, but found 2.*Expected subject[2]*to be 1, but found 3*\");\n }\n\n [Fact]\n public void When_more_than_10_subjects_items_are_not_equivalent_to_expectation_only_10_are_reported()\n {\n // Arrange\n var subject = Enumerable.Repeat(2, 11);\n\n // Act\n Action action = () => subject.Should().AllBeEquivalentTo(1);\n\n // Assert\n action.Should().Throw().Which\n .Message.Should().Contain(\"subject[9] to be 1, but found 2\")\n .And.NotContain(\"item[10]\");\n }\n\n [Fact]\n public void\n When_some_subject_items_are_not_equivalent_to_expectation_for_huge_table_execution_time_should_still_be_short()\n {\n // Arrange\n const int N = 100000;\n var subject = new List(N) { 1 };\n\n for (int i = 1; i < N; i++)\n {\n subject.Add(2);\n }\n\n // Act\n Action action = () =>\n {\n try\n {\n subject.Should().AllBeEquivalentTo(1);\n }\n catch\n {\n // ignored, we only care about execution time\n }\n };\n\n // Assert\n action.ExecutionTime().Should().BeLessThan(1.Seconds());\n }\n\n [Fact]\n public void\n When_an_object_implements_multiple_IEnumerable_interfaces_but_the_declared_type_is_assignable_to_only_one_it_should_respect_the_declared_type()\n {\n // Arrange\n IEnumerable collection1 = new EnumerableOfStringAndObject();\n IEnumerable collection2 = new EnumerableOfStringAndObject();\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().NotThrow(\"the declared type is assignable to only one IEnumerable interface\");\n }\n\n [Fact]\n public void When_an_unordered_collection_must_be_strict_using_a_predicate_it_should_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options =>\n options.WithStrictOrderingFor(s => s.Path.Contains(\"UnorderedCollection\")));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*Expected*[0].UnorderedCollection*5 item(s)*empty collection*\");\n }\n\n [Fact]\n public void\n When_an_unordered_collection_must_be_strict_using_a_predicate_and_order_was_reset_to_not_strict_it_should_not_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options =>\n options\n .WithStrictOrderingFor(s => s.Path.Contains(\"UnorderedCollection\"))\n .WithoutStrictOrdering());\n }\n\n [Fact]\n public void When_an_unordered_collection_must_be_strict_using_an_expression_it_should_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act\n Action action =\n () =>\n subject.Should().BeEquivalentTo(expectation,\n options => options\n .WithStrictOrderingFor(\n s => s.UnorderedCollection));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"*Expected*[0].UnorderedCollection*5 item(s)*empty collection*\");\n }\n\n [Fact]\n public void Can_force_strict_ordering_based_on_the_parent_type_of_an_unordered_collection()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrderingFor(oi => oi.ParentType == expectation[0].GetType()));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*Expected*[0].UnorderedCollection*5 item(s)*empty collection*\");\n }\n\n [Fact]\n public void\n When_an_unordered_collection_must_be_strict_using_an_expression_and_order_is_reset_to_not_strict_it_should_not_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n options => options\n .WithStrictOrderingFor(s => s.UnorderedCollection)\n .WithoutStrictOrdering());\n }\n\n [Fact]\n public void When_an_unordered_collection_must_not_be_strict_using_a_predicate_it_should_not_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrdering()\n .WithoutStrictOrderingFor(s => s.Path.Contains(\"UnorderedCollection\")));\n }\n\n [Fact]\n public void When_an_unordered_collection_must_not_be_strict_using_an_expression_it_should_not_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrdering()\n .WithoutStrictOrderingFor(x => x.UnorderedCollection));\n }\n\n [Fact]\n public void\n When_an_unordered_collection_must_not_be_strict_using_a_predicate_and_order_was_reset_to_strict_it_should_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrdering()\n .WithoutStrictOrderingFor(s => s.Path.Contains(\"UnorderedCollection\"))\n .WithStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"*Expected*subject[0].UnorderedCollection[0]*to be 2, but found 1.*Expected subject[0].UnorderedCollection[1]*to be 1, but found 2*\");\n }\n\n [Fact]\n public void When_an_unordered_collection_must_not_be_strict_using_an_expression_and_collection_is_not_equal_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n UnorderedCollection = new[] { 1 }\n };\n\n var expectation = new\n {\n UnorderedCollection = new[] { 2 }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrdering()\n .WithoutStrictOrderingFor(x => x.UnorderedCollection));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*not strict*\");\n }\n\n [Fact]\n public void Can_request_strict_ordering_using_an_expression_that_points_to_the_collection_items()\n {\n // Arrange\n var subject = new List { \"first\", \"second\" };\n\n var expectation = new List { \"second\", \"first\" };\n\n var act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.WithStrictOrderingFor(v => v));\n\n act.Should().Throw().WithMessage(\"Expected*second*but*first*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_collections_and_configured_to_use_runtime_properties_it_should_respect_the_runtime_type()\n {\n // Arrange\n ICollection collection1 = new NonGenericCollection([new Customer()]);\n ICollection collection2 = new NonGenericCollection([new Car()]);\n\n // Act\n Action act =\n () =>\n collection1.Should().BeEquivalentTo(collection2,\n opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw(\"the types have different properties\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_generic_collections_it_should_respect_the_declared_type()\n {\n // Arrange\n var collection1 = new Collection { new DerivedCustomerType(\"123\") };\n var collection2 = new Collection { new(\"123\") };\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().NotThrow(\"the objects are equivalent according to the members on the declared type\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_non_generic_collections_it_should_respect_the_runtime_type()\n {\n // Arrange\n ICollection subject = new NonGenericCollection([new Customer()]);\n ICollection expectation = new NonGenericCollection([new Car()]);\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Wheels*not have*VehicleId*not have*\");\n }\n\n [Fact]\n public void When_custom_assertion_rules_are_utilized_the_rules_should_be_respected()\n {\n // Arrange\n var subject = new[]\n {\n new { Value = new Customer { Name = \"John\", Age = 31, Id = 1 } },\n new { Value = new Customer { Name = \"Jane\", Age = 24, Id = 2 } }\n };\n\n var expectation = new[]\n {\n new { Value = new CustomerDto { Name = \"John\", Age = 30 } },\n new { Value = new CustomerDto { Name = \"Jane\", Age = 24 } }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opts => opts\n .Using(ctx => ctx.Subject.Should().BeInRange(ctx.Expectation - 1, ctx.Expectation + 1))\n .WhenTypeIs()\n );\n }\n\n [Fact]\n public void When_expectation_is_null_enumerable_it_should_throw()\n {\n // Arrange\n IEnumerable subject = [];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo((IEnumerable)null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject*to be , but found*\");\n }\n\n [Fact]\n public void When_nested_objects_are_excluded_from_collections_it_should_use_simple_equality_semantics()\n {\n // Arrange\n var actual = new MyObject\n {\n MyString = \"identical string\",\n Child = new ClassIdentifiedById { Id = 1, MyChildString = \"identical string\" }\n };\n\n var expectation = new MyObject\n {\n MyString = \"identical string\",\n Child = new ClassIdentifiedById { Id = 1, MyChildString = \"DIFFERENT STRING\" }\n };\n\n IList actualList = new List { actual };\n IList expectationList = new List { expectation };\n\n // Act / Assert\n actualList.Should().BeEquivalentTo(expectationList, opt => opt.WithoutRecursing());\n }\n\n [Fact]\n public void When_no_collection_item_matches_it_should_report_the_closest_match()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 30, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"Jane\", Age = 30, Id = 2 },\n new() { Name = \"John\", Age = 28, Id = 1 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*[1].Age*28*27*\");\n }\n\n [Fact]\n public void When_only_a_deeply_nested_property_is_included_it_should_exclude_the_other_properties()\n {\n // Arrange\n var actualObjects = new[]\n {\n new { SubObject = new { Property1 = \"John\", Property2 = \"John\" } },\n new { SubObject = new { Property1 = \"John\", Property2 = \"John\" } }\n };\n\n var expectedObjects = new[]\n {\n new { SubObject = new { Property1 = \"John\", Property2 = \"John\" } },\n new { SubObject = new { Property1 = \"John\", Property2 = \"Jane\" } }\n };\n\n // Act / Assert\n actualObjects.Should().BeEquivalentTo(expectedObjects, options =>\n options.Including(order => order.SubObject.Property1));\n }\n\n [Fact]\n public void When_selection_rules_are_configured_they_should_be_evaluated_from_last_to_first()\n {\n // Arrange\n var list1 = new[] { new { Value = 3 } };\n var list2 = new[] { new { Value = 2 } };\n\n // Act\n Action act = () => list1.Should().BeEquivalentTo(list2, config =>\n {\n config.WithoutSelectionRules();\n config.Using(new SelectNoMembersSelectionRule());\n config.Using(new SelectPropertiesSelectionRule());\n return config;\n });\n\n // Assert\n act.Should().Throw().WithMessage(\"*to be 2, but found 3*\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_generic_overload_it_should_throw()\n {\n // Arrange\n var list1 = new[] { new { Value = 3 } };\n var list2 = new[] { new { Value = 2 } };\n\n // Act\n Action act = () => list1.Should().BeEquivalentTo(list2, config: null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_subject_and_expectation_are_null_enumerable_it_should_succeed()\n {\n // Arrange\n IEnumerable subject = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo((IEnumerable)null);\n }\n\n [Fact]\n public void When_string_collection_subject_is_empty_and_expectation_is_object_succeed()\n {\n // Arrange\n var subject = new List();\n\n // Act / Assert\n subject.Should().AllBe(\"one\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_AllBe_for_string_collection_it_should_throw()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\", config: null);\n\n // Assert\n action.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_all_string_subject_items_are_equal_to_expectation_object_with_a_config_it_should_succeed()\n {\n // Arrange\n var subject = new List { \"one\", \"one\" };\n\n // Act / Assert\n subject.Should().AllBe(\"one\", opt => opt);\n }\n\n [Fact]\n public void When_not_all_string_subject_items_are_equal_to_expectation_object_with_a_config_it_should_fail()\n {\n // Arrange\n var subject = new List { \"one\", \"two\" };\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\", opt => opt, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*we want to test the failure message*\");\n }\n\n [Fact]\n public void When_all_string_subject_items_are_equal_to_expectation_object_with_a_config_it_should_allow_chaining()\n {\n // Arrange\n var subject = new List { \"one\", \"one\" };\n\n // Act / Assert\n subject.Should().AllBe(\"one\", opt => opt)\n .And.HaveCount(2);\n }\n\n [Fact]\n public void When_subject_is_empty_and_expectation_is_object_succeed()\n {\n // Arrange\n var subject = new List();\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo('g');\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_AllBeEquivalentTo_it_should_throw()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action action = () => subject.Should().AllBeEquivalentTo('g', config: null);\n\n // Assert\n action.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_all_subject_items_are_equivalent_to_expectation_object_with_a_config_it_should_succeed()\n {\n // Arrange\n var subject = new List { 'g', 'g' };\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo('g', opt => opt);\n }\n\n [Fact]\n public void When_not_all_subject_items_are_equivalent_to_expectation_object_with_a_config_it_should_fail()\n {\n // Arrange\n var subject = new List { 'g', 'a' };\n\n // Act\n Action action = () =>\n subject.Should().AllBeEquivalentTo('g', opt => opt, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*we want to test the failure message*\");\n }\n\n [Fact]\n public void When_all_subject_items_are_equivalent_to_expectation_object_with_a_config_it_should_allow_chaining()\n {\n // Arrange\n var subject = new List { 'g', 'g' };\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo('g', opt => opt)\n .And.HaveCount(2);\n }\n\n [Fact]\n public void When_subject_is_null_and_expectation_is_enumerable_it_should_throw()\n {\n // Arrange\n IEnumerable subject = null;\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(Enumerable.Empty());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject*not to be *\");\n }\n\n [Fact]\n public void When_the_expectation_is_null_it_should_throw()\n {\n // Arrange\n int[,] actual =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual*to be *{{1, 2, 3}, {4, 5, 6}}*\");\n }\n\n [Fact]\n public void When_a_multi_dimensional_array_is_compared_to_null_it_should_throw()\n {\n // Arrange\n Array actual = null;\n\n int[,] expectation =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare a multi-dimensional array to *\");\n }\n\n [Fact]\n public void When_a_multi_dimensional_array_is_compared_to_a_non_array_it_should_throw()\n {\n // Arrange\n var actual = new object();\n\n int[,] expectation =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare a multi-dimensional array to something else*\");\n }\n\n [Fact]\n public void When_the_length_of_the_2nd_dimension_differs_between_the_arrays_it_should_throw()\n {\n // Arrange\n int[,] actual =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n int[,] expectation = { { 1, 2, 3 } };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dimension 0 to contain 1 item(s), but found 2*\");\n }\n\n [Fact]\n public void When_the_length_of_the_first_dimension_differs_between_the_arrays_it_should_throw()\n {\n // Arrange\n int[,] actual =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n int[,] expectation =\n {\n { 1, 2 },\n { 4, 5 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dimension 1 to contain 2 item(s), but found 3*\");\n }\n\n [Fact]\n public void When_the_number_of_dimensions_of_the_arrays_are_not_the_same_it_should_throw()\n {\n // Arrange\n#pragma warning disable format // VS and Rider disagree on how to format a multidimensional array initializer\n int[,,] actual =\n {\n {\n { 1 },\n { 2 },\n { 3 }\n },\n {\n { 4 },\n { 5 },\n { 6 }\n }\n };\n#pragma warning restore format\n\n int[,] expectation =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual*2 dimension(s)*but it has 3*\");\n }\n\n [Fact]\n public void When_the_other_dictionary_does_not_contain_enough_items_it_should_throw()\n {\n // Arrange\n var expected = new { Customers = new Dictionary { [\"Key1\"] = \"Value1\", [\"Key2\"] = \"Value2\" } };\n\n var subject = new { Customers = new Dictionary { [\"Key1\"] = \"Value1\" } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Customers*dictionary*2 item(s)*but*misses*Key2*\");\n }\n\n [Fact]\n public void When_the_other_property_is_not_a_dictionary_it_should_throw()\n {\n // Arrange\n var expected = new { Customers = \"I am a string\" };\n\n var subject = new { Customers = new Dictionary { [\"Key2\"] = \"Value2\", [\"Key1\"] = \"Value1\" } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*property*Customers*String*found*Dictionary*\");\n }\n\n [Fact]\n public void\n When_the_root_object_is_referenced_from_an_object_in_a_nested_collection_it_should_treat_it_as_a_cyclic_reference()\n {\n // Arrange\n var company1 = new MyCompany { Name = \"Company\" };\n var user1 = new MyUser { Name = \"User\", Company = company1 };\n company1.Users = [user1];\n company1.Logo = new MyCompanyLogo { Url = \"blank\", Company = company1, CreatedBy = user1 };\n\n var company2 = new MyCompany { Name = \"Company\" };\n var user2 = new MyUser { Name = \"User\", Company = company2 };\n company2.Users = [user2];\n company2.Logo = new MyCompanyLogo { Url = \"blank\", Company = company2, CreatedBy = user2 };\n\n // Act / Assert\n company1.Should().BeEquivalentTo(company2, o => o.IgnoringCyclicReferences());\n }\n\n [Fact]\n public void When_the_subject_contains_less_items_than_expected_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"*subject*to be a collection with 2 item(s), but*contains 1 item(s) less than*\");\n }\n\n [Fact]\n public void When_the_subject_contains_more_items_than_expected_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject*to be a collection with 1 item(s), but*contains 1 item(s) more than*\");\n }\n\n [Fact]\n public void When_the_subject_contains_same_number_of_items_and_both_contain_duplicates_it_should_succeed()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_the_subject_contains_same_number_of_items_but_expectation_contains_duplicates_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"John\", Age = 27, Id = 1 },\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected property subject[1].Name*to be *actual*\\\"Jane\\\" *\\\"John\\\"*expected*\");\n }\n\n [Fact]\n public void When_the_subject_contains_same_number_of_items_but_subject_contains_duplicates_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected property subject[1].Name*to be *actual*\\\"John\\\" *\\\"Jane\\\"*expected*\");\n }\n\n [Fact]\n public void\n When_two_collections_have_nested_members_of_the_contained_equivalent_but_not_equal_it_should_not_throw()\n {\n // Arrange\n var list1 = new[] { new { Nested = new ClassWithOnlyAProperty { Value = 1 } } };\n\n var list2 = new[] { new { Nested = new { Value = 1 } } };\n\n // Act / Assert\n list1.Should().BeEquivalentTo(list2, opts => opts);\n }\n\n [Fact]\n public void\n When_two_collections_have_properties_of_the_contained_items_excluded_but_still_differ_it_should_throw()\n {\n // Arrange\n KeyValuePair[] list1 = [new(1, 123)];\n KeyValuePair[] list2 = [new(2, 321)];\n\n // Act\n Action act = () => list1.Should().BeEquivalentTo(list2, config => config\n .Excluding(ctx => ctx.Key)\n .ComparingByMembers>());\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property list1[0].Value*to be 321, but found 123.*\");\n }\n\n [Fact]\n public void\n When_two_equivalent_dictionaries_are_compared_directly_as_if_it_is_a_collection_it_should_succeed()\n {\n // Arrange\n var result = new Dictionary { [\"C\"] = null, [\"B\"] = 0, [\"A\"] = 0 };\n\n // Act / Assert\n result.Should().BeEquivalentTo(new Dictionary\n {\n [\"A\"] = 0,\n [\"B\"] = 0,\n [\"C\"] = null\n });\n }\n\n [Fact]\n public void When_two_equivalent_dictionaries_are_compared_directly_it_should_succeed()\n {\n // Arrange\n var result = new Dictionary { [\"C\"] = 0, [\"B\"] = 0, [\"A\"] = 0 };\n\n // Act / Assert\n result.Should().BeEquivalentTo(new Dictionary { [\"A\"] = 0, [\"B\"] = 0, [\"C\"] = 0 });\n }\n\n [Fact]\n public void When_two_lists_dont_contain_the_same_structural_equal_objects_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 30, Id = 2 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*subject[1].Age*30*24*\");\n }\n\n [Fact]\n public void When_two_lists_only_differ_in_excluded_properties_it_should_not_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27 },\n new() { Name = \"Jane\", Age = 30 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n options => options\n .ExcludingMissingMembers()\n .Excluding(c => c.Age));\n }\n\n [Fact]\n public void When_two_multi_dimensional_arrays_are_equivalent_it_should_not_throw()\n {\n // Arrange\n int[,] subject =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n int[,] expectation =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_multi_dimensional_arrays_are_not_equivalent_it_should_throw()\n {\n // Arrange\n int[,] actual =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n int[,] expectation =\n {\n { 1, 2, 4 },\n { 4, -5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*actual[0,2]*4*3*actual[1,1]*-5*5*\");\n }\n\n [Fact]\n public void When_two_multi_dimensional_arrays_have_empty_dimensions_they_should_be_equivalent()\n {\n // Arrange\n Array actual = new long[,] { { } };\n\n Array expectation = new long[,] { { } };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_multi_dimensional_arrays_are_empty_they_should_be_equivalent()\n {\n // Arrange\n Array actual = new long[0, 1] { };\n\n Array expectation = new long[0, 1] { };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_nested_dictionaries_contain_null_values_it_should_not_crash()\n {\n // Arrange\n var projection = new { ReferencedEquipment = new Dictionary { [1] = null } };\n\n var persistedProjection = new { ReferencedEquipment = new Dictionary { [1] = null } };\n\n // Act / Assert\n persistedProjection.Should().BeEquivalentTo(projection);\n }\n\n [Fact]\n public void When_two_nested_dictionaries_contain_null_values_it_should_not_crash2()\n {\n // Arrange\n var userId = Guid.NewGuid();\n\n var actual = new UserRolesLookupElement();\n actual.Add(userId, \"Admin\", \"Special\");\n\n var expected = new UserRolesLookupElement();\n expected.Add(userId, \"Admin\", \"Other\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*Roles[*][1]*Special*Other*\");\n }\n\n [Fact]\n public void When_two_nested_dictionaries_do_not_match_it_should_throw()\n {\n // Arrange\n var projection = new { ReferencedEquipment = new Dictionary { [1] = \"Bla1\" } };\n\n var persistedProjection = new { ReferencedEquipment = new Dictionary { [1] = \"Bla2\" } };\n\n // Act\n Action act = () => persistedProjection.Should().BeEquivalentTo(projection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*ReferencedEquipment[1]*Bla2*Bla1*\");\n }\n\n [Fact]\n public void When_two_ordered_lists_are_structurally_equivalent_it_should_succeed()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_unordered_lists_are_structurally_equivalent_and_order_is_strict_it_should_fail()\n {\n // Arrange\n Customer[] subject =\n [\n new()\n { Name = \"John\", Age = 27, Id = 1 },\n new()\n { Name = \"Jane\", Age = 24, Id = 2 }\n ];\n\n var expectation = new Collection\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options.WithStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected property subject[0].Name*John*Jane*subject[1].Name*Jane*John*\");\n }\n\n [Fact]\n public void When_two_unordered_lists_are_structurally_equivalent_and_order_was_reset_to_strict_it_should_fail()\n {\n // Arrange\n Customer[] subject =\n [\n new()\n { Name = \"John\", Age = 27, Id = 1 },\n new()\n { Name = \"Jane\", Age = 24, Id = 2 }\n ];\n\n var expectation = new Collection\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(\n expectation,\n options => options\n .WithStrictOrdering()\n .WithoutStrictOrdering()\n .WithStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected property subject[0].Name*John*Jane*subject[1].Name*Jane*John*\");\n }\n\n [Fact]\n public void When_two_unordered_lists_are_structurally_equivalent_and_order_was_reset_to_not_strict_it_should_succeed()\n {\n // Arrange\n Customer[] subject =\n [\n new()\n { Name = \"John\", Age = 27, Id = 1 },\n new()\n { Name = \"Jane\", Age = 24, Id = 2 }\n ];\n\n var expectation = new Collection\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, x => x.WithStrictOrdering().WithoutStrictOrdering());\n }\n\n [Fact]\n public void When_two_unordered_lists_are_structurally_equivalent_it_should_succeed()\n {\n // Arrange\n Customer[] subject =\n [\n new()\n { Name = \"John\", Age = 27, Id = 1 },\n new()\n { Name = \"Jane\", Age = 24, Id = 2 }\n ];\n\n var expectation = new Collection\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_unordered_lists_contain_empty_different_objects_it_should_throw()\n {\n // Arrange\n var actual = new object[] { new() };\n var expected = new object[] { new() };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_two_unordered_lists_contain_null_in_subject_it_should_throw()\n {\n // Arrange\n var actual = new object[] { null };\n var expected = new object[] { new() };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_two_unordered_lists_contain_null_in_expectation_it_should_throw()\n {\n // Arrange\n var actual = new object[] { new() };\n var expected = new object[] { null };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Theory]\n [MemberData(nameof(ArrayTestData))]\n public void When_two_unordered_lists_contain_empty_objects_they_should_still_be_structurally_equivalent(TActual[] actual, TExpected[] expected)\n#pragma warning restore xUnit1039\n {\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_an_exception_is_thrown_during_data_access_the_stack_trace_contains_the_original_site()\n {\n // Arrange\n var genericCollectionA = new List { new() };\n\n var genericCollectionB = new List { new() };\n\n var expectedTargetSite = typeof(ExceptionThrowingClass)\n .GetProperty(nameof(ExceptionThrowingClass.ExceptionThrowingProperty))!.GetMethod;\n\n // Act\n Action act = () => genericCollectionA.Should().BeEquivalentTo(genericCollectionB);\n\n // Assert\n act.Should().Throw().And.TargetSite.Should().Be(expectedTargetSite);\n }\n\n public static TheoryData ArrayTestData()\n {\n var arrays = new object[]\n {\n new int?[] { null, 1 }, new int?[] { 1, null }, new object[] { null, 1 }, new object[] { 1, null }\n };\n\n var pairs =\n from x in arrays\n from y in arrays\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n [Fact]\n public void Comparing_lots_of_complex_objects_should_still_be_fast()\n {\n // Arrange\n ClassWithLotsOfProperties GetObject(int i)\n {\n return new ClassWithLotsOfProperties\n {\n#pragma warning disable CA1305\n Id = i.ToString(),\n Value1 = i.ToString(),\n Value2 = i.ToString(),\n Value3 = i.ToString(),\n Value4 = i.ToString(),\n Value5 = i.ToString(),\n Value6 = i.ToString(),\n Value7 = i.ToString(),\n Value8 = i.ToString(),\n Value9 = i.ToString(),\n Value10 = i.ToString(),\n Value11 = i.ToString(),\n Value12 = i.ToString(),\n#pragma warning restore CA1305\n };\n }\n\n var actual = new List();\n var expectation = new List();\n\n var maxAmount = 100;\n\n for (var i = 0; i < maxAmount; i++)\n {\n actual.Add(GetObject(i));\n expectation.Add(GetObject(maxAmount - 1 - i));\n }\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.ExecutionTime().Should().BeLessThan(20.Seconds());\n }\n\n private class ClassWithLotsOfProperties\n {\n public string Id { get; set; }\n\n public string Value1 { get; set; }\n\n public string Value2 { get; set; }\n\n public string Value3 { get; set; }\n\n public string Value4 { get; set; }\n\n public string Value5 { get; set; }\n\n public string Value6 { get; set; }\n\n public string Value7 { get; set; }\n\n public string Value8 { get; set; }\n\n public string Value9 { get; set; }\n\n public string Value10 { get; set; }\n\n public string Value11 { get; set; }\n\n public string Value12 { get; set; }\n }\n\n private class LogbookEntryProjection\n {\n public virtual LogbookCode Logbook { get; set; }\n\n public virtual ICollection LogbookRelations { get; set; }\n }\n\n private class LogbookRelation\n {\n public virtual LogbookCode Logbook { get; set; }\n }\n\n private class LogbookCode\n {\n public LogbookCode(string key)\n {\n Key = key;\n }\n\n public string Key { get; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/AttributeData.cs", "namespace AwesomeAssertions.Xml.Equivalency;\n\ninternal class AttributeData\n{\n public AttributeData(string namespaceUri, string localName, string value, string prefix)\n {\n NamespaceUri = namespaceUri;\n LocalName = localName;\n Value = value;\n Prefix = prefix;\n }\n\n public string NamespaceUri { get; }\n\n public string LocalName { get; }\n\n public string Value { get; }\n\n private string Prefix { get; }\n\n public string QualifiedName\n {\n get\n {\n if (string.IsNullOrEmpty(Prefix))\n {\n return LocalName;\n }\n\n return Prefix + \":\" + LocalName;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/CollectionMemberOrderingRuleDecorator.cs", "namespace AwesomeAssertions.Equivalency.Ordering;\n\ninternal class CollectionMemberOrderingRuleDecorator : IOrderingRule\n{\n private readonly IOrderingRule orderingRule;\n\n public CollectionMemberOrderingRuleDecorator(IOrderingRule orderingRule)\n {\n this.orderingRule = orderingRule;\n }\n\n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n return orderingRule.Evaluate(new CollectionMemberObjectInfo(objectInfo));\n }\n\n public override string ToString()\n {\n return orderingRule.ToString();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EqualityStrategyProvider.cs", "using System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal sealed class EqualityStrategyProvider\n{\n private readonly List referenceTypes = [];\n private readonly List valueTypes = [];\n private readonly ConcurrentDictionary typeCache = new();\n\n [CanBeNull]\n private readonly Func defaultStrategy;\n\n private bool? compareRecordsByValue;\n\n public EqualityStrategyProvider()\n {\n }\n\n public EqualityStrategyProvider(Func defaultStrategy)\n {\n this.defaultStrategy = defaultStrategy;\n }\n\n public bool? CompareRecordsByValue\n {\n get => compareRecordsByValue;\n set\n {\n compareRecordsByValue = value;\n typeCache.Clear();\n }\n }\n\n public EqualityStrategy GetEqualityStrategy(Type type)\n {\n // As the valueFactory parameter captures instance members,\n // be aware if the cache must be cleared on mutating the members.\n return typeCache.GetOrAdd(type, typeKey =>\n {\n if (!typeKey.IsPrimitive && referenceTypes.Count > 0 && referenceTypes.Exists(t => typeKey.IsSameOrInherits(t)))\n {\n return EqualityStrategy.ForceMembers;\n }\n else if (valueTypes.Count > 0 && valueTypes.Exists(t => typeKey.IsSameOrInherits(t)))\n {\n return EqualityStrategy.ForceEquals;\n }\n else if (!typeKey.IsPrimitive && referenceTypes.Count > 0 &&\n referenceTypes.Exists(t => typeKey.IsAssignableToOpenGeneric(t)))\n {\n return EqualityStrategy.ForceMembers;\n }\n else if (valueTypes.Count > 0 && valueTypes.Exists(t => typeKey.IsAssignableToOpenGeneric(t)))\n {\n return EqualityStrategy.ForceEquals;\n }\n else if ((compareRecordsByValue.HasValue || defaultStrategy is null) && typeKey.IsRecord())\n {\n return compareRecordsByValue is true ? EqualityStrategy.ForceEquals : EqualityStrategy.ForceMembers;\n }\n else if (defaultStrategy is not null)\n {\n return defaultStrategy(typeKey);\n }\n\n return typeKey.HasValueSemantics() ? EqualityStrategy.Equals : EqualityStrategy.Members;\n });\n }\n\n public bool AddReferenceType(Type type)\n {\n if (valueTypes.Exists(t => type.IsSameOrInherits(t)))\n {\n return false;\n }\n\n referenceTypes.Add(type);\n typeCache.Clear();\n return true;\n }\n\n public bool AddValueType(Type type)\n {\n if (referenceTypes.Exists(t => type.IsSameOrInherits(t)))\n {\n return false;\n }\n\n valueTypes.Add(type);\n typeCache.Clear();\n return true;\n }\n\n public override string ToString()\n {\n var builder = new StringBuilder();\n\n if (compareRecordsByValue is true)\n {\n builder.AppendLine(\"- Compare records by value\");\n }\n else\n {\n builder.AppendLine(\"- Compare records by their members\");\n }\n\n foreach (Type valueType in valueTypes)\n {\n builder.AppendLine(CultureInfo.InvariantCulture, $\"- Compare {valueType} by value\");\n }\n\n foreach (Type type in referenceTypes)\n {\n builder.AppendLine(CultureInfo.InvariantCulture, $\"- Compare {type} by its members\");\n }\n\n return builder.ToString();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/ByteArrayOrderingRule.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency.Ordering;\n\n/// \n/// Ordering rule that ensures that byte arrays are always compared in strict ordering since it would cause a\n/// severe performance impact otherwise.\n/// \ninternal class ByteArrayOrderingRule : IOrderingRule\n{\n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n return objectInfo.CompileTimeType.IsSameOrInherits(typeof(IEnumerable))\n ? OrderStrictness.Strict\n : OrderStrictness.Irrelevant;\n }\n\n public override string ToString()\n {\n return \"Be strict about the order of items in byte arrays\";\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Accessibility.cs", "using System;\nusing System.Collections.Generic;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Accessibility\n {\n [Fact]\n public void When_a_property_is_write_only_it_should_be_ignored()\n {\n // Arrange\n var expected = new ClassWithWriteOnlyProperty\n {\n WriteOnlyProperty = 123,\n SomeOtherProperty = \"whatever\"\n };\n\n var subject = new\n {\n SomeOtherProperty = \"whatever\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_property_is_private_it_should_be_ignored()\n {\n // Arrange\n var subject = new Customer(\"MyPassword\")\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var other = new Customer(\"SomeOtherPassword\")\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_a_field_is_private_it_should_be_ignored()\n {\n // Arrange\n var subject = new ClassWithAPrivateField(1234)\n {\n Value = 1\n };\n\n var other = new ClassWithAPrivateField(54321)\n {\n Value = 1\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_a_property_is_protected_it_should_be_ignored()\n {\n // Arrange\n var subject = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n subject.SetProtected(\"ActualValue\");\n\n var expected = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n expected.SetProtected(\"ExpectedValue\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_property_is_internal_and_it_should_be_included_it_should_fail_the_assertion()\n {\n // Arrange\n var actual = new ClassWithInternalProperty\n {\n PublicProperty = \"public\",\n InternalProperty = \"internal\",\n ProtectedInternalProperty = \"internal\"\n };\n\n var expected = new ClassWithInternalProperty\n {\n PublicProperty = \"public\",\n InternalProperty = \"also internal\",\n ProtectedInternalProperty = \"also internal\"\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.IncludingInternalProperties());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*InternalProperty*internal*also internal*ProtectedInternalProperty*\");\n }\n\n private class ClassWithInternalProperty\n {\n [UsedImplicitly]\n public string PublicProperty { get; set; }\n\n [UsedImplicitly]\n internal string InternalProperty { get; set; }\n\n [UsedImplicitly]\n protected internal string ProtectedInternalProperty { get; set; }\n }\n\n [Fact]\n public void When_a_field_is_internal_it_should_be_excluded_from_the_comparison()\n {\n // Arrange\n var actual = new ClassWithInternalField\n {\n PublicField = \"public\",\n InternalField = \"internal\",\n ProtectedInternalField = \"internal\"\n };\n\n var expected = new ClassWithInternalField\n {\n PublicField = \"public\",\n InternalField = \"also internal\",\n ProtectedInternalField = \"also internal\"\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_field_is_internal_and_it_should_be_included_it_should_fail_the_assertion()\n {\n // Arrange\n var actual = new ClassWithInternalField\n {\n PublicField = \"public\",\n InternalField = \"internal\",\n ProtectedInternalField = \"internal\"\n };\n\n var expected = new ClassWithInternalField\n {\n PublicField = \"public\",\n InternalField = \"also internal\",\n ProtectedInternalField = \"also internal\"\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.IncludingInternalFields());\n\n // Assert\n act.Should().Throw().WithMessage(\"*InternalField*internal*also internal*ProtectedInternalField*\");\n }\n\n private class ClassWithInternalField\n {\n [UsedImplicitly]\n public string PublicField;\n\n [UsedImplicitly]\n internal string InternalField;\n\n [UsedImplicitly]\n protected internal string ProtectedInternalField;\n }\n\n [Fact]\n public void When_a_property_is_internal_it_should_be_excluded_from_the_comparison()\n {\n // Arrange\n var actual = new ClassWithInternalProperty\n {\n PublicProperty = \"public\",\n InternalProperty = \"internal\",\n ProtectedInternalProperty = \"internal\"\n };\n\n var expected = new ClassWithInternalProperty\n {\n PublicProperty = \"public\",\n InternalProperty = \"also internal\",\n ProtectedInternalProperty = \"also internal\"\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void Private_protected_properties_are_ignored()\n {\n // Arrange\n var subject = new ClassWithPrivateProtectedProperty(\"Name\", 13);\n var other = new ClassWithPrivateProtectedProperty(\"Name\", 37);\n\n // Act/Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n private class ClassWithPrivateProtectedProperty\n {\n public ClassWithPrivateProtectedProperty(string name, int value)\n {\n Name = name;\n Value = value;\n }\n\n [UsedImplicitly]\n public string Name { get; }\n\n [UsedImplicitly]\n private protected int Value { get; }\n }\n\n [Fact]\n public void Private_protected_fields_are_ignored()\n {\n // Arrange\n var subject = new ClassWithPrivateProtectedField(\"Name\", 13);\n var other = new ClassWithPrivateProtectedField(\"Name\", 37);\n\n // Act/Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n private class ClassWithPrivateProtectedField\n {\n public ClassWithPrivateProtectedField(string name, int value)\n {\n Name = name;\n this.value = value;\n }\n\n [UsedImplicitly]\n public string Name;\n\n [UsedImplicitly]\n private protected int value;\n }\n\n [Fact]\n public void Normal_properties_have_priority_over_explicitly_implemented_properties()\n {\n // Arrange\n var instance = new MyClass\n {\n Message = \"instance string message\",\n };\n ((IMyInterface)instance).Message = 42;\n instance.Items.AddRange([1, 2, 3]);\n\n var other = new MyClass\n {\n Message = \"other string message\",\n };\n ((IMyInterface)other).Message = 42;\n other.Items.AddRange([1, 2, 27]);\n\n // Act\n Action act = () => instance.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*Expected property *.Message to be the same string*\" +\n \"*Expected *.Items[2] to be 27, but found 3*\"\n );\n }\n\n private class MyParentClass\n {\n public List Items { get; } = [];\n }\n\n private class MyClass : MyParentClass, IMyInterface\n {\n public string Message { get; set; }\n\n int IMyInterface.Message { get; set; }\n\n IReadOnlyCollection IMyInterface.Items => Items;\n }\n\n private interface IMyInterface\n {\n int Message { get; set; }\n\n IReadOnlyCollection Items { get; }\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Digit.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal class Digit\n{\n private readonly int length;\n private readonly Digit nextDigit;\n private int index;\n\n public Digit(int length, Digit nextDigit)\n {\n this.length = length;\n this.nextDigit = nextDigit;\n }\n\n public int[] GetIndices()\n {\n var indices = new List();\n\n Digit digit = this;\n\n while (digit is not null)\n {\n indices.Add(digit.index);\n digit = digit.nextDigit;\n }\n\n return indices.ToArray();\n }\n\n public bool Increment()\n {\n bool success = nextDigit?.Increment() == true;\n\n if (!success)\n {\n if (index < (length - 1))\n {\n index++;\n success = true;\n }\n else\n {\n index = 0;\n }\n }\n\n return success;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/XDocumentValueFormatter.cs", "using System.Xml.Linq;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class XDocumentValueFormatter : IValueFormatter\n{\n public bool CanHandle(object value)\n {\n return value is XDocument;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var document = (XDocument)value;\n\n if (document.Root is not null)\n {\n formatChild(\"root\", document.Root, formattedGraph);\n }\n else\n {\n formattedGraph.AddFragment(\"[XML document without root element]\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MemberVisibility.cs", "using System;\n\n#pragma warning disable CA1714\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Determines which members are included in the equivalency assertion\n/// \n[Flags]\npublic enum MemberVisibility\n{\n None = 0,\n Internal = 1,\n Public = 2,\n ExplicitlyImplemented = 4,\n DefaultInterfaceProperties = 8\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EqualityStrategy.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic enum EqualityStrategy\n{\n /// \n /// The object overrides , so use that.\n /// \n Equals,\n\n /// \n /// The object does not seem to override , so compare by members\n /// \n Members,\n\n /// \n /// Compare using , whether or not the object overrides it.\n /// \n ForceEquals,\n\n /// \n /// Compare the members, regardless of an override exists or not.\n /// \n ForceMembers,\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/MatchAllOrderingRule.cs", "namespace AwesomeAssertions.Equivalency.Ordering;\n\n/// \n/// An ordering rule that basically states that the order of items in all collections is important.\n/// \ninternal class MatchAllOrderingRule : IOrderingRule\n{\n /// \n /// Determines if ordering of the member referred to by the current is relevant.\n /// \n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n return OrderStrictness.Strict;\n }\n\n public override string ToString()\n {\n return \"Always be strict about the collection order\";\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Excluding.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Excluding\n {\n [Fact]\n public void A_member_excluded_by_path_is_described_in_the_failure_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\",\n Age = 13\n };\n\n var customer = new\n {\n Name = \"Jack\",\n Age = 37\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(customer, options => options\n .Excluding(d => d.Age));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Exclude*Age*\");\n }\n\n [Fact]\n public void A_member_excluded_by_predicate_is_described_in_the_failure_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\",\n Age = 13\n };\n\n var customer = new\n {\n Name = \"Jack\",\n Age = 37\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(customer, options => options\n .Excluding(ctx => ctx.Path == \"Age\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Exclude member when*Age*\");\n }\n\n [Fact]\n public void When_only_the_excluded_property_doesnt_match_it_should_not_throw()\n {\n // Arrange\n var dto = new CustomerDto\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"Dennis\"\n };\n\n // Act / Assert\n dto.Should().BeEquivalentTo(customer, options => options\n .Excluding(d => d.Name)\n .Excluding(d => d.Id));\n }\n\n [Fact]\n public void When_only_the_excluded_property_doesnt_match_it_should_not_throw_if_root_is_a_collection()\n {\n // Arrange\n var dto = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"Dennis\"\n };\n\n // Act / Assert\n new[] { dto }.Should().BeEquivalentTo(new[] { customer }, options => options\n .Excluding(d => d.Name)\n .Excluding(d => d.Id));\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_excluding_members_it_should_pass_if_only_the_excluded_members_are_different()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act =\n () =>\n class1.Should().BeEquivalentTo(class2,\n opts => opts.Excluding(o => o.Field3).Excluding(o => o.Property1));\n\n // Assert\n act.Should().NotThrow(\"the non-excluded fields have the same value\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_excluding_members_it_should_fail_if_any_non_excluded_members_are_different()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.Excluding(o => o.Property1));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Field3*\");\n }\n\n [Fact]\n public void When_all_shared_properties_match_it_should_not_throw()\n {\n // Arrange\n var dto = new CustomerDto\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new Customer\n {\n Id = 1,\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n // Act / Assert\n dto.Should().BeEquivalentTo(customer, options => options.ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_a_deeply_nested_property_with_a_value_mismatch_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1\n {\n Text = \"Level1\",\n Level = new Level2\n {\n Text = \"Mismatch\"\n }\n }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto\n {\n Text = \"Level1\",\n Level = new Level2Dto\n {\n Text = \"Level2\"\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.Excluding(r => r.Level.Level.Text));\n }\n\n [Fact]\n public void When_a_deeply_nested_property_with_a_value_mismatch_is_excluded_it_should_not_throw_if_root_is_a_collection()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1\n {\n Text = \"Level1\",\n Level = new Level2\n {\n Text = \"Mismatch\"\n }\n }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto\n {\n Text = \"Level1\",\n Level = new Level2Dto\n {\n Text = \"Level2\"\n }\n }\n };\n\n // Act / Assert\n new[] { subject }.Should().BeEquivalentTo(new[] { expected },\n options => options.Excluding(r => r.Level.Level.Text));\n }\n\n [Fact]\n public void When_a_property_with_a_value_mismatch_is_excluded_using_a_predicate_it_should_not_throw()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1\n {\n Text = \"Level1\",\n Level = new Level2\n {\n Text = \"Mismatch\"\n }\n }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto\n {\n Text = \"Level1\",\n Level = new Level2Dto\n {\n Text = \"Level2\"\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, config =>\n config.Excluding(ctx => ctx.Path == \"Level.Level.Text\"));\n }\n\n [Fact]\n public void When_members_are_excluded_by_the_access_modifier_of_the_getter_using_a_predicate_they_should_be_ignored()\n {\n // Arrange\n var subject = new ClassWithAllAccessModifiersForMembers(\"public\", \"protected\",\n \"internal\", \"protected-internal\", \"private\", \"private-protected\");\n\n var expected = new ClassWithAllAccessModifiersForMembers(\"public\", \"protected\",\n \"ignored-internal\", \"ignored-protected-internal\", \"private\", \"private-protected\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, config => config\n .IncludingInternalFields()\n .Excluding(ctx =>\n ctx.WhichGetterHas(CSharpAccessModifier.Internal) ||\n ctx.WhichGetterHas(CSharpAccessModifier.ProtectedInternal)));\n }\n\n [Fact]\n public void When_members_are_excluded_by_the_access_modifier_of_the_setter_using_a_predicate_they_should_be_ignored()\n {\n // Arrange\n var subject = new ClassWithAllAccessModifiersForMembers(\"public\", \"protected\",\n \"internal\", \"protected-internal\", \"private\", \"private-protected\");\n\n var expected = new ClassWithAllAccessModifiersForMembers(\"public\", \"protected\",\n \"ignored-internal\", \"ignored-protected-internal\", \"ignored-private\", \"private-protected\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, config => config\n .IncludingInternalFields()\n .Excluding(ctx =>\n ctx.WhichSetterHas(CSharpAccessModifier.Internal) ||\n ctx.WhichSetterHas(CSharpAccessModifier.ProtectedInternal) ||\n ctx.WhichSetterHas(CSharpAccessModifier.Private)));\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_excluding_properties_it_should_still_compare_fields()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"color\"\n };\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.ExcludingProperties());\n\n // Assert\n act.Should().Throw().WithMessage(\"*dolor*color*\");\n }\n\n [Fact]\n public void When_excluding_fields_it_should_still_compare_properties()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"different\"\n };\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.ExcludingFields());\n\n // Assert\n act.Should().Throw().WithMessage(\"*Property3*consectetur*\");\n }\n\n [Fact]\n public void When_excluding_properties_via_non_array_indexers_it_should_exclude_the_specified_paths()\n {\n // Arrange\n var subject = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 3,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 2\n }\n }\n };\n\n var expected = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 2,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 3\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .Excluding(x => x.List[1].Foo)\n .Excluding(x => x.Dictionary[\"Bar\"].Value));\n }\n\n [Fact]\n public void\n When_excluding_properties_via_non_array_indexers_it_should_exclude_the_specified_paths_if_root_is_a_collection()\n {\n // Arrange\n var subject = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 3,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 2\n }\n }\n };\n\n var expected = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 2,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 3\n }\n }\n };\n\n // Act / Assert\n new[] { subject }.Should().BeEquivalentTo(new[] { expected },\n options => options\n .Excluding(x => x.List[1].Foo)\n .Excluding(x => x.Dictionary[\"Bar\"].Value));\n }\n\n [Fact]\n public void When_excluding_properties_via_non_array_indexers_it_should_not_exclude_paths_with_different_indexes()\n {\n // Arrange\n var subject = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 3,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 2\n }\n }\n };\n\n var expected = new\n {\n List = new[]\n {\n new\n {\n Foo = 5,\n Bar = 2\n },\n new\n {\n Foo = 2,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 6\n },\n [\"Bar\"] = new()\n {\n Value = 3\n }\n }\n };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expected,\n options => options\n .Excluding(x => x.List[1].Foo)\n .Excluding(x => x.Dictionary[\"Bar\"].Value));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void\n When_configured_for_runtime_typing_and_properties_are_excluded_the_runtime_type_should_be_used_and_properties_should_be_ignored()\n {\n // Arrange\n object class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n object class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\"\n };\n\n // Act / Assert\n class1.Should().BeEquivalentTo(class2, opts => opts.ExcludingProperties().PreferringRuntimeMemberTypes());\n }\n\n [Fact]\n public void When_excluding_virtual_or_abstract_property_exclusion_works_properly()\n {\n var obj1 = new Derived\n {\n DerivedProperty1 = \"Something\",\n DerivedProperty2 = \"A\"\n };\n\n var obj2 = new Derived\n {\n DerivedProperty1 = \"Something\",\n DerivedProperty2 = \"B\"\n };\n\n obj1.Should().BeEquivalentTo(obj2, opt => opt\n .Excluding(o => o.AbstractProperty)\n .Excluding(o => o.VirtualProperty)\n .Excluding(o => o.DerivedProperty2));\n }\n\n [Fact]\n public void Abstract_properties_cannot_be_excluded()\n {\n var obj1 = new Derived\n {\n DerivedProperty1 = \"Something\",\n DerivedProperty2 = \"A\"\n };\n\n var obj2 = new Derived\n {\n DerivedProperty1 = \"Something\",\n DerivedProperty2 = \"B\"\n };\n\n Action act = () => obj1.Should().BeEquivalentTo(obj2, opt => opt\n .Excluding(o => o.AbstractProperty + \"B\"));\n\n act.Should().Throw().WithMessage(\"*(o.AbstractProperty + \\\"B\\\")*cannot be used to select a member*\");\n }\n\n#if NETCOREAPP3_0_OR_GREATER\n [Fact]\n public void Can_exclude_a_default_interface_property_using_an_expression()\n {\n // Arrange\n IHaveDefaultProperty subject = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Value\"\n };\n\n IHaveDefaultProperty expectation = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Another Value\"\n };\n\n // Act\n var act = () => subject.Should().BeEquivalentTo(expectation,\n x => x.Excluding(p => p.DefaultProperty));\n\n // Assert\n act.Should().Throw().Which.Message.Should().NotContain(\"subject.DefaultProperty\");\n }\n\n [Fact]\n public void Can_exclude_a_default_interface_property_using_a_name()\n {\n // Arrange\n IHaveDefaultProperty subject = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Value\"\n };\n\n IHaveDefaultProperty expectation = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Another Value\"\n };\n\n // Act\n var act = () => subject.Should().BeEquivalentTo(expectation,\n x => x.Excluding(info => info.Name.Contains(\"DefaultProperty\")));\n\n // Assert\n act.Should().Throw().Which.Message.Should().NotContain(\"subject.DefaultProperty\");\n }\n\n private class ClassReceivedDefaultInterfaceProperty : IHaveDefaultProperty\n {\n public string NormalProperty { get; set; }\n }\n\n private interface IHaveDefaultProperty\n {\n string NormalProperty { get; set; }\n\n int DefaultProperty => NormalProperty.Length;\n }\n#endif\n\n [Fact]\n public void An_anonymous_object_with_multiple_fields_excludes_correctly()\n {\n // Arrange\n var subject = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n Age = 34\n };\n\n var expectation = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n Age = 29\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.MiddleName, p.LastName, p.Age }));\n }\n\n [Fact]\n public void An_empty_anonymous_object_excludes_nothing()\n {\n // Arrange\n var subject = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n Age = 34\n };\n\n var expectation = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n Age = 29\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { }));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void An_anonymous_object_can_exclude_collections()\n {\n // Arrange\n var subject = new\n {\n Names = new[]\n {\n \"John\",\n \"X.\",\n \"Doe\"\n },\n Age = 34\n };\n\n var expectation = new\n {\n Names = new[]\n {\n \"John\",\n \"W.\",\n \"Smith\"\n },\n Age = 34\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names }));\n }\n\n [Fact]\n public void An_anonymous_object_can_exclude_nested_objects()\n {\n // Arrange\n var subject = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n },\n Age = 34\n };\n\n var expectation = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Age = 34\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names.MiddleName, p.Names.LastName }));\n }\n\n [Fact]\n public void An_anonymous_object_can_exclude_nested_objects_inside_collections()\n {\n // Arrange\n var subject = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Age = 1,\n Color = \"Black\"\n },\n new\n {\n Name = \"Cat\",\n Age = 1,\n Color = \"Black\"\n },\n new\n {\n Name = \"Bird\",\n Age = 1,\n Color = \"Black\"\n },\n }\n };\n\n var expectation = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Age = 1,\n Color = \"Black\"\n },\n new\n {\n Name = \"Dog\",\n Age = 2,\n Color = \"Gray\"\n },\n new\n {\n Name = \"Bird\",\n Age = 3,\n Color = \"Black\"\n },\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names.MiddleName, p.Names.LastName })\n .For(p => p.Pets)\n .Exclude(p => new { p.Age, p.Name }));\n\n // Assert\n act.Should().Throw().Which.Message.Should()\n .NotMatch(\"*Pets[1].Age*\").And\n .NotMatch(\"*Pets[1].Name*\").And\n .Match(\"*Pets[1].Color*\");\n }\n\n [Fact]\n public void An_anonymous_object_can_exclude_nested_objects_inside_nested_collections()\n {\n // Arrange\n var subject = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 2,\n },\n },\n },\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 10\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 21\",\n Age = 3,\n },\n },\n },\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 2,\n },\n },\n },\n },\n };\n\n var expectation = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 2,\n },\n },\n },\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 1,\n },\n },\n },\n new\n {\n Name = \"Bird\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 2,\n },\n },\n },\n },\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names.MiddleName, p.Names.LastName })\n .For(person => person.Pets)\n .For(pet => pet.Fleas)\n .Exclude(flea => new { flea.Name, flea.Age }));\n\n // Assert\n act.Should().Throw().Which.Message.Should()\n .NotMatch(\"*Pets[*].Fleas[*].Age*\").And\n .NotMatch(\"*Pets[*].Fleas[*].Name*\").And\n .Match(\"*- Exclude*Pets[]Fleas[]Age*\").And\n .Match(\"*- Exclude*Pets[]Fleas[]Name*\");\n }\n\n [Fact]\n public void An_empty_anonymous_object_excludes_nothing_inside_collections()\n {\n // Arrange\n var subject = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Age = 1\n },\n new\n {\n Name = \"Cat\",\n Age = 1\n },\n new\n {\n Name = \"Bird\",\n Age = 1\n },\n }\n };\n\n var expectation = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Age = 1\n },\n new\n {\n Name = \"Dog\",\n Age = 2\n },\n new\n {\n Name = \"Bird\",\n Age = 1\n },\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names.MiddleName, p.Names.LastName })\n .For(p => p.Pets)\n .Exclude(p => new { }));\n\n // Assert\n act.Should().Throw().WithMessage(\"*Pets[1].Name*Pets[1].Age*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/NestedPropertiesSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class NestedPropertiesSpecs\n{\n [Fact]\n public void When_all_the_properties_of_the_nested_objects_are_equal_it_should_succeed()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1 { Text = \"Level1\", Level = new Level2 { Text = \"Level2\" } }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto { Text = \"Level1\", Level = new Level2Dto { Text = \"Level2\" } }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_the_expectation_contains_a_nested_null_it_should_properly_report_the_difference()\n {\n // Arrange\n var subject = new Root { Text = \"Root\", Level = new Level1 { Text = \"Level1\", Level = new Level2() } };\n\n var expected = new RootDto { Text = \"Root\", Level = new Level1Dto { Text = \"Level1\", Level = null } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Expected*Level.Level*to be , but found*Level2*Without automatic conversion*\");\n }\n\n [Fact]\n public void\n When_not_all_the_properties_of_the_nested_objects_are_equal_but_nested_objects_are_excluded_it_should_succeed()\n {\n // Arrange\n var subject = new\n {\n Property = new ClassWithValueSemanticsOnSingleProperty\n {\n Key = \"123\",\n NestedProperty = \"Should be ignored\"\n }\n };\n\n var expected = new\n {\n Property = new ClassWithValueSemanticsOnSingleProperty\n {\n Key = \"123\",\n NestedProperty = \"Should be ignored as well\"\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.WithoutRecursing());\n }\n\n [Fact]\n public void When_nested_objects_should_be_excluded_it_should_do_a_simple_equality_check_instead()\n {\n // Arrange\n var item = new Item { Child = new Item() };\n\n // Act\n Action act = () => item.Should().BeEquivalentTo(new Item(), options => options.WithoutRecursing());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*Item*null*\");\n }\n\n public class Item\n {\n public Item Child { get; set; }\n }\n\n [Fact]\n public void When_not_all_the_properties_of_the_nested_objects_are_equal_it_should_throw()\n {\n // Arrange\n var subject = new Root { Text = \"Root\", Level = new Level1 { Text = \"Level1\" } };\n\n var expected = new RootDto { Text = \"Root\", Level = new Level1Dto { Text = \"Level2\" } };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().Which.Message\n\n // Checking exception message exactly is against general guidelines\n // but in that case it was done on purpose, so that we have at least have a single\n // test confirming that whole mechanism of gathering description from\n // equivalency steps works.\n .Should().Be(\"\"\"\n Expected property subject.Level.Text to be the same string, but they differ at index 5:\n ↓ (actual)\n \"Level1\"\n \"Level2\"\n ↑ (expected).\n\n With configuration:\n - Prefer the declared type of the members\n - Compare enums by value\n - Compare tuples by their properties\n - Compare anonymous types by their properties\n - Compare records by their members\n - Include non-browsable members\n - Match member by name (or throw)\n - Be strict about the order of items in byte arrays\n - Without automatic conversion.\n\n \"\"\");\n }\n\n [Fact]\n public void When_the_actual_nested_object_is_null_it_should_throw()\n {\n // Arrange\n var subject = new Root { Text = \"Root\", Level = new Level1 { Text = \"Level2\" } };\n\n var expected = new RootDto { Text = \"Root\", Level = null };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*Level*to be *, but found*Level1*Level2*\");\n }\n\n public class StringSubContainer\n {\n public string SubValue { get; set; }\n }\n\n public class StringContainer\n {\n public StringContainer(string mainValue, string subValue = null)\n {\n MainValue = mainValue;\n SubValues = [new StringSubContainer { SubValue = subValue }];\n }\n\n public string MainValue { get; set; }\n\n public IList SubValues { get; set; }\n }\n\n public class MyClass2\n {\n public StringContainer One { get; set; }\n\n public StringContainer Two { get; set; }\n }\n\n [Fact]\n public void When_deeply_nested_strings_dont_match_it_should_properly_report_the_mismatches()\n {\n // Arrange\n MyClass2[] expected =\n [\n new MyClass2 { One = new StringContainer(\"EXPECTED\", \"EXPECTED\"), Two = new StringContainer(\"CORRECT\") },\n new MyClass2()\n ];\n\n MyClass2[] actual =\n [\n new MyClass2\n {\n One = new StringContainer(\"INCORRECT\", \"INCORRECT\"), Two = new StringContainer(\"CORRECT\")\n },\n new MyClass2()\n ];\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*EXPECTED*INCORRECT*EXPECTED*INCORRECT*\");\n }\n\n [Fact]\n public void When_the_nested_object_property_is_null_it_should_throw()\n {\n // Arrange\n var subject = new Root { Text = \"Root\", Level = null };\n\n var expected = new RootDto { Text = \"Root\", Level = new Level1Dto { Text = \"Level2\" } };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected property subject.Level*to be*Level1Dto*Level2*, but found *\");\n }\n\n [Fact]\n public void When_not_all_the_properties_of_the_nested_object_exist_on_the_expected_object_it_should_throw()\n {\n // Arrange\n var subject = new { Level = new { Text = \"Level1\", } };\n\n var expected = new { Level = new { Text = \"Level1\", OtherProperty = \"OtherProperty\" } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expectation has property Level.OtherProperty that the other object does not have*\");\n }\n\n [Fact]\n public void When_all_the_shared_properties_of_the_nested_objects_are_equal_it_should_succeed()\n {\n // Arrange\n var subject = new { Level = new { Text = \"Level1\", Property = \"Property\" } };\n\n var expected = new { Level = new { Text = \"Level1\", OtherProperty = \"OtherProperty\" } };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, options => options.ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_deeply_nested_properties_do_not_have_all_equal_values_it_should_throw()\n {\n // Arrange\n var root = new Root\n {\n Text = \"Root\",\n Level = new Level1 { Text = \"Level1\", Level = new Level2 { Text = \"Level2\" } }\n };\n\n var rootDto = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto { Text = \"Level1\", Level = new Level2Dto { Text = \"A wrong text value\" } }\n };\n\n // Act\n Action act = () => root.Should().BeEquivalentTo(rootDto);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected*Level.Level.Text*to be *\\\"Level2\\\"*A wrong text value*\");\n }\n\n [Fact]\n public void When_two_objects_have_the_same_nested_objects_it_should_not_throw()\n {\n // Arrange\n var c1 = new ClassOne();\n var c2 = new ClassOne();\n\n // Act / Assert\n c1.Should().BeEquivalentTo(c2);\n }\n\n [Fact]\n public void When_a_property_of_a_nested_object_doesnt_match_it_should_clearly_indicate_the_path()\n {\n // Arrange\n var c1 = new ClassOne();\n var c2 = new ClassOne();\n c2.RefOne.ValTwo = 2;\n\n // Act\n Action act = () => c1.Should().BeEquivalentTo(c2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property c1.RefOne.ValTwo to be 2, but found 3*\");\n }\n\n [Fact]\n public void Should_support_nested_collections_containing_empty_objects()\n {\n // Arrange\n OuterWithObject[] orig = [new OuterWithObject { MyProperty = [new Inner()] }];\n\n OuterWithObject[] expectation = [new OuterWithObject { MyProperty = [new Inner()] }];\n\n // Act / Assert\n orig.Should().BeEquivalentTo(expectation);\n }\n\n public class Inner;\n\n public class OuterWithObject\n {\n public Inner[] MyProperty { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Including.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Including\n {\n [Fact]\n public void When_specific_properties_have_been_specified_it_should_ignore_the_other_properties()\n {\n // Arrange\n var subject = new\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"Dennis\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(customer, options => options\n .Including(d => d.Age)\n .Including(d => d.Birthdate));\n }\n\n [Fact]\n public void A_member_included_by_path_is_described_in_the_failure_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\"\n };\n\n var customer = new\n {\n Name = \"Jack\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(customer, options => options\n .Including(d => d.Name));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Include*Name*\");\n }\n\n [Fact]\n public void A_member_included_by_predicate_is_described_in_the_failure_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\"\n };\n\n var customer = new\n {\n Name = \"Jack\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(customer, options => options\n .Including(ctx => ctx.Path == \"Name\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Include member when*Name*\");\n }\n\n [Fact]\n public void When_a_predicate_for_properties_to_include_has_been_specified_it_should_ignore_the_other_properties()\n {\n // Arrange\n var subject = new\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"Dennis\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(customer, options => options\n .Including(info => info.Path.EndsWith(\"Age\", StringComparison.Ordinal))\n .Including(info => info.Path.EndsWith(\"Birthdate\", StringComparison.Ordinal)));\n }\n\n [Fact]\n public void When_a_non_property_expression_is_provided_it_should_throw()\n {\n // Arrange\n var dto = new CustomerDto();\n\n // Act\n Action act = () => dto.Should().BeEquivalentTo(dto, options => options.Including(d => d.GetType()));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expression cannot be used to select a member.*\")\n .WithParameterName(\"expression\");\n }\n\n [Fact]\n public void When_including_a_property_it_should_exactly_match_the_property()\n {\n // Arrange\n var actual = new\n {\n DeclaredType = LocalOtherType.NonDefault,\n Type = LocalType.NonDefault\n };\n\n var expectation = new\n {\n DeclaredType = LocalOtherType.NonDefault\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation,\n config => config.Including(o => o.DeclaredType));\n }\n\n private enum LocalOtherType : byte\n {\n Default,\n NonDefault\n }\n\n private enum LocalType : byte\n {\n Default,\n NonDefault\n }\n\n public class CustomType\n {\n [UsedImplicitly]\n public string Name { get; set; }\n }\n\n [Fact]\n public void When_including_a_property_using_an_expression_it_should_evaluate_it_from_the_root()\n {\n // Arrange\n var list1 = new List\n {\n new()\n {\n Name = \"A\"\n },\n new()\n {\n Name = \"B\"\n }\n };\n\n var list2 = new List\n {\n new()\n {\n Name = \"C\"\n },\n new()\n {\n Name = \"D\"\n }\n };\n\n var objectA = new ClassA\n {\n ListOfCustomTypes = list1\n };\n\n var objectB = new ClassA\n {\n ListOfCustomTypes = list2\n };\n\n // Act\n Action act = () => objectA.Should().BeEquivalentTo(objectB, options => options.Including(x => x.ListOfCustomTypes));\n\n // Assert\n act.Should().Throw().WithMessage(\"*C*but*A*D*but*B*\");\n }\n\n private class ClassA\n {\n public List ListOfCustomTypes { get; set; }\n }\n\n [Fact]\n public void When_null_is_provided_as_property_expression_it_should_throw()\n {\n // Arrange\n var dto = new CustomerDto();\n\n // Act\n Action act =\n () => dto.Should().BeEquivalentTo(dto, options => options.Including(null));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected an expression, but found .*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_including_fields_it_should_succeed_if_just_the_included_field_match()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act =\n () =>\n class1.Should().BeEquivalentTo(class2, opts => opts.Including(o => o.Field1).Including(o => o.Field2));\n\n // Assert\n act.Should().NotThrow(\"the only selected fields have the same value\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_including_fields_it_should_fail_if_any_included_field_do_not_match()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act =\n () =>\n class1.Should().BeEquivalentTo(class2,\n opts => opts.Including(o => o.Field1).Including(o => o.Field2).Including(o => o.Field3));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected field class1.Field3*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_both_field_and_properties_are_configured_for_inclusion_both_should_be_included()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Property1 = \"sit\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties();\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.IncludingFields().IncludingProperties());\n\n // Assert\n act.Should().Throw().Which.Message.Should().Contain(\"Field1\").And.Contain(\"Property1\");\n }\n\n [Fact]\n public void Including_nested_objects_restores_the_default_behavior()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1\n {\n Text = \"Level1\",\n Level = new Level2\n {\n Text = \"Mismatch\"\n }\n }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto\n {\n Text = \"Level1\",\n Level = new Level2Dto\n {\n Text = \"Level2\"\n }\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected,\n options => options.WithoutRecursing().IncludingNestedObjects());\n\n // Assert\n act.Should().Throw().WithMessage(\"*Level.Level.Text*Mismatch*Level2*\");\n }\n\n#if NETCOREAPP3_0_OR_GREATER\n [Fact]\n public void Can_include_a_default_interface_property_using_an_expression()\n {\n // Arrange\n IHaveDefaultProperty subject = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Value\"\n };\n\n IHaveDefaultProperty expectation = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Another Value\"\n };\n\n // Act\n var act = () => subject.Should().BeEquivalentTo(expectation, x => x.Including(p => p.DefaultProperty));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property subject.DefaultProperty to be 13, but found 5.*\");\n }\n\n [Fact]\n public void Can_include_a_default_interface_property_using_a_name()\n {\n // Arrange\n IHaveDefaultProperty subject = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Value\"\n };\n\n IHaveDefaultProperty expectation = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Another Value\"\n };\n\n // Act\n var act = () => subject.Should().BeEquivalentTo(expectation,\n x => x.Including(p => p.Name.Contains(\"DefaultProperty\")));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property subject.DefaultProperty to be 13, but found 5.*\");\n }\n\n private class ClassReceivedDefaultInterfaceProperty : IHaveDefaultProperty\n {\n public string NormalProperty { get; set; }\n }\n\n private interface IHaveDefaultProperty\n {\n string NormalProperty { get; set; }\n\n int DefaultProperty => NormalProperty.Length;\n }\n#endif\n\n [Fact]\n public void An_anonymous_object_selects_correctly()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var expectation = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opts => opts.Including(o => new { o.Field1, o.Field2, o.Field3 }));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected field subject.Field3*\");\n }\n\n [Fact]\n public void An_anonymous_object_selects_nested_fields_correctly()\n {\n // Arrange\n var subject = new\n {\n Field = \"Lorem\",\n NestedField = new\n {\n FieldB = \"ipsum\"\n }\n };\n\n var expectation = new\n {\n FieldA = \"Lorem\",\n NestedField = new\n {\n FieldB = \"no ipsum\"\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opts => opts.Including(o => new { o.NestedField.FieldB }));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*subject.NestedField.FieldB*\");\n }\n\n [Fact]\n public void An_anonymous_object_in_combination_with_exclude_selects_nested_fields_correctly()\n {\n // Arrange\n var subject = new\n {\n FieldA = \"Lorem\",\n NestedField = new\n {\n FieldB = \"ipsum\",\n FieldC = \"ipsum2\",\n FieldD = \"ipsum3\",\n FieldE = \"ipsum4\",\n }\n };\n\n var expectation = new\n {\n FieldA = \"Lorem\",\n NestedField = new\n {\n FieldB = \"no ipsum\",\n FieldC = \"no ipsum2\",\n FieldD = \"no ipsum3\",\n FieldE = \"no ipsum4\",\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(o => new { o.NestedField })\n .Including(o => new { o.NestedField.FieldB }));\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should()\n .Match(\"*Expected*subject.NestedField.FieldB*\").And\n .NotMatch(\"*Expected*FieldC*FieldD*FieldE*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/Failure.cs", "namespace AwesomeAssertions.Xml.Equivalency;\n\ninternal class Failure\n{\n public Failure(string formatString, params object[] formatParams)\n {\n FormatString = formatString;\n FormatParams = formatParams;\n }\n\n public string FormatString { get; }\n\n public object[] FormatParams { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/AttributeBasedFormatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Configuration;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Specialized value formatter that looks for static methods in the caller's assembly marked with the\n/// .\n/// \npublic class AttributeBasedFormatter : IValueFormatter\n{\n private Dictionary formatters;\n private ValueFormatterDetectionMode detectionMode;\n\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return IsScanningEnabled && value is not null && GetFormatter(value) is not null;\n }\n\n private static bool IsScanningEnabled => AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode == ValueFormatterDetectionMode.Scan;\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n MethodInfo method = GetFormatter(value);\n\n object[] parameters = [value, formattedGraph];\n\n method.Invoke(null, parameters);\n }\n\n private MethodInfo GetFormatter(object value)\n {\n Type valueType = value.GetType();\n\n do\n {\n if (Formatters.TryGetValue(valueType, out var formatter))\n {\n return formatter;\n }\n\n valueType = valueType.BaseType;\n }\n while (valueType is not null);\n\n return null;\n }\n\n private Dictionary Formatters\n {\n get\n {\n HandleValueFormatterDetectionModeChanges();\n\n return formatters ??= FindCustomFormatters();\n }\n }\n\n private void HandleValueFormatterDetectionModeChanges()\n {\n ValueFormatterDetectionMode configuredDetectionMode =\n AssertionEngine.Configuration.Formatting.ValueFormatterDetectionMode;\n\n if (detectionMode != configuredDetectionMode)\n {\n detectionMode = configuredDetectionMode;\n formatters = null;\n }\n }\n\n private static Dictionary FindCustomFormatters()\n {\n var query =\n from type in TypeReflector.GetAllTypesFromAppDomain(Applicable)\n where type is not null\n from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public)\n where method.IsStatic\n where method.ReturnType == typeof(void)\n where method.IsDecoratedWithOrInherit()\n let methodParameters = method.GetParameters()\n where methodParameters.Length == 2\n select new { Type = methodParameters[0].ParameterType, Method = method }\n into formatter\n group formatter by formatter.Type\n into formatterGroup\n select formatterGroup.First();\n\n return query.ToDictionary(f => f.Type, f => f.Method);\n }\n\n private static bool Applicable(Assembly assembly)\n {\n GlobalFormattingOptions options = AssertionEngine.Configuration.Formatting;\n ValueFormatterDetectionMode mode = options.ValueFormatterDetectionMode;\n\n return mode == ValueFormatterDetectionMode.Scan || (\n mode == ValueFormatterDetectionMode.Specific &&\n assembly.FullName.Split(',')[0].Equals(options.ValueFormatterAssembly, StringComparison.OrdinalIgnoreCase));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XAttributeAssertionSpecs.cs", "using System;\nusing System.Xml.Linq;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XAttributeAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_asserting_an_xml_attribute_is_equal_to_the_same_xml_attribute_it_should_succeed()\n {\n // Arrange\n var attribute = new XAttribute(\"name\", \"value\");\n var sameXAttribute = new XAttribute(\"name\", \"value\");\n\n // Act / Assert\n attribute.Should().Be(sameXAttribute);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_attribute_is_equal_to_a_different_xml_attribute_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n var otherAttribute = new XAttribute(\"name2\", \"value\");\n\n // Act\n Action act = () =>\n theAttribute.Should().Be(otherAttribute, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"Expected theAttribute to be {otherAttribute} because we want to test the failure message, but found {theAttribute}.\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_are_null_it_succeeds()\n {\n XAttribute theAttribute = null;\n\n // Act / Assert\n theAttribute.Should().Be(null);\n }\n\n [Fact]\n public void When_the_expected_attribute_is_null_then_it_fails()\n {\n XAttribute theAttribute = null;\n\n // Act\n Action act = () =>\n theAttribute.Should().Be(new XAttribute(\"name\", \"value\"), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theAttribute to be name=\\\"value\\\" *failure message*, but found .\");\n }\n\n [Fact]\n public void When_the_attribute_is_expected_to_equal_null_it_fails()\n {\n XAttribute theAttribute = new(\"name\", \"value\");\n\n // Act\n Action act = () => theAttribute.Should().Be(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theAttribute to be *failure message*, but found name=\\\"value\\\".\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_asserting_an_xml_attribute_is_not_equal_to_a_different_xml_attribute_it_should_succeed()\n {\n // Arrange\n var attribute = new XAttribute(\"name\", \"value\");\n var otherXAttribute = new XAttribute(\"name2\", \"value\");\n\n // Act / Assert\n attribute.Should().NotBe(otherXAttribute);\n }\n\n [Fact]\n public void When_asserting_an_xml_attribute_is_not_equal_to_the_same_xml_attribute_it_should_throw()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n var sameXAttribute = theAttribute;\n\n // Act\n Action act = () =>\n theAttribute.Should().NotBe(sameXAttribute);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theAttribute to be name=\\\"value\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_attribute_is_not_equal_to_the_same_xml_attribute_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n var sameAttribute = theAttribute;\n\n // Act\n Action act = () =>\n theAttribute.Should().NotBe(sameAttribute, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"Did not expect theAttribute to be {sameAttribute} because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_a_null_attribute_is_not_supposed_to_be_an_attribute_it_succeeds()\n {\n // Arrange\n XAttribute theAttribute = null;\n\n // Act / Assert\n theAttribute.Should().NotBe(new XAttribute(\"name\", \"value\"));\n }\n\n [Fact]\n public void When_an_attribute_is_not_supposed_to_be_null_it_succeeds()\n {\n // Arrange\n XAttribute theAttribute = new(\"name\", \"value\");\n\n // Act / Assert\n theAttribute.Should().NotBe(null);\n }\n\n [Fact]\n public void When_a_null_attribute_is_not_supposed_to_be_null_it_fails()\n {\n // Arrange\n XAttribute theAttribute = null;\n\n // Act\n Action act = () => theAttribute.Should().NotBe(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theAttribute to be *failure message*.\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_asserting_a_null_xml_attribute_is_null_it_should_succeed()\n {\n // Arrange\n XAttribute attribute = null;\n\n // Act / Assert\n attribute.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_a_non_null_xml_attribute_is_null_it_should_fail()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n\n // Act\n Action act = () =>\n theAttribute.Should().BeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute to be , but found name=\\\"value\\\".\");\n }\n\n [Fact]\n public void When_asserting_a_non_null_xml_attribute_is_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n\n // Act\n Action act = () =>\n theAttribute.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"Expected theAttribute to be because we want to test the failure message, but found {theAttribute}.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_asserting_a_non_null_xml_attribute_is_not_null_it_should_succeed()\n {\n // Arrange\n var attribute = new XAttribute(\"name\", \"value\");\n\n // Act / Assert\n attribute.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_attribute_is_not_null_it_should_fail()\n {\n // Arrange\n XAttribute theAttribute = null;\n\n // Act\n Action act = () =>\n theAttribute.Should().NotBeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute not to be .\");\n }\n\n [Fact]\n public void When_asserting_a_null_xml_attribute_is_not_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n XAttribute theAttribute = null;\n\n // Act\n Action act = () =>\n theAttribute.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute not to be because we want to test the failure message.\");\n }\n }\n\n public class HaveValue\n {\n [Fact]\n public void When_asserting_attribute_has_a_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var attribute = new XAttribute(\"age\", \"36\");\n\n // Act / Assert\n attribute.Should().HaveValue(\"36\");\n }\n\n [Fact]\n public void When_asserting_attribute_has_a_specific_value_but_it_has_a_different_value_it_should_throw()\n {\n // Arrange\n var theAttribute = new XAttribute(\"age\", \"36\");\n\n // Act\n Action act = () =>\n theAttribute.Should().HaveValue(\"16\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute \\\"age\\\" to have value \\\"16\\\", but found \\\"36\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_attribute_has_a_specific_value_but_it_has_a_different_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var theAttribute = new XAttribute(\"age\", \"36\");\n\n // Act\n Action act = () =>\n theAttribute.Should().HaveValue(\"16\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute \\\"age\\\" to have value \\\"16\\\" because we want to test the failure message, but found \\\"36\\\".\");\n }\n\n [Fact]\n public void When_an_attribute_is_null_then_have_value_should_fail()\n {\n XAttribute theAttribute = null;\n\n // Act\n Action act = () =>\n theAttribute.Should().HaveValue(\"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the attribute to have value \\\"value\\\" *failure message*, but theAttribute is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AssertionExtensions.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.IO;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Collections;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Numeric;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Specialized;\nusing AwesomeAssertions.Streams;\nusing AwesomeAssertions.Types;\nusing AwesomeAssertions.Xml;\nusing JetBrains.Annotations;\nusing NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute;\n#if !NETSTANDARD2_0\nusing AwesomeAssertions.Events;\n#endif\n\nnamespace AwesomeAssertions;\n\n/// \n/// Contains extension methods for custom assertions in unit tests.\n/// \n[DebuggerNonUserCode]\npublic static class AssertionExtensions\n{\n private static readonly AggregateExceptionExtractor Extractor = new();\n\n static AssertionExtensions()\n {\n AssertionEngine.EnsureInitialized();\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n /// is .\n /// is .\n [Pure]\n public static Action Invoking(this T subject, Action action)\n {\n Guard.ThrowIfArgumentIsNull(subject);\n Guard.ThrowIfArgumentIsNull(action);\n\n return () => action(subject);\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n /// is .\n /// is .\n [Pure]\n public static Func Invoking(this T subject, Func action)\n {\n Guard.ThrowIfArgumentIsNull(subject);\n Guard.ThrowIfArgumentIsNull(action);\n\n return () => action(subject);\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n [Pure]\n public static Func Awaiting(this T subject, Func action)\n {\n return () => action(subject);\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n [Pure]\n public static Func> Awaiting(this T subject, Func> action)\n {\n return () => action(subject);\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n [Pure]\n public static Func Awaiting(this T subject, Func action)\n {\n return () => action(subject).AsTask();\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n [Pure]\n public static Func> Awaiting(this T subject, Func> action)\n {\n return () => action(subject).AsTask();\n }\n\n /// \n /// Provides methods for asserting the execution time of a method or property.\n /// \n /// The object that exposes the method or property.\n /// A reference to the method or property to measure the execution time of.\n /// \n /// Returns an object for asserting that the execution time matches certain conditions.\n /// \n /// is .\n /// is .\n [MustUseReturnValue /* do not use Pure because this method executes the action before returning to the caller */]\n public static MemberExecutionTime ExecutionTimeOf(this T subject, Expression> action,\n StartTimer createTimer = null)\n {\n Guard.ThrowIfArgumentIsNull(subject);\n Guard.ThrowIfArgumentIsNull(action);\n\n createTimer ??= () => new StopwatchTimer();\n\n return new MemberExecutionTime(subject, action, createTimer);\n }\n\n /// \n /// Provides methods for asserting the execution time of an action.\n /// \n /// An action to measure the execution time of.\n /// \n /// Returns an object for asserting that the execution time matches certain conditions.\n /// \n /// is .\n [MustUseReturnValue /* do not use Pure because this method executes the action before returning to the caller */]\n public static ExecutionTime ExecutionTime(this Action action, StartTimer createTimer = null)\n {\n createTimer ??= () => new StopwatchTimer();\n\n return new ExecutionTime(action, createTimer);\n }\n\n /// \n /// Provides methods for asserting the execution time of an async action.\n /// \n /// \n /// Returns an object for asserting that the execution time matches certain conditions.\n /// \n /// is .\n [MustUseReturnValue /* do not use Pure because this method executes the action before returning to the caller */]\n public static ExecutionTime ExecutionTime(this Func action)\n {\n return new ExecutionTime(action, () => new StopwatchTimer());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static ExecutionTimeAssertions Should(this ExecutionTime executionTime)\n {\n return new ExecutionTimeAssertions(executionTime, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static AssemblyAssertions Should([NotNull] this Assembly assembly)\n {\n return new AssemblyAssertions(assembly, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static XDocumentAssertions Should([NotNull] this XDocument actualValue)\n {\n return new XDocumentAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static XElementAssertions Should([NotNull] this XElement actualValue)\n {\n return new XElementAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static XAttributeAssertions Should([NotNull] this XAttribute actualValue)\n {\n return new XAttributeAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static StreamAssertions Should([NotNull] this Stream actualValue)\n {\n return new StreamAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static BufferedStreamAssertions Should([NotNull] this BufferedStream actualValue)\n {\n return new BufferedStreamAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Forces enumerating a collection. Should be used to assert that a method that uses the\n /// keyword throws a particular exception.\n /// \n [Pure]\n public static Action Enumerating(this Func enumerable)\n {\n return () => ForceEnumeration(enumerable);\n }\n\n /// \n /// Forces enumerating a collection. Should be used to assert that a method that uses the\n /// keyword throws a particular exception.\n /// \n [Pure]\n public static Action Enumerating(this Func> enumerable)\n {\n return () => ForceEnumeration(enumerable);\n }\n\n /// \n /// Forces enumerating a collection of the provided .\n /// Should be used to assert that a method that uses the keyword throws a particular exception.\n /// \n /// The object that exposes the method or property.\n /// A reference to the method or property to force enumeration of.\n public static Action Enumerating(this T subject, Func> enumerable)\n {\n return () => ForceEnumeration(subject, enumerable);\n }\n\n private static void ForceEnumeration(Func enumerable)\n {\n foreach (object _ in enumerable())\n {\n // Do nothing\n }\n }\n\n private static void ForceEnumeration(T subject, Func enumerable)\n {\n foreach (object _ in enumerable(subject))\n {\n // Do nothing\n }\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static ObjectAssertions Should([NotNull] this object actualValue)\n {\n return new ObjectAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static BooleanAssertions Should(this bool actualValue)\n {\n return new BooleanAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableBooleanAssertions Should(this bool? actualValue)\n {\n return new NullableBooleanAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static GuidAssertions Should(this Guid actualValue)\n {\n return new GuidAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableGuidAssertions Should(this Guid? actualValue)\n {\n return new NullableGuidAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static GenericCollectionAssertions Should([NotNull] this IEnumerable actualValue)\n {\n return new GenericCollectionAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static StringCollectionAssertions Should([NotNull] this IEnumerable @this)\n {\n return new StringCollectionAssertions(@this, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static GenericDictionaryAssertions, TKey, TValue> Should(\n [NotNull] this IDictionary actualValue)\n {\n return new GenericDictionaryAssertions, TKey, TValue>(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current of .\n /// \n [Pure]\n public static GenericDictionaryAssertions>, TKey, TValue> Should(\n [NotNull] this IEnumerable> actualValue)\n {\n return new GenericDictionaryAssertions>, TKey, TValue>(actualValue,\n AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static GenericDictionaryAssertions Should(\n [NotNull] this TCollection actualValue)\n where TCollection : IEnumerable>\n {\n return new GenericDictionaryAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static DateTimeAssertions Should(this DateTime actualValue)\n {\n return new DateTimeAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static DateTimeOffsetAssertions Should(this DateTimeOffset actualValue)\n {\n return new DateTimeOffsetAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableDateTimeAssertions Should(this DateTime? actualValue)\n {\n return new NullableDateTimeAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableDateTimeOffsetAssertions Should(this DateTimeOffset? actualValue)\n {\n return new NullableDateTimeOffsetAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n#if NET6_0_OR_GREATER\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static DateOnlyAssertions Should(this DateOnly actualValue)\n {\n return new DateOnlyAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableDateOnlyAssertions Should(this DateOnly? actualValue)\n {\n return new NullableDateOnlyAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static TimeOnlyAssertions Should(this TimeOnly actualValue)\n {\n return new TimeOnlyAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableTimeOnlyAssertions Should(this TimeOnly? actualValue)\n {\n return new NullableTimeOnlyAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n#endif\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static ComparableTypeAssertions Should([NotNull] this IComparable comparableValue)\n {\n return new ComparableTypeAssertions(comparableValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this int actualValue)\n {\n return new Int32Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this int? actualValue)\n {\n return new NullableInt32Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this uint actualValue)\n {\n return new UInt32Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this uint? actualValue)\n {\n return new NullableUInt32Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this decimal actualValue)\n {\n return new DecimalAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this decimal? actualValue)\n {\n return new NullableDecimalAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this byte actualValue)\n {\n return new ByteAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this byte? actualValue)\n {\n return new NullableByteAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this sbyte actualValue)\n {\n return new SByteAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this sbyte? actualValue)\n {\n return new NullableSByteAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this short actualValue)\n {\n return new Int16Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this short? actualValue)\n {\n return new NullableInt16Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this ushort actualValue)\n {\n return new UInt16Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this ushort? actualValue)\n {\n return new NullableUInt16Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this long actualValue)\n {\n return new Int64Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this long? actualValue)\n {\n return new NullableInt64Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this ulong actualValue)\n {\n return new UInt64Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this ulong? actualValue)\n {\n return new NullableUInt64Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this float actualValue)\n {\n return new SingleAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this float? actualValue)\n {\n return new NullableSingleAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this double actualValue)\n {\n return new DoubleAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this double? actualValue)\n {\n return new NullableDoubleAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static StringAssertions Should([NotNull] this string actualValue)\n {\n return new StringAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static SimpleTimeSpanAssertions Should(this TimeSpan actualValue)\n {\n return new SimpleTimeSpanAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableSimpleTimeSpanAssertions Should(this TimeSpan? actualValue)\n {\n return new NullableSimpleTimeSpanAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static TypeAssertions Should([NotNull] this Type subject)\n {\n return new TypeAssertions(subject, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n /// is .\n [Pure]\n public static TypeSelectorAssertions Should(this TypeSelector typeSelector)\n {\n Guard.ThrowIfArgumentIsNull(typeSelector);\n\n return new TypeSelectorAssertions(AssertionChain.GetOrCreate(), typeSelector.ToArray());\n }\n\n /// \n /// Returns a object\n /// that can be used to assert the current .\n /// \n /// \n [Pure]\n public static ConstructorInfoAssertions Should([NotNull] this ConstructorInfo constructorInfo)\n {\n return new ConstructorInfoAssertions(constructorInfo, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the current .\n /// \n /// \n [Pure]\n public static MethodInfoAssertions Should([NotNull] this MethodInfo methodInfo)\n {\n return new MethodInfoAssertions(methodInfo, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the methods returned by the\n /// current .\n /// \n /// \n /// is .\n [Pure]\n public static MethodInfoSelectorAssertions Should(this MethodInfoSelector methodSelector)\n {\n Guard.ThrowIfArgumentIsNull(methodSelector);\n\n return new MethodInfoSelectorAssertions(AssertionChain.GetOrCreate(), methodSelector.ToArray());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n /// \n [Pure]\n public static PropertyInfoAssertions Should([NotNull] this PropertyInfo propertyInfo)\n {\n return new PropertyInfoAssertions(propertyInfo, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the properties returned by the\n /// current .\n /// \n /// \n /// is .\n [Pure]\n public static PropertyInfoSelectorAssertions Should(this PropertyInfoSelector propertyInfoSelector)\n {\n Guard.ThrowIfArgumentIsNull(propertyInfoSelector);\n\n return new PropertyInfoSelectorAssertions(AssertionChain.GetOrCreate(), propertyInfoSelector.ToArray());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static ActionAssertions Should([NotNull] this Action action)\n {\n return new ActionAssertions(action, Extractor, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NonGenericAsyncFunctionAssertions Should([NotNull] this Func action)\n {\n return new NonGenericAsyncFunctionAssertions(action, Extractor, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current System.Func{Task{T}}.\n /// \n [Pure]\n public static GenericAsyncFunctionAssertions Should([NotNull] this Func> action)\n {\n return new GenericAsyncFunctionAssertions(action, Extractor, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static FunctionAssertions Should([NotNull] this Func func)\n {\n return new FunctionAssertions(func, Extractor, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static TaskCompletionSourceAssertions Should(this TaskCompletionSource tcs)\n {\n return new TaskCompletionSourceAssertions(tcs, AssertionChain.GetOrCreate());\n }\n\n#if !NETSTANDARD2_0\n\n /// \n /// Starts monitoring for its events.\n /// \n /// The object for which to monitor the events.\n /// is .\n public static IMonitor Monitor(this T eventSource)\n {\n return new EventMonitor(eventSource, new EventMonitorOptions());\n }\n\n /// \n /// Starts monitoring for its events using the given .\n /// \n /// The object for which to monitor the events.\n /// \n /// Options to configure the EventMonitor.\n /// \n /// is .\n public static IMonitor Monitor(this T eventSource, Action configureOptions)\n {\n Guard.ThrowIfArgumentIsNull(configureOptions, nameof(configureOptions));\n\n var options = new EventMonitorOptions();\n configureOptions(options);\n return new EventMonitor(eventSource, options);\n }\n\n#endif\n\n#if NET6_0_OR_GREATER\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static TaskCompletionSourceAssertions Should(this TaskCompletionSource tcs)\n {\n return new TaskCompletionSourceAssertions(tcs, AssertionChain.GetOrCreate());\n }\n\n#endif\n\n /// \n /// Safely casts the specified object to the type specified through .\n /// \n /// \n /// Has been introduced to allow casting objects without breaking the fluent API.\n /// \n /// The to cast to\n [Pure]\n public static TTo As(this object subject)\n {\n return subject is TTo to ? to : default;\n }\n\n #region Prevent chaining on AndConstraint\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this ReferenceTypeAssertions _)\n where TAssertions : ReferenceTypeAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this BooleanAssertions _)\n where TAssertions : BooleanAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateTimeAssertions _)\n where TAssertions : DateTimeAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateTimeOffsetAssertions _)\n where TAssertions : DateTimeOffsetAssertions\n {\n InvalidShouldCall();\n }\n\n#if NET6_0_OR_GREATER\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateOnlyAssertions _)\n where TAssertions : DateOnlyAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this TimeOnlyAssertions _)\n where TAssertions : TimeOnlyAssertions\n {\n InvalidShouldCall();\n }\n\n#endif\n\n /// \n /// You are asserting the itself. Remove the Should() method directly following And.\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this ExecutionTimeAssertions _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this GuidAssertions _)\n where TAssertions : GuidAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this MethodInfoSelectorAssertions _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this NumericAssertionsBase _)\n where TSubject : struct, IComparable\n where TAssertions : NumericAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this PropertyInfoSelectorAssertions _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this SimpleTimeSpanAssertions _)\n where TAssertions : SimpleTimeSpanAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this TaskCompletionSourceAssertionsBase _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this TypeSelectorAssertions _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this EnumAssertions _)\n where TEnum : struct, Enum\n where TAssertions : EnumAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateTimeRangeAssertions _)\n where TAssertions : DateTimeAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateTimeOffsetRangeAssertions _)\n where TAssertions : DateTimeOffsetAssertions\n {\n InvalidShouldCall();\n }\n\n [DoesNotReturn]\n private static void InvalidShouldCall()\n {\n throw new InvalidOperationException(\n \"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'.\");\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Tracing/GetTraceMessage.cs", "namespace AwesomeAssertions.Equivalency.Tracing;\n\n/// \n/// Defines a function that takes the full path from the root object until the current object\n/// in the equivalency operation separated by dots, and returns the trace message to log.\n/// \npublic delegate string GetTraceMessage(INode node);\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/RecordSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class RecordSpecs\n{\n [Fact]\n public void When_the_subject_is_a_record_it_should_compare_it_by_its_members()\n {\n var actual = new MyRecord { StringField = \"foo\", CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { StringField = \"foo\", CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_the_subject_is_a_record_struct_it_should_compare_it_by_its_members()\n {\n var actual = new MyRecordStruct(\"foo\", [\"bar\", \"zip\", \"foo\"]);\n\n var expected = new MyRecordStruct(\"foo\", [\"bar\", \"zip\", \"foo\"]);\n\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_the_subject_is_a_record_it_should_mention_that_in_the_configuration_output()\n {\n var actual = new MyRecord { StringField = \"foo\", };\n\n var expected = new MyRecord { StringField = \"bar\", };\n\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n act.Should().Throw()\n .WithMessage(\"*Compare records by their members*\");\n }\n\n [Fact]\n public void When_a_record_should_be_treated_as_a_value_type_it_should_use_its_equality_for_comparing()\n {\n var actual = new MyRecord { StringField = \"foo\", CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { StringField = \"foo\", CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n Action act = () => actual.Should().BeEquivalentTo(expected, o => o\n .ComparingByValue());\n\n act.Should().Throw()\n .WithMessage(\"*Expected*MyRecord*but found*MyRecord*\")\n .WithMessage(\"*Compare*MyRecord by value*\");\n }\n\n [Fact]\n public void When_all_records_should_be_treated_as_value_types_it_should_use_equality_for_comparing()\n {\n var actual = new MyRecord { StringField = \"foo\", CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { StringField = \"foo\", CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n Action act = () => actual.Should().BeEquivalentTo(expected, o => o\n .ComparingRecordsByValue());\n\n act.Should().Throw()\n .WithMessage(\"*Expected*MyRecord*but found*MyRecord*\")\n .WithMessage(\"*Compare records by value*\");\n }\n\n [Fact]\n public void\n When_all_records_except_a_specific_type_should_be_treated_as_value_types_it_should_compare_that_specific_type_by_its_members()\n {\n var actual = new MyRecord { StringField = \"foo\", CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { StringField = \"foo\", CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n actual.Should().BeEquivalentTo(expected, o => o\n .ComparingRecordsByValue()\n .ComparingByMembers());\n }\n\n [Fact]\n public void When_global_record_comparing_options_are_chained_it_should_ensure_the_last_one_wins()\n {\n var actual = new MyRecord { CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n actual.Should().BeEquivalentTo(expected, o => o\n .ComparingRecordsByValue()\n .ComparingRecordsByMembers());\n }\n\n private record MyRecord\n {\n public string StringField;\n\n public string[] CollectionProperty { get; init; }\n }\n\n private record struct MyRecordStruct(string StringField, string[] CollectionProperty)\n {\n public string StringField = StringField;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedFactAttributeDiscoverer.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedFactAttributeDiscoverer : IXunitTestCaseDiscoverer\n{\n private readonly IMessageSink diagnosticMessageSink;\n\n public CulturedFactAttributeDiscoverer(IMessageSink diagnosticMessageSink)\n {\n this.diagnosticMessageSink = diagnosticMessageSink;\n }\n\n public IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod,\n IAttributeInfo factAttribute)\n {\n var ctorArgs = factAttribute.GetConstructorArguments().ToArray();\n var cultures = Reflector.ConvertArguments(ctorArgs, [typeof(string[])]).Cast().Single();\n\n if (cultures is null || cultures.Length == 0)\n {\n cultures = [\"en-US\", \"fr-FR\"];\n }\n\n TestMethodDisplay methodDisplay = discoveryOptions.MethodDisplayOrDefault();\n TestMethodDisplayOptions methodDisplayOptions = discoveryOptions.MethodDisplayOptionsOrDefault();\n\n return cultures.Select(culture =>\n new CulturedXunitTestCase(diagnosticMessageSink, methodDisplay, methodDisplayOptions, testMethod, culture)).ToList();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/AssertionScopeSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution\n{\n /// \n /// Type specs.\n /// \n public partial class AssertionScopeSpecs\n {\n [Fact]\n public void When_disposed_it_should_throw_any_failures()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure1\");\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().StartWith(\"Failure1\");\n }\n }\n\n [Fact]\n public void When_disposed_it_should_throw_any_failures_and_properly_format_using_args()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure{0}\", 1);\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().StartWith(\"Failure1\");\n }\n }\n\n [Fact]\n public void When_lazy_version_is_not_disposed_it_should_not_execute_fail_reason_function()\n {\n // Arrange\n var scope = new AssertionScope();\n bool failReasonCalled = false;\n\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(() =>\n {\n failReasonCalled = true;\n return new FailReason(\"Failure\");\n });\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n act();\n failReasonCalled.Should().BeFalse(\" fail reason function cannot be called for scope that successful\");\n }\n\n [Fact]\n public void When_lazy_version_is_disposed_it_should_throw_any_failures_and_properly_format_using_args()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain\n .GetOrCreate()\n .FailWith(() => new FailReason(\"Failure{0}\", 1));\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().StartWith(\"Failure1\");\n }\n }\n\n [Fact]\n public void When_multiple_scopes_are_nested_it_should_throw_all_failures_from_the_outer_scope()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure1\");\n\n using (new AssertionScope())\n {\n AssertionChain.GetOrCreate().FailWith(\"Failure2\");\n\n using var deeplyNestedScope = new AssertionScope();\n AssertionChain.GetOrCreate().FailWith(\"Failure3\");\n }\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().ContainAll(\"Failure1\", \"Failure2\", \"Failure3\");\n }\n }\n\n [Fact]\n public void When_multiple_nested_scopes_each_have_multiple_failures_it_should_throw_all_failures_from_the_outer_scope()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure1.1\");\n AssertionChain.GetOrCreate().FailWith(\"Failure1.2\");\n\n using (new AssertionScope())\n {\n AssertionChain.GetOrCreate().FailWith(\"Failure2.1\");\n AssertionChain.GetOrCreate().FailWith(\"Failure2.2\");\n\n using var deeplyNestedScope = new AssertionScope();\n AssertionChain.GetOrCreate().FailWith(\"Failure3.1\");\n AssertionChain.GetOrCreate().FailWith(\"Failure3.2\");\n }\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().ContainAll(\n \"Failure1.1\", \"Failure1.2\", \"Failure2.1\", \"Failure2.2\", \"Failure3.1\", \"Failure3.2\");\n }\n }\n\n [Fact]\n public void When_a_nested_scope_is_discarded_its_failures_should_also_be_discarded()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure1\");\n\n using (new AssertionScope())\n {\n AssertionChain.GetOrCreate().FailWith(\"Failure2\");\n\n using var deeplyNestedScope = new AssertionScope();\n AssertionChain.GetOrCreate().FailWith(\"Failure3\");\n deeplyNestedScope.Discard();\n }\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().ContainAll(\"Failure1\", \"Failure2\")\n .And.NotContain(\"Failure3\");\n }\n }\n\n [Fact]\n public async Task When_using_a_scope_across_thread_boundaries_it_should_work()\n {\n using var semaphore = new SemaphoreSlim(0, 1);\n await Task.WhenAll(SemaphoreYieldAndWait(semaphore), SemaphoreYieldAndRelease(semaphore));\n }\n\n private static async Task SemaphoreYieldAndWait(SemaphoreSlim semaphore)\n {\n await Task.Yield();\n var scope = new AssertionScope();\n await semaphore.WaitAsync();\n scope.Should().BeSameAs(AssertionScope.Current);\n }\n\n private static async Task SemaphoreYieldAndRelease(SemaphoreSlim semaphore)\n {\n await Task.Yield();\n var scope = new AssertionScope();\n semaphore.Release();\n scope.Should().BeSameAs(AssertionScope.Current);\n }\n\n [Fact]\n public void When_custom_strategy_used_respect_its_behavior()\n {\n // Arrange\n using var _ = new AssertionScope(new FailWithStupidMessageAssertionStrategy());\n\n // Act\n Action act = () => AssertionChain.GetOrCreate().FailWith(\"Failure 1\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Good luck with understanding what's going on!\");\n }\n\n [Fact]\n public void When_custom_strategy_is_null_it_should_throw()\n {\n // Arrange\n IAssertionStrategy strategy = null;\n\n // Arrange / Act\n Func act = () => new AssertionScope(strategy);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"assertionStrategy\");\n }\n\n [Fact]\n public void When_using_a_custom_strategy_it_should_include_failure_messages_of_all_failing_assertions()\n {\n // Arrange\n var scope = new AssertionScope(new CustomAssertionStrategy());\n false.Should().BeTrue();\n true.Should().BeFalse();\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"*but found false*but found true*\");\n }\n\n [Fact]\n public void When_nested_scope_is_disposed_it_passes_reports_to_parent_scope()\n {\n // Arrange/Act\n var outerScope = new AssertionScope();\n outerScope.AddReportable(\"outerReportable\", \"foo\");\n\n using (var innerScope = new AssertionScope())\n {\n innerScope.AddReportable(\"innerReportable\", \"bar\");\n }\n\n AssertionChain.GetOrCreate().FailWith(\"whatever reason\");\n\n Action act = () => outerScope.Dispose();\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"Whatever reason*outerReportable*foo*innerReportable*bar*\");\n }\n\n [Fact]\n public void Formatting_options_passed_to_inner_assertion_scopes()\n {\n // Arrange\n var subject = new[]\n {\n new\n {\n Value = 42\n }\n };\n\n var expected = new[]\n {\n new\n {\n Value = 42\n },\n new\n {\n Value = 42\n }\n };\n\n // Act\n using var scope = new AssertionScope();\n scope.FormattingOptions.MaxDepth = 1;\n subject.Should().BeEquivalentTo(expected);\n\n // Assert\n scope.Discard().Should().ContainSingle()\n .Which.Should().Contain(\"Maximum recursion depth of 1 was reached\");\n }\n\n [Fact]\n public void Multiple_named_scopes_will_prefix_the_caller_identifier()\n {\n // Arrange\n List nonEmptyList = [1, 2];\n\n // Act\n Action act = () =>\n {\n using var scope1 = new AssertionScope(\"Test1\");\n using var scope2 = new AssertionScope(\"Test2\");\n nonEmptyList.Should().BeEmpty();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected Test1/Test2/nonEmptyList to be empty*\");\n }\n\n [Fact]\n public void A_scope_with_multiple_failures_after_a_successful_assertion_should_show_all_errors()\n {\n Action act = () =>\n {\n // any call to AssertionScope.Current (like in AssertionChain.GetOrCreate())\n _ = AssertionScope.Current.HasFailures();\n\n using (new AssertionScope())\n {\n 42.Should().Be(27);\n 42.Should().Be(23);\n }\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected value to be 27, but found 42*{Environment.NewLine}\" +\n \"*Expected value to be 23, but found 42*\");\n }\n\n public class CustomAssertionStrategy : IAssertionStrategy\n {\n private readonly List failureMessages = [];\n\n public IEnumerable FailureMessages => failureMessages;\n\n public IEnumerable DiscardFailures()\n {\n var discardedFailures = failureMessages.ToArray();\n failureMessages.Clear();\n return discardedFailures;\n }\n\n public void ThrowIfAny(IDictionary context)\n {\n if (failureMessages.Count > 0)\n {\n var builder = new StringBuilder();\n builder.AppendJoin(Environment.NewLine, failureMessages).AppendLine();\n\n if (context.Any())\n {\n foreach (KeyValuePair pair in context)\n {\n builder.AppendFormat(CultureInfo.InvariantCulture,\n $\"{Environment.NewLine}With {pair.Key}:{Environment.NewLine}{{0}}\", pair.Value);\n }\n }\n\n AssertionEngine.TestFramework.Throw(builder.ToString());\n }\n }\n\n public void HandleFailure(string message)\n {\n failureMessages.Add(message);\n }\n }\n\n internal class FailWithStupidMessageAssertionStrategy : IAssertionStrategy\n {\n public IEnumerable FailureMessages => [];\n\n public void HandleFailure(string message) =>\n AssertionEngine.TestFramework.Throw(\"Good luck with understanding what's going on!\");\n\n public IEnumerable DiscardFailures() => [];\n\n public void ThrowIfAny(IDictionary context)\n {\n // do nothing\n }\n }\n }\n}\n\n#pragma warning disable RCS1110, CA1050, S3903 // Declare type inside namespace.\npublic class AssertionScopeSpecsWithoutNamespace\n#pragma warning restore RCS1110, CA1050, S3903 // Declare type inside namespace.\n{\n [Fact]\n public void This_class_should_not_be_inside_a_namespace()\n {\n // Arrange\n Type type = typeof(AssertionScopeSpecsWithoutNamespace);\n\n // Act / Assert\n type.Assembly.Should().DefineType(null, type.Name, \"this class should not be inside a namespace\");\n }\n\n [Fact]\n public void When_the_test_method_is_not_inside_a_namespace_it_should_not_throw_a_NullReferenceException()\n {\n // Act\n Action act = () => 1.Should().Be(2, \"we don't want a NullReferenceException\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"*we don't want a NullReferenceException*\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/GetSubjectId.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Allows deferred fetching of the subject ID.\n/// \npublic delegate string GetSubjectId();\n"], ["/AwesomeAssertions/Tests/Approval.Tests/ApiApproval.cs", "using System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Threading.Tasks;\nusing System.Xml.Linq;\nusing System.Xml.XPath;\nusing PublicApiGenerator;\nusing VerifyTests;\nusing VerifyTests.DiffPlex;\nusing VerifyXunit;\nusing Xunit;\n\nnamespace Approval.Tests;\n\npublic class ApiApproval\n{\n static ApiApproval() => VerifyDiffPlex.Initialize(OutputType.Minimal);\n\n [Theory]\n [ClassData(typeof(TargetFrameworksTheoryData))]\n public Task ApproveApi(string framework)\n {\n var configuration = typeof(ApiApproval).Assembly.GetCustomAttribute()!.Configuration;\n var assemblyFile = CombinedPaths(\"Src\", \"AwesomeAssertions\", \"bin\", configuration, framework, \"AwesomeAssertions.dll\");\n var assembly = Assembly.LoadFile(assemblyFile);\n var publicApi = assembly.GeneratePublicApi(options: null);\n\n return Verifier\n .Verify(publicApi)\n .ScrubLinesContaining(\"FrameworkDisplayName\")\n .UseDirectory(Path.Combine(\"ApprovedApi\", \"AwesomeAssertions\"))\n .UseFileName(framework)\n .DisableDiff();\n }\n\n private class TargetFrameworksTheoryData : TheoryData\n {\n public TargetFrameworksTheoryData()\n {\n var csproj = CombinedPaths(\"Src\", \"AwesomeAssertions\", \"AwesomeAssertions.csproj\");\n var project = XDocument.Load(csproj);\n var targetFrameworks = project.XPathSelectElement(\"/Project/PropertyGroup/TargetFrameworks\");\n AddRange(targetFrameworks!.Value.Split(';'));\n }\n }\n\n private static string GetSolutionDirectory([CallerFilePath] string path = \"\") =>\n Path.Combine(Path.GetDirectoryName(path)!, \"..\", \"..\");\n\n private static string CombinedPaths(params string[] paths) =>\n Path.GetFullPath(Path.Combine(paths.Prepend(GetSolutionDirectory()).ToArray()));\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/MemberMatchingSpecs.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class MemberMatchingSpecs\n{\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_excluding_missing_members_both_fields_and_properties_should_be_ignored()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new { Field1 = \"Lorem\" };\n\n // Act / Assert\n class1.Should().BeEquivalentTo(class2, opts => opts.ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_a_property_shared_by_anonymous_types_doesnt_match_it_should_throw()\n {\n // Arrange\n var subject = new { Age = 36 };\n\n var other = new { Age = 37 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other, options => options.ExcludingMissingMembers());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Nested_properties_can_be_mapped_using_a_nested_expression()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\n e => e.Children[0].Property2,\n s => s.Children[0].Property1));\n }\n\n [Fact]\n public void Nested_properties_can_be_mapped_using_a_nested_type_and_property_names()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property1\"));\n }\n\n [Fact]\n public void Nested_explicitly_implemented_properties_can_be_mapped_using_a_nested_type_and_property_names()\n {\n // Arrange\n var subject =\n new ParentOfSubjectWithExplicitlyImplementedProperty(new[] { new SubjectWithExplicitImplementedProperty() });\n\n ((IProperty)subject.Children[0]).Property = \"Hello\";\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property\"));\n }\n\n [Fact]\n public void Nested_fields_can_be_mapped_using_a_nested_type_and_field_names()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties { Field1 = \"John\", Field2 = \"Mary\" };\n\n var expectation = new ClassWithSomeFieldsAndProperties { Field1 = \"Mary\", Field2 = \"John\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Field1\", \"Field2\")\n .WithMapping(\"Field2\", \"Field1\"));\n }\n\n [Fact]\n public void Nested_properties_can_be_mapped_using_a_nested_type_and_a_property_expression()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\n e => e.Property2, s => s.Property1));\n }\n\n [Fact]\n public void Nested_properties_on_a_collection_can_be_mapped_using_a_dotted_path()\n {\n // Arrange\n var subject = new { Parent = new[] { new SubjectWithProperty1 { Property1 = \"Hello\" } } };\n\n var expectation = new { Parent = new[] { new ExpectationWithProperty2 { Property2 = \"Hello\" } } };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[].Property2\", \"Parent[].Property1\"));\n }\n\n [Fact]\n public void Properties_can_be_mapped_by_name()\n {\n // Arrange\n var subject = new SubjectWithProperty1 { Property1 = \"Hello\" };\n\n var expectation = new ExpectationWithProperty2 { Property2 = \"Hello\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property1\"));\n }\n\n [Fact]\n public void Properties_can_be_mapped_by_name_to_an_explicitly_implemented_property()\n {\n // Arrange\n var subject = new SubjectWithExplicitImplementedProperty();\n\n ((IProperty)subject).Property = \"Hello\";\n\n var expectation = new ExpectationWithProperty2\n {\n Property2 = \"Hello\"\n };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property\"));\n }\n\n [Fact]\n public void Fields_can_be_mapped_by_name()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties { Field1 = \"Hello\", Field2 = \"John\" };\n\n var expectation = new ClassWithSomeFieldsAndProperties { Field1 = \"John\", Field2 = \"Hello\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Field2\", \"Field1\")\n .WithMapping(\"Field1\", \"Field2\"));\n }\n\n [Fact]\n public void Fields_can_be_mapped_to_a_property_by_name()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties { Property1 = \"John\" };\n\n var expectation = new ClassWithSomeFieldsAndProperties { Field1 = \"John\", };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Field1\", \"Property1\")\n .Including(e => e.Field1));\n }\n\n [Fact]\n public void Properties_can_be_mapped_to_a_field_by_expression()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties { Field1 = \"John\", };\n\n var expectation = new ClassWithSomeFieldsAndProperties { Property1 = \"John\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(e => e.Property1, s => s.Field1)\n .Including(e => e.Property1));\n }\n\n [Fact]\n public void Properties_can_be_mapped_to_inherited_properties()\n {\n // Arrange\n var subject = new Derived { BaseProperty = \"Hello World\" };\n\n var expectation = new { AnotherProperty = \"Hello World\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(e => e.AnotherProperty, s => s.BaseProperty));\n }\n\n [Fact]\n public void A_failed_assertion_reports_the_subjects_mapped_property()\n {\n // Arrange\n var subject = new SubjectWithProperty1 { Property1 = \"Hello\" };\n\n var expectation = new ExpectationWithProperty2 { Property2 = \"Hello2\" };\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(e => e.Property2, e => e.Property1));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected property subject.Property1 to be*Hello*\");\n }\n\n [Fact]\n public void An_empty_expectation_member_path_is_not_allowed()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"\", \"Parent[0].Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*member path*\");\n }\n\n [Fact]\n public void An_empty_subject_member_path_is_not_allowed()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[0].Property1\", \"\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*member path*\");\n }\n\n [Fact]\n public void Null_as_the_expectation_member_path_is_not_allowed()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(null, \"Parent[0].Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*member path*\");\n }\n\n [Fact]\n public void Null_as_the_subject_member_path_is_not_allowed()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[0].Property1\", null));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*member path*\");\n }\n\n [Fact]\n public void Subject_and_expectation_member_paths_must_have_the_same_parent()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[].Property1\", \"OtherParent[].Property2\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*parent*\");\n }\n\n [Fact]\n public void Numeric_indexes_in_the_path_are_not_allowed()\n {\n var subject = new { Parent = new[] { new SubjectWithProperty1 { Property1 = \"Hello\" } } };\n\n var expectation = new { Parent = new[] { new ExpectationWithProperty2 { Property2 = \"Hello\" } } };\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[0].Property2\", \"Parent[0].Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*without specific index*\");\n }\n\n [Fact]\n public void Mapping_to_a_non_existing_subject_member_is_not_allowed()\n {\n // Arrange\n var subject = new SubjectWithProperty1 { Property1 = \"Hello\" };\n\n var expectation = new ExpectationWithProperty2 { Property2 = \"Hello\" };\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"NonExistingProperty\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*not have member NonExistingProperty*\");\n }\n\n [Fact]\n public void A_null_subject_should_result_in_a_normal_assertion_failure()\n {\n // Arrange\n SubjectWithProperty1 subject = null;\n\n ExpectationWithProperty2 expectation = new() { Property2 = \"Hello\" };\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*Expected*ExpectationWithProperty2*found *\");\n }\n\n [Fact]\n public void Nested_types_and_dotted_expectation_member_paths_cannot_be_combined()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent.Property2\", \"Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*cannot be a nested path*\");\n }\n\n [Fact]\n public void Nested_types_and_dotted_subject_member_paths_cannot_be_combined()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Parent.Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*cannot be a nested path*\");\n }\n\n [Fact]\n public void The_member_name_on_a_nested_type_mapping_must_be_a_valid_member()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"NonExistingProperty\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*does not have member NonExistingProperty*\");\n }\n\n [Fact]\n public void Exclusion_of_missing_members_works_with_mapping()\n {\n // Arrange\n var subject = new\n {\n Property1 = 1\n };\n\n var expectation = new\n {\n Property2 = 2,\n Ignore = 3\n };\n\n // Act / Assert\n subject.Should()\n .NotBeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property1\")\n .ExcludingMissingMembers()\n );\n }\n\n [Fact]\n public void Mapping_works_with_exclusion_of_missing_members()\n {\n // Arrange\n var subject = new\n {\n Property1 = 1\n };\n\n var expectation = new\n {\n Property2 = 2,\n Ignore = 3\n };\n\n // Act / Assert\n subject.Should()\n .NotBeEquivalentTo(expectation, opt => opt\n .ExcludingMissingMembers()\n .WithMapping(\"Property2\", \"Property1\")\n );\n }\n\n [Fact]\n public void Can_map_members_of_a_root_collection()\n {\n // Arrange\n var entity = new Entity\n {\n EntityId = 1,\n Name = \"Test\"\n };\n\n var dto = new EntityDto\n {\n Id = 1,\n Name = \"Test\"\n };\n\n Entity[] entityCol = [entity];\n EntityDto[] dtoCol = [dto];\n\n // Act / Assert\n dtoCol.Should().BeEquivalentTo(entityCol, c =>\n c.WithMapping(s => s.EntityId, d => d.Id));\n }\n\n [Fact]\n public void Can_explicitly_include_a_property_on_a_mapped_type()\n {\n // Arrange\n var expectation = new CustomerWithPropertiesDto\n {\n AddressInformation = new CustomerWithPropertiesDto.ResidenceDto\n {\n Address = \"123 Main St\",\n IsValidated = true,\n },\n };\n\n var subject = new CustomerWithProperty\n {\n Address = new CustomerWithProperty.Residence\n {\n Address = \"123 Main St\",\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o\n .Including(r => r.AddressInformation.Address)\n .WithMapping(s => s.AddressInformation, d => d.Address));\n }\n\n [Fact]\n public void Can_exclude_a_property_on_a_mapped_type()\n {\n // Arrange\n var expectation = new CustomerWithPropertiesDto\n {\n AddressInformation = new CustomerWithPropertiesDto.ResidenceDto\n {\n Address = \"123 Main St\",\n IsValidated = true,\n },\n };\n\n var subject = new CustomerWithProperty\n {\n Address = new CustomerWithProperty.Residence\n {\n Address = \"123 Main St\",\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o\n .Excluding(r => r.AddressInformation.IsValidated)\n .WithMapping(s => s.AddressInformation, d => d.Address));\n }\n\n [Fact]\n public void Can_explicitly_include_a_field_on_a_mapped_type()\n {\n // Arrange\n var expectation = new CustomerWithFieldDto\n {\n AddressInformation = new CustomerWithFieldDto.ResidenceDto\n {\n Address = \"123 Main St\",\n IsValidated = true,\n },\n };\n\n var subject = new CustomerWithField\n {\n Address = new CustomerWithField.Residence\n {\n Address = \"123 Main St\",\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o\n .Including(r => r.AddressInformation.Address)\n .WithMapping(s => s.AddressInformation, d => d.Address));\n }\n\n [Fact]\n public void Can_exclude_a_field_on_a_mapped_type()\n {\n // Arrange\n var expectation = new CustomerWithFieldDto\n {\n AddressInformation = new CustomerWithFieldDto.ResidenceDto\n {\n Address = \"123 Main St\",\n IsValidated = true,\n },\n };\n\n var subject = new CustomerWithField\n {\n Address = new CustomerWithField.Residence\n {\n Address = \"123 Main St\",\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o\n .Excluding(r => r.AddressInformation.IsValidated)\n .WithMapping(s => s.AddressInformation, d => d.Address));\n }\n\n private class CustomerWithProperty\n {\n public Residence Address { get; set; }\n\n public class Residence\n {\n [UsedImplicitly]\n public string Address { get; set; }\n }\n }\n\n private class CustomerWithPropertiesDto\n {\n public ResidenceDto AddressInformation { get; set; }\n\n public class ResidenceDto\n {\n public string Address { get; set; }\n\n public bool IsValidated { get; set; }\n }\n }\n\n private class CustomerWithField\n {\n public Residence Address;\n\n public class Residence\n {\n [UsedImplicitly]\n public string Address;\n }\n }\n\n private class CustomerWithFieldDto\n {\n public ResidenceDto AddressInformation;\n\n public class ResidenceDto\n {\n public string Address;\n\n [UsedImplicitly]\n public bool IsValidated;\n }\n }\n\n private class Entity\n {\n public int EntityId { get; init; }\n\n [UsedImplicitly]\n public string Name { get; init; }\n }\n\n private class EntityDto\n {\n public int Id { get; init; }\n\n [UsedImplicitly]\n public string Name { get; init; }\n }\n\n internal class ParentOfExpectationWithProperty2\n {\n public ExpectationWithProperty2[] Children { get; }\n\n public ParentOfExpectationWithProperty2(ExpectationWithProperty2[] children)\n {\n Children = children;\n }\n }\n\n internal class ParentOfSubjectWithProperty1\n {\n public SubjectWithProperty1[] Children { get; }\n\n public ParentOfSubjectWithProperty1(SubjectWithProperty1[] children)\n {\n Children = children;\n }\n }\n\n internal class ParentOfSubjectWithExplicitlyImplementedProperty\n {\n public SubjectWithExplicitImplementedProperty[] Children { get; }\n\n public ParentOfSubjectWithExplicitlyImplementedProperty(SubjectWithExplicitImplementedProperty[] children)\n {\n Children = children;\n }\n }\n\n internal class SubjectWithProperty1\n {\n public string Property1 { get; set; }\n }\n\n internal class SubjectWithExplicitImplementedProperty : IProperty\n {\n string IProperty.Property { get; set; }\n }\n\n internal interface IProperty\n {\n string Property { get; set; }\n }\n\n internal class ExpectationWithProperty2\n {\n public string Property2 { get; set; }\n }\n\n internal class Base\n {\n public string BaseProperty { get; set; }\n }\n\n internal class Derived : Base\n {\n public string DerivedProperty { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Tracing/ITraceWriter.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency.Tracing;\n\n/// \n/// Represents an object that is used by the class to receive tracing statements on what is\n/// happening during a structural equivalency comparison.\n/// \npublic interface ITraceWriter\n{\n /// \n /// Writes a single line to the trace.\n /// \n void AddSingle(string trace);\n\n /// \n /// Starts a block that scopes an operation that should be written to the trace after the returned \n /// is disposed.\n /// \n IDisposable AddBlock(string trace);\n\n /// \n /// Returns a copy of the trace.\n /// \n string ToString();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/OrderStrictness.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic enum OrderStrictness\n{\n Strict,\n NotStrict,\n Irrelevant\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/CyclicReferenceHandling.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Indication of how cyclic references should be handled when validating equality of nested properties.\n/// \npublic enum CyclicReferenceHandling\n{\n /// \n /// Cyclic references will be ignored.\n /// \n Ignore,\n\n /// \n /// Cyclic references will result in an exception.\n /// \n ThrowException\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DefaultValueFormatter.cs", "using System;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DefaultValueFormatter : IValueFormatter\n{\n /// \n /// Determines whether this instance can handle the specified value.\n /// \n /// The value.\n /// \n /// if this instance can handle the specified value; otherwise, .\n /// \n public virtual bool CanHandle(object value)\n {\n return true;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n if (value.GetType() == typeof(object))\n {\n formattedGraph.AddFragment($\"System.Object (HashCode={value.GetHashCode()})\");\n return;\n }\n\n if (HasCompilerGeneratedToStringImplementation(value))\n {\n WriteTypeAndMemberValues(value, formattedGraph, formatChild);\n }\n else if (context.UseLineBreaks)\n {\n formattedGraph.AddFragmentOnNewLine(value.ToString());\n }\n else\n {\n formattedGraph.AddFragment(value.ToString());\n }\n }\n\n /// \n /// Selects which members of to format.\n /// \n /// The of the object being formatted.\n /// The members of that will be included when formatting this object.\n /// The default is all non-private members.\n protected virtual MemberInfo[] GetMembers(Type type)\n {\n return type.GetMembers(MemberKind.Public);\n }\n\n private static bool HasCompilerGeneratedToStringImplementation(object value)\n {\n Type type = value.GetType();\n\n return HasDefaultToStringImplementation(value) || type.IsCompilerGenerated();\n }\n\n private static bool HasDefaultToStringImplementation(object value)\n {\n string str = value.ToString();\n\n return str is null || str == value.GetType().ToString();\n }\n\n private void WriteTypeAndMemberValues(object obj, FormattedObjectGraph formattedGraph, FormatChild formatChild)\n {\n Type type = obj.GetType();\n WriteTypeName(formattedGraph, type);\n WriteTypeValue(obj, formattedGraph, formatChild, type);\n }\n\n private void WriteTypeName(FormattedObjectGraph formattedGraph, Type type)\n {\n var typeName = type.HasFriendlyName() ? TypeDisplayName(type) : string.Empty;\n formattedGraph.AddFragment(typeName);\n }\n\n private void WriteTypeValue(object obj, FormattedObjectGraph formattedGraph, FormatChild formatChild, Type type)\n {\n MemberInfo[] members = GetMembers(type);\n if (members.Length == 0)\n {\n formattedGraph.AddFragment(\"{ }\");\n }\n else\n {\n formattedGraph.EnsureInitialNewLine();\n formattedGraph.AddLine(\"{\");\n WriteMemberValues(obj, members, formattedGraph, formatChild);\n formattedGraph.AddFragmentOnNewLine(\"}\");\n }\n }\n\n private static void WriteMemberValues(object obj, MemberInfo[] members, FormattedObjectGraph formattedGraph, FormatChild formatChild)\n {\n using var iterator = new Iterator(members.OrderBy(mi => mi.Name, StringComparer.Ordinal));\n\n while (iterator.MoveNext())\n {\n WriteMemberValueTextFor(obj, iterator.Current, formattedGraph, formatChild);\n\n if (!iterator.IsLast)\n {\n formattedGraph.AddFragment(\", \");\n }\n }\n }\n\n /// \n /// Selects the name to display for .\n /// \n /// The of the object being formatted.\n /// The name to be displayed for .\n /// The default is .\n protected virtual string TypeDisplayName(Type type) => TypeValueFormatter.Format(type);\n\n private static void WriteMemberValueTextFor(object value, MemberInfo member, FormattedObjectGraph formattedGraph,\n FormatChild formatChild)\n {\n object memberValue;\n\n try\n {\n memberValue = member switch\n {\n FieldInfo fi => fi.GetValue(value),\n PropertyInfo pi => pi.GetValue(value),\n _ => throw new InvalidOperationException()\n };\n }\n catch (Exception ex)\n {\n ex = (ex as TargetInvocationException)?.InnerException ?? ex;\n memberValue = $\"[Member '{member.Name}' threw an exception: '{ex.Message}']\";\n }\n\n formattedGraph.AddFragmentOnNewLine($\"{new string(' ', FormattedObjectGraph.SpacesPerIndentation)}{member.Name} = \");\n formatChild(member.Name, memberValue, formattedGraph);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/AssertionScopeSpecs.ScopedFormatters.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\npublic partial class AssertionScopeSpecs\n{\n [Fact]\n public void A_scoped_formatter_will_be_used()\n {\n // Arrange\n Action act = () =>\n {\n // Act\n using var outerScope = new AssertionScope();\n\n var outerFormatter = new OuterFormatter();\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n 1.Should().Be(2);\n };\n\n // Assert\n act.Should().Throw().WithMessage($\"*{nameof(OuterFormatter)}*\");\n }\n\n [Fact]\n public void A_scoped_formatter_is_not_available_after_disposal()\n {\n // Arrange\n Action act = () =>\n {\n // Act\n using var outerScope = new AssertionScope();\n\n var outerFormatter = new OuterFormatter();\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n\n // ReSharper disable once DisposeOnUsingVariable\n outerScope.Dispose();\n\n 1.Should().Be(2);\n };\n\n // Assert\n act.Should().Throw().Which.Message.Should().NotMatch($\"*{nameof(OuterFormatter)}*\");\n }\n\n [Fact]\n public void Removing_a_formatter_from_scope_works()\n {\n // Arrange\n using var outerScope = new AssertionScope();\n var outerFormatter = new OuterFormatter();\n\n // Act 1\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n 1.Should().Be(2);\n\n // Assert 1\n outerScope.Discard().Should().ContainSingle().Which.Should().Match($\"*{nameof(OuterFormatter)}*\");\n\n // Act 2\n outerScope.FormattingOptions.RemoveFormatter(outerFormatter);\n 1.Should().Be(2);\n\n // Assert2\n outerScope.Discard().Should().ContainSingle().Which.Should().NotMatch($\"*{nameof(OuterFormatter)}*\");\n outerScope.FormattingOptions.ScopedFormatters.Should().BeEmpty();\n }\n\n [Fact]\n public void Add_a_formatter_to_nested_scope_adds_and_removes_correctly_on_dispose()\n {\n // Arrange\n using var outerScope = new AssertionScope(\"outside\");\n\n var outerFormatter = new OuterFormatter();\n var innerFormatter = new InnerFormatter();\n\n // Act 1\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n 1.Should().Be(2);\n\n // Assert 1 / Test if outer scope contains OuterFormatter\n outerScope.Discard().Should().ContainSingle().Which.Should().Match($\"*{nameof(OuterFormatter)}*\");\n\n using (var innerScope = new AssertionScope(\"inside\"))\n {\n // Act 2\n innerScope.FormattingOptions.AddFormatter(innerFormatter);\n MyEnum.Value1.Should().Be(MyEnum.Value2); // InnerFormatter\n 1.Should().Be(2); // OuterFormatter\n\n // Assert 2\n innerScope.Discard().Should()\n .SatisfyRespectively(\n failure1 => failure1.Should().Match($\"*{nameof(InnerFormatter)}*\"),\n failure2 => failure2.Should().Match($\"*{nameof(OuterFormatter)}*\"));\n }\n\n // Act 3\n 1.Should().Be(2);\n\n // Assert 3\n outerScope.Discard().Should().ContainSingle().Which.Should().Match($\"*{nameof(OuterFormatter)}*\");\n }\n\n [Fact]\n public void Removing_a_formatter_from_outer_scope_inside_nested_scope_leaves_outer_scope_untouched()\n {\n // Arrange\n using var outerScope = new AssertionScope();\n var outerFormatter = new OuterFormatter();\n var innerFormatter = new InnerFormatter();\n\n // Act\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n\n using var innerScope = new AssertionScope();\n innerScope.FormattingOptions.AddFormatter(innerFormatter);\n innerScope.FormattingOptions.RemoveFormatter(outerFormatter);\n 1.Should().Be(2);\n MyEnum.Value1.Should().Be(MyEnum.Value2);\n\n // Assert\n innerScope.Discard().Should().SatisfyRespectively(\n failure1 => failure1.Should().Match(\"*2, but found 1*\"),\n failure2 => failure2.Should().NotMatch($\"*{nameof(OuterFormatter)}*\")\n .And.Match($\"*{nameof(InnerFormatter)}*\"));\n\n outerScope.FormattingOptions.ScopedFormatters.Should().ContainSingle()\n .Which.Should().Be(outerFormatter);\n }\n\n private class OuterFormatter : IValueFormatter\n {\n public bool CanHandle(object value) => value is int;\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(nameof(OuterFormatter));\n }\n }\n\n private class InnerFormatter : IValueFormatter\n {\n public bool CanHandle(object value) => value is MyEnum;\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(nameof(InnerFormatter));\n }\n }\n\n private enum MyEnum\n {\n Value1,\n Value2,\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MemberInfoAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic abstract class MemberInfoAssertions : ReferenceTypeAssertions\n where TSubject : MemberInfo\n where TAssertions : MemberInfoAssertions\n{\n private readonly AssertionChain assertionChain;\n\n protected MemberInfoAssertions(TSubject subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the selected member is decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint, TAttribute> BeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n return BeDecoratedWith(_ => true, because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected member is not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n return NotBeDecoratedWith(_ => true, because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected member is decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint, TAttribute> BeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {Identifier} to be decorated with {{0}}{{reason}}\" +\n \", but {context:member} is .\", typeof(TAttribute));\n\n IEnumerable attributes = [];\n\n if (assertionChain.Succeeded)\n {\n attributes = Subject.GetMatchingAttributes(isMatchingAttributePredicate);\n\n assertionChain\n .ForCondition(attributes.Any())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected {Identifier} {SubjectDescription} to be decorated with {{0}}{{reason}}\" +\n \", but that attribute was not found.\", typeof(TAttribute)));\n }\n\n return new AndWhichConstraint, TAttribute>(this, attributes);\n }\n\n /// \n /// Asserts that the selected member is not decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {Identifier} to not be decorated with {{0}}{{reason}}\" +\n \", but {context:member} is .\", typeof(TAttribute));\n\n if (assertionChain.Succeeded)\n {\n IEnumerable attributes = Subject.GetMatchingAttributes(isMatchingAttributePredicate);\n\n assertionChain\n .ForCondition(!attributes.Any())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected {Identifier} {SubjectDescription} to not be decorated with {{0}}{{reason}}\" +\n \", but that attribute was found.\", typeof(TAttribute)));\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n protected override string Identifier => \"member\";\n\n private protected virtual string SubjectDescription => $\"{Subject.DeclaringType}.{Subject.Name}\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IOrderingRule.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Defines a rule that is used to determine whether the order of items in collections is relevant or not.\n/// \npublic interface IOrderingRule\n{\n /// \n /// Determines if ordering of the member referred to by the current is relevant.\n /// \n OrderStrictness Evaluate(IObjectInfo objectInfo);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Basic.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Basic\n {\n [Fact]\n public void Property_names_are_case_sensitive()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\"\n };\n\n var other = new\n {\n name = \"John\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expectation*name**other*not have*\");\n }\n\n [Fact]\n public void Field_names_are_case_sensitive()\n {\n // Arrange\n var subject = new ClassWithFieldInUpperCase\n {\n Name = \"John\"\n };\n\n var other = new ClassWithFieldInLowerCase\n {\n name = \"John\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expectation*name**other*not have*\");\n }\n\n private class ClassWithFieldInLowerCase\n {\n [UsedImplicitly]\n#pragma warning disable SA1307\n public string name;\n#pragma warning restore SA1307\n }\n\n private class ClassWithFieldInUpperCase\n {\n [UsedImplicitly]\n public string Name;\n }\n\n [Fact]\n public void When_a_property_is_an_indexer_it_should_be_ignored()\n {\n // Arrange\n var expected = new ClassWithIndexer\n {\n Foo = \"test\"\n };\n\n var result = new ClassWithIndexer\n {\n Foo = \"test\"\n };\n\n // Act / Assert\n result.Should().BeEquivalentTo(expected);\n }\n\n public class ClassWithIndexer\n {\n [UsedImplicitly]\n public object Foo { get; set; }\n\n public string this[int n] =>\n n.ToString(\n CultureInfo.InvariantCulture);\n }\n\n [Fact]\n public void When_the_expected_object_has_a_property_not_available_on_the_subject_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n };\n\n var other = new\n {\n // ReSharper disable once StringLiteralTypo\n City = \"Rijswijk\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expectation has property City that the other object does not have*\");\n }\n\n [Fact]\n public void When_equally_named_properties_are_type_incompatible_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n Type = \"A\"\n };\n\n var other = new\n {\n Type = 36\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected property subject.Type to be 36, but found*\\\"A\\\"*\");\n }\n\n [Fact]\n public void When_multiple_properties_mismatch_it_should_report_all_of_them()\n {\n // Arrange\n var subject = new\n {\n Property1 = \"A\",\n Property2 = \"B\",\n SubType1 = new\n {\n SubProperty1 = \"C\",\n SubProperty2 = \"D\"\n }\n };\n\n var other = new\n {\n Property1 = \"1\",\n Property2 = \"2\",\n SubType1 = new\n {\n SubProperty1 = \"3\",\n SubProperty2 = \"D\"\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"\"\"\n *property subject.Property1*to be *\"A\" *\"1\"\n *property subject.Property2*to be *\"B\" *\"2\"\n *property subject.SubType1.SubProperty1*to be *\"C\" * \"3\"*\n \"\"\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void Including_all_declared_properties_excludes_all_fields()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"foo\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n // Act / Assert\n class1.Should().BeEquivalentTo(class2, opts => opts.IncludingAllDeclaredProperties());\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void Including_all_runtime_properties_excludes_all_fields()\n {\n // Arrange\n object class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n object class2 = new ClassWithSomeFieldsAndProperties\n {\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n // Act / Assert\n class1.Should().BeEquivalentTo(class2, opts => opts.IncludingAllRuntimeProperties());\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void Respecting_the_runtime_type_includes_both_properties_and_fields_included()\n {\n // Arrange\n object class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Property1 = \"sit\"\n };\n\n object class2 = new ClassWithSomeFieldsAndProperties();\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw().Which.Message.Should().Contain(\"Field1\").And.Contain(\"Property1\");\n }\n\n [Fact]\n public void A_nested_class_without_properties_inside_a_collection_is_fine()\n {\n // Arrange\n var sut = new List\n {\n new()\n {\n Name = \"theName\"\n }\n };\n\n // Act / Assert\n sut.Should().BeEquivalentTo(\n [\n new BaseClassPointingToClassWithoutProperties\n {\n Name = \"theName\"\n }\n ]);\n }\n\n#if NETCOREAPP3_0_OR_GREATER\n [Fact]\n public void Will_include_default_interface_properties_in_the_comparison()\n {\n var lista = new List\n {\n new Test { Name = \"Test\" }\n };\n\n List listb = new()\n {\n new Test { Name = \"Test\" }\n };\n\n lista.Should().BeEquivalentTo(listb);\n }\n\n private class Test : ITest\n {\n public string Name { get; set; }\n }\n\n private interface ITest\n {\n string Name { get; }\n\n int NameLength => Name.Length;\n }\n#endif\n\n internal class BaseClassPointingToClassWithoutProperties\n {\n [UsedImplicitly]\n public string Name { get; set; }\n\n [UsedImplicitly]\n public ClassWithoutProperty ClassWithoutProperty { get; } = new();\n }\n\n internal class ClassWithoutProperty;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/XElementValueFormatter.cs", "using System;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class XElementValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is XElement;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var element = (XElement)value;\n\n formattedGraph.AddFragment(element.HasElements\n ? FormatElementWithChildren(element)\n : FormatElementWithoutChildren(element));\n }\n\n private static string FormatElementWithoutChildren(XElement element)\n {\n return element.ToString().EscapePlaceholders();\n }\n\n private static string FormatElementWithChildren(XElement element)\n {\n string[] lines = SplitIntoSeparateLines(element);\n\n // Can't use env.newline because the input doc may have unix or windows style\n // line-breaks\n string firstLine = lines[0].RemoveNewLines();\n string lastLine = lines[^1].RemoveNewLines();\n\n string formattedElement = firstLine + \"…\" + lastLine;\n return formattedElement.EscapePlaceholders();\n }\n\n private static string[] SplitIntoSeparateLines(XElement element)\n {\n string formattedXml = element.ToString();\n return formattedXml.Split([Environment.NewLine], StringSplitOptions.None);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Browsability.cs", "using System;\nusing System.ComponentModel;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Browsability\n {\n [Fact]\n public void When_browsable_field_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_browsable_property_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n BrowsableProperty = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n BrowsableProperty = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_advanced_browsable_field_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n AdvancedBrowsableField = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n AdvancedBrowsableField = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_advanced_browsable_property_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n AdvancedBrowsableProperty = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n AdvancedBrowsableProperty = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_explicitly_browsable_field_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n ExplicitlyBrowsableField = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n ExplicitlyBrowsableField = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_explicitly_browsable_property_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n ExplicitlyBrowsableProperty = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n ExplicitlyBrowsableProperty = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_non_browsable_field_differs_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n NonBrowsableField = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n NonBrowsableField = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_non_browsable_property_differs_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n NonBrowsableProperty = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n NonBrowsableProperty = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_property_is_non_browsable_only_in_subject_excluding_non_browsable_members_should_not_make_it_succeed()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n PropertyThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n PropertyThatMightBeNonBrowsable = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected property subject.PropertyThatMightBeNonBrowsable to be 1, but found 0.*\");\n }\n\n [Fact]\n public void\n When_property_is_non_browsable_only_in_subject_ignoring_non_browsable_members_on_subject_should_make_it_succeed()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n PropertyThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n PropertyThatMightBeNonBrowsable = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(\n expectation,\n config => config.IgnoringNonBrowsableMembersOnSubject().ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_non_browsable_property_on_subject_is_ignored_but_is_present_on_expectation_it_should_fail()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n PropertyThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n PropertyThatMightBeNonBrowsable = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.IgnoringNonBrowsableMembersOnSubject());\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expectation has*ThatMightBeNonBrowsable that is non-browsable in the other object, and non-browsable \" +\n \"members on the subject are ignored with the current configuration*\");\n }\n\n [Fact]\n public void Only_ignore_non_browsable_matching_members()\n {\n // Arrange\n var subject = new\n {\n NonExisting = 0\n };\n\n var expectation = new\n {\n Existing = 1\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, config => config.IgnoringNonBrowsableMembersOnSubject());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_property_is_non_browsable_only_in_expectation_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n PropertyThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n PropertyThatMightBeNonBrowsable = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_field_is_non_browsable_only_in_subject_excluding_non_browsable_members_should_not_make_it_succeed()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n FieldThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n FieldThatMightBeNonBrowsable = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected field subject.FieldThatMightBeNonBrowsable to be 1, but found 0.*\");\n }\n\n [Fact]\n public void When_field_is_non_browsable_only_in_subject_ignoring_non_browsable_members_on_subject_should_make_it_succeed()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n FieldThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n FieldThatMightBeNonBrowsable = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(\n expectation,\n config => config.IgnoringNonBrowsableMembersOnSubject().ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_field_is_non_browsable_only_in_expectation_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n FieldThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n FieldThatMightBeNonBrowsable = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_property_is_missing_from_subject_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject =\n new\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2\n /* NonBrowsableProperty missing */\n };\n\n var expected = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2,\n NonBrowsableProperty = 2\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_field_is_missing_from_subject_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject =\n new\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n /* NonBrowsableField missing */\n NonBrowsableProperty = 2\n };\n\n var expected = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2,\n NonBrowsableProperty = 2\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_property_is_missing_from_expectation_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2,\n NonBrowsableProperty = 2\n };\n\n var expected =\n new\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2\n /* NonBrowsableProperty missing */\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_field_is_missing_from_expectation_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2,\n NonBrowsableProperty = 2\n };\n\n var expected =\n new\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n /* NonBrowsableField missing */\n NonBrowsableProperty = 2\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void\n When_non_browsable_members_are_excluded_it_should_still_be_possible_to_explicitly_include_non_browsable_field()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n NonBrowsableField = 1\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n NonBrowsableField = 2\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(\n expectation,\n opt => opt.IncludingFields().ExcludingNonBrowsableMembers().Including(e => e.NonBrowsableField));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected field subject.NonBrowsableField to be 2, but found 1.*\");\n }\n\n [Fact]\n public void\n When_non_browsable_members_are_excluded_it_should_still_be_possible_to_explicitly_include_non_browsable_property()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n NonBrowsableProperty = 1\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n NonBrowsableProperty = 2\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(\n expectation,\n opt => opt.IncludingProperties().ExcludingNonBrowsableMembers().Including(e => e.NonBrowsableProperty));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected property subject.NonBrowsableProperty to be 2, but found 1.*\");\n }\n\n private class ClassWithNonBrowsableMembers\n {\n [UsedImplicitly]\n public int BrowsableField = -1;\n\n [UsedImplicitly]\n public int BrowsableProperty { get; set; }\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Always)]\n public int ExplicitlyBrowsableField = -1;\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Always)]\n public int ExplicitlyBrowsableProperty { get; set; }\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Advanced)]\n public int AdvancedBrowsableField = -1;\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Advanced)]\n public int AdvancedBrowsableProperty { get; set; }\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Never)]\n public int NonBrowsableField = -1;\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Never)]\n public int NonBrowsableProperty { get; set; }\n }\n\n private class ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n [UsedImplicitly]\n public int BrowsableProperty { get; set; }\n\n [UsedImplicitly]\n public int FieldThatMightBeNonBrowsable = -1;\n\n [UsedImplicitly]\n public int PropertyThatMightBeNonBrowsable { get; set; }\n }\n\n private class ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n [UsedImplicitly]\n public int BrowsableProperty { get; set; }\n\n [EditorBrowsable(EditorBrowsableState.Never)]\n [UsedImplicitly]\n public int FieldThatMightBeNonBrowsable = -1;\n\n [EditorBrowsable(EditorBrowsableState.Never)]\n [UsedImplicitly]\n public int PropertyThatMightBeNonBrowsable { get; set; }\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XElementAssertionSpecs.cs", "using System;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XElementAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_asserting_an_xml_element_is_equal_to_the_same_xml_element_it_should_succeed()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n var sameElement = new XElement(\"element\");\n\n // Act / Assert\n theElement.Should().Be(sameElement);\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_equal_to_a_different_xml_element_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n var otherElement = new XElement(\"other\");\n\n // Act\n Action act = () =>\n theElement.Should().Be(otherElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to be*other*because we want to test the failure message, but found *element*\");\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_equal_to_an_xml_element_with_a_deep_difference_it_should_fail()\n {\n // Arrange\n var theElement =\n new XElement(\"parent\",\n new XElement(\"child\",\n new XElement(\"grandChild2\")));\n\n var expected =\n new XElement(\"parent\",\n new XElement(\"child\",\n new XElement(\"grandChild\")));\n\n // Act\n Action act = () => theElement.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to be , but found .\");\n }\n\n [Fact]\n public void When_the_expected_element_is_null_it_fails()\n {\n // Arrange\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().Be(new XElement(\"other\"), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to be *failure message*, but found .\");\n }\n\n [Fact]\n public void When_element_is_expected_to_equal_null_it_fails()\n {\n // Arrange\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () => theElement.Should().Be(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to be *failure message*, but found .\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_are_null_it_succeeds()\n {\n // Arrange\n XElement theElement = null;\n\n // Act / Assert\n theElement.Should().Be(null);\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_asserting_an_xml_element_is_not_equal_to_a_different_xml_element_it_should_succeed()\n {\n // Arrange\n var element = new XElement(\"element\");\n var otherElement = new XElement(\"other\");\n\n // Act / Assert\n element.Should().NotBe(otherElement);\n }\n\n [Fact]\n public void When_asserting_a_deep_xml_element_is_not_equal_to_a_different_xml_element_it_should_succeed()\n {\n // Arrange\n var differentElement =\n new XElement(\"parent\",\n new XElement(\"child\",\n new XElement(\"grandChild\")));\n\n var element =\n new XElement(\"parent\",\n new XElement(\"child\",\n new XElement(\"grandChild2\")));\n\n // Act / Assert\n element.Should().NotBe(differentElement);\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_not_equal_to_the_same_xml_element_it_should_fail()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n var sameElement = theElement;\n\n // Act\n Action act = () =>\n theElement.Should().NotBe(sameElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theElement to be because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_an_element_is_not_supposed_to_be_null_it_succeeds()\n {\n // Arrange\n XElement theElement = new(\"element\");\n\n // Act / Assert\n theElement.Should().NotBe(null);\n }\n\n [Fact]\n public void When_a_null_element_is_not_supposed_to_be_an_element_it_succeeds()\n {\n // Arrange\n XElement theElement = null;\n\n // Act / Assert\n theElement.Should().NotBe(new XElement(\"other\"));\n }\n\n [Fact]\n public void When_a_null_element_is_not_supposed_to_be_null_it_fails()\n {\n // Arrange\n XElement theElement = null;\n\n // Act\n Action act = () => theElement.Should().NotBe(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theElement to be *failure message*.\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_asserting_an_xml_element_is_null_and_it_is_it_should_succeed()\n {\n // Arrange\n XElement element = null;\n\n // Act / Assert\n element.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_null_but_it_is_not_it_should_fail()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().BeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to be , but found .\");\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_null_but_it_is_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to be because we want to test the failure message, but found .\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_asserting_a_non_null_xml_element_is_not_null_it_should_succeed()\n {\n // Arrange\n var element = new XElement(\"element\");\n\n // Act / Assert\n element.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_element_is_not_null_it_should_fail()\n {\n // Arrange\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotBeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected theElement not to be .\");\n }\n\n [Fact]\n public void When_asserting_a_null_xml_element_is_not_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement not to be because we want to test the failure message.\");\n }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void When_asserting_a_xml_element_is_equivalent_to_the_same_xml_element_it_should_succeed()\n {\n // Arrange\n var element = new XElement(\"element\");\n var sameXElement = element;\n\n // Act / Assert\n element.Should().BeEquivalentTo(sameXElement);\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_equivalent_to_a_different_xml_element_with_same_structure_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().BeEquivalentTo(otherXElement);\n }\n\n [Fact]\n public void When_asserting_an_empty_xml_element_is_equivalent_to_a_different_selfclosing_xml_element_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().BeEquivalentTo(otherElement);\n }\n\n [Fact]\n public void When_asserting_a_selfclosing_xml_element_is_equivalent_to_a_different_empty_xml_element_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().BeEquivalentTo(otherElement);\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_equivalent_to_a_xml_element_with_elements_missing_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in theElement at \\\"/parent\\\", but found Element \\\"child2\\\".\");\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_equivalent_to_a_different_xml_element_with_extra_elements_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child2\\\" in theElement at \\\"/parent\\\", but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_equivalent_to_a_different_xml_element_elements_missing_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in theElement at \\\"/parent\\\" because we want to test the failure message, but found Element \\\"child2\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_equivalent_to_a_different_xml_element_with_extra_elements_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child2\\\" in theElement at \\\"/parent\\\" because we want to test the failure message, but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_empty_xml_element_is_equivalent_to_a_different_xml_element_with_text_content_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"text\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected content \\\"text\\\" in theElement at \\\"/parent/child\\\" because we want to test the failure message, but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void When_an_element_is_null_then_be_equivalent_to_null_succeeds()\n {\n XElement theElement = null;\n\n // Act / Assert\n theElement.Should().BeEquivalentTo(null);\n }\n\n [Fact]\n public void When_an_element_is_null_then_be_equivalent_to_an_element_fails()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(new XElement(\"element\"), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to be equivalent to *failure message*, but found \\\"\\\".\");\n }\n\n [Fact]\n public void When_an_element_is_equivalent_to_null_it_fails()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to be equivalent to \\\"\\\" *failure message*, but found .\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_a_different_xml_element_with_different_namespace_prefix_it_should_succeed()\n {\n // Arrange\n var subject = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_a_different_xml_element_which_differs_only_on_unused_namespace_declaration_it_should_succeed()\n {\n // Arrange\n var subject = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_lacks_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"a\\\" in theElement at \\\"/xml/element\\\" because we want to test the failure message, but found none.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_has_extra_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect to find attribute \\\"a\\\" in theElement at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_has_different_attribute_values_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"a\\\" in theElement at \\\"/xml/element\\\" to have value \\\"c\\\" because we want to test the failure message, but found \\\"b\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_has_attribute_with_different_namespace_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect to find attribute \\\"ns:a\\\" in theElement at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_has_different_text_contents_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"a\");\n var expected = XElement.Parse(\"b\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected content to be \\\"b\\\" in theElement at \\\"/xml\\\" because we want to test the failure message, but found \\\"a\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_with_different_comments_it_should_succeed()\n {\n // Arrange\n var subject = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_elements_missing_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().NotBeEquivalentTo(otherXElement);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_extra_elements_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().NotBeEquivalentTo(otherXElement);\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_same_structure_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_same_contents_but_different_ns_prefixes_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n var otherXElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_same_contents_but_extra_unused_xmlns_declaration_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(@\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_not_equivalent_to_the_same_xml_element_it_should_fail()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n var sameXElement = theElement;\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(sameXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_same_structure_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(otherXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_the_same_xml_element_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var sameXElement = theElement;\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(sameXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void When_a_null_element_is_unexpected_equivalent_to_null_it_fails()\n {\n XElement theElement = null;\n\n // Act\n Action act = () => theElement.Should().NotBeEquivalentTo(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theElement to be equivalent *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_a_null_element_is_not_equivalent_to_an_element_it_succeeds()\n {\n XElement theElement = null;\n\n // Act / Assert\n theElement.Should().NotBeEquivalentTo(new XElement(\"element\"));\n }\n\n [Fact]\n public void When_an_element_is_not_equivalent_to_null_it_succeeds()\n {\n XElement theElement = new(\"element\");\n\n // Act / Assert\n theElement.Should().NotBeEquivalentTo(null);\n }\n }\n\n public class HaveValue\n {\n [Fact]\n public void When_asserting_element_has_a_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"grega\");\n\n // Act / Assert\n element.Should().HaveValue(\"grega\");\n }\n\n [Fact]\n public void When_asserting_element_has_a_specific_value_but_it_has_a_different_value_it_should_throw()\n {\n // Arrange\n var theElement = XElement.Parse(\"grega\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveValue(\"stamac\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement 'user' to have value \\\"stamac\\\", but found \\\"grega\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_element_has_a_specific_value_but_it_has_a_different_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"grega\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveValue(\"stamac\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement 'user' to have value \\\"stamac\\\" because we want to test the failure message, but found \\\"grega\\\".\");\n }\n\n [Fact]\n public void When_xml_element_is_null_then_have_value_should_fail()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveValue(\"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the element to have value \\\"value\\\" *failure message*, but theElement is .\");\n }\n }\n\n public class HaveAttribute\n {\n [Fact]\n public void Passes_when_attribute_found()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().HaveAttribute(\"name\");\n }\n\n [Fact]\n public void Passes_when_attribute_found_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().HaveAttribute(XName.Get(\"name\", \"http://www.example.com/2012/test\"));\n }\n\n [Fact]\n public void Throws_when_attribute_is_not_found()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(\"age\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"age\\\"*failure message*, but found no such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_attribute_is_not_found_with_namespace()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(XName.Get(\"age\", \"http://www.example.com/2012/test\"),\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"{http://www.example.com/2012/test}age\\\"\"\n + \"*failure message*but found no such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_xml_element_is_null()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(\"name\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"name\\\" in element *failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_xml_element_is_null_with_namespace()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute((XName)\"name\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"name\\\" in element*failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_null()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_null_with_namespace()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute((XName)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_empty()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n }\n\n public class NotHaveAttribute\n {\n [Fact]\n public void Passes_when_attribute_not_found()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().NotHaveAttribute(\"surname\");\n }\n\n [Fact]\n public void Passes_when_attribute_not_found_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().NotHaveAttribute(XName.Get(\"surname\", \"http://www.example.com/2012/test\"));\n }\n\n [Fact]\n public void Throws_when_attribute_is_found()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(\"name\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to have attribute \\\"name\\\"*failure message*, but found such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_attribute_is_found_with_namespace()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(XName.Get(\"name\", \"http://www.example.com/2012/test\"),\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to have attribute \\\"{http://www.example.com/2012/test}name\\\"\"\n + \"*failure message*but found such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_xml_element_is_null()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(\"name\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect attribute \\\"name\\\" in element *failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_xml_element_is_null_with_namespace()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute((XName)\"name\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect attribute \\\"name\\\" in element*failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_null()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_null_with_namespace()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute((XName)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_empty()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n }\n\n public class HaveAttributeWithValue\n {\n [Fact]\n public void When_asserting_element_has_attribute_with_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().HaveAttributeWithValue(\"name\", \"martin\");\n }\n\n [Fact]\n public void When_asserting_element_has_attribute_with_ns_and_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().HaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"martin\");\n }\n\n [Fact]\n public void When_asserting_element_has_attribute_with_specific_value_but_attribute_does_not_exist_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(\"age\", \"36\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"age\\\" with value \\\"36\\\", but found no such attribute in \");\n }\n\n [Fact]\n public void When_asserting_element_has_attribute_with_ns_and_specific_value_but_attribute_does_not_exist_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(XName.Get(\"age\", \"http://www.example.com/2012/test\"), \"36\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"{http://www.example.com/2012/test}age\\\" with value \\\"36\\\",\"\n + \" but found no such attribute in \");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_specific_value_but_attribute_does_not_exist_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n theElement.Should().HaveAttributeWithValue(\"age\", \"36\", \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"age\\\" with value \\\"36\\\" because we want to test the failure message,\"\n + \" but found no such attribute in \");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_ns_and_specific_value_but_attribute_does_not_exist_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(XName.Get(\"age\", \"http://www.example.com/2012/test\"), \"36\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"{http://www.example.com/2012/test}age\\\" with value \\\"36\\\"\"\n + \" because we want to test the failure message,\"\n + \" but found no such attribute in \");\n }\n\n [Fact]\n public void When_asserting_element_has_attribute_with_specific_value_but_attribute_has_different_value_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(\"name\", \"dennis\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"name\\\" in theElement to have value \\\"dennis\\\", but found \\\"martin\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_ns_and_specific_value_but_attribute_has_different_value_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"dennis\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"{http://www.example.com/2012/test}name\\\" in theElement to have value \\\"dennis\\\", but found \\\"martin\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_specific_value_but_attribute_has_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should()\n .HaveAttributeWithValue(\"name\", \"dennis\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"name\\\" in theElement to have value \\\"dennis\\\"\"\n + \" because we want to test the failure message, but found \\\"martin\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_ns_and_specific_value_but_attribute_has_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"dennis\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"{http://www.example.com/2012/test}name\\\" in theElement to have value \\\"dennis\\\"\"\n + \" because we want to test the failure message, but found \\\"martin\\\".\");\n }\n\n [Fact]\n public void When_xml_element_is_null_then_have_attribute_should_fail()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(\"name\", \"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"name\\\" in element to have value \\\"value\\\" *failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void When_xml_element_is_null_then_have_attribute_with_XName_should_fail()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue((XName)\"name\", \"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"name\\\" in element to have value \\\"value\\\" *failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void When_asserting_element_has_an_attribute_with_a_null_name_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(null, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n\n [Fact]\n public void When_asserting_element_has_an_attribute_with_a_null_XName_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue((XName)null, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n\n [Fact]\n public void When_asserting_element_has_an_attribute_with_an_empty_name_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(string.Empty, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n }\n\n public class NotHaveAttributeWithValue\n {\n [Fact]\n public void Passes_when_attribute_does_not_fit()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(\"surname\", \"martin\");\n }\n\n [Fact]\n public void Passes_when_attribute_does_not_fit_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(XName.Get(\"surname\", \"http://www.example.com/2012/test\"), \"martin\");\n }\n\n [Fact]\n public void Passes_when_attribute_and_value_does_not_fit()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(\"surname\", \"mike\");\n }\n\n [Fact]\n public void Passes_when_attribute_and_value_does_not_fit_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(XName.Get(\"surname\", \"http://www.example.com/2012/test\"), \"mike\");\n }\n\n [Fact]\n public void Passes_when_attribute_fits_and_value_does_not()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(\"name\", \"mike\");\n }\n\n [Fact]\n public void Passes_when_attribute_fits_and_value_does_not_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"mike\");\n }\n\n [Fact]\n public void Throws_when_attribute_and_name_fits()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n theElement.Should()\n .NotHaveAttributeWithValue(\"name\", \"martin\", \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to have attribute \\\"name\\\" with value \\\"martin\\\" because we want to test the failure message,\"\n + \" but found such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_attribute_and_name_fits_with_namespace()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"martin\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to have attribute \\\"{http://www.example.com/2012/test}name\\\" with value \\\"martin\\\"\"\n + \" because we want to test the failure message,\"\n + \" but found such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_element_is_null()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(\"name\", \"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect attribute \\\"name\\\" in element to have value \\\"value\\\"*failure message*, but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_element_is_null_with_namespace()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should()\n .NotHaveAttributeWithValue((XName)\"name\", \"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect attribute \\\"name\\\" in element to have value \\\"value\\\"*failure message*, but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_expected_is_null()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(null, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n\n [Fact]\n public void Throws_when_expected_is_null_with_namespace()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue((XName)null, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n\n [Fact]\n public void Throws_when_expected_attribute_is_something_but_value_is_null()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(\"some\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedValue\");\n }\n\n [Fact]\n public void Throws_when_expected_attribute_is_something_but_value_is_null_with_namespace()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue((XName)\"some\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedValue\");\n }\n\n [Fact]\n public void Throws_when_expected_is_empty()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(string.Empty, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n }\n\n public class HaveElement\n {\n [Fact]\n public void When_asserting_element_has_child_element_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElement(\"child\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_with_ns_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElement(XName.Get(\"child\", \"http://www.example.com/2012/test\"));\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"unknown\\\", but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_with_ns_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(XName.Get(\"unknown\", \"http://www.example.com/2012/test\"));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"{{http://www.example.com/2012/test}}unknown\\\", but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(\"unknown\", \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"unknown\\\" because we want to test the failure message,\"\n + \" but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_with_ns_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(XName.Get(\"unknown\", \"http://www.example.com/2012/test\"),\n \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"{{http://www.example.com/2012/test}}unknown\\\"\"\n + \" because we want to test the failure message, but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_it_should_return_the_matched_element_in_the_which_property()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n var matchedElement = element.Should().HaveElement(\"child\").Subject;\n\n // Assert\n matchedElement.Should().BeOfType()\n .And.HaveAttributeWithValue(\"attr\", \"1\");\n\n matchedElement.Name.Should().Be(XName.Get(\"child\"));\n }\n\n [Fact]\n public void When_asserting_element_has_a_child_element_with_a_null_name_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_asserting_element_has_a_child_element_with_a_null_XName_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement((XName)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_asserting_element_has_a_child_element_with_an_empty_name_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expected\");\n }\n }\n\n public class HaveElementWithOccurrence\n {\n [Fact]\n public void Element_has_two_child_elements_and_it_expected_does_it_succeeds()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElement(\"child\", Exactly.Twice());\n }\n\n [Fact]\n public void Asserting_element_inside_an_assertion_scope_it_checks_the_whole_assertion_scope_before_failing()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n element.Should().HaveElement(\"child\", Exactly.Twice());\n element.Should().HaveElement(\"child\", Exactly.Twice());\n }\n };\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Element_has_two_child_elements_and_three_expected_it_fails()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElement(\"child\", Exactly.Twice());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected element to have an element \\\"child\\\"*exactly*2 times, but found it 3 times.\");\n }\n\n [Fact]\n public void Element_is_valid_and_expected_null_with_string_overload_it_fails()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElement(null, Exactly.Twice());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the element has an element if the expected name is .*\");\n }\n\n [Fact]\n public void Element_is_valid_and_expected_null_with_x_name_overload_it_fails()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElement((XName)null, Exactly.Twice());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the element has an element count if the element name is .*\");\n }\n\n [Fact]\n public void Chaining_after_a_successful_occurrence_check_does_continue_the_assertion()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElement(\"child\", AtLeast.Twice())\n .Which.Should().NotBeNull();\n }\n\n [Fact]\n public void Chaining_after_a_non_successful_occurrence_check_does_not_continue_the_assertion()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElement(\"child\", Exactly.Once())\n .Which.Should().NotBeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected element to have an element \\\"child\\\"*exactly*1 time, but found it 3 times.\");\n }\n\n [Fact]\n public void Null_element_is_expected_to_have_an_element_count_it_should_fail()\n {\n // Arrange\n XElement xElement = null;\n\n // Act\n Action act = () => xElement.Should().HaveElement(\"child\", AtLeast.Once());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected* to have an element with count of *, but the element itself is .\");\n }\n }\n\n public class HaveElementWithValue\n {\n [Fact]\n public void The_element_cannot_be_null()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void Has_element_with_specified_value()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElementWithValue(\"child\", \"b\");\n }\n\n [Fact]\n public void Throws_when_element_is_not_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(\"c\", \"f\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*c*f*element*isn't found*\");\n }\n\n [Fact]\n public void Throws_when_element_found_but_value_does_not_match()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(\"child\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*c*element*does not have such a value*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue((XName)null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(\"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(XNamespace.None + \"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void The_element_cannot_be_null_and_searching_with_namespace()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () =>\n element.Should()\n .HaveElementWithValue(XNamespace.None + \"child\", \"b\", \"we want to test the {0} message\", \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*failure message*element itself is *\");\n }\n\n [Fact]\n public void Has_element_with_specified_value_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElementWithValue(XNamespace.None + \"child\", \"b\");\n }\n\n [Fact]\n public void Throws_when_element_with_namespace_not_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n element.Should().HaveElementWithValue(XNamespace.None + \"c\", \"f\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\"*c*f*element*isn't found*\");\n }\n\n [Fact]\n public void Throws_when_element_with_namespace_found_but_value_does_not_match()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(XNamespace.None + \"child\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*c*element*does not have such a value*\");\n }\n }\n\n public class NotHaveElement\n {\n [Fact]\n public void The_element_cannot_be_null()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () => element.Should().NotHaveElement(\"child\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void Element_does_not_have_this_child_element()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElement(\"c\");\n }\n\n [Fact]\n public void Throws_when_element_found_but_expected_to_be_absent()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElement(\"child\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Did not*child*element*was found*\");\n }\n\n [Fact]\n public void Throws_when_unexpected_element_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElement(null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*unexpectedElement*\");\n }\n\n [Fact]\n public void Throws_when_unexpected_element_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElement((XName)null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*unexpectedElement*\");\n }\n\n [Fact]\n public void The_element_cannot_be_null_and_searching_with_namespace()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () =>\n element.Should()\n .NotHaveElement(XNamespace.None + \"child\", \"we want to test the {0} message\", \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*failure message*element itself is *\");\n }\n\n [Fact]\n public void Not_have_element_with_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElement(XNamespace.None + \"c\");\n }\n }\n\n public class NotHaveElementWithValue\n {\n [Fact]\n public void The_element_cannot_be_null()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void Throws_when_element_with_specified_value_is_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not*element*child*value*b*does have this value*\");\n }\n\n [Fact]\n public void Passes_when_element_not_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(\"c\", \"f\");\n }\n\n [Fact]\n public void Passes_when_element_found_but_value_does_not_match()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(\"child\", \"c\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue((XName)null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void The_element_cannot_be_null_and_searching_with_namespace()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () =>\n element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"b\", \"we want to test the {0} message\",\n \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*failure message*element itself is *\");\n }\n\n [Fact]\n public void Throws_when_element_with_specified_value_is_found_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not expect*element*child*value*b*does have this value*\");\n }\n\n [Fact]\n public void Passes_when_element_with_namespace_not_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(XNamespace.None + \"c\", \"f\");\n }\n\n [Fact]\n public void Passes_when_element_with_namespace_found_but_value_does_not_match()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"c\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/CallerIdentificationSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\n#pragma warning disable RCS1192, RCS1214, S4144 // verbatim string literals and interpolated strings\n// ReSharper disable RedundantStringInterpolation\nnamespace AwesomeAssertions.Specs.Execution\n{\n public class CallerIdentificationSpecs\n {\n [Fact]\n public void Types_in_the_system_namespace_are_excluded_from_identification()\n {\n // Act\n Action act = () => SystemNamespaceClass.AssertAgainstFailure();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected object*\",\n \"because a subject in a system namespace should not be ignored by caller identification\");\n }\n\n [Fact]\n public void Types_in_a_namespace_nested_under_system_are_excluded_from_identification()\n {\n // Act\n Action act = () => System.Data.NestedSystemNamespaceClass.AssertAgainstFailure();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected object*\");\n }\n\n [Fact]\n public void Types_in_a_namespace_prefixed_with_system_are_excluded_from_identification()\n {\n // Act\n Action act = () => SystemPrefixed.SystemPrefixedNamespaceClass.AssertAgainstFailure();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected actualCaller*\");\n }\n\n [Fact]\n public void When_variable_name_contains_Should_it_should_identify_the_entire_variable_name_as_the_caller()\n {\n // Arrange\n string fooShould = \"bar\";\n\n // Act\n Action act = () => fooShould.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected fooShould to be *\");\n }\n\n [Fact]\n public async Task When_should_is_passed_argument_context_should_still_be_found()\n {\n // Arrange\n var bob = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => bob.Should(timer).NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n bob.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect bob to complete within 1s because test testArg.\");\n }\n\n [Fact]\n public void When_variable_is_captured_it_should_use_the_variable_name()\n {\n // Arrange\n string foo = \"bar\";\n\n // Act\n Action act = () => foo.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo to be *\");\n }\n\n [Fact]\n public void When_field_is_the_subject_it_should_use_the_field_name()\n {\n // Arrange & Act\n Action act = () =>\n {\n var foo = new Foo();\n foo.Field.Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.Field to be *\");\n }\n\n [Fact]\n public void When_property_is_the_subject_it_should_use_the_property_name()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.Bar.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.Bar to be *\");\n }\n\n [Fact]\n public void When_method_name_is_the_subject_it_should_use_the_method_name()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod().Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod() to be *\");\n }\n\n [Fact]\n public void When_method_contains_arguments_it_should_add_them_to_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"test\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"test\\\") to be *\");\n }\n\n [Fact]\n public void When_the_caller_contains_multiple_members_it_should_include_them_all()\n {\n // Arrange\n string test1 = \"test1\";\n var foo = new Foo\n {\n Field = \"test3\"\n };\n\n // Act\n Action act = () => foo.GetFoo(test1).GetFooStatic(\"test\" + 2).GetFoo(foo.Field).Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(test1).GetFooStatic(\\\"test\\\" + 2).GetFoo(foo.Field) to be *\");\n }\n\n [Fact]\n public void When_the_caller_contains_multiple_members_across_multiple_lines_it_should_include_them_all()\n {\n // Arrange\n string test1 = \"test1\";\n var foo = new Foo\n {\n Field = \"test3\"\n };\n\n // Act\n Action act = () => foo\n .GetFoo(test1)\n .GetFooStatic(\"test\" + 2)\n .GetFoo(foo.Field)\n .Should()\n .BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(test1).GetFooStatic(\\\"test\\\" + 2).GetFoo(foo.Field) to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_Should_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\".Should()\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\".Should()\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_semicolon_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"test;\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"test;\\\") to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Code should not contain multiple statements on one line\", \"SA1107\")]\n [SuppressMessage(\"Code should not contain multiple statements on one line\", \"IDE0055\")]\n public void When_there_are_several_statements_on_the_line_it_should_use_the_correct_statement()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n#pragma warning disable format\n Action act = () =>\n {\n var foo2 = foo; foo2.Should().BeNull();\n };\n#pragma warning restore format\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo2 to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_escaped_quote_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"test\\\";\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"test\\\\\\\";\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_verbatim_string_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(@\"test\", argument2: $@\"test2\", argument3: @$\"test3\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(@\\\"test\\\", argument2: $@\\\"test2\\\", argument3: @$\\\"test3\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_multi_line_verbatim_string_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(@\"\n bob dole\n \"\n )\n .Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(@\\\" bob dole \\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_verbatim_string_interpolation_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(@$\"test\"\";\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(@$\\\"test\\\"\\\";\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_concatenations_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"1\" + 2).Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"1\\\" + 2) to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_multi_line_concatenations_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"abc\"\n + \"def\"\n )\n .Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"abc\\\"+ \\\"def\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_string_with_comment_like_contents_inside_it_should_include_them_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"test//test2/*test3*/\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"test//test2/*test3*/\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_verbatim_string_with_verbatim_like_string_inside_it_should_include_them_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(@\"test @\"\" @$\"\" bob\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(@\\\"test @\\\"\\\" @$\\\"\\\" bob\\\") to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"SA1515\")]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"IDE0055\")]\n public void When_the_caller_contains_single_line_comment_it_should_ignore_that()\n {\n // Arrange\n string foo = \"bar\";\n\n // Act\n Action act = () =>\n {\n foo\n // some important comment\n .Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"SA1515\")]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"IDE0055\")]\n public void When_the_caller_contains_multi_line_comment_it_should_ignore_that()\n {\n // Arrange\n string foo = \"bar\";\n\n // Act\n Action act = () =>\n {\n foo\n /*\n * some important comment\n */\n .Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"SA1515\")]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"IDE0055\")]\n public void When_the_caller_contains_several_comments_it_should_ignore_them()\n {\n // Arrange\n string foo = \"bar\";\n\n // Act\n Action act = () =>\n {\n foo\n // some important comment\n /* another one */.Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Code should not contain multiple statements on one line\", \"IDE0055\")]\n [SuppressMessage(\"Single-line comment should be preceded by blank line\", \"SA1515\")]\n public void When_the_caller_with_methods_has_comments_between_it_should_ignore_them()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () =>\n {\n foo\n // some important comment\n .GetFoo(\"bob\")\n /* another one */\n .BarMethod()\n .Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(\\\"bob\\\").BarMethod() to be *\");\n }\n\n [Fact]\n public void When_the_method_has_Should_prefix_it_should_read_whole_method()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.ShouldReturnSomeBool().Should().BeFalse();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.ShouldReturnSomeBool() to be false*\");\n }\n\n [Collection(\"UIFacts\")]\n public class UIFacts\n {\n [UIFact]\n public async Task Caller_identification_should_also_work_for_statements_following_async_code()\n {\n // Arrange\n const string someText = \"Hello\";\n Func task = async () => await Task.Yield();\n\n // Act\n await task.Should().NotThrowAsync();\n Action act = () => someText.Should().Be(\"Hi\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*someText*\", \"it should capture the variable name\");\n }\n }\n\n [Fact]\n public void A_method_taking_an_array_initializer_is_an_identifier()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.GetFoo(new[] { 1, 2, 3 }.Sum() + \"\")\n .Should()\n .BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(new[] { 1, 2, 3 }.Sum() + \\\"\\\") to be *\");\n }\n\n [Fact]\n public void A_method_taking_a_target_typed_new_expression_is_an_identifier()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.GetFoo(new('a', 10))\n .Should()\n .BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(new('a', 10)) to be *\");\n }\n\n [Fact]\n public void A_method_taking_a_list_is_an_identifier()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.GetFoo(new List { 1, 2, 3 }.Sum() + \"\")\n .Should()\n .BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(new List { 1, 2, 3 }*\");\n }\n\n [Fact]\n public void An_array_initializer_preceding_an_assertion_is_not_an_identifier()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().BeEmpty();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to be empty*\");\n }\n\n [Fact]\n public void An_object_initializer_preceding_an_assertion_is_not_an_identifier()\n {\n // Act\n Action act = () => new { Property = \"blah\" }.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected object to be*\");\n }\n\n [Fact]\n public void All_core_code_anywhere_in_the_stack_trace_is_ignored()\n {\n /*\n We want to test this specific scenario.\n\n 1. CallerIdentifier.DetermineCallerIdentity\n 2. AwesomeAssertions code\n 3. Custom extension <--- pointed to by lastUserStackFrameBeforeAwesomeAssertionsCodeIndex\n 4. AwesomeAssertions code <--- this is where DetermineCallerIdentity tried to get the variable name from before the fix\n 5. Test\n */\n\n var node = Node.From(GetSubjectId);\n\n // Assert\n node.Subject.Description.Should().StartWith(\"node.Subject.Description\");\n }\n\n [CustomAssertion]\n private string GetSubjectId() => AssertionChain.GetOrCreate().CallerIdentifier;\n }\n\n#pragma warning disable IDE0060, RCS1163 // Remove unused parameter\n [SuppressMessage(\"The name of a C# element does not begin with an upper-case letter\", \"SA1300\")]\n [SuppressMessage(\"Parameter is never used\", \"CA1801\")]\n public class Foo\n {\n public string Field = \"bar\";\n\n public string Bar => \"bar\";\n\n public string BarMethod() => Bar;\n\n public string BarMethod(string argument) => Bar;\n\n public string BarMethod(string argument, string argument2, string argument3) => Bar;\n\n public bool ShouldReturnSomeBool() => true;\n\n public Foo GetFoo(string argument) => this;\n }\n\n [SuppressMessage(\"Parameter is never used\", \"CA1801\")]\n public static class Extensions\n {\n public static Foo GetFooStatic(this Foo foo, string prm) => foo;\n }\n#pragma warning restore IDE0060, RCS1163 // Remove unused parameter\n}\n\nnamespace System\n{\n public static class SystemNamespaceClass\n {\n public static void AssertAgainstFailure()\n {\n object actualCaller = null;\n actualCaller.Should().NotBeNull(\"because we want this to fail and not return the name of the subject\");\n }\n }\n}\n\nnamespace SystemPrefixed\n{\n public static class SystemPrefixedNamespaceClass\n {\n public static void AssertAgainstFailure()\n {\n object actualCaller = null;\n actualCaller.Should().NotBeNull(\"because we want this to fail and return the name of the subject\");\n }\n }\n}\n\nnamespace System.Data\n{\n public static class NestedSystemNamespaceClass\n {\n public static void AssertAgainstFailure()\n {\n object actualCaller = null;\n actualCaller.Should().NotBeNull(\"because we want this to fail and not return the name of the subject\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/PredicateLambdaExpressionValueFormatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// The is responsible for formatting\n/// boolean lambda expressions.\n/// \npublic class PredicateLambdaExpressionValueFormatter : IValueFormatter\n{\n public bool CanHandle(object value) => value is LambdaExpression;\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var lambdaExpression = (LambdaExpression)value;\n\n var reducedExpression = ReduceConstantSubExpressions(lambdaExpression.Body);\n\n if (reducedExpression is BinaryExpression { NodeType: ExpressionType.AndAlso } binaryExpression)\n {\n var subExpressions = ExtractChainOfExpressionsJoinedWithAndOperator(binaryExpression);\n formattedGraph.AddFragment(string.Join(\" AndAlso \", subExpressions.Select(e => e.ToString())));\n }\n else\n {\n formattedGraph.AddFragment(reducedExpression.ToString());\n }\n }\n\n /// \n /// This step simplifies the lambda expression by replacing parts of it which do not depend on the lambda parameters\n /// with the actual values of these sub-expressions. The simplified expression is much easier to read.\n /// E.g. \"(_.Text == \"two\") AndAlso (_.Number == 3)\"\n /// Instead of \"(_.Text == value(AwesomeAssertions.Specs.Collections.GenericCollectionAssertionsSpecs+c__DisplayClass122_0).twoText) AndAlso (_.Number == 3)\".\n /// \n private static Expression ReduceConstantSubExpressions(Expression expression)\n {\n try\n {\n return new ConstantSubExpressionReductionVisitor().Visit(expression);\n }\n catch (InvalidOperationException)\n {\n // Fallback if we make an invalid rewrite of the expression.\n return expression;\n }\n }\n\n /// \n /// This step simplifies the lambda expression by removing unnecessary parentheses for root level chain of AND operators.\n /// E.g. (_.Text == \"two\") AndAlso (_.Number == 3) AndAlso (_.OtherText == \"foo\")\n /// Instead of ((_.Text == \"two\") AndAlso (_.Number == 3)) AndAlso (_.OtherText == \"foo\")\n /// This simplification is only implemented for the chain of AND operators because this is the most common predicate scenario.\n /// Similar logic can be implemented in the future for other operators.\n /// \n private static List ExtractChainOfExpressionsJoinedWithAndOperator(BinaryExpression binaryExpression)\n {\n var visitor = new AndOperatorChainExtractor();\n visitor.Visit(binaryExpression);\n return visitor.AndChain;\n }\n\n /// \n /// Expression visitor which can detect whether the expression depends on parameters.\n /// \n private sealed class ParameterDetector : ExpressionVisitor\n {\n public bool HasParameters { get; private set; }\n\n public override Expression Visit(Expression node)\n {\n // As soon as at least one parameter was found in the expression tree we should stop iterating (this is achieved by not calling base.Visit).\n return HasParameters ? node : base.Visit(node);\n }\n\n protected override Expression VisitParameter(ParameterExpression node)\n {\n HasParameters = true;\n return node;\n }\n }\n\n /// \n /// Expression visitor which can replace constant sub-expressions with constant values.\n /// \n private sealed class ConstantSubExpressionReductionVisitor : ExpressionVisitor\n {\n public override Expression Visit(Expression node)\n {\n if (node is null)\n {\n return null;\n }\n\n if (node is ConstantExpression)\n {\n return node;\n }\n\n if (!HasLiftedOperator(node) && ExpressionIsConstant(node))\n {\n return Expression.Constant(Expression.Lambda(node).Compile().DynamicInvoke());\n }\n\n return base.Visit(node);\n }\n\n private static bool HasLiftedOperator(Expression expression) =>\n expression is BinaryExpression { IsLifted: true } or UnaryExpression { IsLifted: true };\n\n private static bool ExpressionIsConstant(Expression expression)\n {\n if (expression is NewExpression or MemberInitExpression)\n {\n return false;\n }\n\n var visitor = new ParameterDetector();\n visitor.Visit(expression);\n return !visitor.HasParameters;\n }\n }\n\n /// \n /// Expression visitor which can extract sub-expressions from an expression which has the following form:\n /// (SubExpression1) AND (SubExpression2) ... AND (SubExpressionN)\n /// \n private sealed class AndOperatorChainExtractor : ExpressionVisitor\n {\n public List AndChain { get; } = [];\n\n public override Expression Visit(Expression node)\n {\n if (node!.NodeType == ExpressionType.AndAlso)\n {\n var binaryExpression = (BinaryExpression)node;\n Visit(binaryExpression.Left);\n Visit(binaryExpression.Right);\n }\n else\n {\n AndChain.Add(node);\n }\n\n return null;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/SubjectInfoExtensions.cs", "using AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\npublic static class SubjectInfoExtensions\n{\n /// \n /// Checks if the subject info setter has the given access modifier.\n /// \n /// The subject info being checked.\n /// The access modifier that the subject info setter should have.\n /// True if the subject info setter has the given access modifier, false otherwise.\n public static bool WhichSetterHas(this IMemberInfo memberInfo, CSharpAccessModifier accessModifier)\n {\n return memberInfo.SetterAccessibility == accessModifier;\n }\n\n /// \n /// Checks if the subject info setter does not have the given access modifier.\n /// \n /// The subject info being checked.\n /// The access modifier that the subject info setter should not have.\n /// True if the subject info setter does not have the given access modifier, false otherwise.\n public static bool WhichSetterDoesNotHave(this IMemberInfo memberInfo, CSharpAccessModifier accessModifier)\n {\n return memberInfo.SetterAccessibility != accessModifier;\n }\n\n /// \n /// Checks if the subject info getter has the given access modifier.\n /// \n /// The subject info being checked.\n /// The access modifier that the subject info getter should have.\n /// True if the subject info getter has the given access modifier, false otherwise.\n public static bool WhichGetterHas(this IMemberInfo memberInfo, CSharpAccessModifier accessModifier)\n {\n return memberInfo.GetterAccessibility == accessModifier;\n }\n\n /// \n /// Checks if the subject info getter does not have the given access modifier.\n /// \n /// The subject info being checked.\n /// The access modifier that the subject info getter should not have.\n /// True if the subject info getter does not have the given access modifier, false otherwise.\n public static bool WhichGetterDoesNotHave(this IMemberInfo memberInfo, CSharpAccessModifier accessModifier)\n {\n return memberInfo.GetterAccessibility != accessModifier;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/AsyncFunctionAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an asynchronous method yields the expected result.\n/// \n/// The type of to be handled.\n/// The type of assertion to be returned.\n[DebuggerNonUserCode]\npublic class AsyncFunctionAssertions : DelegateAssertionsBase, TAssertions>\n where TTask : Task\n where TAssertions : AsyncFunctionAssertions\n{\n private readonly AssertionChain assertionChain;\n\n protected AsyncFunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain,\n IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n protected override string Identifier => \"async function\";\n\n /// \n /// Asserts that the current will not complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> NotCompleteWithinAsync(TimeSpan timeSpan,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:task} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n (Task task, TimeSpan remainingTime) = InvokeWithTimer(timeSpan);\n\n if (remainingTime >= TimeSpan.Zero)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(task, remainingTime, _ => Task.CompletedTask);\n\n assertionChain\n .ForCondition(!completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current throws an exception of the exact type (and not a derived exception type).\n /// \n /// The type of exception expected to be thrown.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Returns an object that allows asserting additional members of the thrown exception.\n /// \n public async Task> ThrowExactlyAsync(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n Type expectedType = typeof(TException);\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw exactly {0}{reason}, but found .\", expectedType);\n\n if (assertionChain.Succeeded)\n {\n Exception exception = await InvokeWithInterceptionAsync(Subject);\n\n assertionChain\n .ForCondition(exception is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0}{reason}, but no exception was thrown.\", expectedType);\n\n if (assertionChain.Succeeded)\n {\n exception.Should().BeOfType(expectedType, because, becauseArgs);\n }\n\n return new ExceptionAssertions([exception as TException], assertionChain);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n /// \n /// Asserts that the current throws an exception of type .\n /// \n /// The type of exception expected to be thrown.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> ThrowAsync(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw {0}{reason}, but found .\", typeof(TException));\n\n if (assertionChain.Succeeded)\n {\n Exception exception = await InvokeWithInterceptionAsync(Subject);\n return ThrowInternal(exception, because, becauseArgs);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n /// \n /// Asserts that the current throws an exception of type \n /// within a specific timeout.\n /// \n /// The type of exception expected to be thrown.\n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> ThrowWithinAsync(TimeSpan timeSpan,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw {0} within {1}{reason}, but found .\",\n typeof(TException), timeSpan);\n\n if (assertionChain.Succeeded)\n {\n Exception caughtException = await InvokeWithInterceptionAsync(timeSpan);\n return AssertThrows(caughtException, timeSpan, because, becauseArgs);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n private ExceptionAssertions AssertThrows(\n Exception exception, TimeSpan timeSpan,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where TException : Exception\n {\n TException[] expectedExceptions = Extractor.OfType(exception).ToArray();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected a <{0}> to be thrown within {1}{reason}, \", typeof(TException), timeSpan, chain => chain\n .ForCondition(exception is not null)\n .FailWith(\"but no exception was thrown.\")\n .Then\n .ForCondition(expectedExceptions.Length > 0)\n .FailWith(\"but found <{0}>:\" + Environment.NewLine + \"{1}.\",\n exception?.GetType(),\n exception));\n\n return new ExceptionAssertions(expectedExceptions, assertionChain);\n }\n\n private async Task InvokeWithInterceptionAsync(TimeSpan timeout)\n {\n try\n {\n // For the duration of this nested invocation, configure CallerIdentifier\n // to match the contents of the subject rather than our own call site.\n //\n // Func action = async () => await subject.Should().BeSomething();\n // await action.Should().ThrowAsync();\n //\n // If an assertion failure occurs, we want the message to talk about \"subject\"\n // not \"await action\".\n using (CallerIdentifier.OnlyOneAssertionScopeOnCallStack()\n ? CallerIdentifier.OverrideStackSearchUsingCurrentScope()\n : default)\n {\n (TTask task, TimeSpan remainingTime) = InvokeWithTimer(timeout);\n\n if (remainingTime < TimeSpan.Zero)\n {\n // timeout reached without exception\n return null;\n }\n\n if (task.IsFaulted)\n {\n // exception in synchronous portion\n return task.Exception!.GetBaseException();\n }\n\n // Start monitoring the task regarding timeout.\n // Here we do not need to know whether the task completes (successfully) in timeout\n // or does not complete. We are only interested in the exception which is thrown, not returned.\n // So, we can ignore the result.\n _ = await CompletesWithinTimeoutAsync(task, remainingTime, cancelledTask => cancelledTask);\n }\n\n return null;\n }\n catch (Exception exception)\n {\n return exception;\n }\n }\n\n /// \n /// Asserts that the current does not throw an exception of type .\n /// \n /// The type of exception expected to not be thrown.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> NotThrowAsync([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n try\n {\n await Subject!.Invoke();\n }\n catch (Exception exception)\n {\n return NotThrowInternal(exception, because, becauseArgs);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Invokes the subject and measures the sync execution time.\n /// \n private protected (TTask result, TimeSpan remainingTime) InvokeWithTimer(TimeSpan timeSpan)\n {\n Common.ITimer timer = Clock.StartTimer();\n TTask result = Subject.Invoke();\n TimeSpan remainingTime = timeSpan - timer.Elapsed;\n\n return (result, remainingTime);\n }\n\n /// \n /// Monitors the specified task whether it completes withing the remaining time span.\n /// \n private protected async Task CompletesWithinTimeoutAsync(Task target, TimeSpan remainingTime, Func onTaskCanceled)\n {\n using var delayCancellationTokenSource = new CancellationTokenSource();\n\n Task delayTask = Clock.DelayAsync(remainingTime, delayCancellationTokenSource.Token);\n Task completedTask = await Task.WhenAny(target, delayTask);\n\n if (completedTask.IsFaulted)\n {\n // Throw the inner exception.\n await completedTask;\n }\n\n if (completedTask != target)\n {\n // The monitored task did not complete.\n return false;\n }\n\n if (target.IsCanceled)\n {\n await onTaskCanceled(target);\n }\n\n // The monitored task is completed, we shall cancel the clock.\n#pragma warning disable CA1849 // Call async methods when in an async method: Is not a drop-in replacement in this case, but may cause problems.\n delayCancellationTokenSource.Cancel();\n#pragma warning restore CA1849 // Call async methods when in an async method\n return true;\n }\n\n private protected static async Task InvokeWithInterceptionAsync(Func action)\n {\n try\n {\n // For the duration of this nested invocation, configure CallerIdentifier\n // to match the contents of the subject rather than our own call site.\n //\n // Func action = async () => await subject.Should().BeSomething();\n // await action.Should().ThrowAsync();\n //\n // If an assertion failure occurs, we want the message to talk about \"subject\"\n // not \"await action\".\n using (CallerIdentifier.OnlyOneAssertionScopeOnCallStack()\n ? CallerIdentifier.OverrideStackSearchUsingCurrentScope()\n : default)\n {\n await action();\n }\n\n return null;\n }\n catch (Exception exception)\n {\n return exception;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeEquivalentTo.cs", "using System;\nusing System.Collections.Immutable;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeEquivalentTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeEquivalentTo\n {\n [Fact]\n public void When_two_collections_contain_the_same_elements_it_should_treat_them_as_equivalent()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1, 2];\n\n // Act / Assert\n collection1.Should().BeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_a_collection_contains_same_elements_it_should_treat_it_as_equivalent()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().BeEquivalentTo([3, 1, 2]);\n }\n\n [Fact]\n public void When_character_collections_are_equivalent_it_should_not_throw()\n {\n // Arrange\n char[] list1 = \"abc123ab\".ToCharArray();\n char[] list2 = \"abc123ab\".ToCharArray();\n\n // Act / Assert\n list1.Should().BeEquivalentTo(list2);\n }\n\n [Fact]\n public void When_collections_are_not_equivalent_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2];\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2, \"we treat {0} alike\", \"all\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*collection*2 item(s)*we treat all alike, but *1 item(s) more than*\");\n }\n\n [Fact]\n public void When_collections_with_duplicates_are_not_equivalent_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3, 1];\n int[] collection2 = [1, 2, 3, 3];\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1[3]*to be 3, but found 1*\");\n }\n\n [Fact]\n public void When_testing_for_equivalence_against_empty_collection_it_should_throw()\n {\n // Arrange\n int[] subject = [1, 2, 3];\n int[] otherCollection = [];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be a collection with 0 item(s), but*contains 3 item(s)*\");\n }\n\n [Fact]\n public void When_two_collections_are_both_empty_it_should_treat_them_as_equivalent()\n {\n // Arrange\n int[] subject = [];\n int[] otherCollection = [];\n\n // Act / Assert\n subject.Should().BeEquivalentTo(otherCollection);\n }\n\n [Fact]\n public void When_testing_for_equivalence_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = null;\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected**but found {1, 2, 3}*\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equivalent_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act =\n () => collection.Should()\n .BeEquivalentTo(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to be *\");\n }\n\n [Fact]\n public void Default_immutable_arrays_should_be_equivalent()\n {\n // Arrange\n ImmutableArray collection = default;\n ImmutableArray collection1 = default;\n\n // Act / Assert\n collection.Should().BeEquivalentTo(collection1);\n }\n\n [Fact]\n public void Default_immutable_lists_should_be_equivalent()\n {\n // Arrange\n ImmutableList collection = default;\n ImmutableList collection1 = default;\n\n // Act / Assert\n collection.Should().BeEquivalentTo(collection1);\n }\n\n [Fact]\n public void Can_ignore_casing_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"first\", \"test\", \"last\" };\n var expectation = new[] { \"first\", \"TEST\", \"last\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"first\", \" test\", \"last\" };\n var expectation = new[] { \"first\", \"test\", \"last\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"first\", \"test \", \"last\" };\n var expectation = new[] { \"first\", \"test\", \"last\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"first\", \"A\\nB\\r\\nC\", \"last\" };\n var expectation = new[] { \"first\", \"A\\r\\nB\\nC\", \"last\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringNewlineStyle());\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void When_collection_is_not_equivalent_to_another_smaller_collection_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_large_collection_is_equivalent_to_another_equally_size_collection_it_should_throw()\n {\n // Arrange\n var collection1 = Enumerable.Repeat(1, 10000);\n var collection2 = Enumerable.Repeat(1, 10000);\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_is_not_equivalent_to_another_equally_sized_collection_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1, 4];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_collections_are_unexpectedly_equivalent_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1, 2];\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 {1, 2, 3} not*equivalent*{3, 1, 2}.\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equivalent_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] actual = null;\n int[] expectation = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n actual.Should().NotBeEquivalentTo(expectation, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*be equivalent because we want to test the behaviour with a null subject, but found *\");\n }\n\n [Fact]\n public void When_non_empty_collection_is_not_expected_to_be_equivalent_to_an_empty_collection_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_testing_collections_not_to_be_equivalent_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = null;\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify inequivalence against a collection.*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void When_testing_collections_not_to_be_equivalent_against_same_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n var collection1 = collection;\n\n // Act\n Action act = () => collection.Should().NotBeEquivalentTo(collection1,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not to be equivalent*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_a_collections_is_equivalent_to_an_approximate_copy_it_should_throw()\n {\n // Arrange\n double[] collection = [1.0, 2.0, 3.0];\n double[] collection1 = [1.5, 2.5, 3.5];\n\n // Act\n Action act = () => collection.Should().NotBeEquivalentTo(collection1, opt => opt\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.5))\n .WhenTypeIs(),\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not to be equivalent*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equivalent_with_options_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] actual = null;\n int[] expectation = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n actual.Should().NotBeEquivalentTo(expectation, opt => opt, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual not to be equivalent *failure message*, but found .*\");\n }\n\n [Fact]\n public void Default_immutable_array_should_not_be_equivalent_to_initialized_immutable_array()\n {\n // Arrange\n ImmutableArray subject = default;\n ImmutableArray expectation = ImmutableArray.Create(\"a\", \"b\", \"c\");\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Immutable_array_should_not_be_equivalent_to_default_immutable_array()\n {\n // Arrange\n ImmutableArray collection = ImmutableArray.Create(\"a\", \"b\", \"c\");\n ImmutableArray collection1 = default;\n\n // Act / Assert\n collection.Should().NotBeEquivalentTo(collection1);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Pathway.cs", "using AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents the path of a field or property in an object graph.\n/// \npublic record Pathway\n{\n public delegate string GetDescription(string pathAndName);\n\n private readonly string path = string.Empty;\n private string name = string.Empty;\n private string pathAndName;\n\n private readonly GetDescription getDescription;\n\n public Pathway(string path, string name, GetDescription getDescription)\n {\n Path = path;\n Name = name;\n this.getDescription = getDescription;\n }\n\n /// \n /// Creates an instance of with the specified parent and name and a factory\n /// to provide a description for the path and name.\n /// \n public Pathway(Pathway parent, string name, GetDescription getDescription)\n {\n Path = parent.PathAndName;\n Name = name;\n this.getDescription = getDescription;\n }\n\n /// \n /// Gets the path of the field or property without the name.\n /// \n public string Path\n {\n get => path;\n private init\n {\n path = value;\n pathAndName = null;\n }\n }\n\n /// \n /// Gets the name of the field or property without the path.\n /// \n public string Name\n {\n get => name;\n internal set\n {\n name = value;\n pathAndName = null;\n }\n }\n\n /// \n /// Gets the path and name of the field or property separated by dots.\n /// \n public string PathAndName => pathAndName ??= path.Combine(name);\n\n /// \n /// Gets the display representation of this path.\n /// \n public string Description => getDescription(PathAndName);\n\n public override string ToString() => Description;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MethodInfoSelectorAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Types;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains assertions for the objects returned by the parent .\n/// \n[DebuggerNonUserCode]\npublic class MethodInfoSelectorAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The methods to assert.\n /// is .\n public MethodInfoSelectorAssertions(AssertionChain assertionChain, params MethodInfo[] methods)\n {\n this.assertionChain = assertionChain;\n Guard.ThrowIfArgumentIsNull(methods);\n\n SubjectMethods = methods;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public IEnumerable SubjectMethods { get; }\n\n /// \n /// Asserts that the selected methods are virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] nonVirtualMethods = GetAllNonVirtualMethodsFromSelection();\n\n assertionChain\n .ForCondition(nonVirtualMethods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to be virtual{reason}, but the following methods are not virtual:\n {{GetDescriptionsFor(nonVirtualMethods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods are not virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] virtualMethods = GetAllVirtualMethodsFromSelection();\n\n assertionChain\n .ForCondition(virtualMethods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods not to be virtual{reason}, but the following methods are virtual:\n {{GetDescriptionsFor(virtualMethods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n private MethodInfo[] GetAllNonVirtualMethodsFromSelection()\n {\n return SubjectMethods.Where(method => method.IsNonVirtual()).ToArray();\n }\n\n private MethodInfo[] GetAllVirtualMethodsFromSelection()\n {\n return SubjectMethods.Where(method => !method.IsNonVirtual()).ToArray();\n }\n\n /// \n /// Asserts that the selected methods are async.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAsync([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] nonAsyncMethods = SubjectMethods.Where(method => !method.IsAsync()).ToArray();\n\n assertionChain\n .ForCondition(nonAsyncMethods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to be async{reason}, but the following methods are not:\n {{GetDescriptionsFor(nonAsyncMethods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods are not async.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAsync([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] asyncMethods = SubjectMethods.Where(method => method.IsAsync()).ToArray();\n\n assertionChain\n .ForCondition(asyncMethods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods not to be async{reason}, but the following methods are:\n {{GetDescriptionsFor(asyncMethods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods are decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n return BeDecoratedWith(_ => true, because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected methods are decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n MethodInfo[] methodsWithoutAttribute = GetMethodsWithout(isMatchingAttributePredicate);\n\n assertionChain\n .ForCondition(methodsWithoutAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to be decorated with {0}{reason}, but the following methods are not:\n {{GetDescriptionsFor(methodsWithoutAttribute)}}\n \"\"\", typeof(TAttribute)));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods are not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n return NotBeDecoratedWith(_ => true, because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected methods are not decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n MethodInfo[] methodsWithAttribute = GetMethodsWith(isMatchingAttributePredicate);\n\n assertionChain\n .ForCondition(methodsWithAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to not be decorated with {0}{reason}, but the following methods are:\n {{GetDescriptionsFor(methodsWithAttribute)}}\n \"\"\", typeof(TAttribute)));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods have specified .\n /// \n /// The expected access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] methods = SubjectMethods.Where(pi => pi.GetCSharpAccessModifier() != accessModifier).ToArray();\n\n assertionChain\n .ForCondition(methods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to be {{accessModifier}}{reason}, but the following methods are not:\n {{GetDescriptionsFor(methods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods don't have specified \n /// \n /// The expected access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] methods = SubjectMethods.Where(pi => pi.GetCSharpAccessModifier() == accessModifier).ToArray();\n\n assertionChain\n .ForCondition(methods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to not be {{accessModifier}}{reason}, but the following methods are:\"\n {{GetDescriptionsFor(methods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n private MethodInfo[] GetMethodsWithout(Expression> isMatchingPredicate)\n where TAttribute : Attribute\n {\n return SubjectMethods.Where(method => !method.IsDecoratedWith(isMatchingPredicate)).ToArray();\n }\n\n private MethodInfo[] GetMethodsWith(Expression> isMatchingPredicate)\n where TAttribute : Attribute\n {\n return SubjectMethods.Where(method => method.IsDecoratedWith(isMatchingPredicate)).ToArray();\n }\n\n private static string GetDescriptionsFor(IEnumerable methods)\n {\n IEnumerable descriptions = methods.Select(method => MethodInfoAssertions.GetDescriptionFor(method));\n\n return string.Join(Environment.NewLine, descriptions);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n#pragma warning disable CA1822 // Do not change signature of a public member\n protected string Context => \"method\";\n#pragma warning restore CA1822\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/MethodInfoExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class MethodInfoExtensions\n{\n /// \n /// A sum of all possible . It's needed to calculate what options were used when decorating with .\n /// They are a subset of which can be checked on a type and therefore this mask has to be applied to check only for options.\n /// \n private static readonly Lazy ImplementationOptionsMask =\n new(() => Enum.GetValues(typeof(MethodImplOptions)).Cast().Sum(x => x));\n\n internal static bool IsAsync(this MethodInfo methodInfo)\n {\n return methodInfo.IsDecoratedWith();\n }\n\n internal static IEnumerable GetMatchingAttributes(this MemberInfo memberInfo,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n var customAttributes = memberInfo.GetCustomAttributes(inherit: false).ToList();\n\n if (typeof(TAttribute) == typeof(MethodImplAttribute) && memberInfo is MethodBase methodBase)\n {\n (bool success, MethodImplAttribute methodImplAttribute) = RecreateMethodImplAttribute(methodBase);\n if (success)\n {\n customAttributes.Add(methodImplAttribute as TAttribute);\n }\n }\n\n return customAttributes\n .Where(isMatchingAttributePredicate.Compile());\n }\n\n internal static bool IsNonVirtual(this MethodInfo method)\n {\n return !method.IsVirtual || method.IsFinal;\n }\n\n private static (bool success, MethodImplAttribute attribute) RecreateMethodImplAttribute(MethodBase methodBase)\n {\n MethodImplAttributes implementationFlags = methodBase.MethodImplementationFlags;\n\n int implementationFlagsMatchingImplementationOptions =\n (int)implementationFlags & ImplementationOptionsMask.Value;\n\n MethodImplOptions implementationOptions = (MethodImplOptions)implementationFlagsMatchingImplementationOptions;\n\n if (implementationOptions != default)\n {\n return (true, new MethodImplAttribute(implementationOptions));\n }\n\n return (false, null);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IObjectInfo.cs", "using System;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents an object, dictionary key pair, collection item or member in an object graph.\n/// \npublic interface IObjectInfo\n{\n /// \n /// Gets the type of the object\n /// \n [Obsolete(\"Use CompileTimeType or RuntimeType instead\")]\n Type Type { get; }\n\n /// \n /// Gets the type of the parent, e.g. the type that declares a property or field.\n /// \n /// \n /// Is for the root object.\n /// \n [CanBeNull]\n Type ParentType { get; }\n\n /// \n /// Gets the full path from the root object until the current node separated by dots.\n /// \n string Path { get; set; }\n\n /// \n /// Gets the compile-time type of the current object. If the current object is not the root object and the type is not ,\n /// then it returns the same as the property does.\n /// \n Type CompileTimeType { get; }\n\n /// \n /// Gets the run-time type of the current object.\n /// \n Type RuntimeType { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/AssertionChainSpecs.MessageFormating.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\n/// \n/// The message formatting specs.\n/// \npublic partial class AssertionChainSpecs\n{\n public class MessageFormatting\n {\n [Fact]\n public void Multiple_assertions_in_an_assertion_scope_are_all_reported()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure\");\n AssertionChain.GetOrCreate().FailWith(\"Failure\");\n\n using (new AssertionScope())\n {\n AssertionChain.GetOrCreate().FailWith(\"Failure\");\n AssertionChain.GetOrCreate().FailWith(\"Failure\");\n }\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Contain(\"Failure\", Exactly.Times(4));\n }\n\n [InlineData(\"foo\")]\n [InlineData(\"{}\")]\n [Theory]\n public void The_failure_message_uses_the_name_of_the_scope_as_context(string context)\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope(context);\n new[] { 1, 2, 3 }.Should().Equal(3, 2, 1);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected {context} to be equal to*\");\n }\n\n [Fact]\n public void The_failure_message_uses_the_lazy_name_of_the_scope_as_context()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope(() => \"lazy foo\");\n new[] { 1, 2, 3 }.Should().Equal(3, 2, 1);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected lazy foo to be equal to*\");\n }\n\n [Fact]\n public void The_failure_message_includes_all_failures()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var values = new Dictionary();\n values.Should().ContainKey(0);\n values.Should().ContainKey(1);\n };\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"\"\"\n Expected * to contain key 0.\n Expected * to contain key 1.\n\n \"\"\");\n }\n\n [Fact]\n public void The_failure_message_includes_all_failures_as_well()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var values = new List();\n values.Should().ContainSingle();\n values.Should().ContainSingle();\n };\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"\"\"\n Expected * to contain a single item, but the collection is empty.\n Expected * to contain a single item, but the collection is empty.\n\n \"\"\");\n }\n\n [Fact]\n public void The_reason_can_contain_parentheses()\n {\n // Act\n Action act = () => 1.Should().Be(2, \"can't use these in becauseArgs: {0} {1}\", \"{\", \"}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because can't use these in becauseArgs: { }*\");\n }\n\n [Fact]\n public void Because_reason_should_ignore_undefined_arguments()\n {\n // Act\n object[] becauseArgs = null;\n Action act = () => 1.Should().Be(2, \"it should still work\", becauseArgs);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because it should still work*\");\n }\n\n [Fact]\n public void Because_reason_should_threat_parentheses_as_literals_if_no_arguments_are_defined()\n {\n // Act\n#pragma warning disable CA2241\n // ReSharper disable once FormatStringProblem\n Action act = () => 1.Should().Be(2, \"use of {} is okay if there are no because arguments\");\n#pragma warning restore CA2241\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because use of {} is okay if there are no because arguments*\");\n }\n\n [Fact]\n public void Because_reason_should_inform_about_invalid_parentheses_with_a_default_message()\n {\n // Act\n#pragma warning disable CA2241\n // ReSharper disable once FormatStringProblem\n Action act = () => 1.Should().Be(2, \"use of {} is considered invalid in because parameter with becauseArgs\",\n \"additional becauseArgs argument\");\n#pragma warning restore CA2241\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*because message 'use of {} is considered invalid in because parameter with becauseArgs' could not be formatted with string.Format*\");\n }\n\n [Fact]\n public void Message_should_keep_parentheses_in_literal_values()\n {\n // Act\n Action act = () => \"{foo}\".Should().Be(\"{bar}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string to be the same string*\\\"{foo}\\\"*\\\"{bar}\\\"*\");\n }\n\n [Fact]\n public void Message_should_contain_literal_value_if_marked_with_double_parentheses()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate().FailWith(\"{{empty}}\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"{empty}*\");\n }\n\n [InlineData(\"\\r\")]\n [InlineData(\"\\\\r\")]\n [InlineData(\"\\\\\\r\")]\n [InlineData(\"\\\\\\\\r\")]\n [InlineData(\"\\\\\\\\\\r\")]\n [InlineData(\"\\n\")]\n [InlineData(\"\\\\n\")]\n [InlineData(\"\\\\\\n\")]\n [InlineData(\"\\\\\\\\n\")]\n [InlineData(\"\\\\\\\\\\n\")]\n [Theory]\n public void Message_should_not_have_modified_carriage_return_or_line_feed_control_characters(string str)\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate().FailWith(str);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(str);\n }\n\n [InlineData(\"\\r\")]\n [InlineData(\"\\\\r\")]\n [InlineData(\"\\\\\\r\")]\n [InlineData(@\"\\\\r\")]\n [InlineData(\"\\\\\\\\\\r\")]\n [InlineData(\"\\n\")]\n [InlineData(\"\\\\n\")]\n [InlineData(\"\\\\\\n\")]\n [InlineData(@\"\\\\n\")]\n [InlineData(\"\\\\\\\\\\n\")]\n [Theory]\n public void Message_should_not_have_modified_carriage_return_or_line_feed_control_characters_in_supplied_arguments(\n string str)\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate().FailWith(@\"\\{0}\\A\", str);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"\\\\\\\"\" + str + \"\\\"\\\\A*\");\n }\n\n [Fact]\n public void Message_should_not_have_trailing_backslashes_removed_from_subject()\n {\n // Arrange / Act\n Action act = () => \"A\\\\\".Should().Be(\"A\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\"\"*\"A\\\"*\"A\"*\"\"\");\n }\n\n [Fact]\n public void Message_should_not_have_trailing_backslashes_removed_from_expectation()\n {\n // Arrange / Act\n Action act = () => \"A\".Should().Be(\"A\\\\\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\"\"*\"A\"*\"A\\\"*\"\"\");\n }\n\n [Fact]\n public void Message_should_have_scope_reportable_values_appended_at_the_end()\n {\n // Arrange\n var scope = new AssertionScope();\n scope.AddReportable(\"SomeKey\", \"SomeValue\");\n scope.AddReportable(\"AnotherKey\", \"AnotherValue\");\n\n AssertionChain.GetOrCreate().FailWith(\"{SomeKey}{AnotherKey}\");\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"\"\"\n *With SomeKey:\n SomeValue\n With AnotherKey:\n AnotherValue\n\n \"\"\");\n }\n\n [Fact]\n public void Message_should_not_contain_reportable_values_added_to_chain_without_surrounding_scope()\n {\n // Arrange\n var chain = AssertionChain.GetOrCreate();\n chain.AddReportable(\"SomeKey\", \"SomeValue\");\n chain.AddReportable(\"AnotherKey\", \"AnotherValue\");\n\n // Act\n Action act = () => chain.FailWith(\"{SomeKey}{AnotherKey}\");\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().BeEmpty();\n }\n\n [Fact]\n public void Deferred_reportable_values_should_not_be_calculated_in_absence_of_failures()\n {\n // Arrange\n var scope = new AssertionScope();\n var deferredValueInvoked = false;\n\n scope.AddReportable(\"MyKey\", () =>\n {\n deferredValueInvoked = true;\n\n return \"MyValue\";\n });\n\n // Act\n scope.Dispose();\n\n // Assert\n deferredValueInvoked.Should().BeFalse();\n }\n\n [Fact]\n public void Message_should_start_with_the_defined_expectation()\n {\n // Act\n Action act = () =>\n {\n var assertion = AssertionChain.GetOrCreate();\n\n assertion\n .WithExpectation(\"Expectations are the root \", chain => chain\n .ForCondition(false)\n .FailWith(\"of disappointment\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectations are the root of disappointment\");\n }\n\n [Fact]\n public void Message_should_start_with_the_defined_expectation_and_arguments()\n {\n // Act\n Action act = () =>\n {\n var assertion = AssertionChain.GetOrCreate();\n\n assertion\n .WithExpectation(\"Expectations are the {0} \", \"root\", chain => chain.ForCondition(false)\n .FailWith(\"of disappointment\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectations are the \\\"root\\\" of disappointment\");\n }\n\n [Fact]\n public void Message_should_contain_object_as_context_if_identifier_can_not_be_resolved()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"Expected {context}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected object\");\n }\n\n [Fact]\n public void Message_should_contain_the_fallback_value_as_context_if_identifier_can_not_be_resolved()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"Expected {context:fallback}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected fallback\");\n }\n\n [Fact]\n public void Message_should_contain_the_default_identifier_as_context_if_identifier_can_not_be_resolved()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .WithDefaultIdentifier(\"identifier\")\n .ForCondition(false)\n .FailWith(\"Expected {context}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected identifier\");\n }\n\n [Fact]\n public void Message_should_contain_the_reason_as_defined()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .BecauseOf(\"because reasons\")\n .FailWith(\"Expected{reason}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because reasons\");\n }\n\n [Fact]\n public void Message_should_contain_the_reason_as_defined_with_arguments()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .BecauseOf(\"because {0}\", \"reasons\")\n .FailWith(\"Expected{reason}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because reasons\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentifier.cs", "using System;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Text.RegularExpressions;\nusing System.Threading;\nusing AwesomeAssertions.CallerIdentification;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Tries to extract the name of the variable or invocation on which the assertion is executed.\n/// \n// REFACTOR: Should be internal and treated as an implementation detail of the AssertionScope\npublic static class CallerIdentifier\n{\n public static Action Logger { get; set; } = _ => { };\n\n public static string DetermineCallerIdentity()\n {\n string caller = null;\n\n try\n {\n var stack = new StackTrace(fNeedFileInfo: true);\n\n var allStackFrames = GetFrames(stack);\n\n int searchStart = allStackFrames.Length - 1;\n\n if (StartStackSearchAfterStackFrame.Value is not null)\n {\n searchStart = Array.FindLastIndex(\n allStackFrames,\n allStackFrames.Length - StartStackSearchAfterStackFrame.Value.SkipStackFrameCount,\n frame => !IsCurrentAssembly(frame));\n }\n\n int lastUserStackFrameBeforeAwesomeAssertionsCodeIndex = Array.FindIndex(\n allStackFrames,\n startIndex: 0,\n count: searchStart + 1,\n frame => !IsCurrentAssembly(frame) && !IsDynamic(frame) && !IsDotNet(frame));\n\n for (int i = lastUserStackFrameBeforeAwesomeAssertionsCodeIndex; i < allStackFrames.Length; i++)\n {\n var frame = allStackFrames[i];\n\n Logger(frame.ToString());\n\n if (frame.GetMethod() is not null\n && !IsDynamic(frame)\n && !IsDotNet(frame)\n && !IsCustomAssertion(frame)\n && !IsCurrentAssembly(frame))\n {\n caller = ExtractVariableNameFrom(frame);\n break;\n }\n }\n }\n catch (Exception e)\n {\n // Ignore exceptions, as determination of caller identity is only a nice-to-have\n Logger(e.ToString());\n }\n\n return caller;\n }\n\n private sealed class StackFrameReference : IDisposable\n {\n public int SkipStackFrameCount { get; }\n\n private readonly StackFrameReference previousReference;\n\n public StackFrameReference()\n {\n var stack = new StackTrace();\n\n var allStackFrames = GetFrames(stack);\n\n int firstUserCodeFrameIndex = 0;\n\n while (firstUserCodeFrameIndex < allStackFrames.Length\n && IsCurrentAssembly(allStackFrames[firstUserCodeFrameIndex]))\n {\n firstUserCodeFrameIndex++;\n }\n\n SkipStackFrameCount = (allStackFrames.Length - firstUserCodeFrameIndex) + 1;\n\n previousReference = StartStackSearchAfterStackFrame.Value;\n StartStackSearchAfterStackFrame.Value = this;\n }\n\n public void Dispose()\n {\n StartStackSearchAfterStackFrame.Value = previousReference;\n }\n }\n\n private static readonly AsyncLocal StartStackSearchAfterStackFrame = new();\n\n internal static IDisposable OverrideStackSearchUsingCurrentScope()\n {\n return new StackFrameReference();\n }\n\n internal static bool OnlyOneAssertionScopeOnCallStack()\n {\n var allStackFrames = GetFrames(new StackTrace());\n\n int firstNonAwesomeAssertionsStackFrameIndex = Array.FindIndex(\n allStackFrames,\n frame => !IsCurrentAssembly(frame));\n\n if (firstNonAwesomeAssertionsStackFrameIndex < 0)\n {\n return true;\n }\n\n int startOfSecondAwesomeAssertionsScopeStackFrameIndex = Array.FindIndex(\n allStackFrames,\n startIndex: firstNonAwesomeAssertionsStackFrameIndex + 1,\n frame => IsCurrentAssembly(frame));\n\n return startOfSecondAwesomeAssertionsScopeStackFrameIndex < 0;\n }\n\n private static bool IsCustomAssertion(StackFrame frame)\n {\n MethodBase getMethod = frame.GetMethod();\n\n if (getMethod is not null)\n {\n return\n getMethod.IsDecoratedWithOrInherit() ||\n IsCustomAssertionClass(getMethod.DeclaringType) ||\n getMethod.ReflectedType?.Assembly.IsDefined(typeof(CustomAssertionsAssemblyAttribute)) == true;\n }\n\n return false;\n }\n\n /// \n /// Check if is a custom assertion class.\n /// \n /// \n /// Checking also explicitly the declaring type is necessary for DisplayClasses, which can't be marked\n /// themselves like normal nested classes.\n /// \n /// The class type to check\n /// True if type is a custom assertion class, or nested inside such a class.\n private static bool IsCustomAssertionClass(Type type)\n => type is not null && (type.IsDecoratedWithOrInherit() || IsCustomAssertionClass(type.DeclaringType));\n\n private static bool IsDynamic(StackFrame frame)\n {\n return frame.GetMethod() is { DeclaringType: null };\n }\n\n private static bool IsCurrentAssembly(StackFrame frame)\n {\n return frame.GetMethod()?.DeclaringType?.Assembly == typeof(CallerIdentifier).Assembly;\n }\n\n private static bool IsDotNet(StackFrame frame)\n {\n var frameNamespace = frame.GetMethod()?.DeclaringType?.Namespace;\n const StringComparison comparisonType = StringComparison.OrdinalIgnoreCase;\n\n return frameNamespace?.StartsWith(\"system.\", comparisonType) == true ||\n frameNamespace?.Equals(\"system\", comparisonType) == true;\n }\n\n private static bool IsCompilerServices(StackFrame frame)\n {\n return frame.GetMethod()?.DeclaringType?.Namespace is \"System.Runtime.CompilerServices\";\n }\n\n private static string ExtractVariableNameFrom(StackFrame frame)\n {\n string caller = null;\n string statement = GetSourceCodeStatementFrom(frame);\n\n if (!string.IsNullOrEmpty(statement))\n {\n Logger(statement);\n\n if (!IsBooleanLiteral(statement) && !IsNumeric(statement) && !IsStringLiteral(statement) &&\n !StartsWithNewKeyword(statement))\n {\n caller = statement;\n }\n }\n\n return caller;\n }\n\n private static string GetSourceCodeStatementFrom(StackFrame frame)\n {\n string fileName = frame.GetFileName();\n int expectedLineNumber = frame.GetFileLineNumber();\n\n if (string.IsNullOrEmpty(fileName) || expectedLineNumber == 0)\n {\n return null;\n }\n\n try\n {\n using var reader = new StreamReader(File.OpenRead(fileName));\n string line;\n int currentLine = 1;\n\n while ((line = reader.ReadLine()) is not null && currentLine < expectedLineNumber)\n {\n currentLine++;\n }\n\n return currentLine == expectedLineNumber\n && line != null\n ? GetSourceCodeStatementFrom(frame, reader, line)\n : null;\n }\n catch\n {\n // We don't care. Just assume the symbol file is not available or unreadable\n return null;\n }\n }\n\n private static string GetSourceCodeStatementFrom(StackFrame frame, StreamReader reader, string line)\n {\n int column = frame.GetFileColumnNumber();\n\n if (column > 0)\n {\n line = line.Substring(Math.Min(column - 1, line.Length - 1));\n }\n\n var sb = new CallerStatementBuilder();\n\n do\n {\n sb.Append(line);\n }\n while (!sb.IsDone() && (line = reader.ReadLine()) != null);\n\n return sb.ToString();\n }\n\n private static bool StartsWithNewKeyword(string candidate)\n {\n return Regex.IsMatch(candidate, @\"(?:^|s+)new(?:\\s?\\[|\\s?\\{|\\s\\w+)\");\n }\n\n private static bool IsStringLiteral(string candidate)\n {\n return candidate.StartsWith('\\\"');\n }\n\n private static bool IsNumeric(string candidate)\n {\n const NumberStyles numberStyle = NumberStyles.Float | NumberStyles.AllowThousands;\n return double.TryParse(candidate, numberStyle, CultureInfo.InvariantCulture, out _);\n }\n\n private static bool IsBooleanLiteral(string candidate)\n {\n return candidate is \"true\" or \"false\";\n }\n\n private static StackFrame[] GetFrames(StackTrace stack)\n {\n var frames = stack.GetFrames();\n#if !NET6_0_OR_GREATER\n if (frames == null)\n {\n return [];\n }\n#endif\n return frames\n .Where(frame => !IsCompilerServices(frame))\n .ToArray();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IMemberInfo.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a field or property in an object graph.\n/// \npublic interface IMemberInfo\n{\n /// \n /// Gets the name of the current member.\n /// \n string Name { get; }\n\n /// \n /// Gets the type of this member.\n /// \n Type Type { get; }\n\n /// \n /// Gets the type that declares the current member.\n /// \n Type DeclaringType { get; }\n\n /// \n /// Gets the full path from the root object until and including the current node separated by dots.\n /// \n string Path { get; set; }\n\n /// \n /// Gets the access modifier for the getter of this member.\n /// \n CSharpAccessModifier GetterAccessibility { get; }\n\n /// \n /// Gets the access modifier for the setter of this member.\n /// \n CSharpAccessModifier SetterAccessibility { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/EnumerableValueFormatter.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class EnumerableValueFormatter : IValueFormatter\n{\n /// \n /// The number of items to include when formatting this object.\n /// \n /// The default value is 32.\n protected virtual int MaxItems => 32;\n\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public virtual bool CanHandle(object value)\n {\n return value is IEnumerable;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n IEnumerable collection = ((IEnumerable)value).Cast();\n\n using var iterator = new Iterator(collection, MaxItems);\n\n var iteratorGraph = formattedGraph.KeepOnSingleLineAsLongAsPossible();\n FormattedObjectGraph.PossibleMultilineFragment separatingCommaGraph = null;\n\n while (iterator.MoveNext())\n {\n if (!iterator.HasReachedMaxItems)\n {\n formatChild(iterator.Index.ToString(CultureInfo.InvariantCulture), iterator.Current, formattedGraph);\n }\n else\n {\n using IDisposable _ = formattedGraph.WithIndentation();\n string moreItemsMessage = value is ICollection c ? $\"…{c.Count - MaxItems} more…\" : \"…more…\";\n iteratorGraph.AddLineOrFragment(moreItemsMessage);\n }\n\n separatingCommaGraph?.InsertLineOrFragment(\", \");\n separatingCommaGraph = formattedGraph.KeepOnSingleLineAsLongAsPossible();\n\n // We cannot know whether or not the enumerable will take up more than one line of\n // output until we have formatted the first item. So we format the first item, then\n // go back and insert the enumerable's opening brace in the correct place depending\n // on whether that first item was all on one line or not.\n if (iterator.IsLast)\n {\n iteratorGraph.AddStartingLineOrFragment(\"{\");\n iteratorGraph.AddLineOrFragment(\"}\");\n }\n }\n\n if (iterator.IsEmpty)\n {\n iteratorGraph.AddFragment(\"{empty}\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/FormatterSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Formatting;\nusing AwesomeAssertions.Specs.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\n[Collection(\"FormatterSpecs\")]\npublic sealed class FormatterSpecs : IDisposable\n{\n [Fact]\n public void Use_configuration_when_highlighting_string_difference()\n {\n // Arrange\n string subject = \"this is a very long string with lots of words that most won't be displayed in the error message!\";\n string expected = \"this is another string that differs after a couple of words.\";\n Action action = () => subject.Should().Be(expected);\n\n int previousStringPrintLength = AssertionConfiguration.Current.Formatting.StringPrintLength;\n try\n {\n // Act\n AssertionConfiguration.Current.Formatting.StringPrintLength = 10;\n\n // Assert\n action.Should().Throw().WithMessage(\"\"\"\n *\n ↓ (actual)\n \"this is a very long…\"\n \"this is another…\"\n ↑ (expected).\n \"\"\");\n }\n finally\n {\n AssertionConfiguration.Current.Formatting.StringPrintLength = previousStringPrintLength;\n }\n }\n\n [Fact]\n public void When_value_contains_cyclic_reference_it_should_create_descriptive_error_message()\n {\n // Arrange\n var parent = new Node();\n parent.Children.Add(new Node());\n parent.Children.Add(parent);\n\n // Act\n string result = Formatter.ToString(parent);\n\n // Assert\n result.Should().ContainEquivalentOf(\"cyclic reference\");\n }\n\n [Fact]\n public void When_the_same_object_appears_twice_in_the_graph_at_different_paths()\n {\n // Arrange\n var a = new A();\n\n var b = new B\n {\n X = a,\n Y = a\n };\n\n // Act\n Action act = () => b.Should().BeNull();\n\n // Assert\n var exception = act.Should().Throw().Which;\n exception.Message.Should().NotContainEquivalentOf(\"cyclic\");\n }\n\n private class A;\n\n private class B\n {\n public A X { get; set; }\n\n public A Y { get; set; }\n }\n\n [Fact]\n public void When_the_subject_or_expectation_contains_reserved_symbols_it_should_escape_then()\n {\n // Arrange\n string result = \"{ a : [{ b : \\\"2016-05-23T10:45:12Z\\\" } ]}\";\n\n string expectedJson = \"{ a : [{ b : \\\"2016-05-23T10:45:12Z\\\" }] }\";\n\n // Act\n Action act = () => result.Should().Be(expectedJson);\n\n // Assert\n act.Should().Throw().WithMessage(\"*at*index 37*\");\n }\n\n [Fact]\n public void When_a_timespan_is_one_tick_it_should_be_formatted_as_positive()\n {\n // Arrange\n var time = TimeSpan.FromTicks(1);\n\n // Act\n string result = Formatter.ToString(time);\n\n // Assert\n result.Should().NotStartWith(\"-\");\n }\n\n [Fact]\n public void When_a_timespan_is_minus_one_tick_it_should_be_formatted_as_negative()\n {\n // Arrange\n var time = TimeSpan.FromTicks(-1);\n\n // Act\n string result = Formatter.ToString(time);\n\n // Assert\n result.Should().StartWith(\"-\");\n }\n\n [Fact]\n public void When_a_datetime_is_very_close_to_the_edges_of_a_datetimeoffset_it_should_not_crash()\n {\n // Arrange\n var dateTime = DateTime.MinValue + 1.Minutes();\n\n // Act\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<00:01:00>\");\n }\n\n [Fact]\n public void When_the_minimum_value_of_a_datetime_is_provided_it_should_return_a_clear_representation()\n {\n // Arrange\n var dateTime = DateTime.MinValue;\n\n // Act\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<0001-01-01 00:00:00.000>\");\n }\n\n [Fact]\n public void When_the_maximum_value_of_a_datetime_is_provided_it_should_return_a_clear_representation()\n {\n // Arrange\n var dateTime = DateTime.MaxValue;\n\n // Act\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<9999-12-31 23:59:59.9999999>\");\n }\n\n [Fact]\n public void When_a_property_throws_an_exception_it_should_ignore_that_and_still_create_a_descriptive_error_message()\n {\n // Arrange\n var subject = new ExceptionThrowingClass();\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Contain(\"Member 'ThrowingProperty' threw an exception: 'CustomMessage'\");\n }\n\n [Fact]\n public void When_an_exception_contains_an_inner_exception_they_should_both_appear_in_the_error_message()\n {\n // Arrange\n Exception subject = new(\"OuterExceptionMessage\", new InvalidOperationException(\"InnerExceptionMessage\"));\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Contain(\"OuterExceptionMessage\")\n .And.Contain(\"InnerExceptionMessage\");\n }\n\n [InlineData(typeof(ulong), \"ulong\")]\n [InlineData(typeof(void), \"void\")]\n [InlineData(typeof(float?), \"float?\")]\n [Theory]\n public void When_the_object_is_a_primitive_type_it_should_be_formatted_as_language_keyword(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(List), \"System.Collections.Generic.List\")]\n [InlineData(typeof(Dictionary<,>), \"System.Collections.Generic.Dictionary\")]\n [InlineData(typeof(Dictionary>, Dictionary>>), \"System.Collections.Generic.Dictionary>, System.Collections.Generic.Dictionary>>\")]\n public void When_the_object_is_a_generic_type_it_should_be_formatted_as_written_in_source_code(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(int[]), \"int[]\")]\n [InlineData(typeof(float[][]), \"float[][]\")]\n [InlineData(typeof(float[][][]), \"float[][][]\")]\n [InlineData(typeof(FormatterSpecs[,]), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs[,]\")]\n [InlineData(typeof((string, int, Type)[,,]), \"System.ValueTuple[,,]\")]\n public void When_the_object_is_an_array_it_should_be_formatted_as_written_in_source_code(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(NestedClass), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs+NestedClass\")]\n [InlineData(typeof(NestedClass), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs+NestedClass\")]\n [InlineData(typeof(NestedClass.InnerClass), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs+NestedClass`1+InnerClass\")]\n public void When_the_object_is_a_nested_class_its_declaring_types_should_be_formatted_like_the_clr_shorthand(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(int?[]), \"int?[]\")]\n [InlineData(typeof((string, int?)), \"System.ValueTuple\")]\n public void When_the_object_contains_a_nullable_type_somewhere_it_should_be_formatted_with_a_questionmark(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(List), \"List\")]\n [InlineData(typeof(Dictionary<,>), \"Dictionary\")]\n [InlineData(typeof(Dictionary>, Dictionary>>), \"Dictionary>, Dictionary>>\")]\n public void When_the_object_is_a_shortvaluetype_with_generic_type_it_should_be_formatted_as_written_in_source_code_without_namespaces(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject.AsFormattableShortType());\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(null, \"\")]\n [InlineData(typeof(FormatterSpecs), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs\")]\n [InlineData(typeof(List), \"System.Collections.Generic.List\")]\n [InlineData(typeof(Dictionary<,>), \"System.Collections.Generic.Dictionary\")]\n [InlineData(typeof(Dictionary>, Dictionary>>), \"System.Collections.Generic.Dictionary\")]\n public void When_the_object_is_requested_to_be_formatted_as_type_definition_it_should_format_without_generic_argument_details(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject.AsFormattableTypeDefinition());\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(null, \"\")]\n [InlineData(typeof(FormatterSpecs), \"FormatterSpecs\")]\n [InlineData(typeof(List), \"List\")]\n [InlineData(typeof(Dictionary<,>), \"Dictionary\")]\n [InlineData(typeof(Dictionary>, Dictionary>>), \"Dictionary\")]\n public void When_the_object_is_requested_to_be_formatted_as_short_type_definition_it_should_format_without_generic_argument_details_and_without_namespaces(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject.AsFormattableShortTypeDefinition());\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Fact]\n public void When_the_object_is_a_class_without_namespace_it_should_be_formatted_with_the_class_name_only()\n {\n // Act\n string result = Formatter.ToString(typeof(AssertionScopeSpecsWithoutNamespace));\n\n // Assert\n result.Should().Be(nameof(AssertionScopeSpecsWithoutNamespace));\n }\n\n private sealed class NestedClass\n {\n public sealed class InnerClass;\n }\n\n private sealed class NestedClass\n {\n public sealed class InnerClass;\n }\n\n [Fact]\n public void When_the_object_is_a_generic_type_without_custom_string_representation_it_should_show_the_properties()\n {\n // Arrange\n var stuff = new List>\n {\n new()\n {\n StuffId = 1,\n Description = \"Stuff_1\",\n Children = [1, 2, 3, 4]\n },\n new()\n {\n StuffId = 2,\n Description = \"Stuff_2\",\n Children = [1, 2, 3, 4]\n }\n };\n\n var expectedStuff = new List>\n {\n new()\n {\n StuffId = 1,\n Description = \"Stuff_1\",\n Children = [1, 2, 3, 4]\n },\n new()\n {\n StuffId = 2,\n Description = \"WRONG_DESCRIPTION\",\n Children = [1, 2, 3, 4]\n }\n };\n\n // Act\n Action act = () => stuff.Should().NotBeNull()\n .And.Equal(expectedStuff, (t1, t2) => t1.StuffId == t2.StuffId && t1.Description == t2.Description);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"\"\"\n Expected stuff to be equal to\n {\n AwesomeAssertions.Specs.Formatting.FormatterSpecs+Stuff\n {\n Children = {1, 2, 3, 4},\n Description = \"Stuff_1\",\n StuffId = 1\n },\n AwesomeAssertions.Specs.Formatting.FormatterSpecs+Stuff\n {\n Children = {1, 2, 3, 4},\n Description = \"WRONG_DESCRIPTION\",\n StuffId = 2\n }\n }, but\n {\n AwesomeAssertions.Specs.Formatting.FormatterSpecs+Stuff\n {\n Children = {1, 2, 3, 4},\n Description = \"Stuff_1\",\n StuffId = 1\n },\n AwesomeAssertions.Specs.Formatting.FormatterSpecs+Stuff\n {\n Children = {1, 2, 3, 4},\n Description = \"Stuff_2\",\n StuffId = 2\n }\n } differs at index 1.\n \"\"\");\n }\n\n [Fact]\n public void When_the_object_is_a_user_defined_type_it_should_show_the_name_on_the_initial_line()\n {\n // Arrange\n var stuff = new StuffRecord(42, \"description\", new ChildRecord(24), [10, 20, 30, 40]);\n\n // Act\n Action act = () => stuff.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\n \"\"\"\n Expected stuff to be , but found AwesomeAssertions.Specs.Formatting.FormatterSpecs+StuffRecord\n {\n RecordChildren = {10, 20, 30, 40},\n RecordDescription = \"description\",\n RecordId = 42,\n SingleChild = AwesomeAssertions.Specs.Formatting.FormatterSpecs+ChildRecord\n {\n ChildRecordId = 24\n }\n }.\n \"\"\");\n }\n\n [Fact]\n public void When_the_object_is_an_anonymous_type_it_should_show_the_properties_recursively()\n {\n // Arrange\n var stuff = new\n {\n Description = \"absent\",\n SingleChild = new { ChildId = 8 },\n Children = new[] { 1, 2, 3, 4 },\n };\n\n var expectedStuff = new\n {\n SingleChild = new { ChildId = 4 },\n Children = new[] { 10, 20, 30, 40 },\n };\n\n // Act\n Action act = () => stuff.Should().Be(expectedStuff);\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Be(\n \"\"\"\n Expected stuff to be\n {\n Children = {10, 20, 30, 40},\n SingleChild =\n {\n ChildId = 4\n }\n }, but found\n {\n Children = {1, 2, 3, 4},\n Description = \"absent\",\n SingleChild =\n {\n ChildId = 8\n }\n }.\n \"\"\");\n }\n\n [Fact]\n public void\n When_the_object_is_a_list_of_anonymous_type_it_should_show_the_properties_recursively_with_newlines_and_indentation()\n {\n // Arrange\n var stuff = new[]\n {\n new\n {\n Description = \"absent\",\n },\n new\n {\n Description = \"absent\",\n },\n };\n\n var expectedStuff = new[]\n {\n new\n {\n ComplexChildren = new[]\n {\n new { Property = \"hello\" },\n new { Property = \"goodbye\" },\n },\n },\n };\n\n // Act\n Action act = () => stuff.Should().BeEquivalentTo(expectedStuff);\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\n \"\"\"\n Expected stuff to be a collection with 1 item(s), but*\n {\n {\n Description = \"absent\"\n },*\n {\n Description = \"absent\"\n }\n }\n contains 1 item(s) more than\n\n {\n {\n ComplexChildren =*\n {\n {\n Property = \"hello\"\n },*\n {\n Property = \"goodbye\"\n }\n }\n }\n }.*\n \"\"\");\n }\n\n [Fact]\n public void When_the_object_is_an_empty_anonymous_type_it_should_show_braces_on_the_same_line()\n {\n // Arrange\n var stuff = new\n {\n };\n\n // Act\n Action act = () => stuff.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"*but found { }*\");\n }\n\n [Fact]\n public void When_the_object_is_a_tuple_it_should_show_the_properties_recursively()\n {\n // Arrange\n (int TupleId, string Description, List Children) stuff = (1, \"description\", [1, 2, 3, 4]);\n\n (int, string, List) expectedStuff = (2, \"WRONG_DESCRIPTION\", new List { 4, 5, 6, 7 });\n\n // Act\n Action act = () => stuff.Should().Be(expectedStuff);\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\n \"\"\"\n Expected stuff to be equal to*\n {\n Item1 = 2,*\n Item2 = \"WRONG_DESCRIPTION\",*\n Item3 = {4, 5, 6, 7}\n }, but found*\n {\n Item1 = 1,*\n Item2 = \"description\",*\n Item3 = {1, 2, 3, 4}\n }.*\n \"\"\");\n }\n\n [Fact]\n public void When_the_object_is_a_record_it_should_show_the_properties_recursively()\n {\n // Arrange\n var stuff = new StuffRecord(\n RecordId: 9,\n RecordDescription: \"descriptive\",\n SingleChild: new ChildRecord(ChildRecordId: 80),\n RecordChildren: [4, 5, 6, 7]);\n\n var expectedStuff = new\n {\n RecordDescription = \"WRONG_DESCRIPTION\",\n };\n\n // Act\n Action act = () => stuff.Should().Be(expectedStuff);\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\n \"\"\"\n Expected stuff to be*\n {\n RecordDescription = \"WRONG_DESCRIPTION\"\n }, but found AwesomeAssertions.Specs.Formatting.FormatterSpecs+StuffRecord\n {\n RecordChildren = {4, 5, 6, 7},*\n RecordDescription = \"descriptive\",*\n RecordId = 9,*\n SingleChild = AwesomeAssertions.Specs.Formatting.FormatterSpecs+ChildRecord\n {\n ChildRecordId = 80\n }\n }.\n \"\"\");\n }\n\n [Fact]\n public void When_the_to_string_override_throws_it_should_use_the_default_behavior()\n {\n // Arrange\n var subject = new NullThrowingToStringImplementation();\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Contain(\"SomeProperty\");\n }\n\n [Fact]\n public void\n When_the_maximum_recursion_depth_is_met_it_should_give_a_descriptive_message()\n {\n // Arrange\n var head = new Node();\n var node = head;\n\n int maxDepth = 10;\n int iterations = (maxDepth / 2) + 1; // Each iteration adds two levels of depth to the graph\n\n foreach (int i in Enumerable.Range(0, iterations))\n {\n var newHead = new Node();\n node.Children.Add(newHead);\n node = newHead;\n }\n\n // Act\n string result = Formatter.ToString(head, new FormattingOptions\n {\n MaxDepth = maxDepth\n });\n\n // Assert\n result.Should().ContainEquivalentOf($\"maximum recursion depth of {maxDepth}\");\n }\n\n [Fact]\n public void When_the_maximum_recursion_depth_is_never_reached_it_should_render_the_entire_graph()\n {\n // Arrange\n var head = new Node();\n var node = head;\n\n int iterations = 10;\n\n foreach (int i in Enumerable.Range(0, iterations))\n {\n var newHead = new Node();\n node.Children.Add(newHead);\n node = newHead;\n }\n\n // Act\n string result = Formatter.ToString(head, new FormattingOptions\n {\n // Each iteration adds two levels of depth to the graph\n MaxDepth = (iterations * 2) + 1\n });\n\n // Assert\n result.Should().NotContainEquivalentOf(\"maximum recursion depth\");\n }\n\n [Fact]\n public void When_formatting_a_collection_exceeds_the_max_line_count_it_should_cut_off_the_result()\n {\n // Arrange\n var collection = Enumerable.Range(0, 20)\n .Select(i => new StuffWithAField\n {\n Description = $\"Property {i}\",\n Field = $\"Field {i}\",\n StuffId = i\n })\n .ToArray();\n\n // Act\n string result = Formatter.ToString(collection, new FormattingOptions\n {\n MaxLines = 50\n });\n\n // Assert\n result.Should().Match(\"*Output has exceeded*50*line*\");\n }\n\n [Fact]\n public void When_formatting_a_byte_array_it_should_limit_the_items()\n {\n // Arrange\n byte[] value = new byte[1000];\n new Random().NextBytes(value);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Match(\"{0x*, …968 more…}\");\n }\n\n [Fact]\n public void When_formatting_with_default_behavior_it_should_include_non_private_fields()\n {\n // Arrange\n var stuffWithAField = new StuffWithAField { Field = \"Some Text\" };\n\n // Act\n string result = Formatter.ToString(stuffWithAField);\n\n // Assert\n result.Should().Contain(\"Field\").And.Contain(\"Some Text\");\n result.Should().NotContain(\"privateField\");\n }\n\n [Fact]\n public void When_formatting_unsigned_integer_it_should_have_c_sharp_postfix()\n {\n // Arrange\n uint value = 12U;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12u\");\n }\n\n [Fact]\n public void When_formatting_long_integer_it_should_have_c_sharp_postfix()\n {\n // Arrange\n long value = 12L;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12L\");\n }\n\n [Fact]\n public void When_formatting_unsigned_long_integer_it_should_have_c_sharp_postfix()\n {\n // Arrange\n ulong value = 12UL;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12UL\");\n }\n\n [Fact]\n public void When_formatting_short_integer_it_should_have_f_sharp_postfix()\n {\n // Arrange\n short value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12s\");\n }\n\n [Fact]\n public void When_formatting_unsigned_short_integer_it_should_have_f_sharp_postfix()\n {\n // Arrange\n ushort value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12us\");\n }\n\n [Fact]\n public void When_formatting_byte_it_should_use_hexadecimal_notation()\n {\n // Arrange\n byte value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"0x0C\");\n }\n\n [Fact]\n public void When_formatting_signed_byte_it_should_have_f_sharp_postfix()\n {\n // Arrange\n sbyte value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12y\");\n }\n\n [Fact]\n public void When_formatting_single_it_should_have_c_sharp_postfix()\n {\n // Arrange\n float value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12F\");\n }\n\n [Fact]\n public void When_formatting_single_positive_infinity_it_should_be_property_reference()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"Single.PositiveInfinity\");\n }\n\n [Fact]\n public void When_formatting_single_negative_infinity_it_should_be_property_reference()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"Single.NegativeInfinity\");\n }\n\n [Fact]\n public void When_formatting_single_it_should_have_max_precision()\n {\n // Arrange\n float value = 1 / 3F;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().BeOneOf(\"0.33333334F\", \"0.333333343F\");\n }\n\n [Fact]\n public void When_formatting_single_not_a_number_it_should_just_say_nan()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n // NaN is not even equal to itself so its type does not matter.\n result.Should().Be(\"NaN\");\n }\n\n [Fact]\n public void When_formatting_double_integer_it_should_have_decimal_point()\n {\n // Arrange\n double value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12.0\");\n }\n\n [Fact]\n public void When_formatting_double_with_big_exponent_it_should_have_exponent()\n {\n // Arrange\n double value = 1E+30;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"1E+30\");\n }\n\n [Fact]\n public void When_formatting_double_positive_infinity_it_should_be_property_reference()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"Double.PositiveInfinity\");\n }\n\n [Fact]\n public void When_formatting_double_negative_infinity_it_should_be_property_reference()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"Double.NegativeInfinity\");\n }\n\n [Fact]\n public void When_formatting_double_not_a_number_it_should_just_say_nan()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n // NaN is not even equal to itself so its type does not matter.\n result.Should().Be(\"NaN\");\n }\n\n [Fact]\n public void When_formatting_double_it_should_have_max_precision()\n {\n // Arrange\n double value = 1 / 3D;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().BeOneOf(\"0.3333333333333333\", \"0.33333333333333331\");\n }\n\n [Fact]\n public void When_formatting_decimal_it_should_have_c_sharp_postfix()\n {\n // Arrange\n decimal value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12M\");\n }\n\n [Fact]\n public void When_formatting_a_pending_task_it_should_return_the_task_status()\n {\n // Arrange\n Task bar = new TaskCompletionSource().Task;\n\n // Act\n string result = Formatter.ToString(bar);\n\n // Assert\n result.Should().Be(\"System.Threading.Tasks.Task {Status=WaitingForActivation}\");\n }\n\n [Fact]\n public void When_formatting_a_completion_source_it_should_include_the_underlying_task()\n {\n // Arrange\n var completionSource = new TaskCompletionSource();\n\n // Act\n string result = Formatter.ToString(completionSource);\n\n // Assert\n result.Should().Match(\"*TaskCompletionSource*System.Threading.Tasks.Task*Status=WaitingForActivation*\");\n }\n\n private class MyKey\n {\n public int KeyProp { get; set; }\n }\n\n private class MyValue\n {\n public int ValueProp { get; set; }\n }\n\n [Fact]\n public void When_formatting_a_dictionary_it_should_format_keys_and_values()\n {\n // Arrange\n var subject = new Dictionary\n {\n [new MyKey { KeyProp = 13 }] = new() { ValueProp = 37 }\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Match(\"*{*[*MyKey*KeyProp = 13*] = *MyValue*ValueProp = 37*}*\");\n }\n\n [Fact]\n public void When_formatting_an_empty_dictionary_it_should_be_clear_from_the_message()\n {\n // Arrange\n var subject = new Dictionary();\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Match(\"{empty}\");\n }\n\n [Fact]\n public void When_formatting_a_large_dictionary_it_should_limit_the_number_of_formatted_entries()\n {\n // Arrange\n var subject = Enumerable.Range(0, 50).ToDictionary(e => e, e => e);\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Match(\"*…18 more…*\");\n }\n\n [Fact]\n public void\n When_formatting_multiple_items_with_a_custom_string_representation_using_line_breaks_it_should_end_lines_with_a_comma()\n {\n // Arrange\n object[] subject = [new ClassAWithToStringOverride(), new ClassBWithToStringOverride()];\n\n // Act\n string result = Formatter.ToString(subject, new FormattingOptions { UseLineBreaks = true });\n\n // Assert\n result.Should().Contain($\"One override, {Environment.NewLine}\");\n result.Should().Contain($\"Other override{Environment.NewLine}\");\n }\n\n private class ClassAWithToStringOverride\n {\n public override string ToString() => \"One override\";\n }\n\n private class ClassBWithToStringOverride\n {\n public override string ToString() => \"Other override\";\n }\n\n public class BaseStuff\n {\n public int StuffId { get; set; }\n\n public string Description { get; set; }\n }\n\n public class StuffWithAField\n {\n public int StuffId { get; set; }\n\n public string Description { get; set; }\n\n public string Field;\n#pragma warning disable 169, CA1823, IDE0044, RCS1169\n private string privateField;\n#pragma warning restore 169, CA1823, IDE0044, RCS1169\n }\n\n public class Stuff : BaseStuff\n {\n public List Children { get; set; }\n }\n\n private record StuffRecord(int RecordId, string RecordDescription, ChildRecord SingleChild, List RecordChildren);\n\n private record ChildRecord(int ChildRecordId);\n\n [Fact]\n public void When_defining_a_custom_value_formatter_it_should_respect_the_overrides()\n {\n // Arrange\n var value = new CustomClass();\n var formatter = new CustomClassValueFormatter();\n using var _ = new FormatterScope(formatter);\n\n // Act\n string str = Formatter.ToString(value);\n\n // Assert\n str.Should().Match(\n \"*CustomClass\" + Environment.NewLine +\n \"{\" + Environment.NewLine +\n \" IntProperty = 0\" + Environment.NewLine +\n \"}*\");\n }\n\n private class CustomClass\n {\n public int IntProperty { get; set; }\n\n public string StringProperty { get; set; }\n }\n\n private class CustomClassValueFormatter : DefaultValueFormatter\n {\n public override bool CanHandle(object value) => value is CustomClass;\n\n protected override MemberInfo[] GetMembers(Type type)\n {\n return base\n .GetMembers(type)\n .Where(e => e.GetUnderlyingType() != typeof(string))\n .ToArray();\n }\n\n protected override string TypeDisplayName(Type type) => type.Name;\n }\n\n [Fact]\n public void When_defining_a_custom_enumerable_value_formatter_it_should_respect_the_overrides()\n {\n // Arrange\n var values = new CustomClass[]\n {\n new() { IntProperty = 1 },\n new() { IntProperty = 2 }\n };\n\n var formatter = new SingleItemValueFormatter();\n using var _ = new FormatterScope(formatter);\n\n // Act\n string str = Formatter.ToString(values);\n\n str.Should().Match(Environment.NewLine +\n \"{*AwesomeAssertions*FormatterSpecs+CustomClass\" + Environment.NewLine +\n \" {\" + Environment.NewLine +\n \" IntProperty = 1,\" + Environment.NewLine +\n \" StringProperty = \" + Environment.NewLine +\n \" },*…1 more…*}*\");\n }\n\n private class SingleItemValueFormatter : EnumerableValueFormatter\n {\n protected override int MaxItems => 1;\n\n public override bool CanHandle(object value) => value is IEnumerable;\n }\n\n private sealed class FormatterScope : IDisposable\n {\n private readonly IValueFormatter formatter;\n\n public FormatterScope(IValueFormatter formatter)\n {\n this.formatter = formatter;\n Formatter.AddFormatter(formatter);\n }\n\n public void Dispose() => Formatter.RemoveFormatter(formatter);\n }\n\n public void Dispose() => AssertionEngine.ResetToDefaults();\n}\n\ninternal class ExceptionThrowingClass\n{\n public string ThrowingProperty => throw new InvalidOperationException(\"CustomMessage\");\n}\n\ninternal class NullThrowingToStringImplementation\n{\n public NullThrowingToStringImplementation()\n {\n SomeProperty = \"SomeProperty\";\n }\n\n public string SomeProperty { get; set; }\n\n public override string ToString()\n {\n return null;\n }\n}\n\ninternal class Node\n{\n public Node()\n {\n Children = [];\n }\n\n public static Node Default { get; } = new();\n\n public List Children { get; set; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/DelegateAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that a synchronous method yields the expected result.\n/// \n[DebuggerNonUserCode]\npublic abstract class DelegateAssertions : DelegateAssertionsBase\n where TDelegate : Delegate\n where TAssertions : DelegateAssertions\n{\n private readonly AssertionChain assertionChain;\n\n protected DelegateAssertions(TDelegate @delegate, IExtractExceptions extractor, AssertionChain assertionChain)\n : base(@delegate, extractor, assertionChain, new Clock())\n {\n this.assertionChain = assertionChain;\n }\n\n private protected DelegateAssertions(TDelegate @delegate, IExtractExceptions extractor, AssertionChain assertionChain, IClock clock)\n : base(@delegate, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current throws an exception of type .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public ExceptionAssertions Throw([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw {0}{reason}, but found .\", typeof(TException));\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n Exception exception = InvokeSubjectWithInterception();\n return ThrowInternal(exception, because, becauseArgs);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n /// \n /// Asserts that the current does not throw an exception of type .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotThrow([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw {0}{reason}, but found .\", typeof(TException));\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n Exception exception = InvokeSubjectWithInterception();\n return NotThrowInternal(exception, because, becauseArgs);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current throws an exception of the exact type (and not a derived exception type).\n /// \n /// \n /// The type of the exception it should throw.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Returns an object that allows asserting additional members of the thrown exception.\n /// \n public ExceptionAssertions ThrowExactly([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw exactly {0}{reason}, but found .\", typeof(TException));\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n Exception exception = InvokeSubjectWithInterception();\n\n Type expectedType = typeof(TException);\n\n assertionChain\n .ForCondition(exception is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0}{reason}, but no exception was thrown.\", expectedType);\n\n if (assertionChain.Succeeded)\n {\n exception.Should().BeOfType(expectedType, because, becauseArgs);\n }\n\n return new ExceptionAssertions([exception as TException], assertionChain);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n protected abstract void InvokeSubject();\n\n private protected Exception InvokeSubjectWithInterception()\n {\n Exception actualException = null;\n\n try\n {\n // For the duration of this nested invocation, configure CallerIdentifier\n // to match the contents of the subject rather than our own call site.\n //\n // Action action = () => subject.Should().BeSomething();\n // action.Should().Throw();\n //\n // If an assertion failure occurs, we want the message to talk about \"subject\"\n // not \"action\".\n using (CallerIdentifier.OnlyOneAssertionScopeOnCallStack()\n ? CallerIdentifier.OverrideStackSearchUsingCurrentScope()\n : default)\n {\n InvokeSubject();\n }\n }\n catch (Exception exc)\n {\n actualException = exc;\n }\n\n return actualException;\n }\n\n private protected void FailIfSubjectIsAsyncVoid()\n {\n if (Subject.GetMethodInfo().IsDecoratedWithOrInherit())\n {\n throw new InvalidOperationException(\n \"Cannot use action assertions on an async void method. Assign the async method to a variable of type Func instead of Action so that it can be awaited.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/TypeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a meets certain expectations.\n/// \n[DebuggerNonUserCode]\npublic class TypeAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public TypeAssertions(Type type, AssertionChain assertionChain)\n : base(type, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current is equal to the specified type.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return Be(typeof(TExpected), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is equal to the specified type.\n /// \n /// The expected type\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(Type expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject == expected)\n .FailWith(() => GetFailReasonIfTypesAreDifferent(Subject, expected));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts than an instance of the subject type is assignable variable of type .\n /// \n /// The type to which instances of the type should be assignable.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public new AndConstraint BeAssignableTo([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return BeAssignableTo(typeof(T), because, becauseArgs);\n }\n\n /// \n /// Asserts than an instance of the subject type is assignable variable of given .\n /// \n /// The type to which instances of the type should be assignable.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public new AndConstraint BeAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n bool isAssignable = type.IsGenericTypeDefinition\n ? Subject.IsAssignableToOpenGeneric(type)\n : type.IsAssignableFrom(Subject);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(isAssignable)\n .FailWith(\"Expected {context:type} {0} to be assignable to {1}{reason}, but it is not.\",\n Subject, type);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts than an instance of the subject type is not assignable variable of type .\n /// \n /// The type to which instances of the type should not be assignable.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public new AndConstraint NotBeAssignableTo([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeAssignableTo(typeof(T), because, becauseArgs);\n }\n\n /// \n /// Asserts than an instance of the subject type is not assignable variable of given .\n /// \n /// The type to which instances of the type should not be assignable.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public new AndConstraint NotBeAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n bool isAssignable = type.IsGenericTypeDefinition\n ? Subject.IsAssignableToOpenGeneric(type)\n : type.IsAssignableFrom(Subject);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!isAssignable)\n .FailWith(\"Expected {context:type} {0} to not be assignable to {1}{reason}, but it is.\",\n Subject, type);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Creates an error message in case the specified type differs from the\n /// type.\n /// \n /// \n /// A that describes that the two specified types are not the same.\n /// \n private static FailReason GetFailReasonIfTypesAreDifferent(Type actual, Type expected)\n {\n string expectedType = expected.ToFormattedString();\n string actualType = actual.ToFormattedString();\n\n if (expectedType == actualType)\n {\n expectedType = $\"[{expected.AssemblyQualifiedName}]\";\n actualType = $\"[{actual.AssemblyQualifiedName}]\";\n }\n\n return new FailReason($\"Expected type to be {expectedType}{{reason}}, but found {actualType}.\");\n }\n\n /// \n /// Asserts that the current type is not equal to the specified type.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBe(typeof(TUnexpected), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current type is not equal to the specified type.\n /// \n /// The unexpected type\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(Type unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject != unexpected)\n .FailWith(() => GetFailReasonIfTypesAreEqual(Subject, unexpected));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Creates an error message in case the specified type equals the\n /// type.\n /// \n /// \n /// A that describes that the two specified types are the same.\n /// \n private static FailReason GetFailReasonIfTypesAreEqual(Type actual, Type unexpected)\n {\n string unexpectedType = unexpected.AsFormattableTypeDefinition().ToFormattedString();\n string actualType = actual.AsFormattableTypeDefinition().ToFormattedString();\n\n if (unexpected is not null && unexpectedType == actualType)\n {\n unexpectedType = $\"[{unexpected.AssemblyQualifiedName}]\";\n }\n\n return new FailReason($\"Expected type not to be {unexpectedType}{{reason}}, but it is.\");\n }\n\n /// \n /// Asserts that the current is decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint BeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n IEnumerable attributes = Subject.GetMatchingAttributes();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(attributes.Any())\n .FailWith(\"Expected type {0} to be decorated with {1}{reason}, but the attribute was not found.\",\n Subject, typeof(TAttribute));\n\n return new AndWhichConstraint(this, attributes);\n }\n\n /// \n /// Asserts that the current is decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint BeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n BeDecoratedWith(because, becauseArgs);\n\n IEnumerable attributes = Subject.GetMatchingAttributes(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(attributes.Any())\n .FailWith(\n \"Expected type {0} to be decorated with {1} that matches {2}{reason}, but no matching attribute was found.\",\n Subject, typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndWhichConstraint(this, attributes);\n }\n\n /// \n /// Asserts that the current is decorated with, or inherits from a parent class, the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint BeDecoratedWithOrInherit(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n IEnumerable attributes = Subject.GetMatchingOrInheritedAttributes();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(attributes.Any())\n .FailWith(\"Expected type {0} to be decorated with or inherit {1}{reason}, but the attribute was not found.\",\n Subject, typeof(TAttribute));\n\n return new AndWhichConstraint(this, attributes);\n }\n\n /// \n /// Asserts that the current is decorated with, or inherits from a parent class, an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint BeDecoratedWithOrInherit(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n BeDecoratedWithOrInherit(because, becauseArgs);\n\n IEnumerable attributes = Subject.GetMatchingOrInheritedAttributes(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(attributes.Any())\n .FailWith(\n \"Expected type {0} to be decorated with or inherit {1} that matches {2}{reason}\" +\n \", but no matching attribute was found.\", Subject, typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndWhichConstraint(this, attributes);\n }\n\n /// \n /// Asserts that the current is not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TAttribute : Attribute\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsDecoratedWith())\n .FailWith(\"Expected type {0} to not be decorated with {1}{reason}, but the attribute was found.\",\n Subject, typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with an attribute of type\n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsDecoratedWith(isMatchingAttributePredicate))\n .FailWith(\n \"Expected type {0} to not be decorated with {1} that matches {2}{reason}, but a matching attribute was found.\",\n Subject, typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with and does not inherit from a parent class,\n /// the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWithOrInherit(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsDecoratedWithOrInherit())\n .FailWith(\"Expected type {0} to not be decorated with or inherit {1}{reason}, but the attribute was found.\",\n Subject, typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with and does not inherit from a parent class, an\n /// attribute of type that matches the specified\n /// .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWithOrInherit(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsDecoratedWithOrInherit(isMatchingAttributePredicate))\n .FailWith(\n \"Expected type {0} to not be decorated with or inherit {1} that matches {2}{reason}\" +\n \", but a matching attribute was found.\",\n Subject, typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current implements .\n /// \n /// The interface that should be implemented.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Implement(Type interfaceType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n\n AssertSubjectImplements(interfaceType, because, becauseArgs);\n\n return new AndConstraint(this);\n }\n\n private bool AssertSubjectImplements(Type interfaceType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n bool containsInterface = interfaceType.IsAssignableFrom(Subject) && interfaceType != Subject;\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type {0} to implement interface {1}{reason}\", Subject, interfaceType, chain => chain\n .ForCondition(interfaceType.IsInterface)\n .FailWith(\", but {0} is not an interface.\", interfaceType)\n .Then\n .ForCondition(containsInterface)\n .FailWith(\", but it does not.\"));\n\n return assertionChain.Succeeded;\n }\n\n /// \n /// Asserts that the current implements interface .\n /// \n /// The interface that should be implemented.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Implement([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TInterface : class\n {\n return Implement(typeof(TInterface), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not implement .\n /// \n /// The interface that should be not implemented.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotImplement(Type interfaceType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n\n bool containsInterface = interfaceType.IsAssignableFrom(Subject) && interfaceType != Subject;\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type {0} to not implement interface {1}{reason}\", Subject, interfaceType, chain => chain\n .ForCondition(interfaceType.IsInterface)\n .FailWith(\", but {0} is not an interface.\", interfaceType)\n .Then\n .ForCondition(!containsInterface)\n .FailWith(\", but it does.\", interfaceType));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not implement interface .\n /// \n /// The interface that should not be implemented.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotImplement([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TInterface : class\n {\n return NotImplement(typeof(TInterface), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is derived from .\n /// \n /// The type that should be derived from.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeDerivedFrom(Type baseType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(baseType);\n\n bool isDerivedFrom = baseType.IsGenericTypeDefinition\n ? Subject.IsDerivedFromOpenGeneric(baseType)\n : Subject.IsSubclassOf(baseType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type {0} to be derived from {1}{reason}\", Subject, baseType, chain => chain\n .ForCondition(!baseType.IsInterface)\n .FailWith(\", but {0} is an interface.\", baseType)\n .Then\n .ForCondition(isDerivedFrom)\n .FailWith(\", but it is not.\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is derived from .\n /// \n /// The type that should be derived from.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDerivedFrom([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TBaseClass : class\n {\n return BeDerivedFrom(typeof(TBaseClass), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is not derived from .\n /// \n /// The type that should not be derived from.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDerivedFrom(Type baseType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(baseType);\n\n bool isDerivedFrom = baseType.IsGenericTypeDefinition\n ? Subject.IsDerivedFromOpenGeneric(baseType)\n : Subject.IsSubclassOf(baseType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type {0} not to be derived from {1}{reason}\", Subject, baseType, chain => chain\n .ForCondition(!baseType.IsInterface)\n .FailWith(\", but {0} is an interface.\", baseType)\n .Then\n .ForCondition(!isDerivedFrom)\n .FailWith(\", but it is.\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not derived from .\n /// \n /// The type that should not be derived from.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDerivedFrom([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TBaseClass : class\n {\n return NotBeDerivedFrom(typeof(TBaseClass), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is sealed.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint BeSealed([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be sealed{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.IsCSharpSealed())\n .FailWith(\"Expected type {0} to be sealed{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not sealed.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint NotBeSealed([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type not to be sealed{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsCSharpSealed())\n .FailWith(\"Expected type {0} not to be sealed{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is abstract.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint BeAbstract([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be abstract{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.IsCSharpAbstract())\n .FailWith(\"Expected {context:type} {0} to be abstract{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not abstract.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint NotBeAbstract([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type not to be abstract{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsCSharpAbstract())\n .FailWith(\"Expected type {0} not to be abstract{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is static.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint BeStatic([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be static{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.IsCSharpStatic())\n .FailWith(\"Expected type {0} to be static{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not static.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint NotBeStatic([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type not to be static{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsCSharpStatic())\n .FailWith(\"Expected type {0} not to be static{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a property named .\n /// \n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint HaveProperty(\n string name, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Cannot determine if a type has a property named {name} if the type is .\");\n\n PropertyInfo propertyInfo = null;\n\n if (assertionChain.Succeeded)\n {\n propertyInfo = Subject.FindPropertyByName(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is not null)\n .FailWith(() =>\n {\n string subjectDescription = assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : Subject.ToFormattedString();\n\n return new FailReason($\"Expected {subjectDescription} to have a property {name}{{reason}}, but it does not.\");\n });\n }\n\n return new AndWhichConstraint(this, propertyInfo);\n }\n\n /// \n /// Asserts that the current has a property of type named\n /// .\n /// \n /// The type of the property.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n public AndWhichConstraint HaveProperty(\n Type propertyType, string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(propertyType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Cannot determine if a type has a property named {name} if the type is .\");\n\n PropertyInfo propertyInfo = null;\n\n if (assertionChain.Succeeded)\n {\n propertyInfo = Subject.FindPropertyByName(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is not null)\n .FailWith(() =>\n {\n string subjectDescription = assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : Subject.ToFormattedString();\n\n return new FailReason(\n $\"Expected {subjectDescription} to have a property {name} of type {{0}}{{reason}}, but it does not.\",\n propertyType);\n })\n .Then\n .ForCondition(propertyInfo.PropertyType == propertyType)\n .FailWith($\"Expected property {propertyInfo.Name} to be of type {{0}}{{reason}}, but it is not.\",\n propertyType);\n }\n\n return new AndWhichConstraint(this, propertyInfo);\n }\n\n /// \n /// Asserts that the current has a property of type named\n /// .\n /// \n /// The type of the property.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint HaveProperty(\n string name, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveProperty(typeof(TProperty), name, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not have a property named .\n /// \n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotHaveProperty(string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Cannot determine if a type has an unexpected property named {name} if the type is .\");\n\n if (assertionChain.Succeeded)\n {\n PropertyInfo propertyInfo = Subject.FindPropertyByName(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is null)\n .FailWith(() =>\n {\n string subjectDescription = assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : Subject.ToFormattedString();\n\n return new FailReason(\n $\"Did not expect {subjectDescription} to have a property {propertyInfo?.Name}{{reason}}, but it does.\");\n });\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current explicitly implements a property named\n /// from interface .\n /// \n /// The type of the interface.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n public AndConstraint HaveExplicitProperty(\n Type interfaceType, string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {{context:type}} to explicitly implement {{0}}.{name}{{reason}}\" +\n \", but {context:type} is .\", interfaceType);\n\n if (assertionChain.Succeeded && AssertSubjectImplements(interfaceType, because, becauseArgs))\n {\n var explicitlyImplementsProperty = Subject.HasExplicitlyImplementedProperty(interfaceType, name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(explicitlyImplementsProperty)\n .FailWith(\n $\"Expected {{0}} to explicitly implement {{1}}.{name}{{reason}}, but it does not.\",\n Subject, interfaceType);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current explicitly implements a property named\n /// from interface .\n /// \n /// The interface whose member is being explicitly implemented.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint HaveExplicitProperty(\n string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TInterface : class\n {\n return HaveExplicitProperty(typeof(TInterface), name, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not explicitly implement a property named\n /// from interface .\n /// \n /// The type of the interface.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n public AndConstraint NotHaveExplicitProperty(\n Type interfaceType, string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {{context:type}} to not explicitly implement {{0}}.{name}{{reason}}\" +\n \", but {context:type} is .\", interfaceType);\n\n if (assertionChain.Succeeded && AssertSubjectImplements(interfaceType, because, becauseArgs))\n {\n var explicitlyImplementsProperty = Subject.HasExplicitlyImplementedProperty(interfaceType, name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!explicitlyImplementsProperty)\n .FailWith(\n $\"Expected {{0}} to not explicitly implement {{1}}.{name}{{reason}}\" +\n \", but it does.\", Subject, interfaceType);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not explicitly implement a property named\n /// from interface .\n /// \n /// The interface whose member is not being explicitly implemented.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotHaveExplicitProperty(\n string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TInterface : class\n {\n return NotHaveExplicitProperty(typeof(TInterface), name, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current explicitly implements a method named \n /// from interface .\n /// \n /// The type of the interface.\n /// The name of the method.\n /// The expected types of the method parameters.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n /// is .\n public AndConstraint HaveExplicitMethod(\n Type interfaceType, string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected {{context:type}} to explicitly implement {{0}}.{name}\" +\n $\"({GetParameterString(parameterTypes)}){{reason}}, but {{context:type}} is .\",\n interfaceType));\n\n if (assertionChain.Succeeded && AssertSubjectImplements(interfaceType, because, becauseArgs))\n {\n var explicitlyImplementsMethod = Subject.HasMethod($\"{interfaceType}.{name}\", parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(explicitlyImplementsMethod)\n .FailWith(() => new FailReason(\n $\"Expected {{0}} to explicitly implement {{1}}.{name}\" +\n $\"({GetParameterString(parameterTypes)}){{reason}}, but it does not.\",\n Subject, interfaceType));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current explicitly implements a method named \n /// from interface .\n /// \n /// The interface whose member is being explicitly implemented.\n /// The name of the method.\n /// The expected types of the method parameters.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n /// is .\n public AndConstraint HaveExplicitMethod(\n string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TInterface : class\n {\n return HaveExplicitMethod(typeof(TInterface), name, parameterTypes, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not explicitly implement a method named \n /// from interface .\n /// \n /// The type of the interface.\n /// The name of the method.\n /// The expected types of the method parameters.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n /// is .\n public AndConstraint NotHaveExplicitMethod(\n Type interfaceType, string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected {{context:type}} to not explicitly implement {{0}}.{name}\" +\n $\"({GetParameterString(parameterTypes)}){{reason}}, but {{context:type}} is .\",\n interfaceType));\n\n if (assertionChain.Succeeded && AssertSubjectImplements(interfaceType, because, becauseArgs))\n {\n var explicitlyImplementsMethod = Subject.HasMethod($\"{interfaceType}.{name}\", parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!explicitlyImplementsMethod)\n .FailWith(() => new FailReason(\n $\"Expected {{0}} to not explicitly implement {{1}}.{name}\" +\n $\"({GetParameterString(parameterTypes)}){{reason}}, but it does.\",\n Subject, interfaceType));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not explicitly implement a method named \n /// from interface .\n /// \n /// The interface whose member is not being explicitly implemented.\n /// The name of the method.\n /// The expected types of the method parameters.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n /// is .\n public AndConstraint NotHaveExplicitMethod(\n string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TInterface : class\n {\n return NotHaveExplicitMethod(typeof(TInterface), name, parameterTypes, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an indexer of type .\n /// with parameter types .\n /// \n /// The type of the indexer.\n /// The parameter types for the indexer.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndWhichConstraint HaveIndexer(\n Type indexerType, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(indexerType);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n string parameterString = GetParameterString(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {{0}} {{context:type}}[{parameterString}] to exist{{reason}}\" +\n \", but {context:type} is .\", indexerType.AsFormattableShortType());\n\n PropertyInfo propertyInfo = null;\n\n if (assertionChain.Succeeded)\n {\n propertyInfo = Subject.GetIndexerByParameterTypes(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is not null)\n .FailWith(\n $\"Expected {{0}} {{1}}[{parameterString}] to exist{{reason}}\" +\n \", but it does not.\", indexerType.AsFormattableShortType(), Subject)\n .Then\n .ForCondition(propertyInfo.PropertyType == indexerType)\n .FailWith(\"Expected {0} to be of type {1}{reason}, but it is not.\",\n propertyInfo, indexerType);\n }\n\n return new AndWhichConstraint(this, propertyInfo, assertionChain,\n $\"[{parameterString}]\");\n }\n\n /// \n /// Asserts that the current does not have an indexer that takes parameter types\n /// .\n /// \n /// The expected indexer's parameter types.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotHaveIndexer(\n IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected indexer {{context:type}}[{GetParameterString(parameterTypes)}] to not exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n if (assertionChain.Succeeded)\n {\n PropertyInfo propertyInfo = Subject.GetIndexerByParameterTypes(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is null)\n .FailWith(() => new FailReason(\n $\"Expected indexer {{0}}[{GetParameterString(parameterTypes)}] to not exist{{reason}}\" +\n \", but it does.\", Subject));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a method named with parameter types\n /// .\n /// \n /// The name of the method.\n /// The parameter types for the indexer.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n /// is .\n public AndWhichConstraint HaveMethod(\n string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected method {{context:type}}.{name}({GetParameterString(parameterTypes)}) to exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n MethodInfo methodInfo = null;\n\n if (assertionChain.Succeeded)\n {\n methodInfo = Subject.GetMethod(name, parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is not null)\n .FailWith(() =>\n {\n string methodDescription;\n if (methodInfo is null)\n {\n methodDescription = $\"{Subject.AsFormattableTypeDefinition().ToFormattedString()}.{name}\";\n }\n else\n {\n methodDescription = MethodInfoAssertions.GetDescriptionFor(methodInfo);\n }\n\n return new FailReason(\n $\"Expected method {methodDescription}({GetParameterString(parameterTypes)}) to exist{{reason}}\" +\n \", but it does not.\");\n });\n }\n\n return new AndWhichConstraint(this, methodInfo);\n }\n\n /// \n /// Asserts that the current does not expose a method named \n /// with parameter types .\n /// \n /// The name of the method.\n /// The method parameter types.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n /// is .\n public AndConstraint NotHaveMethod(\n string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected method {{context:type}}.{name}({GetParameterString(parameterTypes)}) to not exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n if (assertionChain.Succeeded)\n {\n MethodInfo methodInfo = Subject.GetMethod(name, parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is null)\n .FailWith(() =>\n {\n string methodDescription = MethodInfoAssertions.GetDescriptionFor(methodInfo);\n return new FailReason(\n $\"Expected method {methodDescription}({GetParameterString(parameterTypes)}) to not exist{{reason}}\" +\n \", but it does.\");\n });\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a constructor with .\n /// \n /// The parameter types for the indexer.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveConstructor(\n IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected constructor {{context:type}}({GetParameterString(parameterTypes)}) to exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n ConstructorInfo constructorInfo = null;\n\n if (assertionChain.Succeeded)\n {\n constructorInfo = Subject.GetConstructor(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(constructorInfo is not null)\n .FailWith(() => new FailReason(\n $\"Expected constructor {{0}}({GetParameterString(parameterTypes)}) to exist{{reason}}\" +\n \", but it does not.\", Subject));\n }\n\n return new AndWhichConstraint(this, constructorInfo);\n }\n\n /// \n /// Asserts that the current has a default constructor.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveDefaultConstructor(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveConstructor([], because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not have a constructor with .\n /// \n /// The parameter types for the indexer.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint NotHaveConstructor(\n IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected constructor {{context:type}}({GetParameterString(parameterTypes)}) not to exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n ConstructorInfo constructorInfo = null;\n\n if (assertionChain.Succeeded)\n {\n constructorInfo = Subject.GetConstructor(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(constructorInfo is null)\n .FailWith(() => new FailReason(\n $\"Expected constructor {{0}}({GetParameterString(parameterTypes)}) not to exist{{reason}}\" +\n \", but it does.\", Subject));\n }\n\n return new AndWhichConstraint(this, constructorInfo);\n }\n\n /// \n /// Asserts that the current does not have a default constructor.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint NotHaveDefaultConstructor(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveConstructor([], because, becauseArgs);\n }\n\n private static string GetParameterString(IEnumerable parameterTypes)\n {\n return string.Join(\", \", parameterTypes.Select(parameterType => parameterType.ToFormattedString()));\n }\n\n /// \n /// Asserts that the current has the specified C# .\n /// \n /// The expected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint HaveAccessModifier(\n CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:type}} to be {accessModifier}{{reason}}, but {{context:type}} is .\");\n\n if (assertionChain.Succeeded)\n {\n CSharpAccessModifier subjectAccessModifier = Subject.GetCSharpAccessModifier();\n\n assertionChain.ForCondition(accessModifier == subjectAccessModifier)\n .BecauseOf(because, becauseArgs)\n .ForCondition(accessModifier == subjectAccessModifier)\n .FailWith(\n $\"Expected {{context:type}} {{0}} to be {accessModifier}{{reason}}\" +\n $\", but it is {subjectAccessModifier}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not have the specified C# .\n /// \n /// The unexpected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint NotHaveAccessModifier(\n CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:type}} not to be {accessModifier}{{reason}}, but {{context:type}} is .\");\n\n if (assertionChain.Succeeded)\n {\n CSharpAccessModifier subjectAccessModifier = Subject.GetCSharpAccessModifier();\n\n assertionChain\n .ForCondition(accessModifier != subjectAccessModifier)\n .BecauseOf(because, becauseArgs)\n .ForCondition(accessModifier != subjectAccessModifier)\n .FailWith($\"Expected {{context:type}} {{0}} not to be {accessModifier}{{reason}}, but it is.\",\n Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an implicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveImplicitConversionOperator(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveImplicitConversionOperator(typeof(TSource), typeof(TTarget), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an implicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndWhichConstraint HaveImplicitConversionOperator(\n Type sourceType, Type targetType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(sourceType);\n Guard.ThrowIfArgumentIsNull(targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected public static implicit {0}({1}) to exist{reason}, but {context:type} is .\",\n targetType, sourceType);\n\n MethodInfo methodInfo = null;\n\n if (assertionChain.Succeeded)\n {\n methodInfo = Subject.GetImplicitConversionOperator(sourceType, targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is not null)\n .FailWith(\"Expected public static implicit {0}({1}) to exist{reason}, but it does not.\",\n targetType, sourceType);\n }\n\n return new AndWhichConstraint(this, methodInfo, assertionChain);\n }\n\n /// \n /// Asserts that the current does not have an implicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveImplicitConversionOperator(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveImplicitConversionOperator(typeof(TSource), typeof(TTarget), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not have an implicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndConstraint NotHaveImplicitConversionOperator(\n Type sourceType, Type targetType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(sourceType);\n Guard.ThrowIfArgumentIsNull(targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected public static implicit {0}({1}) to not exist{reason}, but {context:type} is .\",\n targetType, sourceType);\n\n if (assertionChain.Succeeded)\n {\n MethodInfo methodInfo = Subject.GetImplicitConversionOperator(sourceType, targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is null)\n .FailWith(\"Expected public static implicit {0}({1}) to not exist{reason}, but it does.\",\n targetType, sourceType);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an explicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveExplicitConversionOperator(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveExplicitConversionOperator(typeof(TSource), typeof(TTarget), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an explicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndWhichConstraint HaveExplicitConversionOperator(\n Type sourceType, Type targetType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(sourceType);\n Guard.ThrowIfArgumentIsNull(targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected public static explicit {0}({1}) to exist{reason}, but {context:type} is .\",\n targetType, sourceType);\n\n MethodInfo methodInfo = null;\n\n if (assertionChain.Succeeded)\n {\n methodInfo = Subject.GetExplicitConversionOperator(sourceType, targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is not null)\n .FailWith(\"Expected public static explicit {0}({1}) to exist{reason}, but it does not.\",\n targetType, sourceType);\n }\n\n return new AndWhichConstraint(this, methodInfo);\n }\n\n /// \n /// Asserts that the current does not have an explicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveExplicitConversionOperator(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveExplicitConversionOperator(typeof(TSource), typeof(TTarget), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not have an explicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndConstraint NotHaveExplicitConversionOperator(\n Type sourceType, Type targetType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(sourceType);\n Guard.ThrowIfArgumentIsNull(targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected public static explicit {0}({1}) to not exist{reason}, but {context:type} is .\",\n targetType, sourceType);\n\n if (assertionChain.Succeeded)\n {\n MethodInfo methodInfo = Subject.GetExplicitConversionOperator(sourceType, targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is null)\n .FailWith(\"Expected public static explicit {0}({1}) to not exist{reason}, but it does.\",\n targetType, sourceType);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"type\";\n\n private void AssertThatSubjectIsClass()\n {\n if (Subject.IsInterface || Subject.IsValueType || typeof(Delegate).IsAssignableFrom(Subject.BaseType))\n {\n throw new InvalidOperationException($\"{Subject.ToFormattedString()} must be a class.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DictionaryValueFormatter.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DictionaryValueFormatter : IValueFormatter\n{\n /// \n /// The number of items to include when formatting this object.\n /// \n /// The default value is 32.\n protected virtual int MaxItems => 32;\n\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public virtual bool CanHandle(object value)\n {\n return value is IDictionary;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n int startCount = formattedGraph.LineCount;\n IEnumerable> collection = AsEnumerable((IDictionary)value);\n\n using var iterator = new Iterator>(collection, MaxItems);\n\n while (iterator.MoveNext())\n {\n if (iterator.IsFirst)\n {\n formattedGraph.AddFragment(\"{\");\n }\n\n if (!iterator.HasReachedMaxItems)\n {\n var index = iterator.Index.ToString(CultureInfo.InvariantCulture);\n formattedGraph.AddFragment(\"[\");\n formatChild(index + \".Key\", iterator.Current.Key, formattedGraph);\n formattedGraph.AddFragment(\"] = \");\n formatChild(index + \".Value\", iterator.Current.Value, formattedGraph);\n }\n else\n {\n using IDisposable _ = formattedGraph.WithIndentation();\n string moreItemsMessage = $\"…{collection.Count() - MaxItems} more…\";\n AddLineOrFragment(formattedGraph, startCount, moreItemsMessage);\n }\n\n if (iterator.IsLast)\n {\n AddLineOrFragment(formattedGraph, startCount, \"}\");\n }\n else\n {\n formattedGraph.AddFragment(\", \");\n }\n }\n\n if (iterator.IsEmpty)\n {\n formattedGraph.AddFragment(\"{empty}\");\n }\n }\n\n private static void AddLineOrFragment(FormattedObjectGraph formattedGraph, int startCount, string fragment)\n {\n if (formattedGraph.LineCount > (startCount + 1))\n {\n formattedGraph.AddLine(fragment);\n }\n else\n {\n formattedGraph.AddFragment(fragment);\n }\n }\n\n private static IEnumerable> AsEnumerable(IDictionary dictionary)\n {\n IDictionaryEnumerator iterator = dictionary.GetEnumerator();\n\n using (iterator as IDisposable)\n {\n while (iterator.MoveNext())\n {\n yield return new KeyValuePair(iterator.Key, iterator.Value);\n }\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/TestTypes.cs", "using System;\nusing System.Collections.Generic;\n\n// ReSharper disable NotAccessedField.Global\n// ReSharper disable NotAccessedField.Local\n// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global\n// ReSharper disable UnusedMember.Global\n// ReSharper disable AutoPropertyCanBeMadeGetOnly.Local\n#pragma warning disable SA1649\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic enum EnumULong : ulong\n{\n Int64Max = long.MaxValue,\n UInt64LessOne = ulong.MaxValue - 1,\n UInt64Max = ulong.MaxValue\n}\n\npublic enum EnumLong : long\n{\n Int64Max = long.MaxValue,\n Int64LessOne = long.MaxValue - 1\n}\n\n#region Test Classes\n\npublic class ClassOne\n{\n public ClassTwo RefOne { get; set; } = new();\n\n public int ValOne { get; set; } = 1;\n}\n\npublic class ClassTwo\n{\n public int ValTwo { get; set; } = 3;\n}\n\npublic class ClassWithWriteOnlyProperty : IHaveWriteOnlyProperty\n{\n private int writeOnlyPropertyValue;\n\n public int WriteOnlyProperty\n {\n set => writeOnlyPropertyValue = value;\n }\n\n public string SomeOtherProperty { get; set; }\n}\n\npublic interface IHaveWriteOnlyProperty\n{\n int WriteOnlyProperty { set; }\n}\n\ninternal enum EnumOne\n{\n One = 0,\n Two = 3\n}\n\ninternal enum EnumCharOne\n{\n A = 'A',\n B = 'B'\n}\n\ninternal enum EnumCharTwo\n{\n A = 'Z',\n ValueB = 'B'\n}\n\ninternal enum EnumTwo\n{\n One = 0,\n Two = 3\n}\n\ninternal enum EnumThree\n{\n ValueZero = 0,\n Two = 3\n}\n\ninternal enum EnumFour\n{\n Three = 3\n}\n\ninternal class ClassWithEnumCharOne\n{\n public EnumCharOne Enum { get; set; }\n}\n\ninternal class ClassWithEnumCharTwo\n{\n public EnumCharTwo Enum { get; set; }\n}\n\ninternal class ClassWithEnumOne\n{\n public EnumOne Enum { get; set; }\n}\n\ninternal class ClassWithEnumTwo\n{\n public EnumTwo Enum { get; set; }\n}\n\ninternal class ClassWithEnumThree\n{\n public EnumThree Enum { get; set; }\n}\n\ninternal class ClassWithEnumFour\n{\n public EnumFour Enum { get; set; }\n}\n\ninternal class ClassWithNoMembers;\n\ninternal class ClassWithOnlyAField\n{\n public int Value;\n}\n\ninternal class ClassWithAPrivateField : ClassWithOnlyAField\n{\n private readonly int value;\n\n public ClassWithAPrivateField(int value)\n {\n this.value = value;\n }\n}\n\ninternal class ClassWithOnlyAProperty\n{\n public int Value { get; set; }\n}\n\ninternal struct StructWithNoMembers;\n\ninternal class ClassWithSomeFieldsAndProperties\n{\n public string Field1;\n\n public string Field2;\n\n public string Field3;\n\n public string Property1 { get; set; }\n\n public string Property2 { get; set; }\n\n public string Property3 { get; set; }\n}\n\ninternal class ClassWithCctor\n{\n // ReSharper disable once EmptyConstructor\n static ClassWithCctor()\n {\n }\n}\n\ninternal class ClassWithCctorAndNonDefaultConstructor\n{\n // ReSharper disable once EmptyConstructor\n static ClassWithCctorAndNonDefaultConstructor() { }\n\n public ClassWithCctorAndNonDefaultConstructor(int _) { }\n}\n\ninternal class MyCompanyLogo\n{\n public string Url { get; set; }\n\n public MyCompany Company { get; set; }\n\n public MyUser CreatedBy { get; set; }\n}\n\ninternal class MyUser\n{\n public string Name { get; set; }\n\n public MyCompany Company { get; set; }\n}\n\ninternal class MyCompany\n{\n public string Name { get; set; }\n\n public MyCompanyLogo Logo { get; set; }\n\n public List Users { get; set; }\n}\n\npublic class Customer : Entity\n{\n private string PrivateProperty { get; set; }\n\n protected string ProtectedProperty { get; set; }\n\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n\n public long Id { get; set; }\n\n public void SetProtected(string value)\n {\n ProtectedProperty = value;\n }\n\n public Customer()\n {\n }\n\n public Customer(string privateProperty)\n {\n PrivateProperty = privateProperty;\n }\n}\n\npublic class Entity\n{\n internal long Version { get; set; }\n}\n\npublic class CustomerDto\n{\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n}\n\npublic class CustomerType\n{\n public CustomerType(string code)\n {\n Code = code;\n }\n\n public string Code { get; }\n\n public override bool Equals(object obj)\n {\n return obj is CustomerType other && Code == other.Code;\n }\n\n public override int GetHashCode()\n {\n return Code?.GetHashCode() ?? 0;\n }\n\n public static bool operator ==(CustomerType a, CustomerType b)\n {\n if (ReferenceEquals(a, b))\n {\n return true;\n }\n\n if (a is null || b is null)\n {\n return false;\n }\n\n return a.Code == b.Code;\n }\n\n public static bool operator !=(CustomerType a, CustomerType b)\n {\n return !(a == b);\n }\n}\n\npublic class DerivedCustomerType : CustomerType\n{\n public string DerivedInfo { get; set; }\n\n public DerivedCustomerType(string code)\n : base(code)\n {\n }\n}\n\npublic class CustomConvertible : IConvertible\n{\n private readonly string convertedStringValue;\n\n public CustomConvertible(string convertedStringValue)\n {\n this.convertedStringValue = convertedStringValue;\n }\n\n public TypeCode GetTypeCode()\n {\n throw new InvalidCastException();\n }\n\n public bool ToBoolean(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public char ToChar(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public sbyte ToSByte(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public byte ToByte(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public short ToInt16(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public ushort ToUInt16(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public int ToInt32(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public uint ToUInt32(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public long ToInt64(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public ulong ToUInt64(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public float ToSingle(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public double ToDouble(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public decimal ToDecimal(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public DateTime ToDateTime(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public string ToString(IFormatProvider provider)\n {\n return convertedStringValue;\n }\n\n public object ToType(Type conversionType, IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n}\n\npublic abstract class Base\n{\n public abstract string AbstractProperty { get; }\n\n public virtual string VirtualProperty => \"Foo\";\n\n public virtual string NonExcludedBaseProperty => \"Foo\";\n}\n\npublic class Derived : Base\n{\n public string DerivedProperty1 { get; set; }\n\n public string DerivedProperty2 { get; set; }\n\n public override string AbstractProperty => $\"{DerivedProperty1} {DerivedProperty2}\";\n\n public override string VirtualProperty => \"Bar\";\n\n public override string NonExcludedBaseProperty => \"Bar\";\n\n public virtual string NonExcludedDerivedProperty => \"Foo\";\n}\n\n#endregion\n\n#region Nested classes for comparison\n\npublic class ClassWithAllAccessModifiersForMembers\n{\n public string PublicField;\n protected string protectedField;\n internal string InternalField;\n protected internal string ProtectedInternalField;\n private readonly string privateField;\n private protected string privateProtectedField;\n\n public string PublicProperty { get; set; }\n\n public string ReadOnlyProperty { get; private set; }\n\n public string WriteOnlyProperty { private get; set; }\n\n protected string ProtectedProperty { get; set; }\n\n internal string InternalProperty { get; set; }\n\n protected internal string ProtectedInternalProperty { get; set; }\n\n private string PrivateProperty { get; set; }\n\n private protected string PrivateProtectedProperty { get; set; }\n\n public ClassWithAllAccessModifiersForMembers(string publicValue, string protectedValue, string internalValue,\n string protectedInternalValue, string privateValue, string privateProtectedValue)\n {\n PublicField = publicValue;\n protectedField = protectedValue;\n InternalField = internalValue;\n ProtectedInternalField = protectedInternalValue;\n privateField = privateValue;\n privateProtectedField = privateProtectedValue;\n\n PublicProperty = publicValue;\n ReadOnlyProperty = privateValue;\n WriteOnlyProperty = privateValue;\n ProtectedProperty = protectedValue;\n InternalProperty = internalValue;\n ProtectedInternalProperty = protectedInternalValue;\n PrivateProperty = privateValue;\n PrivateProtectedProperty = privateProtectedValue;\n }\n}\n\npublic class ClassWithValueSemanticsOnSingleProperty\n{\n public string Key { get; set; }\n\n public string NestedProperty { get; set; }\n\n protected bool Equals(ClassWithValueSemanticsOnSingleProperty other)\n {\n return Key == other.Key;\n }\n\n public override bool Equals(object obj)\n {\n if (obj is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n if (obj.GetType() != GetType())\n {\n return false;\n }\n\n return Equals((ClassWithValueSemanticsOnSingleProperty)obj);\n }\n\n public override int GetHashCode()\n {\n return Key.GetHashCode();\n }\n}\n\npublic class Root\n{\n public string Text { get; set; }\n\n public Level1 Level { get; set; }\n}\n\npublic class Level1\n{\n public string Text { get; set; }\n\n public Level2 Level { get; set; }\n}\n\npublic class Level2\n{\n public string Text { get; set; }\n}\n\npublic class RootDto\n{\n public string Text { get; set; }\n\n public Level1Dto Level { get; set; }\n}\n\npublic class Level1Dto\n{\n public string Text { get; set; }\n\n public Level2Dto Level { get; set; }\n}\n\npublic class Level2Dto\n{\n public string Text { get; set; }\n}\n\npublic class CyclicRoot\n{\n public string Text { get; set; }\n\n public CyclicLevel1 Level { get; set; }\n}\n\npublic class CyclicRootWithValueObject\n{\n public ValueObject Value { get; set; }\n\n public CyclicLevelWithValueObject Level { get; set; }\n}\n\npublic class ValueObject\n{\n public ValueObject(string value)\n {\n Value = value;\n }\n\n public string Value { get; }\n\n public override bool Equals(object obj)\n {\n return ((ValueObject)obj).Value == Value;\n }\n\n public override int GetHashCode()\n {\n return Value.GetHashCode();\n }\n}\n\npublic class CyclicLevel1\n{\n public string Text { get; set; }\n\n public CyclicRoot Root { get; set; }\n}\n\npublic class CyclicLevelWithValueObject\n{\n public ValueObject Value { get; set; }\n\n public CyclicRootWithValueObject Root { get; set; }\n}\n\npublic class CyclicRootDto\n{\n public string Text { get; set; }\n\n public CyclicLevel1Dto Level { get; set; }\n}\n\npublic class CyclicLevel1Dto\n{\n public string Text { get; set; }\n\n public CyclicRootDto Root { get; set; }\n}\n\n#endregion\n\n#region Interfaces for verifying inheritance of properties\n\npublic class Car : Vehicle, ICar\n{\n public int Wheels { get; set; }\n}\n\npublic class ExplicitCar : ExplicitVehicle, ICar\n{\n public int Wheels { get; set; }\n}\n\npublic class Vehicle : IVehicle\n{\n public int VehicleId { get; set; }\n}\n\npublic class VehicleWithField\n{\n public int VehicleId;\n}\n\npublic class ExplicitVehicle : IVehicle\n{\n int IVehicle.VehicleId { get; set; }\n\n public int VehicleId { get; set; }\n}\n\npublic interface IReadOnlyVehicle\n{\n int VehicleId { get; }\n}\n\npublic class ExplicitReadOnlyVehicle : IReadOnlyVehicle\n{\n private readonly int explicitValue;\n\n public ExplicitReadOnlyVehicle(int explicitValue)\n {\n this.explicitValue = explicitValue;\n }\n\n int IReadOnlyVehicle.VehicleId => explicitValue;\n\n public int VehicleId { get; set; }\n}\n\npublic interface ICar : IVehicle\n{\n int Wheels { get; set; }\n}\n\npublic interface IVehicle\n{\n int VehicleId { get; set; }\n}\n\npublic class SomeDto\n{\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n}\n\n#endregion\n\n#pragma warning restore SA1649\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XmlElementAssertions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Xml;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an \n/// is in the expected state./>\n/// \n[DebuggerNonUserCode]\npublic class XmlElementAssertions : XmlNodeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// \n public XmlElementAssertions(XmlElement xmlElement, AssertionChain assertionChain)\n : base(xmlElement, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current has the specified\n /// inner text.\n /// \n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveInnerText(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.InnerText == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have value {0}{reason}, but found {1}.\",\n expected, Subject.InnerText);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an attribute\n /// with the specified \n /// and .\n /// \n /// The name of the expected attribute\n /// The value of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveAttribute(string expectedName, string expectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveAttributeWithNamespace(expectedName, string.Empty, expectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an attribute\n /// with the specified , \n /// and .\n /// \n /// The name of the expected attribute\n /// The namespace of the expected attribute\n /// The value of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveAttributeWithNamespace(\n string expectedName,\n string expectedNamespace,\n string expectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n XmlAttribute attribute = Subject.Attributes[expectedName, expectedNamespace];\n\n string expectedFormattedName =\n (string.IsNullOrEmpty(expectedNamespace) ? string.Empty : $\"{{{expectedNamespace}}}\")\n + expectedName;\n\n assertionChain\n .ForCondition(attribute is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have attribute {0}\"\n + \" with value {1}{reason}, but found no such attribute in {2}\",\n expectedFormattedName, expectedValue, Subject);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(attribute!.Value == expectedValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected attribute {0} in {context:subject} to have value {1}{reason}, but found {2}.\",\n expectedFormattedName, expectedValue, attribute.Value);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a direct child element with the specified\n /// name, ignoring the namespace.\n /// \n /// The name of the expected child element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElement(\n string expectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveElementWithNamespace(expectedName, null, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has a direct child element with the specified\n /// name and namespace.\n /// \n /// The name of the expected child element\n /// The namespace of the expected child element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithNamespace(\n string expectedName,\n string expectedNamespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n XmlElement element = expectedNamespace == null ? Subject[expectedName] : Subject[expectedName, expectedNamespace];\n\n string expectedFormattedName =\n (string.IsNullOrEmpty(expectedNamespace) ? string.Empty : $\"{{{expectedNamespace}}}\")\n + expectedName;\n\n assertionChain\n .ForCondition(element is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have child element {0}{reason}, but no such child element was found.\",\n expectedFormattedName.EscapePlaceholders());\n\n return new AndWhichConstraint(this, element, assertionChain, \"/\" + expectedName);\n }\n\n protected override string Identifier => \"XML element\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/AggregateExceptionValueFormatter.cs", "using System;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class AggregateExceptionValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is AggregateException;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var exception = (AggregateException)value;\n\n if (exception.InnerExceptions.Count == 1)\n {\n formattedGraph.AddFragment(\"(aggregated) \");\n\n formatChild(\"inner\", exception.InnerException, formattedGraph);\n }\n else\n {\n formattedGraph.AddLine(Invariant($\"{exception.InnerExceptions.Count} (aggregated) exceptions:\"));\n\n foreach (Exception innerException in exception.InnerExceptions)\n {\n formattedGraph.AddLine(string.Empty);\n formatChild(\"InnerException\", innerException, formattedGraph);\n }\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Common/TypeExtensionsSpecs.cs", "using System;\nusing System.Collections.Immutable;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing JetBrains.Annotations;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Common;\n\npublic class TypeExtensionsSpecs\n{\n [Fact]\n public void When_comparing_types_and_types_are_same_it_should_return_true()\n {\n // Arrange\n var type1 = typeof(InheritedType);\n var type2 = typeof(InheritedType);\n\n // Act\n bool result = type1.IsSameOrInherits(type2);\n\n // Assert\n result.Should().BeTrue();\n }\n\n [Fact]\n public void When_comparing_types_and_first_type_inherits_second_it_should_return_true()\n {\n // Arrange\n var type1 = typeof(InheritingType);\n var type2 = typeof(InheritedType);\n\n // Act\n bool result = type1.IsSameOrInherits(type2);\n\n // Assert\n result.Should().BeTrue();\n }\n\n [Fact]\n public void When_comparing_types_and_second_type_inherits_first_it_should_return_false()\n {\n // Arrange\n var type1 = typeof(InheritedType);\n var type2 = typeof(InheritingType);\n\n // Act\n bool result = type1.IsSameOrInherits(type2);\n\n // Assert\n result.Should().BeFalse();\n }\n\n [Fact]\n public void When_comparing_types_and_types_are_different_it_should_return_false()\n {\n // Arrange\n var type1 = typeof(string);\n var type2 = typeof(InheritedType);\n\n // Act\n bool result = type1.IsSameOrInherits(type2);\n\n // Assert\n result.Should().BeFalse();\n }\n\n [Fact]\n public void When_getting_explicit_conversion_operator_from_a_type_with_fake_conversion_operators_it_should_not_return_any()\n {\n // Arrange\n var type1 = typeof(TypeWithFakeConversionOperators);\n var type2 = typeof(byte);\n\n // Act\n MethodInfo result = type1.GetExplicitConversionOperator(type1, type2);\n\n // Assert\n result.Should().BeNull();\n }\n\n [Fact]\n public void When_getting_implicit_conversion_operator_from_a_type_with_fake_conversion_operators_it_should_not_return_any()\n {\n // Arrange\n var type1 = typeof(TypeWithFakeConversionOperators);\n var type2 = typeof(int);\n\n // Act\n MethodInfo result = type1.GetImplicitConversionOperator(type1, type2);\n\n // Assert\n result.Should().BeNull();\n }\n\n [Fact]\n public void When_getting_fake_explicit_conversion_operator_from_a_type_with_fake_conversion_operators_it_should_return_one()\n {\n // Arrange\n var type = typeof(TypeWithFakeConversionOperators);\n string name = \"op_Explicit\";\n var bindingAttr = BindingFlags.Public | BindingFlags.Static;\n var returnType = typeof(byte);\n\n // Act\n MethodInfo result = GetFakeConversionOperator(type, name, bindingAttr, returnType);\n\n // Assert\n result.Should().NotBeNull();\n }\n\n [Fact]\n public void When_getting_fake_implicit_conversion_operator_from_a_type_with_fake_conversion_operators_it_should_return_one()\n {\n // Arrange\n var type = typeof(TypeWithFakeConversionOperators);\n string name = \"op_Implicit\";\n var bindingAttr = BindingFlags.Public | BindingFlags.Static;\n var returnType = typeof(int);\n\n // Act\n MethodInfo result = GetFakeConversionOperator(type, name, bindingAttr, returnType);\n\n // Assert\n result.Should().NotBeNull();\n }\n\n [Theory]\n [InlineData(typeof(MyRecord), true)]\n [InlineData(typeof(MyRecordStruct), true)]\n [InlineData(typeof(MyRecordStructWithCustomPrintMembers), true)]\n [InlineData(typeof(MyRecordStructWithOverriddenEquality), true)]\n [InlineData(typeof(MyReadonlyRecordStruct), true)]\n [InlineData(typeof(MyStruct), false)]\n [InlineData(typeof(MyStructWithFakeCompilerGeneratedEquality), false)]\n [InlineData(typeof(MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers), true)] // false positive!\n [InlineData(typeof(MyStructWithOverriddenEquality), false)]\n [InlineData(typeof(MyClass), false)]\n [InlineData(typeof(int), false)]\n [InlineData(typeof(string), false)]\n public void IsRecord_should_detect_records_correctly(Type type, bool expected)\n {\n type.IsRecord().Should().Be(expected);\n }\n\n [Fact]\n public void When_checking_if_anonymous_type_is_record_it_should_return_false()\n {\n new { Value = 42 }.GetType().IsRecord().Should().BeFalse();\n }\n\n [Fact]\n public void When_checking_if_value_tuple_is_record_it_should_return_false()\n {\n (42, \"the answer\").GetType().IsRecord().Should().BeFalse();\n }\n\n [Fact]\n public void When_checking_if_class_with_multiple_equality_methods_is_record_it_should_return_false()\n {\n typeof(ImmutableArray).IsRecord().Should().BeFalse();\n }\n\n private static MethodInfo GetFakeConversionOperator(Type type, string name, BindingFlags bindingAttr, Type returnType)\n {\n MethodInfo[] methods = type.GetMethods(bindingAttr);\n\n return methods.SingleOrDefault(m =>\n m.Name == name\n && m.ReturnType == returnType\n && m.GetParameters().Select(p => p.ParameterType).SequenceEqual([type])\n );\n }\n\n private class InheritedType;\n\n private class InheritingType : InheritedType;\n\n private readonly struct TypeWithFakeConversionOperators\n {\n private readonly int value;\n\n [UsedImplicitly]\n private TypeWithFakeConversionOperators(int value)\n {\n this.value = value;\n }\n\n#pragma warning disable IDE1006, SA1300 // These two functions mimic the compiler generated conversion operators\n [UsedImplicitly]\n public static int op_Implicit(TypeWithFakeConversionOperators typeWithFakeConversionOperators) =>\n typeWithFakeConversionOperators.value;\n\n [UsedImplicitly]\n public static byte op_Explicit(TypeWithFakeConversionOperators typeWithFakeConversionOperators) =>\n (byte)typeWithFakeConversionOperators.value;\n#pragma warning restore SA1300, IDE1006\n }\n\n [UsedImplicitly]\n private record MyRecord(int Value);\n\n [UsedImplicitly]\n private record struct MyRecordStruct(int Value);\n\n [UsedImplicitly]\n private record struct MyRecordStructWithCustomPrintMembers(int Value)\n {\n // ReSharper disable once RedundantNameQualifier\n private bool PrintMembers(System.Text.StringBuilder builder)\n {\n builder.Append(Value);\n return true;\n }\n }\n\n private record struct MyRecordStructWithOverriddenEquality(int Value)\n {\n public bool Equals(MyRecordStructWithOverriddenEquality other) => Value == other.Value;\n\n public override int GetHashCode() => Value;\n }\n\n [UsedImplicitly]\n private readonly record struct MyReadonlyRecordStruct(int Value);\n\n private struct MyStruct\n {\n [UsedImplicitly]\n public int Value { get; set; }\n }\n\n private struct MyStructWithFakeCompilerGeneratedEquality : IEquatable\n {\n [UsedImplicitly]\n public int Value { get; set; }\n\n public bool Equals(MyStructWithFakeCompilerGeneratedEquality other) => Value == other.Value;\n\n public override bool Equals(object obj) => obj is MyStructWithFakeCompilerGeneratedEquality other && Equals(other);\n\n public override int GetHashCode() => Value;\n\n [CompilerGenerated]\n public static bool operator ==(MyStructWithFakeCompilerGeneratedEquality left,\n MyStructWithFakeCompilerGeneratedEquality right) => left.Equals(right);\n\n public static bool operator !=(MyStructWithFakeCompilerGeneratedEquality left,\n MyStructWithFakeCompilerGeneratedEquality right) => !left.Equals(right);\n }\n\n // Note that this struct is mistakenly detected as a record struct by the current version of TypeExtensions.IsRecord.\n // This cannot be avoided at present, unless something is changed at language level,\n // or a smarter way to check for record structs is found.\n private struct MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers\n : IEquatable\n {\n [UsedImplicitly]\n public int Value { get; set; }\n\n public bool Equals(MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers other) => Value == other.Value;\n\n public override bool Equals(object obj) =>\n obj is MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers other && Equals(other);\n\n public override int GetHashCode() => Value;\n\n [CompilerGenerated]\n public static bool operator ==(MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers left,\n MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers right) => left.Equals(right);\n\n public static bool operator !=(MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers left,\n MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers right) => !left.Equals(right);\n\n [UsedImplicitly]\n private bool PrintMembers(StringBuilder builder)\n {\n builder.Append(Value);\n return true;\n }\n }\n\n private struct MyStructWithOverriddenEquality : IEquatable\n {\n [UsedImplicitly]\n public int Value { get; set; }\n\n public bool Equals(MyStructWithOverriddenEquality other) => Value == other.Value;\n\n public override bool Equals(object obj) => obj is MyStructWithOverriddenEquality other && Equals(other);\n\n public override int GetHashCode() => Value;\n\n public static bool operator ==(MyStructWithOverriddenEquality left, MyStructWithOverriddenEquality right) =>\n left.Equals(right);\n\n public static bool operator !=(MyStructWithOverriddenEquality left, MyStructWithOverriddenEquality right) =>\n !left.Equals(right);\n }\n\n private class MyClass\n {\n [UsedImplicitly]\n public int Value { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/PropertyInfoSelectorAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Types;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains assertions for the objects returned by the parent .\n/// \n[DebuggerNonUserCode]\npublic class PropertyInfoSelectorAssertions\n{\n /// \n /// Initializes a new instance of the class, for a number of objects.\n /// \n /// The properties to assert.\n /// is .\n public PropertyInfoSelectorAssertions(AssertionChain assertionChain, params PropertyInfo[] properties)\n {\n CurrentAssertionChain = assertionChain;\n Guard.ThrowIfArgumentIsNull(properties);\n\n SubjectProperties = properties;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public IEnumerable SubjectProperties { get; }\n\n /// \n /// Asserts that the selected properties are virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n PropertyInfo[] nonVirtualProperties = GetAllNonVirtualPropertiesFromSelection();\n\n CurrentAssertionChain\n .ForCondition(nonVirtualProperties.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties to be virtual{reason}, but the following properties are not virtual:\" +\n Environment.NewLine + GetDescriptionsFor(nonVirtualProperties));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected properties are not virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n PropertyInfo[] virtualProperties = GetAllVirtualPropertiesFromSelection();\n\n CurrentAssertionChain\n .ForCondition(virtualProperties.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties not to be virtual{reason}, but the following properties are virtual:\" +\n Environment.NewLine + GetDescriptionsFor(virtualProperties));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected properties have a setter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeWritable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n PropertyInfo[] readOnlyProperties = GetAllReadOnlyPropertiesFromSelection();\n\n CurrentAssertionChain\n .ForCondition(readOnlyProperties.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties to have a setter{reason}, but the following properties do not:\" +\n Environment.NewLine + GetDescriptionsFor(readOnlyProperties));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected properties do not have a setter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeWritable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n PropertyInfo[] writableProperties = GetAllWritablePropertiesFromSelection();\n\n CurrentAssertionChain\n .ForCondition(writableProperties.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected selected properties to not have a setter{reason}, but the following properties do:\" +\n Environment.NewLine + GetDescriptionsFor(writableProperties));\n\n return new AndConstraint(this);\n }\n\n private PropertyInfo[] GetAllReadOnlyPropertiesFromSelection()\n {\n return SubjectProperties.Where(property => !property.CanWrite).ToArray();\n }\n\n private PropertyInfo[] GetAllWritablePropertiesFromSelection()\n {\n return SubjectProperties.Where(property => property.CanWrite).ToArray();\n }\n\n private PropertyInfo[] GetAllNonVirtualPropertiesFromSelection()\n {\n return SubjectProperties.Where(property => !property.IsVirtual()).ToArray();\n }\n\n private PropertyInfo[] GetAllVirtualPropertiesFromSelection()\n {\n return SubjectProperties.Where(property => property.IsVirtual()).ToArray();\n }\n\n /// \n /// Asserts that the selected properties are decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n PropertyInfo[] propertiesWithoutAttribute = GetPropertiesWithout();\n\n CurrentAssertionChain\n .ForCondition(propertiesWithoutAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties to be decorated with {0}{reason}\" +\n \", but the following properties are not:\" + Environment.NewLine +\n GetDescriptionsFor(propertiesWithoutAttribute), typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected properties are not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n PropertyInfo[] propertiesWithAttribute = GetPropertiesWith();\n\n CurrentAssertionChain\n .ForCondition(propertiesWithAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties not to be decorated with {0}{reason}\" +\n \", but the following properties are:\" + Environment.NewLine +\n GetDescriptionsFor(propertiesWithAttribute), typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n private PropertyInfo[] GetPropertiesWithout()\n where TAttribute : Attribute\n {\n return SubjectProperties.Where(property => !property.IsDecoratedWith()).ToArray();\n }\n\n private PropertyInfo[] GetPropertiesWith()\n where TAttribute : Attribute\n {\n return SubjectProperties.Where(property => property.IsDecoratedWith()).ToArray();\n }\n\n private static string GetDescriptionsFor(IEnumerable properties)\n {\n IEnumerable descriptions = properties.Select(property => Formatter.ToString(property));\n\n return string.Join(Environment.NewLine, descriptions);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n#pragma warning disable CA1822 // Do not change signature of a public member\n protected string Context => \"property info\";\n#pragma warning restore CA1822\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ReferenceTypeAssertionsSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ReferenceTypeAssertionsSpecs\n{\n [Fact]\n public void When_the_same_objects_are_expected_to_be_the_same_it_should_not_fail()\n {\n // Arrange\n var subject = new ClassWithCustomEqualMethod(1);\n var referenceToSubject = subject;\n\n // Act / Assert\n subject.Should().BeSameAs(referenceToSubject);\n }\n\n [Fact]\n public void When_two_different_objects_are_expected_to_be_the_same_it_should_fail_with_a_clear_explanation()\n {\n // Arrange\n var subject = new\n {\n Name = \"John Doe\"\n };\n\n var otherObject = new\n {\n UserName = \"JohnDoe\"\n };\n\n // Act\n Action act = () => subject.Should().BeSameAs(otherObject, \"they are {0} {1}\", \"the\", \"same\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"\"\"\n Expected subject to refer to\n {\n UserName = \"JohnDoe\"\n } because they are the same, but found\n {\n Name = \"John Doe\"\n }.\n \"\"\");\n }\n\n [Fact]\n public void When_a_derived_class_has_longer_formatting_than_the_base_class()\n {\n var subject = new SimpleComplexBase[] { new Complex(\"goodbye\"), new Simple() };\n Action act = () => subject.Should().BeEmpty();\n act.Should().Throw()\n .WithMessage(\n \"\"\"\n Expected subject to be empty, but found at least one item\n {\n AwesomeAssertions.Specs.Primitives.Complex\n {\n Statement = \"goodbye\"\n }\n }.\n \"\"\");\n }\n\n [Fact]\n public void When_two_different_objects_are_expected_not_to_be_the_same_it_should_not_fail()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var notSameObject = new ClassWithCustomEqualMethod(1);\n\n // Act / Assert\n someObject.Should().NotBeSameAs(notSameObject);\n }\n\n [Fact]\n public void When_two_equal_object_are_expected_not_to_be_the_same_it_should_fail()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n ClassWithCustomEqualMethod sameObject = someObject;\n\n // Act\n Action act = () => someObject.Should().NotBeSameAs(sameObject, \"they are {0} {1}\", \"the\", \"same\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect someObject to refer to*ClassWithCustomEqualMethod(1) because they are the same.\");\n }\n\n [Fact]\n public void When_object_is_of_the_expected_type_it_should_not_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act / Assert\n aString.Should().BeOfType(typeof(string));\n }\n\n [Fact]\n public void When_object_is_of_the_expected_open_generic_type_it_should_not_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act / Assert\n aList.Should().BeOfType(typeof(List<>));\n }\n\n [Fact]\n public void When_object_is_not_of_the_expected_open_generic_type_it_should_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act\n Action action = () => aList.Should().BeOfType(typeof(Dictionary<,>));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type to be System.Collections.Generic.Dictionary, but found System.Collections.Generic.List.\");\n }\n\n [Fact]\n public void When_object_is_null_it_should_throw()\n {\n // Arrange\n string aString = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n aString.Should().BeOfType(typeof(string));\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected aString to be string, but found .\");\n }\n\n [Fact]\n public void When_object_is_not_of_the_expected_type_it_should_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act\n Action action = () => aString.Should().BeOfType(typeof(int));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type to be int, but found string.\");\n }\n\n [Fact]\n public void When_an_assertion_fails_on_BeOfType_succeeding_message_should_be_included()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var item = string.Empty;\n item.Should().BeOfType();\n item.Should().BeOfType();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to be int, but found string.*\" +\n \"Expected type to be long, but found string.\");\n }\n\n [Fact]\n public void When_object_is_of_the_unexpected_type_it_should_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act\n Action action = () => aString.Should().NotBeOfType(typeof(string));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type not to be [\" + typeof(string).AssemblyQualifiedName + \"], but it is.\");\n }\n\n [Fact]\n public void When_object_is_of_the_unexpected_generic_type_it_should_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act\n Action action = () => aString.Should().NotBeOfType();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type not to be [\" + typeof(string).AssemblyQualifiedName + \"], but it is.\");\n }\n\n [Fact]\n public void When_object_is_of_the_unexpected_open_generic_type_it_should_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act\n Action action = () => aList.Should().NotBeOfType(typeof(List<>));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type not to be [\" + typeof(List<>).AssemblyQualifiedName + \"], but it is.\");\n }\n\n [Fact]\n public void When_object_is_not_of_the_expected_type_it_should_not_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act / Assert\n aString.Should().NotBeOfType(typeof(int));\n }\n\n [Fact]\n public void When_object_is_not_of_the_unexpected_open_generic_type_it_should_not_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act / Assert\n aList.Should().NotBeOfType(typeof(Dictionary<,>));\n }\n\n [Fact]\n public void When_generic_object_is_not_of_the_unexpected_type_it_should_not_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act / Assert\n aList.Should().NotBeOfType();\n }\n\n [Fact]\n public void When_non_generic_object_is_not_of_the_unexpected_open_generic_type_it_should_not_throw()\n {\n // Arrange\n var aString = \"blah\";\n\n // Act / Assert\n aString.Should().NotBeOfType(typeof(Dictionary<,>));\n }\n\n [Fact]\n public void When_asserting_object_is_not_of_type_and_it_is_null_it_should_throw()\n {\n // Arrange\n string aString = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n aString.Should().NotBeOfType(typeof(string));\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected aString not to be string, but found .\");\n }\n\n [Fact]\n public void When_object_satisfies_predicate_it_should_not_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act / Assert\n someObject.Should().Match(o => o != null);\n }\n\n [Fact]\n public void When_typed_object_satisfies_predicate_it_should_not_throw()\n {\n // Arrange\n var someObject = new SomeDto\n {\n Name = \"Dennis Doomen\",\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20)\n };\n\n // Act / Assert\n someObject.Should().Match(o => o.Age > 0);\n }\n\n [Fact]\n public void When_object_does_not_match_the_predicate_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().Match(o => o == null, \"it is not initialized yet\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someObject to match (o == null) because it is not initialized yet*\");\n }\n\n [Fact]\n public void When_a_typed_object_does_not_match_the_predicate_it_should_throw()\n {\n // Arrange\n var someObject = new SomeDto\n {\n Name = \"Dennis Doomen\",\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20)\n };\n\n // Act\n Action act = () => someObject.Should().Match((SomeDto d) => d.Name.Length == 0, \"it is not initialized yet\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someObject to match (d.Name.Length == 0) because it is not initialized yet*\");\n }\n\n [Fact]\n public void When_object_is_matched_against_a_null_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().Match(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot match an object against a predicate.*\");\n }\n\n #region Structure Reporting\n\n [Fact]\n public void When_an_assertion_on_two_objects_fails_it_should_show_the_properties_of_the_class()\n {\n // Arrange\n var subject = new SomeDto\n {\n Age = 37,\n Birthdate = 20.September(1973),\n Name = \"Dennis\"\n };\n\n var other = new SomeDto\n {\n Age = 2,\n Birthdate = 22.February(2009),\n Name = \"Teddie\"\n };\n\n // Act\n Action act = () => subject.Should().Be(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be*AwesomeAssertions*SomeDto*{*Age = 2*Birthdate = <2009-02-22>*\" +\n \" Name = \\\"Teddie\\\"*}, but found*AwesomeAssertions*SomeDto*{*Age = 37*\" +\n \" Birthdate = <1973-09-20>*Name = \\\"Dennis\\\"*}.\");\n }\n\n [Fact]\n public void When_an_assertion_on_two_objects_fails_and_they_implement_tostring_it_should_show_their_string_representation()\n {\n // Arrange\n object subject = 3;\n object other = 4;\n\n // Act\n Action act = () => subject.Should().Be(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be 4, but found 3.\");\n }\n\n [Fact]\n public void When_an_assertion_on_two_unknown_objects_fails_it_should_report_the_type_name()\n {\n // Arrange\n var subject = new object();\n var other = new object();\n\n // Act\n Action act = () => subject.Should().Be(other);\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected subject to be System.Object (HashCode={other.GetHashCode()}), \" +\n $\"but found System.Object (HashCode={subject.GetHashCode()}).\");\n }\n\n #endregion\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n var subject = new ReferenceTypeAssertionsDummy(null);\n\n // Act\n Action action = () => subject.Equals(subject);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean BeSameAs() instead?\");\n }\n\n public class ReferenceTypeAssertionsDummy : ReferenceTypeAssertions\n {\n public ReferenceTypeAssertionsDummy(object subject)\n : base(subject, AssertionChain.GetOrCreate())\n {\n }\n\n protected override string Identifier => string.Empty;\n }\n }\n}\n\npublic class SomeDto\n{\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n}\n\ninternal class ClassWithCustomEqualMethod\n{\n public ClassWithCustomEqualMethod(int key)\n {\n Key = key;\n }\n\n private int Key { get; }\n\n private bool Equals(ClassWithCustomEqualMethod other)\n {\n if (other is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, other))\n {\n return true;\n }\n\n return other.Key == Key;\n }\n\n public override bool Equals(object obj)\n {\n if (obj is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n if (obj.GetType() != typeof(ClassWithCustomEqualMethod))\n {\n return false;\n }\n\n return Equals((ClassWithCustomEqualMethod)obj);\n }\n\n public override int GetHashCode()\n {\n return Key;\n }\n\n public static bool operator ==(ClassWithCustomEqualMethod left, ClassWithCustomEqualMethod right)\n {\n return Equals(left, right);\n }\n\n public static bool operator !=(ClassWithCustomEqualMethod left, ClassWithCustomEqualMethod right)\n {\n return !Equals(left, right);\n }\n\n public override string ToString()\n {\n return $\"ClassWithCustomEqualMethod({Key})\";\n }\n}\n\npublic abstract class SimpleComplexBase;\n\npublic class Simple : SimpleComplexBase\n{\n public override string ToString() => \"Simple(Hello)\";\n}\n\npublic class Complex : SimpleComplexBase\n{\n public string Statement { get; set; }\n\n public Complex(string statement)\n {\n Statement = statement;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AssertionEngine.cs", "using System;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Configuration;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensibility;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Represents the run-time configuration of the assertion library.\n/// \npublic static class AssertionEngine\n{\n private static readonly object Lockable = new();\n private static ITestFramework testFramework;\n private static bool isInitialized;\n\n static AssertionEngine()\n {\n EnsureInitialized();\n }\n\n /// \n /// Gets or sets the run-time test framework used for throwing assertion exceptions.\n /// \n public static ITestFramework TestFramework\n {\n get\n {\n if (testFramework is not null)\n {\n return testFramework;\n }\n\n lock (Lockable)\n {\n#pragma warning disable CA1508\n if (testFramework is null)\n#pragma warning restore CA1508\n {\n testFramework = TestFrameworkFactory.GetFramework(Configuration.TestFramework);\n }\n }\n\n return testFramework;\n }\n set => testFramework = value;\n }\n\n /// \n /// Provides access to the global configuration and options to customize the behavior of AwesomeAssertions.\n /// \n public static GlobalConfiguration Configuration { get; private set; } = new();\n\n /// \n /// Resets the configuration to its default state and forces the engine to reinitialize the next time it is used.\n /// \n [PublicAPI]\n public static void ResetToDefaults()\n {\n isInitialized = false;\n Configuration = new();\n testFramework = null;\n EnsureInitialized();\n }\n\n internal static void EnsureInitialized()\n {\n if (isInitialized)\n {\n return;\n }\n\n lock (Lockable)\n {\n if (!isInitialized)\n {\n ExecuteCustomInitializers();\n\n isInitialized = true;\n }\n }\n }\n\n private static void ExecuteCustomInitializers()\n {\n var currentAssembly = Assembly.GetExecutingAssembly();\n var currentAssemblyName = currentAssembly.GetName();\n\n AssertionEngineInitializerAttribute[] attributes = [];\n\n try\n {\n attributes = AppDomain.CurrentDomain\n .GetAssemblies()\n .Where(assembly => assembly != currentAssembly && !assembly.IsDynamic && !IsFramework(assembly))\n .Where(a => a.GetReferencedAssemblies().Any(r => r.FullName == currentAssemblyName.FullName))\n .SelectMany(a => a.GetCustomAttributes())\n .ToArray();\n }\n catch\n {\n // Just ignore any exceptions that might happen while trying to find the attributes\n }\n\n foreach (var attribute in attributes)\n {\n try\n {\n attribute.Initialize();\n }\n catch\n {\n // Just ignore any exceptions that might happen while trying to find the attributes\n }\n }\n }\n\n private static bool IsFramework(Assembly assembly)\n {\n#if NET6_0_OR_GREATER\n return assembly!.FullName?.StartsWith(\"Microsoft.\", StringComparison.OrdinalIgnoreCase) == true ||\n assembly.FullName?.StartsWith(\"System.\", StringComparison.OrdinalIgnoreCase) == true;\n#else\n return assembly.FullName.StartsWith(\"Microsoft.\", StringComparison.OrdinalIgnoreCase) ||\n assembly.FullName.StartsWith(\"System.\", StringComparison.OrdinalIgnoreCase);\n#endif\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainEquivalentOf.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]ContainEquivalentOf specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class ContainEquivalentOf\n {\n [Fact]\n public void When_collection_contains_object_equal_of_another_it_should_succeed()\n {\n // Arrange\n var item = new Customer { Name = \"John\" };\n Customer[] collection = [new Customer { Name = \"Jane\" }, item];\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_collection_contains_object_equivalent_of_another_it_should_succeed()\n {\n // Arrange\n Customer[] collection = [new Customer { Name = \"Jane\" }, new Customer { Name = \"John\" }];\n var item = new Customer { Name = \"John\" };\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_character_collection_does_contain_equivalent_it_should_succeed()\n {\n // Arrange\n char[] collection = \"abc123ab\".ToCharArray();\n char item = 'c';\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item);\n }\n\n [Fact]\n public void Can_chain_a_successive_assertion_on_the_matching_item()\n {\n // Arrange\n char[] collection = \"abc123ab\".ToCharArray();\n char item = 'c';\n\n // Act\n var act = () => collection.Should().ContainEquivalentOf(item).Which.Should().Be('C');\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection[2] to be equal to C, but found c.\");\n }\n\n [Fact]\n public void When_string_collection_does_contain_same_string_with_other_case_it_should_throw()\n {\n // Arrange\n string[] collection = [\"a\", \"b\", \"c\"];\n string item = \"C\";\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection {\\\"a\\\", \\\"b\\\", \\\"c\\\"} to contain equivalent of \\\"C\\\".*\");\n }\n\n [Fact]\n public void When_string_collection_does_contain_same_string_it_should_throw_with_a_useful_message()\n {\n // Arrange\n string[] collection = [\"a\"];\n string item = \"b\";\n\n // Act\n Action act = () =>\n collection.Should().ContainEquivalentOf(item, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_object_equivalent_of_another_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int item = 4;\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item);\n\n // Act / Assert\n act.Should().Throw().WithMessage(\"Expected collection {1, 2, 3} to contain equivalent of 4.*\");\n }\n\n [Fact]\n public void When_asserting_collection_to_contain_equivalent_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int expectation = 1;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainEquivalentOf(expectation, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain equivalent of 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_contains_equivalent_null_object_it_should_succeed()\n {\n // Arrange\n int?[] collection = [1, 2, 3, null];\n int? item = null;\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_collection_does_not_contain_equivalent_null_object_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int? item = null;\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected collection {1, 2, 3} to contain equivalent of .*\");\n }\n\n [Fact]\n public void When_empty_collection_does_not_contain_equivalent_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n int item = 1;\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected collection {empty} to contain equivalent of 1.*\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_equivalent_because_of_second_property_it_should_throw()\n {\n // Arrange\n Customer[] subject =\n [\n new Customer\n {\n Name = \"John\",\n Age = 18\n },\n new Customer\n {\n Name = \"Jane\",\n Age = 18\n }\n ];\n\n var item = new Customer { Name = \"John\", Age = 20 };\n\n // Act\n Action act = () => subject.Should().ContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_does_contain_equivalent_by_including_single_property_it_should_not_throw()\n {\n // Arrange\n Customer[] collection =\n [\n new Customer\n {\n Name = \"John\",\n Age = 18\n },\n new Customer\n {\n Name = \"Jane\",\n Age = 18\n }\n ];\n\n var item = new Customer { Name = \"John\", Age = 20 };\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item, options => options.Including(x => x.Name));\n }\n\n [Fact]\n public void Tracing_should_be_included_in_the_assertion_output()\n {\n // Arrange\n Customer[] collection =\n [\n new Customer\n {\n Name = \"John\",\n Age = 18\n },\n new Customer\n {\n Name = \"Jane\",\n Age = 18\n }\n ];\n\n var item = new Customer { Name = \"John\", Age = 21 };\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item, options => options.WithTracing());\n\n // Assert\n act.Should().Throw().WithMessage(\"*Equivalency was proven*\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_ContainEquivalentOf_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n object item = null;\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_collection_contains_object_equivalent_of_boxed_object_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n object boxedValue = 2;\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(boxedValue);\n }\n }\n\n public class NotContainEquivalentOf\n {\n [Fact]\n public void When_collection_contains_object_equal_to_another_it_should_throw()\n {\n // Arrange\n var item = 1;\n int[] collection = [0, 1];\n\n // Act\n Action act = () =>\n collection.Should().NotContainEquivalentOf(item, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {0, 1} not to contain*because we want to test the failure message, \" +\n \"but found one at index 1.*With configuration*\");\n }\n\n [Fact]\n public void When_collection_contains_several_objects_equal_to_another_it_should_throw()\n {\n // Arrange\n var item = 1;\n int[] collection = [0, 1, 1];\n\n // Act\n Action act = () =>\n collection.Should().NotContainEquivalentOf(item, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {0, 1, 1} not to contain*because we want to test the failure message, \" +\n \"but found several at indices {1, 2}.*With configuration*\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_to_contain_equivalent_but_collection_is_null_it_should_throw()\n {\n // Arrange\n var item = 1;\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected collection*not to contain*but collection is .\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_NotContainEquivalentOf_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n object item = null;\n\n // Act\n Action act = () => collection.Should().NotContainEquivalentOf(item, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_to_not_contain_equivalent_it_should_succeed()\n {\n // Arrange\n int[] collection = [];\n int item = 4;\n\n // Act / Assert\n collection.Should().NotContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_asserting_a_null_collection_to_not_contain_equivalent_of__then_it_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainEquivalentOf(1, config => config, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to contain *failure message*, but collection is .\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_object_equivalent_of_unexpected_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int item = 4;\n\n // Act / Assert\n collection.Should().NotContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_equivalent_it_should_respect_config()\n {\n // Arrange\n Customer[] collection =\n [\n new Customer\n {\n Name = \"John\",\n Age = 18\n },\n new Customer\n {\n Name = \"Jane\",\n Age = 18\n }\n ];\n\n var item = new Customer { Name = \"John\", Age = 20 };\n\n // Act\n Action act = () => collection.Should().NotContainEquivalentOf(item, options => options.Excluding(x => x.Age));\n\n // Assert\n act.Should().Throw().WithMessage(\"*Exclude*Age*\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_equivalent_it_should_allow_combining_inside_assertion_scope()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int another = 3;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n collection.Should()\n .NotContainEquivalentOf(another, \"because we want to test {0}\", \"first message\")\n .And\n .HaveCount(4, \"because we want to test {0}\", \"second message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*not to contain*first message*but found one at index 2.*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringEqualityStrategy.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringEqualityStrategy : IStringComparisonStrategy\n{\n private const string Indentation = \" \";\n private const string Prefix = Indentation + \"\\\"\";\n private const string Suffix = \"\\\"\";\n private const char ArrowDown = '\\u2193';\n private const char ArrowUp = '\\u2191';\n private const char Ellipsis = '\\u2026';\n\n private readonly IEqualityComparer comparer;\n private readonly string predicateDescription;\n\n public StringEqualityStrategy(IEqualityComparer comparer, string predicateDescription)\n {\n this.comparer = comparer;\n this.predicateDescription = predicateDescription;\n }\n\n public string ExpectationDescription => $\"Expected {{context:string}} to {predicateDescription} \";\n\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n if (ValidateAgainstSuperfluousWhitespace(assertionChain, subject, expected))\n {\n return;\n }\n\n int indexOfMismatch = GetIndexOfFirstMismatch(subject, expected);\n\n assertionChain\n .ForCondition(indexOfMismatch == -1)\n .FailWith(() => new FailReason(CreateFailureMessage(subject, expected, indexOfMismatch)));\n }\n\n private string CreateFailureMessage(string subject, string expected, int indexOfMismatch)\n {\n string locationDescription = $\"at index {indexOfMismatch}\";\n var matchingString = subject[..indexOfMismatch];\n int lineNumber = matchingString.Count(c => c == '\\n');\n\n if (lineNumber > 0)\n {\n var indexOfLastNewlineBeforeMismatch = matchingString.LastIndexOf('\\n');\n var column = matchingString.Length - indexOfLastNewlineBeforeMismatch;\n locationDescription = $\"on line {lineNumber + 1} and column {column} (index {indexOfMismatch})\";\n }\n\n string mismatchSegment = GetMismatchSegment(subject, expected, indexOfMismatch).EscapePlaceholders();\n\n return $$\"\"\"\n {{ExpectationDescription}}the same string{reason}, but they differ {{locationDescription}}:\n {{mismatchSegment}}.\n \"\"\";\n }\n\n private bool ValidateAgainstSuperfluousWhitespace(AssertionChain assertion, string subject, string expected)\n {\n assertion\n .ForCondition(!(expected.Length > subject.Length && comparer.Equals(expected.TrimEnd(), subject)))\n .FailWith($\"{ExpectationDescription}{{0}}{{reason}}, but it misses some extra whitespace at the end.\", expected)\n .Then\n .ForCondition(!(subject.Length > expected.Length && comparer.Equals(subject.TrimEnd(), expected)))\n .FailWith($\"{ExpectationDescription}{{0}}{{reason}}, but it has unexpected whitespace at the end.\", expected);\n\n return !assertion.Succeeded;\n }\n\n /// \n /// Get the mismatch segment between and ,\n /// when they differ at index .\n /// \n private static string GetMismatchSegment(string subject, string expected, int firstIndexOfMismatch)\n {\n int trimStart = GetStartIndexOfPhraseToShowBeforeTheMismatchingIndex(subject, firstIndexOfMismatch);\n\n int whiteSpaceCountBeforeArrow = (firstIndexOfMismatch - trimStart) + Prefix.Length;\n\n if (trimStart > 0)\n {\n whiteSpaceCountBeforeArrow++;\n }\n\n var visibleText = subject[trimStart..firstIndexOfMismatch];\n whiteSpaceCountBeforeArrow += visibleText.Count(c => c is '\\r' or '\\n');\n\n var sb = new StringBuilder();\n\n sb.Append(' ', whiteSpaceCountBeforeArrow).Append(ArrowDown).AppendLine(\" (actual)\");\n AppendPrefixAndEscapedPhraseToShowWithEllipsisAndSuffix(sb, subject, trimStart);\n AppendPrefixAndEscapedPhraseToShowWithEllipsisAndSuffix(sb, expected, trimStart);\n sb.Append(' ', whiteSpaceCountBeforeArrow).Append(ArrowUp).Append(\" (expected)\");\n\n return sb.ToString();\n }\n\n /// \n /// Appends the prefix, the escaped visible phrase decorated with ellipsis and the suffix to the .\n /// \n /// When text phrase starts at and with a calculated length omits text on start or end, an ellipsis is added.\n private static void AppendPrefixAndEscapedPhraseToShowWithEllipsisAndSuffix(StringBuilder stringBuilder,\n string text, int indexOfStartingPhrase)\n {\n var subjectLength = GetLengthOfPhraseToShowOrDefaultLength(text[indexOfStartingPhrase..]);\n\n stringBuilder.Append(Prefix);\n\n if (indexOfStartingPhrase > 0)\n {\n stringBuilder.Append(Ellipsis);\n }\n\n stringBuilder.Append(text\n .Substring(indexOfStartingPhrase, subjectLength)\n .Replace(\"\\r\", \"\\\\r\", StringComparison.OrdinalIgnoreCase)\n .Replace(\"\\n\", \"\\\\n\", StringComparison.OrdinalIgnoreCase));\n\n if (text.Length > (indexOfStartingPhrase + subjectLength))\n {\n stringBuilder.Append(Ellipsis);\n }\n\n stringBuilder.AppendLine(Suffix);\n }\n\n /// \n /// Calculates the start index of the visible segment from when highlighting the difference at .\n /// \n /// \n /// Either keep the last 10 characters before or a word begin (separated by whitespace) between 15 and 5 characters before .\n /// \n private static int GetStartIndexOfPhraseToShowBeforeTheMismatchingIndex(string value, int indexOfFirstMismatch)\n {\n const int defaultCharactersToKeep = 10;\n const int minCharactersToKeep = 5;\n const int maxCharactersToKeep = 15;\n const int lengthOfWhitespace = 1;\n const int phraseLengthToCheckForWordBoundary = (maxCharactersToKeep - minCharactersToKeep) + lengthOfWhitespace;\n\n if (indexOfFirstMismatch <= defaultCharactersToKeep)\n {\n return 0;\n }\n\n var indexToStartSearchingForWordBoundary = Math.Max(indexOfFirstMismatch - (maxCharactersToKeep + lengthOfWhitespace), 0);\n\n var indexOfWordBoundary = value\n .IndexOf(' ', indexToStartSearchingForWordBoundary, phraseLengthToCheckForWordBoundary) -\n indexToStartSearchingForWordBoundary;\n\n if (indexOfWordBoundary >= 0)\n {\n return indexToStartSearchingForWordBoundary + indexOfWordBoundary + lengthOfWhitespace;\n }\n\n return indexOfFirstMismatch - defaultCharactersToKeep;\n }\n\n /// \n /// Calculates how many characters to keep in .\n /// \n /// \n /// If a word end is found between 45 and 60 characters, use this word end, otherwise keep 50 characters.\n /// \n private static int GetLengthOfPhraseToShowOrDefaultLength(string value)\n {\n var defaultLength = AssertionConfiguration.Current.Formatting.StringPrintLength;\n int minLength = defaultLength - 5;\n int maxLength = defaultLength + 10;\n const int lengthOfWhitespace = 1;\n\n var indexOfWordBoundary = value\n .LastIndexOf(' ', Math.Min(maxLength + lengthOfWhitespace, value.Length) - 1);\n\n if (indexOfWordBoundary >= minLength)\n {\n return indexOfWordBoundary;\n }\n\n return Math.Min(defaultLength, value.Length);\n }\n\n /// \n /// Get index of the first mismatch between and . \n /// \n /// \n /// \n /// Returns the index of the first mismatch, or -1 if the strings are equal.\n private int GetIndexOfFirstMismatch(string subject, string expected)\n {\n int indexOfMismatch = subject.IndexOfFirstMismatch(expected, comparer);\n\n if (indexOfMismatch != -1)\n {\n return indexOfMismatch;\n }\n\n // If no mismatch is found, we can assume the strings are equal when they also have the same length.\n if (subject.Length == expected.Length)\n {\n return -1;\n }\n\n // the mismatch is the first character of the longer string.\n return Math.Min(subject.Length, expected.Length);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringValidator.cs", "using AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringValidator\n{\n private readonly IStringComparisonStrategy comparisonStrategy;\n private AssertionChain assertionChain;\n\n public StringValidator(AssertionChain assertionChain, IStringComparisonStrategy comparisonStrategy, string because,\n object[] becauseArgs)\n {\n this.comparisonStrategy = comparisonStrategy;\n this.assertionChain = assertionChain.BecauseOf(because, becauseArgs);\n }\n\n public void Validate(string subject, string expected)\n {\n if (expected is null && subject is null)\n {\n return;\n }\n\n if (!ValidateAgainstNulls(subject, expected))\n {\n return;\n }\n\n if (expected.IsLongOrMultiline() || subject.IsLongOrMultiline())\n {\n assertionChain = assertionChain.UsingLineBreaks;\n }\n\n comparisonStrategy.ValidateAgainstMismatch(assertionChain, subject, expected);\n }\n\n private bool ValidateAgainstNulls(string subject, string expected)\n {\n if (expected is null == subject is null)\n {\n return true;\n }\n\n assertionChain.FailWith($\"{comparisonStrategy.ExpectationDescription}{{0}}{{reason}}, but found {{1}}.\", expected, subject);\n return false;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/AssertionChainSpecs.Chaining.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\n/// \n/// The chaining API specs.\n/// \npublic partial class AssertionChainSpecs\n{\n public class Chaining\n {\n [Fact]\n public void A_successful_assertion_does_not_affect_the_chained_failing_assertion()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(condition: true)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second assertion\");\n\n // Arrange\n act.Should().Throw().WithMessage(\"*Second assertion*\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_next_one_with_arguments()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second {0}\", \"assertion\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second \\\"assertion\\\"\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_next_one_with_argument_providers()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second {0}\", () => \"assertion\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second \\\"assertion\\\"\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_next_one_with_a_fail_reason_function()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(() => new FailReason(\"Second {0}\", \"assertion\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second \\\"assertion\\\"\");\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_the_reason_should_be_part_of_consecutive_failures()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .BecauseOf(\"because reasons\")\n .FailWith(\"Expected{reason}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because reasons\");\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_the_reason_with_arguments_should_be_part_of_consecutive_failures()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .BecauseOf(\"because {0}\", \"reasons\")\n .FailWith(\"Expected{reason}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because reasons\");\n }\n\n [Fact]\n public void Passing_a_null_value_as_reason_does_not_fail()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .BecauseOf(null, \"only because for method disambiguity\")\n .ForCondition(false)\n .FailWith(\"First assertion\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void When_a_given_is_used_before_an_assertion_then_the_result_should_be_available_for_evaluation()\n {\n // Act / Assert\n AssertionChain.GetOrCreate()\n .Given(() => new[] { \"a\", \"b\" })\n .ForCondition(collection => collection.Length > 0)\n .FailWith(\"First assertion\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_evaluate_the_succeeding_given_statement()\n {\n // Arrange\n using var _ = new AssertionScope(new IgnoringFailuresAssertionStrategy());\n\n // Act / Assert\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .Given(() => throw new InvalidOperationException());\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_evaluate_the_succeeding_condition()\n {\n // Arrange\n bool secondConditionEvaluated = false;\n\n try\n {\n using var _ = new AssertionScope();\n\n // Act\n AssertionChain.GetOrCreate()\n .Given(() => (string)null)\n .ForCondition(s => s is not null)\n .FailWith(\"but is was null\")\n .Then\n .ForCondition(_ => secondConditionEvaluated = true)\n .FailWith(\"it should be 42\");\n }\n catch\n {\n // Ignore\n }\n\n // Assert\n secondConditionEvaluated.Should().BeFalse(\"because the 2nd condition should not be invoked\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_failure()\n {\n // Arrange\n var scope = new AssertionScope();\n\n // Act\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .ForCondition(false)\n .FailWith(\"Second assertion\");\n\n string[] failures = scope.Discard();\n scope.Dispose();\n\n Assert.Single(failures);\n Assert.Contains(\"First assertion\", failures);\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_failure_with_arguments()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second {0}\", \"assertion\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_failure_with_argument_providers()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second {0}\", () => \"assertion\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_failure_with_a_fail_reason_function()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(() => new FailReason(\"Second {0}\", \"assertion\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_expectation()\n {\n // Act\n Action act = () =>\n {\n using var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectations are the root \", c => c\n .ForCondition(false)\n .FailWith(\"of disappointment\")\n .Then\n .WithExpectation(\"Assumptions are the root \", c2 => c2\n .FailWith(\"of all evil\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectations are the root of disappointment\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_expectation_with_arguments()\n {\n // Act\n Action act = () =>\n {\n using var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectations are the {0} \", \"root\", c => c\n .ForCondition(false)\n .FailWith(\"of disappointment\")\n .Then\n .WithExpectation(\"Assumptions are the {0} \", \"root\", c2 => c2\n .FailWith(\"of all evil\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectations are the \\\"root\\\" of disappointment\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_default_identifier()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .WithDefaultIdentifier(\"identifier\")\n .ForCondition(false)\n .FailWith(\"Expected {context}\")\n .Then\n .WithDefaultIdentifier(\"other\")\n .FailWith(\"Expected {context}\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected identifier\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_reasons_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .BecauseOf(\"because {0}\", \"whatever\")\n .ForCondition(false)\n .FailWith(\"Expected{reason}\")\n .Then\n .BecauseOf(\"because reasons\")\n .FailWith(\"Expected{reason}\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because whatever\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_reasons_with_arguments_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .BecauseOf(\"because {0}\", \"whatever\")\n .ForCondition(false)\n .FailWith(\"Expected{reason}\")\n .Then\n .BecauseOf(\"because {0}\", \"reasons\")\n .FailWith(\"Expected{reason}\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because whatever\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_evaluate_the_succeeding_given_statement()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .Given(() => throw new InvalidOperationException());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_succeeding_expectation()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectations are the root \", chain => chain\n .ForCondition(true)\n .FailWith(\"of disappointment\")\n .Then\n .WithExpectation(\"Assumptions are the root \", innerChain => innerChain\n .FailWith(\"of all evil\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Assumptions are the root of all evil\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_succeeding_expectation_with_arguments()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectations are the {0} \", \"root\", c => c\n .ForCondition(true)\n .FailWith(\"of disappointment\")\n .Then\n .WithExpectation(\"Assumptions are the {0} \", \"root\", c2 => c2\n .FailWith(\"of all evil\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Assumptions are the \\\"root\\\" of all evil\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_succeeding_default_identifier()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithDefaultIdentifier(\"identifier\")\n .ForCondition(true)\n .FailWith(\"Expected {context}\")\n .Then\n .WithDefaultIdentifier(\"other\")\n .FailWith(\"Expected {context}\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected other\");\n }\n\n [Fact]\n public void Continuing_an_assertion_with_occurrence()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .WithExpectation(\"{expectedOccurrence} \", c => c\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"Second {0}\", \"assertion\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Exactly 1 time Second \\\"assertion\\\"*\");\n }\n\n [Fact]\n public void Continuing_an_assertion_with_occurrence_will_not_be_executed_when_first_assertion_fails()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .WithExpectation(\"{expectedOccurrence} \", c => c\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"Second {0}\", \"assertion\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void Continuing_an_assertion_with_occurrence_overrides_the_previous_defined_expectations()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"First expectation\", c => c\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .WithExpectation(\"{expectedOccurrence} \", c2 => c2\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"Second {0}\", \"assertion\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Exactly 1 time Second \\\"assertion\\\"*\");\n }\n\n [Fact]\n public void Continuing_an_assertion_after_occurrence_check_works()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"{expectedOccurrence} \", c => c\n .ForConstraint(Exactly.Once(), 1)\n .FailWith(\"First assertion\")\n .Then\n .WithExpectation(\"Second expectation \", c2 => c2\n .ForCondition(false)\n .FailWith(\"Second {0}\", \"assertion\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second expectation Second \\\"assertion\\\"*\");\n }\n\n [Fact]\n public void Continuing_an_assertion_with_occurrence_check_before_defining_expectation_works()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .ForConstraint(Exactly.Once(), 2)\n .WithExpectation(\"Second expectation \", c => c\n .FailWith(\"Second {0}\", \"assertion\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second expectation Second \\\"assertion\\\"*\");\n }\n\n [Fact]\n public void Does_not_continue_a_chained_assertion_after_the_first_one_failed_the_occurrence_check()\n {\n // Arrange\n var scope = new AssertionScope();\n\n // Act\n AssertionChain.GetOrCreate()\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"First {0}\", \"assertion\")\n .Then\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"Second {0}\", \"assertion\");\n\n string[] failures = scope.Discard();\n\n // Assert\n Assert.Single(failures);\n Assert.Contains(\"First \\\"assertion\\\"\", failures);\n }\n\n [Fact]\n public void Discard_a_scope_after_continuing_chained_assertion()\n {\n // Arrange\n using var scope = new AssertionScope();\n\n // Act\n AssertionChain.GetOrCreate()\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"First {0}\", \"assertion\");\n\n var failures = scope.Discard();\n\n // Assert\n Assert.Single(failures);\n Assert.Contains(\"First \\\"assertion\\\"\", failures);\n }\n\n // [Fact]\n // public void Get_info_about_line_breaks_from_parent_scope_after_continuing_chained_assertion()\n // {\n // // Arrange\n // using var scope = new AssertionScope();\n // scope.FormattingOptions.UseLineBreaks = true;\n //\n // // Act\n // var innerScope = AssertionChain.GetOrCreate()\n // .ForConstraint(Exactly.Once(), 1)\n // .FailWith(\"First {0}\", \"assertion\")\n // .Then\n // .UsingLineBreaks;\n //\n // // Assert\n // innerScope.UsingLineBreaks.Should().Be(scope.UsingLineBreaks);\n // }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/FunctionAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that a synchronous function yields the expected result.\n/// \n[DebuggerNonUserCode]\npublic class FunctionAssertions : DelegateAssertions, FunctionAssertions>\n{\n private readonly AssertionChain assertionChain;\n\n public FunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain)\n : base(subject, extractor, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n public FunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain, IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n protected override void InvokeSubject()\n {\n Subject();\n }\n\n protected override string Identifier => \"function\";\n\n /// \n /// Asserts that the current does not throw any exception.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint, T> NotThrow([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n T result = default;\n\n if (assertionChain.Succeeded)\n {\n try\n {\n result = Subject!();\n }\n catch (Exception exception)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exception{reason}, but found {0}.\", exception);\n\n result = default;\n }\n }\n\n return new AndWhichConstraint, T>(this, result, assertionChain, \".Result\");\n }\n\n /// \n /// Asserts that the current stops throwing any exception\n /// after a specified amount of time.\n /// \n /// \n /// The is invoked. If it raises an exception,\n /// the invocation is repeated until it either stops raising any exceptions\n /// or the specified wait time is exceeded.\n /// \n /// \n /// The time after which the should have stopped throwing any exception.\n /// \n /// \n /// The time between subsequent invocations of the .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// or are negative.\n public AndWhichConstraint, T> NotThrowAfter(TimeSpan waitTime, TimeSpan pollInterval,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw any exceptions after {0}{reason}, but found .\", waitTime);\n\n T result = default;\n\n if (assertionChain.Succeeded)\n {\n result = NotThrowAfter(Subject, Clock, waitTime, pollInterval, because, becauseArgs);\n }\n\n return new AndWhichConstraint, T>(this, result, assertionChain, \".Result\");\n }\n\n internal TResult NotThrowAfter(Func subject, IClock clock, TimeSpan waitTime, TimeSpan pollInterval,\n string because, object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(waitTime);\n Guard.ThrowIfArgumentIsNegative(pollInterval);\n\n TimeSpan? invocationEndTime = null;\n Exception exception = null;\n ITimer timer = clock.StartTimer();\n\n while (invocationEndTime is null || invocationEndTime < waitTime)\n {\n try\n {\n return subject();\n }\n catch (Exception ex)\n {\n exception = ex;\n }\n\n clock.Delay(pollInterval);\n invocationEndTime = timer.Elapsed;\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exceptions after {0}{reason}, but found {1}.\", waitTime, exception);\n\n return default;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/TypeSelector.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Allows for fluent filtering a list of types.\n/// \npublic class TypeSelector : IEnumerable\n{\n private List types;\n\n public TypeSelector(Type type)\n : this([type])\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// is or contains .\n public TypeSelector(IEnumerable types)\n {\n Guard.ThrowIfArgumentIsNull(types);\n Guard.ThrowIfArgumentContainsNull(types);\n\n this.types = types.ToList();\n }\n\n /// \n /// The resulting objects.\n /// \n public Type[] ToArray()\n {\n return types.ToArray();\n }\n\n /// \n /// Determines whether a type is a subclass of another type, but NOT the same type.\n /// \n public TypeSelector ThatDeriveFrom()\n {\n types = types.Where(type => type.IsSubclassOf(typeof(TBase))).ToList();\n return this;\n }\n\n /// \n /// Determines whether a type is not a subclass of another type.\n /// \n public TypeSelector ThatDoNotDeriveFrom()\n {\n types = types.Where(type => !type.IsSubclassOf(typeof(TBase))).ToList();\n return this;\n }\n\n /// \n /// Determines whether a type implements an interface (but is not the interface itself).\n /// \n public TypeSelector ThatImplement()\n {\n types = types\n .Where(t => typeof(TInterface).IsAssignableFrom(t) && t != typeof(TInterface))\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type does not implement an interface (but is not the interface itself).\n /// \n public TypeSelector ThatDoNotImplement()\n {\n types = types\n .Where(t => !typeof(TInterface).IsAssignableFrom(t) && t != typeof(TInterface))\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type is decorated with a particular attribute.\n /// \n public TypeSelector ThatAreDecoratedWith()\n where TAttribute : Attribute\n {\n types = types\n .Where(t => t.IsDecoratedWith())\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type is decorated with, or inherits from a parent class, a particular attribute.\n /// \n public TypeSelector ThatAreDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n types = types\n .Where(t => t.IsDecoratedWithOrInherit())\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type is not decorated with a particular attribute.\n /// \n public TypeSelector ThatAreNotDecoratedWith()\n where TAttribute : Attribute\n {\n types = types\n .Where(t => !t.IsDecoratedWith())\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type is not decorated with and does not inherit from a parent class, a particular attribute.\n /// \n public TypeSelector ThatAreNotDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n types = types\n .Where(t => !t.IsDecoratedWithOrInherit())\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether the namespace of type is exactly .\n /// \n public TypeSelector ThatAreInNamespace(string @namespace)\n {\n types = types.Where(t => t.Namespace == @namespace).ToList();\n return this;\n }\n\n /// \n /// Determines whether the namespace of type is exactly not .\n /// \n public TypeSelector ThatAreNotInNamespace(string @namespace)\n {\n types = types.Where(t => t.Namespace != @namespace).ToList();\n return this;\n }\n\n /// \n /// Determines whether the namespace of type starts with .\n /// \n public TypeSelector ThatAreUnderNamespace(string @namespace)\n {\n types = types.Where(t => t.IsUnderNamespace(@namespace)).ToList();\n return this;\n }\n\n /// \n /// Determines whether the namespace of type does not start with .\n /// \n public TypeSelector ThatAreNotUnderNamespace(string @namespace)\n {\n types = types.Where(t => !t.IsUnderNamespace(@namespace)).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are value types\n /// \n public TypeSelector ThatAreValueTypes()\n {\n types = types.Where(t => t.IsValueType).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are not value types\n /// \n public TypeSelector ThatAreNotValueTypes()\n {\n types = types.Where(t => !t.IsValueType).ToList();\n return this;\n }\n\n /// \n /// Determines whether the type is a class\n /// \n public TypeSelector ThatAreClasses()\n {\n types = types.Where(t => t.IsClass).ToList();\n return this;\n }\n\n /// \n /// Determines whether the type is not a class\n /// \n public TypeSelector ThatAreNotClasses()\n {\n types = types.Where(t => !t.IsClass).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are abstract\n /// \n public TypeSelector ThatAreAbstract()\n {\n types = types.Where(t => t.IsCSharpAbstract()).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are not abstract\n /// \n public TypeSelector ThatAreNotAbstract()\n {\n types = types.Where(t => !t.IsCSharpAbstract()).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are sealed\n /// \n public TypeSelector ThatAreSealed()\n {\n types = types.Where(t => t.IsSealed).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are not sealed\n /// \n public TypeSelector ThatAreNotSealed()\n {\n types = types.Where(t => !t.IsSealed).ToList();\n return this;\n }\n\n /// \n /// Filters and returns only the types that are interfaces\n /// \n public TypeSelector ThatAreInterfaces()\n {\n types = types.Where(t => t.IsInterface).ToList();\n return this;\n }\n\n /// \n /// Filters and returns only the types that are not interfaces\n /// \n public TypeSelector ThatAreNotInterfaces()\n {\n types = types.Where(t => !t.IsInterface).ToList();\n return this;\n }\n\n /// \n /// Determines whether the type is static\n /// \n public TypeSelector ThatAreStatic()\n {\n types = types.Where(t => t.IsCSharpStatic()).ToList();\n return this;\n }\n\n /// \n /// Determines whether the type is not static\n /// \n public TypeSelector ThatAreNotStatic()\n {\n types = types.Where(t => !t.IsCSharpStatic()).ToList();\n return this;\n }\n\n /// \n /// Allows to filter the types with the passed\n /// \n public TypeSelector ThatSatisfy(Func predicate)\n {\n types = types.Where(predicate).ToList();\n return this;\n }\n\n /// \n /// Filters and returns only the types which have access modifier .\n /// \n /// Required access modifier for types\n public TypeSelector ThatHaveAccessModifier(CSharpAccessModifier accessModifier)\n {\n types = types.Where(t => t.GetCSharpAccessModifier() == accessModifier).ToList();\n return this;\n }\n\n /// \n /// Filters and returns only the types which don't have access modifier .\n /// \n /// Unwanted access modifier for types\n public TypeSelector ThatDoNotHaveAccessModifier(CSharpAccessModifier accessModifier)\n {\n types = types.Where(t => t.GetCSharpAccessModifier() != accessModifier).ToList();\n return this;\n }\n\n /// \n /// Returns T for the types which are or ; the type itself otherwise\n /// \n public TypeSelector UnwrapTaskTypes()\n {\n types = types.ConvertAll(type =>\n {\n if (type.IsGenericType)\n {\n Type genericTypeDefinition = type.GetGenericTypeDefinition();\n if (genericTypeDefinition == typeof(Task<>) || genericTypeDefinition == typeof(ValueTask<>))\n {\n return type.GetGenericArguments().Single();\n }\n }\n\n return type == typeof(Task) || type == typeof(ValueTask) ? typeof(void) : type;\n });\n\n return this;\n }\n\n /// \n /// Returns T for the types which are or implement the ; the type itself otherwise\n /// \n public TypeSelector UnwrapEnumerableTypes()\n {\n var unwrappedTypes = new List();\n\n foreach (Type type in types)\n {\n if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))\n {\n unwrappedTypes.Add(type.GetGenericArguments().Single());\n }\n else\n {\n var iEnumerableImplementations = type\n .GetInterfaces()\n .Where(iType => iType.IsGenericType && iType.GetGenericTypeDefinition() == typeof(IEnumerable<>))\n .Select(ied => ied.GetGenericArguments().Single())\n .ToList();\n\n if (iEnumerableImplementations.Count > 0)\n {\n unwrappedTypes.AddRange(iEnumerableImplementations);\n }\n else\n {\n unwrappedTypes.Add(type);\n }\n }\n }\n\n types = unwrappedTypes;\n return this;\n }\n\n /// \n /// Returns an enumerator that iterates through the collection.\n /// \n /// \n /// A that can be used to iterate through the collection.\n /// \n /// 1\n public IEnumerator GetEnumerator()\n {\n return types.GetEnumerator();\n }\n\n /// \n /// Returns an enumerator that iterates through a collection.\n /// \n /// \n /// An object that can be used to iterate through the collection.\n /// \n /// 2\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/PropertyInfoSelectorAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Types;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class PropertyInfoSelectorAssertionSpecs\n{\n public class BeVirtual\n {\n [Fact]\n public void When_asserting_properties_are_virtual_and_they_are_it_should_succeed()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesVirtual));\n\n // Act / Assert\n propertyInfoSelector.Should().BeVirtual();\n }\n\n [Fact]\n public void When_asserting_properties_are_virtual_but_non_virtual_properties_are_found_it_should_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithNonVirtualPublicProperties));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().BeVirtual();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_properties_are_virtual_but_non_virtual_properties_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithNonVirtualPublicProperties));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().BeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected properties\" +\n \" to be virtual because we want to test the error message,\" +\n \" but the following properties are not virtual:*\" +\n \"ClassWithNonVirtualPublicProperties.PublicNonVirtualProperty*\" +\n \"ClassWithNonVirtualPublicProperties.InternalNonVirtualProperty*\" +\n \"ClassWithNonVirtualPublicProperties.ProtectedNonVirtualProperty\");\n }\n }\n\n public class NotBeVirtual\n {\n [Fact]\n public void When_asserting_properties_are_not_virtual_and_they_are_not_it_should_succeed()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithNonVirtualPublicProperties));\n\n // Act / Assert\n propertyInfoSelector.Should().NotBeVirtual();\n }\n\n [Fact]\n public void When_asserting_properties_are_not_virtual_but_virtual_properties_are_found_it_should_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesVirtual));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().NotBeVirtual();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_properties_are_not_virtual_but_virtual_properties_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesVirtual));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().NotBeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected properties\" +\n \" not to be virtual because we want to test the error message,\" +\n \" but the following properties are virtual*\" +\n \"*ClassWithAllPropertiesVirtual.PublicVirtualProperty\" +\n \"*ClassWithAllPropertiesVirtual.InternalVirtualProperty\" +\n \"*ClassWithAllPropertiesVirtual.ProtectedVirtualProperty\");\n }\n }\n\n public class BeDecoratedWith\n {\n [Fact]\n public void When_asserting_properties_are_decorated_with_attribute_and_they_are_it_should_succeed()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute));\n\n // Act / Assert\n propertyInfoSelector.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_properties_are_decorated_with_attribute_and_they_are_not_it_should_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute))\n .ThatArePublicOrInternal;\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_properties_are_decorated_with_attribute_and_they_are_not_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should()\n .BeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected properties to be decorated with\" +\n \" AwesomeAssertions*DummyPropertyAttribute because we want to test the error message,\" +\n \" but the following properties are not:*\" +\n \"ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.PublicProperty*\" +\n \"ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.InternalProperty*\" +\n \"ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.ProtectedProperty\");\n }\n }\n\n public class NotBeDecoratedWith\n {\n [Fact]\n public void When_asserting_properties_are_not_decorated_with_attribute_and_they_are_not_it_should_succeed()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute));\n\n // Act / Assert\n propertyInfoSelector.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_properties_are_not_decorated_with_attribute_and_they_are_it_should_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute))\n .ThatArePublicOrInternal;\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().NotBeDecoratedWith();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_properties_are_not_decorated_with_attribute_and_they_are_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should()\n .NotBeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected properties not to be decorated*\" +\n \"DummyPropertyAttribute*\" +\n \"because we want to test the error message*\" +\n \"ClassWithAllPropertiesDecoratedWithDummyAttribute.PublicProperty*\" +\n \"ClassWithAllPropertiesDecoratedWithDummyAttribute.InternalProperty*\" +\n \"ClassWithAllPropertiesDecoratedWithDummyAttribute.ProtectedProperty*\");\n }\n }\n\n public class BeWritable\n {\n [Fact]\n public void When_a_read_only_property_is_expected_to_be_writable_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithReadOnlyProperties));\n\n // Act\n Action action = () => propertyInfoSelector.Should().BeWritable(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\n \"Expected all selected properties to have a setter because we want to test the error message, \" +\n \"but the following properties do not:*\" +\n \"ClassWithReadOnlyProperties.ReadOnlyProperty*\" +\n \"ClassWithReadOnlyProperties.ReadOnlyProperty2\");\n }\n\n [Fact]\n public void When_writable_properties_are_expected_to_be_writable_it_should_not_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithOnlyWritableProperties));\n\n // Act / Assert\n propertyInfoSelector.Should().BeWritable();\n }\n }\n\n public class NotBeWritable\n {\n [Fact]\n public void When_a_writable_property_is_expected_to_be_read_only_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithWritableProperties));\n\n // Act\n Action action = () => propertyInfoSelector.Should().NotBeWritable(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\n \"Expected selected properties to not have a setter because we want to test the error message, \" +\n \"but the following properties do:*\" +\n \"ClassWithWritableProperties.ReadWriteProperty*\" +\n \"ClassWithWritableProperties.ReadWriteProperty2\");\n }\n\n [Fact]\n public void When_read_only_properties_are_expected_to_not_be_writable_it_should_not_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithOnlyReadOnlyProperties));\n\n // Act / Assert\n propertyInfoSelector.Should().NotBeWritable();\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var someObject = new PropertyInfoSelectorAssertions(AssertionChain.GetOrCreate());\n\n // Act\n var action = () => someObject.Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n\n [Fact]\n public void A_failing_check_on_a_generic_class_includes_the_generic_type_in_the_failure_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(GenericClassWithOnlyReadOnlyProperties));\n\n // Act\n Action action = () => propertyInfoSelector.Should().BeWritable(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected all selected properties to have a setter because we want to test the error message, \" +\n \"but the following properties do not:*\" +\n \"GenericClassWithOnlyReadOnlyProperties.ReadOnlyProperty\");\n }\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class ClassWithAllPropertiesVirtual\n{\n public virtual string PublicVirtualProperty { set { } }\n\n internal virtual string InternalVirtualProperty => null;\n\n protected virtual string ProtectedVirtualProperty { get; set; }\n}\n\ninternal interface IInterfaceWithProperty\n{\n string PublicNonVirtualProperty { get; set; }\n}\n\ninternal class ClassWithNonVirtualPublicProperties : IInterfaceWithProperty\n{\n public string PublicNonVirtualProperty { get; set; }\n\n internal string InternalNonVirtualProperty { get; set; }\n\n protected string ProtectedNonVirtualProperty { get; set; }\n}\n\ninternal class ClassWithReadOnlyProperties\n{\n public string ReadOnlyProperty => \"\";\n\n public string ReadOnlyProperty2 => \"\";\n\n public string ReadWriteProperty { get => \"\"; set { } }\n}\n\ninternal class ClassWithWritableProperties\n{\n public string ReadOnlyProperty => \"\";\n\n public string ReadWriteProperty { get => \"\"; set { } }\n\n public string ReadWriteProperty2 { get => \"\"; set { } }\n}\n\ninternal class ClassWithOnlyWritableProperties\n{\n public string ReadWriteProperty { set { } }\n}\n\ninternal class ClassWithOnlyReadOnlyProperties\n{\n public string ReadOnlyProperty => \"\";\n\n public string ReadOnlyProperty2 => \"\";\n}\n\ninternal class GenericClassWithOnlyReadOnlyProperties\n{\n public TSubject ReadOnlyProperty => default;\n}\n\ninternal class ClassWithAllPropertiesDecoratedWithDummyAttribute\n{\n [DummyProperty(\"Value\")]\n public string PublicProperty { get; set; }\n\n [DummyProperty(\"Value\")]\n [DummyProperty(\"OtherValue\")]\n public string PublicPropertyWithSameAttributeTwice { get; set; }\n\n [DummyProperty]\n internal string InternalProperty { get; set; }\n\n [DummyProperty]\n protected string ProtectedProperty { get; set; }\n}\n\ninternal class ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute\n{\n public string PublicProperty { get; set; }\n\n internal string InternalProperty { get; set; }\n\n protected string ProtectedProperty { get; set; }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/MethodInfoSelectorSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Types;\nusing Internal.Main.Test;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class MethodInfoSelectorSpecs\n{\n [Fact]\n public void When_method_info_selector_is_created_with_a_null_type_it_should_throw()\n {\n // Arrange\n MethodInfoSelector methodInfoSelector;\n\n // Act\n Action act = () => methodInfoSelector = new MethodInfoSelector((Type)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_method_info_selector_is_created_with_a_null_type_list_it_should_throw()\n {\n // Arrange\n MethodInfoSelector methodInfoSelector;\n\n // Act\n Action act = () => methodInfoSelector = new MethodInfoSelector((Type[])null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_method_info_selector_is_null_then_should_should_throw()\n {\n // Arrange\n MethodInfoSelector methodInfoSelector = null;\n\n // Act\n var act = () => methodInfoSelector.Should();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"methodSelector\");\n }\n\n [Fact]\n public void When_selecting_methods_from_types_in_an_assembly_it_should_return_the_applicable_methods()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable methods = assembly.Types()\n .ThatAreDecoratedWith()\n .Methods();\n\n // Assert\n methods.Should()\n .HaveCount(2)\n .And.Contain(m => m.Name == \"Method1\")\n .And.Contain(m => m.Name == \"Method2\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_public_or_internal_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatArePublicOrInternal;\n\n // Assert\n const int PublicMethodCount = 2;\n const int InternalMethodCount = 1;\n methods.Should().HaveCount(PublicMethodCount + InternalMethodCount);\n }\n\n [Fact]\n public void When_selecting_methods_decorated_with_specific_attribute_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreDecoratedWith().ToArray();\n\n // Assert\n methods.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_methods_not_decorated_with_specific_attribute_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n methods.Should()\n .NotBeEmpty()\n .And.NotContain(m => m.Name == \"PublicVirtualVoidMethodWithAttribute\")\n .And.NotContain(m => m.Name == \"ProtectedVirtualVoidMethodWithAttribute\");\n }\n\n [Fact]\n public void When_selecting_methods_that_return_a_specific_type_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatReturn().ToArray();\n\n // Assert\n methods.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_methods_that_do_not_return_a_specific_type_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatDoNotReturn().ToArray();\n\n // Assert\n methods.Should().HaveCount(5);\n }\n\n [Fact]\n public void When_selecting_methods_without_return_value_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatReturnVoid.ToArray();\n\n // Assert\n methods.Should().HaveCount(4);\n }\n\n [Fact]\n public void When_selecting_methods_with_return_value_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatDoNotReturnVoid.ToArray();\n\n // Assert\n methods.Should().HaveCount(3);\n }\n\n [Fact]\n public void When_combining_filters_to_filter_methods_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods()\n .ThatArePublicOrInternal\n .ThatReturnVoid\n .ToArray();\n\n // Assert\n methods.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_methods_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreDecoratedWith().ToArray();\n\n // Assert\n methods.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_methods_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreDecoratedWithOrInherit().ToArray();\n\n // Assert\n methods.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_methods_not_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n methods.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_methods_not_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotDecoratedWithOrInherit().ToArray();\n\n // Assert\n methods.Should().BeEmpty();\n }\n\n [Fact]\n public void When_selecting_methods_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreDecoratedWith()\n .ToArray();\n\n // Assert\n methods.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_methods_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable methods =\n type.Methods().ThatAreDecoratedWithOrInherit().ToArray();\n\n // Assert\n methods.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_methods_not_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotDecoratedWith()\n .ToArray();\n\n // Assert\n methods.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_methods_that_are_abstract_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithAbstractAndVirtualMethods);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreAbstract().ToArray();\n\n // Assert\n methods.Should().HaveCount(3);\n }\n\n [Fact]\n public void When_selecting_methods_that_are_not_abstract_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithAbstractAndVirtualMethods);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotAbstract().ToArray();\n\n // Assert\n methods.Should().HaveCount(10);\n }\n\n [Fact]\n public void When_selecting_methods_that_are_async_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithAsyncAndNonAsyncMethod);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreAsync().ToArray();\n\n // Assert\n methods.Should().ContainSingle()\n .Which.Name.Should().Be(\"PublicAsyncMethod\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_not_async_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithAsyncAndNonAsyncMethod);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreNotAsync().ToArray();\n\n // Assert\n methods.Should().ContainSingle()\n .Which.Name.Should().Be(\"PublicNonAsyncMethod\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_virtual_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreVirtual().ToArray();\n\n // Assert\n methods.Should()\n .NotBeEmpty()\n .And.Contain(m => m.Name == \"PublicVirtualVoidMethodWithAttribute\")\n .And.Contain(m => m.Name == \"ProtectedVirtualVoidMethodWithAttribute\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_not_virtual_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreNotVirtual().ToArray();\n\n // Assert\n methods.Should()\n .NotBeEmpty()\n .And.NotContain(m => m.Name == \"PublicVirtualVoidMethodWithAttribute\")\n .And.NotContain(m => m.Name == \"ProtectedVirtualVoidMethodWithAttribute\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_static_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithStaticAndNonStaticMethod);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreStatic().ToArray();\n\n // Assert\n methods.Should().ContainSingle()\n .Which.Name.Should().Be(\"PublicStaticMethod\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_not_static_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithStaticAndNonStaticMethod);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreNotStatic().ToArray();\n\n // Assert\n methods.Should().ContainSingle()\n .Which.Name.Should().Be(\"PublicNonStaticMethod\");\n }\n\n [Fact]\n public void\n When_selecting_methods_not_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable methods =\n type.Methods().ThatAreNotDecoratedWithOrInherit().ToArray();\n\n // Assert\n methods.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_methods_return_types_it_should_return_the_correct_types()\n {\n // Arrange\n Type type = typeof(TestClassForMethodReturnTypesSelector);\n\n // Act\n IEnumerable returnTypes = type.Methods().ReturnTypes().ToArray();\n\n // Assert\n returnTypes.Should()\n .HaveCount(3)\n .And.Contain(typeof(void))\n .And.Contain(typeof(int))\n .And.Contain(typeof(string));\n }\n\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n var action = () => type.Methods().Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class TestClassForMethodSelector\n{\n#pragma warning disable 67, S3264 // \"event is never used\"\n public event EventHandler SomethingChanged = (_, _) => { };\n#pragma warning restore 67, S3264\n\n public virtual void PublicVirtualVoidMethod()\n {\n }\n\n [DummyMethod]\n public virtual void PublicVirtualVoidMethodWithAttribute()\n {\n }\n\n internal virtual int InternalVirtualIntMethod()\n {\n return 0;\n }\n\n [DummyMethod]\n protected virtual void ProtectedVirtualVoidMethodWithAttribute()\n {\n }\n\n private void PrivateVoidDoNothing()\n {\n }\n\n protected virtual string ProtectedVirtualStringMethod()\n {\n return \"\";\n }\n\n private string PrivateStringMethod()\n {\n return \"\";\n }\n}\n\ninternal class TestClassForMethodSelectorWithInheritableAttribute\n{\n [DummyMethod]\n public virtual void PublicVirtualVoidMethodWithAttribute() { }\n}\n\ninternal class TestClassForMethodSelectorWithNonInheritableAttribute\n{\n [DummyMethodNonInheritableAttribute]\n public virtual void PublicVirtualVoidMethodWithAttribute() { }\n}\n\ninternal class TestClassForMethodSelectorWithInheritableAttributeDerived : TestClassForMethodSelectorWithInheritableAttribute\n{\n public override void PublicVirtualVoidMethodWithAttribute() { }\n}\n\ninternal class TestClassForMethodSelectorWithNonInheritableAttributeDerived\n : TestClassForMethodSelectorWithNonInheritableAttribute\n{\n public override void PublicVirtualVoidMethodWithAttribute() { }\n}\n\ninternal class TestClassForMethodSelectorWithAsyncAndNonAsyncMethod\n{\n public async Task PublicAsyncMethod() => await Task.Yield();\n\n public Task PublicNonAsyncMethod() => Task.CompletedTask;\n}\n\ninternal class TestClassForMethodSelectorWithStaticAndNonStaticMethod\n{\n public static void PublicStaticMethod() { }\n\n public void PublicNonStaticMethod() { }\n}\n\ninternal class TestClassForMethodReturnTypesSelector\n{\n public void SomeMethod() { }\n\n public int AnotherMethod() { return default; }\n\n public string OneMoreMethod() { return default; }\n}\n\n[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]\npublic class DummyMethodNonInheritableAttributeAttribute : Attribute\n{\n public bool Filter { get; set; }\n}\n\n[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]\npublic class DummyMethodAttribute : Attribute\n{\n public bool Filter { get; set; }\n}\n\ninternal abstract class TestClassForMethodSelectorWithAbstractAndVirtualMethods\n{\n public abstract void PublicAbstractMethod();\n\n protected abstract void ProtectedAbstractMethod();\n\n internal abstract void InternalAbstractMethod();\n\n public static void PublicStaticMethod() { }\n\n protected static void ProtectedStaticMethod() { }\n\n internal static void InternalStaticMethod() { }\n\n public virtual void PublicVirtualMethod() { }\n\n protected virtual void ProptectedVirtualMethod() { }\n\n internal virtual void InternalVirtualMethod() { }\n\n public void PublicNotAbstractMethod() { }\n\n protected void ProtectedNotAbstractMethod() { }\n\n internal void InternalNotAbstractMethod() { }\n\n private void PrivateAbstractMethod() { }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XDocumentAssertionSpecs.cs", "using System;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XDocumentAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_asserting_a_xml_document_is_equal_to_the_same_xml_document_it_should_succeed()\n {\n // Arrange\n var document = new XDocument();\n var sameXDocument = document;\n\n // Act / Assert\n document.Should().Be(sameXDocument);\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equal_to_a_different_xml_document_it_should_fail()\n {\n // Arrange\n var theDocument = new XDocument();\n var otherXDocument = new XDocument();\n\n // Act\n Action act = () =>\n theDocument.Should().Be(otherXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be [XML document without root element], but found [XML document without root element].\");\n }\n\n [Fact]\n public void When_the_expected_element_is_null_it_fails()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().Be(new XDocument(), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be [XML document without root element] *failure message*, but found .\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_documents_are_null_it_succeeds()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().Be(null);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_document_is_expected_to_equal_null_it_fails()\n {\n // Arrange\n XDocument theDocument = new();\n\n // Act\n Action act = () => theDocument.Should().Be(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be *failure message*, but found [XML document without root element].\");\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equal_to_a_different_xml_document_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().Be(otherXDocument, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be because we want to test the failure message, but found .\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_asserting_a_xml_document_is_not_equal_to_a_different_xml_document_it_should_succeed()\n {\n // Arrange\n var document = new XDocument();\n var otherXDocument = new XDocument();\n\n // Act / Assert\n document.Should().NotBe(otherXDocument);\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_not_equal_to_the_same_xml_document_it_should_fail()\n {\n // Arrange\n var theDocument = new XDocument();\n var sameXDocument = theDocument;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBe(sameXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be [XML document without root element].\");\n }\n\n [Fact]\n public void When_a_null_document_is_not_supposed_to_be_a_document_it_succeeds()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act / Assert\n theDocument.Should().NotBe(new XDocument());\n }\n\n [Fact]\n public void When_a_document_is_not_supposed_to_be_null_it_succeeds()\n {\n // Arrange\n XDocument theDocument = new();\n\n // Act / Assert\n theDocument.Should().NotBe(null);\n }\n\n [Fact]\n public void When_a_null_document_is_not_supposed_to_be_equal_to_null_it_fails()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().NotBe(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theDocument to be *failure message*.\");\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_not_equal_to_the_same_xml_document_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var sameXDocument = theDocument;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBe(sameXDocument, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be because we want to test the failure message.\");\n }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void When_asserting_a_xml_document_is_equivalent_to_the_same_xml_document_it_should_succeed()\n {\n // Arrange\n var document = new XDocument();\n var sameXDocument = document;\n\n // Act / Assert\n document.Should().BeEquivalentTo(sameXDocument);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_selfclosing_document_is_equivalent_to_a_different_xml_document_with_same_structure_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n document.Should().BeEquivalentTo(otherXDocument);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_equivalent_to_a_different_xml_document_with_same_structure_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n document.Should().BeEquivalentTo(otherXDocument);\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equivalent_to_a_xml_document_with_elements_missing_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(otherXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in theDocument at \\\"/parent\\\", but found Element \\\"child2\\\".\");\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equivalent_to_a_different_xml_document_with_extra_elements_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child2\\\" in theDocument at \\\"/parent\\\", but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_with_selfclosing_child_is_equivalent_to_a_different_xml_document_with_subchild_child_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(otherXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child\\\" in theDocument at \\\"/parent/child\\\", but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_equivalent_to_a_different_xml_document_elements_missing_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in theDocument at \\\"/parent\\\" because we want to test the failure message,\"\n + \" but found Element \\\"child2\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_equivalent_to_a_different_xml_document_with_extra_elements_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child2\\\" in theDocument at \\\"/parent\\\" because we want to test the failure message,\"\n + \" but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void When_a_document_is_null_then_be_equivalent_to_null_succeeds()\n {\n XDocument theDocument = null;\n\n // Act / Assert\n theDocument.Should().BeEquivalentTo(null);\n }\n\n [Fact]\n public void When_a_document_is_null_then_be_equivalent_to_a_document_fails()\n {\n XDocument theDocument = null;\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(\n XDocument.Parse(\"\"), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theDocument to be equivalent to *failure message*\" +\n \", but found \\\"\\\".\");\n }\n\n [Fact]\n public void When_a_document_is_equivalent_to_null_it_fails()\n {\n XDocument theDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theDocument to be equivalent to \\\"\\\" *failure message*\" +\n \", but found .\");\n }\n\n [Fact]\n public void\n When_assertion_an_xml_document_is_equivalent_to_a_different_xml_document_with_different_namespace_prefix_it_should_succeed()\n {\n // Arrange\n var subject = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_a_different_xml_document_which_differs_only_on_unused_namespace_declaration_it_should_succeed()\n {\n // Arrange\n var subject = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_lacks_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message, but found none.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_has_extra_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect to find attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_has_different_attribute_values_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" to have value \\\"c\\\" because we want to test the failure message, but found \\\"b\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_has_attribute_with_different_namespace_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect to find attribute \\\"ns:a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_has_different_text_contents_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"a\");\n var expected = XDocument.Parse(\"b\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected content to be \\\"b\\\" in theDocument at \\\"/xml\\\" because we want to test the failure message, but found \\\"a\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_with_different_comments_it_should_succeed()\n {\n // Arrange\n var subject = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_an_xml_document_but_has_different_attribute_value_it_should_fail_with_xpath_to_difference()\n {\n // Arrange\n XDocument actual = XDocument.Parse(\"\");\n XDocument expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"/xml/b\\\"*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_document_with_repeating_element_names_but_differs_it_should_fail_with_index_xpath_to_difference()\n {\n // Arrange\n XDocument actual = XDocument.Parse(\n \"\");\n\n XDocument expected = XDocument.Parse(\n \"\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"/xml/xml2[3]/a[2]\\\"*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_document_with_repeating_element_names_on_different_levels_but_differs_it_should_fail_with_index_xpath_to_difference()\n {\n // Arrange\n XDocument actual = XDocument.Parse(\n \"\");\n\n XDocument expected = XDocument.Parse(\n \"\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"/xml/xml[3]/xml[2]\\\"*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_document_with_repeating_element_names_with_different_parents_but_differs_it_should_fail_with_index_xpath_to_difference()\n {\n // Arrange\n XDocument actual = XDocument.Parse(\n \"\");\n\n XDocument expected = XDocument.Parse(\n \"\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"/root/xml1[3]/xml2[2]\\\"*\");\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_elements_missing_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n document.Should().NotBeEquivalentTo(otherXDocument);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_extra_elements_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n document.Should().NotBeEquivalentTo(otherXDocument);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_same_structure_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(otherXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_not_equivalent_to_the_same_xml_document_it_should_fail()\n {\n // Arrange\n var theDocument = new XDocument();\n var sameXDocument = theDocument;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(sameXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_same_structure_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(otherDocument, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_same_contents_but_different_ns_prefixes_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(@\"\");\n var otherXDocument = XDocument.Parse(@\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(otherXDocument, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_same_contents_but_extra_unused_xmlns_declaration_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(@\"\");\n var otherDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(otherDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_the_same_xml_document_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var sameXDocument = theDocument;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(sameXDocument, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void When_a_null_document_is_unexpected_equivalent_to_null_it_fails()\n {\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().NotBeEquivalentTo(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theDocument to be equivalent *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_a_null_document_is_not_equivalent_to_a_document_it_succeeds()\n {\n XDocument theDocument = null;\n\n // Act / Assert\n theDocument.Should().NotBeEquivalentTo(XDocument.Parse(\"\"));\n }\n\n [Fact]\n public void When_a_document_is_not_equivalent_to_null_it_succeeds()\n {\n XDocument theDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n theDocument.Should().NotBeEquivalentTo(null);\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_asserting_a_null_xml_document_is_null_it_should_succeed()\n {\n // Arrange\n XDocument document = null;\n\n // Act / Assert\n document.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_a_non_null_xml_document_is_null_it_should_fail()\n {\n // Arrange\n var theDocument = new XDocument();\n\n // Act\n Action act = () =>\n theDocument.Should().BeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be , but found [XML document without root element].\");\n }\n\n [Fact]\n public void When_asserting_a_non_null_xml_document_is_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be because we want to test the failure message, but found .\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_asserting_a_non_null_xml_document_is_not_null_it_should_succeed()\n {\n // Arrange\n var document = new XDocument();\n\n // Act / Assert\n document.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_document_is_not_null_it_should_fail()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected theDocument not to be .\");\n }\n\n [Fact]\n public void When_asserting_a_null_xml_document_is_not_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument not to be because we want to test the failure message.\");\n }\n }\n\n public class HaveRoot\n {\n [Fact]\n public void When_asserting_document_has_root_element_and_it_does_it_should_succeed_and_return_it_for_chaining()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n XElement root = document.Should().HaveRoot(\"parent\").Subject;\n\n // Assert\n root.Should().BeSameAs(document.Root);\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => theDocument.Should().HaveRoot(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element \\\"unknown\\\", but found .\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveRoot(\"unknown\", \"because we want to test the failure message\");\n\n // Assert\n string expectedMessage = \"Expected theDocument to have root element \\\"unknown\\\"\" +\n \" because we want to test the failure message\" +\n $\", but found {Formatter.ToString(theDocument)}.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_asserting_a_null_document_has_root_element_it_should_fail()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().HaveRoot(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has a root element if the document itself is .\");\n }\n\n [Fact]\n public void When_asserting_a_document_has_a_root_element_with_a_null_name_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => theDocument.Should().HaveRoot(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has a root element if the expected name is *\");\n }\n\n [Fact]\n public void When_asserting_a_document_has_a_root_element_with_a_null_xname_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => theDocument.Should().HaveRoot((XName)null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has a root element if the expected name is *\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_with_ns_and_it_does_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveRoot(XName.Get(\"parent\", \"http://www.example.com/2012/test\"));\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_with_ns_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveRoot(XName.Get(\"unknown\", \"http://www.example.com/2012/test\"));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element \\\"{http://www.example.com/2012/test}unknown\\\", but found .\");\n }\n\n [Fact]\n public void Can_chain_another_assertion_on_the_root_element()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => theDocument.Should().HaveRoot(\"parent\").Which.Should().HaveElement(\"unknownChild\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument/parent to have child element*unknownChild*\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_with_ns_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveRoot(XName.Get(\"unknown\", \"http://www.example.com/2012/test\"),\n \"because we want to test the failure message\");\n\n // Assert\n string expectedMessage =\n \"Expected theDocument to have root element \\\"{http://www.example.com/2012/test}unknown\\\"\" +\n \" because we want to test the failure message\" +\n $\", but found {Formatter.ToString(theDocument)}.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n }\n\n public class HaveElement\n {\n [Fact]\n public void When_document_has_the_expected_child_element_it_should_not_throw_and_return_the_element_for_chaining()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n XElement element = document.Should().HaveElement(\"child\").Subject;\n\n // Assert\n element.Should().BeSameAs(document.Element(\"parent\").Element(\"child\"));\n }\n\n [Fact]\n public void Can_chain_another_assertion_on_the_root_element()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n var act = () => document.Should().HaveElement(\"child\").Which.Should().HaveElement(\"grandChild\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected document/child to have child element*grandChild*\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_with_child_element_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveElement(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element with child \\\"unknown\\\", but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_with_child_element_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveElement(\"unknown\", \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element with child \\\"unknown\\\" because we want to test the failure message,\"\n + \" but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_with_child_element_with_ns_and_it_does_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElement(XName.Get(\"child\", \"http://www.example.org/2012/test\"));\n }\n\n [Fact]\n public void When_asserting_document_has_root_with_child_element_with_ns_but_it_does_not_it_should_fail()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n document.Should().HaveElement(XName.Get(\"unknown\", \"http://www.example.org/2012/test\"));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected document to have root element with child \\\"{http://www.example.org/2012/test}unknown\\\",\"\n + \" but no such child element was found.\");\n }\n\n [Fact]\n public void\n When_asserting_document_has_root_with_child_element_with_ns_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveElement(XName.Get(\"unknown\", \"http://www.example.org/2012/test\"),\n \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element with child \\\"{http://www.example.org/2012/test}unknown\\\"\"\n + \" because we want to test the failure message, but no such child element was found.\");\n }\n\n [Fact]\n public void\n When_asserting_document_has_root_with_child_element_with_attributes_it_should_be_possible_to_use_which_to_assert_on_the_element()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n XElement matchedElement = document.Should().HaveElement(\"child\").Subject;\n\n // Assert\n matchedElement.Should().BeOfType().And.HaveAttributeWithValue(\"attr\", \"1\");\n matchedElement.Name.Should().Be(XName.Get(\"child\"));\n }\n\n [Fact]\n public void When_asserting_a_null_document_has_an_element_it_should_fail()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () => document.Should().HaveElement(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has an element if the document itself is .\");\n }\n\n [Fact]\n public void When_asserting_a_document_without_root_element_has_an_element_it_should_fail()\n {\n // Arrange\n XDocument document = new();\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n document.Should().HaveElement(\"unknown\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected document to have root element with child \\\"unknown\\\", but it has no root element.\");\n }\n\n [Fact]\n public void When_asserting_a_document_has_an_element_with_a_null_name_it_should_fail()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has an element if the expected name is *\");\n }\n\n [Fact]\n public void When_asserting_a_document_has_an_element_with_a_null_xname_it_should_fail()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement((XName)null);\n\n // Assert\n act.Should().ThrowExactly().WithMessage(\n \"Cannot assert the document has an element if the expected name is *\");\n }\n }\n\n public class HaveElementWithValue\n {\n [Fact]\n public void The_document_cannot_be_null()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void The_expected_element_with_the_expected_value_is_valid()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElementWithValue(\"child\", \"b\");\n }\n\n [Fact]\n public void Throws_when_element_is_not_found()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(\"grandchild\", \"f\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*grandchild*f*element*isn't found*\");\n }\n\n [Fact]\n public void Throws_when_element_found_but_value_does_not_match()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(\"child\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*c*element*does not have such a value*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_with_namespace_is_null()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue((XName)null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(\"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null_and_searching_with_namespace()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(XNamespace.None + \"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void The_document_cannot_be_null_and_using_a_namespace()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () =>\n document.Should()\n .HaveElementWithValue(XNamespace.None + \"child\", \"b\", \"we want to test the {0} message\", \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*failure message*element itself is *\");\n }\n\n [Fact]\n public void Has_element_with_namespace_and_specified_value()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElementWithValue(XNamespace.None + \"child\", \"b\");\n }\n\n [Fact]\n public void Throws_when_element_with_namespace_is_not_found()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n document.Should().HaveElementWithValue(XNamespace.None + \"grandchild\", \"f\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\"*grandchild*f*element*isn't found*\");\n }\n\n [Fact]\n public void Throws_when_element_with_namespace_found_but_value_does_not_match()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(XNamespace.None + \"child\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*c*element*does not have such a value*\");\n }\n }\n\n public class HaveElementWithOccurrence\n {\n [Fact]\n public void When_asserting_document_has_two_child_elements_and_it_does_it_succeeds()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElement(\"child\", Exactly.Twice());\n }\n\n [Fact]\n public void Asserting_document_null_inside_an_assertion_scope_it_checks_the_whole_assertion_scope_before_failing()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n document.Should().HaveElement(\"child\", Exactly.Twice());\n document.Should().HaveElement(\"child\", Exactly.Twice());\n }\n };\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void\n Asserting_with_document_root_null_inside_an_assertion_scope_it_checks_the_whole_assertion_scope_before_failing()\n {\n // Arrange\n XDocument document = new();\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n document.Should().HaveElement(\"child\", Exactly.Twice());\n document.Should().HaveElement(\"child\", Exactly.Twice());\n }\n };\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_asserting_document_has_two_child_elements_but_it_does_have_three_it_fails()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement(\"child\", Exactly.Twice());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected document to have a root element containing a child \\\"child\\\"*exactly*2 times, but found it 3 times*\");\n }\n\n [Fact]\n public void Document_is_valid_and_expected_null_with_string_overload_it_fails()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement(null, Exactly.Twice());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has an element if the expected name is .*\");\n }\n\n [Fact]\n public void Document_is_valid_and_expected_null_with_x_name_overload_it_fails()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement((XName)null, Exactly.Twice());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has an element count if the element name is .*\");\n }\n\n [Fact]\n public void Chaining_after_a_successful_occurrence_check_does_continue_the_assertion()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElement(\"child\", AtLeast.Twice())\n .Which.Should().NotBeNull();\n }\n\n [Fact]\n public void Chaining_after_a_non_successful_occurrence_check_does_not_continue_the_assertion()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement(\"child\", Exactly.Once())\n .Which.Should().NotBeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected document to have a root element containing a child \\\"child\\\"*exactly*1 time, but found it 3 times.\");\n }\n\n [Fact]\n public void When_asserting_a_null_document_to_have_an_element_count_it_should_fail()\n {\n // Arrange\n XDocument xDocument = null;\n\n // Act\n Action act = () => xDocument.Should().HaveElement(\"child\", AtLeast.Once());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the count if the document itself is .\");\n }\n }\n\n public class NotHaveElement\n {\n [Fact]\n public void The_document_cannot_be_null()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () => document.Should().NotHaveElement(\"child\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void The_document_does_not_have_this_element()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n document.Should().NotHaveElement(\"c\");\n }\n\n [Fact]\n public void Throws_when_element_found_but_expected_to_be_absent()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().NotHaveElement(\"child\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Did not*child*element*was found*\");\n }\n\n [Fact]\n public void Throws_when_unexpected_element_is_null()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().NotHaveElement(null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*unexpectedElement*\");\n }\n\n [Fact]\n public void Throws_when_unexpected_element_is_null_with_namespace()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().NotHaveElement((XName)null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*unexpectedElement*\");\n }\n\n [Fact]\n public void Throws_when_null_with_namespace()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () =>\n document.Should()\n .NotHaveElement(XNamespace.None + \"child\", \"we want to test the {0} message\", \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*failure message*element itself is *\");\n }\n\n [Fact]\n public void Not_have_element_with_with_namespace()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n document.Should().NotHaveElement(XNamespace.None + \"c\");\n }\n }\n\n public class NotHaveElementWithValue\n {\n [Fact]\n public void The_document_cannot_be_null()\n {\n // Arrange\n XDocument element = null;\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void Throws_when_element_with_specified_value_is_found()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not*element*child*value*b*does have this value*\");\n }\n\n [Fact]\n public void Passes_when_element_not_found()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(\"c\", \"f\");\n }\n\n [Fact]\n public void Passes_when_element_found_but_value_does_not_match()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(\"child\", \"c\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null_with_namespace()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue((XName)null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null_with_namespace()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void The_document_cannot_be_null_and_searching_with_namespace()\n {\n // Arrange\n XDocument element = null;\n\n // Act\n Action act = () =>\n element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"b\", \"we want to test the {0} message\",\n \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*failure message*element itself is *\");\n }\n\n [Fact]\n public void Throws_when_element_with_specified_value_is_found_with_namespace()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not expect*element*child*value*b*does have this value*\");\n }\n\n [Fact]\n public void Passes_when_element_with_namespace_not_found()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(XNamespace.None + \"c\", \"f\");\n }\n\n [Fact]\n public void Passes_when_element_with_namespace_found_but_value_does_not_match()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"c\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/XmlReaderValueFormatter.cs", "using System.Xml;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class XmlReaderValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is XmlReader;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var reader = (XmlReader)value;\n\n if (reader.ReadState == ReadState.Initial)\n {\n reader.Read();\n }\n\n var result = \"\\\"\" + reader.ReadOuterXml() + \"\\\"\";\n\n formattedGraph.AddFragment(result);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XmlNodeFormatter.cs", "using System.Xml;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Xml;\n\npublic class XmlNodeFormatter : IValueFormatter\n{\n public bool CanHandle(object value)\n {\n return value is XmlNode;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n string outerXml = ((XmlNode)value).OuterXml;\n\n const int maxLength = 20;\n\n if (outerXml.Length > maxLength)\n {\n outerXml = outerXml.Substring(0, maxLength).TrimEnd() + \"…\";\n }\n\n formattedGraph.AddLine(outerXml.EscapePlaceholders());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/TypeSelectorAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Types;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that all s in a \n/// meet certain expectations.\n/// \n[DebuggerNonUserCode]\npublic class TypeSelectorAssertions\n{\n /// \n /// Initializes a new instance of the class.\n /// \n /// is or contains .\n public TypeSelectorAssertions(AssertionChain assertionChain, params Type[] types)\n {\n CurrentAssertionChain = assertionChain;\n Guard.ThrowIfArgumentIsNull(types);\n Guard.ThrowIfArgumentContainsNull(types);\n\n Subject = types;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public IEnumerable Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDecoratedWith([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Type[] typesWithoutAttribute = Subject\n .Where(type => !type.IsDecoratedWith())\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithoutAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be decorated with {0}{reason}, but the attribute was not found on the following types:\n {{GetDescriptionsFor(typesWithoutAttribute)}}.\n \"\"\",\n typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n Type[] typesWithoutMatchingAttribute = Subject\n .Where(type => !type.IsDecoratedWith(isMatchingAttributePredicate))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithoutMatchingAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be decorated with {0} that matches {1}{reason}, but no matching attribute was found on the following types:\n {{GetDescriptionsFor(typesWithoutMatchingAttribute)}}.\n \"\"\",\n typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is decorated with, or inherits from a parent class, the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDecoratedWithOrInherit(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Type[] typesWithoutAttribute = Subject\n .Where(type => !type.IsDecoratedWithOrInherit())\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithoutAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be decorated with or inherit {0}{reason}, but the attribute was not found on the following types:\n {{GetDescriptionsFor(typesWithoutAttribute)}}.\n \"\"\",\n typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is decorated with, or inherits from a parent class, an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeDecoratedWithOrInherit(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n Type[] typesWithoutMatchingAttribute = Subject\n .Where(type => !type.IsDecoratedWithOrInherit(isMatchingAttributePredicate))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithoutMatchingAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be decorated with or inherit {0} that matches {1}{reason}, but no matching attribute was found on the following types:\n {{GetDescriptionsFor(typesWithoutMatchingAttribute)}}.\n \"\"\",\n typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Type[] typesWithAttribute = Subject\n .Where(type => type.IsDecoratedWith())\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to not be decorated with {0}{reason}, but the attribute was found on the following types:\n {{GetDescriptionsFor(typesWithAttribute)}}.\n \"\"\",\n typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n Type[] typesWithMatchingAttribute = Subject\n .Where(type => type.IsDecoratedWith(isMatchingAttributePredicate))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithMatchingAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to not be decorated with {0} that matches {1}{reason}, but a matching attribute was found on the following types:\n {{GetDescriptionsFor(typesWithMatchingAttribute)}}.\n \"\"\",\n typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with and does not inherit from a parent class, the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWithOrInherit(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Type[] typesWithAttribute = Subject\n .Where(type => type.IsDecoratedWithOrInherit())\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to not be decorated with or inherit {0}{reason}, but the attribute was found on the following types:\n {{GetDescriptionsFor(typesWithAttribute)}}.\n \"\"\",\n typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with and does not inherit from a parent class, an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWithOrInherit(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n Type[] typesWithMatchingAttribute = Subject\n .Where(type => type.IsDecoratedWithOrInherit(isMatchingAttributePredicate))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithMatchingAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to not be decorated with or inherit {0} that matches {1}{reason}, but a matching attribute was found on the following types:\n {{GetDescriptionsFor(typesWithMatchingAttribute)}}.\n \"\"\",\n typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected types are sealed\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSealed([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var notSealedTypes = Subject.Where(type => !type.IsCSharpSealed()).ToArray();\n\n CurrentAssertionChain.ForCondition(notSealedTypes.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be sealed{reason}, but the following types are not:\n {{GetDescriptionsFor(notSealedTypes)}}.\n \"\"\");\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the all are not sealed classes\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSealed([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var sealedTypes = Subject.Where(type => type.IsCSharpSealed()).ToArray();\n\n CurrentAssertionChain.ForCondition(sealedTypes.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types not to be sealed{reason}, but the following types are:\n {{GetDescriptionsFor(sealedTypes)}}.\n \"\"\");\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is in the specified .\n /// \n /// \n /// The namespace that the type must be in.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeInNamespace(string @namespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Type[] typesNotInNamespace = Subject\n .Where(t => t.Namespace != @namespace)\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesNotInNamespace.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be in namespace {0}{reason}, but the following types are in a different namespace:\n {{GetDescriptionsFor(typesNotInNamespace)}}.\n \"\"\",\n @namespace);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not in the specified .\n /// \n /// \n /// The namespace that the type must not be in.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeInNamespace(string @namespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Type[] typesInNamespace = Subject\n .Where(t => t.Namespace == @namespace)\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesInNamespace.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected no types to be in namespace {0}{reason}, but the following types are in the namespace:\n {{GetDescriptionsFor(typesInNamespace)}}.\n \"\"\",\n @namespace);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the namespace of the current starts with the specified .\n /// \n /// \n /// The namespace that the namespace of the type must start with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeUnderNamespace(string @namespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Type[] typesNotUnderNamespace = Subject\n .Where(t => !t.IsUnderNamespace(@namespace))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesNotUnderNamespace.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected the namespaces of all types to start with {0}{reason}, but the namespaces of the following types do not start with it:\n {{GetDescriptionsFor(typesNotUnderNamespace)}}.\n \"\"\",\n @namespace);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the namespace of the current \n /// does not starts with the specified .\n /// \n /// \n /// The namespace that the namespace of the type must not start with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeUnderNamespace(string @namespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Type[] typesUnderNamespace = Subject\n .Where(t => t.IsUnderNamespace(@namespace))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesUnderNamespace.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected the namespaces of all types to not start with {0}{reason}, but the namespaces of the following types start with it:\n {{GetDescriptionsFor(typesUnderNamespace)}}.\n \"\"\",\n @namespace);\n\n return new AndConstraint(this);\n }\n\n private static string GetDescriptionsFor(IEnumerable types)\n {\n IEnumerable descriptions = types.Select(type => GetDescriptionFor(type));\n return string.Join(Environment.NewLine, descriptions);\n }\n\n private static string GetDescriptionFor(Type type)\n {\n return type.ToString();\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\n \"Equals is not part of Awesome Assertions. Did you mean BeInNamespace() or BeDecoratedWith() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/MultidimensionalArrayFormatter.cs", "using System;\nusing System.Collections;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class MultidimensionalArrayFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is Array { Rank: >= 2 };\n }\n\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\", Justification = \"Required refactoring\")]\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var arr = (Array)value;\n\n if (arr.Length == 0)\n {\n formattedGraph.AddFragment(\"{empty}\");\n return;\n }\n\n int[] dimensionIndices = Enumerable.Range(0, arr.Rank).Select(dimension => arr.GetLowerBound(dimension)).ToArray();\n\n int currentLoopIndex = 0;\n\n // ReSharper disable once NotDisposedResource (false positive)\n // See https://youtrack.jetbrains.com/issue/QD-8114/It-is-not-a-problem-Local-variable-enumerator-is-never-disposed\n IEnumerator enumerator = arr.GetEnumerator();\n\n // Emulate n-ary loop\n while (currentLoopIndex >= 0)\n {\n int currentDimensionIndex = dimensionIndices[currentLoopIndex];\n\n if (IsFirstIteration(arr, currentDimensionIndex, currentLoopIndex))\n {\n formattedGraph.AddFragment(\"{\");\n }\n\n if (IsInnerMostLoop(arr, currentLoopIndex))\n {\n enumerator.MoveNext();\n formatChild(string.Join(\"-\", dimensionIndices), enumerator.Current, formattedGraph);\n\n if (!IsLastIteration(arr, currentDimensionIndex, currentLoopIndex))\n {\n formattedGraph.AddFragment(\", \");\n }\n\n ++dimensionIndices[currentLoopIndex];\n }\n else\n {\n ++currentLoopIndex;\n continue;\n }\n\n while (IsLastIteration(arr, currentDimensionIndex, currentLoopIndex))\n {\n formattedGraph.AddFragment(\"}\");\n\n // Reset current loop's variable to start value ...and move to outer loop\n dimensionIndices[currentLoopIndex] = arr.GetLowerBound(currentLoopIndex);\n --currentLoopIndex;\n\n if (currentLoopIndex < 0)\n {\n break;\n }\n\n currentDimensionIndex = dimensionIndices[currentLoopIndex];\n\n if (!IsLastIteration(arr, currentDimensionIndex, currentLoopIndex))\n {\n formattedGraph.AddFragment(\", \");\n }\n\n ++dimensionIndices[currentLoopIndex];\n }\n }\n }\n\n private static bool IsFirstIteration(Array arr, int index, int dimension)\n {\n return index == arr.GetLowerBound(dimension);\n }\n\n private static bool IsInnerMostLoop(Array arr, int index)\n {\n return index == (arr.Rank - 1);\n }\n\n private static bool IsLastIteration(Array arr, int index, int dimension)\n {\n return index >= arr.GetUpperBound(dimension);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedXunitTheoryTestCase.cs", "using System;\nusing System.ComponentModel;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedXunitTheoryTestCase : XunitTheoryTestCase\n{\n [EditorBrowsable(EditorBrowsableState.Never)]\n [Obsolete(\"Called by the de-serializer; should only be called by deriving classes for de-serialization purposes\")]\n public CulturedXunitTheoryTestCase() { }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The message sink used to send diagnostic messages\n /// Default method display to use (when not customized).\n /// Default method display options to use (when not customized).\n /// The method under test.\n public CulturedXunitTheoryTestCase(IMessageSink diagnosticMessageSink,\n TestMethodDisplay defaultMethodDisplay,\n TestMethodDisplayOptions defaultMethodDisplayOptions,\n ITestMethod testMethod,\n string culture)\n : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod)\n {\n Initialize(culture);\n }\n\n public string Culture { get; private set; }\n\n public override void Deserialize(IXunitSerializationInfo data)\n {\n base.Deserialize(data);\n\n Initialize(data.GetValue(\"Culture\"));\n }\n\n protected override string GetUniqueID() => $\"{base.GetUniqueID()}[{Culture}]\";\n\n private void Initialize(string culture)\n {\n Culture = culture;\n\n Traits.Add(\"Culture\", culture);\n\n DisplayName += $\"[{culture}]\";\n }\n\n public override Task RunAsync(IMessageSink diagnosticMessageSink,\n IMessageBus messageBus,\n object[] constructorArguments,\n ExceptionAggregator aggregator,\n CancellationTokenSource cancellationTokenSource) =>\n new CulturedXunitTheoryTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, diagnosticMessageSink,\n messageBus, aggregator, cancellationTokenSource).RunAsync();\n\n public override void Serialize(IXunitSerializationInfo data)\n {\n base.Serialize(data);\n\n data.AddValue(\"Culture\", Culture);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/MethodInfoAssertionSpecs.cs", "using System;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class MethodInfoAssertionSpecs\n{\n public class BeVirtual\n {\n [Fact]\n public void When_asserting_a_method_is_virtual_and_it_is_then_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithAllMethodsVirtual).GetParameterlessMethod(\"PublicVirtualDoNothing\");\n\n // Act / Assert\n methodInfo.Should().BeVirtual();\n }\n\n [Fact]\n public void When_asserting_a_method_is_virtual_but_it_is_not_then_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithNonVirtualPublicMethods).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method void AwesomeAssertions*ClassWithNonVirtualPublicMethods.PublicDoNothing\" +\n \" to be virtual because we want to test the error message,\" +\n \" but it is not virtual.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_virtual_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().BeVirtual(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method to be virtual *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotBeVirtual\n {\n [Fact]\n public void When_asserting_a_method_is_not_virtual_and_it_is_not_then_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithNonVirtualPublicMethods).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeVirtual();\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_virtual_but_it_is_then_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithAllMethodsVirtual).GetParameterlessMethod(\"PublicVirtualDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method *ClassWithAllMethodsVirtual.PublicVirtualDoNothing\" +\n \" not to be virtual because we want to test the error message,\" +\n \" but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_virtual_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeVirtual(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method not to be virtual *failure message*, but methodInfo is .\");\n }\n }\n\n public class BeDecoratedWithOfT\n {\n [Fact]\n public void When_asserting_a_method_is_decorated_with_attribute_and_it_is_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_and_it_is_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"DoNotInlineMe\");\n\n // Act / Assert\n methodInfo.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_constructor_is_decorated_with_an_attribute_and_it_is_it_succeeds()\n {\n // Arrange\n ConstructorInfo constructorMethodInfo =\n typeof(ClassWithMethodWithImplementationAttribute).GetConstructor(Type.EmptyTypes);\n\n // Act / Assert\n constructorMethodInfo.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_constructor_is_decorated_with_an_attribute_and_it_is_not_it_throws()\n {\n // Arrange\n ConstructorInfo constructorMethodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetConstructor([typeof(string)]);\n\n // Act\n Action act = () =>\n constructorMethodInfo.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw(\n \"Expected constructor AwesomeAssertions.Specs.Types.ClassWithMethodsThatAreNotDecoratedWithDummyAttribute(string parameter) \" +\n \"to be decorated with System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_and_it_is_not_it_throws()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothing to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_with_no_options_and_it_is_it_throws()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"NoOptions\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodWithImplementationAttribute.NoOptions to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_with_zero_as_options_and_it_is_it_throws()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"ZeroOptions\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodWithImplementationAttribute.ZeroOptions to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_class_is_decorated_with_an_attribute_and_it_is_not_it_throws()\n {\n // Arrange\n var type = typeof(ClassWithAllMethodsDecoratedWithDummyAttribute);\n\n // Act\n Action act = () =>\n type.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type AwesomeAssertions*ClassWithAllMethodsDecoratedWithDummyAttribute to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but the attribute was not found.\");\n }\n\n [Fact]\n public void When_a_method_is_decorated_with_an_attribute_it_should_allow_chaining_assertions_on_it()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () => methodInfo.Should().BeDecoratedWith().Which.Filter.Should().BeFalse();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_but_it_is_not_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.PublicDoNothing to be decorated with \" +\n \"AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but that attribute was not found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_BeDecoratedWith_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () => methodInfo.Should().BeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_attribute_matching_a_predicate_and_it_is_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().BeDecoratedWith(d => d.Filter);\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_matching_a_predicate_and_it_is_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"DoNotInlineMe\");\n\n // Act / Assert\n methodInfo.Should().BeDecoratedWith(x => x.Value == MethodImplOptions.NoInlining);\n }\n\n [Fact]\n public void\n When_asserting_a_method_is_decorated_with_an_attribute_matching_a_predicate_but_it_is_not_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should()\n .BeDecoratedWith(d => !d.Filter, \"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.PublicDoNothing to be decorated with \" +\n \"AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but that attribute was not found.\");\n }\n\n [Fact]\n public void\n When_asserting_a_method_is_decorated_with_an_attribute_matching_a_predicate_but_it_is_not_it_throws()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"DoNotInlineMe\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith(x => x.Value == MethodImplOptions.AggressiveInlining);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodWithImplementationAttribute.DoNotInlineMe to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void\n When_asserting_a_method_is_decorated_with_an_attribute_and_multiple_attributes_match_continuation_using_the_matched_value_should_fail()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\n \"PublicDoNothingWithSameAttributeTwice\");\n\n // Act\n Action act =\n () =>\n methodInfo.Should()\n .BeDecoratedWith()\n .Which.Filter.Should()\n .BeTrue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_is_null_be_decorated_withOfT_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method to be decorated with *.DummyMethodAttribute *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotBeDecoratedWithOfT\n {\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_attribute_and_it_is_not_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_an_attribute_and_it_is_not_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_constructor_is_not_decorated_with_an_attribute_and_it_is_not_it_succeeds()\n {\n // Arrange\n ConstructorInfo constructorMethodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetConstructor([typeof(string)]);\n\n // Act / Assert\n constructorMethodInfo.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_constructor_is_not_decorated_with_an_attribute_and_it_is_it_throws()\n {\n // Arrange\n ConstructorInfo constructorMethodInfo =\n typeof(ClassWithMethodWithImplementationAttribute).GetConstructor([typeof(string[])]);\n\n // Act\n Action act = () =>\n constructorMethodInfo.Should().NotBeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected constructor AwesomeAssertions.Specs.Types.ClassWithMethodWithImplementationAttribute(string[]) \" +\n \"to not be decorated with System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_an_attribute_but_it_is_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothing to not be decorated with \" +\n \"AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but that attribute was found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_an_attribute_and_it_is_it_throws()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"DoNotInlineMe\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodWithImplementationAttribute.DoNotInlineMe to not be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_attribute_matching_a_predicate_and_it_is_not_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeDecoratedWith(d => !d.Filter);\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotBeDecoratedWith_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () => methodInfo.Should().NotBeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void\n When_asserting_a_method_is_not_decorated_with_an_attribute_matching_a_predicate_but_it_is_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should()\n .NotBeDecoratedWith(d => d.Filter, \"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothing to not be decorated with \" +\n \"AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but that attribute was found.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_decorated_withOfT_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method to not be decorated with *.DummyMethodAttribute *failure message*\" +\n \", but methodInfo is .\");\n }\n }\n\n public class BeAsync\n {\n [Fact]\n public void When_asserting_a_method_is_async_and_it_is_then_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithAllMethodsAsync).GetParameterlessMethod(\"PublicAsyncDoNothing\");\n\n // Act / Assert\n methodInfo.Should().BeAsync();\n }\n\n [Fact]\n public void When_asserting_a_method_is_async_but_it_is_not_then_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithNonAsyncMethods).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeAsync(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method Task AwesomeAssertions*ClassWithNonAsyncMethods.PublicDoNothing\" +\n \" to be async because we want to test the error message,\" +\n \" but it is not.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_async_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().BeAsync(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method to be async *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotBeAsync\n {\n [Fact]\n public void When_asserting_a_method_is_not_async_and_it_is_not_then_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithNonAsyncMethods).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeAsync();\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_async_but_it_is_then_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithAllMethodsAsync).GetParameterlessMethod(\"PublicAsyncDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeAsync(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*ClassWithAllMethodsAsync.PublicAsyncDoNothing*\" +\n \"not to be async*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_async_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeAsync(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method not to be async *failure message*, but methodInfo is .\");\n }\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class ClassWithAllMethodsVirtual\n{\n public virtual void PublicVirtualDoNothing()\n {\n }\n\n internal virtual void InternalVirtualDoNothing()\n {\n }\n\n protected virtual void ProtectedVirtualDoNothing()\n {\n }\n}\n\ninternal interface IInterfaceWithPublicMethod\n{\n void PublicDoNothing();\n}\n\ninternal class ClassWithNonVirtualPublicMethods : IInterfaceWithPublicMethod\n{\n public void PublicDoNothing()\n {\n }\n\n internal void InternalDoNothing()\n {\n }\n\n protected void ProtectedDoNothing()\n {\n }\n}\n\ninternal class ClassWithAllMethodsDecoratedWithDummyAttribute\n{\n [DummyMethod(Filter = true)]\n public void PublicDoNothing()\n {\n }\n\n [DummyMethod(Filter = true)]\n [DummyMethod(Filter = false)]\n public void PublicDoNothingWithSameAttributeTwice()\n {\n }\n\n [DummyMethod]\n protected void ProtectedDoNothing()\n {\n }\n\n [DummyMethod]\n private void PrivateDoNothing()\n {\n }\n}\n\ninternal class ClassWithMethodsThatAreNotDecoratedWithDummyAttribute\n{\n public ClassWithMethodsThatAreNotDecoratedWithDummyAttribute(string _) { }\n\n public void PublicDoNothing()\n {\n }\n\n protected void ProtectedDoNothing()\n {\n }\n\n private void PrivateDoNothing()\n {\n }\n}\n\ninternal class ClassWithAllMethodsAsync\n{\n public async Task PublicAsyncDoNothing()\n {\n await Task.Yield();\n }\n\n internal async Task InternalAsyncDoNothing()\n {\n await Task.Yield();\n }\n\n protected async Task ProtectedAsyncDoNothing()\n {\n await Task.Yield();\n }\n}\n\ninternal class ClassWithNonAsyncMethods\n{\n public Task PublicDoNothing()\n {\n return Task.CompletedTask;\n }\n\n internal Task InternalDoNothing()\n {\n return Task.CompletedTask;\n }\n\n protected Task ProtectedDoNothing()\n {\n return Task.CompletedTask;\n }\n}\n\ninternal class ClassWithMethodWithImplementationAttribute\n{\n [MethodImpl(MethodImplOptions.NoOptimization)]\n public ClassWithMethodWithImplementationAttribute() { }\n\n [MethodImpl(MethodImplOptions.NoOptimization)]\n public ClassWithMethodWithImplementationAttribute(string[] _) { }\n\n [MethodImpl(MethodImplOptions.NoInlining)]\n public void DoNotInlineMe() { }\n\n [MethodImpl]\n public void NoOptions() { }\n\n [MethodImpl((MethodImplOptions)0)]\n public void ZeroOptions() { }\n}\n\ninternal class ClassWithPublicMethods\n{\n public void PublicDoNothing()\n {\n }\n\n public void DoNothingWithParameter(int _)\n {\n }\n}\n\ninternal class GenericClassWithNonPublicMethods\n{\n protected void PublicDoNothing()\n {\n }\n\n internal void DoNothingWithParameter(TSubject _)\n {\n }\n\n private void DoNothingWithAnotherParameter(string _)\n {\n }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/AssemblyAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \npublic class AssemblyAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public AssemblyAssertions(Assembly assembly, AssertionChain assertionChain)\n : base(assembly, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that an assembly does not reference the specified assembly.\n /// \n /// The assembly which should not be referenced.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotReference(Assembly assembly,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(assembly);\n\n var assemblyName = assembly.GetName().Name;\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected assembly not to reference assembly {0}{reason}, but {context:assembly} is .\",\n assemblyName);\n\n if (assertionChain.Succeeded)\n {\n var subjectName = Subject!.GetName().Name;\n\n IEnumerable references = Subject.GetReferencedAssemblies().Select(x => x.Name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!references.Contains(assemblyName))\n .FailWith(\"Expected assembly {0} not to reference assembly {1}{reason}.\", subjectName, assemblyName);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that an assembly references the specified assembly.\n /// \n /// The assembly which should be referenced.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Reference(Assembly assembly,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(assembly);\n\n var assemblyName = assembly.GetName().Name;\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected assembly to reference assembly {0}{reason}, but {context:assembly} is .\", assemblyName);\n\n if (assertionChain.Succeeded)\n {\n var subjectName = Subject!.GetName().Name;\n\n IEnumerable references = Subject.GetReferencedAssemblies().Select(x => x.Name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(references.Contains(assemblyName))\n .FailWith(\"Expected assembly {0} to reference assembly {1}{reason}, but it does not.\", subjectName, assemblyName);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the assembly defines a type called and .\n /// \n /// The namespace of the class.\n /// The name of the class.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint DefineType(string @namespace, string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected assembly to define type {0}.{1}{reason}, but {context:assembly} is .\",\n @namespace, name);\n\n Type foundType = null;\n\n if (assertionChain.Succeeded)\n {\n foundType = Subject!.GetTypes().SingleOrDefault(t => t.Namespace == @namespace && t.Name == name);\n\n assertionChain\n .ForCondition(foundType is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected assembly {0} to define type {1}.{2}{reason}, but it does not.\",\n Subject.FullName, @namespace, name);\n }\n\n return new AndWhichConstraint(this, foundType);\n }\n\n /// Asserts that the assembly is unsigned.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeUnsigned([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .FailWith(\"Can't check for assembly signing if {context:assembly} reference is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.GetName().GetPublicKey() is not { Length: > 0 })\n .FailWith(\n \"Did not expect the assembly {0} to be signed{reason}, but it is.\", Subject.FullName);\n }\n\n return new AndConstraint(this);\n }\n\n /// Asserts that the assembly is signed with the specified public key.\n /// \n /// The base-16 string representation of the public key, like \"e0851575614491c6d25018fadb75\".\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint BeSignedWithPublicKey(string publicKey,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(publicKey);\n\n assertionChain\n .ForCondition(Subject is not null)\n .FailWith(\"Can't check for assembly signing if {context:assembly} reference is .\");\n\n if (assertionChain.Succeeded)\n {\n var bytes = Subject!.GetName().GetPublicKey() ?? [];\n string assemblyKey = ToHexString(bytes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected assembly {0} to have public key {1} \", Subject.FullName, publicKey, chain => chain\n .ForCondition(bytes.Length != 0)\n .FailWith(\"{reason}, but it is unsigned.\")\n .Then\n .ForCondition(string.Equals(assemblyKey, publicKey, StringComparison.OrdinalIgnoreCase))\n .FailWith(\"{reason}, but it has {0} instead.\", assemblyKey));\n }\n\n return new AndConstraint(this);\n }\n\n private static string ToHexString(byte[] bytes) =>\n#if NET6_0_OR_GREATER\n Convert.ToHexString(bytes);\n#else\n BitConverter.ToString(bytes).Replace(\"-\", string.Empty, StringComparison.Ordinal);\n#endif\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"assembly\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/AssemblyAssertionSpecs.cs", "using System;\nusing System.Reflection;\nusing AssemblyA;\nusing AssemblyB;\nusing AwesomeAssertions.Specs.Types;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class AssemblyAssertionSpecs\n{\n public class NotReference\n {\n [Fact]\n public void When_an_assembly_is_not_referenced_and_should_not_reference_is_asserted_it_should_succeed()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act / Assert\n assemblyB.Should().NotReference(assemblyA);\n }\n\n [Fact]\n public void When_an_assembly_is_not_referenced_it_should_allow_chaining()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act / Assert\n assemblyB.Should().NotReference(assemblyA)\n .And.NotBeNull();\n }\n\n [Fact]\n public void When_an_assembly_is_referenced_and_should_not_reference_is_asserted_it_should_fail()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().NotReference(assemblyB);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_is_null_not_reference_should_fail()\n {\n // Arrange\n Assembly assemblyA = null;\n Assembly assemblyB = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().NotReference(assemblyB, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected assembly not to reference assembly \\\"AssemblyB\\\" *failure message*, but assemblyA is .\");\n }\n\n [Fact]\n public void When_an_assembly_is_not_referencing_null_it_should_throw()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().NotReference(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"assembly\");\n }\n }\n\n public class Reference\n {\n [Fact]\n public void When_an_assembly_is_referenced_and_should_reference_is_asserted_it_should_succeed()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act / Assert\n assemblyA.Should().Reference(assemblyB);\n }\n\n [Fact]\n public void When_an_assembly_is_referenced_it_should_allow_chaining()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act / Assert\n assemblyA.Should().Reference(assemblyB)\n .And.NotBeNull();\n }\n\n [Fact]\n public void When_an_assembly_is_not_referenced_and_should_reference_is_asserted_it_should_fail()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyB.Should().Reference(assemblyA);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_is_null_reference_should_fail()\n {\n // Arrange\n Assembly assemblyA = null;\n Assembly assemblyB = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().Reference(assemblyB, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected assembly to reference assembly \\\"AssemblyB\\\" *failure message*, but assemblyA is .\");\n }\n\n [Fact]\n public void When_an_assembly_is_referencing_null_it_should_throw()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().Reference(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"assembly\");\n }\n }\n\n public class DefineType\n {\n [Fact]\n public void Can_find_a_specific_type()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act / Assert\n thisAssembly\n .Should().DefineType(GetType().Namespace, typeof(WellKnownClassWithAttribute).Name)\n .Which.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void Can_continue_assertions_on_the_found_type()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act\n Action act = () => thisAssembly\n .Should().DefineType(GetType().Namespace, typeof(WellKnownClassWithAttribute).Name)\n .Which.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*WellKnownClassWithAttribute*decorated*SerializableAttribute*not found.\");\n }\n\n [Fact]\n public void\n When_an_assembly_does_not_define_a_type_and_Should_DefineType_is_asserted_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act\n Action act = () => thisAssembly.Should().DefineType(\"FakeNamespace\", \"FakeName\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected assembly \\\"{thisAssembly.FullName}\\\" \" +\n \"to define type \\\"FakeNamespace\\\".\\\"FakeName\\\" \" +\n \"because we want to test the failure message, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_define_type_should_fail()\n {\n // Arrange\n Assembly thisAssembly = null;\n\n // Act\n Action act = () =>\n thisAssembly.Should().DefineType(GetType().Namespace, \"WellKnownClassWithAttribute\",\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected assembly to define type *.\\\"WellKnownClassWithAttribute\\\" *failure message*\" +\n \", but thisAssembly is .\");\n }\n\n [Fact]\n public void When_an_assembly_defining_a_type_with_a_null_name_it_should_throw()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act\n Action act = () => thisAssembly.Should().DefineType(GetType().Namespace, null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_an_assembly_defining_a_type_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act\n Action act = () => thisAssembly.Should().DefineType(GetType().Namespace, string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_an_assembly_is_null_and_Should_BeNull_is_asserted_it_should_succeed()\n {\n // Arrange\n Assembly thisAssembly = null;\n\n // Act / Assert\n thisAssembly\n .Should().BeNull();\n }\n }\n\n public class BeUnsigned\n {\n [Theory]\n [InlineData(null)]\n [InlineData(\"\")]\n public void Guards_for_unsigned_assembly(string noKey)\n {\n // Arrange\n var unsignedAssembly = FindAssembly.Stub(noKey);\n\n // Act & Assert\n unsignedAssembly.Should().BeUnsigned();\n }\n\n [Fact]\n public void Throws_for_signed_assembly()\n {\n // Arrange\n var signedAssembly = FindAssembly.Stub(\"0123456789ABCEF007\");\n\n // Act\n Action act = () => signedAssembly.Should().BeUnsigned(\"this assembly is never shipped\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the assembly * to be signed because this assembly is never shipped, but it is.\");\n }\n\n [Fact]\n public void Throws_for_null_subject()\n {\n // Arrange\n Assembly nullAssembly = null;\n\n // Act\n Action act = () => nullAssembly.Should().BeUnsigned();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Can't check for assembly signing if nullAssembly reference is .\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var unsignedAssembly = FindAssembly.Stub(\"\");\n\n // Act & Assert\n unsignedAssembly.Should().BeUnsigned().And.NotBeNull();\n }\n }\n\n public class BeSignedWithPublicKey\n {\n [Theory]\n [InlineData(\"0123456789ABCEF007\")]\n [InlineData(\"0123456789abcef007\")]\n [InlineData(\"0123456789ABcef007\")]\n public void Guards_for_signed_assembly_with_expected_public_key(string publicKey)\n {\n // Arrange\n var signedAssembly = FindAssembly.Stub(\"0123456789ABCEF007\");\n\n // Act & Assert\n signedAssembly.Should().BeSignedWithPublicKey(publicKey);\n }\n\n [Theory]\n [InlineData(null)]\n [InlineData(\"\")]\n public void Throws_for_unsigned_assembly(string noKey)\n {\n // Arrange\n var unsignedAssembly = FindAssembly.Stub(noKey);\n\n // Act\n Action act = () => unsignedAssembly.Should().BeSignedWithPublicKey(\"1234\", \"signing is part of the contract\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected assembly * to have public key \\\"1234\\\" because signing is part of the contract, but it is unsigned.\");\n }\n\n [Fact]\n public void Throws_signed_assembly_with_different_public_key()\n {\n // Arrange\n var signedAssembly = FindAssembly.Stub(\"0123456789ABCEF007\");\n\n // Act\n Action act = () => signedAssembly.Should().BeSignedWithPublicKey(\"1234\", \"signing is part of the contract\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected assembly * to have public key \\\"1234\\\" because signing is part of the contract, but it has * instead.\");\n }\n\n [Fact]\n public void Throws_for_null_assembly()\n {\n // Arrange\n Assembly nullAssembly = null;\n\n // Act\n Action act = () => nullAssembly.Should().BeSignedWithPublicKey(\"1234\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Can't check for assembly signing if nullAssembly reference is .\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var key = \"0123456789ABCEF007\";\n var signedAssembly = FindAssembly.Stub(key);\n\n // Act & Assert\n signedAssembly.Should().BeSignedWithPublicKey(key).And.NotBeNull();\n }\n }\n}\n\n[DummyClass(\"name\", true)]\npublic class WellKnownClassWithAttribute;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Events/EventAssertionSpecs.cs", "#if NET47\nusing System.Reflection.Emit;\n#endif\n\nusing System;\nusing System.ComponentModel;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Events;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Events;\n\n[Collection(\"EventMonitoring\")]\npublic class EventAssertionSpecs\n{\n public class ShouldRaise\n {\n [Fact]\n public void When_asserting_an_event_that_doesnt_exist_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitoredSubject = subject.Monitor();\n\n // Act\n // ReSharper disable once AccessToDisposedClosure\n Action act = () => monitoredSubject.Should().Raise(\"NonExistingEvent\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Not monitoring any events named \\\"NonExistingEvent\\\".\");\n }\n\n [Fact]\n public void When_asserting_that_an_event_was_not_raised_and_it_doesnt_exist_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n Action act = () => monitor.Should().NotRaise(\"NonExistingEvent\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Not monitoring any events named \\\"NonExistingEvent\\\".\");\n }\n\n [Fact]\n public void When_an_event_was_not_raised_it_should_throw_and_use_the_reason()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n Action act = () => monitor.Should().Raise(\"PropertyChanged\", \"{0} should cause the event to get raised\", \"Foo()\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected object \" + Formatter.ToString(subject) +\n \" to raise event \\\"PropertyChanged\\\" because Foo() should cause the event to get raised, but it did not.\");\n }\n\n [Fact]\n public void When_the_expected_event_was_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithoutSender();\n\n // Act / Assert\n monitor.Should().Raise(\"PropertyChanged\");\n }\n\n [Fact]\n public void When_an_unexpected_event_was_raised_it_should_throw_and_use_the_reason()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithoutSender();\n\n // Act\n Action act = () =>\n monitor.Should().NotRaise(\"PropertyChanged\", \"{0} should cause the event to get raised\", \"Foo()\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected object \" + Formatter.ToString(subject) +\n \" to not raise event \\\"PropertyChanged\\\" because Foo() should cause the event to get raised, but it did.\");\n }\n\n [Fact]\n public void When_an_unexpected_event_was_not_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act / Assert\n monitor.Should().NotRaise(\"PropertyChanged\");\n }\n\n [Fact]\n public void When_the_event_sender_is_not_the_expected_object_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithoutSender();\n\n // Act\n Action act = () => monitor.Should().Raise(\"PropertyChanged\").WithSender(subject);\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected sender {Formatter.ToString(subject)}, but found {{}}.\");\n }\n\n [Fact]\n public void When_the_event_sender_is_the_expected_object_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSender();\n\n // Act / Assert\n monitor.Should().Raise(\"PropertyChanged\").WithSender(subject);\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_WithArgs_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act\n Action act = () => monitor.Should()\n .Raise(\"NonConventionalEvent\")\n .WithArgs(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_the_event_parameters_dont_match_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithoutSender();\n\n // Act\n Action act = () => monitor\n .Should().Raise(\"PropertyChanged\")\n .WithArgs(args => args.PropertyName == \"SomeProperty\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected at least one event with some argument of type*PropertyChangedEventArgs*matches*(args.PropertyName == \\\"SomeProperty\\\"), but found none.\");\n }\n\n [Fact]\n public void When_the_event_args_are_of_a_different_type_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act\n Action act = () => monitor\n .Should().Raise(\"PropertyChanged\")\n .WithArgs(args => args.Cancel);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*event*argument*type*CancelEventArgs>*\");\n }\n\n [Fact]\n public void When_the_event_parameters_do_match_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act / Assert\n monitor\n .Should().Raise(\"PropertyChanged\")\n .WithArgs(args => args.PropertyName == \"SomeProperty\");\n }\n\n [Fact]\n public void When_running_in_parallel_it_should_not_throw()\n {\n // Arrange\n void Action(int _)\n {\n EventRaisingClass subject = new();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSender();\n monitor.Should().Raise(\"PropertyChanged\");\n }\n\n // Act\n Action act = () => Enumerable.Range(0, 1000)\n .AsParallel()\n .ForAll(Action);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_monitored_class_event_has_fired_it_should_be_possible_to_reset_the_event_monitor()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var eventMonitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act\n eventMonitor.Clear();\n\n // Assert\n eventMonitor.Should().NotRaise(\"PropertyChanged\");\n }\n\n [Fact]\n public void When_a_non_conventional_event_with_a_specific_argument_was_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act / Assert\n monitor\n .Should().Raise(\"NonConventionalEvent\")\n .WithArgs(args => args == \"third argument\");\n }\n\n [Fact]\n public void When_a_non_conventional_event_with_many_specific_arguments_was_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act / Assert\n monitor\n .Should().Raise(\"NonConventionalEvent\")\n .WithArgs(null, args => args == \"third argument\");\n }\n\n [Fact]\n public void When_a_predicate_based_parameter_assertion_expects_more_parameters_then_an_event_has_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act\n Action act = () => monitor\n .Should().Raise(nameof(EventRaisingClass.NonConventionalEvent))\n .WithArgs(null, null, null, args => args == \"fourth argument\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*4 parameters*String*, but*2*\");\n }\n\n [Fact]\n public void When_a_non_conventional_event_with_a_specific_argument_was_not_raised_it_should_throw()\n {\n // Arrange\n const int wrongArgument = 3;\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act\n Action act = () => monitor\n .Should().Raise(\"NonConventionalEvent\")\n .WithArgs(args => args == wrongArgument);\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"Expected at least one event with some argument*type*int*matches*(args == {wrongArgument})\" +\n \", but found none.\");\n }\n\n [Fact]\n public void When_a_non_conventional_event_with_many_specific_arguments_was_not_raised_it_should_throw()\n {\n // Arrange\n const string wrongArgument = \"not a third argument\";\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act\n Action act = () => monitor\n .Should().Raise(\"NonConventionalEvent\")\n .WithArgs(null, args => args == wrongArgument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected at least one event with some arguments*match*\\\"(args == \\\"\" + wrongArgument +\n \"\\\")\\\", but found none.\");\n }\n\n [Fact]\n public void When_a_specific_event_is_expected_it_should_return_only_relevant_events()\n {\n // Arrange\n var observable = new EventRaisingClass();\n using var monitor = observable.Monitor();\n\n // Act\n observable.RaiseEventWithSpecificSender(\"Foo\");\n observable.RaiseEventWithSpecificSender(\"Bar\");\n observable.RaiseNonConventionalEvent(\"don't care\", 123, \"don't care\");\n\n // Assert\n var recording = monitor\n .Should()\n .Raise(nameof(observable.PropertyChanged));\n\n recording.EventName.Should().Be(nameof(observable.PropertyChanged));\n recording.EventObject.Should().BeSameAs(observable);\n recording.EventHandlerType.Should().Be(typeof(PropertyChangedEventHandler));\n recording.Should().HaveCount(2, \"because only two property changed events were raised\");\n }\n\n [Fact]\n public void When_a_specific_sender_is_expected_it_should_return_only_relevant_events()\n {\n // Arrange\n var observable = new EventRaisingClass();\n using var monitor = observable.Monitor();\n\n // Act\n observable.RaiseEventWithSpecificSender(observable);\n observable.RaiseEventWithSpecificSender(new object());\n\n // Assert\n var recording = monitor\n .Should()\n .Raise(nameof(observable.PropertyChanged))\n .WithSender(observable);\n\n recording.Should().ContainSingle().Which.Parameters[0].Should().BeSameAs(observable);\n }\n\n [Fact]\n public void When_constraints_are_specified_it_should_filter_the_events_based_on_those_constraints()\n {\n // Arrange\n var observable = new EventRaisingClass();\n using var monitor = observable.Monitor();\n\n // Act\n observable.RaiseEventWithSenderAndPropertyName(\"Foo\");\n observable.RaiseEventWithSenderAndPropertyName(\"Boo\");\n\n // Assert\n var recording = monitor\n .Should()\n .Raise(nameof(observable.PropertyChanged))\n .WithSender(observable)\n .WithArgs(args => args.PropertyName == \"Boo\");\n\n recording\n .Should().ContainSingle(\"because we were expecting a specific property change\")\n .Which.Parameters[^1].Should().BeOfType()\n .Which.PropertyName.Should().Be(\"Boo\");\n }\n\n [Fact]\n public void When_events_are_raised_regardless_of_time_tick_it_should_return_by_invocation_order()\n {\n // Arrange\n var observable = new TestEventRaisingInOrder();\n\n using var monitor = observable.Monitor(conf =>\n conf.ConfigureTimestampProvider(() => 11.January(2022).At(12, 00).AsUtc()));\n\n // Act\n observable.RaiseAllEvents();\n\n // Assert\n monitor.OccurredEvents[0].EventName.Should().Be(nameof(TestEventRaisingInOrder.InterfaceEvent));\n monitor.OccurredEvents[0].Sequence.Should().Be(0);\n\n monitor.OccurredEvents[1].EventName.Should().Be(nameof(TestEventRaisingInOrder.Interface2Event));\n monitor.OccurredEvents[1].Sequence.Should().Be(1);\n\n monitor.OccurredEvents[2].EventName.Should().Be(nameof(TestEventRaisingInOrder.Interface3Event));\n monitor.OccurredEvents[2].Sequence.Should().Be(2);\n }\n\n [Fact]\n public void When_monitoring_a_class_it_should_be_possible_to_attach_to_additional_interfaces_on_the_same_object()\n {\n // Arrange\n var subject = new TestEventRaising();\n using var outerMonitor = subject.Monitor();\n using var innerMonitor = subject.Monitor();\n\n // Act\n subject.RaiseBothEvents();\n\n // Assert\n outerMonitor.Should().Raise(\"InterfaceEvent\");\n innerMonitor.Should().Raise(\"Interface2Event\");\n }\n }\n\n public class ShouldRaisePropertyChanged\n {\n [Fact]\n public void When_a_property_changed_event_was_raised_for_the_expected_property_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n subject.RaiseEventWithSenderAndPropertyName(\"SomeOtherProperty\");\n\n // Act / Assert\n monitor.Should().RaisePropertyChangeFor(x => x.SomeProperty);\n }\n\n [Fact]\n public void When_an_expected_property_changed_event_was_raised_for_all_properties_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(null);\n\n // Act / Assert\n monitor.Should().RaisePropertyChangeFor(null);\n }\n\n [Fact]\n public void When_a_property_changed_event_for_a_specific_property_was_not_raised_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n Action act = () => monitor.Should().RaisePropertyChangeFor(x => x.SomeProperty, \"the property was changed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected object \" + Formatter.ToString(subject) +\n \" to raise event \\\"PropertyChanged\\\" for property \\\"SomeProperty\\\" because the property was changed, but it did not*\");\n }\n\n [Fact]\n public void When_a_property_agnostic_property_changed_event_for_was_not_raised_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n monitor.Should().RaisePropertyChangeFor(null);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected object \" + Formatter.ToString(subject) +\n \" to raise event \\\"PropertyChanged\\\" for property , but it did not*\");\n }\n\n [Fact]\n public void\n When_the_property_changed_event_was_raised_for_the_wrong_property_it_should_throw_and_include_the_actual_properties_raised()\n {\n // Arrange\n var bar = new EventRaisingClass();\n using var monitor = bar.Monitor();\n bar.RaiseEventWithSenderAndPropertyName(\"OtherProperty1\");\n bar.RaiseEventWithSenderAndPropertyName(\"OtherProperty2\");\n bar.RaiseEventWithSenderAndPropertyName(\"OtherProperty2\");\n\n // Act\n Action act = () => monitor.Should().RaisePropertyChangeFor(b => b.SomeProperty);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*property*SomeProperty*but*OtherProperty1*OtherProperty2*\");\n }\n\n [Fact]\n public void\n The_number_of_property_changed_recorded_for_a_specific_property_matches_the_number_of_times_it_was_raised_specifically()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeProperty));\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeProperty));\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeOtherProperty));\n\n // Act\n monitor.Should().RaisePropertyChangeFor(x => x.SomeProperty).Should().HaveCount(2);\n }\n\n [Fact]\n public void\n The_number_of_property_changed_recorded_for_a_specific_property_matches_the_number_of_times_it_was_raised_including_agnostic_property()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeProperty));\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeOtherProperty));\n subject.RaiseEventWithSenderAndPropertyName(null);\n subject.RaiseEventWithSenderAndPropertyName(string.Empty);\n\n // Act\n monitor.Should().RaisePropertyChangeFor(x => x.SomeProperty).Should().HaveCount(3);\n }\n\n [Fact]\n public void\n The_number_of_property_changed_recorded_matches_the_number_of_times_it_was_raised()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeProperty));\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeOtherProperty));\n subject.RaiseEventWithSenderAndPropertyName(null);\n subject.RaiseEventWithSenderAndPropertyName(string.Empty);\n\n // Act\n monitor.Should().RaisePropertyChangeFor(null).Should().HaveCount(4);\n }\n }\n\n public class ShouldNotRaisePropertyChanged\n {\n [Fact]\n public void When_a_property_changed_event_was_raised_by_monitored_class_it_should_be_possible_to_reset_the_event_monitor()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var eventMonitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act\n eventMonitor.Clear();\n\n // Assert\n eventMonitor.Should().NotRaisePropertyChangeFor(e => e.SomeProperty);\n }\n\n [Fact]\n public void When_a_property_changed_event_for_an_unexpected_property_was_raised_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act\n Action act = () => monitor.Should().NotRaisePropertyChangeFor(x => x.SomeProperty, \"nothing happened\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect object \" + Formatter.ToString(subject) +\n \" to raise the \\\"PropertyChanged\\\" event for property \\\"SomeProperty\\\" because nothing happened, but it did.\");\n }\n\n [Fact]\n public void When_a_property_changed_event_for_another_than_the_unexpected_property_was_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeOtherProperty\");\n\n // Act / Assert\n monitor.Should().NotRaisePropertyChangeFor(x => x.SomeProperty);\n }\n\n [Fact]\n public void Throw_for_an_agnostic_property_when_any_property_changed_is_recorded()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeOtherProperty));\n\n // Act\n Action act = () => monitor.Should().NotRaisePropertyChangeFor(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect object \" + Formatter.ToString(subject) +\n \" to raise the \\\"PropertyChanged\\\" event, but it did.\");\n }\n\n [Fact]\n public void Throw_for_a_specific_property_when_an_agnostic_property_changed_is_recorded()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(null);\n\n // Act\n Action act = () => monitor.Should().NotRaisePropertyChangeFor(x => x.SomeProperty);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect object \" + Formatter.ToString(subject) +\n \" to raise the \\\"PropertyChanged\\\" event for property \\\"SomeProperty\\\", but it did.\");\n }\n }\n\n public class PreconditionChecks\n {\n [Fact]\n public void When_monitoring_a_null_object_it_should_throw()\n {\n // Arrange\n EventRaisingClass subject = null;\n\n // Act\n Action act = () => subject.Monitor();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot monitor the events of a object*\");\n }\n\n [Fact]\n public void When_nesting_monitoring_requests_scopes_should_be_isolated()\n {\n // Arrange\n var eventSource = new EventRaisingClass();\n using var outerScope = eventSource.Monitor();\n\n // Act\n using var innerScope = eventSource.Monitor();\n\n // Assert\n ((object)innerScope).Should().NotBeSameAs(outerScope);\n }\n\n [Fact]\n public void When_monitoring_an_object_with_invalid_property_expression_it_should_throw()\n {\n // Arrange\n var eventSource = new EventRaisingClass();\n using var monitor = eventSource.Monitor();\n Func func = e => e.SomeOtherProperty;\n\n // Act\n Action act = () => monitor.Should().RaisePropertyChangeFor(e => func(e));\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expression\");\n }\n\n [Fact]\n public void Event_assertions_should_expose_the_monitor()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n var exposedMonitor = monitor.Should().Monitor;\n\n // Assert\n ((object)exposedMonitor).Should().BeSameAs(monitor);\n }\n }\n\n public class Metadata\n {\n [Fact]\n public void When_monitoring_an_object_it_should_monitor_all_the_events_it_exposes()\n {\n // Arrange\n var eventSource = new ClassThatRaisesEventsItself();\n using var eventMonitor = eventSource.Monitor();\n\n // Act\n EventMetadata[] metadata = eventMonitor.MonitoredEvents;\n\n // Assert\n metadata.Should().BeEquivalentTo(\n [\n new\n {\n EventName = nameof(ClassThatRaisesEventsItself.InterfaceEvent),\n HandlerType = typeof(EventHandler)\n },\n new\n {\n EventName = nameof(ClassThatRaisesEventsItself.PropertyChanged),\n HandlerType = typeof(PropertyChangedEventHandler)\n }\n ]);\n }\n\n [Fact]\n public void When_monitoring_an_object_through_an_interface_it_should_monitor_only_the_events_it_exposes()\n {\n // Arrange\n var eventSource = new ClassThatRaisesEventsItself();\n using var monitor = eventSource.Monitor();\n\n // Act\n EventMetadata[] metadata = monitor.MonitoredEvents;\n\n // Assert\n metadata.Should().BeEquivalentTo(\n [\n new\n {\n EventName = nameof(IEventRaisingInterface.InterfaceEvent),\n HandlerType = typeof(EventHandler)\n }\n ]);\n }\n\n#if NETFRAMEWORK // DefineDynamicAssembly is obsolete in .NET Core\n [Fact]\n public void When_an_object_doesnt_expose_any_events_it_should_throw()\n {\n // Arrange\n object eventSource = CreateProxyObject();\n\n // Act\n Action act = () => eventSource.Monitor();\n\n // Assert\n act.Should().Throw().WithMessage(\"*not expose any events*\");\n }\n\n [Fact]\n public void When_monitoring_interface_of_a_class_and_no_recorder_exists_for_an_event_it_should_throw()\n {\n // Arrange\n var eventSource = (IEventRaisingInterface)CreateProxyObject();\n using var eventMonitor = eventSource.Monitor();\n\n // Act\n Action action = () => eventMonitor.GetRecordingFor(\"SomeEvent\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Not monitoring any events named \\\"SomeEvent\\\".\");\n }\n\n private object CreateProxyObject()\n {\n Type baseType = typeof(EventRaisingClass);\n Type interfaceType = typeof(IEventRaisingInterface);\n\n AssemblyName assemblyName = new() { Name = baseType.Assembly.FullName + \".GeneratedForTest\" };\n\n AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName,\n AssemblyBuilderAccess.Run);\n\n ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, false);\n string typeName = baseType.Name + \"_GeneratedForTest\";\n\n TypeBuilder typeBuilder =\n moduleBuilder.DefineType(typeName, TypeAttributes.Public, baseType, [interfaceType]);\n\n MethodBuilder addHandler = EmitAddRemoveEventHandler(\"add\");\n typeBuilder.DefineMethodOverride(addHandler, interfaceType.GetMethod(\"add_InterfaceEvent\"));\n MethodBuilder removeHandler = EmitAddRemoveEventHandler(\"remove\");\n typeBuilder.DefineMethodOverride(removeHandler, interfaceType.GetMethod(\"remove_InterfaceEvent\"));\n\n Type generatedType = typeBuilder.CreateType();\n return Activator.CreateInstance(generatedType);\n\n MethodBuilder EmitAddRemoveEventHandler(string methodName)\n {\n MethodBuilder method =\n typeBuilder.DefineMethod($\"{interfaceType.FullName}.{methodName}_InterfaceEvent\",\n MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.Final |\n MethodAttributes.HideBySig |\n MethodAttributes.NewSlot);\n\n method.SetReturnType(typeof(void));\n method.SetParameters(typeof(EventHandler));\n ILGenerator gen = method.GetILGenerator();\n gen.Emit(OpCodes.Ret);\n return method;\n }\n }\n\n#endif\n\n [Fact]\n public void When_event_exists_on_class_but_not_on_monitored_interface_it_should_not_allow_monitoring_it()\n {\n // Arrange\n var eventSource = new ClassThatRaisesEventsItself();\n using var eventMonitor = eventSource.Monitor();\n\n // Act\n Action action = () => eventMonitor.GetRecordingFor(\"PropertyChanged\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Not monitoring any events named \\\"PropertyChanged\\\".\");\n }\n\n [Fact]\n public void When_an_object_raises_two_events_it_should_provide_the_data_about_those_occurrences()\n {\n // Arrange\n DateTime utcNow = 17.September(2017).At(21, 00).AsUtc();\n\n var eventSource = new EventRaisingClass();\n using var monitor = eventSource.Monitor(opt => opt.ConfigureTimestampProvider(() => utcNow));\n\n // Act\n eventSource.RaiseEventWithSenderAndPropertyName(\"theProperty\");\n\n utcNow += 1.Hours();\n\n eventSource.RaiseNonConventionalEvent(\"first\", 123, \"third\");\n\n // Assert\n monitor.OccurredEvents.Should().BeEquivalentTo(\n [\n new\n {\n EventName = \"PropertyChanged\",\n TimestampUtc = utcNow - 1.Hours(),\n Parameters = new object[] { eventSource, new PropertyChangedEventArgs(\"theProperty\") }\n },\n new\n {\n EventName = \"NonConventionalEvent\",\n TimestampUtc = utcNow,\n Parameters = new object[] { \"first\", 123, \"third\" }\n }\n ], o => o.WithStrictOrdering());\n }\n\n [Fact]\n public void When_monitoring_interface_with_inherited_event_it_should_not_throw()\n {\n // Arrange\n var eventSource = (IInheritsEventRaisingInterface)new ClassThatRaisesEventsItself();\n\n // Act\n Action action = () => eventSource.Monitor();\n\n // Assert\n action.Should().NotThrow();\n }\n }\n\n public class WithArgs\n {\n [Fact]\n public void One_matching_argument_type_before_mismatching_types_passes()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new B());\n a.OnEvent(new C());\n\n // Act / Assert\n IEventRecording filteredEvents = aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs();\n filteredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void One_matching_argument_type_after_mismatching_types_passes()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new B());\n\n // Act / Assert\n IEventRecording filteredEvents = aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs();\n filteredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void Throws_when_none_of_the_arguments_are_of_the_expected_type()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new C());\n\n // Act\n Action act = () => aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*event*argument*\");\n }\n\n [Fact]\n public void One_matching_argument_type_anywhere_between_mismatching_types_passes()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new B());\n a.OnEvent(new C());\n\n // Act / Assert\n IEventRecording filteredEvents = aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs();\n filteredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void One_matching_argument_type_anywhere_between_mismatching_types_with_parameters_passes()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new B());\n a.OnEvent(new C());\n\n // Act / Assert\n IEventRecording filteredEvents = aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs(_ => true);\n filteredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void Mismatching_argument_types_with_one_parameter_matching_a_different_type_fails()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new C());\n\n // Act\n Action act = () => aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs(_ => true);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*event*argument*type*B*none*\");\n }\n\n [Fact]\n public void Mismatching_argument_types_with_two_or_more_parameters_matching_a_different_type_fails()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new C());\n\n // Act\n Action act = () => aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs(_ => true, _ => false);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*event*parameters*type*B*found*\");\n }\n\n [Fact]\n public void One_matching_argument_type_with_two_or_more_parameters_matching_a_mismatching_type_fails()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new B());\n\n // Act\n Action act = () => aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs(_ => true, _ => false);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*event*parameters*type*B*found*\");\n }\n }\n\n public class MonitorDefaultBehavior\n {\n [Fact]\n public void Broken_event_add_accessors_fails()\n {\n // Arrange\n var sut = new TestEventBrokenEventHandlerRaising();\n\n // Act / Assert\n sut.Invoking(c =>\n {\n using var monitor = c.Monitor();\n }).Should().Throw();\n }\n\n [Fact]\n public void Broken_event_remove_accessors_fails()\n {\n // Arrange\n var sut = new TestEventBrokenEventHandlerRaising();\n\n // Act / Assert\n sut.Invoking(c =>\n {\n using var monitor = c.Monitor();\n }).Should().Throw();\n }\n }\n\n public class IgnoreMisbehavingEventAccessors\n {\n [Fact]\n public void Monitoring_class_with_broken_event_add_accessor_succeeds()\n {\n // Arrange\n var classToMonitor = new TestEventBrokenEventHandlerRaising();\n\n // Act / Assert\n classToMonitor.Invoking(c =>\n {\n using var monitor = c.Monitor(opt => opt.IgnoringEventAccessorExceptions());\n }).Should().NotThrow();\n }\n\n [Fact]\n public void Class_with_broken_event_remove_accessor_succeeds()\n {\n // Arrange\n var classToMonitor = new TestEventBrokenEventHandlerRaising();\n\n // Act / Assert\n classToMonitor.Invoking(c =>\n {\n using var monitor = c.Monitor(opt => opt.IgnoringEventAccessorExceptions());\n }).Should().NotThrow();\n }\n\n [Fact]\n public void Recording_event_with_broken_add_accessor_succeeds()\n {\n // Arrange\n var classToMonitor = new TestEventBrokenEventHandlerRaising();\n\n using var monitor =\n classToMonitor.Monitor(opt =>\n opt.IgnoringEventAccessorExceptions().RecordingEventsWithBrokenAccessor());\n\n //Act\n classToMonitor.RaiseOkEvent();\n\n //Assert\n monitor.MonitoredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void Ignoring_broken_event_accessor_should_also_not_record_events()\n {\n // Arrange\n var classToMonitor = new TestEventBrokenEventHandlerRaising();\n\n using var monitor = classToMonitor.Monitor(opt => opt.IgnoringEventAccessorExceptions());\n\n //Act\n classToMonitor.RaiseOkEvent();\n\n //Assert\n monitor.MonitoredEvents.Should().BeEmpty();\n }\n }\n\n private interface IAddOkEvent\n {\n event EventHandler OkEvent;\n }\n\n private interface IAddFailingRecordableEvent\n {\n public event EventHandler AddFailingRecorableEvent;\n }\n\n private interface IAddFailingEvent\n {\n public event EventHandler AddFailingEvent;\n }\n\n private interface IRemoveFailingEvent\n {\n public event EventHandler RemoveFailingEvent;\n }\n\n private class TestEventBrokenEventHandlerRaising\n : IAddFailingEvent, IRemoveFailingEvent, IAddOkEvent, IAddFailingRecordableEvent\n {\n public event EventHandler AddFailingEvent\n {\n add => throw new InvalidOperationException(\"Add is failing\");\n remove => OkEvent -= value;\n }\n\n public event EventHandler AddFailingRecorableEvent\n {\n add\n {\n OkEvent += value;\n throw new InvalidOperationException(\"Add is failing\");\n }\n\n remove => OkEvent -= value;\n }\n\n public event EventHandler OkEvent;\n\n public event EventHandler RemoveFailingEvent\n {\n add => OkEvent += value;\n remove => throw new InvalidOperationException(\"Remove is failing\");\n }\n\n public void RaiseOkEvent()\n {\n OkEvent?.Invoke(this, EventArgs.Empty);\n }\n }\n\n public class A\n {\n#pragma warning disable MA0046\n public event EventHandler Event;\n#pragma warning restore MA0046\n\n public void OnEvent(object o)\n {\n Event.Invoke(nameof(A), o);\n }\n }\n\n public class B;\n\n public class C;\n\n public class ClassThatRaisesEventsItself : IInheritsEventRaisingInterface\n {\n#pragma warning disable RCS1159\n public event PropertyChangedEventHandler PropertyChanged;\n#pragma warning restore RCS1159\n\n public event EventHandler InterfaceEvent;\n\n protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)\n {\n PropertyChanged?.Invoke(this, e);\n }\n\n protected virtual void OnInterfaceEvent()\n {\n InterfaceEvent?.Invoke(this, EventArgs.Empty);\n }\n }\n\n public class TestEventRaising : IEventRaisingInterface, IEventRaisingInterface2\n {\n public event EventHandler InterfaceEvent;\n\n public event EventHandler Interface2Event;\n\n public void RaiseBothEvents()\n {\n InterfaceEvent?.Invoke(this, EventArgs.Empty);\n Interface2Event?.Invoke(this, EventArgs.Empty);\n }\n }\n\n private class TestEventRaisingInOrder : IEventRaisingInterface, IEventRaisingInterface2, IEventRaisingInterface3\n {\n public event EventHandler Interface3Event;\n\n public event EventHandler Interface2Event;\n\n public event EventHandler InterfaceEvent;\n\n public void RaiseAllEvents()\n {\n InterfaceEvent?.Invoke(this, EventArgs.Empty);\n Interface2Event?.Invoke(this, EventArgs.Empty);\n Interface3Event?.Invoke(this, EventArgs.Empty);\n }\n }\n\n public interface IEventRaisingInterface\n {\n event EventHandler InterfaceEvent;\n }\n\n public interface IEventRaisingInterface2\n {\n event EventHandler Interface2Event;\n }\n\n public interface IEventRaisingInterface3\n {\n event EventHandler Interface3Event;\n }\n\n public interface IInheritsEventRaisingInterface : IEventRaisingInterface;\n\n public class EventRaisingClass : INotifyPropertyChanged\n {\n public string SomeProperty { get; set; }\n\n public int SomeOtherProperty { get; set; }\n\n public event PropertyChangedEventHandler PropertyChanged = (_, _) => { };\n\n#pragma warning disable MA0046\n public event Action NonConventionalEvent = (_, _, _) => { };\n#pragma warning restore MA0046\n\n public void RaiseNonConventionalEvent(string first, int second, string third)\n {\n NonConventionalEvent.Invoke(first, second, third);\n }\n\n public void RaiseEventWithoutSender()\n {\n#pragma warning disable AV1235, MA0091 // 'sender' is deliberately null\n PropertyChanged(null, new PropertyChangedEventArgs(\"\"));\n#pragma warning restore AV1235, MA0091\n }\n\n public void RaiseEventWithSender()\n {\n PropertyChanged(this, new PropertyChangedEventArgs(\"\"));\n }\n\n public void RaiseEventWithSpecificSender(object sender)\n {\n#pragma warning disable MA0091\n PropertyChanged(sender, new PropertyChangedEventArgs(\"\"));\n#pragma warning restore MA0091\n }\n\n public void RaiseEventWithSenderAndPropertyName(string propertyName)\n {\n PropertyChanged(this, new PropertyChangedEventArgs(propertyName));\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/GenericAsyncFunctionAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an asynchronous method yields the expected result.\n/// \n/// The type returned in the .\npublic class GenericAsyncFunctionAssertions\n : AsyncFunctionAssertions, GenericAsyncFunctionAssertions>\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public GenericAsyncFunctionAssertions(Func> subject, IExtractExceptions extractor, AssertionChain assertionChain)\n : this(subject, extractor, assertionChain, new Clock())\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Initializes a new instance of the class with custom .\n /// \n public GenericAsyncFunctionAssertions(Func> subject, IExtractExceptions extractor, AssertionChain assertionChain,\n IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current will complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task, TResult>> CompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n (Task task, TimeSpan remainingTime) = InvokeWithTimer(timeSpan);\n\n assertionChain\n .ForCondition(remainingTime >= TimeSpan.Zero)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(task, remainingTime, _ => Task.CompletedTask);\n\n assertionChain\n .ForCondition(completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n\n#pragma warning disable CA1849 // Call async methods when in an async method\n TResult result = assertionChain.Succeeded ? task.Result : default;\n#pragma warning restore CA1849 // Call async methods when in an async method\n return new AndWhichConstraint, TResult>(this, result, assertionChain, \".Result\");\n }\n\n return new AndWhichConstraint, TResult>(this, default(TResult));\n }\n\n /// \n /// Asserts that the current does not throw any exception.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task, TResult>> NotThrowAsync(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n try\n {\n TResult result = await Subject!.Invoke();\n return new AndWhichConstraint, TResult>(this, result, assertionChain, \".Result\");\n }\n catch (Exception exception)\n {\n _ = NotThrowInternal(exception, because, becauseArgs);\n }\n }\n\n return new AndWhichConstraint, TResult>(this, default(TResult));\n }\n\n /// \n /// Asserts that the current stops throwing any exception\n /// after a specified amount of time.\n /// \n /// \n /// The is invoked. If it raises an exception,\n /// the invocation is repeated until it either stops raising any exceptions\n /// or the specified wait time is exceeded.\n /// \n /// \n /// The time after which the should have stopped throwing any exception.\n /// \n /// \n /// The time between subsequent invocations of the .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// or are negative.\n public Task, TResult>> NotThrowAfterAsync(\n TimeSpan waitTime, TimeSpan pollInterval, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(waitTime);\n Guard.ThrowIfArgumentIsNegative(pollInterval);\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw any exceptions after {0}{reason}, but found .\", waitTime);\n\n if (assertionChain.Succeeded)\n {\n return AssertionTaskAsync();\n\n async Task, TResult>> AssertionTaskAsync()\n {\n TimeSpan? invocationEndTime = null;\n Exception exception = null;\n Common.ITimer timer = Clock.StartTimer();\n\n while (invocationEndTime is null || invocationEndTime < waitTime)\n {\n try\n {\n TResult result = await Subject.Invoke();\n return new AndWhichConstraint, TResult>(this, result, assertionChain, \".Result\");\n }\n catch (Exception ex)\n {\n exception = ex;\n await Clock.DelayAsync(pollInterval, CancellationToken.None);\n invocationEndTime = timer.Elapsed;\n }\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exceptions after {0}{reason}, but found {1}.\", waitTime, exception);\n\n return new AndWhichConstraint, TResult>(this, default(TResult));\n }\n }\n\n return Task.FromResult(new AndWhichConstraint, TResult>(this, default(TResult)));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/TaskAssertionSpecs.cs", "using System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\nusing static AwesomeAssertions.FluentActions;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic static class TaskAssertionSpecs\n{\n public class Extension\n {\n [Fact]\n public void When_getting_the_subject_it_should_remain_unchanged()\n {\n // Arrange\n Func> subject = () => Task.FromResult(42);\n\n // Act\n Action action = () => subject.Should().Subject.As().Should().BeSameAs(subject);\n\n // Assert\n action.Should().NotThrow(\"the Subject should remain the same\");\n }\n }\n\n public class NotThrow\n {\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n Func> subject = () => Task.FromResult(42);\n\n // Act\n Action action = () => subject.Should().Subject.As().Should().BeSameAs(subject);\n\n // Assert\n action.Should().NotThrow(\"the Subject should remain the same\").And.NotBeNull();\n }\n }\n\n public class NotThrowAfter\n {\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n Func> subject = () => Task.FromResult(42);\n\n // Act\n Action action = () => subject.Should().Subject.As().Should().BeSameAs(subject);\n\n // Assert\n action.Should().NotThrowAfter(1.Seconds(), 1.Seconds()).And.NotBeNull();\n }\n }\n\n public class CompleteWithinAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_throw()\n {\n // Arrange\n var timeSpan = 0.Milliseconds();\n Func action = null;\n\n // Act\n Func testAction = () => action.Should().CompleteWithinAsync(\n timeSpan, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_task_completes_fast_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n taskFactory.Awaiting(t => (Task)t.Task).Should(timer).CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_consumes_time_in_sync_portion_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t =>\n {\n // simulate sync work longer than accepted time\n timer.Delay(101.Milliseconds());\n return (Task)t.Task;\n })\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_completes_late_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n taskFactory.Awaiting(t => (Task)t.Task).Should(timer).CompleteWithinAsync(100.Milliseconds());\n\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Canceled_tasks_are_also_completed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Excepted_tasks_unexpectedly_completed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class NotCompleteWithinAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_throw()\n {\n // Arrange\n var timeSpan = 0.Milliseconds();\n Func action = null;\n\n // Act\n Func testAction = () => action.Should().NotCompleteWithinAsync(\n timeSpan, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_task_completes_fast_it_should_throw()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task).Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_consumes_time_in_sync_portion_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t =>\n {\n // simulate sync work longer than accepted time\n timer.Delay(101.Milliseconds());\n return (Task)t.Task;\n })\n .Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_completes_late_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task).Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Canceled_tasks_are_also_completed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task).Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Excepted_tasks_unexpectedly_completed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task).Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class ThrowAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = () => action.Should().ThrowAsync(\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_subject_is_null_in_assertion_scope_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().ThrowAsync(\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_task_throws_it_should_succeed()\n {\n // Act\n Func action = () =>\n {\n return\n Awaiting(() => Task.FromException(new InvalidOperationException(\"foo\")))\n .Should().ThrowAsync();\n };\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_throws_unexpected_exception_it_should_fail()\n {\n // Act\n Func action = () =>\n {\n return\n Awaiting(() => Task.FromException(new NotSupportedException(\"foo\")))\n .Should().ThrowAsync();\n };\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown,\"\n + \" but found :*foo*\");\n }\n\n [Fact]\n public async Task When_task_completes_without_exception_it_should_fail()\n {\n // Act\n Func action = () =>\n {\n return\n Awaiting(() => Task.CompletedTask)\n .Should().ThrowAsync();\n };\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown, but no exception was thrown.\");\n }\n }\n\n public class ThrowWithinAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = () => action.Should().ThrowWithinAsync(\n 100.Milliseconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_subject_is_null_in_assertion_scope_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().ThrowWithinAsync(\n 100.Milliseconds(), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Theory]\n [InlineData(99)]\n [InlineData(100)]\n public async Task When_task_throws_fast_it_should_succeed(int delay)\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(100.Ticks());\n };\n\n timer.Delay(delay.Ticks());\n taskFactory.SetException(new InvalidOperationException(\"foo\"));\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_throws_slow_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(100.Ticks());\n };\n\n timer.Delay(101.Ticks());\n taskFactory.SetException(new InvalidOperationException(\"foo\"));\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_throws_asynchronous_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return Awaiting(() => (Task)taskFactory.Task)\n .Should(timer).ThrowWithinAsync(1.Seconds());\n };\n\n _ = action.Invoke();\n taskFactory.SetException(new InvalidOperationException(\"foo\"));\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_not_completes_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(\n 100.Ticks(), \"because we want to test the failure {0}\", \"message\");\n };\n\n timer.Delay(101.Ticks());\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown within 10.0µs\"\n + \" because we want to test the failure message,\"\n + \" but no exception was thrown.\");\n }\n\n [Fact]\n public async Task When_task_completes_without_exception_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(100.Milliseconds());\n };\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown within 100ms, but no exception was thrown.\");\n }\n\n [Fact]\n public async Task When_task_throws_unexpected_exception_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(100.Milliseconds());\n };\n\n taskFactory.SetException(new NotSupportedException(\"foo\"));\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown within 100ms,\"\n + \" but found :*foo*\");\n }\n\n [Fact]\n public async Task When_task_throws_unexpected_exception_asynchronous_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return Awaiting(() => (Task)taskFactory.Task)\n .Should(timer).ThrowWithinAsync(1.Seconds());\n };\n\n _ = action.Invoke();\n taskFactory.SetException(new NotSupportedException(\"foo\"));\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown within 1s,\"\n + \" but found :*foo*\");\n }\n\n [Fact]\n public async Task When_task_is_canceled_before_timeout_it_succeeds()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return Awaiting(() => (Task)taskFactory.Task)\n .Should(timer).ThrowWithinAsync(1.Seconds());\n };\n\n _ = action.Invoke();\n\n taskFactory.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_is_canceled_after_timeout_it_fails()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return Awaiting(() => (Task)taskFactory.Task)\n .Should(timer).ThrowWithinAsync(1.Seconds());\n };\n\n _ = action.Invoke();\n\n timer.Delay(1.Seconds());\n taskFactory.SetCanceled();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class ThrowExactlyAsync\n {\n [Fact]\n public async Task Does_not_continue_assertion_on_exact_exception_type()\n {\n // Arrange\n var a = () => Task.Delay(1);\n\n // Act\n using var scope = new AssertionScope();\n await a.Should().ThrowExactlyAsync();\n\n // Assert\n scope.Discard().Should().ContainSingle()\n .Which.Should().Match(\"*InvalidOperationException*no exception*\");\n }\n }\n\n [Collection(\"UIFacts\")]\n public class CompleteWithinAsyncUIFacts\n {\n [UIFact]\n public async Task When_task_completes_fast_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n taskFactory.Awaiting(t => (Task)t.Task).Should(timer).CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [UIFact]\n public async Task When_task_completes_late_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n taskFactory.Awaiting(t => (Task)t.Task).Should(timer).CompleteWithinAsync(100.Milliseconds());\n\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [UIFact]\n public async Task When_task_is_checking_synchronization_context_it_should_succeed()\n {\n // Arrange\n Func task = CheckContextAsync;\n\n // Act\n Func action = () => this.Awaiting(_ => task()).Should().CompleteWithinAsync(1.Seconds());\n\n // Assert\n await action.Should().NotThrowAsync();\n\n async Task CheckContextAsync()\n {\n await Task.Delay(1);\n SynchronizationContext.Current.Should().NotBeNull();\n }\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventAssertions.cs", "using System;\nusing System.ComponentModel;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Provides convenient assertion methods on a that can be\n/// used to assert that certain events have been raised.\n/// \npublic class EventAssertions : ReferenceTypeAssertions>\n{\n private const string PropertyChangedEventName = nameof(INotifyPropertyChanged.PropertyChanged);\n private readonly AssertionChain assertionChain;\n\n protected internal EventAssertions(IMonitor monitor, AssertionChain assertionChain)\n : base(monitor.Subject, assertionChain)\n {\n this.assertionChain = assertionChain;\n Monitor = monitor;\n }\n\n /// \n /// Gets the which is being asserted.\n /// \n public IMonitor Monitor { get; }\n\n /// \n /// Asserts that an object has raised a particular event at least once.\n /// \n /// \n /// The name of the event that should have been raised.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public IEventRecording Raise(string eventName, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n IEventRecording recording = Monitor.GetRecordingFor(eventName);\n\n if (!recording.Any())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected object {0} to raise event {1}{reason}, but it did not.\", Monitor.Subject, eventName);\n }\n\n return recording;\n }\n\n /// \n /// Asserts that an object has not raised a particular event.\n /// \n /// \n /// The name of the event that should not be raised.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public void NotRaise(string eventName, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n IEventRecording events = Monitor.GetRecordingFor(eventName);\n\n if (events.Any())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected object {0} to not raise event {1}{reason}, but it did.\", Monitor.Subject, eventName);\n }\n }\n\n /// \n /// Asserts that an object has raised the event for a particular property.\n /// \n /// \n /// A lambda expression referring to the property for which the property changed event should have been raised, or\n /// to refer to all properties.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Returns only the events having arguments of type targeting the property.\n /// \n public IEventRecording RaisePropertyChangeFor(Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n string propertyName = propertyExpression?.GetPropertyInfo().Name;\n\n IEventRecording recording = Monitor.GetRecordingFor(PropertyChangedEventName);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(recording.Any())\n .FailWith(\n \"Expected object {0} to raise event {1} for property {2}{reason}, but it did not raise that event at all.\",\n Monitor.Subject, PropertyChangedEventName, propertyName);\n\n if (assertionChain.Succeeded)\n {\n var actualPropertyNames = recording\n .SelectMany(@event => @event.Parameters.OfType())\n .Select(eventArgs => eventArgs.PropertyName)\n .Distinct()\n .ToArray();\n\n assertionChain\n .ForCondition(actualPropertyNames.Contains(propertyName))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected object {0} to raise event {1} for property {2}{reason}, but it was only raised for {3}.\",\n Monitor.Subject, PropertyChangedEventName, propertyName, actualPropertyNames);\n }\n\n return recording.WithPropertyChangeFor(propertyName);\n }\n\n /// \n /// Asserts that an object has not raised the event for a particular property.\n /// \n /// \n /// A lambda expression referring to the property for which the property changed event should have been raised.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public void NotRaisePropertyChangeFor(Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n IEventRecording recording = Monitor.GetRecordingFor(PropertyChangedEventName);\n\n string propertyName = propertyExpression?.GetPropertyInfo().Name;\n\n if (propertyName is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!recording.Any())\n .FailWith(\n \"Did not expect object {0} to raise the {1} event{reason}, but it did.\",\n Monitor.Subject, PropertyChangedEventName);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!recording.Any(@event => @event.IsAffectingPropertyName(propertyName)))\n .FailWith(\n \"Did not expect object {0} to raise the {1} event for property {2}{reason}, but it did.\",\n Monitor.Subject, PropertyChangedEventName, propertyName);\n }\n }\n\n protected override string Identifier => \"subject\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeSelectorSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Types;\nusing Internal.AbstractAndNotAbstractClasses.Test;\nusing Internal.InterfaceAndClasses.Test;\nusing Internal.Main.Test;\nusing Internal.NotOnlyClasses.Test;\nusing Internal.Other.Test;\nusing Internal.Other.Test.Common;\nusing Internal.SealedAndNotSealedClasses.Test;\nusing Internal.StaticAndNonStaticClasses.Test;\nusing Internal.UnwrapSelectorTestTypes.Test;\nusing Internal.ValueTypesAndNotValueTypes.Test;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Types\n{\n public class TypeSelectorSpecs\n {\n [Fact]\n public void When_type_selector_is_created_with_a_null_type_it_should_throw()\n {\n // Arrange\n TypeSelector propertyInfoSelector;\n\n // Act\n Action act = () => propertyInfoSelector = new TypeSelector((Type)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_type_selector_is_created_with_a_null_type_list_it_should_throw()\n {\n // Arrange\n TypeSelector propertyInfoSelector;\n\n // Act\n Action act = () => propertyInfoSelector = new TypeSelector((Type[])null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_type_selector_is_null_then_should_should_throw()\n {\n // Arrange\n TypeSelector propertyInfoSelector = null;\n\n // Act\n var act = () => propertyInfoSelector.Should();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"typeSelector\");\n }\n\n [Fact]\n public void When_selecting_types_that_derive_from_a_specific_class_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassDerivedFromSomeBaseClass).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatDeriveFrom();\n\n // Assert\n types.Should().ContainSingle()\n .Which.Should().Be(typeof(ClassDerivedFromSomeBaseClass));\n }\n\n [Fact]\n public void When_selecting_types_that_derive_from_a_specific_generic_class_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassDerivedFromSomeGenericBaseClass).Assembly;\n\n // Act\n TypeSelector types = AllTypes.From(assembly).ThatDeriveFrom>();\n\n // Assert\n types.ToArray().Should().ContainSingle()\n .Which.Should().Be(typeof(ClassDerivedFromSomeGenericBaseClass));\n }\n\n [Fact]\n public void When_selecting_types_that_do_not_derive_from_a_specific_class_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassDerivedFromSomeBaseClass).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.Main.Test\")\n .ThatDoNotDeriveFrom();\n\n // Assert\n types.Should()\n .HaveCount(12);\n }\n\n [Fact]\n public void When_selecting_types_that_do_not_derive_from_a_specific_generic_class_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassDerivedFromSomeGenericBaseClass).Assembly;\n\n // Act\n TypeSelector types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.Main.Test\")\n .ThatDoNotDeriveFrom>();\n\n // Assert\n types.ToArray().Should()\n .HaveCount(12);\n }\n\n [Fact]\n public void When_selecting_types_that_implement_a_specific_interface_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassImplementingSomeInterface).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatImplement();\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(ClassImplementingSomeInterface))\n .And.Contain(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_selecting_types_that_do_not_implement_a_specific_interface_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassImplementingSomeInterface).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.Main.Test\")\n .ThatDoNotImplement();\n\n // Assert\n types.Should()\n .HaveCount(10);\n }\n\n [Fact]\n public void When_selecting_types_that_are_decorated_with_a_specific_attribute_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatAreDecoratedWith();\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(ClassWithSomeAttribute))\n .And.Contain(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_decorated_with_a_specific_attribute_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatAreNotDecoratedWith();\n\n // Assert\n types.Should()\n .NotBeEmpty()\n .And.NotContain(typeof(ClassWithSomeAttribute))\n .And.NotContain(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_selecting_types_from_specific_namespace_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatAreInNamespace(\"Internal.Other.Test\");\n\n // Assert\n types.Should().ContainSingle()\n .Which.Should().Be(typeof(SomeOtherClass));\n }\n\n [Fact]\n public void When_selecting_types_other_than_from_specific_namespace_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreUnderNamespace(\"Internal.Other\")\n .ThatAreNotInNamespace(\"Internal.Other.Test\");\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(SomeCommonClass));\n }\n\n [Fact]\n public void When_selecting_types_from_specific_namespace_or_sub_namespaces_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatAreUnderNamespace(\"Internal.Other.Test\");\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(SomeOtherClass))\n .And.Contain(typeof(SomeCommonClass));\n }\n\n [Fact]\n public void When_selecting_types_other_than_from_specific_namespace_or_sub_namespaces_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreUnderNamespace(\"Internal.Other\")\n .ThatAreNotUnderNamespace(\"Internal.Other.Test\");\n\n // Assert\n types.Should()\n .BeEmpty();\n }\n\n [Fact]\n public void When_combining_type_selection_filters_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreDecoratedWith()\n .ThatImplement()\n .ThatAreInNamespace(\"Internal.Main.Test\");\n\n // Assert\n types.Should().ContainSingle()\n .Which.Should().Be(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_using_the_single_type_ctor_of_TypeSelector_it_should_contain_that_singe_type()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttribute);\n\n // Act\n var typeSelector = new TypeSelector(type);\n\n // Assert\n typeSelector\n .ToArray()\n .Should()\n .ContainSingle()\n .Which.Should().Be(type);\n }\n\n [Fact]\n public void When_selecting_types_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreDecoratedWith();\n\n // Assert\n types.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_types_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreDecoratedWithOrInherit();\n\n // Assert\n types.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_types_not_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreNotDecoratedWith();\n\n // Assert\n types.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_types_not_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreNotDecoratedWithOrInherit();\n\n // Assert\n types.Should().BeEmpty();\n }\n\n [Fact]\n public void When_selecting_types_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeNonInheritableAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreDecoratedWith();\n\n // Assert\n types.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_types_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeNonInheritableAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreDecoratedWithOrInherit();\n\n // Assert\n types.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_types_not_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeNonInheritableAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreNotDecoratedWith();\n\n // Assert\n types.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_types_not_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeNonInheritableAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreNotDecoratedWithOrInherit();\n\n // Assert\n types.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_global_types_from_global_namespace_it_should_succeed()\n {\n // Arrange\n TypeSelector types = new[] { typeof(ClassInGlobalNamespace) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreUnderNamespace(null);\n\n // Assert\n filteredTypes.As>().Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_global_types_not_from_global_namespace_it_should_succeed()\n {\n // Arrange\n TypeSelector types = new[] { typeof(ClassInGlobalNamespace) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreNotUnderNamespace(null);\n\n // Assert\n filteredTypes.As>().Should().BeEmpty();\n }\n\n [Fact]\n public void When_selecting_local_types_from_global_namespace_it_should_succeed()\n {\n // Arrange\n TypeSelector types = new[] { typeof(SomeBaseClass) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreUnderNamespace(null);\n\n // Assert\n filteredTypes.As>().Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_local_types_not_from_global_namespace_it_should_succeed()\n {\n // Arrange\n TypeSelector types = new[] { typeof(SomeBaseClass) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreNotUnderNamespace(null);\n\n // Assert\n filteredTypes.As>().Should().BeEmpty();\n }\n\n [Fact]\n public void When_selecting_a_prefix_of_a_namespace_it_should_not_match()\n {\n // Arrange\n TypeSelector types = new[] { typeof(SomeBaseClass) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreUnderNamespace(\"Internal.Main.Tes\");\n\n // Assert\n filteredTypes.As>().Should().BeEmpty();\n }\n\n [Fact]\n public void When_deselecting_a_prefix_of_a_namespace_it_should_not_match()\n {\n // Arrange\n TypeSelector types = new[] { typeof(SomeBaseClass) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreNotUnderNamespace(\"Internal.Main.Tes\");\n\n // Assert\n filteredTypes.As>().Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_types_that_are_classes_it_should_return_the_correct_types()\n {\n // Arrange\n TypeSelector types = new[]\n {\n typeof(NotOnlyClassesClass), typeof(NotOnlyClassesEnumeration), typeof(INotOnlyClassesInterface)\n }.Types();\n\n // Act\n IEnumerable filteredTypes = types.ThatAreClasses();\n\n // Assert\n filteredTypes.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(NotOnlyClassesClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(NotOnlyClassesClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.NotOnlyClasses.Test\")\n .ThatAreNotClasses();\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(INotOnlyClassesInterface))\n .And.Contain(typeof(NotOnlyClassesEnumeration));\n }\n\n [Fact]\n public void When_selecting_types_that_are_value_types_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(InternalEnumValueType).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.ValueTypesAndNotValueTypes.Test\")\n .ThatAreValueTypes();\n\n // Assert\n types.Should()\n .HaveCount(3);\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_value_types_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(InternalEnumValueType).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.ValueTypesAndNotValueTypes.Test\")\n .ThatAreNotValueTypes();\n\n // Assert\n types.Should()\n .HaveCount(3);\n }\n\n [Fact]\n public void When_selecting_types_that_are_abstract_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(AbstractClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.AbstractAndNotAbstractClasses.Test\")\n .ThatAreAbstract();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(AbstractClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_abstract_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(NotAbstractClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.AbstractAndNotAbstractClasses.Test\")\n .ThatAreNotAbstract();\n\n // Assert\n types.Should()\n .HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_types_that_are_sealed_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(SealedClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.SealedAndNotSealedClasses.Test\")\n .ThatAreSealed();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(SealedClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_sealed_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(NotSealedClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.SealedAndNotSealedClasses.Test\")\n .ThatAreNotSealed();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(NotSealedClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_static_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(StaticClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.StaticAndNonStaticClasses.Test\")\n .ThatAreStatic();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(StaticClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_static_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(StaticClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.StaticAndNonStaticClasses.Test\")\n .ThatAreNotStatic();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(NotAStaticClass));\n }\n\n [Fact]\n public void When_selecting_types_with_predicate_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(SomeBaseClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatSatisfy(t => t.GetCustomAttribute() is not null);\n\n // Assert\n types.Should()\n .HaveCount(3)\n .And.Contain(typeof(ClassWithSomeAttribute))\n .And.Contain(typeof(ClassWithSomeAttributeDerived))\n .And.Contain(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_unwrap_task_types_it_should_return_the_correct_types()\n {\n IEnumerable types = typeof(ClassToExploreUnwrappedTaskTypes)\n .Methods()\n .ReturnTypes()\n .UnwrapTaskTypes();\n\n types.Should()\n .BeEquivalentTo([typeof(int), typeof(void), typeof(void), typeof(string), typeof(bool)]);\n }\n\n [Fact]\n public void When_unwrap_enumerable_types_it_should_return_the_correct_types()\n {\n IEnumerable types = typeof(ClassToExploreUnwrappedEnumerableTypes)\n .Methods()\n .ReturnTypes()\n .UnwrapEnumerableTypes();\n\n types.Should()\n .HaveCount(4)\n .And.Contain(typeof(IEnumerable))\n .And.Contain(typeof(bool))\n .And.Contain(typeof(int))\n .And.Contain(typeof(string));\n }\n\n [Fact]\n public void When_selecting_types_that_are_interfaces_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(InternalInterface).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.InterfaceAndClasses.Test\")\n .ThatAreInterfaces();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(InternalInterface));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_interfaces_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(InternalNotInterfaceClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.InterfaceAndClasses.Test\")\n .ThatAreNotInterfaces();\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(InternalNotInterfaceClass))\n .And.Contain(typeof(InternalAbstractClass));\n }\n\n [Fact]\n public void When_selecting_types_by_access_modifier_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = Assembly.GetExecutingAssembly();\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.PublicAndInternalClasses.Test\")\n .ThatHaveAccessModifier(CSharpAccessModifier.Public);\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(Internal.PublicAndInternalClasses.Test.PublicClass));\n }\n\n [Fact]\n public void When_selecting_types_excluding_access_modifier_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = Assembly.GetExecutingAssembly();\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.PublicAndInternalClasses.Test\")\n .ThatDoNotHaveAccessModifier(CSharpAccessModifier.Public);\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(Internal.PublicAndInternalClasses.Test.InternalClass));\n }\n }\n}\n\n#region Internal classes used in unit tests\n\nnamespace Internal.Main.Test\n{\n internal class SomeBaseClass;\n\n internal class ClassDerivedFromSomeBaseClass : SomeBaseClass;\n\n internal class SomeGenericBaseClass\n {\n public T Value { get; set; }\n }\n\n internal class ClassDerivedFromSomeGenericBaseClass : SomeGenericBaseClass;\n\n internal interface ISomeInterface;\n\n internal class ClassImplementingSomeInterface : ISomeInterface;\n\n [AttributeUsage(AttributeTargets.Class)]\n internal class SomeAttribute : Attribute;\n\n [AttributeUsage(AttributeTargets.Class, Inherited = false)]\n internal class SomeNonInheritableAttribute : Attribute;\n\n [Some]\n internal class ClassWithSomeAttribute\n {\n public string Property1 { get; set; }\n\n public void Method1()\n {\n }\n }\n\n internal class ClassWithSomeAttributeDerived : ClassWithSomeAttribute;\n\n [SomeNonInheritable]\n internal class ClassWithSomeNonInheritableAttribute\n {\n public string Property1 { get; set; }\n\n public void Method1()\n {\n }\n }\n\n internal class ClassWithSomeNonInheritableAttributeDerived : ClassWithSomeNonInheritableAttribute;\n\n [Some]\n internal class ClassWithSomeAttributeThatImplementsSomeInterface : ISomeInterface\n {\n public string Property2 { get; set; }\n\n public void Method2()\n {\n }\n }\n}\n\nnamespace Internal.Other.Test\n{\n internal class SomeOtherClass;\n}\n\nnamespace Internal.Other.Test.Common\n{\n internal class SomeCommonClass;\n}\n\nnamespace Internal.NotOnlyClasses.Test\n{\n internal class NotOnlyClassesClass;\n\n internal enum NotOnlyClassesEnumeration;\n\n internal interface INotOnlyClassesInterface;\n}\n\nnamespace Internal.StaticAndNonStaticClasses.Test\n{\n internal static class StaticClass;\n\n internal class NotAStaticClass;\n}\n\nnamespace Internal.AbstractAndNotAbstractClasses.Test\n{\n internal abstract class AbstractClass;\n\n internal class NotAbstractClass;\n\n internal static class NotAbstractStaticClass;\n}\n\nnamespace Internal.InterfaceAndClasses.Test\n{\n internal interface InternalInterface;\n\n internal abstract class InternalAbstractClass;\n\n internal class InternalNotInterfaceClass;\n}\n\nnamespace Internal.UnwrapSelectorTestTypes.Test\n{\n internal class ClassToExploreUnwrappedTaskTypes\n {\n internal int DoWithInt() { return default; }\n\n internal Task DoWithTask() { return Task.CompletedTask; }\n\n internal ValueTask DoWithValueTask() { return default; }\n\n internal Task DoWithIntTask() { return Task.FromResult(string.Empty); }\n\n internal ValueTask DoWithBoolValueTask() { return new ValueTask(false); }\n }\n\n internal class ClassToExploreUnwrappedEnumerableTypes\n {\n internal IEnumerable DoWithTask() { return default; }\n\n internal List DoWithIntTask() { return default; }\n\n internal ClassImplementingMultipleEnumerable DoWithBoolValueTask() { return default; }\n }\n\n internal class ClassImplementingMultipleEnumerable : IEnumerable, IEnumerable\n {\n private readonly IEnumerable integers = [];\n private readonly IEnumerable strings = [];\n\n public IEnumerator GetEnumerator() => integers.GetEnumerator();\n\n IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)integers).GetEnumerator();\n\n IEnumerator IEnumerable.GetEnumerator() => strings.GetEnumerator();\n }\n}\n\nnamespace Internal.SealedAndNotSealedClasses.Test\n{\n internal sealed class SealedClass;\n\n internal class NotSealedClass;\n}\n\nnamespace Internal.PublicAndInternalClasses.Test\n{\n public class PublicClass;\n\n internal class InternalClass;\n}\n\nnamespace Internal.ValueTypesAndNotValueTypes.Test\n{\n internal struct InternalStructValueType;\n\n internal record struct InternalRecordStructValueType;\n\n internal class InternalClassNotValueType;\n\n internal record InternalRecordClass;\n\n internal enum InternalEnumValueType;\n\n internal interface InternalInterfaceNotValueType;\n}\n\n#pragma warning disable RCS1110, S3903 // Declare type inside namespace.\ninternal class ClassInGlobalNamespace;\n#pragma warning restore RCS1110, S3903\n\n#endregion\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ByteValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class ByteValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is byte;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(\"0x\" + ((byte)value).ToString(\"X2\", CultureInfo.InvariantCulture));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/PropertyInfoSelectorSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing AwesomeAssertions.Types;\nusing Internal.Main.Test;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class PropertyInfoSelectorSpecs\n{\n [Fact]\n public void When_property_info_selector_is_created_with_a_null_type_it_should_throw()\n {\n // Arrange\n PropertyInfoSelector propertyInfoSelector;\n\n // Act\n Action act = () => propertyInfoSelector = new PropertyInfoSelector((Type)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_property_info_selector_is_created_with_a_null_type_list_it_should_throw()\n {\n // Arrange\n PropertyInfoSelector propertyInfoSelector;\n\n // Act\n Action act = () => propertyInfoSelector = new PropertyInfoSelector((Type[])null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_property_info_selector_is_null_then_should_should_throw()\n {\n // Arrange\n PropertyInfoSelector propertyInfoSelector = null;\n\n // Act\n Action act = () => propertyInfoSelector.Should();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"propertyInfoSelector\");\n }\n\n [Fact]\n public void When_selecting_properties_from_types_in_an_assembly_it_should_return_the_applicable_properties()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable properties = assembly.Types()\n .ThatAreDecoratedWith()\n .Properties();\n\n // Assert\n properties.Should()\n .HaveCount(2)\n .And.Contain(m => m.Name == \"Property1\")\n .And.Contain(m => m.Name == \"Property2\");\n }\n\n [Fact]\n public void When_selecting_properties_that_are_public_or_internal_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInternalAndPublicProperties);\n\n // Act\n IEnumerable properties = type.Properties().ThatArePublicOrInternal.ToArray();\n\n // Assert\n properties.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_abstract_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreAbstract.ToArray();\n\n // Assert\n properties.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_not_abstract_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotAbstract.ToArray();\n\n // Assert\n properties.Should().HaveCount(10);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_static_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreStatic.ToArray();\n\n // Assert\n properties.Should().HaveCount(4);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_not_static_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotStatic.ToArray();\n\n // Assert\n properties.Should().HaveCount(8);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_virtual_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreVirtual.ToArray();\n\n // Assert\n properties.Should().HaveCount(7);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_not_virtual_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotVirtual.ToArray();\n\n // Assert\n properties.Should().HaveCount(5);\n }\n\n [Fact]\n public void When_selecting_properties_decorated_with_specific_attribute_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreDecoratedWith().ToArray();\n\n // Assert\n properties.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_properties_not_decorated_with_specific_attribute_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n properties.Should()\n .NotBeEmpty()\n .And.NotContain(p => p.Name == \"PublicVirtualStringPropertyWithAttribute\")\n .And.NotContain(p => p.Name == \"ProtectedVirtualIntPropertyWithAttribute\");\n }\n\n [Fact]\n public void When_selecting_methods_that_return_a_specific_type_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().OfType().ToArray();\n\n // Assert\n properties.Should().HaveCount(8);\n }\n\n [Fact]\n public void When_selecting_methods_that_do_not_return_a_specific_type_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().NotOfType().ToArray();\n\n // Assert\n properties.Should().HaveCount(4);\n }\n\n [Fact]\n public void\n When_selecting_properties_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreDecoratedWith().ToArray();\n\n // Assert\n properties.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_properties_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable properties =\n type.Properties().ThatAreDecoratedWithOrInherit().ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_properties_not_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_properties_not_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable properties =\n type.Properties().ThatAreNotDecoratedWithOrInherit().ToArray();\n\n // Assert\n properties.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_properties_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable properties =\n type.Properties().ThatAreDecoratedWith().ToArray();\n\n // Assert\n properties.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_properties_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable properties = type.Properties()\n .ThatAreDecoratedWithOrInherit().ToArray();\n\n // Assert\n properties.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_properties_not_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable properties =\n type.Properties().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_properties_not_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable properties = type.Properties()\n .ThatAreNotDecoratedWithOrInherit().ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_properties_return_types_it_should_return_the_correct_types()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable returnTypes = type.Properties().ReturnTypes().ToArray();\n\n // Assert\n returnTypes.Should()\n .BeEquivalentTo(\n [\n typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string),\n typeof(string), typeof(int), typeof(int), typeof(int), typeof(int)\n ]);\n }\n\n public class ThatArePublicOrInternal\n {\n [Fact]\n public void When_combining_filters_to_filter_methods_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties()\n .ThatArePublicOrInternal\n .OfType()\n .ThatAreDecoratedWith()\n .ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void When_a_property_only_has_a_public_setter_it_should_be_included_in_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPublicSetter);\n\n // Act\n IEnumerable properties = type.Properties().ThatArePublicOrInternal.ToArray();\n\n // Assert\n properties.Should().HaveCount(3);\n }\n\n private class TestClassForPublicSetter\n {\n private static string myPrivateStaticStringField;\n\n public static string PublicStaticStringProperty { set => myPrivateStaticStringField = value; }\n\n public static string InternalStaticStringProperty { get; set; }\n\n public int PublicIntProperty { get; init; }\n }\n\n [Fact]\n public void When_selecting_properties_with_at_least_one_accessor_being_private_should_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPrivateAccessors);\n\n // Act\n IEnumerable properties = type.Properties().ThatArePublicOrInternal.ToArray();\n\n // Assert\n properties.Should().HaveCount(4);\n }\n\n private class TestClassForPrivateAccessors\n {\n public bool PublicBoolPrivateGet { private get; set; }\n\n public bool PublicBoolPrivateSet { get; private set; }\n\n internal bool InternalBoolPrivateGet { private get; set; }\n\n internal bool InternalBoolPrivateSet { get; private set; }\n }\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class TestClassForPropertySelectorWithInternalAndPublicProperties\n{\n public static string PublicStaticStringProperty { get; }\n\n internal static string InternalStaticStringProperty { get; set; }\n\n protected static string ProtectedStaticStringProperty { get; set; }\n\n private static string PrivateStaticStringProperty { get; set; }\n}\n\ninternal abstract class TestClassForPropertySelector\n{\n private static string myPrivateStaticStringField;\n\n public static string PublicStaticStringProperty { set => myPrivateStaticStringField = value; }\n\n internal static string InternalStaticStringProperty { get; set; }\n\n protected static string ProtectedStaticStringProperty { get; set; }\n\n private static string PrivateStaticStringProperty { get; set; }\n\n // An abstract method/property is implicitly a virtual method/property.\n public abstract string PublicAbstractStringProperty { get; set; }\n\n public abstract string PublicAbstractStringPropertyWithSetterOnly { set; }\n\n private string myPrivateStringField;\n\n public virtual string PublicVirtualStringProperty { set => myPrivateStringField = value; }\n\n [DummyProperty]\n public virtual string PublicVirtualStringPropertyWithAttribute { get; set; }\n\n public virtual int PublicVirtualIntPropertyWithPrivateSetter { get; private set; }\n\n internal virtual int InternalVirtualIntPropertyWithPrivateSetter { get; private set; }\n\n [DummyProperty]\n protected virtual int ProtectedVirtualIntPropertyWithAttribute { get; set; }\n\n private int PrivateIntProperty { get; set; }\n}\n\ninternal class TestClassForPropertySelectorWithInheritableAttribute\n{\n [DummyProperty]\n public virtual string PublicVirtualStringPropertyWithAttribute { get; set; }\n}\n\ninternal class TestClassForPropertySelectorWithNonInheritableAttribute\n{\n [DummyPropertyNonInheritableAttribute]\n public virtual string PublicVirtualStringPropertyWithAttribute { get; set; }\n}\n\ninternal class TestClassForPropertySelectorWithInheritableAttributeDerived : TestClassForPropertySelectorWithInheritableAttribute\n{\n public override string PublicVirtualStringPropertyWithAttribute { get; set; }\n}\n\ninternal class TestClassForPropertySelectorWithNonInheritableAttributeDerived : TestClassForPropertySelectorWithNonInheritableAttribute\n{\n public override string PublicVirtualStringPropertyWithAttribute { get; set; }\n}\n\n[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = false)]\npublic class DummyPropertyNonInheritableAttributeAttribute : Attribute\n{\n public DummyPropertyNonInheritableAttributeAttribute()\n {\n }\n\n public DummyPropertyNonInheritableAttributeAttribute(string value)\n {\n Value = value;\n }\n\n public string Value { get; private set; }\n}\n\n[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]\npublic class DummyPropertyAttribute : Attribute\n{\n public DummyPropertyAttribute()\n {\n }\n\n public DummyPropertyAttribute(string value)\n {\n Value = value;\n }\n\n public string Value { get; private set; }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AndWhichConstraint.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Provides a property that can be used in chained assertions where the prior assertions returns a\n/// single object that the assertion continues on.\n/// \npublic class AndWhichConstraint : AndConstraint\n{\n private readonly AssertionChain assertionChain;\n private readonly string pathPostfix;\n private readonly Lazy getSubject;\n\n /// \n /// Creates an object that allows continuing an assertion executed through and\n /// which resulted in a single .\n /// \n public AndWhichConstraint(TParent parent, TSubject subject)\n : base(parent)\n {\n getSubject = new Lazy(() => subject);\n }\n\n /// \n /// Creates an object that allows continuing an assertion executed through and\n /// which resulted in a single on an existing , but where\n /// the previous caller identifier is post-fixed with .\n /// \n public AndWhichConstraint(TParent parent, TSubject subject, AssertionChain assertionChain, string pathPostfix = \"\")\n : base(parent)\n {\n getSubject = new Lazy(() => subject);\n\n this.assertionChain = assertionChain;\n this.pathPostfix = pathPostfix;\n }\n\n /// \n /// Creates an object that allows continuing an assertion executed through and\n /// which resulted in a potential collection of objects through .\n /// \n /// \n /// If contains more than one object, a clear exception is thrown.\n /// \n public AndWhichConstraint(TParent parent, IEnumerable subjects)\n : base(parent)\n {\n getSubject = new Lazy(() => Single(subjects));\n }\n\n /// \n /// Creates an object that allows continuing an assertion executed through and\n /// which resulted in a potential collection of objects through on an\n /// existing , but where\n /// the previous caller identifier is post-fixed with .\n /// \n /// \n /// If contains more than one object, a clear exception is thrown.\n /// \n public AndWhichConstraint(TParent parent, IEnumerable subjects, AssertionChain assertionChain, string pathPostfix)\n : base(parent)\n {\n getSubject = new Lazy(() => Single(subjects));\n\n this.assertionChain = assertionChain;\n this.pathPostfix = pathPostfix;\n }\n\n private static TSubject Single(IEnumerable subjects)\n {\n TSubject[] matchedElements = subjects.ToArray();\n\n if (matchedElements.Length > 1)\n {\n string foundObjects = string.Join(Environment.NewLine,\n matchedElements.Select(ele => \"\\t\" + Formatter.ToString(ele)));\n\n string message = \"More than one object found. AwesomeAssertions cannot determine which object is meant.\"\n + $\" Found objects:{Environment.NewLine}{foundObjects}\";\n\n AssertionEngine.TestFramework.Throw(message);\n }\n\n return matchedElements.Single();\n }\n\n /// \n /// Returns the single result of a prior assertion that is used to select a nested or collection item.\n /// \n /// \n /// Just a convenience property that returns the same value as .\n /// \n public TSubject Subject => Which;\n\n /// \n /// Returns the single result of a prior assertion that is used to select a nested or collection item.\n /// \n public TSubject Which\n {\n get\n {\n if (pathPostfix is not null and not \"\")\n {\n assertionChain.WithCallerPostfix(pathPostfix).ReuseOnce();\n }\n\n return getSubject.Value;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TimeSpanValueFormatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class TimeSpanValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is TimeSpan;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var timeSpan = (TimeSpan)value;\n\n if (timeSpan == TimeSpan.MinValue)\n {\n formattedGraph.AddFragment(\"min time span\");\n return;\n }\n\n if (timeSpan == TimeSpan.MaxValue)\n {\n formattedGraph.AddFragment(\"max time span\");\n return;\n }\n\n List fragments = GetNonZeroFragments(timeSpan);\n\n if (fragments.Count == 0)\n {\n formattedGraph.AddFragment(\"default\");\n }\n\n string sign = timeSpan.Ticks >= 0 ? string.Empty : \"-\";\n\n if (fragments.Count == 1)\n {\n formattedGraph.AddFragment(sign + fragments.Single());\n }\n else\n {\n formattedGraph.AddFragment(sign + fragments.JoinUsingWritingStyle());\n }\n }\n\n private static List GetNonZeroFragments(TimeSpan timeSpan)\n {\n TimeSpan absoluteTimespan = timeSpan.Duration();\n\n var fragments = new List();\n\n AddDaysIfNotZero(absoluteTimespan, fragments);\n AddHoursIfNotZero(absoluteTimespan, fragments);\n AddMinutesIfNotZero(absoluteTimespan, fragments);\n AddSecondsIfNotZero(absoluteTimespan, fragments);\n AddMilliSecondsIfNotZero(absoluteTimespan, fragments);\n AddMicrosecondsIfNotZero(absoluteTimespan, fragments);\n\n return fragments;\n }\n\n private static void AddMicrosecondsIfNotZero(TimeSpan timeSpan, List fragments)\n {\n var ticks = timeSpan.Ticks % TimeSpan.TicksPerMillisecond;\n\n if (ticks > 0)\n {\n var microSeconds = ticks * (1000.0 / TimeSpan.TicksPerMillisecond);\n fragments.Add(microSeconds.ToString(\"0.0\", CultureInfo.InvariantCulture) + \"µs\");\n }\n }\n\n private static void AddSecondsIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Seconds > 0)\n {\n string result = timeSpan.Seconds.ToString(CultureInfo.InvariantCulture);\n\n fragments.Add(result + \"s\");\n }\n }\n\n private static void AddMilliSecondsIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Milliseconds > 0)\n {\n var result = timeSpan.Milliseconds.ToString(CultureInfo.InvariantCulture);\n\n fragments.Add(result + \"ms\");\n }\n }\n\n private static void AddMinutesIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Minutes > 0)\n {\n fragments.Add(timeSpan.Minutes.ToString(CultureInfo.InvariantCulture) + \"m\");\n }\n }\n\n private static void AddHoursIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Hours > 0)\n {\n fragments.Add(timeSpan.Hours.ToString(CultureInfo.InvariantCulture) + \"h\");\n }\n }\n\n private static void AddDaysIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Days > 0)\n {\n fragments.Add(timeSpan.Days.ToString(CultureInfo.InvariantCulture) + \"d\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class Miscellaneous\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n var someObject = new Exception();\n\n // Act / Assert\n someObject.Should()\n .BeOfType()\n .And\n .NotBeNull();\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n var someObject = new Exception();\n\n // Act\n var action = () => someObject.Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() or BeSameAs() instead?\");\n }\n }\n\n internal class DumbObjectEqualityComparer : IEqualityComparer\n {\n // ReSharper disable once MemberHidesStaticFromOuterClass\n public new bool Equals(object x, object y)\n {\n return (x == y) || (x is not null && y is not null && x.Equals(y));\n }\n\n public int GetHashCode(object obj) => obj.GetHashCode();\n }\n}\n\ninternal class DummyBaseClass;\n\ninternal sealed class DummyImplementingClass : DummyBaseClass, IDisposable\n{\n public void Dispose()\n {\n // Ignore\n }\n}\n\ninternal class SomeClass\n{\n public SomeClass(int key)\n {\n Key = key;\n }\n\n public int Key { get; }\n\n public override string ToString() => $\"SomeClass({Key})\";\n}\n\ninternal class SomeClassEqualityComparer : IEqualityComparer\n{\n public bool Equals(SomeClass x, SomeClass y)\n {\n return (x == y) || (x is not null && y is not null && x.Key.Equals(y.Key));\n }\n\n public int GetHashCode(SomeClass obj) => obj.Key;\n}\n\ninternal class SomeClassAssertions : ObjectAssertions\n{\n public SomeClassAssertions(SomeClass value)\n : base(value, AssertionChain.GetOrCreate())\n {\n }\n}\n\ninternal static class AssertionExtensions\n{\n public static SomeClassAssertions Should(this SomeClass value) => new(value);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/AssertionScope.cs", "using System;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents an implicit or explicit scope within which multiple assertions can be collected.\n/// \n/// \n/// This class is supposed to have a very short lifetime and is not safe to be used in assertion that cross thread-boundaries\n/// such as when using or .\n/// \npublic sealed class AssertionScope : IDisposable\n{\n private readonly IAssertionStrategy assertionStrategy;\n\n /// \n /// The default scopes, which were implicitly created by accessing .\n /// \n private static readonly AsyncLocal DefaultScope = new();\n private static readonly AsyncLocal CurrentScope = new();\n private readonly Func callerIdentityProvider = () => CallerIdentifier.DetermineCallerIdentity();\n private readonly ContextDataDictionary reportableData = new();\n private readonly StringBuilder tracing = new();\n\n#pragma warning disable CA2213 // Disposable fields should be disposed\n private AssertionScope parent;\n#pragma warning restore CA2213\n\n /// \n /// Starts an unnamed scope within which multiple assertions can be executed\n /// and which will not throw until the scope is disposed.\n /// \n public AssertionScope()\n : this(() => null, new CollectingAssertionStrategy())\n {\n }\n\n /// \n /// Starts a named scope within which multiple assertions can be executed\n /// and which will not throw until the scope is disposed.\n /// \n public AssertionScope(string name)\n : this(() => name, new CollectingAssertionStrategy())\n {\n }\n\n /// \n /// Starts a new scope based on the given assertion strategy.\n /// \n /// The assertion strategy for this scope.\n /// is .\n public AssertionScope(IAssertionStrategy assertionStrategy)\n : this(() => null, assertionStrategy)\n {\n }\n\n /// \n /// Starts a named scope within which multiple assertions can be executed\n /// and which will not throw until the scope is disposed.\n /// \n public AssertionScope(Func name)\n : this(name, new CollectingAssertionStrategy())\n {\n }\n\n /// \n /// Starts a new scope based on the given assertion strategy and parent assertion scope\n /// \n /// The assertion strategy for this scope.\n /// is .\n private AssertionScope(Func name, IAssertionStrategy assertionStrategy)\n {\n parent = GetParentScope();\n CurrentScope.Value = this;\n\n this.assertionStrategy = assertionStrategy\n ?? throw new ArgumentNullException(nameof(assertionStrategy));\n\n if (parent is not null)\n {\n // Combine the existing Name with the parent.Name if it exists.\n Name = () =>\n {\n var parentName = parent.Name();\n if (parentName.IsNullOrEmpty())\n {\n return name();\n }\n\n if (name().IsNullOrEmpty())\n {\n return parentName;\n }\n\n return parentName + \"/\" + name();\n };\n\n callerIdentityProvider = parent.callerIdentityProvider;\n FormattingOptions = parent.FormattingOptions.Clone();\n }\n else\n {\n Name = name;\n }\n }\n\n /// \n /// Get parent scope.\n /// \n /// The parent scope is any explicitly opened , except\n /// for the implicitly opened through access to or\n /// .\n /// \n /// \n /// The parent scope\n private static AssertionScope GetParentScope()\n {\n if (CurrentScope.Value is not null && CurrentScope.Value != DefaultScope.Value)\n {\n return CurrentScope.Value;\n }\n\n return null;\n }\n\n /// \n /// Gets or sets the name of the current assertion scope, e.g. the path of the object graph\n /// that is being asserted on.\n /// \n /// \n /// The context is provided by a which\n /// only gets evaluated when its value is actually needed (in most cases during a failure).\n /// \n public Func Name { get; }\n\n /// \n /// Gets the current thread-specific assertion scope.\n /// \n public static AssertionScope Current\n {\n get\n {\n if (CurrentScope.Value is not null)\n {\n return CurrentScope.Value;\n }\n\n DefaultScope.Value ??= new AssertionScope(() => null, new DefaultAssertionStrategy());\n return DefaultScope.Value;\n }\n }\n\n /// \n /// Exposes the options the scope will use for formatting objects in case an assertion fails.\n /// \n public FormattingOptions FormattingOptions { get; } = AssertionConfiguration.Current.Formatting.Clone();\n\n /// \n /// Adds a pre-formatted failure message to the current scope.\n /// \n public void AddPreFormattedFailure(string formattedFailureMessage)\n {\n assertionStrategy.HandleFailure(formattedFailureMessage);\n }\n\n /// \n /// Adds some information to the assertion scope that will be included in the message\n /// that is emitted if an assertion fails.\n /// \n internal void AddReportable(string key, string value)\n {\n reportableData.Add(new ContextDataDictionary.DataItem(key, value, reportable: true, requiresFormatting: false));\n }\n\n /// \n /// Adds some information to the assertion scope that will be included in the message\n /// that is emitted if an assertion fails. The value is only calculated on failure.\n /// \n internal void AddReportable(string key, Func valueFunc)\n {\n reportableData.Add(new ContextDataDictionary.DataItem(key, new DeferredReportable(valueFunc), reportable: true,\n requiresFormatting: false));\n }\n\n /// \n /// Adds a block of tracing to the scope for reporting when an assertion fails.\n /// \n public void AppendTracing(string tracingBlock)\n {\n tracing.Append(tracingBlock);\n }\n\n /// \n /// Returns all failures that happened up to this point and ensures they will not cause\n /// to fail the assertion.\n /// \n public string[] Discard()\n {\n return assertionStrategy.DiscardFailures().ToArray();\n }\n\n public bool HasFailures()\n {\n return assertionStrategy.FailureMessages.Any();\n }\n\n /// \n public void Dispose()\n {\n CurrentScope.Value = parent;\n\n if (parent is not null)\n {\n foreach (string failureMessage in assertionStrategy.FailureMessages)\n {\n parent.assertionStrategy.HandleFailure(failureMessage);\n }\n\n parent.reportableData.Add(reportableData);\n parent.AppendTracing(tracing.ToString());\n\n parent = null;\n }\n else\n {\n if (tracing.Length > 0)\n {\n reportableData.Add(new ContextDataDictionary.DataItem(\"trace\", tracing.ToString(), reportable: true, requiresFormatting: false));\n }\n\n assertionStrategy.ThrowIfAny(reportableData.GetReportable());\n }\n }\n\n private sealed class DeferredReportable(Func valueFunc)\n {\n private readonly Lazy lazyValue = new(valueFunc);\n\n public override string ToString() => lazyValue.Value;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DoubleValueFormatter.cs", "using System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DoubleValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is double;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(Format(value));\n }\n\n private static string Format(object value)\n {\n double doubleValue = (double)value;\n\n if (double.IsPositiveInfinity(doubleValue))\n {\n return nameof(Double) + \".\" + nameof(double.PositiveInfinity);\n }\n\n if (double.IsNegativeInfinity(doubleValue))\n {\n return nameof(Double) + \".\" + nameof(double.NegativeInfinity);\n }\n\n if (double.IsNaN(doubleValue))\n {\n return doubleValue.ToString(CultureInfo.InvariantCulture);\n }\n\n string formattedValue = doubleValue.ToString(\"R\", CultureInfo.InvariantCulture);\n\n return !formattedValue.Contains('.', StringComparison.Ordinal) && !formattedValue.Contains('E', StringComparison.Ordinal)\n ? formattedValue + \".0\"\n : formattedValue;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XAttributeFormatterSpecs.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XAttributeFormatterSpecs\n{\n [Fact]\n public void When_formatting_an_attribute_it_should_return_the_name_and_value()\n {\n // Act\n var element = XElement.Parse(@\"\");\n XAttribute attribute = element.Attribute(\"name\");\n string result = Formatter.ToString(attribute);\n\n // Assert\n result.Should().Be(@\"name=\"\"Martin\"\"\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/GivenSelectorSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\npublic class GivenSelectorSpecs\n{\n [Fact]\n public void A_consecutive_subject_should_be_selected()\n {\n // Arrange\n string value = string.Empty;\n\n // Act\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"First selector\")\n .Given(_ => value = \"Second selector\");\n\n // Assert\n value.Should().Be(\"Second selector\");\n }\n\n [Fact]\n public void After_a_failed_condition_a_consecutive_subject_should_be_ignored()\n {\n // Arrange\n string value = string.Empty;\n\n // Act\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .Given(() => \"First selector\")\n .Given(_ => value = \"Second selector\");\n\n // Assert\n value.Should().BeEmpty();\n }\n\n [Fact]\n public void A_consecutive_condition_should_be_evaluated()\n {\n // Act / Assert\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"Subject\")\n .ForCondition(_ => true)\n .FailWith(\"Failed\");\n }\n\n [Fact]\n public void After_a_failed_condition_a_consecutive_condition_should_be_ignored()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(false)\n .Given(() => \"Subject\")\n .ForCondition(_ => throw new ApplicationException())\n .FailWith(\"Failed\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_it_fails_with_a_message_after_selecting_the_subject()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"First\")\n .FailWith(\"First selector\")\n .Then\n .Given(_ => \"Second\")\n .FailWith(\"Second selector\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second selector\");\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_it_fails_with_a_message_with_arguments_after_selecting_the_subject()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"First\")\n .FailWith(\"{0} selector\", \"First\")\n .Then\n .Given(_ => \"Second\")\n .FailWith(\"{0} selector\", \"Second\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\\\"Second\\\" selector\");\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_it_fails_with_a_message_with_argument_selectors_after_selecting_the_subject()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"First\")\n .FailWith(\"{0} selector\", _ => \"First\")\n .Then\n .Given(_ => \"Second\")\n .FailWith(\"{0} selector\", _ => \"Second\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\\\"Second\\\" selector\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_failure_messages_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .Given(() => \"First\")\n .FailWith(\"First selector\")\n .Then\n .FailWith(\"Second selector\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First selector\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_failure_messages_with_arguments_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .Given(() => \"First\")\n .FailWith(\"{0} selector\", \"First\")\n .Then\n .FailWith(\"{0} selector\", \"Second\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\\\"First\\\" selector\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_failure_messages_with_argument_selectors_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .Given(() => \"First\")\n .FailWith(\"{0} selector\", _ => \"First\")\n .Then\n .FailWith(\"{0} selector\", _ => \"Second\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\\\"First\\\" selector\");\n }\n\n [Fact]\n public void The_failure_message_should_be_preceded_by_the_expectation_after_selecting_a_subject()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectation \", chain => chain\n .Given(() => \"Subject\")\n .FailWith(\"Failure\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectation Failure\");\n }\n\n [Fact]\n public void\n The_failure_message_should_not_be_preceded_by_the_expectation_after_selecting_a_subject_and_clearing_the_expectation()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectation \", chain => chain\n .Given(() => \"Subject\"))\n .Then\n .FailWith(\"Failure\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Failure\");\n }\n\n [Fact]\n public void Clearing_the_expectation_does_not_affect_a_successful_assertion()\n {\n // Act\n var assertionChain = AssertionChain.GetOrCreate();\n\n assertionChain\n .WithExpectation(\"Expectation \", chain => chain\n .Given(() => \"Don't care\")\n .ForCondition(_ => true)\n .FailWith(\"Should not fail\"));\n\n // Assert\n assertionChain.Succeeded.Should().BeTrue();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/MethodInfoFormatter.cs", "using System.Reflection;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class MethodInfoFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is MethodInfo;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var method = (MethodInfo)value;\n if (method.IsSpecialName && method.Name == \"op_Implicit\")\n {\n FormatOperator(method, \"implicit\", formattedGraph, formatChild);\n }\n else if (method.IsSpecialName && method.Name == \"op_Explicit\")\n {\n FormatOperator(method, \"explicit\", formattedGraph, formatChild);\n }\n else\n {\n formatChild(\"type\", method!.DeclaringType.AsFormattableShortType(), formattedGraph);\n formattedGraph.AddFragment($\".{method.Name}\");\n }\n }\n\n private static void FormatOperator(MethodInfo method, string operatorType, FormattedObjectGraph formattedGraph, FormatChild formatChild)\n {\n formattedGraph.AddFragment($\"{operatorType} operator \");\n formatChild(\"type\", method.ReturnType.AsFormattableShortType(), formattedGraph);\n formattedGraph.AddFragment(\"(\");\n formatChild(\"type\", method.GetParameters()[0].ParameterType.AsFormattableShortType(), formattedGraph);\n formattedGraph.AddFragment(\")\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/PropertyInfoAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class PropertyInfoAssertions : MemberInfoAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public PropertyInfoAssertions(PropertyInfo propertyInfo, AssertionChain assertionChain)\n : base(propertyInfo, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the selected property is virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeVirtual(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property to be virtual{reason}, but {context:property} is .\")\n .Then\n .ForCondition(Subject.IsVirtual())\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subjectDescription} to be virtual{{reason}}, but it is not.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property is not virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property not to be virtual{reason}, but {context:property} is .\")\n .Then\n .ForCondition(!Subject.IsVirtual())\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected property {subjectDescription} not to be virtual{{reason}}, but it is.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property has a setter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeWritable(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property to have a setter{reason}, but {context:property} is .\")\n .Then\n .ForCondition(Subject!.CanWrite)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subjectDescription} to have a setter{{reason}}.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property has a setter with the specified C# access modifier.\n /// \n /// The expected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint BeWritable(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:project}} to be {accessModifier}{{reason}}, but it is .\")\n .Then\n .ForCondition(Subject!.CanWrite)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subjectDescription} to have a setter{{reason}}.\");\n });\n\n if (assertionChain.Succeeded)\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n assertionChain.OverrideCallerIdentifier(() => $\"setter of {subjectDescription}\");\n assertionChain.ReuseOnce();\n\n Subject!.GetSetMethod(nonPublic: true).Should().HaveAccessModifier(accessModifier, because, becauseArgs);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property does not have a setter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeWritable(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:property} not to have a setter{reason}, but it is .\")\n .Then\n .ForCondition(!Subject!.CanWrite)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Did not expect {subjectDescription} to have a setter{{reason}}.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property has a getter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeReadable([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property to have a getter{reason}, but {context:property} is .\")\n .Then\n .ForCondition(Subject!.CanRead)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected property {subjectDescription} to have a getter{{reason}}, but it does not.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property has a getter with the specified C# access modifier.\n /// \n /// The expected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint BeReadable(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:property}} to be {accessModifier}{{reason}}, but it is .\")\n .Then\n .ForCondition(Subject!.CanRead)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subjectDescription} to have a getter{{reason}}, but it does not.\");\n });\n\n if (assertionChain.Succeeded)\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n assertionChain.OverrideCallerIdentifier(() => $\"getter of {subjectDescription}\");\n assertionChain.ReuseOnce();\n\n Subject!.GetGetMethod(nonPublic: true).Should().HaveAccessModifier(accessModifier, because, becauseArgs);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property does not have a getter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeReadable(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property not to have a getter{reason}, but {context:property} is .\")\n .Then\n .ForCondition(!Subject!.CanRead)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Did not expect {subjectDescription} to have a getter{{reason}}.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property returns a specified type.\n /// \n /// The expected type of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Return(Type propertyType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(propertyType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type of property to be {0}{reason}, but {context:property} is .\", propertyType)\n .Then.ForCondition(Subject!.PropertyType == propertyType)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected type of property {2} to be {0}{reason}, but it is {1}.\",\n propertyType, Subject.PropertyType, Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property returns .\n /// \n /// The expected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Return([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return Return(typeof(TReturn), because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected property does not return a specified type.\n /// \n /// The unexpected type of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotReturn(Type propertyType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(propertyType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type of property not to be {0}{reason}, but {context:property} is .\", propertyType)\n .Then\n .ForCondition(Subject!.PropertyType != propertyType)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected type of property {0} not to be {1}{reason}, but it is.\", Subject, propertyType);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property does not return .\n /// \n /// The unexpected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotReturn([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotReturn(typeof(TReturn), because, becauseArgs);\n }\n\n private string GetSubjectDescription(AssertionChain assertionChain) =>\n assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : $\"{Identifier} {Subject.ToFormattedString()}\";\n\n private protected override string SubjectDescription => Subject.ToFormattedString();\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"property\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedXunitTheoryTestCaseRunner.cs", "using System;\nusing System.Globalization;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedXunitTheoryTestCaseRunner : XunitTheoryTestCaseRunner\n{\n private readonly string culture;\n private CultureInfo originalCulture;\n private CultureInfo originalUICulture;\n\n public CulturedXunitTheoryTestCaseRunner(CulturedXunitTheoryTestCase culturedXunitTheoryTestCase,\n string displayName,\n string skipReason,\n object[] constructorArguments,\n IMessageSink diagnosticMessageSink,\n IMessageBus messageBus,\n ExceptionAggregator aggregator,\n CancellationTokenSource cancellationTokenSource)\n : base(culturedXunitTheoryTestCase, displayName, skipReason, constructorArguments, diagnosticMessageSink, messageBus,\n aggregator, cancellationTokenSource)\n {\n culture = culturedXunitTheoryTestCase.Culture;\n }\n\n protected override Task AfterTestCaseStartingAsync()\n {\n try\n {\n originalCulture = CurrentCulture;\n originalUICulture = CurrentUICulture;\n\n var cultureInfo = new CultureInfo(culture);\n CurrentCulture = cultureInfo;\n CurrentUICulture = cultureInfo;\n }\n catch (Exception ex)\n {\n Aggregator.Add(ex);\n return Task.FromResult(0);\n }\n\n return base.AfterTestCaseStartingAsync();\n }\n\n protected override Task BeforeTestCaseFinishedAsync()\n {\n if (originalUICulture is not null)\n {\n CurrentUICulture = originalUICulture;\n }\n\n if (originalCulture is not null)\n {\n CurrentCulture = originalCulture;\n }\n\n return base.BeforeTestCaseFinishedAsync();\n }\n\n private static CultureInfo CurrentCulture\n {\n get => CultureInfo.CurrentCulture;\n set => CultureInfo.CurrentCulture = value;\n }\n\n private static CultureInfo CurrentUICulture\n {\n get => CultureInfo.CurrentUICulture;\n set => CultureInfo.CurrentUICulture = value;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeSelectorAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Types;\nusing DummyNamespace;\nusing DummyNamespace.InnerDummyNamespace;\nusing DummyNamespaceTwo;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class TypeSelectorAssertionSpecs\n{\n public class BeSealed\n {\n [Fact]\n public void When_all_types_are_sealed_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(Sealed)\n ]);\n\n // Act / Assert\n types.Should().BeSealed();\n }\n\n [Fact]\n public void When_any_type_is_not_sealed_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(Sealed),\n typeof(Abstract)\n ]);\n\n // Act\n Action act = () => types.Should().BeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be sealed *failure message*, but the following types are not:*.Abstract.\");\n }\n }\n\n public class NotBeSealed\n {\n [Fact]\n public void When_all_types_are_not_sealed_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(Abstract)\n ]);\n\n // Act / Assert\n types.Should().NotBeSealed();\n }\n\n [Fact]\n public void When_any_type_is_sealed_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(Abstract),\n typeof(Sealed)\n ]);\n\n // Act\n Action act = () => types.Should().NotBeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all types not to be sealed *failure message*, but the following types are:*.Sealed.\");\n }\n }\n\n public class BeDecoratedWith\n {\n [Fact]\n public void When_asserting_a_selection_of_decorated_types_is_decorated_with_an_attribute_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute)\n ]);\n\n // Act / Assert\n types.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_selection_of_non_decorated_types_is_decorated_with_an_attribute_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute),\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should().BeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be decorated with *.DummyClassAttribute *failure message*\" +\n \", but the attribute was not found on the following types:\" +\n \"**.ClassWithoutAttribute*.OtherClassWithoutAttribute.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_TypeSelector_BeDecoratedWith_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithAttribute));\n\n // Act\n Action act = () => types.Should()\n .BeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_a_selection_of_types_with_unexpected_attribute_property_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute),\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should()\n .BeDecoratedWith(\n a => a.Name == \"Expected\" && a.IsEnabled, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be decorated with *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\") * a.IsEnabled *failure message*, but no matching attribute was found on \" +\n \"the following types:*.ClassWithoutAttribute*.OtherClassWithoutAttribute.\");\n }\n }\n\n public class BeDecoratedWithOrInherit\n {\n [Fact]\n public void When_asserting_a_selection_of_decorated_types_inheriting_an_attribute_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithInheritedAttribute)\n ]);\n\n // Act / Assert\n types.Should().BeDecoratedWithOrInherit();\n }\n\n [Fact]\n public void When_asserting_a_selection_of_non_decorated_types_inheriting_an_attribute_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute),\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should().BeDecoratedWithOrInherit(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be decorated with or inherit *.DummyClassAttribute *failure message*\" +\n \", but the attribute was not found on the following types:\" +\n \"*.ClassWithoutAttribute*.OtherClassWithoutAttribute.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_TypeSelector_BeDecoratedWithOrInherit_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithAttribute));\n\n // Act\n Action act = () => types.Should()\n .BeDecoratedWithOrInherit(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void\n When_asserting_a_selection_of_types_with_some_inheriting_attributes_with_unexpected_attribute_property_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute),\n typeof(ClassWithInheritedAttribute),\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should()\n .BeDecoratedWithOrInherit(\n a => a.Name == \"Expected\" && a.IsEnabled, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be decorated with or inherit *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\")*a.IsEnabled *failure message*, but no matching attribute was found \" +\n \"on the following types:*.ClassWithoutAttribute*.OtherClassWithoutAttribute.\");\n }\n }\n\n public class NotBeDecoratedWith\n {\n [Fact]\n public void When_asserting_a_selection_of_non_decorated_types_is_not_decorated_with_an_attribute_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act / Assert\n types.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_selection_of_decorated_types_is_not_decorated_with_an_attribute_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(ClassWithAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should().NotBeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to not be decorated *.DummyClassAttribute *failure message*\" +\n \", but the attribute was found on the following types:*.ClassWithAttribute.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_TypeSelector_NotBeDecoratedWith_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithAttribute));\n\n // Act\n Action act = () => types.Should()\n .NotBeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_a_selection_of_types_with_unexpected_attribute_and_unexpected_attribute_property_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(ClassWithAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should()\n .NotBeDecoratedWith(\n a => a.Name == \"Expected\" && a.IsEnabled, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to not be decorated with *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\") * a.IsEnabled *failure message*, but a matching attribute was found \" +\n \"on the following types:*.ClassWithAttribute.\");\n }\n }\n\n public class NotBeDecoratedWithOrInherit\n {\n [Fact]\n public void When_asserting_a_selection_of_non_decorated_types_does_not_inherit_an_attribute_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act / Assert\n types.Should().NotBeDecoratedWithOrInherit();\n }\n\n [Fact]\n public void When_asserting_a_selection_of_decorated_types_does_not_inherit_an_attribute_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(ClassWithInheritedAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should().NotBeDecoratedWithOrInherit(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to not be decorated with or inherit *.DummyClassAttribute *failure message*\" +\n \", but the attribute was found on the following types:*.ClassWithInheritedAttribute.\");\n }\n\n [Fact]\n public void When_a_selection_of_types_do_inherit_unexpected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithInheritedAttribute));\n\n // Act\n Action act = () => types.Should()\n .NotBeDecoratedWithOrInherit(\n a => a.Name == \"Expected\" && a.IsEnabled, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to not be decorated with or inherit *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\") * a.IsEnabled *failure message*, but a matching attribute was found \" +\n \"on the following types:*.ClassWithInheritedAttribute.\");\n }\n\n [Fact]\n public void When_a_selection_of_types_do_not_inherit_unexpected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithoutAttribute));\n\n // Act / Assert\n types.Should()\n .NotBeDecoratedWithOrInherit(a => a.Name == \"Expected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_TypeSelector_NotBeDecoratedWithOrInherit_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithAttribute));\n\n // Act\n Action act = () => types.Should()\n .NotBeDecoratedWithOrInherit(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n }\n\n public class BeInNamespace\n {\n [Fact]\n public void When_a_type_is_in_the_expected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespace));\n\n // Act / Assert\n types.Should().BeInNamespace(nameof(DummyNamespace));\n }\n\n [Fact]\n public void When_a_type_is_not_in_the_expected_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act\n Action act = () =>\n types.Should().BeInNamespace(nameof(DummyNamespace), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be in namespace \\\"DummyNamespace\\\" *failure message*, but the following types \" +\n \"are in a different namespace:*.ClassNotInDummyNamespace*.OtherClassNotInDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_in_the_expected_global_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInGlobalNamespace));\n\n // Act / Assert\n types.Should().BeInNamespace(null);\n }\n\n [Fact]\n public void When_a_type_in_the_global_namespace_is_not_in_the_expected_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInGlobalNamespace));\n\n // Act\n Action act = () => types.Should().BeInNamespace(nameof(DummyNamespace));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be in namespace \\\"DummyNamespace\\\", but the following types \" +\n \"are in a different namespace:*ClassInGlobalNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_not_in_the_expected_global_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act\n Action act = () => types.Should().BeInNamespace(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be in namespace , but the following types are in a different namespace:\" +\n \"*.ClassInDummyNamespace*.ClassNotInDummyNamespace*.OtherClassNotInDummyNamespace.\");\n }\n }\n\n public class NotBeInNamespace\n {\n [Fact]\n public void When_a_type_is_not_in_the_unexpected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespace));\n\n // Act / Assert\n types.Should().NotBeInNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n }\n\n [Fact]\n public void When_a_type_is_not_in_the_unexpected_parent_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act / Assert\n types.Should().NotBeInNamespace(nameof(DummyNamespace));\n }\n\n [Fact]\n public void When_a_type_is_in_the_unexpected_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act\n Action act = () =>\n types.Should().NotBeInNamespace(nameof(DummyNamespace), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected no types to be in namespace \\\"DummyNamespace\\\" *failure message*\" +\n \", but the following types are in the namespace:*DummyNamespace.ClassInDummyNamespace.\");\n }\n }\n\n public class BeUnderNamespace\n {\n [Fact]\n public void When_a_type_is_under_the_expected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespace));\n\n // Act / Assert\n types.Should().BeUnderNamespace(nameof(DummyNamespace));\n }\n\n [Fact]\n public void When_a_type_is_under_the_expected_nested_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act / Assert\n types.Should().BeUnderNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_expected_parent_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act / Assert\n types.Should().BeUnderNamespace(nameof(DummyNamespace));\n }\n\n [Fact]\n public void When_a_type_is_exactly_under_the_expected_global_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInGlobalNamespace));\n\n // Act / Assert\n types.Should().BeUnderNamespace(null);\n }\n\n [Fact]\n public void When_a_type_is_under_the_expected_global_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act / Assert\n types.Should().BeUnderNamespace(null);\n }\n\n [Fact]\n public void When_a_type_only_shares_a_prefix_with_the_expected_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespaceTwo));\n\n // Act\n Action act = () =>\n types.Should().BeUnderNamespace(nameof(DummyNamespace), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the namespaces of all types to start with \\\"DummyNamespace\\\" *failure message*\" +\n \", but the namespaces of the following types do not start with it:*.ClassInDummyNamespaceTwo.\");\n }\n\n [Fact]\n public void When_asserting_a_selection_of_types_not_under_a_namespace_is_under_that_namespace_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassInInnerDummyNamespace)\n ]);\n\n // Act\n Action act = () =>\n types.Should().BeUnderNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to start with \\\"DummyNamespace.InnerDummyNamespace\\\"\" +\n \", but the namespaces of the following types do not start with it:*.ClassInDummyNamespace.\");\n }\n }\n\n public class NotBeUnderNamespace\n {\n [Fact]\n public void When_a_types_is_not_under_the_unexpected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act / Assert\n types.Should().NotBeUnderNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_namespace_it_shold_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespace));\n\n // Act\n Action act = () =>\n types.Should().NotBeUnderNamespace(nameof(DummyNamespace), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with \\\"DummyNamespace\\\" *failure message*\" +\n \", but the namespaces of the following types start with it:*.ClassInDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_nested_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act\n Action act = () =>\n types.Should().NotBeUnderNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with \\\"DummyNamespace.InnerDummyNamespace\\\"\" +\n \", but the namespaces of the following types start with it:*.ClassInInnerDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_parent_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act\n Action act = () => types.Should().NotBeUnderNamespace(nameof(DummyNamespace));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with \\\"DummyNamespace\\\"\" +\n \", but the namespaces of the following types start with it:*.ClassInInnerDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_global_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInGlobalNamespace));\n\n // Act\n Action act = () => types.Should().NotBeUnderNamespace(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with \" +\n \", but the namespaces of the following types start with it:*ClassInGlobalNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_parent_global_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act\n Action act = () => types.Should().NotBeUnderNamespace(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with , but the namespaces of the following types \" +\n \"start with it:*.ClassInDummyNamespace*.ClassNotInDummyNamespace*.OtherClassNotInDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_only_shares_a_prefix_with_the_unexpected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespaceTwo));\n\n // Act / Assert\n types.Should().NotBeUnderNamespace(nameof(DummyNamespace));\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute)\n ]);\n\n // Act\n var action = () => types.Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Equals is not part of Awesome Assertions. Did you mean BeInNamespace() or BeDecoratedWith() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/TaskOfTAssertionSpecs.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n#if NET47\nusing AwesomeAssertions.Specs.Common;\n#endif\nusing AwesomeAssertions.Specs.Exceptions;\nusing Xunit;\nusing Xunit.Sdk;\nusing static AwesomeAssertions.FluentActions;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic static class TaskOfTAssertionSpecs\n{\n public class CompleteWithinAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_fail()\n {\n // Arrange\n var timeSpan = 0.Milliseconds();\n Func> action = null;\n\n // Act\n Func testAction = () => action.Should().CompleteWithinAsync(\n timeSpan, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_subject_is_null_with_AssertionScope_it_should_fail()\n {\n // Arrange\n var timeSpan = 0.Milliseconds();\n Func> action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().CompleteWithinAsync(\n timeSpan, \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_task_completes_fast_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).CompleteWithinAsync(100.Milliseconds()))\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Can_chain_another_assertion_on_the_result_of_the_async_operation()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).CompleteWithinAsync(100.Milliseconds()))\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_completes_and_result_is_not_expected_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> funcSubject = () => taskFactory.Task;\n\n (await funcSubject.Should(timer).CompleteWithinAsync(100.Milliseconds()))\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(99);\n timer.Complete();\n\n // Assert\n // TODO message currently shows \"Expected (await funcSubject to be...\", but should be \"Expected funcSubject to be...\",\n // maybe with or without await.\n await action.Should().ThrowAsync().WithMessage(\"*to be 42, but found 99 (difference of 57).\");\n }\n\n [Fact]\n public async Task When_task_completes_and_async_result_is_not_expected_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> funcSubject = () => taskFactory.Task;\n\n await funcSubject.Should(timer).CompleteWithinAsync(100.Milliseconds()).WithResult(42);\n };\n\n taskFactory.SetResult(99);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"Expected funcSubject.Result to be 42, but found 99.\");\n }\n\n [Fact]\n public async Task When_task_completes_late_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n Func> func = () => taskFactory.Task;\n\n return func.Should(timer).CompleteWithinAsync(100.Milliseconds());\n };\n\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_completes_late_it_in_assertion_scope_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n using var _ = new AssertionScope();\n await func.Should(timer).CompleteWithinAsync(100.Milliseconds());\n };\n\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_does_not_complete_the_result_extension_does_not_hang()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n using var _ = new AssertionScope();\n await func.Should(timer).CompleteWithinAsync(100.Milliseconds()).WithResult(2);\n };\n\n timer.Complete();\n\n // Assert\n var assertionTask = action.Should().ThrowAsync()\n .WithMessage(\"Expected*to complete within 100ms.\");\n\n await Awaiting(() => assertionTask).Should().CompleteWithinAsync(200.Seconds());\n }\n\n [Fact]\n public async Task When_task_consumes_time_in_sync_portion_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n Func> func = () =>\n {\n timer.Delay(101.Milliseconds());\n return taskFactory.Task;\n };\n\n return func.Should(timer).CompleteWithinAsync(100.Milliseconds());\n };\n\n taskFactory.SetResult(99);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Canceled_tasks_do_not_cause_a_default_value_to_be_returned()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => t.Task)\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds())\n .WithResult(0);\n\n taskFactory.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Exception_throwing_tasks_do_not_cause_a_default_value_to_be_returned()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => t.Task)\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds())\n .WithResult(0);\n\n taskFactory.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class NotThrowAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_fail()\n {\n // Arrange\n Func> action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().NotThrowAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_task_does_not_throw_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).NotThrowAsync())\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Can_chain_another_assertion_on_the_result_of_the_async_operation()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).NotThrowAsync())\n .Which.Should().Be(10);\n };\n\n taskFactory.SetResult(20);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*func.Result to be 10*\");\n }\n\n [Fact]\n public async Task When_task_throws_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n\n // Act\n Func action = () =>\n {\n Func> func = () => throw new AggregateException();\n\n return func.Should(timer).NotThrowAsync();\n };\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n [Collection(\"UIFacts\")]\n public class NotThrowAsyncUIFacts\n {\n [UIFact]\n public async Task When_task_does_not_throw_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).NotThrowAsync())\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [UIFact]\n public async Task When_task_throws_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n\n // Act\n Func action = () =>\n {\n Func> func = () => throw new AggregateException();\n\n return func.Should(timer).NotThrowAsync();\n };\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class NotThrowAfterAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_fail()\n {\n // Arrange\n var waitTime = 0.Milliseconds();\n var pollInterval = 0.Milliseconds();\n Func> action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().NotThrowAfterAsync(waitTime, pollInterval,\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_wait_time_is_negative_it_should_fail()\n {\n // Arrange\n var waitTime = -1.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n var asyncObject = new AsyncClass();\n Func> someFunc = () => asyncObject.ReturnTaskInt();\n\n // Act\n Func act = () => someFunc.Should().NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().ThrowAsync()\n .WithParameterName(\"waitTime\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public async Task When_poll_interval_is_negative_it_should_fail()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = -1.Milliseconds();\n\n var asyncObject = new AsyncClass();\n Func> someFunc = () => asyncObject.ReturnTaskInt();\n\n // Act\n Func act = () => someFunc.Should().NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().ThrowAsync()\n .WithParameterName(\"pollInterval\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public async Task When_exception_is_thrown_before_timeout_it_should_fail()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.CompleteAfter(waitTime);\n\n Func> throwLongerThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n return 42;\n };\n\n // Act\n Func action = () => throwLongerThanWaitTime.Should(clock)\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exceptions after 2s because we passed valid arguments*\");\n }\n\n [Fact]\n public async Task When_exception_is_thrown_after_timeout_it_should_succeed()\n {\n // Arrange\n var waitTime = 6.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.Delay(waitTime);\n\n Func> throwShorterThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Divide(12))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n return 42;\n };\n\n // Act\n Func act = async () =>\n {\n (await throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval))\n .Which.Should().Be(42);\n };\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n }\n\n public class NotThrowAfterAsyncUIFacts\n {\n [UIFact]\n public async Task When_exception_is_thrown_before_timeout_it_should_fail()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.CompleteAfter(waitTime);\n\n Func> throwLongerThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n return 42;\n };\n\n // Act\n Func action = () => throwLongerThanWaitTime.Should(clock)\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exceptions after 2s because we passed valid arguments*\");\n }\n\n [UIFact]\n public async Task When_exception_is_thrown_after_timeout_it_should_succeed()\n {\n // Arrange\n var waitTime = 6.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.Delay(waitTime);\n\n Func> throwShorterThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Divide(12))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n return 42;\n };\n\n // Act\n Func act = async () =>\n {\n (await throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval))\n .Which.Should().Be(42);\n };\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/SubsequentOrderingAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Collections;\n\n[DebuggerNonUserCode]\npublic class SubsequentOrderingAssertions\n : GenericCollectionAssertions, T>\n{\n private readonly IOrderedEnumerable previousOrderedEnumerable;\n private bool subsequentOrdering;\n\n public SubsequentOrderingAssertions(IEnumerable actualValue, IOrderedEnumerable previousOrderedEnumerable, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n this.previousOrderedEnumerable = previousOrderedEnumerable;\n }\n\n /// \n /// Asserts that a subsequence is ordered in ascending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> ThenBeInAscendingOrder(\n Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return ThenBeInAscendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a subsequence is ordered in ascending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> ThenBeInAscendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return ThenBeOrderedBy(propertyExpression, comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a subsequence is ordered in descending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> ThenBeInDescendingOrder(\n Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return ThenBeInDescendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a subsequence is ordered in descending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> ThenBeInDescendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return ThenBeOrderedBy(propertyExpression, comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n private AndConstraint> ThenBeOrderedBy(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n [StringSyntax(\"CompositeFormat\")] string because,\n object[] becauseArgs)\n {\n subsequentOrdering = true;\n return BeOrderedBy(propertyExpression, comparer, direction, because, becauseArgs);\n }\n\n internal sealed override IOrderedEnumerable GetOrderedEnumerable(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n ICollection unordered)\n {\n if (subsequentOrdering)\n {\n Func keySelector = propertyExpression.Compile();\n\n IOrderedEnumerable expectation = direction == SortOrder.Ascending\n ? previousOrderedEnumerable.ThenBy(keySelector, comparer)\n : previousOrderedEnumerable.ThenByDescending(keySelector, comparer);\n\n return expectation;\n }\n\n return base.GetOrderedEnumerable(propertyExpression, comparer, direction, unordered);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ReferenceTypeAssertionsSpecs.Satisfy.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ReferenceTypeAssertionsSpecs\n{\n public class Satisfy\n {\n [Fact]\n public void Object_satisfying_inspector_does_not_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act / Assert\n someObject.Should().Satisfy(x => x.Should().NotBeNull());\n }\n\n [Fact]\n public void Object_not_satisfying_inspector_throws()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().Satisfy(o => o.Should().BeNull(\"it is not initialized yet\"));\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"\"\"\n Expected {nameof(someObject)} to match inspector, but the inspector was not satisfied:\n *Expected o to be because it is not initialized yet, but found System.Object*\n \"\"\");\n }\n\n [Fact]\n public void Object_satisfied_against_null_throws()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().Satisfy(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify an object against a inspector.*\");\n }\n\n [Fact]\n public void Typed_object_satisfying_inspector_does_not_throw()\n {\n // Arrange\n var personDto = new PersonDto\n {\n Name = \"Name Nameson\",\n Birthdate = new DateTime(2000, 1, 1),\n };\n\n // Act / Assert\n personDto.Should().Satisfy(o => o.Age.Should().BeGreaterThan(0));\n }\n\n [Fact]\n public void Complex_typed_object_satisfying_inspector_does_not_throw()\n {\n // Arrange\n var complexDto = new PersonAndAddressDto\n {\n Person = new PersonDto\n {\n Name = \"Name Nameson\",\n Birthdate = new DateTime(2000, 1, 1),\n },\n Address = new AddressDto\n {\n Street = \"Named St.\",\n Number = \"42\",\n City = \"Nowhere\",\n Country = \"Neverland\",\n PostalCode = \"12345\",\n }\n };\n\n // Act / Assert\n complexDto.Should().Satisfy(dto =>\n {\n dto.Person.Should().Satisfy(person =>\n {\n person.Name.Should().Be(\"Name Nameson\");\n person.Age.Should().BeGreaterThan(0);\n person.Birthdate.Should().Be(1.January(2000));\n });\n\n dto.Address.Should().Satisfy(address =>\n {\n address.Street.Should().Be(\"Named St.\");\n address.Number.Should().Be(\"42\");\n address.City.Should().Be(\"Nowhere\");\n address.Country.Should().Be(\"Neverland\");\n address.PostalCode.Should().Be(\"12345\");\n });\n });\n }\n\n [Fact]\n public void Typed_object_not_satisfying_inspector_throws()\n {\n // Arrange\n var personDto = new PersonDto\n {\n Name = \"Name Nameson\",\n Birthdate = new DateTime(2000, 1, 1),\n };\n\n // Act\n Action act = () => personDto.Should().Satisfy(d =>\n {\n d.Name.Should().Be(\"Someone Else\");\n d.Age.Should().BeLessThan(20);\n d.Birthdate.Should().BeAfter(1.January(2001));\n });\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"\"\"\n Expected {nameof(personDto)} to match inspector, but the inspector was not satisfied:\n *Expected d.Name*\n *Expected d.Age*\n *Expected d.Birthdate*\n \"\"\");\n }\n\n [Fact]\n public void Complex_typed_object_not_satisfying_inspector_throws()\n {\n // Arrange\n var complexDto = new PersonAndAddressDto\n {\n Person = new PersonDto\n {\n Name = \"Buford Howard Tannen\",\n Birthdate = new DateTime(1937, 3, 26),\n },\n Address = new AddressDto\n {\n Street = \"Mason Street\",\n Number = \"1809\",\n City = \"Hill Valley\",\n Country = \"United States\",\n PostalCode = \"CA 91905\",\n },\n };\n\n // Act\n Action act = () => complexDto.Should().Satisfy(dto =>\n {\n dto.Person.Should().Satisfy(person =>\n {\n person.Name.Should().Be(\"Biff Tannen\");\n person.Age.Should().Be(48);\n person.Birthdate.Should().Be(26.March(1937));\n });\n\n dto.Address.Should().Satisfy(address =>\n {\n address.Street.Should().Be(\"Mason Street\");\n address.Number.Should().Be(\"1809\");\n address.City.Should().Be(\"Hill Valley, San Diego County, California\");\n address.Country.Should().Be(\"United States\");\n address.PostalCode.Should().Be(\"CA 91905\");\n });\n });\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"\"\"\n Expected {nameof(complexDto)} to match inspector, but the inspector was not satisfied:\n *Expected dto.Person to match inspector*\n *Expected person.Name*\n *Expected dto.Address to match inspector*\n *Expected address.City*\n \"\"\");\n }\n\n [Fact]\n public void Typed_object_satisfied_against_incorrect_type_throws()\n {\n // Arrange\n var personDto = new PersonDto();\n\n // Act\n Action act = () => personDto.Should().Satisfy(dto => dto.Should().NotBeNull());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected {nameof(personDto)} to be assignable to {typeof(AddressDto)}, but {typeof(PersonDto)} is not.\");\n }\n\n [Fact]\n public void Sub_class_satisfied_against_base_class_does_not_throw()\n {\n // Arrange\n var subClass = new SubClass\n {\n Number = 42,\n Date = new DateTime(2021, 1, 1),\n Text = \"Some text\"\n };\n\n // Act / Assert\n subClass.Should().Satisfy(x =>\n {\n x.Number.Should().Be(42);\n x.Date.Should().Be(1.January(2021));\n });\n }\n\n [Fact]\n public void Base_class_satisfied_against_sub_class_throws()\n {\n // Arrange\n var baseClass = new BaseClass\n {\n Number = 42,\n Date = new DateTime(2021, 1, 1),\n };\n\n // Act\n Action act = () => baseClass.Should().Satisfy(x =>\n {\n x.Number.Should().Be(42);\n x.Date.Should().Be(1.January(2021));\n x.Text.Should().Be(\"Some text\");\n });\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected {nameof(baseClass)} to be assignable to {typeof(SubClass)}, but {typeof(BaseClass)} is not.\");\n }\n\n [Fact]\n public void Nested_assertion_on_null_throws()\n {\n // Arrange\n var complexDto = new PersonAndAddressDto\n {\n Person = new PersonDto\n {\n Name = \"Buford Howard Tannen\",\n },\n Address = null,\n };\n\n // Act\n Action act = () => complexDto.Should().Satisfy(dto =>\n {\n dto.Person.Name.Should().Be(\"Buford Howard Tannen\");\n dto.Address.Should().Satisfy(address => address.City.Should().Be(\"Hill Valley\"));\n });\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"\"\"\n Expected {nameof(complexDto)} to match inspector, but the inspector was not satisfied:\n *Expected dto.Address to be assignable to {typeof(AddressDto)}, but found .\n \"\"\");\n }\n\n [Fact]\n public void Using_nested_assertion_scope()\n {\n // Arrange\n var complexDto = new PersonAndAddressDto\n {\n Person = new PersonDto\n {\n Name = \"Buford Howard Tannen\",\n },\n Address = null,\n };\n\n // Act\n Action act = () => complexDto.Should().Satisfy(dto =>\n {\n dto.Person.Name.Should().Be(\"Buford Howard Tannen\");\n\n using (new AssertionScope())\n {\n dto.Address.Should().Satisfy(address => address.City.Should().Be(\"Hill Valley\"));\n }\n });\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"\"\"\n Expected {nameof(complexDto)} to match inspector, but the inspector was not satisfied:\n *Expected dto.Address to be assignable to {typeof(AddressDto)}, but found .\n \"\"\");\n }\n\n [Fact]\n public void Using_assertion_scope_with_null_subject()\n {\n // Arrange\n object subject = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n subject.Should().Satisfy(x => x.Should().NotBeNull());\n }\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be assignable to object, but found .\");\n }\n\n [Fact]\n public void Using_assertion_scope_with_subject_satisfied_against_incorrect_type_throws()\n {\n // Arrange\n var personDto = new PersonDto();\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n personDto.Should().Satisfy(dto => dto.Should().NotBeNull());\n }\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected {nameof(personDto)} to be assignable to {typeof(AddressDto)}, but {typeof(PersonDto)} is not.\");\n }\n }\n\n private class PersonDto\n {\n public string Name { get; init; }\n\n public DateTime Birthdate { get; init; }\n\n public int Age => DateTime.UtcNow.Subtract(Birthdate).Days / 365;\n }\n\n private class PersonAndAddressDto\n {\n public PersonDto Person { get; init; }\n\n public AddressDto Address { get; init; }\n }\n\n private class AddressDto\n {\n public string Street { get; init; }\n\n public string Number { get; init; }\n\n public string City { get; init; }\n\n public string PostalCode { get; init; }\n\n public string Country { get; init; }\n }\n\n private class BaseClass\n {\n public int Number { get; init; }\n\n public DateTime Date { get; init; }\n }\n\n private sealed class SubClass : BaseClass\n {\n public string Text { get; init; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NumericAssertionsBase.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\npublic abstract class NumericAssertionsBase\n where T : struct, IComparable\n where TAssertions : NumericAssertionsBase\n{\n public abstract TSubject Subject { get; }\n\n protected NumericAssertionsBase(AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the integral number value is exactly the same as the value.\n /// \n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T subject && subject.CompareTo(expected) == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be {0}{reason}, but found {1}\" + GenerateDifferenceMessage(expected), expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the integral number value is exactly the same as the value.\n /// \n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(T? expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(expected is { } value ? Subject is T subject && subject.CompareTo(value) == 0 : Subject is not T)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be {0}{reason}, but found {1}\" + GenerateDifferenceMessage(expected), expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the integral number value is not the same as the value.\n /// \n /// The unexpected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(T unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is not T subject || subject.CompareTo(unexpected) != 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the integral number value is not the same as the value.\n /// \n /// The unexpected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(T? unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(unexpected is { } value ? Subject is not T subject || subject.CompareTo(value) != 0 : Subject is T)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is greater than zero.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BePositive([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T subject && subject.CompareTo(default) > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be positive{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is less than zero.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNegative([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T value && !IsNaN(value) && value.CompareTo(default) < 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be negative{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is less than the specified value.\n /// \n /// The value to compare the current numeric value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThan(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(expected))\n {\n throw new ArgumentException(\"A value can never be less than NaN\", nameof(expected));\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T value && !IsNaN(value) && value.CompareTo(expected) < 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be less than {0}{reason}, but found {1}\" + GenerateDifferenceMessage(expected),\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is less than or equal to the specified value.\n /// \n /// The value to compare the current numeric value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThanOrEqualTo(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(expected))\n {\n throw new ArgumentException(\"A value can never be less than or equal to NaN\", nameof(expected));\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T value && !IsNaN(value) && value.CompareTo(expected) <= 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:value} to be less than or equal to {0}{reason}, but found {1}\" +\n GenerateDifferenceMessage(expected), expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is greater than the specified value.\n /// \n /// The value to compare the current numeric value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThan(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(expected))\n {\n throw new ArgumentException(\"A value can never be greater than NaN\", nameof(expected));\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T subject && subject.CompareTo(expected) > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:value} to be greater than {0}{reason}, but found {1}\" + GenerateDifferenceMessage(expected),\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is greater than or equal to the specified value.\n /// \n /// The value to compare the current numeric value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThanOrEqualTo(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(expected))\n {\n throw new ArgumentException(\"A value can never be greater than or equal to a NaN\", nameof(expected));\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T subject && subject.CompareTo(expected) >= 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:value} to be greater than or equal to {0}{reason}, but found {1}\" +\n GenerateDifferenceMessage(expected), expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is within a range.\n /// \n /// \n /// Where the range is continuous or incremental depends on the actual type of the value.\n /// \n /// \n /// The minimum valid value of the range (inclusive).\n /// \n /// \n /// The maximum valid value of the range (inclusive).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeInRange(T minimumValue, T maximumValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(minimumValue) || IsNaN(maximumValue))\n {\n throw new ArgumentException(\"A range cannot begin or end with NaN\");\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T value && value.CompareTo(minimumValue) >= 0 && value.CompareTo(maximumValue) <= 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be between {0} and {1}{reason}, but found {2}.\",\n minimumValue, maximumValue, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is not within a range.\n /// \n /// \n /// Where the range is continuous or incremental depends on the actual type of the value.\n /// \n /// \n /// The minimum valid value of the range.\n /// \n /// \n /// The maximum valid value of the range.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeInRange(T minimumValue, T maximumValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(minimumValue) || IsNaN(maximumValue))\n {\n throw new ArgumentException(\"A range cannot begin or end with NaN\");\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T value && !(value.CompareTo(minimumValue) >= 0 && value.CompareTo(maximumValue) <= 0))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not be between {0} and {1}{reason}, but found {2}.\",\n minimumValue, maximumValue, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params T[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T value && validValues.Contains(value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is of the specified type .\n /// \n /// \n /// The type that the subject is supposed to be of.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeOfType(Type expectedType, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedType);\n\n Type subjectType = Subject?.GetType();\n\n if (expectedType.IsGenericTypeDefinition && subjectType?.IsGenericType == true)\n {\n subjectType.GetGenericTypeDefinition().Should().Be(expectedType, because, becauseArgs);\n }\n else\n {\n subjectType.Should().Be(expectedType, because, becauseArgs);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is not of the specified type .\n /// \n /// \n /// The type that the subject is not supposed to be of.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeOfType(Type unexpectedType, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedType);\n\n CurrentAssertionChain\n .ForCondition(Subject is T)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected type not to be {0}{reason}, but found .\", unexpectedType);\n\n if (CurrentAssertionChain.Succeeded)\n {\n Subject.GetType().Should().NotBe(unexpectedType, because, becauseArgs);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is satisfied.\n /// \n /// \n /// The predicate which must be satisfied\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n CurrentAssertionChain\n .ForCondition(Subject is T expression && predicate.Compile()(expression))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to match {0}{reason}, but found {1}.\", predicate.Body, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n\n private protected virtual bool IsNaN(T value) => false;\n\n /// \n /// A method to generate additional information upon comparison failures.\n /// \n /// The current numeric value verified to be non-null.\n /// The value to compare the current numeric value with.\n /// \n /// Returns the difference between a number value and the value.\n /// Returns `null` if the compared numbers are small enough that a difference message is irrelevant.\n /// \n private protected virtual string CalculateDifferenceForFailureMessage(T subject, T expected) => null;\n\n private string GenerateDifferenceMessage(T? expected)\n {\n const string noDifferenceMessage = \".\";\n\n if (Subject is not T subject || expected is not { } expectedValue)\n {\n return noDifferenceMessage;\n }\n\n var difference = CalculateDifferenceForFailureMessage(subject, expectedValue);\n return difference is null ? noDifferenceMessage : $\" (difference of {difference}).\";\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/ObjectExtensionsSpecs.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class ObjectExtensionsSpecs\n{\n [Theory]\n [MemberData(nameof(GetNonEquivalentNumericData))]\n public void When_comparing_non_equivalent_boxed_numerics_it_should_fail(object actual, object expected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, expected);\n\n // Assert\n success.Should().BeFalse();\n }\n\n public static TheoryData GetNonEquivalentNumericData => new()\n {\n { double.Epsilon, 0M }, // double.Epsilon cannot be represented in Decimal\n { 0M, double.Epsilon },\n { double.Epsilon, 0.3M }, // 0.3M cannot be represented in double\n { 0.3M, double.Epsilon },\n { (byte)2, 256 }, // 256 cannot be represented in byte\n { 256, (byte)2 },\n { -1, (ushort)65535 }, // 65535 is -1 casted to ushort\n { (ushort)65535, -1 },\n { 0.02d, 0 },\n { 0, 0.02d },\n { 0.02f, 0 },\n { 0, 0.02f },\n { long.MaxValue, 9.22337204E+18 },\n { 9.22337204E+18, long.MaxValue },\n { 9223372030000000000L, 9.22337204E+18 },\n { 9.22337204E+18, 9223372030000000000L }\n };\n\n [Theory]\n [MemberData(nameof(GetNumericAndNumericData))]\n public void When_comparing_a_numeric_to_a_numeric_it_should_succeed(object actual, object expected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, expected);\n\n // Assert\n success.Should().BeTrue();\n }\n\n public static TheoryData GetNumericAndNumericData()\n {\n var pairs =\n from x in GetNumericIConvertibles()\n from y in GetNumericIConvertibles()\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n [Theory]\n [MemberData(nameof(GetNonNumericAndNumericData))]\n public void When_comparing_a_non_numeric_to_a_numeric_it_should_fail(object actual, object unexpected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, unexpected);\n\n // Assert\n success.Should().BeFalse();\n }\n\n public static TheoryData GetNonNumericAndNumericData()\n {\n var pairs =\n from x in GetNonNumericIConvertibles()\n from y in GetNumericIConvertibles()\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n [Theory]\n [MemberData(nameof(GetNumericAndNonNumericData))]\n public void When_comparing_a_numeric_to_a_non_numeric_it_should_fail(object actual, object unexpected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, unexpected);\n\n // Assert\n success.Should().BeFalse();\n }\n\n public static TheoryData GetNumericAndNonNumericData()\n {\n var pairs =\n from x in GetNumericIConvertibles()\n from y in GetNonNumericIConvertibles()\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n [Theory]\n [MemberData(nameof(GetNonNumericAndNonNumericData))]\n public void When_comparing_a_non_numeric_to_a_non_numeric_it_should_fail(object actual, object unexpected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, unexpected);\n\n // Assert\n success.Should().BeFalse();\n }\n\n public static TheoryData GetNonNumericAndNonNumericData()\n {\n object[] nonNumerics = GetNonNumericIConvertibles();\n\n var pairs =\n from x in nonNumerics\n from y in nonNumerics\n where x != y\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n private static object[] GetNumericIConvertibles()\n {\n return\n [\n (byte)1,\n (sbyte)1,\n (short)1,\n (ushort)1,\n 1,\n 1U,\n 1L,\n 1UL,\n 1F,\n 1D,\n 1M,\n ];\n }\n\n private static object[] GetNonNumericIConvertibles()\n {\n return\n [\n true,\n '\\u0001',\n new DateTime(1),\n DBNull.Value,\n \"1\"\n ];\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.cs", "using System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Specs.Types\n{\n /// \n /// Type assertion specs.\n /// \n public partial class TypeAssertionSpecs;\n\n #region Internal classes used in unit tests\n\n [DummyClass(\"Expected\", true)]\n public class ClassWithAttribute;\n\n public class ClassWithInheritedAttribute : ClassWithAttribute;\n\n public class ClassWithoutAttribute;\n\n public class OtherClassWithoutAttribute;\n\n [AttributeUsage(AttributeTargets.Class)]\n public class DummyClassAttribute : Attribute\n {\n public string Name { get; }\n\n public bool IsEnabled { get; }\n\n public DummyClassAttribute(string name, bool isEnabled)\n {\n Name = name;\n IsEnabled = isEnabled;\n }\n }\n\n public interface IDummyInterface;\n\n public interface IDummyInterface;\n\n public class ClassThatImplementsInterface : IDummyInterface, IDummyInterface;\n\n public class ClassThatDoesNotImplementInterface;\n\n public class DummyBaseType : IDummyInterface;\n\n public class ClassWithGenericBaseType : DummyBaseType;\n\n public class ClassWithMembers\n {\n protected internal ClassWithMembers() { }\n\n private ClassWithMembers(string _) { }\n\n protected string PrivateWriteProtectedReadProperty { get => null; private set { } }\n\n internal string this[string str] { private get => str; set { } }\n\n protected internal string this[int i] { get => i.ToString(CultureInfo.InvariantCulture); private set { } }\n\n private void VoidMethod() { }\n\n private void VoidMethod(string _) { }\n }\n\n public class ClassExplicitlyImplementingInterface : IExplicitInterface\n {\n public string ImplicitStringProperty { get => null; private set { } }\n\n string IExplicitInterface.ExplicitStringProperty { set { } }\n\n public string ExplicitImplicitStringProperty { get; set; }\n\n string IExplicitInterface.ExplicitImplicitStringProperty { get; set; }\n\n public void ImplicitMethod() { }\n\n public void ImplicitMethod(string overload) { }\n\n void IExplicitInterface.ExplicitMethod() { }\n\n void IExplicitInterface.ExplicitMethod(string overload) { }\n\n public void ExplicitImplicitMethod() { }\n\n public void ExplicitImplicitMethod(string _) { }\n\n void IExplicitInterface.ExplicitImplicitMethod() { }\n\n void IExplicitInterface.ExplicitImplicitMethod(string overload) { }\n }\n\n public interface IExplicitInterface\n {\n string ImplicitStringProperty { get; }\n\n string ExplicitStringProperty { set; }\n\n string ExplicitImplicitStringProperty { get; set; }\n\n void ImplicitMethod();\n\n void ImplicitMethod(string overload);\n\n void ExplicitMethod();\n\n void ExplicitMethod(string overload);\n\n void ExplicitImplicitMethod();\n\n void ExplicitImplicitMethod(string overload);\n }\n\n public class ClassWithoutMembers;\n\n public interface IPublicInterface;\n\n internal interface IInternalInterface;\n\n internal class InternalClass;\n\n internal struct InternalStruct;\n\n internal enum InternalEnum\n {\n Value1,\n Value2\n }\n\n internal class Nested\n {\n private class PrivateClass;\n\n protected enum ProtectedEnum;\n\n public interface IPublicInterface;\n\n internal class InternalClass;\n\n protected internal interface IProtectedInternalInterface;\n }\n\n internal readonly struct TypeWithConversionOperators\n {\n private readonly int value;\n\n private TypeWithConversionOperators(int value)\n {\n this.value = value;\n }\n\n public static implicit operator int(TypeWithConversionOperators typeWithConversionOperators) =>\n typeWithConversionOperators.value;\n\n public static explicit operator byte(TypeWithConversionOperators typeWithConversionOperators) =>\n (byte)typeWithConversionOperators.value;\n }\n\n internal sealed class Sealed;\n\n internal abstract class Abstract;\n\n internal static class Static;\n\n internal struct Struct;\n\n public delegate void ExampleDelegate();\n\n internal class ClassNotInDummyNamespace;\n\n internal class OtherClassNotInDummyNamespace;\n\n internal class GenericClass;\n\n #endregion\n}\n\nnamespace AssemblyB\n{\n#pragma warning disable 436 // disable the warning on conflicting types, as this is the intention for the spec\n\n /// \n /// A class that intentionally has the exact same name and namespace as the ClassC from the AssemblyB\n /// assembly. This class is used to test the behavior of comparisons on such types.\n /// \n internal class ClassC;\n\n#pragma warning restore 436\n}\n\n#region Internal classes used in unit tests\n\nnamespace DummyNamespace\n{\n internal class ClassInDummyNamespace;\n\n namespace InnerDummyNamespace\n {\n internal class ClassInInnerDummyNamespace;\n }\n}\n\nnamespace DummyNamespaceTwo\n{\n internal class ClassInDummyNamespaceTwo;\n}\n\n#endregion\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/TypeEnumerableExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Types;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Extension methods for filtering a collection of types.\n/// \npublic static class TypeEnumerableExtensions\n{\n /// \n /// Filters to only include types decorated with a particular attribute.\n /// \n public static IEnumerable ThatAreDecoratedWith(this IEnumerable types)\n where TAttribute : Attribute\n {\n return new TypeSelector(types).ThatAreDecoratedWith();\n }\n\n /// \n /// Filters to only include types decorated with, or inherits from a parent class, a particular attribute.\n /// \n public static IEnumerable ThatAreDecoratedWithOrInherit(this IEnumerable types)\n where TAttribute : Attribute\n {\n return new TypeSelector(types).ThatAreDecoratedWithOrInherit();\n }\n\n /// \n /// Filters to only include types not decorated with a particular attribute.\n /// \n public static IEnumerable ThatAreNotDecoratedWith(this IEnumerable types)\n where TAttribute : Attribute\n {\n return new TypeSelector(types).ThatAreNotDecoratedWith();\n }\n\n /// \n /// Filters to only include types not decorated with and does not inherit from a parent class, a particular attribute.\n /// \n public static IEnumerable ThatAreNotDecoratedWithOrInherit(this IEnumerable types)\n where TAttribute : Attribute\n {\n return new TypeSelector(types).ThatAreNotDecoratedWithOrInherit();\n }\n\n /// \n /// Filters to only include types where the namespace of type is exactly .\n /// \n public static IEnumerable ThatAreInNamespace(this IEnumerable types, string @namespace)\n {\n return new TypeSelector(types).ThatAreInNamespace(@namespace);\n }\n\n /// \n /// Filters to only include types where the namespace of type is starts with .\n /// \n public static IEnumerable ThatAreUnderNamespace(this IEnumerable types, string @namespace)\n {\n return new TypeSelector(types).ThatAreUnderNamespace(@namespace);\n }\n\n /// \n /// Filters to only include types that subclass the specified type, but NOT the same type.\n /// \n public static IEnumerable ThatDeriveFrom(this IEnumerable types)\n {\n return new TypeSelector(types).ThatDeriveFrom();\n }\n\n /// \n /// Determines whether a type implements an interface (but is not the interface itself).\n /// \n public static IEnumerable ThatImplement(this IEnumerable types)\n {\n return new TypeSelector(types).ThatImplement();\n }\n\n /// \n /// Filters to only include types that are classes.\n /// \n public static IEnumerable ThatAreClasses(this IEnumerable types)\n {\n return new TypeSelector(types).ThatAreClasses();\n }\n\n /// \n /// Filters to only include types that are not classes.\n /// \n public static IEnumerable ThatAreNotClasses(this IEnumerable types)\n {\n return new TypeSelector(types).ThatAreNotClasses();\n }\n\n /// \n /// Filters to only include types that are static.\n /// \n public static IEnumerable ThatAreStatic(this IEnumerable types)\n {\n return new TypeSelector(types).ThatAreStatic();\n }\n\n /// \n /// Filters to only include types that are not static.\n /// \n public static IEnumerable ThatAreNotStatic(this IEnumerable types)\n {\n return new TypeSelector(types).ThatAreNotStatic();\n }\n\n /// \n /// Filters to only include types that satisfies the passed.\n /// \n public static IEnumerable ThatSatisfy(this IEnumerable types, Func predicate)\n {\n return new TypeSelector(types).ThatSatisfy(predicate);\n }\n\n /// \n /// Returns T for the types which are or ; the type itself otherwise\n /// \n public static IEnumerable UnwrapTaskTypes(this IEnumerable types)\n {\n return new TypeSelector(types).UnwrapTaskTypes();\n }\n\n /// \n /// Returns T for the types which are or implement the ; the type itself otherwise\n /// \n public static IEnumerable UnwrapEnumerableTypes(this IEnumerable types)\n {\n return new TypeSelector(types).UnwrapEnumerableTypes();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TaskFormatter.cs", "using System.Threading.Tasks;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Provides a human-readable version of a generic or non-generic \n/// including its state.\n/// \npublic class TaskFormatter : IValueFormatter\n{\n public bool CanHandle(object value)\n {\n return value is Task;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var task = (Task)value;\n formatChild(\"type\", task.GetType(), formattedGraph);\n formattedGraph.AddFragment($\" {{Status={task.Status}}}\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/ReferenceTypeAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a reference type object is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic abstract class ReferenceTypeAssertions\n where TAssertions : ReferenceTypeAssertions\n{\n protected ReferenceTypeAssertions(TSubject subject, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = subject;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public TSubject Subject { get; }\n\n /// \n /// Asserts that the current object has not been initialized yet.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be {reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current object has been initialized.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} not to be {reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object reference refers to the exact same object as another object reference.\n /// \n /// The expected object\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSameAs(TSubject expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(ReferenceEquals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to refer to {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object reference refers to a different object than another object reference refers to.\n /// \n /// The unexpected object\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSameAs(TSubject unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(!ReferenceEquals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Did not expect {context} to refer to {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is of the specified type .\n /// \n /// The expected type of the object.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint BeOfType([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n BeOfType(typeof(T), because, becauseArgs);\n\n T typedSubject = Subject is T type\n ? type\n : default;\n\n return new AndWhichConstraint((TAssertions)this, typedSubject);\n }\n\n /// \n /// Asserts that the object is of the .\n /// \n /// \n /// The type that the subject is supposed to be.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeOfType(Type expectedType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedType);\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} to be {0}{reason}, but found .\", expectedType);\n\n if (CurrentAssertionChain.Succeeded)\n {\n Type subjectType = Subject.GetType();\n\n if (expectedType.IsGenericTypeDefinition && subjectType.IsGenericType)\n {\n subjectType.GetGenericTypeDefinition().Should().Be(expectedType, because, becauseArgs);\n }\n else\n {\n subjectType.Should().Be(expectedType, because, becauseArgs);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is not of the specified type .\n /// \n /// The type that the subject is not supposed to be.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOfType([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n NotBeOfType(typeof(T), because, becauseArgs);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is not the .\n /// \n /// \n /// The type that the subject is not supposed to be.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeOfType(Type unexpectedType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedType);\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} not to be {0}{reason}, but found .\", unexpectedType);\n\n if (CurrentAssertionChain.Succeeded)\n {\n Type subjectType = Subject.GetType();\n\n if (unexpectedType.IsGenericTypeDefinition && subjectType.IsGenericType)\n {\n subjectType.GetGenericTypeDefinition().Should().NotBe(unexpectedType, because, becauseArgs);\n }\n else\n {\n subjectType.Should().NotBe(unexpectedType, because, becauseArgs);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is assignable to a variable of type .\n /// \n /// The type to which the object should be assignable to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public AndWhichConstraint BeAssignableTo([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} to be assignable to {0}{reason}, but found .\", typeof(T));\n\n if (CurrentAssertionChain.Succeeded)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be assignable to {0}{reason}, but {1} is not.\", typeof(T), Subject.GetType());\n }\n\n T typedSubject = Subject is T type\n ? type\n : default;\n\n return new AndWhichConstraint((TAssertions)this, typedSubject);\n }\n\n /// \n /// Asserts that the object is assignable to a variable of given .\n /// \n /// The type to which the object should be assignable to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint BeAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} to be assignable to {0}{reason}, but found .\", type);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool isAssignable = type.IsGenericTypeDefinition\n ? Subject.GetType().IsAssignableToOpenGeneric(type)\n : type.IsAssignableFrom(Subject.GetType());\n\n CurrentAssertionChain\n .ForCondition(isAssignable)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be assignable to {0}{reason}, but {1} is not.\",\n type,\n Subject.GetType());\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is not assignable to a variable of type .\n /// \n /// The type to which the object should not be assignable to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public AndConstraint NotBeAssignableTo([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeAssignableTo(typeof(T), because, becauseArgs);\n }\n\n /// \n /// Asserts that the object is not assignable to a variable of given .\n /// \n /// The type to which the object should not be assignable to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint NotBeAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} to not be assignable to {0}{reason}, but found .\", type);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool isAssignable = type.IsGenericTypeDefinition\n ? Subject.GetType().IsAssignableToOpenGeneric(type)\n : type.IsAssignableFrom(Subject.GetType());\n\n CurrentAssertionChain\n .ForCondition(!isAssignable)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to not be assignable to {0}{reason}, but {1} is.\", type, Subject.GetType());\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is satisfied.\n /// \n /// The predicate which must be satisfied by the .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return Match(predicate, because, becauseArgs);\n }\n\n /// \n /// Asserts that the is satisfied.\n /// \n /// The predicate which must be satisfied by the .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : TSubject\n {\n Guard.ThrowIfArgumentIsNull(predicate, nameof(predicate), \"Cannot match an object against a predicate.\");\n\n CurrentAssertionChain\n .ForCondition(predicate.Compile()((T)Subject))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context:object} to match {1}{reason}, but found {0}.\", Subject, predicate);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Allows combining one or more assertions using the other assertion methods that this library offers on an instance of .\n /// \n /// \n /// If multiple assertions executed by the fail, they will be raised as a single failure.\n /// \n /// The element inspector which must be satisfied by the .\n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint Satisfy(Action assertion)\n where T : TSubject\n {\n Guard.ThrowIfArgumentIsNull(assertion, nameof(assertion), \"Cannot verify an object against a inspector.\");\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context:object} to be assignable to {0}{reason}, but found .\", typeof(T))\n .Then\n .ForCondition(Subject is T)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context:object} to be assignable to {0}{reason}, but {1} is not.\", typeof(T),\n Subject?.GetType());\n\n if (CurrentAssertionChain.Succeeded)\n {\n string[] failuresFromInspector;\n\n using (var assertionScope = new AssertionScope())\n {\n assertion((T)Subject);\n failuresFromInspector = assertionScope.Discard();\n }\n\n if (failuresFromInspector.Length > 0)\n {\n string failureMessage = Environment.NewLine\n + string.Join(Environment.NewLine, failuresFromInspector.Select(x => x.IndentLines()));\n\n CurrentAssertionChain\n .WithDefaultIdentifier(Identifier)\n .WithExpectation(\"Expected {context:object} to match inspector, but the inspector was not satisfied:\",\n Subject,\n chain => chain.FailWithPreFormatted(failureMessage));\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// It should be a user-friendly name as it is included in the failure message.\n /// \n protected abstract string Identifier { get; }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean BeSameAs() instead?\");\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MethodBaseAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic abstract class MethodBaseAssertions : MemberInfoAssertions\n where TSubject : MethodBase\n where TAssertions : MethodBaseAssertions\n{\n private readonly AssertionChain assertionChain;\n\n protected MethodBaseAssertions(TSubject subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the selected member has the specified C# .\n /// \n /// The expected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint HaveAccessModifier(\n CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected method to be {accessModifier}{{reason}}, but {{context:method}} is .\");\n\n if (assertionChain.Succeeded)\n {\n CSharpAccessModifier subjectAccessModifier = Subject.GetCSharpAccessModifier();\n\n assertionChain\n .ForCondition(accessModifier == subjectAccessModifier)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subject = GetSubjectDescription(assertionChain);\n\n return new FailReason(\n $\"Expected {subject} to be {accessModifier}{{reason}}, but it is {subjectAccessModifier}.\");\n });\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the selected member does not have the specified C# .\n /// \n /// The unexpected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint NotHaveAccessModifier(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected method not to be {accessModifier}{{reason}}, but {{context:member}} is .\");\n\n if (assertionChain.Succeeded)\n {\n CSharpAccessModifier subjectAccessModifier = Subject.GetCSharpAccessModifier();\n\n assertionChain\n .ForCondition(accessModifier != subjectAccessModifier)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subject = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subject} not to be {accessModifier}{{reason}}, but it is.\");\n });\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n internal static string GetParameterString(MethodBase methodBase)\n {\n IEnumerable parameterTypes = methodBase.GetParameters().Select(p => p.ParameterType);\n\n return string.Join(\", \", parameterTypes.Select(p => p.AsFormattableShortType().ToFormattedString()));\n }\n\n private protected string GetSubjectDescription(AssertionChain assertionChain) =>\n assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : $\"{Identifier} {Subject.ToFormattedString()}\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DateTimeOffsetValueFormatter.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DateTimeOffsetValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is DateTime or DateTimeOffset;\n }\n\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\", Justification = \"Needs to be refactored\")]\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n DateTimeOffset dateTimeOffset;\n bool significantOffset = false;\n\n if (value is DateTime dateTime)\n {\n dateTimeOffset = dateTime.ToDateTimeOffset();\n }\n else\n {\n dateTimeOffset = (DateTimeOffset)value;\n significantOffset = true;\n }\n\n formattedGraph.AddFragment(\"<\");\n\n bool hasDate = HasDate(dateTimeOffset);\n\n if (hasDate)\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"yyyy-MM-dd\", CultureInfo.InvariantCulture));\n }\n\n bool hasTime = HasTime(dateTimeOffset);\n\n if (hasTime)\n {\n if (hasDate)\n {\n formattedGraph.AddFragment(\" \");\n }\n\n if (HasNanoSeconds(dateTimeOffset))\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"HH:mm:ss.fffffff\", CultureInfo.InvariantCulture));\n }\n else if (HasMicroSeconds(dateTimeOffset))\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"HH:mm:ss.ffffff\", CultureInfo.InvariantCulture));\n }\n else if (HasMilliSeconds(dateTimeOffset))\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"HH:mm:ss.fff\", CultureInfo.InvariantCulture));\n }\n else\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"HH:mm:ss\", CultureInfo.InvariantCulture));\n }\n }\n\n if (dateTimeOffset.Offset > TimeSpan.Zero)\n {\n formattedGraph.AddFragment(\" +\");\n formatChild(\"offset\", dateTimeOffset.Offset, formattedGraph);\n }\n else if (dateTimeOffset.Offset < TimeSpan.Zero)\n {\n formattedGraph.AddFragment(\" \");\n formatChild(\"offset\", dateTimeOffset.Offset, formattedGraph);\n }\n else if (significantOffset && (hasDate || hasTime))\n {\n formattedGraph.AddFragment(\" +0h\");\n }\n else\n {\n // No offset added, since it was deemed unnecessary\n }\n\n if (!hasDate && !hasTime)\n {\n formattedGraph.AddFragment(\"0001-01-01 00:00:00.000\");\n }\n\n formattedGraph.AddFragment(\">\");\n }\n\n private static bool HasTime(DateTimeOffset dateTime)\n {\n return dateTime.Hour != 0\n || dateTime.Minute != 0\n || dateTime.Second != 0\n || HasMilliSeconds(dateTime)\n || HasMicroSeconds(dateTime)\n || HasNanoSeconds(dateTime);\n }\n\n private static bool HasDate(DateTimeOffset dateTime)\n {\n return dateTime.Day != 1 || dateTime.Month != 1 || dateTime.Year != 1;\n }\n\n private static bool HasMilliSeconds(DateTimeOffset dateTime)\n {\n return dateTime.Millisecond > 0;\n }\n\n private static bool HasMicroSeconds(DateTimeOffset dateTime)\n {\n return (dateTime.Ticks % TimeSpan.FromMilliseconds(1).Ticks) > 0;\n }\n\n private static bool HasNanoSeconds(DateTimeOffset dateTime)\n {\n return (dateTime.Ticks % (TimeSpan.FromMilliseconds(1).Ticks / 1000)) > 0;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TypeValueFormatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic sealed class TypeValueFormatter : IValueFormatter\n{\n public bool CanHandle(object value)\n {\n return value is Type or ShortTypeValue;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n if (value is ShortTypeValue shortValue)\n {\n FormatType(shortValue.Type, formattedGraph.AddFragment, withNamespaces: false);\n }\n else\n {\n FormatType((Type)value, formattedGraph.AddFragment);\n }\n }\n\n /// \n /// Format a type to a friendly name.\n /// \n /// The type to format.\n /// The friendly type name.\n internal static string Format(Type type)\n {\n StringBuilder sb = new();\n FormatType(type, value => sb.Append(value));\n return sb.ToString();\n }\n\n /// \n /// Format a type to a friendly name.\n /// \n /// The type to format.\n /// Function for appending the formatted type part\n /// \n /// If true, all types, including inner types of generic arguments, are formatted\n /// using their full namespace.\n /// \n internal static void FormatType(Type type, Action append, bool withNamespaces = true)\n {\n if (Nullable.GetUnderlyingType(type) is Type nullbase)\n {\n FormatType(nullbase, append, withNamespaces);\n append(\"?\");\n }\n else if (type.IsGenericType)\n {\n if (withNamespaces && !string.IsNullOrEmpty(type.Namespace))\n {\n append(type.Namespace);\n append(\".\");\n }\n\n FormatGenericType(type, append, withNamespaces);\n }\n else if (type.BaseType == typeof(Array))\n {\n FormatArrayType(type, append, withNamespaces);\n }\n else if (LanguageKeywords.TryGetValue(type, out string alias))\n {\n append(alias);\n }\n else if (withNamespaces)\n {\n append(type.FullName);\n }\n else\n {\n append(type.Name);\n }\n }\n\n /// \n /// Format an array type of any dimension.\n /// \n /// The array type. Can have any dimension.\n /// Function for appending the formatted type part.\n /// If true, the type is formatted with its full namespace.\n private static void FormatArrayType(Type type, Action append, bool withNamespace)\n {\n FormatType(type.GetElementType(), append, withNamespace);\n\n append(\"[\");\n append(new string(',', type.GetArrayRank() - 1));\n append(\"]\");\n }\n\n /// \n /// Format a bound or unbound generic type.\n /// \n /// The generic type. Can be bound or unbound generic.\n /// Function for appending the formatted type part.\n /// If true, the type is formatted with its full namespace.\n private static void FormatGenericType(Type type, Action append, bool withNamespace)\n {\n FormatDeclaringTypeNames(type, append);\n\n append(type.Name[..type.Name.LastIndexOf('`')]);\n append(\"<\");\n\n FormatGenericArguments(type, append, withNamespace);\n\n append(\">\");\n }\n\n /// \n /// Format generic arguments of a type.\n /// \n /// The generic base type, of which the generic arguments are formatted.\n /// Function for appending the formatted type part.\n /// If true, the type is formatted with its full namespace.\n private static void FormatGenericArguments(Type type, Action append, bool withNamespace)\n {\n Type[] types = type.GetGenericArguments();\n bool isUnboundType = type.ContainsGenericParameters;\n\n int numberOfGenericArguments = GetNumberOfGenericArguments(type);\n int firstGenericArgumentIndex = types.Length - numberOfGenericArguments;\n for (int index = firstGenericArgumentIndex; index < types.Length; index++)\n {\n if (isUnboundType)\n {\n append(types[index].Name);\n }\n else\n {\n FormatType(types[index], append, withNamespace);\n }\n\n if (index < types.Length - 1)\n {\n append(\", \");\n }\n }\n }\n\n /// \n /// Get number of generic arguments of a type.\n /// \n /// \n /// For nested generic classes like class A<T> { class B<T2> { } },\n /// the inner class also holds the generic arguments of all parent classes,\n /// which we don't want for the formatting.\n /// \n /// The generic type of which to get the generic arguments.\n /// The count of generic arguments which are associated only with .\n private static int GetNumberOfGenericArguments(Type type) =>\n int.Parse(type.Name[(type.Name.LastIndexOf('`') + 1)..], CultureInfo.InvariantCulture);\n\n /// \n /// Format all declaring type names of type .\n /// \n /// The type, of which to format the declaring types.\n /// Function for appending the formatted type part.\n private static void FormatDeclaringTypeNames(Type type, Action append)\n {\n foreach (Type declaringType in GetDeclaringTypes(type))\n {\n // for the declaring types we stick to the default, short notation like Dictionary`2.\n append(declaringType.Name);\n append(\"+\");\n }\n }\n\n /// \n /// Get all declaring types, ordered from outer to inner.\n /// \n /// The base type\n /// All declaring types\n private static List GetDeclaringTypes(Type type)\n {\n if (type.DeclaringType is null)\n {\n return [];\n }\n\n // We don't iterate from inner to outer, because that wouldn't work\n // with an append, but would require an insert, too.\n List declaringTypes = [];\n Type declaringType = type.DeclaringType;\n while (declaringType is not null)\n {\n declaringTypes.Insert(0, declaringType);\n declaringType = declaringType.DeclaringType;\n }\n\n return declaringTypes;\n }\n\n /// \n /// Lookup dictionary to use language keyword instead of type name.\n /// \n private static readonly Dictionary LanguageKeywords = new()\n {\n { typeof(bool), \"bool\" },\n { typeof(byte), \"byte\" },\n { typeof(char), \"char\" },\n { typeof(decimal), \"decimal\" },\n { typeof(double), \"double\" },\n { typeof(float), \"float\" },\n { typeof(int), \"int\" },\n { typeof(long), \"long\" },\n { typeof(object), \"object\" },\n { typeof(sbyte), \"sbyte\" },\n { typeof(short), \"short\" },\n { typeof(string), \"string\" },\n { typeof(uint), \"uint\" },\n { typeof(ulong), \"ulong\" },\n { typeof(void), \"void\" },\n };\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/ExceptionAssertionSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class ExceptionAssertionSpecs\n{\n [Fact]\n public void When_method_throws_an_empty_AggregateException_it_should_fail()\n {\n // Arrange\n Action act = () => throw new AggregateException();\n\n // Act\n Action act2 = () => act.Should().NotThrow();\n\n // Assert\n act2.Should().Throw();\n }\n\n#pragma warning disable xUnit1026 // Theory methods should use all of their parameters\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public void When_the_expected_exception_is_wrapped_it_should_succeed(Action action, T _)\n where T : Exception\n {\n // Act/Assert\n action.Should().Throw();\n }\n\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public void When_the_expected_exception_is_not_wrapped_it_should_fail(Action action, T _)\n where T : Exception\n {\n // Act\n Action act2 = () => action.Should().NotThrow();\n\n // Assert\n act2.Should().Throw();\n }\n#pragma warning restore xUnit1026 // Theory methods should use all of their parameters\n\n public static TheoryData AggregateExceptionTestData()\n {\n Action[] tasks =\n [\n AggregateExceptionWithLeftNestedException,\n AggregateExceptionWithRightNestedException\n ];\n\n Exception[] types =\n [\n new AggregateException(),\n new ArgumentNullException(),\n new InvalidOperationException()\n ];\n\n var data = new TheoryData();\n\n foreach (var task in tasks)\n {\n foreach (var type in types)\n {\n data.Add(task, type);\n }\n }\n\n data.Add(EmptyAggregateException, new AggregateException());\n\n return data;\n }\n\n private static void AggregateExceptionWithLeftNestedException()\n {\n var ex1 = new AggregateException(new InvalidOperationException());\n var ex2 = new ArgumentNullException();\n var wrapped = new AggregateException(ex1, ex2);\n\n throw wrapped;\n }\n\n private static void AggregateExceptionWithRightNestedException()\n {\n var ex1 = new ArgumentNullException();\n var ex2 = new AggregateException(new InvalidOperationException());\n var wrapped = new AggregateException(ex1, ex2);\n\n throw wrapped;\n }\n\n private static void EmptyAggregateException()\n {\n throw new AggregateException();\n }\n\n [Fact]\n public void ThrowExactly_when_subject_throws_subclass_of_expected_exception_it_should_throw()\n {\n // Arrange\n Action act = () => throw new ArgumentNullException();\n\n try\n {\n // Act\n act.Should().ThrowExactly(\"because {0} should do that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should()\n .Match(\n \"Expected type to be System.ArgumentException because Does.Do should do that, but found System.ArgumentNullException.\");\n }\n }\n\n [Fact]\n public void ThrowExactly_when_subject_throws_aggregate_exception_instead_of_expected_exception_it_should_throw()\n {\n // Arrange\n Action act = () => throw new AggregateException(new ArgumentException());\n\n try\n {\n // Act\n act.Should().ThrowExactly(\"because {0} should do that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should()\n .Match(\n \"Expected type to be System.ArgumentException because Does.Do should do that, but found System.AggregateException.\");\n }\n }\n\n [Fact]\n public void ThrowExactly_when_subject_throws_expected_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new ArgumentNullException();\n\n // Act / Assert\n act.Should().ThrowExactly();\n }\n}\n\npublic class SomeTestClass\n{\n internal const string ExceptionMessage = \"someMessage\";\n\n public IList Strings = new List();\n\n public void Throw()\n {\n throw new ArgumentException(ExceptionMessage);\n }\n}\n\npublic abstract class Does\n{\n public abstract void Do();\n\n public abstract void Do(string someParam);\n\n public abstract int Return();\n\n public static Does Throw(TException exception)\n where TException : Exception\n {\n return new DoesThrow(exception);\n }\n\n public static Does Throw()\n where TException : Exception, new()\n {\n return Throw(new TException());\n }\n\n public static Does NotThrow() => new DoesNotThrow();\n\n private class DoesThrow : Does\n where TException : Exception\n {\n private readonly TException exception;\n\n public DoesThrow(TException exception)\n {\n this.exception = exception;\n }\n\n public override void Do() => throw exception;\n\n public override void Do(string someParam) => throw exception;\n\n public override int Return() => throw exception;\n }\n\n private class DoesNotThrow : Does\n {\n public override void Do() { }\n\n public override void Do(string someParam) { }\n\n public override int Return() => 42;\n }\n}\n\ninternal class ExceptionWithProperties : Exception\n{\n public ExceptionWithProperties(string propertyValue)\n {\n Property = propertyValue;\n }\n\n public string Property { get; set; }\n}\n\ninternal class ExceptionWithEmptyToString : Exception\n{\n public override string ToString()\n {\n return string.Empty;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/SingleValueFormatter.cs", "using System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class SingleValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is float;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n float singleValue = (float)value;\n\n if (float.IsPositiveInfinity(singleValue))\n {\n formattedGraph.AddFragment(nameof(Single) + \".\" + nameof(float.PositiveInfinity));\n }\n else if (float.IsNegativeInfinity(singleValue))\n {\n formattedGraph.AddFragment(nameof(Single) + \".\" + nameof(float.NegativeInfinity));\n }\n else if (float.IsNaN(singleValue))\n {\n formattedGraph.AddFragment(singleValue.ToString(CultureInfo.InvariantCulture));\n }\n else\n {\n formattedGraph.AddFragment(singleValue.ToString(\"R\", CultureInfo.InvariantCulture) + \"F\");\n }\n }\n}\n"], ["/AwesomeAssertions/Build/CustomNpmTasks.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Nuke.Common;\nusing Nuke.Common.IO;\nusing Nuke.Common.Tooling;\nusing Nuke.Common.Utilities;\nusing Nuke.Common.Utilities.Collections;\nusing static Serilog.Log;\n\npublic static class CustomNpmTasks\n{\n static AbsolutePath RootDirectory;\n static AbsolutePath TempDir;\n static AbsolutePath NodeDir;\n static AbsolutePath NodeDirPerOs;\n static AbsolutePath WorkingDirectory;\n\n static IReadOnlyDictionary NpmEnvironmentVariables;\n\n static Tool Npm;\n\n static string Version;\n\n static Func GetCachedNodeModules;\n\n public static bool HasCachedNodeModules;\n\n public static void Initialize(AbsolutePath root)\n {\n RootDirectory = root;\n NodeDir = RootDirectory / \".nuke\" / \"temp\";\n\n Version = (RootDirectory / \"NodeVersion\").ReadAllText().Trim();\n GetCachedNodeModules = os => NodeDir.GlobFiles($\"node*{Version}-{os}*/**/node*\", $\"node*{Version}-{os}*/**/npm*\").Count != 0;\n }\n\n public static void NpmFetchRuntime()\n {\n DownloadNodeArchive().ExtractNodeArchive();\n\n LinkTools();\n }\n\n static AbsolutePath DownloadNodeArchive()\n {\n AbsolutePath archive = NodeDir;\n string os = null;\n string archiveType = null;\n\n if (EnvironmentInfo.IsWin)\n {\n os = \"win\";\n archiveType = \".zip\";\n }\n else if (EnvironmentInfo.IsOsx)\n {\n os = \"darwin\";\n archiveType = \".tar.gz\";\n }\n else if (EnvironmentInfo.IsLinux)\n {\n os = \"linux\";\n archiveType = \".tar.xz\";\n }\n\n os.NotNull();\n archiveType.NotNull();\n\n string architecture =\n EnvironmentInfo.IsArm64 ? \"arm64\" :\n EnvironmentInfo.Is64Bit ? \"x64\" : \"x86\";\n\n os = $\"{os}-{architecture}\";\n\n HasCachedNodeModules = GetCachedNodeModules(os);\n\n if (!HasCachedNodeModules)\n {\n Information($\"Fetching node.js ({Version}) for {os}\");\n\n string downloadUrl = $\"https://nodejs.org/dist/v{Version}/node-v{Version}-{os}{archiveType}\";\n archive = NodeDir / $\"node{archiveType}\";\n\n HttpTasks.HttpDownloadFile(downloadUrl, archive, clientConfigurator: c =>\n {\n c.Timeout = TimeSpan.FromSeconds(50);\n\n return c;\n });\n }\n else\n {\n Information(\"Skipping archive download due to cache\");\n }\n\n NodeDirPerOs = NodeDir / $\"node-v{Version}-{os}\";\n WorkingDirectory = NodeDirPerOs;\n\n return archive;\n }\n\n static void ExtractNodeArchive(this AbsolutePath archive)\n {\n if (HasCachedNodeModules)\n {\n Information(\"Skipping archive extraction due to cache\");\n\n return;\n }\n\n Information($\"Extracting node.js binary archive ({archive}) to {NodeDir}\");\n\n if (EnvironmentInfo.IsWin)\n {\n archive.UnZipTo(NodeDir);\n }\n else if (EnvironmentInfo.IsOsx)\n {\n archive.UnTarGZipTo(NodeDir);\n }\n else if (EnvironmentInfo.IsLinux)\n {\n archive.UnTarXzTo(NodeDir);\n }\n }\n\n static void LinkTools()\n {\n AbsolutePath npmExecutable;\n\n if (EnvironmentInfo.IsWin)\n {\n npmExecutable = NodeDirPerOs / \"npm.cmd\";\n }\n else\n {\n WorkingDirectory /= \"bin\";\n\n var nodeExecutable = WorkingDirectory / \"node\";\n var npmNodeModules = NodeDirPerOs / \"lib\" / \"node_modules\";\n npmExecutable = npmNodeModules / \"npm\" / \"bin\" / \"npm\";\n\n Information($\"Set execution permissions for {nodeExecutable}...\");\n nodeExecutable.SetExecutable();\n\n Information($\"Set execution permissions for {npmExecutable}...\");\n npmExecutable.SetExecutable();\n\n Information(\"Linking binaries...\");\n npmExecutable.AddUnixSymlink(WorkingDirectory / \"npm\", force: true);\n npmNodeModules.AddUnixSymlink(WorkingDirectory / \"node_modules\", force: true);\n\n npmExecutable = WorkingDirectory / \"npm\";\n }\n\n Information(\"Resolve tool npm...\");\n npmExecutable.NotNull();\n Npm = ToolResolver.GetTool(npmExecutable);\n\n NpmConfig(\"set update-notifier false\");\n NpmVersion();\n\n SetEnvVars();\n }\n\n static void SetEnvVars()\n {\n NpmEnvironmentVariables = EnvironmentInfo.Variables\n .ToDictionary(x => x.Key, x => x.Value)\n .SetKeyValue(\"path\", WorkingDirectory)\n .AsReadOnly();\n }\n\n public static void NpmInstall(bool silent = false, string workingDirectory = null)\n {\n Npm($\"install {(silent ? \"--silent\" : \"\")}\",\n workingDirectory,\n logger: NpmLogger);\n }\n\n public static void NpmRun(string args, bool silent = false)\n {\n Npm($\"run {(silent ? \"--silent\" : \"\")} {args}\".TrimMatchingDoubleQuotes(),\n environmentVariables: NpmEnvironmentVariables,\n logger: NpmLogger);\n }\n\n static void NpmVersion()\n {\n Npm(\"--version\",\n workingDirectory: WorkingDirectory,\n logInvocation: false,\n logger: NpmLogger,\n environmentVariables: NpmEnvironmentVariables);\n }\n\n static void NpmConfig(string args)\n {\n Npm($\"config {args}\".TrimMatchingDoubleQuotes(),\n workingDirectory: WorkingDirectory,\n logInvocation: false,\n logOutput: false,\n logger: NpmLogger,\n environmentVariables: NpmEnvironmentVariables);\n }\n\n static readonly Action NpmLogger = (outputType, msg) =>\n {\n if (EnvironmentInfo.IsWsl && msg.Contains(\"wslpath\"))\n return;\n\n if (outputType == OutputType.Err)\n {\n Error(msg);\n\n return;\n }\n\n Information(msg);\n };\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XmlElementAssertionSpecs.cs", "using System;\nusing System.Xml;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XmlElementAssertionSpecs\n{\n public class BeEquivalent\n {\n [Fact]\n public void When_asserting_xml_element_is_equivalent_to_another_xml_element_with_same_contents_it_should_succeed()\n {\n // This test is basically just a check that the BeEquivalent method\n // is available on XmlElementAssertions, which it should be if\n // XmlElementAssertions inherits XmlNodeAssertions.\n\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"grega\");\n var element = xmlDoc.DocumentElement;\n var expectedDoc = new XmlDocument();\n expectedDoc.LoadXml(\"grega\");\n var expected = expectedDoc.DocumentElement;\n\n // Act / Assert\n element.Should().BeEquivalentTo(expected);\n }\n }\n\n public class HaveInnerText\n {\n [Fact]\n public void When_asserting_xml_element_has_a_specific_inner_text_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"grega\");\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveInnerText(\"grega\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_a_specific_inner_text_but_it_has_a_different_inner_text_it_should_throw()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"grega\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveInnerText(\"stamac\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_a_specific_inner_text_but_it_has_a_different_inner_text_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"grega\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveInnerText(\"stamac\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have value \\\"stamac\\\" because we want to test the failure message, but found \\\"grega\\\".\");\n }\n }\n\n public class HaveAttribute\n {\n [Fact]\n public void When_asserting_xml_element_has_attribute_with_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\"\"\"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveAttribute(\"name\", \"martin\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_attribute_with_specific_value_but_attribute_does_not_exist_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\"\"\"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveAttribute(\"age\", \"36\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_specific_value_but_attribute_does_not_exist_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"\"\"\"\"\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(\"age\", \"36\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to have attribute \\\"age\\\" with value \\\"36\\\"\" +\n \" because we want to test the failure message\" +\n \", but found no such attribute in \"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveAttribute(\"name\", \"dennis\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_specific_value_but_attribute_has_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"\"\"\"\"\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(\"name\", \"dennis\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected attribute \\\"name\\\" in theElement to have value \\\"dennis\\\"\" +\n \" because we want to test the failure message\" +\n \", but found \\\"martin\\\".\");\n }\n }\n\n public class HaveAttributeWithNamespace\n {\n [Fact]\n public void When_asserting_xml_element_has_attribute_with_ns_and_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\"\"\"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveAttributeWithNamespace(\"name\", \"http://www.example.com/2012/test\", \"martin\");\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_ns_and_specific_value_but_attribute_does_not_exist_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\"\"\"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveAttributeWithNamespace(\"age\", \"http://www.example.com/2012/test\", \"36\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_ns_and_specific_value_but_attribute_does_not_exist_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"\"\"\"\"\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n theElement.Should().HaveAttributeWithNamespace(\"age\", \"http://www.example.com/2012/test\", \"36\",\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theElement to have attribute \\\"{http://www.example.com/2012/test}age\\\" with value \\\"36\\\"\" +\n \" because we want to test the failure message\" +\n \", but found no such attribute in \"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveAttributeWithNamespace(\"name\", \"http://www.example.com/2012/test\", \"dennis\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_ns_and_specific_value_but_attribute_has_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"\"\"\"\"\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithNamespace(\"name\", \"http://www.example.com/2012/test\", \"dennis\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"{http://www.example.com/2012/test}name\\\" in theElement to have value \\\"dennis\\\"\" +\n \" because we want to test the failure message\" +\n \", but found \\\"martin\\\".\");\n }\n }\n\n public class HaveElement\n {\n [Fact]\n public void When_asserting_xml_element_has_child_element_and_it_does_it_should_succeed()\n {\n // Arrange\n var xml = new XmlDocument();\n\n xml.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xml.DocumentElement;\n\n // Act / Assert\n element.Should().HaveElement(\"child\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_but_it_does_not_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveElement(\"unknown\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n\n document.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(\"unknown\", \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"unknown\\\"\"\n + \" because we want to test the failure message\"\n + \", but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_it_should_return_the_matched_element_in_the_which_property()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act\n var matchedElement = element.Should().HaveElement(\"child\").Subject;\n\n // Assert\n matchedElement.Should().BeOfType()\n .And.HaveAttribute(\"attr\", \"1\");\n\n matchedElement.Name.Should().Be(\"child\");\n }\n\n [Fact]\n public void When_asserting_xml_element_with_ns_has_child_element_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n value\n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveElement(\"child\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_and_it_does_with_ns_it_should_succeed2()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n value\n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveElement(\"child\");\n }\n }\n\n public class HaveElementWithNamespace\n {\n [Fact]\n public void When_asserting_xml_element_has_child_element_with_ns_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveElementWithNamespace(\"child\", \"http://www.example.com/2012/test\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_with_ns_but_it_does_not_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveElementWithNamespace(\"unknown\", \"http://www.example.com/2012/test\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_with_ns_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n\n document.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveElementWithNamespace(\"unknown\", \"http://www.example.com/2012/test\",\n \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"{{http://www.example.com/2012/test}}unknown\\\"\"\n + \" because we want to test the failure message\"\n + \", but no such child element was found.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/CollectingAssertionStrategy.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\n\nnamespace AwesomeAssertions.Execution;\n\ninternal class CollectingAssertionStrategy : IAssertionStrategy\n{\n private readonly List failureMessages = [];\n\n /// \n /// Returns the messages for the assertion failures that happened until now.\n /// \n public IEnumerable FailureMessages => failureMessages;\n\n /// \n /// Discards and returns the failure messages that happened up to now.\n /// \n public IEnumerable DiscardFailures()\n {\n var discardedFailures = failureMessages.ToArray();\n failureMessages.Clear();\n return discardedFailures;\n }\n\n /// \n /// Will throw a combined exception for any failures have been collected.\n /// \n public void ThrowIfAny(IDictionary context)\n {\n if (failureMessages.Count > 0)\n {\n var builder = new StringBuilder();\n builder.AppendJoin(Environment.NewLine, failureMessages).AppendLine();\n\n if (context.Any())\n {\n foreach (KeyValuePair pair in context)\n {\n builder.AppendFormat(CultureInfo.InvariantCulture,\n $\"{Environment.NewLine}With {pair.Key}:{Environment.NewLine}{{0}}\", pair.Value);\n }\n }\n\n AssertionEngine.TestFramework.Throw(builder.ToString());\n }\n }\n\n /// \n /// Instructs the strategy to handle a assertion failure.\n /// \n public void HandleFailure(string message)\n {\n failureMessages.Add(message);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/EventRaisingExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Events;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Provides extension methods for monitoring and querying events.\n/// \npublic static class EventRaisingExtensions\n{\n /// \n /// Asserts that all occurrences of the event originates from the .\n /// \n /// \n /// Returns only the events that comes from that sender.\n /// \n public static IEventRecording WithSender(this IEventRecording eventRecording, object expectedSender)\n {\n var eventsForSender = new List();\n var otherSenders = new List();\n var assertion = AssertionChain.GetOrCreate();\n\n foreach (OccurredEvent @event in eventRecording)\n {\n assertion\n .ForCondition(@event.Parameters.Length > 0)\n .FailWith(\"Expected event from sender {0}, \" +\n $\"but event {eventRecording.EventName} does not have any parameters\", expectedSender);\n\n if (assertion.Succeeded)\n {\n object sender = @event.Parameters[0];\n\n if (ReferenceEquals(sender, expectedSender))\n {\n eventsForSender.Add(@event);\n }\n else\n {\n otherSenders.Add(sender);\n }\n }\n }\n\n assertion\n .ForCondition(eventsForSender.Count > 0)\n .FailWith(\"Expected sender {0}, but found {1}.\",\n () => expectedSender,\n () => otherSenders.Distinct());\n\n return new FilteredEventRecording(eventRecording, eventsForSender);\n }\n\n /// \n /// Asserts that at least one occurrence of the events has some argument of the expected\n /// type that matches the given predicate.\n /// \n /// \n /// Returns only the events having some argument matching both type and predicate.\n /// \n /// is .\n public static IEventRecording WithArgs(this IEventRecording eventRecording, Expression> predicate)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n Func compiledPredicate = predicate.Compile();\n\n var eventsWithMatchingPredicate = new List();\n\n foreach (OccurredEvent @event in eventRecording)\n {\n IEnumerable typedParameters = @event.Parameters.OfType();\n\n if (typedParameters.Any(parameter => compiledPredicate(parameter)))\n {\n eventsWithMatchingPredicate.Add(@event);\n }\n }\n\n bool foundMatchingEvent = eventsWithMatchingPredicate.Count > 0;\n\n AssertionChain\n .GetOrCreate()\n .ForCondition(foundMatchingEvent)\n .FailWith(\"Expected at least one event with some argument of type <{0}> that matches {1}, but found none.\",\n typeof(T),\n predicate.Body);\n\n return new FilteredEventRecording(eventRecording, eventsWithMatchingPredicate);\n }\n\n /// \n /// Asserts that at least one occurrence of the events has arguments of the expected\n /// type that pairwise match all the given predicates.\n /// \n /// \n /// Returns only the events having arguments matching both type and all predicates.\n /// \n /// \n /// If a is provided as predicate argument, the corresponding event parameter value is ignored.\n /// \n public static IEventRecording WithArgs(this IEventRecording eventRecording, params Expression>[] predicates)\n {\n Func[] compiledPredicates = predicates.Select(p => p?.Compile()).ToArray();\n\n var eventsWithMatchingPredicate = new List();\n\n foreach (OccurredEvent @event in eventRecording)\n {\n var typedParameters = @event.Parameters.OfType().ToArray();\n bool hasArgumentOfRightType = typedParameters.Length > 0;\n\n if (predicates.Length > typedParameters.Length)\n {\n throw new ArgumentException(\n $\"Expected the event to have at least {predicates.Length} parameters of type {typeof(T).ToFormattedString()}, but only found {typedParameters.Length}.\");\n }\n\n bool isMatch = hasArgumentOfRightType;\n\n for (int index = 0; index < predicates.Length && isMatch; index++)\n {\n isMatch = compiledPredicates[index]?.Invoke(typedParameters[index]) ?? true;\n }\n\n if (isMatch)\n {\n eventsWithMatchingPredicate.Add(@event);\n }\n }\n\n bool foundMatchingEvent = eventsWithMatchingPredicate.Count > 0;\n\n if (!foundMatchingEvent)\n {\n AssertionChain\n .GetOrCreate()\n .FailWith(\n \"Expected at least one event with some arguments of type <{0}> that pairwise match {1}, but found none.\",\n typeof(T),\n string.Join(\" | \", predicates.Where(p => p is not null).Select(p => p.Body.ToString())));\n }\n\n return new FilteredEventRecording(eventRecording, eventsWithMatchingPredicate);\n }\n\n /// \n /// Asserts that all occurrences of the events has arguments of type \n /// and are for property .\n /// \n /// \n /// The property name for which the property changed events should have been raised.\n /// \n /// \n /// Returns only the property changed events affecting the particular property name.\n /// \n /// \n /// If a or string.Empty is provided as property name, the events are return as-is.\n /// \n internal static IEventRecording WithPropertyChangeFor(this IEventRecording eventRecording, string propertyName)\n {\n if (string.IsNullOrEmpty(propertyName))\n {\n return eventRecording;\n }\n\n IEnumerable eventsForPropertyName =\n eventRecording.Where(@event => @event.IsAffectingPropertyName(propertyName))\n .ToList();\n\n return new FilteredEventRecording(eventRecording, eventsForPropertyName);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/PropertyInfoFormatter.cs", "using System.Reflection;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class PropertyInfoFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is PropertyInfo;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var property = (PropertyInfo)value;\n formatChild(\"type\", property.DeclaringType!.AsFormattableShortType(), formattedGraph);\n formattedGraph.AddFragment($\".{property.Name}\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/TaskCompletionSourceAssertionSpecs.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class TaskCompletionSourceAssertionSpecs\n{\n#if NET6_0_OR_GREATER\n public class NonGeneric\n {\n [Fact]\n public async Task When_it_completes_in_time_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds());\n subject.SetResult();\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_did_not_complete_in_time_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to complete within 1s because test testArg.\");\n }\n\n [Fact]\n public async Task When_it_is_null_it_should_fail()\n {\n // Arrange\n TaskCompletionSource subject = null;\n\n // Act\n Func action = () => subject.Should().CompleteWithinAsync(1.Seconds());\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to complete within 1s, but found .\");\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_it_is_not_expected_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n subject.SetResult();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*to not complete within*because test testArg*\");\n }\n\n [Fact]\n public async Task When_it_is_canceled_before_completion_and_it_is_not_expected_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n subject.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_it_throws_before_completion_and_it_is_not_expected_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n subject.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_it_did_not_complete_in_time_and_it_is_not_expected_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_is_null_and_we_validate_to_not_complete_it_should_fail()\n {\n // Arrange\n TaskCompletionSource subject = null;\n\n // Act\n Func action = () => subject.Should().NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to not complete within 1s because test testArg, but found .\");\n }\n\n [Fact]\n public async Task When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n\n // Act\n Func action = () => Task.FromResult(subject.Should().Equals(subject));\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean CompleteWithinAsync() instead?\");\n }\n\n [Fact]\n public async Task Canceled_tasks_are_also_completed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds());\n subject.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Excepted_tasks_unexpectedly_completed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds());\n subject.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n }\n#endif\n\n public class Generic\n {\n [Fact]\n public async Task When_it_completes_in_time_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds());\n subject.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Canceled_tasks_do_not_return_default_value()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds()).WithResult(false);\n subject.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Exception_throwing_tasks_do_not_cause_a_default_value_to_be_returned()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds()).WithResult(false);\n subject.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_result_is_expected_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = async () => (await subject.Should(timer).CompleteWithinAsync(1.Seconds())).Which.Should().Be(42);\n subject.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_async_result_is_expected_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds()).WithResult(42);\n subject.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_result_is_not_expected_it_should_fail()\n {\n // Arrange\n var testSubject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = async () =>\n (await testSubject.Should(timer).CompleteWithinAsync(1.Seconds())).Which.Should().Be(42);\n\n testSubject.SetResult(99);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected *testSubject* to be 42, but found 99 (difference of 57).\");\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_async_result_is_not_expected_it_should_fail()\n {\n // Arrange\n var testSubject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => testSubject.Should(timer).CompleteWithinAsync(1.Seconds()).WithResult(42);\n testSubject.SetResult(99);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected testSubject.Result to be 42, but found 99.\");\n }\n\n [Fact]\n public async Task When_it_did_not_complete_in_time_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to complete within 1s because test testArg.\");\n }\n\n [Fact]\n public async Task When_it_is_null_it_should_fail()\n {\n // Arrange\n TaskCompletionSource subject = null;\n\n // Act\n Func action = () => subject.Should().CompleteWithinAsync(1.Seconds());\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to complete within 1s, but found .\");\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_it_is_not_expected_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n subject.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect*to complete within*because test testArg*\");\n }\n\n [Fact]\n public async Task Canceled_tasks_are_also_completed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n subject.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Excepted_tasks_unexpectedly_completed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n subject.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_it_did_not_complete_in_time_and_it_is_not_expected_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_is_null_and_we_validate_to_not_complete_it_should_fail()\n {\n // Arrange\n TaskCompletionSource subject = null;\n\n // Act\n Func action = () => subject.Should().NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect subject to complete within 1s because test testArg, but found .\");\n }\n\n [Fact]\n public async Task When_accidentally_using_equals_with_generic_it_should_throw_a_helpful_error()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n\n // Act\n Func> action = () => Task.FromResult(subject.Should().Equals(subject));\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean CompleteWithinAsync() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventMonitor.cs", "#if !NETSTANDARD2_0\n\nusing System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Tracks the events an object raises.\n/// \ninternal sealed class EventMonitor : IMonitor\n{\n private readonly WeakReference subject;\n\n private readonly ConcurrentDictionary recorderMap = new();\n\n public EventMonitor(object eventSource, EventMonitorOptions options)\n {\n Guard.ThrowIfArgumentIsNull(eventSource, nameof(eventSource), \"Cannot monitor the events of a object.\");\n Guard.ThrowIfArgumentIsNull(options, nameof(options), \"Event monitor needs configuration.\");\n\n this.options = options;\n\n subject = new WeakReference(eventSource);\n\n Attach(typeof(T), this.options.TimestampProvider);\n }\n\n public T Subject => (T)subject.Target;\n\n private readonly ThreadSafeSequenceGenerator threadSafeSequenceGenerator = new();\n private readonly EventMonitorOptions options;\n\n public EventMetadata[] MonitoredEvents =>\n recorderMap\n .Values\n .Select(recorder => new EventMetadata(recorder.EventName, recorder.EventHandlerType))\n .ToArray();\n\n public OccurredEvent[] OccurredEvents\n {\n get\n {\n IEnumerable query =\n from eventName in recorderMap.Keys\n let recording = GetRecordingFor(eventName)\n from @event in recording\n orderby @event.Sequence\n select @event;\n\n return query.ToArray();\n }\n }\n\n public void Clear()\n {\n foreach (EventRecorder recorder in recorderMap.Values)\n {\n recorder.Reset();\n }\n }\n\n public EventAssertions Should()\n {\n return new EventAssertions(this, AssertionChain.GetOrCreate());\n }\n\n public IEventRecording GetRecordingFor(string eventName)\n {\n if (!recorderMap.TryGetValue(eventName, out EventRecorder recorder))\n {\n throw new InvalidOperationException($\"Not monitoring any events named \\\"{eventName}\\\".\");\n }\n\n return recorder;\n }\n\n private void Attach(Type typeDefiningEventsToMonitor, Func utcNow)\n {\n if (subject.Target is null)\n {\n throw new InvalidOperationException(\"Cannot monitor events on garbage-collected object\");\n }\n\n EventInfo[] events = GetPublicEvents(typeDefiningEventsToMonitor);\n\n if (events.Length == 0)\n {\n throw new InvalidOperationException($\"Type {typeDefiningEventsToMonitor.Name} does not expose any events.\");\n }\n\n foreach (EventInfo eventInfo in events)\n {\n AttachEventHandler(eventInfo, utcNow);\n }\n }\n\n private static EventInfo[] GetPublicEvents(Type type)\n {\n if (!type.IsInterface)\n {\n return type.GetEvents();\n }\n\n return new[] { type }\n .Concat(type.GetInterfaces())\n .SelectMany(i => i.GetEvents())\n .ToArray();\n }\n\n public void Dispose()\n {\n foreach (EventRecorder recorder in recorderMap.Values)\n {\n DisposeSafeIfRequested(recorder);\n }\n\n recorderMap.Clear();\n }\n\n private void DisposeSafeIfRequested(IDisposable recorder)\n {\n try\n {\n recorder.Dispose();\n }\n catch when (options.ShouldIgnoreEventAccessorExceptions)\n {\n // ignore\n }\n }\n\n private void AttachEventHandler(EventInfo eventInfo, Func utcNow)\n {\n if (!recorderMap.TryGetValue(eventInfo.Name, out _))\n {\n var recorder = new EventRecorder(subject.Target, eventInfo.Name, utcNow, threadSafeSequenceGenerator);\n\n if (recorderMap.TryAdd(eventInfo.Name, recorder))\n {\n AttachEventHandler(eventInfo, recorder);\n }\n }\n }\n\n private void AttachEventHandler(EventInfo eventInfo, EventRecorder recorder)\n {\n try\n {\n recorder.Attach(subject, eventInfo);\n }\n catch when (options.ShouldIgnoreEventAccessorExceptions)\n {\n if (!options.ShouldRecordEventsWithBrokenAccessor)\n {\n recorderMap.TryRemove(eventInfo.Name, out _);\n }\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AsyncAssertionsExtensions.cs", "using System.Diagnostics.CodeAnalysis;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Specialized;\n\nnamespace AwesomeAssertions;\n\npublic static class AsyncAssertionsExtensions\n{\n#pragma warning disable AV1755 // \"Name of async method ... should end with Async\"; Async suffix is too noisy in fluent API\n /// \n /// Asserts that the completed provides the specified result.\n /// \n /// The containing the .\n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Please note that this assertion cannot identify whether the previous assertion was successful or not.\n /// In case it was not successful and it is running within an active \n /// there is no current result to compare with.\n /// So, this extension will compare with the default value.\n /// \n public static async Task, T>> WithResult(\n this Task, T>> task,\n T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var andWhichConstraint = await task;\n var subject = andWhichConstraint.Subject;\n subject.Should().Be(expected, because, becauseArgs);\n\n return andWhichConstraint;\n }\n\n /// \n /// Asserts that the completed provides the specified result.\n /// \n /// The containing the .\n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task, T>> WithResult(\n this Task, T>> task,\n T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var andWhichConstraint = await task;\n var subject = andWhichConstraint.Subject;\n subject.Should().Be(expected, because, becauseArgs);\n\n return andWhichConstraint;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedXunitTestCase.cs", "using System;\nusing System.ComponentModel;\nusing System.Globalization;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedXunitTestCase : XunitTestCase\n{\n private string culture;\n\n [EditorBrowsable(EditorBrowsableState.Never)]\n [Obsolete(\"Called by the de-serializer; should only be called by deriving classes for de-serialization purposes\")]\n public CulturedXunitTestCase() { }\n\n public CulturedXunitTestCase(IMessageSink diagnosticMessageSink,\n TestMethodDisplay defaultMethodDisplay,\n TestMethodDisplayOptions defaultMethodDisplayOptions,\n ITestMethod testMethod,\n string culture,\n object[] testMethodArguments = null)\n : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)\n {\n Initialize(culture);\n }\n\n private void Initialize(string culture)\n {\n this.culture = culture;\n\n Traits.Add(\"Culture\", culture);\n\n DisplayName += $\"[{culture}]\";\n }\n\n protected override string GetUniqueID() => $\"{base.GetUniqueID()}[{culture}]\";\n\n public override void Deserialize(IXunitSerializationInfo data)\n {\n base.Deserialize(data);\n\n Initialize(data.GetValue(\"Culture\"));\n }\n\n public override void Serialize(IXunitSerializationInfo data)\n {\n base.Serialize(data);\n\n data.AddValue(\"Culture\", culture);\n }\n\n public override async Task RunAsync(IMessageSink diagnosticMessageSink,\n IMessageBus messageBus,\n object[] constructorArguments,\n ExceptionAggregator aggregator,\n CancellationTokenSource cancellationTokenSource)\n {\n CultureInfo originalCulture = CurrentCulture;\n CultureInfo originalUICulture = CurrentUICulture;\n\n try\n {\n var cultureInfo = new CultureInfo(culture);\n CurrentCulture = cultureInfo;\n CurrentUICulture = cultureInfo;\n\n return await base.RunAsync(diagnosticMessageSink, messageBus, constructorArguments, aggregator,\n cancellationTokenSource);\n }\n finally\n {\n CurrentCulture = originalCulture;\n CurrentUICulture = originalUICulture;\n }\n }\n\n private static CultureInfo CurrentCulture\n {\n get => CultureInfo.CurrentCulture;\n set => CultureInfo.CurrentCulture = value;\n }\n\n private static CultureInfo CurrentUICulture\n {\n get => CultureInfo.CurrentUICulture;\n set => CultureInfo.CurrentUICulture = value;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/PropertyInfoAssertionSpecs.cs", "using System;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class PropertyInfoAssertionSpecs\n{\n public class BeVirtual\n {\n [Fact]\n public void When_asserting_that_a_property_is_virtual_and_it_is_then_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithAllPropertiesVirtual).GetRuntimeProperty(\"PublicVirtualProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeVirtual();\n }\n\n [Fact]\n public void When_asserting_that_a_property_is_virtual_and_it_is_not_then_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithNonVirtualPublicProperties).GetRuntimeProperty(\"PublicNonVirtualProperty\");\n\n // Act\n Action act = () => propertyInfo.Should().BeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property ClassWithNonVirtualPublicProperties.PublicNonVirtualProperty\" +\n \" to be virtual because we want to test the error message,\" +\n \" but it is not.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_virtual_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeVirtual(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property to be virtual *failure message*, but propertyInfo is .\");\n }\n }\n\n public class NotBeVirtual\n {\n [Fact]\n public void When_asserting_that_a_property_is_not_virtual_and_it_is_not_then_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithNonVirtualPublicProperties).GetRuntimeProperty(\"PublicNonVirtualProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotBeVirtual();\n }\n\n [Fact]\n public void When_asserting_that_a_property_is_not_virtual_and_it_is_then_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithAllPropertiesVirtual).GetRuntimeProperty(\"PublicVirtualProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property *ClassWithAllPropertiesVirtual.PublicVirtualProperty\" +\n \" not to be virtual because we want to test the error message,\" +\n \" but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_virtual_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeVirtual(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property not to be virtual *failure message*, but propertyInfo is .\");\n }\n }\n\n public class BeDecortatedWithOfT\n {\n [Fact]\n public void When_asserting_a_property_is_decorated_with_attribute_and_it_is_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_a_property_is_decorated_with_an_attribute_it_allow_chaining_assertions()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith().Which.Value.Should().Be(\"OtherValue\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Value*OtherValue*\");\n }\n\n [Fact]\n public void\n When_a_property_is_decorated_with_an_attribute_and_multiple_attributes_match_continuation_using_the_matched_value_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\n \"PublicPropertyWithSameAttributeTwice\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith().Which.Value.Should().Be(\"OtherValue\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_a_property_is_decorated_with_attribute_and_it_is_not_it_throw_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith(\"because we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property \" +\n \"ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.PublicProperty to be decorated with \" +\n \"AwesomeAssertions*DummyPropertyAttribute because we want to test the error message, but that attribute was not found.\");\n }\n\n [Fact]\n public void\n When_asserting_a_property_is_decorated_with_an_attribute_matching_a_predicate_but_it_is_not_it_throw_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith(d => d.Value == \"NotARealValue\",\n \"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.PublicProperty to be decorated with \" +\n \"AwesomeAssertions*DummyPropertyAttribute because we want to test the error message,\" +\n \" but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_property_is_decorated_with_attribute_matching_a_predicate_and_it_is_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeDecoratedWith(d => d.Value == \"Value\");\n }\n\n [Fact]\n public void When_subject_is_null_be_decorated_withOfT_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property to be decorated with *.DummyPropertyAttribute *failure message*, but propertyInfo is .\");\n }\n\n [Fact]\n public void When_asserting_property_is_decorated_with_null_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith((Expression>)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n }\n\n public class NotBeDecoratedWithOfT\n {\n [Fact]\n public void When_subject_is_null_not_be_decorated_withOfT_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property to not be decorated with *.DummyPropertyAttribute *failure message*, but propertyInfo is .\");\n }\n\n [Fact]\n public void When_asserting_property_is_not_decorated_with_null_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeDecoratedWith((Expression>)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n }\n\n public class BeWritable\n {\n [Fact]\n public void When_asserting_a_readonly_property_is_writable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().BeWritable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\n \"Expected property ClassWithProperties.ReadOnlyProperty to have a setter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_asserting_a_readwrite_property_is_writable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadWriteProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeWritable(\"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_writeonly_property_is_writable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeWritable(\"that's required\");\n }\n\n [Fact]\n public void When_subject_is_null_be_writable_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeWritable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property to have a setter *failure message*, but propertyInfo is .\");\n }\n }\n\n public class BeReadable\n {\n [Fact]\n public void When_asserting_a_readonly_property_is_readable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeReadable(\"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_readwrite_property_is_readable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadWriteProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeReadable(\"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_writeonly_property_is_readable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().BeReadable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\n \"Expected property *WriteOnlyProperty to have a getter because we want to test the error message, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_readable_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeReadable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property to have a getter *failure message*, but propertyInfo is .\");\n }\n }\n\n public class NotBeWritable\n {\n [Fact]\n public void When_asserting_a_readonly_property_is_not_writable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotBeWritable(\"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_readwrite_property_is_not_writable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadWriteProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotBeWritable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect property ClassWithReadOnlyProperties.ReadWriteProperty\" +\n \" to have a setter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_asserting_a_writeonly_property_is_not_writable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotBeWritable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect property ClassWithProperties.WriteOnlyProperty\" +\n \" to have a setter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_writable_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeWritable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected propertyInfo not to have a setter *failure message*, but it is .\");\n }\n }\n\n public class NotBeReadable\n {\n [Fact]\n public void When_asserting_a_readonly_property_is_not_readable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotBeReadable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect property ClassWithReadOnlyProperties.ReadOnlyProperty \" +\n \"to have a getter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_asserting_a_readwrite_property_is_not_readable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadWriteProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotBeReadable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect property ClassWithReadOnlyProperties.ReadWriteProperty \" +\n \"to have a getter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_asserting_a_writeonly_property_is_not_readable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotBeReadable(\"that's required\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_readable_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeReadable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property not to have a getter *failure message*, but propertyInfo is .\");\n }\n }\n\n public class BeReadableAccessModifier\n {\n [Fact]\n public void When_asserting_a_public_read_private_write_property_is_public_readable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadPrivateWriteProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeReadable(CSharpAccessModifier.Public, \"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_private_read_public_write_property_is_public_readable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WritePrivateReadProperty\");\n\n // Act\n Action action = () =>\n propertyInfo.Should().BeReadable(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected getter of property ClassWithProperties.WritePrivateReadProperty \" +\n \"to be Public because we want to test the error message, but it is Private*\");\n }\n\n [Fact]\n public void Do_not_the_check_access_modifier_when_the_property_is_not_readable()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n propertyInfo.Should().BeReadable(CSharpAccessModifier.Private);\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected property ClassWithProperties.WriteOnlyProperty to have a getter, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_readable_with_accessmodifier_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeReadable(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected propertyInfo to be Public *failure message*, but it is .\");\n }\n\n [Fact]\n public void When_asserting_is_readable_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeReadable((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n\n public class BeWritableAccessModifier\n {\n [Fact]\n public void When_asserting_a_public_write_private_read_property_is_public_writable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WritePrivateReadProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeWritable(CSharpAccessModifier.Public, \"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_private_write_public_read_property_is_public_writable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadPrivateWriteProperty\");\n\n // Act\n Action action = () =>\n propertyInfo.Should().BeWritable(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected setter of property ClassWithProperties.ReadPrivateWriteProperty \" +\n \"to be Public because we want to test the error message, but it is Private.\");\n }\n\n [Fact]\n public void Do_not_the_check_access_modifier_when_the_property_is_not_writable()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n propertyInfo.Should().BeWritable(CSharpAccessModifier.Private);\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected property ClassWithProperties.ReadOnlyProperty to have a setter.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_writable_with_accessmodifier_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeWritable(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected propertyInfo to be Public *failure message*, but it is .\");\n }\n\n [Fact]\n public void When_asserting_is_writable_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeWritable((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n\n public class Return\n {\n [Fact]\n public void When_asserting_a_String_property_returns_a_String_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act / Assert\n propertyInfo.Should().Return(typeof(string));\n }\n\n [Fact]\n public void When_asserting_a_String_property_returns_an_Int32_it_throw_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().Return(typeof(int), \"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type of property ClassWithProperties.StringProperty\" +\n \" to be int because we want to test the error message, but it is string.\");\n }\n\n [Fact]\n public void When_subject_is_null_return_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().Return(typeof(int), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type of property to be int *failure message*, but propertyInfo is .\");\n }\n\n [Fact]\n public void When_asserting_property_type_is_null_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().Return(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"propertyType\");\n }\n }\n\n public class ReturnOfT\n {\n [Fact]\n public void When_asserting_a_String_property_returnsOfT_a_String_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act / Assert\n propertyInfo.Should().Return();\n }\n\n [Fact]\n public void When_asserting_a_String_property_returnsOfT_an_Int32_it_throw_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().Return(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type of property ClassWithProperties.StringProperty to be int because we want to test the error \" +\n \"message, but it is string.\");\n }\n }\n\n public class NotReturn\n {\n [Fact]\n public void When_asserting_a_String_property_does_not_returns_an_Int32_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotReturn(typeof(int));\n }\n\n [Fact]\n public void When_asserting_a_String_property_does_not_return_a_String_it_throw_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotReturn(typeof(string), \"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type of property ClassWithProperties.StringProperty\" +\n \" not to be string because we want to test the error message, but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_return_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotReturn(typeof(int), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type of property not to be int *failure message*, but propertyInfo is .\");\n }\n\n [Fact]\n public void When_asserting_property_type_is_not_null_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotReturn(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"propertyType\");\n }\n }\n\n public class NotReturnOfT\n {\n [Fact]\n public void Can_validate_the_type_of_a_property()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotReturn();\n }\n\n [Fact]\n public void When_asserting_a_string_property_does_not_returnsOfT_a_String_it_throw_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotReturn(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type of property ClassWithProperties.StringProperty not to be*String*because we want to test the error \" +\n \"message, but it is.\");\n }\n }\n\n #region Internal classes used in unit tests\n\n private class ClassWithProperties\n {\n public string ReadOnlyProperty { get { return \"\"; } }\n\n public string ReadPrivateWriteProperty { get; private set; }\n\n public string ReadWriteProperty { get; set; }\n\n public string WritePrivateReadProperty { private get; set; }\n\n public string WriteOnlyProperty { set { } }\n\n public string StringProperty { get; set; }\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/BeEquivalentToWithDeeplyNestedStructures.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions;\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Jobs;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\n[SimpleJob(RuntimeMoniker.Net472)]\n[SimpleJob(RuntimeMoniker.Net80)]\npublic class BeEquivalentToWithDeeplyNestedStructures\n{\n public class ComplexType\n {\n public int A { get; set; }\n\n public ComplexType B { get; set; }\n }\n\n [Params(1, 10, 100, 500)]\n public int N { get; set; }\n\n [Params(1, 2, 6)]\n public int Depth { get; set; }\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n subject = Enumerable.Range(0, N).Select(_ => CreateComplex(Depth)).ToList();\n expectation = Enumerable.Range(0, N).Select(_ => CreateComplex(Depth)).ToList();\n }\n\n private static ComplexType CreateComplex(int i)\n {\n if (i == 0)\n {\n return new ComplexType();\n }\n\n return new ComplexType\n {\n A = i,\n B = CreateComplex(i - 1)\n };\n }\n\n private List subject;\n private List expectation;\n\n [Benchmark]\n public void BeEquivalentTo()\n {\n subject.Should().BeEquivalentTo(expectation);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DateOnlyValueFormatter.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DateOnlyValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is DateOnly;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var dateOnly = (DateOnly)value;\n formattedGraph.AddFragment(dateOnly.ToString(\"\", CultureInfo.InvariantCulture));\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TimeOnlyValueFormatter.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class TimeOnlyValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is TimeOnly;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var timeOnly = (TimeOnly)value;\n formattedGraph.AddFragment(timeOnly.ToString(\"\", CultureInfo.InvariantCulture));\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/ActionAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an yields the expected result.\n/// \n[DebuggerNonUserCode]\npublic class ActionAssertions : DelegateAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public ActionAssertions(Action subject, IExtractExceptions extractor, AssertionChain assertionChain)\n : base(subject, extractor, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n public ActionAssertions(Action subject, IExtractExceptions extractor, AssertionChain assertionChain, IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current does not throw any exception.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotThrow([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n Exception exception = InvokeSubjectWithInterception();\n return NotThrowInternal(exception, because, becauseArgs);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current stops throwing any exception\n /// after a specified amount of time.\n /// \n /// \n /// The delegate is invoked. If it raises an exception,\n /// the invocation is repeated until it either stops raising any exceptions\n /// or the specified wait time is exceeded.\n /// \n /// \n /// The time after which the delegate should have stopped throwing any exception.\n /// \n /// \n /// The time between subsequent invocations of the delegate.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// or are negative.\n public AndConstraint NotThrowAfter(TimeSpan waitTime, TimeSpan pollInterval,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(waitTime);\n Guard.ThrowIfArgumentIsNegative(pollInterval);\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw after {0}{reason}, but found .\", waitTime);\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n\n TimeSpan? invocationEndTime = null;\n Exception exception = null;\n ITimer timer = Clock.StartTimer();\n\n while (invocationEndTime is null || invocationEndTime < waitTime)\n {\n exception = InvokeSubjectWithInterception();\n\n if (exception is null)\n {\n break;\n }\n\n Clock.Delay(pollInterval);\n invocationEndTime = timer.Elapsed;\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(exception is null)\n .FailWith(\"Did not expect any exceptions after {0}{reason}, but found {1}.\", waitTime, exception);\n }\n\n return new AndConstraint(this);\n }\n\n protected override void InvokeSubject()\n {\n Subject();\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"action\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeDecoratedWithOrInherit.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeDecoratedWithOrInherit specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeDecoratedWithOrInherit\n {\n [Fact]\n public void When_type_inherits_expected_attribute_it_succeeds()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithAttribute.Should().BeDecoratedWithOrInherit();\n }\n\n [Fact]\n public void When_type_inherits_expected_attribute_it_should_allow_chaining()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithAttribute.Should().BeDecoratedWithOrInherit()\n .Which.IsEnabled.Should().BeTrue();\n }\n\n [Fact]\n public void When_type_does_not_inherit_expected_attribute_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithoutAttribute);\n\n // Act\n Action act = () =>\n type.Should().BeDecoratedWithOrInherit(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithoutAttribute to be decorated with or inherit *.DummyClassAttribute \" +\n \"*failure message*, but the attribute was not found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_BeDecoratedWithOrInherit_it_should_throw()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () => typeWithAttribute.Should()\n .BeDecoratedWithOrInherit(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_type_inherits_expected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithAttribute.Should()\n .BeDecoratedWithOrInherit(a => a.Name == \"Expected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_type_inherits_expected_attribute_with_the_expected_properties_it_should_allow_chaining()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithAttribute.Should()\n .BeDecoratedWithOrInherit(a => a.Name == \"Expected\")\n .Which.IsEnabled.Should().BeTrue();\n }\n\n [Fact]\n public void When_type_inherits_expected_attribute_that_has_an_unexpected_property_it_fails()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should()\n .BeDecoratedWithOrInherit(a => a.Name == \"Unexpected\" && a.IsEnabled);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithInheritedAttribute to be decorated with or inherit *.DummyClassAttribute \" +\n \"that matches (a.Name == \\\"Unexpected\\\")*a.IsEnabled, but no matching attribute was found.\");\n }\n }\n\n public class NotBeDecoratedWithOrInherit\n {\n [Fact]\n public void When_type_does_not_inherit_unexpected_attribute_it_succeeds()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithoutAttribute);\n\n // Act / Assert\n typeWithoutAttribute.Should().NotBeDecoratedWithOrInherit();\n }\n\n [Fact]\n public void When_type_inherits_unexpected_attribute_it_fails()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should()\n .NotBeDecoratedWithOrInherit(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithInheritedAttribute to not be decorated with or inherit *.DummyClassAttribute \" +\n \"*failure message* attribute was found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotBeDecoratedWithOrInherit_it_should_throw()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () => typeWithoutAttribute.Should()\n .NotBeDecoratedWithOrInherit(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_type_does_not_inherit_unexpected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithoutAttribute.Should()\n .NotBeDecoratedWithOrInherit(a => a.Name == \"Unexpected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_type_does_not_inherit_expected_attribute_that_has_an_unexpected_property_it_fails()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () =>\n typeWithoutAttribute.Should()\n .NotBeDecoratedWithOrInherit(a => a.Name == \"Expected\" && a.IsEnabled);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithInheritedAttribute to not be decorated with or inherit *.DummyClassAttribute \" +\n \"that matches (a.Name == \\\"Expected\\\") * a.IsEnabled, but a matching attribute was found.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/MaximumMatchingSolver.cs", "using System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// The class encapsulates the algorithm\n/// for solving the maximum matching problem (see ).\n/// See https://en.wikipedia.org/wiki/Maximum_cardinality_matching for more details.
\n/// A simplified variation of the Ford-Fulkerson algorithm is used for solving the problem.\n/// See https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm for more details.\n///
\ninternal class MaximumMatchingSolver\n{\n private readonly MaximumMatchingProblem problem;\n private readonly Dictionary, List>> matchingElementsByPredicate = [];\n\n public MaximumMatchingSolver(MaximumMatchingProblem problem)\n {\n this.problem = problem;\n }\n\n /// \n /// Solves the maximum matching problem;\n /// \n public MaximumMatchingSolution Solve()\n {\n var matches = new MatchCollection();\n\n foreach (var predicate in problem.Predicates)\n {\n // At each step of the algorithm we search for a solution which contains the current predicate\n // and increases the total number of matches (i.e. Augmenting Flow through the current predicate in the Ford-Fulkerson terminology).\n var newMatches = FindMatchForPredicate(predicate, matches);\n matches.UpdateFrom(newMatches);\n }\n\n var elementsByMatchedPredicate = matches.ToDictionary(match => match.Predicate, match => match.Element);\n\n return new MaximumMatchingSolution(problem, elementsByMatchedPredicate);\n }\n\n /// \n /// To find a solution which contains the specified predicate and increases the total number of matches\n /// we:
\n /// - Search for a free element which matches the specified predicate.
\n /// - Or take over an element which was previously matched with another predicate and repeat the procedure for the previously matched predicate.
\n /// - We are basically searching for a path in the graph of matches between predicates and elements which would start at the specified predicate\n /// and end at an unmatched element.
\n /// - Breadth first search used to traverse the graph.
\n ///
\n private IEnumerable FindMatchForPredicate(Predicate predicate, MatchCollection currentMatches)\n {\n var visitedElements = new HashSet>();\n var breadthFirstSearchTracker = new BreadthFirstSearchTracker(predicate, currentMatches);\n\n while (breadthFirstSearchTracker.TryDequeueUnMatchedPredicate(out var unmatchedPredicate))\n {\n var notVisitedMatchingElements =\n GetMatchingElements(unmatchedPredicate).Where(element => !visitedElements.Contains(element));\n\n foreach (var element in notVisitedMatchingElements)\n {\n visitedElements.Add(element);\n\n if (currentMatches.Contains(element))\n {\n breadthFirstSearchTracker.ReassignElement(element, unmatchedPredicate);\n }\n else\n {\n var finalMatch = new Match { Predicate = unmatchedPredicate, Element = element };\n return breadthFirstSearchTracker.GetMatchChain(finalMatch);\n }\n }\n }\n\n return [];\n }\n\n private List> GetMatchingElements(Predicate predicate)\n {\n if (!matchingElementsByPredicate.TryGetValue(predicate, out var matchingElements))\n {\n matchingElements = problem.Elements.Where(element => predicate.Matches(element.Value)).ToList();\n matchingElementsByPredicate.Add(predicate, matchingElements);\n }\n\n return matchingElements;\n }\n\n private struct Match\n {\n public Predicate Predicate;\n public Element Element;\n }\n\n private sealed class MatchCollection : IEnumerable\n {\n private readonly Dictionary, Match> matchesByElement = [];\n\n public void UpdateFrom(IEnumerable matches)\n {\n foreach (var match in matches)\n {\n matchesByElement[match.Element] = match;\n }\n }\n\n public Predicate GetMatchedPredicate(Element element)\n {\n return matchesByElement[element].Predicate;\n }\n\n public bool Contains(Element element) => matchesByElement.ContainsKey(element);\n\n public IEnumerator GetEnumerator() => matchesByElement.Values.GetEnumerator();\n\n IEnumerator IEnumerable.GetEnumerator() => matchesByElement.Values.GetEnumerator();\n }\n\n private sealed class BreadthFirstSearchTracker\n {\n private readonly Queue> unmatchedPredicatesQueue = new();\n private readonly Dictionary, Match> previousMatchByPredicate = [];\n\n private readonly MatchCollection originalMatches;\n\n public BreadthFirstSearchTracker(Predicate unmatchedPredicate, MatchCollection originalMatches)\n {\n unmatchedPredicatesQueue.Enqueue(unmatchedPredicate);\n\n this.originalMatches = originalMatches;\n }\n\n public bool TryDequeueUnMatchedPredicate(out Predicate unmatchedPredicate)\n {\n if (unmatchedPredicatesQueue.Count == 0)\n {\n unmatchedPredicate = null;\n return false;\n }\n\n unmatchedPredicate = unmatchedPredicatesQueue.Dequeue();\n return true;\n }\n\n public void ReassignElement(Element element, Predicate newMatchedPredicate)\n {\n var previouslyMatchedPredicate = originalMatches.GetMatchedPredicate(element);\n\n previousMatchByPredicate.Add(previouslyMatchedPredicate,\n new Match { Predicate = newMatchedPredicate, Element = element });\n\n unmatchedPredicatesQueue.Enqueue(previouslyMatchedPredicate);\n }\n\n public IEnumerable GetMatchChain(Match lastMatch)\n {\n var match = lastMatch;\n\n do\n {\n yield return match;\n }\n while (previousMatchByPredicate.TryGetValue(match.Predicate, out match));\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DecimalValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DecimalValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is decimal;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((decimal)value).ToString(CultureInfo.InvariantCulture) + \"M\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/Int16ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class Int16ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is short;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((short)value).ToString(CultureInfo.InvariantCulture) + \"s\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/UInt16ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class UInt16ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is ushort;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((ushort)value).ToString(CultureInfo.InvariantCulture) + \"us\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/Int64ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class Int64ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is long;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((long)value).ToString(CultureInfo.InvariantCulture) + \"L\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/UInt32ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class UInt32ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is uint;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((uint)value).ToString(CultureInfo.InvariantCulture) + \"u\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/UInt64ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class UInt64ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is ulong;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((ulong)value).ToString(CultureInfo.InvariantCulture) + \"UL\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/SByteValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class SByteValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is sbyte;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((sbyte)value).ToString(CultureInfo.InvariantCulture) + \"y\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Extensibility.Specs/ExtensionAssemblyAttributeSpecs.cs", "namespace AwesomeAssertions.Extensibility.Specs;\n\npublic class ExtensionAssemblyAttributeSpecs\n{\n [Fact]\n public void Calls_assembly_initialization_code_only_once()\n {\n for (int i = 0; i < 10; i++)\n {\n var act = () => AssertionEngineInitializer.ShouldBeCalledOnlyOnce.Should().Be(1);\n\n act.Should().NotThrow();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/Reason.cs", "using System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents the reason for a structural equivalency assertion.\n/// \npublic class Reason\n{\n public Reason([StringSyntax(\"CompositeFormat\")] string formattedMessage, object[] arguments)\n {\n FormattedMessage = formattedMessage;\n Arguments = arguments;\n }\n\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n public string FormattedMessage { get; set; }\n\n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public object[] Arguments { get; set; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/PropertyInfoSelector.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Allows for fluent selection of properties of a type through reflection.\n/// \npublic class PropertyInfoSelector : IEnumerable\n{\n private IEnumerable selectedProperties;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The type from which to select properties.\n /// is .\n public PropertyInfoSelector(Type type)\n : this([type])\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The types from which to select properties.\n /// is or contains .\n public PropertyInfoSelector(IEnumerable types)\n {\n Guard.ThrowIfArgumentIsNull(types);\n Guard.ThrowIfArgumentContainsNull(types);\n\n selectedProperties = types.SelectMany(t => t\n .GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance\n | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static));\n }\n\n /// \n /// Only select the properties that have at least one public or internal accessor\n /// \n public PropertyInfoSelector ThatArePublicOrInternal\n {\n get\n {\n selectedProperties = selectedProperties.Where(property =>\n {\n return property.GetGetMethod(nonPublic: true) is { IsPublic: true } or { IsAssembly: true }\n || property.GetSetMethod(nonPublic: true) is { IsPublic: true } or { IsAssembly: true };\n });\n\n return this;\n }\n }\n\n /// \n /// Only select the properties that are abstract\n /// \n public PropertyInfoSelector ThatAreAbstract\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => property.IsAbstract());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are not abstract\n /// \n public PropertyInfoSelector ThatAreNotAbstract\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => !property.IsAbstract());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are static\n /// \n public PropertyInfoSelector ThatAreStatic\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => property.IsStatic());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are not static\n /// \n public PropertyInfoSelector ThatAreNotStatic\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => !property.IsStatic());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are virtual\n /// \n public PropertyInfoSelector ThatAreVirtual\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => property.IsVirtual());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are not virtual\n /// \n public PropertyInfoSelector ThatAreNotVirtual\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => !property.IsVirtual());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are decorated with an attribute of the specified type.\n /// \n public PropertyInfoSelector ThatAreDecoratedWith()\n where TAttribute : Attribute\n {\n selectedProperties = selectedProperties.Where(property => property.IsDecoratedWith());\n return this;\n }\n\n /// \n /// Only select the properties that are decorated with, or inherits from a parent class, an attribute of the specified type.\n /// \n public PropertyInfoSelector ThatAreDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n selectedProperties = selectedProperties.Where(property => property.IsDecoratedWithOrInherit());\n return this;\n }\n\n /// \n /// Only select the properties that are not decorated with an attribute of the specified type.\n /// \n public PropertyInfoSelector ThatAreNotDecoratedWith()\n where TAttribute : Attribute\n {\n selectedProperties = selectedProperties.Where(property => !property.IsDecoratedWith());\n return this;\n }\n\n /// \n /// Only select the properties that are not decorated with and does not inherit from a parent class an attribute of the specified type.\n /// \n public PropertyInfoSelector ThatAreNotDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n selectedProperties = selectedProperties.Where(property => !property.IsDecoratedWithOrInherit());\n return this;\n }\n\n /// \n /// Only select the properties that return the specified type\n /// \n public PropertyInfoSelector OfType()\n {\n selectedProperties = selectedProperties.Where(property => property.PropertyType == typeof(TReturn));\n return this;\n }\n\n /// \n /// Only select the properties that do not return the specified type\n /// \n public PropertyInfoSelector NotOfType()\n {\n selectedProperties = selectedProperties.Where(property => property.PropertyType != typeof(TReturn));\n return this;\n }\n\n /// \n /// Select return types of the properties\n /// \n public TypeSelector ReturnTypes()\n {\n var returnTypes = selectedProperties.Select(property => property.PropertyType);\n\n return new TypeSelector(returnTypes);\n }\n\n /// \n /// The resulting objects.\n /// \n public PropertyInfo[] ToArray()\n {\n return selectedProperties.ToArray();\n }\n\n /// \n /// Returns an enumerator that iterates through the collection.\n /// \n /// \n /// A that can be used to iterate through the collection.\n /// \n /// 1\n public IEnumerator GetEnumerator()\n {\n return selectedProperties.GetEnumerator();\n }\n\n /// \n /// Returns an enumerator that iterates through a collection.\n /// \n /// \n /// An object that can be used to iterate through the collection.\n /// \n /// 2\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/TaskCompletionSourceAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n\n#if NET6_0_OR_GREATER\npublic class TaskCompletionSourceAssertions : TaskCompletionSourceAssertionsBase\n{\n private readonly TaskCompletionSource subject;\n\n public TaskCompletionSourceAssertions(TaskCompletionSource tcs, AssertionChain assertionChain)\n : this(tcs, assertionChain, new Clock())\n {\n CurrentAssertionChain = assertionChain;\n }\n\n public TaskCompletionSourceAssertions(TaskCompletionSource tcs, AssertionChain assertionChain, IClock clock)\n : base(clock)\n {\n subject = tcs;\n CurrentAssertionChain = assertionChain;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the of the current will complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> CompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(subject!.Task, timeSpan);\n CurrentAssertionChain\n .ForCondition(completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the of the current will not complete within the specified time.\n /// \n /// The time span to wait for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> NotCompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to not complete within {0}{reason}, but found .\", timeSpan);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(subject!.Task, timeSpan);\n CurrentAssertionChain\n .ForCondition(!completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to not complete within {0}{reason}.\", timeSpan);\n }\n\n return new AndConstraint(this);\n }\n}\n#endif\n\npublic class TaskCompletionSourceAssertions : TaskCompletionSourceAssertionsBase\n{\n private readonly TaskCompletionSource subject;\n\n public TaskCompletionSourceAssertions(TaskCompletionSource tcs, AssertionChain assertionChain)\n : this(tcs, assertionChain, new Clock())\n {\n CurrentAssertionChain = assertionChain;\n }\n\n public TaskCompletionSourceAssertions(TaskCompletionSource tcs, AssertionChain assertionChain, IClock clock)\n : base(clock)\n {\n subject = tcs;\n CurrentAssertionChain = assertionChain;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the of the current will complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task, T>> CompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(subject!.Task, timeSpan);\n\n CurrentAssertionChain\n .ForCondition(completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n\n#pragma warning disable CA1849 // Call async methods when in an async method\n T result = subject.Task.IsCompleted ? subject.Task.Result : default;\n#pragma warning restore CA1849 // Call async methods when in an async method\n return new AndWhichConstraint, T>(this, result, CurrentAssertionChain, \".Result\");\n }\n\n return new AndWhichConstraint, T>(this, default(T));\n }\n\n /// \n /// Asserts that the of the current will not complete within the specified time.\n /// \n /// The time span to wait for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task>> NotCompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(subject!.Task, timeSpan);\n\n CurrentAssertionChain\n .ForCondition(!completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n\n return new AndConstraint>(this);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ExpressionValueFormatter.cs", "using System;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class ExpressionValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is Expression;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(value.ToString().Replace(\" = \", \" == \", StringComparison.Ordinal));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeGreaterThan.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeGreaterThan\n {\n [Fact]\n public void When_a_value_is_greater_than_smaller_value_it_should_not_throw()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act / Assert\n value.Should().BeGreaterThan(smallerValue);\n }\n\n [Fact]\n public void When_a_value_is_greater_than_greater_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(greaterValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_greater_than_same_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int sameValue = 2;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(sameValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_greater_than_greater_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(greaterValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 3 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_another_float()\n {\n // Act\n Action act = () => float.NaN.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_cannot_be_greater_than_NaN()\n {\n // Act\n Action act = () => 3.4F.Should().BeGreaterThan(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_another_double()\n {\n // Act\n Action act = () => double.NaN.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_greater_than_NaN()\n {\n // Act\n Action act = () => 3.4D.Should().BeGreaterThan(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_greater_than_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_byte()\n {\n // Arrange\n var value = (byte)1;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(1);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_non_null_path_for_difference_on_byte()\n {\n // Arrange\n var value = (byte)1;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(2);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5, 5)]\n [InlineData(1, 10)]\n [InlineData(0, 5)]\n [InlineData(0, 0)]\n [InlineData(-1, 5)]\n [InlineData(-1, -1)]\n [InlineData(10, 10)]\n public void To_test_the_null_path_for_difference_on_int(int subject, int expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5L, 5L)]\n [InlineData(1L, 10L)]\n [InlineData(0L, 5L)]\n [InlineData(0L, 0L)]\n [InlineData(-1L, 5L)]\n [InlineData(-1L, -1L)]\n [InlineData(10L, 10L)]\n public void To_test_the_null_path_for_difference_on_long(long subject, long expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(1, 1)]\n [InlineData(10, 10)]\n [InlineData(10, 11)]\n public void To_test_the_null_path_for_difference_on_ushort(ushort subject, ushort expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/DelegateAssertionsBase.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that a method yields the expected result.\n/// \n[DebuggerNonUserCode]\npublic abstract class DelegateAssertionsBase\n : ReferenceTypeAssertions>\n where TDelegate : Delegate\n where TAssertions : DelegateAssertionsBase\n{\n private readonly AssertionChain assertionChain;\n\n private protected IExtractExceptions Extractor { get; }\n\n private protected DelegateAssertionsBase(TDelegate @delegate, IExtractExceptions extractor, AssertionChain assertionChain,\n IClock clock)\n : base(@delegate, assertionChain)\n {\n this.assertionChain = assertionChain;\n Extractor = extractor ?? throw new ArgumentNullException(nameof(extractor));\n Clock = clock ?? throw new ArgumentNullException(nameof(clock));\n }\n\n private protected IClock Clock { get; }\n\n protected ExceptionAssertions ThrowInternal(\n Exception exception,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where TException : Exception\n {\n TException[] expectedExceptions = Extractor.OfType(exception).ToArray();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected a <{0}> to be thrown{reason}, \", typeof(TException), chain => chain\n .ForCondition(exception is not null)\n .FailWith(\"but no exception was thrown.\")\n .Then\n .ForCondition(expectedExceptions.Length > 0)\n .FailWith(\"but found <{0}>:\" + Environment.NewLine + \"{1}.\",\n exception?.GetType(),\n exception));\n\n return new ExceptionAssertions(expectedExceptions, assertionChain);\n }\n\n protected AndConstraint NotThrowInternal(Exception exception, [StringSyntax(\"CompositeFormat\")] string because,\n object[] becauseArgs)\n {\n assertionChain\n .ForCondition(exception is null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exception{reason}, but found {0}.\", exception);\n\n return new AndConstraint((TAssertions)this);\n }\n\n protected AndConstraint NotThrowInternal(Exception exception,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where TException : Exception\n {\n IEnumerable exceptions = Extractor.OfType(exception);\n\n assertionChain\n .ForCondition(!exceptions.Any())\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {0}{reason}, but found {1}.\", typeof(TException), exception);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MethodInfoSelector.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing static System.Reflection.BindingFlags;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Allows for fluent selection of methods of a type through reflection.\n/// \npublic class MethodInfoSelector : IEnumerable\n{\n private IEnumerable selectedMethods;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The type from which to select methods.\n /// is .\n public MethodInfoSelector(Type type)\n : this([type])\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The types from which to select methods.\n /// is or contains .\n public MethodInfoSelector(IEnumerable types)\n {\n Guard.ThrowIfArgumentIsNull(types);\n Guard.ThrowIfArgumentContainsNull(types);\n\n selectedMethods = types.SelectMany(t => t\n .GetMethods(DeclaredOnly | Instance | Static | Public | NonPublic)\n .Where(method => !HasSpecialName(method)));\n }\n\n /// \n /// Only select the methods that are public or internal.\n /// \n public MethodInfoSelector ThatArePublicOrInternal\n {\n get\n {\n selectedMethods = selectedMethods.Where(method => method.IsPublic || method.IsAssembly);\n return this;\n }\n }\n\n /// \n /// Only select the methods without a return value\n /// \n public MethodInfoSelector ThatReturnVoid\n {\n get\n {\n selectedMethods = selectedMethods.Where(method => method.ReturnType == typeof(void));\n return this;\n }\n }\n\n /// \n /// Only select the methods with a return value\n /// \n public MethodInfoSelector ThatDoNotReturnVoid\n {\n get\n {\n selectedMethods = selectedMethods.Where(method => method.ReturnType != typeof(void));\n return this;\n }\n }\n\n /// \n /// Only select the methods that return the specified type\n /// \n public MethodInfoSelector ThatReturn()\n {\n selectedMethods = selectedMethods.Where(method => method.ReturnType == typeof(TReturn));\n return this;\n }\n\n /// \n /// Only select the methods that do not return the specified type\n /// \n public MethodInfoSelector ThatDoNotReturn()\n {\n selectedMethods = selectedMethods.Where(method => method.ReturnType != typeof(TReturn));\n return this;\n }\n\n /// \n /// Only select the methods that are decorated with an attribute of the specified type.\n /// \n public MethodInfoSelector ThatAreDecoratedWith()\n where TAttribute : Attribute\n {\n selectedMethods = selectedMethods.Where(method => method.IsDecoratedWith());\n return this;\n }\n\n /// \n /// Only select the methods that are decorated with, or inherits from a parent class, an attribute of the specified type.\n /// \n public MethodInfoSelector ThatAreDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n selectedMethods = selectedMethods.Where(method => method.IsDecoratedWithOrInherit());\n return this;\n }\n\n /// \n /// Only select the methods that are not decorated with an attribute of the specified type.\n /// \n public MethodInfoSelector ThatAreNotDecoratedWith()\n where TAttribute : Attribute\n {\n selectedMethods = selectedMethods.Where(method => !method.IsDecoratedWith());\n return this;\n }\n\n /// \n /// Only select the methods that are not decorated with and does not inherit from a parent class, an attribute of the specified type.\n /// \n public MethodInfoSelector ThatAreNotDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n selectedMethods = selectedMethods.Where(method => !method.IsDecoratedWithOrInherit());\n return this;\n }\n\n /// \n /// Only return methods that are abstract\n /// \n public MethodInfoSelector ThatAreAbstract()\n {\n selectedMethods = selectedMethods.Where(method => method.IsAbstract);\n return this;\n }\n\n /// \n /// Only return methods that are not abstract\n /// \n public MethodInfoSelector ThatAreNotAbstract()\n {\n selectedMethods = selectedMethods.Where(method => !method.IsAbstract);\n return this;\n }\n\n /// \n /// Only return methods that are async.\n /// \n public MethodInfoSelector ThatAreAsync()\n {\n selectedMethods = selectedMethods.Where(method => method.IsAsync());\n return this;\n }\n\n /// \n /// Only return methods that are not async.\n /// \n public MethodInfoSelector ThatAreNotAsync()\n {\n selectedMethods = selectedMethods.Where(method => !method.IsAsync());\n return this;\n }\n\n /// \n /// Only return methods that are static.\n /// \n public MethodInfoSelector ThatAreStatic()\n {\n selectedMethods = selectedMethods.Where(method => method.IsStatic);\n return this;\n }\n\n /// \n /// Only return methods that are not static.\n /// \n public MethodInfoSelector ThatAreNotStatic()\n {\n selectedMethods = selectedMethods.Where(method => !method.IsStatic);\n return this;\n }\n\n /// \n /// Only return methods that are virtual.\n /// \n public MethodInfoSelector ThatAreVirtual()\n {\n selectedMethods = selectedMethods.Where(method => !method.IsNonVirtual());\n return this;\n }\n\n /// \n /// Only return methods that are not virtual.\n /// \n public MethodInfoSelector ThatAreNotVirtual()\n {\n selectedMethods = selectedMethods.Where(method => method.IsNonVirtual());\n return this;\n }\n\n /// \n /// Select return types of the methods\n /// \n public TypeSelector ReturnTypes()\n {\n var returnTypes = selectedMethods.Select(mi => mi.ReturnType);\n\n return new TypeSelector(returnTypes);\n }\n\n /// \n /// The resulting objects.\n /// \n public MethodInfo[] ToArray()\n {\n return selectedMethods.ToArray();\n }\n\n /// \n /// Determines whether the specified method has a special name (like properties and events).\n /// \n private static bool HasSpecialName(MethodInfo method)\n {\n return (method.Attributes & MethodAttributes.SpecialName) == MethodAttributes.SpecialName;\n }\n\n /// \n /// Returns an enumerator that iterates through the collection.\n /// \n /// \n /// A that can be used to iterate through the collection.\n /// \n /// 1\n public IEnumerator GetEnumerator()\n {\n return selectedMethods.GetEnumerator();\n }\n\n /// \n /// Returns an enumerator that iterates through a collection.\n /// \n /// \n /// An object that can be used to iterate through the collection.\n /// \n /// 2\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/StringExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class StringExtensions\n{\n /// \n /// Finds the first index at which the does not match the \n /// string anymore, accounting for the specified .\n /// \n public static int IndexOfFirstMismatch(this string value, string expected, IEqualityComparer comparer)\n {\n for (int index = 0; index < value.Length; index++)\n {\n if (index >= expected.Length || !comparer.Equals(value[index..(index + 1)], expected[index..(index + 1)]))\n {\n return index;\n }\n }\n\n return -1;\n }\n\n /// \n /// Gets the quoted three characters at the specified index of a string, including the index itself.\n /// \n public static string IndexedSegmentAt(this string value, int index)\n {\n int length = Math.Min(value.Length - index, 3);\n string formattedString = Formatter.ToString(value.Substring(index, length));\n\n return $\"{formattedString} (index {index})\".EscapePlaceholders();\n }\n\n /// \n /// Replaces all numeric indices from a path like \"property[0].nested\" and returns \"property[].nested\"\n /// \n public static string WithoutSpecificCollectionIndices(this string indexedPath)\n {\n return Regex.Replace(indexedPath, @\"\\[[0-9]+\\]\", \"[]\");\n }\n\n /// \n /// Determines whether a string contains a specific index like `[0]` instead of just `[]`.\n /// \n public static bool ContainsSpecificCollectionIndex(this string indexedPath)\n {\n return Regex.IsMatch(indexedPath, @\"\\[[0-9]+\\]\");\n }\n\n /// \n /// Replaces all characters that might conflict with formatting placeholders with their escaped counterparts.\n /// \n public static string EscapePlaceholders(this string value) =>\n value.Replace(\"{\", \"{{\", StringComparison.Ordinal).Replace(\"}\", \"}}\", StringComparison.Ordinal);\n\n /// \n /// Joins a string with one or more other strings using a specified separator.\n /// \n /// \n /// Any string that is empty (including the original string) is ignored.\n /// \n public static string Combine(this string @this, string other, string separator = \".\")\n {\n if (@this.Length == 0)\n {\n return other.Length != 0 ? other : string.Empty;\n }\n\n if (other.StartsWith('['))\n {\n separator = string.Empty;\n }\n\n return @this + separator + other;\n }\n\n /// \n /// Changes the first character of a string to uppercase.\n /// \n public static string Capitalize(this string @this)\n {\n if (@this.Length == 0)\n {\n return @this;\n }\n\n char[] charArray = @this.ToCharArray();\n charArray[0] = char.ToUpperInvariant(charArray[0]);\n return new string(charArray);\n }\n\n /// \n /// Appends tab character at the beginning of each line in a string.\n /// \n /// \n public static string IndentLines(this string @this)\n {\n return string.Join(Environment.NewLine,\n @this.Split(new[] { '\\r', '\\n' }, StringSplitOptions.RemoveEmptyEntries).Select(x => $\"\\t{x}\"));\n }\n\n public static string RemoveNewLines(this string @this)\n {\n return @this.Replace(\"\\n\", string.Empty, StringComparison.Ordinal)\n .Replace(\"\\r\", string.Empty, StringComparison.Ordinal);\n }\n\n public static string RemoveNewlineStyle(this string @this)\n {\n return @this.Replace(\"\\r\\n\", \"\\n\", StringComparison.Ordinal)\n .Replace(\"\\r\", \"\\n\", StringComparison.Ordinal);\n }\n\n public static string RemoveTrailingWhitespaceFromLines(this string input)\n {\n // This regex matches whitespace characters (\\s) that are followed by a line ending (\\r?\\n)\n return Regex.Replace(input, @\"[ \\t]+(?=\\r?\\n)\", string.Empty);\n }\n\n /// \n /// Counts the number of times the appears within a string by using the specified .\n /// \n public static int CountSubstring(this string str, string substring, IEqualityComparer comparer)\n {\n string actual = str ?? string.Empty;\n string search = substring ?? string.Empty;\n\n int count = 0;\n int maxIndex = actual.Length - search.Length;\n for (int index = 0; index <= maxIndex; index++)\n {\n if (comparer.Equals(actual[index..(index + search.Length)], search))\n {\n count++;\n }\n }\n\n return count;\n }\n\n /// \n /// Determines if the is longer than 8 characters or contains an .\n /// \n public static bool IsLongOrMultiline(this string value)\n {\n const int humanReadableLength = 8;\n return value.Length > humanReadableLength || value.Contains(Environment.NewLine, StringComparison.Ordinal);\n }\n\n public static bool IsNullOrEmpty([NotNullWhen(false)] this string value)\n {\n return string.IsNullOrEmpty(value);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.Be.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_two_equal_object_are_expected_to_be_equal_it_should_not_fail()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var equalObject = new ClassWithCustomEqualMethod(1);\n\n // Act / Assert\n someObject.Should().Be(equalObject);\n }\n\n [Fact]\n public void When_two_different_objects_are_expected_to_be_equal_it_should_fail_with_a_clear_explanation()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var nonEqualObject = new ClassWithCustomEqualMethod(2);\n\n // Act\n Action act = () => someObject.Should().Be(nonEqualObject);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someObject to be ClassWithCustomEqualMethod(2), but found ClassWithCustomEqualMethod(1).\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_are_null_it_should_succeed()\n {\n // Arrange\n object someObject = null;\n object expectedObject = null;\n\n // Act / Assert\n someObject.Should().Be(expectedObject);\n }\n\n [Fact]\n public void When_the_subject_is_null_it_should_fail()\n {\n // Arrange\n object someObject = null;\n var nonEqualObject = new ClassWithCustomEqualMethod(2);\n\n // Act\n Action act = () => someObject.Should().Be(nonEqualObject);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someObject to be ClassWithCustomEqualMethod(2), but found .\");\n }\n\n [Fact]\n public void When_two_different_objects_are_expected_to_be_equal_it_should_fail_and_use_the_reason()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var nonEqualObject = new ClassWithCustomEqualMethod(2);\n\n // Act\n Action act = () => someObject.Should().Be(nonEqualObject, \"because it should use the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected someObject to be ClassWithCustomEqualMethod(2) because it should use the reason, but found ClassWithCustomEqualMethod(1).\");\n }\n\n [Fact]\n public void When_comparing_a_numeric_and_an_enum_for_equality_it_should_throw()\n {\n // Arrange\n object subject = 1;\n MyEnum expected = MyEnum.One;\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void An_untyped_value_is_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n object value = new SomeClass(5);\n\n // Act / Assert\n value.Should().Be(new SomeClass(5), new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void A_typed_value_is_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n var value = new SomeClass(5);\n\n // Act / Assert\n value.Should().Be(new SomeClass(5), new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void An_untyped_value_is_not_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(4), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected value to be SomeClass(4)*I said so*found SomeClass(3).\");\n }\n\n [Fact]\n public void A_typed_value_is_not_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(4), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected value to be SomeClass(4)*I said so*found SomeClass(3).\");\n }\n\n [Fact]\n public void A_typed_value_is_not_of_the_same_type()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(3), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to be SomeClass(3)*I said so*found ClassWithCustomEqualMethod(3).\");\n }\n\n [Fact]\n public void A_untyped_value_requires_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(3), comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void A_typed_value_requires_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(3), comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act / Assert\n value.Should().Be(value).And.NotBeNull();\n }\n\n [Fact]\n public void Can_chain_multiple_assertions()\n {\n // Arrange\n var value = new object();\n\n // Act / Assert\n value.Should().Be(value, new DumbObjectEqualityComparer()).And.NotBeNull();\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_non_equal_objects_are_expected_to_be_not_equal_it_should_not_fail()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var nonEqualObject = new ClassWithCustomEqualMethod(2);\n\n // Act / Assert\n someObject.Should().NotBe(nonEqualObject);\n }\n\n [Fact]\n public void When_two_equal_objects_are_expected_not_to_be_equal_it_should_fail_with_a_clear_explanation()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var equalObject = new ClassWithCustomEqualMethod(1);\n\n // Act\n Action act = () =>\n someObject.Should().NotBe(equalObject);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect someObject to be equal to ClassWithCustomEqualMethod(1).\");\n }\n\n [Fact]\n public void When_two_equal_objects_are_expected_not_to_be_equal_it_should_fail_and_use_the_reason()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var equalObject = new ClassWithCustomEqualMethod(1);\n\n // Act\n Action act = () =>\n someObject.Should().NotBe(equalObject, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect someObject to be equal to ClassWithCustomEqualMethod(1) \" +\n \"because we want to test the failure message.\");\n }\n\n [Fact]\n public void An_untyped_value_is_not_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n object value = new SomeClass(5);\n\n // Act / Assert\n value.Should().NotBe(new SomeClass(4), new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void A_typed_value_is_not_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n var value = new SomeClass(5);\n\n // Act / Assert\n value.Should().NotBe(new SomeClass(4), new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void An_untyped_value_is_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().NotBe(new SomeClass(3), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not expect value to be equal to SomeClass(3)*I said so*\");\n }\n\n [Fact]\n public void A_typed_value_is_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().NotBe(new SomeClass(3), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not expect value to be equal to SomeClass(3)*I said so*\");\n }\n\n [Fact]\n public void A_typed_value_is_not_of_the_same_type()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act / Assert\n value.Should().NotBe(new SomeClass(3), new SomeClassEqualityComparer(), \"I said so\");\n }\n\n [Fact]\n public void An_untyped_value_requires_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().NotBe(new SomeClass(3), comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void A_typed_value_requires_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().NotBe(new SomeClass(3), comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act / Assert\n value.Should().NotBe(new SomeClass(3)).And.NotBeNull();\n }\n\n [Fact]\n public void Can_chain_multiple_assertions()\n {\n // Arrange\n var value = new object();\n\n // Act / Assert\n value.Should().NotBe(new object(), new DumbObjectEqualityComparer()).And.NotBeNull();\n }\n }\n\n private enum MyEnum\n {\n One = 1,\n Two = 2\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/MethodInfoSelectorAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Types;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class MethodInfoSelectorAssertionSpecs\n{\n public class BeVirtual\n {\n [Fact]\n public void When_asserting_methods_are_virtual_and_they_are_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsVirtual));\n\n // Act / Assert\n methodSelector.Should().BeVirtual();\n }\n\n [Fact]\n public void When_asserting_methods_are_virtual_but_non_virtual_methods_are_found_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonVirtualPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().BeVirtual();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_methods_are_virtual_but_non_virtual_methods_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonVirtualPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().BeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods\" +\n \" to be virtual because we want to test the error message,\" +\n \" but the following methods are not virtual:*\" +\n \"Void AwesomeAssertions*ClassWithNonVirtualPublicMethods.PublicDoNothing*\" +\n \"Void AwesomeAssertions*ClassWithNonVirtualPublicMethods.InternalDoNothing*\" +\n \"Void AwesomeAssertions*ClassWithNonVirtualPublicMethods.ProtectedDoNothing\");\n }\n }\n\n public class NotBeVirtual\n {\n [Fact]\n public void When_asserting_methods_are_not_virtual_and_they_are_not_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonVirtualPublicMethods));\n\n // Act / Assert\n methodSelector.Should().NotBeVirtual();\n }\n\n [Fact]\n public void When_asserting_methods_are_not_virtual_but_virtual_methods_are_found_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsVirtual));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBeVirtual();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_methods_are_not_virtual_but_virtual_methods_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsVirtual));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods\" +\n \" not to be virtual because we want to test the error message,\" +\n \" but the following methods are virtual\" +\n \"*ClassWithAllMethodsVirtual.PublicVirtualDoNothing\" +\n \"*ClassWithAllMethodsVirtual.InternalVirtualDoNothing\" +\n \"*ClassWithAllMethodsVirtual.ProtectedVirtualDoNothing*\");\n }\n }\n\n public class BeDecoratedWith\n {\n [Fact]\n public void When_injecting_a_null_predicate_into_BeDecoratedWith_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n methodSelector.Should().BeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_methods_are_decorated_with_attribute_and_they_are_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsDecoratedWithDummyAttribute));\n\n // Act / Assert\n methodSelector.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_methods_are_decorated_with_attribute_but_they_are_not_it_should_throw()\n {\n // Arrange\n MethodInfoSelector methodSelector =\n new MethodInfoSelector(typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute))\n .ThatArePublicOrInternal;\n\n // Act\n Action act = () =>\n methodSelector.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_methods_are_decorated_with_attribute_but_they_are_not_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n methodSelector.Should().BeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to be decorated with\" +\n \" AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but the following methods are not:*\" +\n \"Void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.PublicDoNothing*\" +\n \"Void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.ProtectedDoNothing*\" +\n \"Void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.PrivateDoNothing\");\n }\n }\n\n public class NotBeDecoratedWith\n {\n [Fact]\n public void When_injecting_a_null_predicate_into_NotBeDecoratedWith_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_methods_are_not_decorated_with_attribute_and_they_are_not_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute));\n\n // Act / Assert\n methodSelector.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_methods_are_not_decorated_with_attribute_but_they_are_it_should_throw()\n {\n // Arrange\n MethodInfoSelector methodSelector =\n new MethodInfoSelector(typeof(ClassWithAllMethodsDecoratedWithDummyAttribute))\n .ThatArePublicOrInternal;\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBeDecoratedWith();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_methods_are_not_decorated_with_attribute_but_they_are_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsDecoratedWithDummyAttribute));\n\n // Act\n Action act = () => methodSelector.Should()\n .NotBeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all selected methods to not be decorated*DummyMethodAttribute*because we want to test the error message\" +\n \"*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothing*\" +\n \"*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothingWithSameAttributeTwice*\" +\n \"*ClassWithAllMethodsDecoratedWithDummyAttribute.ProtectedDoNothing*\" +\n \"*ClassWithAllMethodsDecoratedWithDummyAttribute.PrivateDoNothing\");\n }\n }\n\n public class Be\n {\n [Fact]\n public void When_all_methods_have_specified_accessor_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithPublicMethods));\n\n // Act / Assert\n methodSelector.Should().Be(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_not_all_methods_have_specified_accessor_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(GenericClassWithNonPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().Be(CSharpAccessModifier.Public);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to be Public\" +\n \", but the following methods are not:*\" +\n \"void AwesomeAssertions*.GenericClassWithNonPublicMethods.PublicDoNothing*\" +\n \"void AwesomeAssertions*.GenericClassWithNonPublicMethods.DoNothingWithParameter*\" +\n \"void AwesomeAssertions*.GenericClassWithNonPublicMethods.DoNothingWithAnotherParameter\");\n }\n\n [Fact]\n public void When_not_all_methods_have_specified_accessor_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(GenericClassWithNonPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().Be(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to be Public\" +\n \" because we want to test the error message\" +\n \", but the following methods are not:*\" +\n \"Void AwesomeAssertions*.GenericClassWithNonPublicMethods.PublicDoNothing*\" +\n \"Void AwesomeAssertions*.GenericClassWithNonPublicMethods.DoNothingWithParameter*\" +\n \"Void AwesomeAssertions*.GenericClassWithNonPublicMethods.DoNothingWithAnotherParameter\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_all_methods_does_not_have_specified_accessor_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(GenericClassWithNonPublicMethods));\n\n // Act / Assert\n methodSelector.Should().NotBe(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_any_method_have_specified_accessor_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBe(CSharpAccessModifier.Public);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to not be Public\" +\n \", but the following methods are:*\" +\n \"Void AwesomeAssertions*ClassWithPublicMethods.PublicDoNothing*\");\n }\n\n [Fact]\n public void When_any_method_have_specified_accessor_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBe(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to not be Public\" +\n \" because we want to test the error message\" +\n \", but the following methods are:*\" +\n \"Void AwesomeAssertions*ClassWithPublicMethods.PublicDoNothing*\");\n }\n }\n\n public class BeAsync\n {\n [Fact]\n public void When_asserting_methods_are_async_and_they_are_then_it_succeeds()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsAsync));\n\n // Act / Assert\n methodSelector.Should().BeAsync();\n }\n\n [Fact]\n public void When_asserting_methods_are_async_but_non_async_methods_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonAsyncMethods));\n\n // Act\n Action act = () => methodSelector.Should().BeAsync(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"\"\"\n Expected all selected methods to be async because we want to test the error message, but the following methods are not:\n Task AwesomeAssertions.Specs.Types.ClassWithNonAsyncMethods.PublicDoNothing\n Task AwesomeAssertions.Specs.Types.ClassWithNonAsyncMethods.InternalDoNothing\n Task AwesomeAssertions.Specs.Types.ClassWithNonAsyncMethods.ProtectedDoNothing\n \"\"\");\n }\n }\n\n public class NotBeAsync\n {\n [Fact]\n public void When_asserting_methods_are_not_async_and_they_are_not_then_it_succeeds()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonAsyncMethods));\n\n // Act / Assert\n methodSelector.Should().NotBeAsync();\n }\n\n [Fact]\n public void When_asserting_methods_are_not_async_but_async_methods_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsAsync));\n\n // Act\n Action act = () => methodSelector.Should().NotBeAsync(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\"\"\n Expected all selected methods not to be async because we want to test the error message, but the following methods are:\n Task AwesomeAssertions.Specs.Types.ClassWithAllMethodsAsync.PublicAsyncDoNothing\n Task AwesomeAssertions.Specs.Types.ClassWithAllMethodsAsync.InternalAsyncDoNothing\n Task AwesomeAssertions.Specs.Types.ClassWithAllMethodsAsync.ProtectedAsyncDoNothing\n \"\"\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.Linq;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n // If you try to implement support for IReadOnlyDictionary, these tests should still succeed.\n public class SanityChecks\n {\n [Fact]\n public void When_the_same_dictionaries_are_expected_to_be_the_same_it_should_not_fail()\n {\n // Arrange\n IDictionary dictionary = new Dictionary();\n IDictionary referenceToDictionary = dictionary;\n\n // Act / Assert\n dictionary.Should().BeSameAs(referenceToDictionary);\n }\n\n [Fact]\n public void When_the_same_custom_dictionaries_are_expected_to_be_the_same_it_should_not_fail()\n {\n // Arrange\n IDictionary dictionary = new DictionaryNotImplementingIReadOnlyDictionary();\n IDictionary referenceToDictionary = dictionary;\n\n // Act / Assert\n dictionary.Should().BeSameAs(referenceToDictionary);\n }\n\n [Fact]\n public void When_object_type_is_exactly_equal_to_the_specified_type_it_should_not_fail()\n {\n // Arrange\n IDictionary dictionary = new DictionaryNotImplementingIReadOnlyDictionary();\n\n // Act / Assert\n dictionary.Should().BeOfType>();\n }\n\n [Fact]\n public void When_a_dictionary_does_not_implement_the_read_only_interface_it_should_have_dictionary_assertions()\n {\n // Arrange\n IDictionary dictionary = new DictionaryNotImplementingIReadOnlyDictionary();\n\n // Act / Assert\n dictionary.Should().NotContainKey(0, \"Dictionaries not implementing IReadOnlyDictionary \"\n + \"should be supported at least until Awesome Assertions 6.0.\");\n }\n }\n\n public class OtherDictionaryAssertions\n {\n [Theory]\n [MemberData(nameof(SingleDictionaryData))]\n public void When_a_dictionary_like_collection_contains_the_expected_key_and_value_it_should_succeed(T subject)\n where T : IEnumerable>\n {\n // Assert\n subject.Should().Contain(1, 42);\n }\n\n [Theory]\n [MemberData(nameof(SingleDictionaryData))]\n public void When_using_a_dictionary_like_collection_it_should_preserve_reference_equality(T subject)\n where T : IEnumerable>\n {\n // Act / Assert\n subject.Should().BeSameAs(subject);\n }\n\n [Theory]\n [MemberData(nameof(SingleDictionaryData))]\n public void When_a_dictionary_like_collection_contains_the_expected_key_it_should_succeed(T subject)\n where T : IEnumerable>\n {\n // Act / Assert\n subject.Should().ContainKey(1);\n }\n\n [Theory]\n [MemberData(nameof(SingleDictionaryData))]\n public void When_a_dictionary_like_collection_contains_the_expected_value_it_should_succeed(T subject)\n where T : IEnumerable>\n {\n // Act / Assert\n subject.Should().ContainValue(42);\n }\n\n [Theory]\n [MemberData(nameof(DictionariesData))]\n public void When_comparing_dictionary_like_collections_for_equality_it_should_succeed(T1 subject, T2 expected)\n where T1 : IEnumerable>\n where T2 : IEnumerable>\n {\n // Act / Assert\n subject.Should().Equal(expected);\n }\n\n [Theory]\n [MemberData(nameof(DictionariesData))]\n public void When_comparing_dictionary_like_collections_for_inequality_it_should_throw(T1 subject, T2 expected)\n where T1 : IEnumerable>\n where T2 : IEnumerable>\n {\n // Act\n Action act = () => subject.Should().NotEqual(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n public static TheoryData SingleDictionaryData() =>\n new(Dictionaries());\n\n public static object[] Dictionaries()\n {\n return\n [\n new Dictionary { [1] = 42 },\n new TrueReadOnlyDictionary(new Dictionary { [1] = 42 }),\n new List> { new(1, 42) }\n ];\n }\n\n public static TheoryData DictionariesData()\n {\n var pairs =\n from x in Dictionaries()\n from y in Dictionaries()\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should()\n .HaveCount(2)\n .And.ContainKey(1)\n .And.ContainValue(\"Two\");\n }\n }\n\n /// \n /// This class only implements ,\n /// as also implements .\n /// \n /// The type of the keys in the dictionary.\n /// The type of the values in the dictionary.\n private class TrueReadOnlyDictionary : IReadOnlyDictionary\n {\n private readonly IReadOnlyDictionary dictionary;\n\n public TrueReadOnlyDictionary(IReadOnlyDictionary dictionary)\n {\n this.dictionary = dictionary;\n }\n\n public TValue this[TKey key] => dictionary[key];\n\n public IEnumerable Keys => dictionary.Keys;\n\n public IEnumerable Values => dictionary.Values;\n\n public int Count => dictionary.Count;\n\n public bool ContainsKey(TKey key) => dictionary.ContainsKey(key);\n\n public IEnumerator> GetEnumerator() => dictionary.GetEnumerator();\n\n public bool TryGetValue(TKey key, out TValue value) => dictionary.TryGetValue(key, out value);\n\n IEnumerator IEnumerable.GetEnumerator() => dictionary.GetEnumerator();\n }\n\n internal class TrackingTestDictionary : IDictionary\n {\n private readonly IDictionary entries;\n\n public TrackingTestDictionary(params KeyValuePair[] entries)\n {\n this.entries = entries.ToDictionary(e => e.Key, e => e.Value);\n Enumerator = new TrackingDictionaryEnumerator(entries);\n }\n\n public TrackingDictionaryEnumerator Enumerator { get; }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public IEnumerator> GetEnumerator()\n {\n Enumerator.IncreaseEnumerationCount();\n Enumerator.Reset();\n return Enumerator;\n }\n\n public void Add(KeyValuePair item)\n {\n entries.Add(item);\n }\n\n public void Clear()\n {\n entries.Clear();\n }\n\n public bool Contains(KeyValuePair item)\n {\n return entries.Contains(item);\n }\n\n public void CopyTo(KeyValuePair[] array, int arrayIndex)\n {\n entries.CopyTo(array, arrayIndex);\n }\n\n public bool Remove(KeyValuePair item)\n {\n return entries.Remove(item);\n }\n\n public int Count\n {\n get { return entries.Count; }\n }\n\n public bool IsReadOnly\n {\n get { return entries.IsReadOnly; }\n }\n\n public bool ContainsKey(int key)\n {\n return entries.ContainsKey(key);\n }\n\n public void Add(int key, string value)\n {\n entries.Add(key, value);\n }\n\n public bool Remove(int key)\n {\n return entries.Remove(key);\n }\n\n public bool TryGetValue(int key, out string value)\n {\n return entries.TryGetValue(key, out value);\n }\n\n public string this[int key]\n {\n get { return entries[key]; }\n set { entries[key] = value; }\n }\n\n public ICollection Keys\n {\n get { return entries.Keys; }\n }\n\n public ICollection Values\n {\n get { return entries.Values; }\n }\n }\n\n internal sealed class TrackingDictionaryEnumerator : IEnumerator>\n {\n private readonly KeyValuePair[] values;\n private int index;\n\n public TrackingDictionaryEnumerator(KeyValuePair[] values)\n {\n index = -1;\n this.values = values;\n }\n\n public int LoopCount { get; private set; }\n\n public void IncreaseEnumerationCount()\n {\n LoopCount++;\n }\n\n public void Dispose()\n {\n }\n\n public bool MoveNext()\n {\n index++;\n return index < values.Length;\n }\n\n public void Reset()\n {\n index = -1;\n }\n\n public KeyValuePair Current\n {\n get { return values[index]; }\n }\n\n object IEnumerator.Current\n {\n get { return Current; }\n }\n }\n\n internal class DictionaryNotImplementingIReadOnlyDictionary : IDictionary\n {\n private readonly Dictionary dictionary = [];\n\n public TValue this[TKey key] { get => dictionary[key]; set => throw new NotImplementedException(); }\n\n public ICollection Keys => dictionary.Keys;\n\n public ICollection Values => dictionary.Values;\n\n public int Count => dictionary.Count;\n\n public bool IsReadOnly => ((ICollection>)dictionary).IsReadOnly;\n\n public void Add(TKey key, TValue value) => throw new NotImplementedException();\n\n public void Add(KeyValuePair item) => throw new NotImplementedException();\n\n public void Clear() => throw new NotImplementedException();\n\n public bool Contains(KeyValuePair item) => dictionary.Contains(item);\n\n public bool ContainsKey(TKey key) => dictionary.ContainsKey(key);\n\n public void CopyTo(KeyValuePair[] array, int arrayIndex) => throw new NotImplementedException();\n\n public IEnumerator> GetEnumerator() => dictionary.GetEnumerator();\n\n public bool Remove(TKey key) => throw new NotImplementedException();\n\n public bool Remove(KeyValuePair item) => throw new NotImplementedException();\n\n public bool TryGetValue(TKey key, out TValue value) => dictionary.TryGetValue(key, out value);\n\n IEnumerator IEnumerable.GetEnumerator() => dictionary.GetEnumerator();\n }\n\n public class MyClass\n {\n public int SomeProperty { get; set; }\n\n protected bool Equals(MyClass other)\n {\n return SomeProperty == other.SomeProperty;\n }\n\n public override bool Equals(object obj)\n {\n if (obj is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n if (obj.GetType() != GetType())\n {\n return false;\n }\n\n return Equals((MyClass)obj);\n }\n\n public override int GetHashCode()\n {\n return SomeProperty;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeDataContractSerializable.cs", "using System;\nusing System.Runtime.Serialization;\nusing AwesomeAssertions.Extensions;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeDataContractSerializable\n {\n [Fact]\n public void When_an_object_is_data_contract_serializable_it_should_succeed()\n {\n // Arrange\n var subject = new DataContractSerializableClass\n {\n Name = \"John\",\n Id = 1\n };\n\n // Act / Assert\n subject.Should().BeDataContractSerializable();\n }\n\n [Fact]\n public void When_an_object_is_not_data_contract_serializable_it_should_fail()\n {\n // Arrange\n var subject = new NonDataContractSerializableClass();\n\n // Act\n Action act = () => subject.Should().BeDataContractSerializable(\"we need to store it on {0}\", \"disk\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*we need to store it on disk*EnumMemberAttribute*\");\n }\n\n [Fact]\n public void When_an_object_is_data_contract_serializable_but_doesnt_restore_all_properties_it_should_fail()\n {\n // Arrange\n var subject = new DataContractSerializableClassNotRestoringAllProperties\n {\n Name = \"John\",\n BirthDay = 20.September(1973)\n };\n\n // Act\n Action act = () => subject.Should().BeDataContractSerializable();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be serializable, but serialization failed with:*property subject.Name*to be*\");\n }\n\n [Fact]\n public void When_a_data_contract_serializable_object_doesnt_restore_an_ignored_property_it_should_succeed()\n {\n // Arrange\n var subject = new DataContractSerializableClassNotRestoringAllProperties\n {\n Name = \"John\",\n BirthDay = 20.September(1973)\n };\n\n // Act / Assert\n subject.Should()\n .BeDataContractSerializable(\n options => options.Excluding(x => x.Name));\n }\n\n [Fact]\n public void When_injecting_null_options_to_BeDataContractSerializable_it_should_throw()\n {\n // Arrange\n var subject = new DataContractSerializableClassNotRestoringAllProperties();\n\n // Act\n Action act = () => subject.Should()\n .BeDataContractSerializable(\n options: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"options\");\n }\n }\n\n public class NonDataContractSerializableClass\n {\n public Color Color { get; set; }\n }\n\n public class DataContractSerializableClass\n {\n [UsedImplicitly]\n public string Name { get; set; }\n\n public int Id;\n }\n\n [DataContract]\n public class DataContractSerializableClassNotRestoringAllProperties\n {\n public string Name { get; set; }\n\n [DataMember]\n public DateTime BirthDay { get; set; }\n }\n\n public enum Color\n {\n Red = 1,\n Yellow = 2\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AssertionsApiSpecs.cs", "using System;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Types;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs;\n\npublic sealed class AssertionsApiSpecs\n{\n [Fact]\n public void Assertions_types_have_property_names_by_convention()\n {\n static bool IsAssertionsClass(Type type)\n {\n if (type.IsDefined(typeof(CompilerGeneratedAttribute)))\n {\n return false;\n }\n\n string name = type.Name;\n int lastIndex = type.Name.LastIndexOf('`');\n if (lastIndex >= 0)\n {\n name = name[..lastIndex];\n }\n\n return name.EndsWith(\"Assertions\", StringComparison.Ordinal);\n }\n\n Assembly awesomeAssertionsAssembly = typeof(AssertionScope).Assembly;\n TypeSelector assertionsClasses = awesomeAssertionsAssembly.Types()\n .ThatAreClasses()\n .ThatAreNotAbstract()\n .ThatAreNotStatic()\n .ThatSatisfy(IsAssertionsClass);\n\n assertionsClasses.AsEnumerable().Should().AllSatisfy(\n type => type.Should().HaveProperty(\"CurrentAssertionChain\"));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/FailureMessageFormatter.cs", "using System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Encapsulates expanding the various placeholders supported in a failure message.\n/// \ninternal class FailureMessageFormatter(FormattingOptions formattingOptions)\n{\n private static readonly char[] Blanks = ['\\r', '\\n', ' ', '\\t'];\n private string reason;\n private ContextDataDictionary contextData;\n private string identifier;\n private string fallbackIdentifier;\n\n public FailureMessageFormatter WithReason(string reason)\n {\n this.reason = SanitizeReason(reason ?? string.Empty);\n return this;\n }\n\n private static string SanitizeReason(string reason)\n {\n if (!string.IsNullOrEmpty(reason))\n {\n reason = EnsurePrefix(\"because\", reason);\n reason = reason.EscapePlaceholders();\n\n return StartsWithBlank(reason) ? reason : \" \" + reason;\n }\n\n return string.Empty;\n }\n\n // SMELL: looks way too complex just to retain the leading whitespace\n private static string EnsurePrefix(string prefix, string text)\n {\n string leadingBlanks = ExtractLeadingBlanksFrom(text);\n string textWithoutLeadingBlanks = text.Substring(leadingBlanks.Length);\n\n return !textWithoutLeadingBlanks.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)\n ? leadingBlanks + prefix + \" \" + textWithoutLeadingBlanks\n : text;\n }\n\n private static string ExtractLeadingBlanksFrom(string text)\n {\n string trimmedText = text.TrimStart(Blanks);\n int leadingBlanksCount = text.Length - trimmedText.Length;\n\n return text.Substring(0, leadingBlanksCount);\n }\n\n private static bool StartsWithBlank(string text)\n {\n return text.Length > 0 && Blanks.Contains(text[0]);\n }\n\n public FailureMessageFormatter WithContext(ContextDataDictionary contextData)\n {\n this.contextData = contextData;\n return this;\n }\n\n public FailureMessageFormatter WithIdentifier(string identifier)\n {\n this.identifier = identifier;\n return this;\n }\n\n public FailureMessageFormatter WithFallbackIdentifier(string fallbackIdentifier)\n {\n this.fallbackIdentifier = fallbackIdentifier;\n return this;\n }\n\n public string Format(string message, object[] messageArgs)\n {\n message = message.Replace(\"{reason}\", reason, StringComparison.Ordinal);\n\n message = SubstituteIdentifier(message, identifier?.EscapePlaceholders(), fallbackIdentifier);\n\n message = SubstituteContextualTags(message, contextData);\n\n message = FormatArgumentPlaceholders(message, messageArgs);\n\n return message;\n }\n\n private static string SubstituteIdentifier(string message, string identifier, string fallbackIdentifier)\n {\n const string pattern = @\"(?:\\s|^)\\{context(?:\\:(?[a-zA-Z\\s]+))?\\}\";\n\n message = Regex.Replace(message, pattern, match =>\n {\n const string result = \" \";\n\n if (!string.IsNullOrEmpty(identifier))\n {\n return result + identifier;\n }\n\n string defaultIdentifier = match.Groups[\"default\"].Value;\n\n if (!string.IsNullOrEmpty(defaultIdentifier))\n {\n return result + defaultIdentifier;\n }\n\n if (!string.IsNullOrEmpty(fallbackIdentifier))\n {\n return result + fallbackIdentifier;\n }\n\n return \" object\";\n });\n\n return message.TrimStart();\n }\n\n private static string SubstituteContextualTags(string message, ContextDataDictionary contextData)\n {\n const string pattern = @\"(?[a-zA-Z]+)(?:\\:(?[a-zA-Z\\s]+))?\\}(?!\\})\";\n\n return Regex.Replace(message, pattern, match =>\n {\n string key = match.Groups[\"key\"].Value;\n string contextualTags = contextData.AsStringOrDefault(key);\n string contextualTagsSubstituted = contextualTags?.EscapePlaceholders();\n\n return contextualTagsSubstituted ?? match.Groups[\"default\"].Value;\n });\n }\n\n private string FormatArgumentPlaceholders(string failureMessage, object[] failureArgs)\n {\n object[] values = failureArgs.Select(object (a) => Formatter.ToString(a, formattingOptions)).ToArray();\n\n try\n {\n return string.Format(CultureInfo.InvariantCulture, failureMessage, values);\n }\n catch (FormatException formatException)\n {\n return\n $\"**WARNING** failure message '{failureMessage}' could not be formatted with string.Format{Environment.NewLine}{formatException.StackTrace}\";\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/PredicateLambdaExpressionValueFormatterSpecs.cs", "using System;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class PredicateLambdaExpressionValueFormatterSpecs\n{\n private readonly PredicateLambdaExpressionValueFormatter formatter = new();\n\n [Fact]\n public void Constructor_expression_with_argument_can_be_formatted()\n {\n // Arrange\n Expression expression = (string arg) => new TestItem { Value = arg };\n\n // Act\n string result = Formatter.ToString(expression);\n\n // Assert\n result.Should().Be(\"new TestItem() {Value = arg}\");\n }\n\n [Fact]\n public void Constructor_expression_can_be_simplified()\n {\n // Arrange\n string value = \"foo\";\n Expression expression = () => new TestItem { Value = value };\n\n // Act\n string result = Formatter.ToString(expression);\n\n // Assert\n result.Should().Be(\"new TestItem() {Value = \\\"foo\\\"}\");\n }\n\n private sealed class TestItem\n {\n public string Value { get; set; }\n }\n\n [Fact]\n public void When_first_level_properties_are_tested_for_equality_against_constants_then_output_should_be_readable()\n {\n // Act\n string result = Format(a => a.Text == \"foo\" && a.Number == 123);\n\n // Assert\n result.Should().Be(\"(a.Text == \\\"foo\\\") AndAlso (a.Number == 123)\");\n }\n\n [Fact]\n public void\n When_first_level_properties_are_tested_for_equality_against_constant_expressions_then_output_should_contain_values_of_constant_expressions()\n {\n // Arrange\n var expectedText = \"foo\";\n var expectedNumber = 123;\n\n // Act\n string result = Format(a => a.Text == expectedText && a.Number == expectedNumber);\n\n // Assert\n result.Should().Be(\"(a.Text == \\\"foo\\\") AndAlso (a.Number == 123)\");\n }\n\n [Fact]\n public void When_more_than_two_conditions_are_joined_with_and_operator_then_output_should_not_have_nested_parenthesis()\n {\n // Act\n string result = Format(a => a.Text == \"123\" && a.Number >= 0 && a.Number <= 1000);\n\n // Assert\n result.Should().Be(\"(a.Text == \\\"123\\\") AndAlso (a.Number >= 0) AndAlso (a.Number <= 1000)\");\n }\n\n [Fact]\n public void When_condition_contains_extension_method_then_extension_method_must_be_formatted()\n {\n // Act\n string result = Format(a => a.TextIsNotBlank() && a.Number >= 0 && a.Number <= 1000);\n\n // Assert\n result.Should().Be(\"a.TextIsNotBlank() AndAlso (a.Number >= 0) AndAlso (a.Number <= 1000)\");\n }\n\n [Fact]\n public void When_condition_contains_linq_extension_method_then_extension_method_must_be_formatted()\n {\n // Arrange\n int[] allowed = [1, 2, 3];\n\n // Act\n string result = Format(a => allowed.Contains(a));\n\n // Assert\n result.Should().Be(\"value(System.Int32[]).Contains(a)\");\n }\n\n [Fact]\n public void Formatting_a_lifted_binary_operator()\n {\n // Arrange\n var subject = new ClassWithNullables { Number = 42 };\n\n // Act\n Action act = () => subject.Should().Match(e => e.Number > 43);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*e.Number > *43*\");\n }\n\n private string Format(Expression> expression) => Format(expression);\n\n private string Format(Expression> expression)\n {\n var graph = new FormattedObjectGraph(maxLines: 100);\n\n formatter.Format(expression, graph, new FormattingContext(), null);\n\n return graph.ToString();\n }\n}\n\ninternal class ClassWithNullables\n{\n public int? Number { get; set; }\n}\n\ninternal class SomeClass\n{\n public string Text { get; set; }\n\n public int Number { get; set; }\n}\n\ninternal static class SomeClassExtensions\n{\n public static bool TextIsNotBlank(this SomeClass someObject) => !string.IsNullOrWhiteSpace(someObject.Text);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/UInt64Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class UInt64Assertions : NumericAssertions\n{\n internal UInt64Assertions(ulong value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(ulong subject, ulong expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n decimal difference = (decimal)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeAtLeast.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeAtLeast\n {\n [Fact]\n public void When_date_is_not_at_least_one_day_before_another_it_should_throw()\n {\n // Arrange\n var target = new DateTime(2009, 10, 2);\n DateTime subject = target - 23.Hours();\n\n // Act\n Action act = () => subject.Should().BeAtLeast(TimeSpan.FromDays(1)).Before(target, \"we like {0}\", \"that\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2009-10-01 01:00:00> to be at least 1d before <2009-10-02> because we like that, but it is behind by 23h.\");\n }\n\n [Fact]\n public void When_date_is_at_least_one_day_before_another_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(2009, 10, 2);\n DateTime subject = target - 24.Hours();\n\n // Act / Assert\n subject.Should().BeAtLeast(TimeSpan.FromDays(1)).Before(target);\n }\n\n [Theory]\n [InlineData(30, 20)] // edge case\n [InlineData(30, 15)]\n public void When_asserting_subject_be_at_least_10_seconds_after_target_but_subject_is_before_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds);\n var subject = 1.January(0001).At(0, 0, subjectSeconds);\n\n // Act\n Action action = () => subject.Should().BeAtLeast(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds}> to be at least 10s after <00:00:30>, but it is behind by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Theory]\n [InlineData(30, 40)] // edge case\n [InlineData(30, 45)]\n public void When_asserting_subject_be_at_least_10_seconds_before_target_but_subject_is_after_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds);\n var subject = 1.January(0001).At(0, 0, subjectSeconds);\n\n // Act\n Action action = () => subject.Should().BeAtLeast(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds}> to be at least 10s before <00:00:30>, but it is ahead by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateTimeRangeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that two objects differ in the expected way.\n/// \n/// \n/// You can use the and\n/// for a more fluent\n/// way of specifying a or a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeRangeAssertions\n where TAssertions : DateTimeAssertions\n{\n #region Private Definitions\n\n private readonly TAssertions parentAssertions;\n private readonly TimeSpanPredicate predicate;\n\n private readonly Dictionary predicates = new()\n {\n [TimeSpanCondition.MoreThan] = new TimeSpanPredicate((ts1, ts2) => ts1 > ts2, \"more than\"),\n [TimeSpanCondition.AtLeast] = new TimeSpanPredicate((ts1, ts2) => ts1 >= ts2, \"at least\"),\n [TimeSpanCondition.Exactly] = new TimeSpanPredicate((ts1, ts2) => ts1 == ts2, \"exactly\"),\n [TimeSpanCondition.Within] = new TimeSpanPredicate((ts1, ts2) => ts1 <= ts2, \"within\"),\n [TimeSpanCondition.LessThan] = new TimeSpanPredicate((ts1, ts2) => ts1 < ts2, \"less than\")\n };\n\n private readonly DateTime? subject;\n private readonly TimeSpan timeSpan;\n\n #endregion\n\n protected internal DateTimeRangeAssertions(TAssertions parentAssertions, AssertionChain assertionChain,\n DateTime? subject,\n TimeSpanCondition condition,\n TimeSpan timeSpan)\n {\n this.parentAssertions = parentAssertions;\n CurrentAssertionChain = assertionChain;\n this.subject = subject;\n this.timeSpan = timeSpan;\n\n predicate = predicates[condition];\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that a occurs a specified amount of time before another .\n /// \n /// \n /// The to compare the subject with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Before(DateTime target,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected date and/or time {0} to be \" + predicate.DisplayText +\n \" {1} before {2}{reason}, but found a DateTime.\",\n subject, timeSpan, target);\n\n if (CurrentAssertionChain.Succeeded)\n {\n TimeSpan actual = target - subject.Value;\n\n CurrentAssertionChain\n .ForCondition(predicate.IsMatchedBy(actual, timeSpan))\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:the date and time} {0} to be \" + predicate.DisplayText +\n \" {1} before {2}{reason}, but it is \" + PositionRelativeToTarget(subject.Value, target) + \" by {3}.\",\n subject, timeSpan, target, actual.Duration());\n }\n\n return new AndConstraint(parentAssertions);\n }\n\n /// \n /// Asserts that a occurs a specified amount of time after another .\n /// \n /// \n /// The to compare the subject with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint After(DateTime target,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected date and/or time {0} to be \" + predicate.DisplayText +\n \" {1} after {2}{reason}, but found a DateTime.\",\n subject, timeSpan, target);\n\n if (CurrentAssertionChain.Succeeded)\n {\n TimeSpan actual = subject.Value - target;\n\n CurrentAssertionChain\n .ForCondition(predicate.IsMatchedBy(actual, timeSpan))\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:the date and time} {0} to be \" + predicate.DisplayText +\n \" {1} after {2}{reason}, but it is \" + PositionRelativeToTarget(subject.Value, target) + \" by {3}.\",\n subject, timeSpan, target, actual.Duration());\n }\n\n return new AndConstraint(parentAssertions);\n }\n\n private static string PositionRelativeToTarget(DateTime actual, DateTime target)\n {\n return (actual - target) >= TimeSpan.Zero ? \"ahead\" : \"behind\";\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Before() or After() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableUInt64Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableUInt64Assertions : NullableNumericAssertions\n{\n internal NullableUInt64Assertions(ulong? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(ulong subject, ulong expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n decimal difference = (decimal)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeDecoratedWith.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeDecoratedWith specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeDecoratedWith\n {\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_it_succeeds()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithAttribute.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_it_should_allow_chaining()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithAttribute.Should().BeDecoratedWith()\n .Which.IsEnabled.Should().BeTrue();\n }\n\n [Fact]\n public void When_type_is_not_decorated_with_expected_attribute_it_fails()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithoutAttribute);\n\n // Act\n Action act = () =>\n typeWithoutAttribute.Should().BeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithoutAttribute to be decorated with *.DummyClassAttribute *failure message*\" +\n \", but the attribute was not found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_BeDecoratedWith_it_should_throw()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should().BeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithAttribute.Should()\n .BeDecoratedWith(a => a.Name == \"Expected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_with_the_expected_properties_it_should_allow_chaining()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithAttribute.Should()\n .BeDecoratedWith(a => a.Name == \"Expected\")\n .Which.IsEnabled.Should().BeTrue();\n }\n\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_that_has_an_unexpected_property_it_fails()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should()\n .BeDecoratedWith(a => a.Name == \"Unexpected\" && a.IsEnabled);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithAttribute to be decorated with *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Unexpected\\\")*a.IsEnabled, but no matching attribute was found.\");\n }\n }\n\n public class NotBeDecoratedWith\n {\n [Fact]\n public void When_type_is_not_decorated_with_unexpected_attribute_it_succeeds()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithoutAttribute);\n\n // Act / Assert\n typeWithoutAttribute.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_type_is_decorated_with_unexpected_attribute_it_fails()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should().NotBeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithAttribute to not be decorated with *.DummyClassAttribute* *failure message*\" +\n \", but the attribute was found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotBeDecoratedWith_it_should_throw()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () => typeWithoutAttribute.Should()\n .NotBeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_type_is_not_decorated_with_unexpected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithoutAttribute.Should()\n .NotBeDecoratedWith(a => a.Name == \"Unexpected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_type_is_not_decorated_with_expected_attribute_that_has_an_unexpected_property_it_fails()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n typeWithoutAttribute.Should()\n .NotBeDecoratedWith(a => a.Name == \"Expected\" && a.IsEnabled);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithAttribute to not be decorated with *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\") * a.IsEnabled, but a matching attribute was found.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/TypeEnumerableExtensionsSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing TypeEnumerableExtensionsSpecs.BaseNamespace;\nusing TypeEnumerableExtensionsSpecs.BaseNamespace.Nested;\nusing TypeEnumerableExtensionsSpecs.Internal;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs\n{\n public class TypeEnumerableExtensionsSpecs\n {\n [Fact]\n public void When_selecting_types_that_decorated_with_attribute_it_should_return_the_correct_type()\n {\n Type[] types =\n [\n typeof(JustAClass), typeof(ClassWithSomeAttribute), typeof(ClassDerivedFromClassWithSomeAttribute)\n ];\n\n types.ThatAreDecoratedWith()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(ClassWithSomeAttribute));\n }\n\n [Fact]\n public void When_selecting_types_that_decorated_with_attribute_or_inherit_it_should_return_the_correct_type()\n {\n Type[] types =\n [\n typeof(JustAClass), typeof(ClassWithSomeAttribute), typeof(ClassDerivedFromClassWithSomeAttribute)\n ];\n\n types.ThatAreDecoratedWithOrInherit()\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(ClassWithSomeAttribute))\n .And.Contain(typeof(ClassDerivedFromClassWithSomeAttribute));\n }\n\n [Fact]\n public void When_selecting_types_that_not_decorated_with_attribute_it_should_return_the_correct_type()\n {\n Type[] types =\n [\n typeof(JustAClass), typeof(ClassWithSomeAttribute), typeof(ClassDerivedFromClassWithSomeAttribute)\n ];\n\n types.ThatAreNotDecoratedWith()\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(JustAClass))\n .And.Contain(typeof(ClassDerivedFromClassWithSomeAttribute));\n }\n\n [Fact]\n public void When_selecting_types_that_not_decorated_with_attribute_or_inherit_it_should_return_the_correct_type()\n {\n Type[] types =\n [\n typeof(JustAClass), typeof(ClassWithSomeAttribute), typeof(ClassDerivedFromClassWithSomeAttribute)\n ];\n\n types.ThatAreNotDecoratedWithOrInherit()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(JustAClass));\n }\n\n [Fact]\n public void When_selecting_types_in_namespace_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(BaseNamespaceClass), typeof(NestedNamespaceClass)];\n\n types.ThatAreInNamespace(typeof(BaseNamespaceClass).Namespace)\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(BaseNamespaceClass));\n }\n\n [Fact]\n public void When_selecting_types_under_namespace_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(BaseNamespaceClass), typeof(NestedNamespaceClass)];\n\n types.ThatAreUnderNamespace(typeof(BaseNamespaceClass).Namespace)\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(BaseNamespaceClass))\n .And.Contain(typeof(NestedNamespaceClass));\n }\n\n [Fact]\n public void When_selecting_derived_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(SomeBaseClass), typeof(SomeClassDerivedFromSomeBaseClass)];\n\n types.ThatDeriveFrom()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(SomeClassDerivedFromSomeBaseClass));\n }\n\n [Fact]\n public void When_selecting_types_that_implement_interface_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(ClassImplementingJustAnInterface), typeof(IJustAnInterface)];\n\n types.ThatImplement()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(ClassImplementingJustAnInterface));\n }\n\n [Fact]\n public void When_selecting_only_the_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(IJustAnInterface)];\n\n types.ThatAreClasses()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(JustAClass));\n }\n\n [Fact]\n public void When_selecting_not_a_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(IJustAnInterface)];\n\n types.ThatAreNotClasses()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(IJustAnInterface));\n }\n\n [Fact]\n public void When_selecting_static_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(AStaticClass)];\n\n types.ThatAreStatic()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(AStaticClass));\n }\n\n [Fact]\n public void When_selecting_not_a_static_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(AStaticClass)];\n\n types.ThatAreNotStatic()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(JustAClass));\n }\n\n [Fact]\n public void When_selecting_types_with_predicate_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(AStaticClass)];\n\n types.ThatSatisfy(t => t.IsSealed && t.IsAbstract)\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(AStaticClass));\n }\n\n [Fact]\n public void When_unwrap_task_types_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(Task), typeof(List)];\n\n types.UnwrapTaskTypes()\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(JustAClass))\n .And.Contain(typeof(List));\n }\n\n [Fact]\n public void When_unwrap_enumerable_types_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(Task), typeof(List)];\n\n types.UnwrapEnumerableTypes()\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(Task))\n .And.Contain(typeof(IJustAnInterface));\n }\n }\n}\n\n#region Internal classes used in unit tests\n\nnamespace TypeEnumerableExtensionsSpecs.BaseNamespace\n{\n internal class BaseNamespaceClass;\n}\n\nnamespace TypeEnumerableExtensionsSpecs.BaseNamespace.Nested\n{\n internal class NestedNamespaceClass;\n}\n\nnamespace TypeEnumerableExtensionsSpecs.Internal\n{\n internal interface IJustAnInterface;\n\n internal class JustAClass;\n\n internal static class AStaticClass;\n\n internal class SomeBaseClass;\n\n internal class SomeClassDerivedFromSomeBaseClass : SomeBaseClass;\n\n internal class ClassImplementingJustAnInterface : IJustAnInterface;\n\n [Some]\n internal class ClassWithSomeAttribute;\n\n internal class ClassDerivedFromClassWithSomeAttribute : ClassWithSomeAttribute;\n\n [AttributeUsage(AttributeTargets.Class)]\n internal class SomeAttribute : Attribute;\n}\n\n#endregion\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateTimeOffsetRangeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n\nnamespace AwesomeAssertions.Primitives;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that two objects differ in the expected way.\n/// \n/// \n/// You can use the and \n/// for a more fluent way of specifying a or a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeOffsetRangeAssertions\n where TAssertions : DateTimeOffsetAssertions\n{\n #region Private Definitions\n\n private readonly TAssertions parentAssertions;\n private readonly TimeSpanPredicate predicate;\n\n private readonly Dictionary predicates = new()\n {\n [TimeSpanCondition.MoreThan] = new TimeSpanPredicate((ts1, ts2) => ts1 > ts2, \"more than\"),\n [TimeSpanCondition.AtLeast] = new TimeSpanPredicate((ts1, ts2) => ts1 >= ts2, \"at least\"),\n [TimeSpanCondition.Exactly] = new TimeSpanPredicate((ts1, ts2) => ts1 == ts2, \"exactly\"),\n [TimeSpanCondition.Within] = new TimeSpanPredicate((ts1, ts2) => ts1 <= ts2, \"within\"),\n [TimeSpanCondition.LessThan] = new TimeSpanPredicate((ts1, ts2) => ts1 < ts2, \"less than\")\n };\n\n private readonly DateTimeOffset? subject;\n private readonly TimeSpan timeSpan;\n\n #endregion\n\n protected internal DateTimeOffsetRangeAssertions(TAssertions parentAssertions, AssertionChain assertionChain,\n DateTimeOffset? subject,\n TimeSpanCondition condition,\n TimeSpan timeSpan)\n {\n this.parentAssertions = parentAssertions;\n CurrentAssertionChain = assertionChain;\n this.subject = subject;\n this.timeSpan = timeSpan;\n\n predicate = predicates[condition];\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that a occurs a specified amount of time before another .\n /// \n /// \n /// The to compare the subject with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Before(DateTimeOffset target,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be \" + predicate.DisplayText +\n \" {0} before {1}{reason}, but found a DateTime.\", timeSpan, target);\n\n if (CurrentAssertionChain.Succeeded)\n {\n TimeSpan actual = target - subject.Value;\n\n CurrentAssertionChain\n .ForCondition(predicate.IsMatchedBy(actual, timeSpan))\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:the date and time} {0} to be \" + predicate.DisplayText +\n \" {1} before {2}{reason}, but it is \" + PositionRelativeToTarget(subject.Value, target) + \" by {3}.\",\n subject, timeSpan, target, actual.Duration());\n }\n\n return new AndConstraint(parentAssertions);\n }\n\n /// \n /// Asserts that a occurs a specified amount of time after another .\n /// \n /// \n /// The to compare the subject with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint After(DateTimeOffset target,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be \" + predicate.DisplayText +\n \" {0} after {1}{reason}, but found a DateTime.\", timeSpan, target);\n\n if (CurrentAssertionChain.Succeeded)\n {\n TimeSpan actual = subject.Value - target;\n\n CurrentAssertionChain\n .ForCondition(predicate.IsMatchedBy(actual, timeSpan))\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:the date and time} {0} to be \" + predicate.DisplayText +\n \" {1} after {2}{reason}, but it is \" + PositionRelativeToTarget(subject.Value, target) + \" by {3}.\",\n subject, timeSpan, target, actual.Duration());\n }\n\n return new AndConstraint(parentAssertions);\n }\n\n private static string PositionRelativeToTarget(DateTimeOffset actual, DateTimeOffset target)\n {\n return (actual - target) >= TimeSpan.Zero ? \"ahead\" : \"behind\";\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Before() or After() instead?\");\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeMoreThan.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeMoreThan\n {\n [Fact]\n public void When_date_is_not_more_than_the_required_one_day_before_another_it_should_throw()\n {\n // Arrange\n var target = new DateTime(2009, 10, 2);\n DateTime subject = target - 1.Days();\n\n // Act\n Action act = () => subject.Should().BeMoreThan(TimeSpan.FromDays(1)).Before(target, \"we like {0}\", \"that\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2009-10-01> to be more than 1d before <2009-10-02> because we like that, but it is behind by 1d.\");\n }\n\n [Fact]\n public void When_date_is_more_than_the_required_one_day_before_another_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(2009, 10, 2);\n DateTime subject = target - 25.Hours();\n\n // Act / Assert\n subject.Should().BeMoreThan(TimeSpan.FromDays(1)).Before(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_more_than_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 15);\n\n // Act\n Action action = () => subject.Should().BeMoreThan(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:15> to be more than 10s after <00:00:30>, but it is behind by 15s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_more_than_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 45);\n\n // Act\n Action action = () => subject.Should().BeMoreThan(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:45> to be more than 10s before <00:00:30>, but it is ahead by 15s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeAtLeast.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeAtLeast\n {\n [Fact]\n public void When_date_is_not_at_least_one_day_before_another_it_should_throw()\n {\n // Arrange\n var target = new DateTimeOffset(2.October(2009), 0.Hours());\n DateTimeOffset subject = target - 23.Hours();\n\n // Act\n Action act = () => subject.Should().BeAtLeast(TimeSpan.FromDays(1)).Before(target, \"we like {0}\", \"that\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2009-10-01 01:00:00 +0h> to be at least 1d before <2009-10-02 +0h> because we like that, but it is behind by 23h.\");\n }\n\n [Fact]\n public void When_date_is_at_least_one_day_before_another_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(2.October(2009));\n DateTimeOffset subject = target - 24.Hours();\n\n // Act / Assert\n subject.Should().BeAtLeast(TimeSpan.FromDays(1)).Before(target);\n }\n\n [Theory]\n [InlineData(30, 20)] // edge case\n [InlineData(30, 15)]\n public void When_asserting_subject_be_at_least_10_seconds_after_target_but_subject_is_before_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, subjectSeconds).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeAtLeast(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds} +0h> to be at least 10s after <00:00:30 +0h>, but it is behind by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Theory]\n [InlineData(30, 40)] // edge case\n [InlineData(30, 45)]\n public void When_asserting_subject_be_at_least_10_seconds_before_target_but_subject_is_after_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, subjectSeconds).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeAtLeast(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds} +0h> to be at least 10s before <00:00:30 +0h>, but it is ahead by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Build/CompressionExtensions.cs", "using System.IO;\nusing Nuke.Common.IO;\nusing SharpCompress.Common;\nusing SharpCompress.Readers;\n\npublic static class CompressionExtensions\n{\n public static void UnTarXzTo(this AbsolutePath archive, AbsolutePath directory)\n {\n using Stream stream = File.OpenRead(archive);\n\n using var reader = ReaderFactory.Open(stream);\n\n while (reader.MoveToNextEntry())\n {\n if (reader.Entry.IsDirectory)\n {\n continue;\n }\n\n reader.WriteEntryToDirectory(directory, new ExtractionOptions\n {\n ExtractFullPath = true,\n Overwrite = true\n });\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeLessThan.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeLessThan\n {\n [Fact]\n public void When_time_is_not_less_than_30s_after_another_time_it_should_throw()\n {\n // Arrange\n var target = new DateTime(1, 1, 1, 12, 0, 30);\n DateTime subject = target + 30.Seconds();\n\n // Act\n Action act =\n () => subject.Should().BeLessThan(TimeSpan.FromSeconds(30)).After(target, \"{0}s is the max\", 30);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <12:01:00> to be less than 30s after <12:00:30> because 30s is the max, but it is ahead by 30s.\");\n }\n\n [Fact]\n public void When_time_is_less_than_30s_after_another_time_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(1, 1, 1, 12, 0, 30);\n DateTime subject = target + 20.Seconds();\n\n // Act / Assert\n subject.Should().BeLessThan(TimeSpan.FromSeconds(30)).After(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_less_than_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 25);\n\n // Act\n Action action = () => subject.Should().BeLessThan(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:25> to be less than 10s after <00:00:30>, but it is behind by 5s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_less_than_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 45);\n\n // Act\n Action action = () => subject.Should().BeLessThan(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:45> to be less than 10s before <00:00:30>, but it is ahead by 15s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/UInt16Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class UInt16Assertions : NumericAssertions\n{\n internal UInt16Assertions(ushort value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(ushort subject, ushort expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeExactly.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeExactly\n {\n [Fact]\n public void When_time_is_not_at_exactly_20_minutes_before_another_time_it_should_throw()\n {\n // Arrange\n DateTime target = 1.January(0001).At(12, 55);\n DateTime subject = 1.January(0001).At(12, 36);\n\n // Act\n Action act =\n () => subject.Should().BeExactly(TimeSpan.FromMinutes(20)).Before(target, \"{0} minutes is enough\", 20);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <12:36:00> to be exactly 20m before <12:55:00> because 20 minutes is enough, but it is behind by 19m.\");\n }\n\n [Fact]\n public void When_time_is_exactly_90_seconds_before_another_time_it_should_not_throw()\n {\n // Arrange\n DateTime target = 1.January(0001).At(12, 55);\n DateTime subject = 1.January(0001).At(12, 53, 30);\n\n // Act / Assert\n subject.Should().BeExactly(TimeSpan.FromSeconds(90)).Before(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_exactly_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 20);\n\n // Ac\n Action action = () => subject.Should().BeExactly(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:20> to be exactly 10s after <00:00:30>, but it is behind by 10s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_exactly_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 40);\n\n // Act\n Action action = () => subject.Should().BeExactly(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:40> to be exactly 10s before <00:00:30>, but it is ahead by 10s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableUInt16Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableUInt16Assertions : NullableNumericAssertions\n{\n internal NullableUInt16Assertions(ushort? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(ushort subject, ushort expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCount.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]HaveCount specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCount\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCount(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_that_is_different_from_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCount(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_collection_has_a_count_that_is_different_from_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () => collection.Should().HaveCount(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain 4 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_has_a_count_larger_than_the_minimum_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCount(c => c >= 3);\n }\n\n [Fact]\n public void Even_with_an_assertion_scope_only_the_first_failure_in_a_chained_call_is_reported()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCount(c => c > 3).And.HaveCount(c => c < 3);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\"*count (c > 3), but count is 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_has_a_count_that_not_matches_the_predicate_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCount(c => c >= 4, \"a minimum of 4 is required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have a count (c >= 4) because a minimum of 4 is required, but count is 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_null_predicate_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCount(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare collection count against a predicate.*\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCount(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain 1 item(s) because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_predicate_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCount(c => c < 3, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain (c < 3) items because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_predicate_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCount(c => (c % 2) == 1);\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_predicate_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCount(c => (c % 2) == 0);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_counting_generic_enumerable_it_should_enumerate()\n {\n // Arrange\n var enumerable = new CountingGenericEnumerable([1, 2, 3]);\n\n // Act\n enumerable.Should().HaveCount(3);\n\n // Assert\n enumerable.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_counting_generic_collection_it_should_not_enumerate()\n {\n // Arrange\n var collection = new CountingGenericCollection([1, 2, 3]);\n\n // Act\n collection.Should().HaveCount(3);\n\n // Assert\n collection.GetCountCallCount.Should().Be(1);\n collection.GetEnumeratorCallCount.Should().Be(0);\n }\n }\n\n public class NotHaveCount\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_different_from_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotHaveCount(2);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotHaveCount(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_has_a_count_that_equals_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () => collection.Should().NotHaveCount(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*not contain*3*because we want to test the failure message*3*\");\n }\n\n [Fact]\n public void When_collection_count_is_same_than_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotHaveCount(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*not contain*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.Be.cs", "using System;\nusing AssemblyA;\nusing AssemblyB;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]Be specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_type_is_equal_to_the_same_type_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n Type sameType = typeof(ClassWithAttribute);\n\n // Act / Assert\n type.Should().Be(sameType);\n }\n\n [Fact]\n public void When_type_is_equal_to_another_type_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n Type differentType = typeof(ClassWithoutAttribute);\n\n // Act\n Action act = () =>\n type.Should().Be(differentType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be *.ClassWithoutAttribute *failure message*, but found *.ClassWithAttribute.\");\n }\n\n [Fact]\n public void When_asserting_equality_of_two_null_types_it_succeeds()\n {\n // Arrange\n Type nullType = null;\n Type someType = null;\n\n // Act / Assert\n nullType.Should().Be(someType);\n }\n\n [Fact]\n public void When_asserting_equality_of_a_type_but_the_type_is_null_it_fails()\n {\n // Arrange\n Type nullType = null;\n Type someType = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n nullType.Should().Be(someType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be *.ClassWithAttribute *failure message*, but found .\");\n }\n\n [Fact]\n public void When_asserting_equality_of_a_type_with_null_it_fails()\n {\n // Arrange\n Type someType = typeof(ClassWithAttribute);\n Type nullType = null;\n\n // Act\n Action act = () =>\n someType.Should().Be(nullType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be *failure message*, but found *.ClassWithAttribute.\");\n }\n\n [Fact]\n public void When_type_is_equal_to_same_type_from_different_assembly_it_fails_with_assembly_qualified_name()\n {\n // Arrange\n#pragma warning disable 436 // disable the warning on conflicting types, as this is the intention for the spec\n\n Type typeFromThisAssembly = typeof(ClassC);\n\n Type typeFromOtherAssembly =\n new ClassA().ReturnClassC().GetType();\n\n#pragma warning restore 436\n\n // Act\n Action act = () =>\n typeFromThisAssembly.Should().Be(typeFromOtherAssembly, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to be [AssemblyB.ClassC, AssemblyB*] *failure message*, but found [AssemblyB.ClassC, AwesomeAssertions.Specs*].\");\n }\n\n [Fact]\n public void When_type_is_equal_to_the_same_type_using_generics_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n\n // Act / Assert\n type.Should().Be();\n }\n\n [Fact]\n public void When_type_is_equal_to_another_type_using_generics_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n type.Should().Be(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be *.ClassWithoutAttribute *failure message*, but found *.ClassWithAttribute.\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_type_is_not_equal_to_the_another_type_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n Type otherType = typeof(ClassWithoutAttribute);\n\n // Act / Assert\n type.Should().NotBe(otherType);\n }\n\n [Fact]\n public void When_type_is_not_equal_to_the_same_type_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n Type sameType = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n type.Should().NotBe(sameType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be [*.ClassWithAttribute*] *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_type_is_not_equal_to_the_same_null_type_it_fails()\n {\n // Arrange\n Type type = null;\n Type sameType = null;\n\n // Act\n Action act = () =>\n type.Should().NotBe(sameType);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_type_is_not_equal_to_another_type_using_generics_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n\n // Act / Assert\n type.Should().NotBe();\n }\n\n [Fact]\n public void When_type_is_not_equal_to_the_same_type_using_generics_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n type.Should().NotBe(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be [*.ClassWithAttribute*] *failure message*, but it is.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/EnumValueFormatter.cs", "using System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class EnumValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public virtual bool CanHandle(object value)\n {\n return value is Enum;\n }\n\n /// \n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n string typePart = value.GetType().Name;\n string namePart = value.ToString().Replace(\", \", \"|\", StringComparison.Ordinal);\n\n string valuePart = Convert.ToDecimal(value, CultureInfo.InvariantCulture)\n .ToString(CultureInfo.InvariantCulture);\n\n formattedGraph.AddFragment($\"{typePart}.{namePart} {{value: {valuePart}}}\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeWithin.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeWithin\n {\n [Fact]\n public void When_date_is_not_within_50_hours_before_another_date_it_should_throw()\n {\n // Arrange\n var target = 10.April(2010).At(12, 0).WithOffset(0.Hours());\n DateTimeOffset subject = target - 50.Hours() - 1.Seconds();\n\n // Act\n Action act =\n () => subject.Should().BeWithin(TimeSpan.FromHours(50)).Before(target, \"{0} hours is enough\", 50);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2010-04-08 09:59:59 +0h> to be within 2d and 2h before <2010-04-10 12:00:00 +0h> because 50 hours is enough, but it is behind by 2d, 2h and 1s.\");\n }\n\n [Fact]\n public void When_date_is_exactly_within_1d_before_another_date_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(10.April(2010));\n DateTimeOffset subject = target - 1.Days();\n\n // Act / Assert\n subject.Should().BeWithin(TimeSpan.FromHours(24)).Before(target);\n }\n\n [Fact]\n public void When_date_is_within_1d_before_another_date_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(10.April(2010));\n DateTimeOffset subject = target - 23.Hours();\n\n // Act / Assert\n subject.Should().BeWithin(TimeSpan.FromHours(24)).Before(target);\n }\n\n [Fact]\n public void When_a_utc_date_is_within_0s_before_itself_it_should_not_throw()\n {\n // Arrange\n var date = DateTimeOffset.UtcNow; // local timezone differs from +0h\n\n // Act / Assert\n date.Should().BeWithin(TimeSpan.Zero).Before(date);\n }\n\n [Fact]\n public void When_a_utc_date_is_within_0s_after_itself_it_should_not_throw()\n {\n // Arrange\n var date = DateTimeOffset.UtcNow; // local timezone differs from +0h\n\n // Act / Assert\n date.Should().BeWithin(TimeSpan.Zero).After(date);\n }\n\n [Theory]\n [InlineData(30, 20)] // edge case\n [InlineData(30, 25)]\n public void When_asserting_subject_be_within_10_seconds_after_target_but_subject_is_before_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, subjectSeconds).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeWithin(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds} +0h> to be within 10s after <00:00:30 +0h>, but it is behind by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Theory]\n [InlineData(30, 40)] // edge case\n [InlineData(30, 35)]\n public void When_asserting_subject_be_within_10_seconds_before_target_but_subject_is_after_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, subjectSeconds).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeWithin(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds} +0h> to be within 10s before <00:00:30 +0h>, but it is ahead by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeMoreThan.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeMoreThan\n {\n [Fact]\n public void When_date_is_not_more_than_the_required_one_day_before_another_it_should_throw()\n {\n // Arrange\n var target = new DateTimeOffset(2.October(2009), 0.Hours());\n DateTimeOffset subject = target - 1.Days();\n\n // Act\n Action act = () => subject.Should().BeMoreThan(TimeSpan.FromDays(1)).Before(target, \"we like {0}\", \"that\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2009-10-01 +0h> to be more than 1d before <2009-10-02 +0h> because we like that, but it is behind by 1d.\");\n }\n\n [Fact]\n public void When_date_is_more_than_the_required_one_day_before_another_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(2.October(2009));\n DateTimeOffset subject = target - 25.Hours();\n\n // Act / Assert\n subject.Should().BeMoreThan(TimeSpan.FromDays(1)).Before(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_more_than_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 15).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeMoreThan(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject <00:00:15 +0h> to be more than 10s after <00:00:30 +0h>, but it is behind by 15s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_more_than_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 45).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeMoreThan(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject <00:00:45 +0h> to be more than 10s before <00:00:30 +0h>, but it is ahead by 15s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/DoubleAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class DoubleAssertions : NumericAssertions\n{\n internal DoubleAssertions(double value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override bool IsNaN(double value) => double.IsNaN(value);\n\n private protected override string CalculateDifferenceForFailureMessage(double subject, double expected)\n {\n var difference = subject - expected;\n return difference != 0 ? difference.ToString(\"R\", CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/FormattedObjectGraph.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// This class is used by the class to collect all the output of the (nested calls of an) into\n/// a the final representation.\n/// \n/// \n/// The will ensure that the number of lines will be limited\n/// to the maximum number of lines provided through its constructor. It will throw\n/// a if the number of lines exceeds the maximum.\n/// \npublic class FormattedObjectGraph\n{\n private readonly int maxLines;\n private readonly List lines = [];\n private readonly StringBuilder lineBuilder = new();\n private int indentation;\n private string lineBuilderWhitespace = string.Empty;\n\n public FormattedObjectGraph(int maxLines)\n {\n this.maxLines = maxLines;\n }\n\n /// \n /// The number of spaces that should be used by every indentation level.\n /// \n public static int SpacesPerIndentation => 4;\n\n /// \n /// Returns the number of lines of text currently in the graph.\n /// \n public int LineCount => lines.Count + (lineBuilder.Length > 0 ? 1 : 0);\n\n /// \n /// Starts a new line with the provided text fragment. Additional text can be added to\n /// that same line through .\n /// \n public void AddFragmentOnNewLine(string fragment)\n {\n FlushCurrentLine();\n\n AddFragment(fragment);\n }\n\n /// \n /// Starts a new line with the provided line of text that does not allow\n /// adding more fragments of text.\n /// \n public void AddLine(string line)\n {\n FlushCurrentLine();\n\n AppendWithoutExceedingMaximumLines(Whitespace + line);\n }\n\n /// \n /// Adds a new fragment of text to the current line.\n /// \n public void AddFragment(string fragment)\n {\n if (lineBuilderWhitespace.Length > 0)\n {\n lineBuilder.Append(lineBuilderWhitespace);\n lineBuilderWhitespace = string.Empty;\n }\n\n lineBuilder.Append(fragment);\n }\n\n /// \n /// Adds a new line if there are no lines and no fragment that would cause a new line.\n /// \n internal void EnsureInitialNewLine()\n {\n if (LineCount == 0)\n {\n InsertInitialNewLine();\n }\n }\n\n /// \n /// Inserts an empty line as the first line unless it is already.\n /// \n private void InsertInitialNewLine()\n {\n if (lines.Count == 0 || !string.IsNullOrEmpty(lines[0]))\n {\n lines.Insert(0, string.Empty);\n lineBuilderWhitespace = Whitespace;\n }\n }\n\n private void FlushCurrentLine()\n {\n string line = lineBuilder.ToString().TrimEnd();\n if (line.Length > 0)\n {\n AppendWithoutExceedingMaximumLines(lineBuilderWhitespace + line);\n }\n\n lineBuilder.Clear();\n lineBuilderWhitespace = Whitespace;\n }\n\n private void AppendWithoutExceedingMaximumLines(string line)\n {\n if (lines.Count == maxLines)\n {\n lines.Add(string.Empty);\n\n lines.Add(\n $\"(Output has exceeded the maximum of {maxLines} lines. \" +\n $\"Increase {nameof(FormattingOptions)}.{nameof(FormattingOptions.MaxLines)} on {nameof(AssertionScope)} or {nameof(AssertionConfiguration)} to include more lines.)\");\n\n throw new MaxLinesExceededException();\n }\n\n lines.Add(line);\n }\n\n /// \n /// Increases the indentation of every line written into this text block until the returned disposable is disposed.\n /// \n /// \n /// The amount of spacing used for each indentation level is determined by .\n /// \n public IDisposable WithIndentation()\n {\n indentation++;\n\n return new Disposable(() =>\n {\n if (indentation > 0)\n {\n indentation--;\n }\n });\n }\n\n /// \n /// Returns the final textual multi-line representation of the object graph.\n /// \n public override string ToString()\n {\n return string.Join(Environment.NewLine, lines.Concat([lineBuilder.ToString()]));\n }\n\n internal PossibleMultilineFragment KeepOnSingleLineAsLongAsPossible()\n {\n return new PossibleMultilineFragment(this);\n }\n\n private string Whitespace => MakeWhitespace(indentation);\n\n private static string MakeWhitespace(int indent) => new(' ', indent * SpacesPerIndentation);\n\n /// \n /// Write fragments that may be on a single line or span multiple lines,\n /// and this is not known until later parts of the fragment are written.\n /// \n internal record PossibleMultilineFragment\n {\n private readonly FormattedObjectGraph parentGraph;\n private readonly int startingLineBuilderIndex;\n private readonly int startingLineCount;\n\n public PossibleMultilineFragment(FormattedObjectGraph parentGraph)\n {\n this.parentGraph = parentGraph;\n startingLineBuilderIndex = parentGraph.lineBuilder.Length;\n startingLineCount = parentGraph.lines.Count;\n }\n\n /// \n /// Write the fragment at the position the graph was in when this instance was created.\n ///\n /// \n /// If more lines have been added since this instance was created then write the\n /// fragment on a new line, otherwise write it on the same line.\n /// \n /// \n internal void AddStartingLineOrFragment(string fragment)\n {\n if (FormatOnSingleLine)\n {\n parentGraph.lineBuilder.Insert(startingLineBuilderIndex, fragment);\n }\n else\n {\n parentGraph.InsertInitialNewLine();\n parentGraph.lines.Insert(startingLineCount + 1, parentGraph.Whitespace + fragment);\n InsertAtStartOfLine(startingLineCount + 2, MakeWhitespace(1));\n }\n }\n\n private bool FormatOnSingleLine => parentGraph.lines.Count == startingLineCount;\n\n private void InsertAtStartOfLine(int lineIndex, string insertion)\n {\n if (!parentGraph.lines[lineIndex].StartsWith(insertion, StringComparison.Ordinal))\n {\n parentGraph.lines[lineIndex] = parentGraph.lines[lineIndex].Insert(0, insertion);\n }\n }\n\n public void InsertLineOrFragment(string fragment)\n {\n if (FormatOnSingleLine)\n {\n parentGraph.lineBuilder.Insert(startingLineBuilderIndex, fragment);\n }\n else\n {\n parentGraph.lines[startingLineCount] = parentGraph.lines[startingLineCount]\n .Insert(startingLineBuilderIndex, InsertNewLineIntoFragment(fragment));\n }\n }\n\n private string InsertNewLineIntoFragment(string fragment)\n {\n if (StartingLineHasBeenAddedTo())\n {\n return fragment + Environment.NewLine + MakeWhitespace(parentGraph.indentation + 1);\n }\n\n return fragment;\n }\n\n private bool StartingLineHasBeenAddedTo() => parentGraph.lines[startingLineCount].Length > startingLineBuilderIndex;\n\n /// \n /// If more lines have been added since this instance was created then write the\n /// fragment on a new line, otherwise write it on the same line.\n /// \n internal void AddLineOrFragment(string fragment)\n {\n if (FormatOnSingleLine)\n {\n parentGraph.AddFragment(fragment);\n }\n else\n {\n parentGraph.AddFragmentOnNewLine(fragment);\n }\n }\n\n internal void AddFragment(string fragment) => parentGraph.AddFragment(fragment);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ExceptionValueFormatter.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class ExceptionValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is Exception;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((Exception)value).ToString());\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeExactly.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeExactly\n {\n [Fact]\n public void Should_succeed_when_asserting_value_is_exactly_equal_to_the_same_value()\n {\n // Arrange\n DateTimeOffset dateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset sameDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().BeExactly(sameDateTime);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_value_is_exactly_equal_to_the_same_nullable_value()\n {\n // Arrange\n DateTimeOffset dateTime = 4.June(2016).ToDateTimeOffset();\n DateTimeOffset? sameDateTime = 4.June(2016).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().BeExactly(sameDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_value_is_exactly_equal_to_a_different_value()\n {\n // Arrange\n var dateTime = 10.March(2012).WithOffset(1.Hours());\n var otherDateTime = dateTime.ToUniversalTime();\n\n // Act\n Action act = () => dateTime.Should().BeExactly(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dateTime to be exactly <2012-03-09 23:00:00 +0h>*failure message, but it was <2012-03-10 +1h>.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_value_is_exactly_equal_to_a_different_nullable_value()\n {\n // Arrange\n DateTimeOffset dateTime = 10.March(2012).WithOffset(1.Hours());\n DateTimeOffset? otherDateTime = dateTime.ToUniversalTime();\n\n // Act\n Action act = () => dateTime.Should().BeExactly(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dateTime to be exactly <2012-03-09 23:00:00 +0h>*failure message, but it was <2012-03-10 +1h>.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_value_is_exactly_equal_to_the_same_nullable_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset? nullableDateTimeB = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTimeA.Should().BeExactly(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_null_value_exactly_equals_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = null;\n DateTimeOffset? nullableDateTimeB = null;\n\n // Act / Assert\n nullableDateTimeA.Should().BeExactly(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_value_exactly_equals_a_different_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset? nullableDateTimeB = new DateTime(2016, 06, 06).ToDateTimeOffset();\n\n // Act\n Action action = () =>\n nullableDateTimeA.Should().BeExactly(nullableDateTimeB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_null_value_is_exactly_equal_to_another_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n DateTimeOffset expectation = 27.March(2016).ToDateTimeOffset(1.Hours());\n\n // Act\n Action action = () =>\n nullableDateTime.Should().BeExactly(expectation, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateTime to be exactly <2016-03-27 +1h> because we want to test the failure message, but found a DateTimeOffset.\");\n }\n }\n\n public class NotBeExactly\n {\n [Fact]\n public void Should_succeed_when_asserting_value_is_not_exactly_equal_to_a_different_value()\n {\n // Arrange\n DateTimeOffset dateTime = 10.March(2012).WithOffset(1.Hours());\n DateTimeOffset otherDateTime = dateTime.ToUniversalTime();\n\n // Act / Assert\n dateTime.Should().NotBeExactly(otherDateTime);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_value_is_not_exactly_equal_to_a_different_nullable_value()\n {\n // Arrange\n DateTimeOffset dateTime = 10.March(2012).WithOffset(1.Hours());\n DateTimeOffset? otherDateTime = dateTime.ToUniversalTime();\n\n // Act / Assert\n dateTime.Should().NotBeExactly(otherDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_value_is_not_exactly_equal_to_the_same_value()\n {\n // Arrange\n var dateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n var sameDateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n\n // Act\n Action act =\n () => dateTime.Should().NotBeExactly(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dateTime to be exactly <2012-03-10 +1h> because we want to test the failure message, but it was.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_value_is_not_exactly_equal_to_the_same_nullable_value()\n {\n // Arrange\n DateTimeOffset dateTime = new(10.March(2012), 1.Hours());\n DateTimeOffset? sameDateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n\n // Act\n Action act =\n () => dateTime.Should().NotBeExactly(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dateTime to be exactly <2012-03-10 +1h> because we want to test the failure message, but it was.\");\n }\n\n [Fact]\n public void When_time_is_not_at_exactly_20_minutes_before_another_time_it_should_throw()\n {\n // Arrange\n DateTimeOffset target = 1.January(0001).At(12, 55).ToDateTimeOffset();\n DateTimeOffset subject = 1.January(0001).At(12, 36).ToDateTimeOffset();\n\n // Act\n Action act =\n () => subject.Should().BeExactly(TimeSpan.FromMinutes(20)).Before(target, \"{0} minutes is enough\", 20);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <12:36:00 +0h> to be exactly 20m before <12:55:00 +0h> because 20 minutes is enough, but it is behind by 19m.\");\n }\n\n [Fact]\n public void When_time_is_exactly_90_seconds_before_another_time_it_should_not_throw()\n {\n // Arrange\n DateTimeOffset target = 1.January(0001).At(12, 55).ToDateTimeOffset();\n DateTimeOffset subject = 1.January(0001).At(12, 53, 30).ToDateTimeOffset();\n\n // Act / Assert\n subject.Should().BeExactly(TimeSpan.FromSeconds(90)).Before(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_exactly_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 20).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeExactly(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:20 +0h> to be exactly 10s after <00:00:30 +0h>, but it is behind by 10s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_exactly_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 40).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeExactly(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:40 +0h> to be exactly 10s before <00:00:30 +0h>, but it is ahead by 10s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/Int32ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class Int32ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is int;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((int)value).ToString(CultureInfo.InvariantCulture));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeLessThan.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeLessThan\n {\n [Fact]\n public void When_time_is_not_less_than_30s_after_another_time_it_should_throw()\n {\n // Arrange\n var target = 1.January(1).At(12, 0, 30).WithOffset(1.Hours());\n DateTimeOffset subject = target + 30.Seconds();\n\n // Act\n Action act =\n () => subject.Should().BeLessThan(TimeSpan.FromSeconds(30)).After(target, \"{0}s is the max\", 30);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <12:01:00 +1h> to be less than 30s after <12:00:30 +1h> because 30s is the max, but it is ahead by 30s.\");\n }\n\n [Fact]\n public void When_time_is_less_than_30s_after_another_time_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(1.January(1).At(12, 0, 30));\n DateTimeOffset subject = target + 20.Seconds();\n\n // Act / Assert\n subject.Should().BeLessThan(TimeSpan.FromSeconds(30)).After(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_less_than_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 25).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeLessThan(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:25 +0h> to be less than 10s after <00:00:30 +0h>, but it is behind by 5s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_less_than_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 45).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeLessThan(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject <00:00:45 +0h> to be less than 10s before <00:00:30 +0h>, but it is ahead by 15s.\");\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals_with_a_range()\n {\n // Arrange\n DateTimeOffset someDateTimeOffset = new(2022, 9, 25, 13, 48, 42, 0, TimeSpan.Zero);\n\n // Act\n var action = () => someDateTimeOffset.Should().BeLessThan(0.Seconds()).Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Before() or After() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/UWP.Specs/App.xaml.cs", "using Microsoft.VisualStudio.TestPlatform.TestExecutor;\nusing Windows.ApplicationModel;\nusing Windows.ApplicationModel.Activation;\nusing Windows.UI.Xaml;\n\nnamespace UWP.Specs;\n\ninternal sealed partial class App : Application\n{\n public App()\n {\n InitializeComponent();\n Suspending += OnSuspending;\n }\n\n protected override void OnLaunched(LaunchActivatedEventArgs args)\n {\n UnitTestClient.Run(args.Arguments);\n }\n\n private void OnSuspending(object sender, SuspendingEventArgs e) =>\n e.SuspendingOperation.GetDeferral().Complete();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/ExecutionTimeAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Provides methods for asserting that the execution time of an satisfies certain conditions.\n/// \npublic class ExecutionTimeAssertions\n{\n private readonly ExecutionTime execution;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The execution on which time must be asserted.\n public ExecutionTimeAssertions(ExecutionTime executionTime, AssertionChain assertionChain)\n {\n execution = executionTime ?? throw new ArgumentNullException(nameof(executionTime));\n CurrentAssertionChain = assertionChain;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Checks the executing action if it satisfies a condition.\n /// If the execution runs into an exception, then this will rethrow it.\n /// \n /// Condition to check on the current elapsed time.\n /// Polling stops when condition returns the expected result.\n /// The rate at which the condition is re-checked.\n /// The elapsed time. (use this, don't measure twice)\n private (bool isRunning, TimeSpan elapsed) PollUntil(Func condition, bool expectedResult, TimeSpan rate)\n {\n TimeSpan elapsed = execution.ElapsedTime;\n bool isRunning = execution.IsRunning;\n\n while (isRunning)\n {\n if (condition(elapsed) == expectedResult)\n {\n break;\n }\n\n isRunning = !execution.Task.Wait(rate);\n elapsed = execution.ElapsedTime;\n }\n\n if (execution.Exception is not null)\n {\n // rethrow captured exception\n throw execution.Exception;\n }\n\n return (isRunning, elapsed);\n }\n\n /// \n /// Asserts that the execution time of the operation is less than or equal to a specified amount of time.\n /// \n /// \n /// The maximum allowed duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThanOrEqualTo(TimeSpan maxDuration,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration <= maxDuration, expectedResult: false, rate: maxDuration);\n\n CurrentAssertionChain\n .ForCondition(elapsed <= maxDuration)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" +\n execution.ActionDescription.EscapePlaceholders() +\n \" should be less than or equal to {0}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{1}.\",\n maxDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the execution time of the operation is less than a specified amount of time.\n /// \n /// \n /// The maximum allowed duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThan(TimeSpan maxDuration,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration < maxDuration, expectedResult: false, rate: maxDuration);\n\n CurrentAssertionChain\n .ForCondition(elapsed < maxDuration)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" +\n execution.ActionDescription.EscapePlaceholders() + \" should be less than {0}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{1}.\",\n maxDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the execution time of the operation is greater than or equal to a specified amount of time.\n /// \n /// \n /// The minimum allowed duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThanOrEqualTo(TimeSpan minDuration,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration >= minDuration, expectedResult: true, rate: minDuration);\n\n CurrentAssertionChain\n .ForCondition(elapsed >= minDuration)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" +\n execution.ActionDescription.EscapePlaceholders() +\n \" should be greater than or equal to {0}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{1}.\",\n minDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the execution time of the operation is greater than a specified amount of time.\n /// \n /// \n /// The minimum allowed duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThan(TimeSpan minDuration,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration > minDuration, expectedResult: true, rate: minDuration);\n\n CurrentAssertionChain\n .ForCondition(elapsed > minDuration)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" +\n execution.ActionDescription.EscapePlaceholders() + \" should be greater than {0}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{1}.\",\n minDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the execution time of the operation is within the expected duration.\n /// by a specified precision.\n /// \n /// \n /// The expected duration.\n /// \n /// \n /// The maximum amount of time which the execution time may differ from the expected duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(TimeSpan expectedDuration, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n TimeSpan minimumValue = expectedDuration - precision;\n TimeSpan maximumValue = expectedDuration + precision;\n\n // for polling we only use max condition, we don't want poll to stop if\n // elapsed time didn't even get to the acceptable range\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration <= maximumValue, expectedResult: false, rate: maximumValue);\n\n CurrentAssertionChain\n .ForCondition(elapsed >= minimumValue && elapsed <= maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" + execution.ActionDescription.EscapePlaceholders() +\n \" should be within {0} from {1}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{2}.\",\n precision,\n expectedDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\n \"Equals is not part of Awesome Assertions. Did you mean BeLessThanOrEqualTo() or BeGreaterThanOrEqualTo() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/UInt32Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class UInt32Assertions : NumericAssertions\n{\n internal UInt32Assertions(uint value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(uint subject, uint expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n long difference = (long)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeSameDateAs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeSameDateAs\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_be_same_date_as_another_with_the_same_date_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeSameDateAs(expectation);\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_should_be_same_as_another_with_same_date_but_different_time_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31, 11, 15, 11), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeSameDateAs(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_to_be_same_date_as_another_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected the date part of subject to be <2009-12-31>, but found a DateTimeOffset.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_same_date_as_another_but_it_doesnt_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 30), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected the date part of subject to be <2009-12-30>, but it was <2009-12-31>.\");\n }\n\n [Fact]\n public void Can_chain_follow_up_assertions()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeSameDateAs(expectation).And.Be(subject);\n }\n }\n\n public class NotBeSameDateAs\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_be_same_date_as_another_with_the_same_date_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void Can_chain_follow_up_assertions()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(expectation).And.Be(subject);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_should_not_be_same_as_another_with_same_date_but_different_time_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31, 11, 15, 11), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_to_not_be_same_date_as_another_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect the date part of subject to be <2009-12-31>, but found a DateTimeOffset.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_same_date_as_another_but_it_doesnt_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 30), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeSameDateAs(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableUInt32Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableUInt32Assertions : NullableNumericAssertions\n{\n internal NullableUInt32Assertions(uint? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(uint subject, uint expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n long difference = (long)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// Collection assertion specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class Chaining\n {\n [Fact]\n public void Chaining_something_should_do_something()\n {\n // Arrange\n var languages = new[] { \"C#\" };\n\n // Act\n var act = () => languages.Should().ContainSingle()\n .Which.Should().EndWith(\"script\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected languages[0]*\");\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should()\n .HaveCount(3)\n .And\n .HaveElementAt(1, 2)\n .And\n .NotContain(4);\n }\n\n [Fact]\n public void When_the_collection_is_ordered_according_to_the_subsequent_ascending_assertion_it_should_succeed()\n {\n // Arrange\n (int, string)[] collection =\n [\n (1, \"a\"),\n (2, \"b\"),\n (2, \"c\"),\n (3, \"a\")\n ];\n\n // Act / Assert\n collection.Should()\n .BeInAscendingOrder(x => x.Item1)\n .And\n .ThenBeInAscendingOrder(x => x.Item2);\n }\n\n [Fact]\n public void When_the_collection_is_not_ordered_according_to_the_subsequent_ascending_assertion_it_should_fail()\n {\n // Arrange\n (int, string)[] collection =\n [\n (1, \"a\"),\n (2, \"b\"),\n (2, \"c\"),\n (3, \"a\")\n ];\n\n // Act\n Action action = () => collection.Should()\n .BeInAscendingOrder(x => x.Item1)\n .And\n .BeInAscendingOrder(x => x.Item2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection*to be ordered \\\"by Item2\\\"*\");\n }\n\n [Fact]\n public void\n When_the_collection_is_ordered_according_to_the_subsequent_ascending_assertion_with_comparer_it_should_succeed()\n {\n // Arrange\n (int, string)[] collection =\n [\n (1, \"a\"),\n (2, \"B\"),\n (2, \"b\"),\n (3, \"a\")\n ];\n\n // Act / Assert\n collection.Should()\n .BeInAscendingOrder(x => x.Item1)\n .And\n .ThenBeInAscendingOrder(x => x.Item2, StringComparer.InvariantCultureIgnoreCase);\n }\n\n [Fact]\n public void When_the_collection_is_ordered_according_to_the_multiple_subsequent_ascending_assertions_it_should_succeed()\n {\n // Arrange\n (int, string, double)[] collection =\n [\n (1, \"a\", 1.1),\n (2, \"b\", 1.2),\n (2, \"c\", 1.3),\n (3, \"a\", 1.1)\n ];\n\n // Act / Assert\n collection.Should()\n .BeInAscendingOrder(x => x.Item1)\n .And\n .ThenBeInAscendingOrder(x => x.Item2)\n .And\n .ThenBeInAscendingOrder(x => x.Item3);\n }\n\n [Fact]\n public void When_the_collection_is_ordered_according_to_the_subsequent_descending_assertion_it_should_succeed()\n {\n // Arrange\n (int, string)[] collection =\n [\n (3, \"a\"),\n (2, \"c\"),\n (2, \"b\"),\n (1, \"a\")\n ];\n\n // Act / Assert\n collection.Should()\n .BeInDescendingOrder(x => x.Item1)\n .And\n .ThenBeInDescendingOrder(x => x.Item2);\n }\n\n [Fact]\n public void When_the_collection_is_not_ordered_according_to_the_subsequent_descending_assertion_it_should_fail()\n {\n // Arrange\n (int, string)[] collection =\n [\n (3, \"a\"),\n (2, \"c\"),\n (2, \"b\"),\n (1, \"a\")\n ];\n\n // Act\n Action action = () => collection.Should()\n .BeInDescendingOrder(x => x.Item1)\n .And\n .BeInDescendingOrder(x => x.Item2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection*to be ordered \\\"by Item2\\\"*\");\n }\n\n [Fact]\n public void\n When_the_collection_is_ordered_according_to_the_subsequent_descending_assertion_with_comparer_it_should_succeed()\n {\n // Arrange\n (int, string)[] collection =\n [\n (3, \"a\"),\n (2, \"b\"),\n (2, \"B\"),\n (1, \"a\")\n ];\n\n // Act / Assert\n collection.Should()\n .BeInDescendingOrder(x => x.Item1)\n .And\n .ThenBeInDescendingOrder(x => x.Item2, StringComparer.InvariantCultureIgnoreCase);\n }\n\n [Fact]\n public void When_the_collection_is_ordered_according_to_the_multiple_subsequent_descending_assertions_it_should_succeed()\n {\n // Arrange\n (int, string, double)[] collection =\n [\n (3, \"a\", 1.1),\n (2, \"c\", 1.3),\n (2, \"b\", 1.2),\n (1, \"a\", 1.1)\n ];\n\n // Act / Assert\n collection.Should()\n .BeInDescendingOrder(x => x.Item1)\n .And\n .ThenBeInDescendingOrder(x => x.Item2)\n .And\n .ThenBeInDescendingOrder(x => x.Item3);\n }\n\n [Fact]\n public void When_asserting_ordering_by_property_of_a_null_collection_failed_inside_a_scope_then_a_subsequent_assertion_is_not_evaluated()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n collection.Should().BeInAscendingOrder(o => o.Text)\n .And.NotBeEmpty(\"this won't be asserted\");\n }\n };\n\n // AssertText but found .\n act.Should().Throw()\n .WithMessage(\"*Text*found*.\");\n }\n\n [Fact]\n public void When_asserting_ordering_with_given_comparer_of_a_null_collection_failed_inside_a_scope_then_a_subsequent_assertion_is_not_evaluated()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n collection.Should().BeInAscendingOrder(Comparer.Default)\n .And.NotBeEmpty(\"this won't be asserted\");\n }\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*found*.\");\n }\n\n [Fact]\n public void When_asserting_ordering_of_an_unordered_collection_failed_inside_a_scope_then_a_subsequent_assertion_is_not_evaluated()\n {\n // Arrange\n int[] collection = [1, 27, 12];\n\n // Act\n Action action = () =>\n {\n using (new AssertionScope())\n {\n collection.Should().BeInAscendingOrder(\"because numbers are ordered\")\n .And.BeEmpty(\"this won't be asserted\");\n }\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*item at index 1 is in wrong order.\");\n }\n }\n\n private class ByLastCharacterComparer : IComparer\n {\n public int Compare(string x, string y)\n {\n return Nullable.Compare(x?[^1], y?[^1]);\n }\n }\n}\n\ninternal class CountingGenericEnumerable : IEnumerable\n{\n private readonly IEnumerable backingSet;\n\n public CountingGenericEnumerable(IEnumerable backingSet)\n {\n this.backingSet = backingSet;\n GetEnumeratorCallCount = 0;\n }\n\n public int GetEnumeratorCallCount { get; private set; }\n\n public IEnumerator GetEnumerator()\n {\n GetEnumeratorCallCount++;\n return backingSet.GetEnumerator();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n}\n\ninternal class CountingGenericCollection : ICollection\n{\n private readonly ICollection backingSet;\n\n public CountingGenericCollection(ICollection backingSet)\n {\n this.backingSet = backingSet;\n }\n\n public int GetEnumeratorCallCount { get; private set; }\n\n public IEnumerator GetEnumerator()\n {\n GetEnumeratorCallCount++;\n return backingSet.GetEnumerator();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public void Add(TElement item) { throw new NotImplementedException(); }\n\n public void Clear() { throw new NotImplementedException(); }\n\n public bool Contains(TElement item) { throw new NotImplementedException(); }\n\n public void CopyTo(TElement[] array, int arrayIndex) { throw new NotImplementedException(); }\n\n public bool Remove(TElement item) { throw new NotImplementedException(); }\n\n public int GetCountCallCount { get; private set; }\n\n public int Count\n {\n get\n {\n GetCountCallCount++;\n return backingSet.Count;\n }\n }\n\n public bool IsReadOnly { get; private set; }\n}\n\ninternal sealed class TrackingTestEnumerable : IEnumerable\n{\n public TrackingTestEnumerable(params int[] values)\n {\n Enumerator = new TrackingEnumerator(values);\n }\n\n public TrackingEnumerator Enumerator { get; }\n\n public IEnumerator GetEnumerator()\n {\n Enumerator.IncreaseEnumerationCount();\n Enumerator.Reset();\n return Enumerator;\n }\n\n IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n}\n\ninternal sealed class TrackingEnumerator : IEnumerator\n{\n private readonly int[] values;\n private int index;\n\n public TrackingEnumerator(int[] values)\n {\n index = -1;\n\n this.values = values;\n }\n\n public int LoopCount { get; private set; }\n\n public void IncreaseEnumerationCount()\n {\n LoopCount++;\n }\n\n public bool MoveNext()\n {\n index++;\n return index < values.Length;\n }\n\n public void Reset()\n {\n index = -1;\n }\n\n public void Dispose() { }\n\n object IEnumerator.Current => Current;\n\n public int Current => values[index];\n}\n\ninternal class OneTimeEnumerable : IEnumerable\n{\n private readonly T[] items;\n private int enumerations;\n\n public OneTimeEnumerable(params T[] items) => this.items = items;\n\n IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n\n public IEnumerator GetEnumerator()\n {\n if (enumerations++ > 0)\n {\n throw new InvalidOperationException(\"OneTimeEnumerable can be enumerated one time only\");\n }\n\n return items.AsEnumerable().GetEnumerator();\n }\n}\n\ninternal class SomeClass\n{\n public string Text { get; set; }\n\n public int Number { get; set; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XmlNodeAssertionSpecs.cs", "using System;\nusing System.Xml;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XmlNodeAssertionSpecs\n{\n public class BeSameAs\n {\n [Fact]\n public void When_asserting_an_xml_node_is_the_same_as_the_same_xml_node_it_should_succeed()\n {\n // Arrange\n var doc = new XmlDocument();\n\n // Act / Assert\n doc.Should().BeSameAs(doc);\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_same_as_a_different_xml_node_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var otherNode = new XmlDocument();\n otherNode.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeSameAs(otherNode, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theDocument to refer to because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_same_as_a_different_xml_node_it_should_fail_with_descriptive_message_and_truncate_xml()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"Some very long text that should be truncated.\");\n var otherNode = new XmlDocument();\n otherNode.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeSameAs(otherNode, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theDocument to refer to because we want to test the failure message, but found Some very long….\");\n }\n\n [Fact]\n public void When_asserting_the_equality_of_an_xml_node_but_is_null_it_should_throw_appropriately()\n {\n // Arrange\n XmlDocument theDocument = null;\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () => theDocument.Should().BeSameAs(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theDocument to refer to *xml*, but found .\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_asserting_an_xml_node_is_null_and_it_is_it_should_succeed()\n {\n // Arrange\n XmlNode node = null;\n\n // Act / Assert\n node.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_null_but_it_is_not_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\");\n\n // Act\n Action act = () =>\n xmlDoc.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_null_but_it_is_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theDocument to be because we want to test the failure message,\" +\n \" but found .\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_asserting_a_non_null_xml_node_is_not_null_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\");\n\n // Act / Assert\n xmlDoc.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_node_is_not_null_it_should_fail()\n {\n // Arrange\n XmlDocument xmlDoc = null;\n\n // Act\n Action act = () =>\n xmlDoc.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_node_is_not_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n XmlDocument theDocument = null;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theDocument not to be because we want to test the failure message.\");\n }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void When_asserting_an_xml_node_is_equivalent_to_the_same_xml_node_it_should_succeed()\n {\n // Arrange\n var doc = new XmlDocument();\n\n // Act / Assert\n doc.Should().BeEquivalentTo(doc);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_with_other_contents_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected local name of element in theDocument at \\\"/\\\" to be \\\"expected\\\" because we want to test the failure message, but found \\\"subject\\\".\");\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_with_same_contents_it_should_succeed()\n {\n // Arrange\n var xml = \"datadata\";\n\n var subject = new XmlDocument();\n subject.LoadXml(xml);\n var expected = new XmlDocument();\n expected.LoadXml(xml);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_assertion_an_xml_node_is_equivalent_to_a_different_xml_node_with_different_namespace_prefix_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument();\n subject.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_which_differs_only_on_unused_namespace_declaration_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument();\n subject.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_a_different_XmlDocument_which_differs_on_a_child_element_name_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected local name of element in theDocument at \\\"/xml/child\\\" to be \\\"expected\\\" because we want to test the failure message, but found \\\"subject\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_which_differs_on_a_child_element_namespace_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected namespace of element \\\"data\\\" in theDocument at \\\"/xml/child\\\" to be \\\"urn:b\\\" because we want to test the failure message, but found \\\"urn:a\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_contains_an_unexpected_node_type_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"data\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected Element \\\"data\\\" in theDocument at \\\"/xml\\\" because we want to test the failure message, but found content \\\"data\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_contains_extra_elements_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected end of document in theDocument because we want to test the failure message, but found \\\"data\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_lacks_elements_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected \\\"data\\\" in theDocument because we want to test the failure message, but found end of document.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_lacks_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message, but found none.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_has_extra_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect to find attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_has_different_attribute_values_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" to have value \\\"c\\\" because we want to test the failure message, but found \\\"b\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_has_attribute_with_different_namespace_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect to find attribute \\\"ns:a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_has_different_text_contents_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"a\");\n var expected = new XmlDocument();\n expected.LoadXml(\"b\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected content to be \\\"b\\\" in theDocument at \\\"/xml\\\" because we want to test the failure message, but found \\\"a\\\".\");\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_equivalent_to_different_xml_node_with_different_comments_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument();\n subject.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_with_different_insignificant_whitespace_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument { PreserveWhitespace = true };\n\n subject.LoadXml(\"\");\n\n var expected = new XmlDocument { PreserveWhitespace = true };\n\n expected.LoadXml(\"\\n \\n \\r\\n\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_that_contains_an_unsupported_node_it_should_throw_a_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n\n // Act\n Action act = () => theDocument.Should().BeEquivalentTo(theDocument);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"CDATA found at /xml is not supported for equivalency comparison.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_that_isnt_it_should_include_the_right_location_in_the_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () => theDocument.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected attribute \\\"c\\\" in theDocument at \\\"/xml/b\\\" to have value \\\"e\\\", but found \\\"d\\\".\");\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void When_asserting_an_xml_node_is_not_equivalent_to_som_other_xml_node_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument();\n subject.LoadXml(\"a\");\n var unexpected = new XmlDocument();\n unexpected.LoadXml(\"b\");\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(unexpected);\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_not_equivalent_to_same_xml_node_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"a\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(theDocument, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect theDocument to be equivalent because we want to test the failure message, but it is.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/Int64Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class Int64Assertions : NumericAssertions\n{\n internal Int64Assertions(long value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(long subject, long expected)\n {\n if (subject is > 0 and < 10 && expected is > 0 and < 10)\n {\n return null;\n }\n\n decimal difference = (decimal)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/Int32Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class Int32Assertions : NumericAssertions\n{\n internal Int32Assertions(int value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(int subject, int expected)\n {\n if (subject is > 0 and < 10 && expected is > 0 and < 10)\n {\n return null;\n }\n\n long difference = (long)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableInt64Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableInt64Assertions : NullableNumericAssertions\n{\n internal NullableInt64Assertions(long? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(long subject, long expected)\n {\n if (subject is > 0 and < 10 && expected is > 0 and < 10)\n {\n return null;\n }\n\n decimal difference = (decimal)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableInt32Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableInt32Assertions : NullableNumericAssertions\n{\n internal NullableInt32Assertions(int? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(int subject, int expected)\n {\n if (subject is > 0 and < 10 && expected is > 0 and < 10)\n {\n return null;\n }\n\n long difference = (long)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeGreaterThan.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeGreaterThan\n {\n [Fact]\n public void A_float_can_never_be_greater_than_NaN()\n {\n // Arrange\n float? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_another_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_greater_than_NaN()\n {\n // Arrange\n double? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_another_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Theory]\n [InlineData(5, 5)]\n [InlineData(1, 10)]\n [InlineData(0, 5)]\n [InlineData(0, 0)]\n [InlineData(-1, 5)]\n [InlineData(-1, -1)]\n [InlineData(10, 10)]\n public void To_test_the_null_path_for_difference_on_nullable_int(int? subject, int expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_nullable_byte()\n {\n // Arrange\n var value = (byte?)1;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(1);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_non_null_path_for_difference_on_nullable_byte()\n {\n // Arrange\n var value = (byte?)1;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(2);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_nullable_decimal()\n {\n // Arrange\n var value = (decimal?)11.0;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(11M);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_short()\n {\n // Arrange\n var value = (short?)11;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(11);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_nullable_short()\n {\n // Arrange\n var value = (short?)11;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(11);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_nullable_ushort()\n {\n // Arrange\n var value = (ushort?)11;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(11);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5L, 5L)]\n [InlineData(1L, 10L)]\n [InlineData(0L, 5L)]\n [InlineData(0L, 0L)]\n [InlineData(-1L, 5L)]\n [InlineData(-1L, -1L)]\n [InlineData(10L, 10L)]\n public void To_test_the_null_path_for_difference_on_nullable_long(long? subject, long expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/DecimalAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class DecimalAssertions : NumericAssertions\n{\n internal DecimalAssertions(decimal value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(decimal subject, decimal expected)\n {\n try\n {\n decimal difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n catch (OverflowException)\n {\n return null;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableDecimalAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableDecimalAssertions : NullableNumericAssertions\n{\n internal NullableDecimalAssertions(decimal? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(decimal subject, decimal expected)\n {\n try\n {\n decimal difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n catch (OverflowException)\n {\n return null;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeWithin.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeWithin\n {\n [Fact]\n public void When_date_is_not_within_50_hours_before_another_date_it_should_throw()\n {\n // Arrange\n var target = new DateTime(2010, 4, 10, 12, 0, 0);\n DateTime subject = target - 50.Hours() - 1.Seconds();\n\n // Act\n Action act =\n () => subject.Should().BeWithin(TimeSpan.FromHours(50)).Before(target, \"{0} hours is enough\", 50);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2010-04-08 09:59:59> to be within 2d and 2h before <2010-04-10 12:00:00> because 50 hours is enough, but it is behind by 2d, 2h and 1s.\");\n }\n\n [Fact]\n public void When_date_is_exactly_within_1d_before_another_date_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(2010, 4, 10);\n DateTime subject = target - 1.Days();\n\n // Act / Assert\n subject.Should().BeWithin(TimeSpan.FromHours(24)).Before(target);\n }\n\n [Fact]\n public void When_date_is_within_1d_before_another_date_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(2010, 4, 10);\n DateTime subject = target - 23.Hours();\n\n // Act / Assert\n subject.Should().BeWithin(TimeSpan.FromHours(24)).Before(target);\n }\n\n [Fact]\n public void When_a_utc_date_is_within_0s_before_itself_it_should_not_throw()\n {\n // Arrange\n var date = DateTime.UtcNow; // local timezone differs from UTC\n\n // Act / Assert\n date.Should().BeWithin(TimeSpan.Zero).Before(date);\n }\n\n [Fact]\n public void When_a_utc_date_is_within_0s_after_itself_it_should_not_throw()\n {\n // Arrange\n var date = DateTime.UtcNow; // local timezone differs from UTC\n\n // Act / Assert\n date.Should().BeWithin(TimeSpan.Zero).After(date);\n }\n\n [Theory]\n [InlineData(30, 20)] // edge case\n [InlineData(30, 25)]\n public void When_asserting_subject_be_within_10_seconds_after_target_but_subject_is_before_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds);\n var subject = 1.January(0001).At(0, 0, subjectSeconds);\n\n // Act\n Action action = () => subject.Should().BeWithin(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds}> to be within 10s after <00:00:30>, but it is behind by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Theory]\n [InlineData(30, 40)] // edge case\n [InlineData(30, 35)]\n public void When_asserting_subject_be_within_10_seconds_before_target_but_subject_is_after_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds);\n var subject = 1.January(0001).At(0, 0, subjectSeconds);\n\n // Act\n Action action = () => subject.Should().BeWithin(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds}> to be within 10s before <00:00:30>, but it is ahead by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Fact]\n public void Should_throw_because_of_assertion_failure_when_asserting_null_is_within_second_before_specific_date()\n {\n // Arrange\n DateTimeOffset? nullDateTime = null;\n DateTimeOffset target = new(2000, 1, 1, 12, 0, 0, TimeSpan.Zero);\n\n // Act\n Action action = () =>\n nullDateTime.Should()\n .BeWithin(TimeSpan.FromSeconds(1))\n .Before(target);\n\n // Assert\n action.Should().Throw()\n .Which.Message\n .Should().StartWith(\n \"Expected nullDateTime to be within 1s before <2000-01-01 12:00:00 +0h>, but found a DateTime\");\n }\n\n [Fact]\n public void Should_throw_because_of_assertion_failure_when_asserting_null_is_within_second_after_specific_date()\n {\n // Arrange\n DateTimeOffset? nullDateTime = null;\n DateTimeOffset target = new(2000, 1, 1, 12, 0, 0, TimeSpan.Zero);\n\n // Act\n Action action = () =>\n nullDateTime.Should()\n .BeWithin(TimeSpan.FromSeconds(1))\n .After(target);\n\n // Assert\n action.Should().Throw()\n .Which.Message\n .Should().StartWith(\n \"Expected nullDateTime to be within 1s after <2000-01-01 12:00:00 +0h>, but found a DateTime\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/Int16Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class Int16Assertions : NumericAssertions\n{\n internal Int16Assertions(short value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(short subject, short expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableInt16Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableInt16Assertions : NullableNumericAssertions\n{\n internal NullableInt16Assertions(short? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(short subject, short expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/StringValueFormatter.cs", "namespace AwesomeAssertions.Formatting;\n\npublic class StringValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is string;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n string result = $\"\"\"\n \"{value}\"\n \"\"\";\n\n formattedGraph.AddFragment(result);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/FormattingOptionsSpecs.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\n[Collection(\"ConfigurationSpecs\")]\npublic sealed class FormattingOptionsSpecs : IDisposable\n{\n [Fact]\n public void When_global_formatting_settings_are_modified()\n {\n AssertionConfiguration.Current.Formatting.UseLineBreaks = true;\n AssertionConfiguration.Current.Formatting.MaxDepth = 123;\n AssertionConfiguration.Current.Formatting.MaxLines = 33;\n AssertionConfiguration.Current.Formatting.StringPrintLength = 321;\n\n AssertionScope.Current.FormattingOptions.UseLineBreaks.Should().BeTrue();\n AssertionScope.Current.FormattingOptions.MaxDepth.Should().Be(123);\n AssertionScope.Current.FormattingOptions.MaxLines.Should().Be(33);\n AssertionScope.Current.FormattingOptions.StringPrintLength.Should().Be(321);\n }\n\n [Fact]\n public void When_a_custom_formatter_exists_in_any_loaded_assembly_it_should_override_the_default_formatters()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Scan;\n\n var subject = new SomeClassWithCustomFormatter\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(\"Property = SomeValue\", \"it should use my custom formatter\");\n }\n\n [Fact]\n public void When_a_base_class_has_a_custom_formatter_it_should_override_the_default_formatters()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Scan;\n\n var subject = new SomeClassInheritedFromClassWithCustomFormatterLvl1\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(\"Property = SomeValue\", \"it should use my custom formatter\");\n }\n\n [Fact]\n public void When_there_are_multiple_custom_formatters_it_should_select_a_more_specific_one()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Scan;\n\n var subject = new SomeClassInheritedFromClassWithCustomFormatterLvl2\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(\"Property is SomeValue\", \"it should use my custom formatter\");\n }\n\n [Fact]\n public void When_a_base_class_has_multiple_custom_formatters_it_should_work_the_same_as_for_the_base_class()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Scan;\n\n var subject = new SomeClassInheritedFromClassWithCustomFormatterLvl3\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(\"Property is SomeValue\", \"it should use my custom formatter\");\n }\n\n [Fact]\n public void When_no_custom_formatter_exists_in_the_specified_assembly_it_should_use_the_default()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterAssembly = \"AwesomeAssertions\";\n\n var subject = new SomeClassWithCustomFormatter\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(subject.ToString());\n }\n\n [Fact]\n public void When_formatter_scanning_is_disabled_it_should_use_the_default_formatters()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Disabled;\n\n var subject = new SomeClassWithCustomFormatter\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(subject.ToString());\n }\n\n [Fact]\n public void When_no_formatter_scanning_is_configured_it_should_use_the_default_formatters()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Disabled;\n\n var subject = new SomeClassWithCustomFormatter\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(subject.ToString());\n }\n\n public class SomeClassWithCustomFormatter\n {\n public string Property { get; set; }\n\n public override string ToString()\n {\n return \"The value of my property is \" + Property;\n }\n }\n\n public class SomeOtherClassWithCustomFormatter\n {\n [UsedImplicitly]\n public string Property { get; set; }\n\n public override string ToString()\n {\n return \"The value of my property is \" + Property;\n }\n }\n\n public class SomeClassInheritedFromClassWithCustomFormatterLvl1 : SomeClassWithCustomFormatter;\n\n public class SomeClassInheritedFromClassWithCustomFormatterLvl2 : SomeClassInheritedFromClassWithCustomFormatterLvl1;\n\n public class SomeClassInheritedFromClassWithCustomFormatterLvl3 : SomeClassInheritedFromClassWithCustomFormatterLvl2;\n\n public static class CustomFormatter\n {\n [ValueFormatter]\n public static int Bar(SomeClassWithCustomFormatter _)\n {\n return -1;\n }\n\n [ValueFormatter]\n public static void Foo(SomeClassWithCustomFormatter value, FormattedObjectGraph output)\n {\n output.AddFragment(\"Property = \" + value.Property);\n }\n\n [ValueFormatter]\n [SuppressMessage(\"ReSharper\", \"CA1801\")]\n public static void Foo(SomeOtherClassWithCustomFormatter _, FormattedObjectGraph output)\n {\n throw new XunitException(\"Should never be called\");\n }\n\n [ValueFormatter]\n public static void Foo(SomeClassInheritedFromClassWithCustomFormatterLvl2 value, FormattedObjectGraph output)\n {\n output.AddFragment(\"Property is \" + value.Property);\n }\n\n [ValueFormatter]\n public static void Foo2(SomeClassInheritedFromClassWithCustomFormatterLvl2 value, FormattedObjectGraph output)\n {\n output.AddFragment(\"Property is \" + value.Property);\n }\n }\n\n public void Dispose()\n {\n AssertionEngine.ResetToDefaults();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/NumericAssertionsExtensions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Numeric;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Contains a number of extension methods for floating point .\n/// \npublic static class NumericAssertionsExtensions\n{\n #region BeCloseTo\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n sbyte nearbyValue, byte delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n sbyte actualValue = parent.Subject;\n sbyte minValue = (sbyte)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = sbyte.MinValue;\n }\n\n sbyte maxValue = (sbyte)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = sbyte.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue, because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n byte nearbyValue, byte delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n byte actualValue = parent.Subject;\n byte minValue = (byte)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = byte.MinValue;\n }\n\n byte maxValue = (byte)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = byte.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue, nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n short nearbyValue, ushort delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n short actualValue = parent.Subject;\n short minValue = (short)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = short.MinValue;\n }\n\n short maxValue = (short)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = short.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n ushort nearbyValue, ushort delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ushort actualValue = parent.Subject;\n ushort minValue = (ushort)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = ushort.MinValue;\n }\n\n ushort maxValue = (ushort)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = ushort.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n int nearbyValue, uint delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n int actualValue = parent.Subject;\n int minValue = (int)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = int.MinValue;\n }\n\n int maxValue = (int)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = int.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because,\n becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n uint nearbyValue, uint delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n uint actualValue = parent.Subject;\n uint minValue = nearbyValue - delta;\n\n if (minValue > nearbyValue)\n {\n minValue = uint.MinValue;\n }\n\n uint maxValue = nearbyValue + delta;\n\n if (maxValue < nearbyValue)\n {\n maxValue = uint.MaxValue;\n }\n\n FailIfValueOutsideBounds(\n parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n long nearbyValue, ulong delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n long actualValue = parent.Subject;\n long minValue = GetMinValue(nearbyValue, delta);\n long maxValue = GetMaxValue(nearbyValue, delta);\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n ulong nearbyValue, ulong delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ulong actualValue = parent.Subject;\n ulong minValue = nearbyValue - delta;\n\n if (minValue > nearbyValue)\n {\n minValue = ulong.MinValue;\n }\n\n ulong maxValue = nearbyValue + delta;\n\n if (maxValue < nearbyValue)\n {\n maxValue = ulong.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n private static void FailIfValueOutsideBounds(AssertionChain assertionChain, bool valueWithinBounds,\n TValue nearbyValue, TDelta delta, TValue actualValue,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n {\n assertionChain\n .ForCondition(valueWithinBounds)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be within {0} from {1}{reason}, but found {2}.\",\n delta, nearbyValue, actualValue);\n }\n\n #endregion\n\n #region NotBeCloseTo\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n sbyte distantValue, byte delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n sbyte actualValue = parent.Subject;\n sbyte minValue = (sbyte)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = sbyte.MinValue;\n }\n\n sbyte maxValue = (sbyte)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = sbyte.MaxValue;\n }\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n byte distantValue, byte delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n byte actualValue = parent.Subject;\n byte minValue = (byte)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = byte.MinValue;\n }\n\n byte maxValue = (byte)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = byte.MaxValue;\n }\n\n FailIfValueInsideBounds(\n parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n short distantValue, ushort delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n short actualValue = parent.Subject;\n short minValue = (short)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = short.MinValue;\n }\n\n short maxValue = (short)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = short.MaxValue;\n }\n\n FailIfValueInsideBounds(\n parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n ushort distantValue, ushort delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ushort actualValue = parent.Subject;\n ushort minValue = (ushort)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = ushort.MinValue;\n }\n\n ushort maxValue = (ushort)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = ushort.MaxValue;\n }\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n int distantValue, uint delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n int actualValue = parent.Subject;\n int minValue = (int)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = int.MinValue;\n }\n\n int maxValue = (int)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = int.MaxValue;\n }\n\n FailIfValueInsideBounds(\n parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n uint distantValue, uint delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n uint actualValue = parent.Subject;\n uint minValue = distantValue - delta;\n\n if (minValue > distantValue)\n {\n minValue = uint.MinValue;\n }\n\n uint maxValue = distantValue + delta;\n\n if (maxValue < distantValue)\n {\n maxValue = uint.MaxValue;\n }\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n long distantValue, ulong delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n long actualValue = parent.Subject;\n long minValue = GetMinValue(distantValue, delta);\n long maxValue = GetMaxValue(distantValue, delta);\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n ulong distantValue, ulong delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ulong actualValue = parent.Subject;\n ulong minValue = distantValue - delta;\n\n if (minValue > distantValue)\n {\n minValue = ulong.MinValue;\n }\n\n ulong maxValue = distantValue + delta;\n\n if (maxValue < distantValue)\n {\n maxValue = ulong.MaxValue;\n }\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue), distantValue,\n delta,\n actualValue,\n because,\n becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n private static void FailIfValueInsideBounds(\n AssertionChain assertionChain,\n bool valueOutsideBounds,\n TValue distantValue, TDelta delta, TValue actualValue,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n {\n assertionChain\n .ForCondition(valueOutsideBounds)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be within {0} from {1}{reason}, but found {2}.\",\n delta, distantValue, actualValue);\n }\n\n #endregion\n\n #region BeApproximately\n\n /// \n /// Asserts a floating point value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NullableNumericAssertions parent,\n float expectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .\", expectedValue,\n precision);\n\n if (assertion.Succeeded)\n {\n var nonNullableAssertions = new SingleAssertions(parent.Subject.Value, assertion);\n nonNullableAssertions.BeApproximately(expectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a floating point value approximates another value as close as possible.\n /// Does not throw if null subject value approximates null value.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NullableNumericAssertions parent,\n float? expectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null && expectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(expectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was {2}.\", expectedValue, precision,\n parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.BeApproximately(expectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a floating point value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NumericAssertions parent,\n float expectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (float.IsNaN(expectedValue))\n {\n throw new ArgumentException(\"Cannot determine approximation of a float to NaN\", nameof(expectedValue));\n }\n\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (float.IsPositiveInfinity(expectedValue))\n {\n FailIfDifferenceOutsidePrecision(float.IsPositiveInfinity(parent.Subject), parent, expectedValue, precision,\n float.NaN, because, becauseArgs);\n }\n else if (float.IsNegativeInfinity(expectedValue))\n {\n FailIfDifferenceOutsidePrecision(float.IsNegativeInfinity(parent.Subject), parent, expectedValue, precision,\n float.NaN, because, becauseArgs);\n }\n else\n {\n float actualDifference = Math.Abs(expectedValue - parent.Subject);\n\n FailIfDifferenceOutsidePrecision(actualDifference <= precision, parent, expectedValue, precision, actualDifference,\n because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NullableNumericAssertions parent,\n double expectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .\", expectedValue,\n precision);\n\n if (assertion.Succeeded)\n {\n var nonNullableAssertions = new DoubleAssertions(parent.Subject.Value, assertion);\n BeApproximately(nonNullableAssertions, expectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value approximates another value as close as possible.\n /// Does not throw if null subject value approximates null value.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NullableNumericAssertions parent,\n double? expectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null && expectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(expectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was {2}.\", expectedValue, precision,\n parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.BeApproximately(expectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NumericAssertions parent,\n double expectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (double.IsNaN(expectedValue))\n {\n throw new ArgumentException(\"Cannot determine approximation of a double to NaN\", nameof(expectedValue));\n }\n\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (double.IsPositiveInfinity(expectedValue))\n {\n FailIfDifferenceOutsidePrecision(double.IsPositiveInfinity(parent.Subject), parent, expectedValue, precision,\n double.NaN, because, becauseArgs);\n }\n else if (double.IsNegativeInfinity(expectedValue))\n {\n FailIfDifferenceOutsidePrecision(double.IsNegativeInfinity(parent.Subject), parent, expectedValue, precision,\n double.NaN, because, becauseArgs);\n }\n else\n {\n double actualDifference = Math.Abs(expectedValue - parent.Subject);\n\n FailIfDifferenceOutsidePrecision(actualDifference <= precision, parent, expectedValue, precision, actualDifference,\n because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(\n this NullableNumericAssertions parent,\n decimal expectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .\", expectedValue,\n precision);\n\n if (assertion.Succeeded)\n {\n var nonNullableAssertions = new DecimalAssertions(parent.Subject.Value, assertion);\n BeApproximately(nonNullableAssertions, expectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value approximates another value as close as possible.\n /// Does not throw if null subject value approximates null value.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(\n this NullableNumericAssertions parent,\n decimal? expectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null && expectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(expectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was {2}.\", expectedValue, precision,\n parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.BeApproximately(expectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NumericAssertions parent,\n decimal expectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n decimal actualDifference = Math.Abs(expectedValue - parent.Subject);\n\n FailIfDifferenceOutsidePrecision(actualDifference <= precision, parent, expectedValue, precision, actualDifference,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n private static void FailIfDifferenceOutsidePrecision(\n bool differenceWithinPrecision,\n NumericAssertions parent, T expectedValue, T precision, T actualDifference,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where T : struct, IComparable\n {\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(differenceWithinPrecision)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {1} +/- {2}{reason}, but {0} differed by {3}.\",\n parent.Subject, expectedValue, precision, actualDifference);\n }\n\n #endregion\n\n #region NotBeApproximately\n\n /// \n /// Asserts a floating point value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NullableNumericAssertions parent,\n float unexpectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is not null)\n {\n var nonNullableAssertions = new SingleAssertions(parent.Subject.Value, parent.CurrentAssertionChain);\n nonNullableAssertions.NotBeApproximately(unexpectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a floating point value does not approximate another value by a given amount.\n /// Throws if both subject and are null.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NullableNumericAssertions parent,\n float? unexpectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null != unexpectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null && unexpectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not approximate {0} +/- {1}{reason}, but it was {2}.\", unexpectedValue,\n precision, parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.NotBeApproximately(unexpectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a floating point value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NumericAssertions parent,\n float unexpectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (float.IsNaN(unexpectedValue))\n {\n throw new ArgumentException(\"Cannot determine approximation of a float to NaN\", nameof(unexpectedValue));\n }\n\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (float.IsPositiveInfinity(unexpectedValue))\n {\n FailIfDifferenceWithinPrecision(parent, !float.IsPositiveInfinity(parent.Subject), unexpectedValue, precision,\n float.NaN, because, becauseArgs);\n }\n else if (float.IsNegativeInfinity(unexpectedValue))\n {\n FailIfDifferenceWithinPrecision(parent, !float.IsNegativeInfinity(parent.Subject), unexpectedValue, precision,\n float.NaN, because, becauseArgs);\n }\n else\n {\n float actualDifference = Math.Abs(unexpectedValue - parent.Subject);\n\n FailIfDifferenceWithinPrecision(parent, actualDifference > precision, unexpectedValue, precision, actualDifference,\n because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(\n this NullableNumericAssertions parent,\n double unexpectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is not null)\n {\n var nonNullableAssertions = new DoubleAssertions(parent.Subject.Value, parent.CurrentAssertionChain);\n nonNullableAssertions.NotBeApproximately(unexpectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value does not approximate another value by a given amount.\n /// Throws if both subject and are null.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(\n this NullableNumericAssertions parent,\n double? unexpectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null != unexpectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n AssertionChain assertionChain = parent.CurrentAssertionChain;\n\n assertionChain\n .ForCondition(parent.Subject is not null && unexpectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not approximate {0} +/- {1}{reason}, but it was {2}.\", unexpectedValue,\n precision, parent.Subject);\n\n if (assertionChain.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.NotBeApproximately(unexpectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NumericAssertions parent,\n double unexpectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (double.IsNaN(unexpectedValue))\n {\n throw new ArgumentException(\"Cannot determine approximation of a double to NaN\", nameof(unexpectedValue));\n }\n\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (double.IsPositiveInfinity(unexpectedValue))\n {\n FailIfDifferenceWithinPrecision(parent, !double.IsPositiveInfinity(parent.Subject), unexpectedValue, precision,\n double.NaN, because, becauseArgs);\n }\n else if (double.IsNegativeInfinity(unexpectedValue))\n {\n FailIfDifferenceWithinPrecision(parent, !double.IsNegativeInfinity(parent.Subject), unexpectedValue, precision,\n double.NaN, because, becauseArgs);\n }\n else\n {\n double actualDifference = Math.Abs(unexpectedValue - parent.Subject);\n\n FailIfDifferenceWithinPrecision(parent, actualDifference > precision, unexpectedValue, precision, actualDifference,\n because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(\n this NullableNumericAssertions parent,\n decimal unexpectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is not null)\n {\n var nonNullableAssertions = new DecimalAssertions(parent.Subject.Value, parent.CurrentAssertionChain);\n NotBeApproximately(nonNullableAssertions, unexpectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value does not approximate another value by a given amount.\n /// Throws if both subject and are null.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(\n this NullableNumericAssertions parent,\n decimal? unexpectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null != unexpectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null && unexpectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not approximate {0} +/- {1}{reason}, but it was {2}.\", unexpectedValue,\n precision, parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.NotBeApproximately(unexpectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NumericAssertions parent,\n decimal unexpectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n decimal actualDifference = Math.Abs(unexpectedValue - parent.Subject);\n\n FailIfDifferenceWithinPrecision(parent, actualDifference > precision, unexpectedValue, precision, actualDifference,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n private static void FailIfDifferenceWithinPrecision(\n NumericAssertions parent, bool differenceOutsidePrecision,\n T unexpectedValue, T precision, T actualDifference,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where T : struct, IComparable\n {\n parent.CurrentAssertionChain\n .ForCondition(differenceOutsidePrecision)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not approximate {1} +/- {2}{reason}, but {0} only differed by {3}.\",\n parent.Subject, unexpectedValue, precision, actualDifference);\n }\n\n #endregion\n\n #region BeNaN\n\n /// \n /// Asserts that the number is seen as not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeNaN(this NumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n float actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(float.IsNaN(actualValue))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be NaN{reason}, but found {0}.\", actualValue);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is seen as not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeNaN(this NumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n double actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(double.IsNaN(actualValue))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be NaN{reason}, but found {0}.\", actualValue);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is seen as not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeNaN(this NullableNumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n float? actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(actualValue is { } value && float.IsNaN(value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be NaN{reason}, but found {0}.\", actualValue);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is seen as not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeNaN(this NullableNumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n double? actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(actualValue is { } value && double.IsNaN(value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be NaN{reason}, but found {0}.\", actualValue);\n\n return new AndConstraint>(parent);\n }\n\n #endregion\n\n #region NotBeNaN\n\n /// \n /// Asserts that the number is not seen as the special value not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeNaN(this NumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n float actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(!float.IsNaN(actualValue))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be NaN{reason}.\");\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is not seen as the special value not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeNaN(this NumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n double actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(!double.IsNaN(actualValue))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be NaN{reason}.\");\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is not seen as the special value not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeNaN(this NullableNumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n float? actualValue = parent.Subject;\n bool actualValueIsNaN = actualValue is { } value && float.IsNaN(value);\n\n parent.CurrentAssertionChain\n .ForCondition(!actualValueIsNaN)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be NaN{reason}.\");\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is not seen as the special value not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeNaN(this NullableNumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n double? actualValue = parent.Subject;\n bool actualValueIsNaN = actualValue is { } value && double.IsNaN(value);\n\n parent.CurrentAssertionChain\n .ForCondition(!actualValueIsNaN)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be NaN{reason}.\");\n\n return new AndConstraint>(parent);\n }\n\n #endregion\n\n private static long GetMinValue(long value, ulong delta)\n {\n long minValue;\n\n if (delta <= (ulong.MaxValue / 2))\n {\n minValue = value - (long)delta;\n }\n else if (value < 0)\n {\n minValue = long.MinValue;\n }\n else\n {\n minValue = -(long)(delta - (ulong)value);\n }\n\n if (minValue > value)\n {\n minValue = long.MinValue;\n }\n\n return minValue;\n }\n\n private static long GetMaxValue(long value, ulong delta)\n {\n long maxValue;\n\n if (delta <= (ulong.MaxValue / 2))\n {\n maxValue = value + (long)delta;\n }\n else if (value >= 0)\n {\n maxValue = long.MaxValue;\n }\n else\n {\n maxValue = (long)((ulong)value + delta);\n }\n\n if (maxValue < value)\n {\n maxValue = long.MaxValue;\n }\n\n return maxValue;\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/XUnit3.Specs/FrameworkSpecs.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions;\nusing Xunit;\n\nnamespace XUnit3.Specs;\n\npublic class FrameworkSpecs\n{\n [Fact]\n public void When_xunit3_is_used_it_should_throw_xunit_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().GetInterfaces().Select(e => e.Name).Should().Contain(\"IAssertionException\");\n exception.GetType().FullName.Should().Be(\"Xunit.Sdk.XunitException\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/NonGenericAsyncFunctionAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an asynchronous method yields the expected result.\n/// \npublic class NonGenericAsyncFunctionAssertions : AsyncFunctionAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public NonGenericAsyncFunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain)\n : this(subject, extractor, assertionChain, new Clock())\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Initializes a new instance of the class with custom .\n /// \n public NonGenericAsyncFunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain, IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current will complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> CompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n (Task task, TimeSpan remainingTime) = InvokeWithTimer(timeSpan);\n\n assertionChain\n .ForCondition(remainingTime >= TimeSpan.Zero)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(task, remainingTime, _ => Task.CompletedTask);\n\n assertionChain\n .ForCondition(completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not throw any exception.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> NotThrowAsync(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n try\n {\n await Subject!.Invoke();\n }\n catch (Exception exception)\n {\n return NotThrowInternal(exception, because, becauseArgs);\n }\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current stops throwing any exception\n /// after a specified amount of time.\n /// \n /// \n /// The is invoked. If it raises an exception,\n /// the invocation is repeated until it either stops raising any exceptions\n /// or the specified wait time is exceeded.\n /// \n /// \n /// The time after which the should have stopped throwing any exception.\n /// \n /// \n /// The time between subsequent invocations of the .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// or are negative.\n public Task> NotThrowAfterAsync(TimeSpan waitTime, TimeSpan pollInterval,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(waitTime);\n Guard.ThrowIfArgumentIsNegative(pollInterval);\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw any exceptions after {0}{reason}, but found .\", waitTime);\n\n if (assertionChain.Succeeded)\n {\n return AssertionTaskAsync();\n\n async Task> AssertionTaskAsync()\n {\n TimeSpan? invocationEndTime = null;\n Exception exception = null;\n Common.ITimer timer = Clock.StartTimer();\n\n while (invocationEndTime is null || invocationEndTime < waitTime)\n {\n exception = await InvokeWithInterceptionAsync(Subject);\n\n if (exception is null)\n {\n return new AndConstraint(this);\n }\n\n await Clock.DelayAsync(pollInterval, CancellationToken.None);\n invocationEndTime = timer.Elapsed;\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exceptions after {0}{reason}, but found {1}.\", waitTime, exception);\n\n return new AndConstraint(this);\n }\n }\n\n return Task.FromResult(new AndConstraint(this));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/EnumAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class EnumAssertions : EnumAssertions>\n where TEnum : struct, Enum\n{\n public EnumAssertions(TEnum subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class EnumAssertions\n where TEnum : struct, Enum\n where TAssertions : EnumAssertions\n{\n public EnumAssertions(TEnum subject, AssertionChain assertionChain)\n : this((TEnum?)subject, assertionChain)\n {\n }\n\n private protected EnumAssertions(TEnum? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n public TEnum? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TEnum expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject?.Equals(expected) == true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TEnum? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Nullable.Equals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TEnum unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject?.Equals(unexpected) != true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TEnum? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(!Nullable.Equals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current value of is defined inside the enum.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDefined([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the enum} to be defined in {0}{reason}, \", typeof(TEnum), chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(Enum.IsDefined(typeof(TEnum), Subject))\n .FailWith(\"but it is not.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current value of is not defined inside the enum.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDefined([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:the enum} to be defined in {0}{reason}, \", typeof(TEnum), chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(!Enum.IsDefined(typeof(TEnum), Subject))\n .FailWith(\"but it is.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue(decimal expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is { } value && GetValue(value) == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to have value {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue(decimal unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(!(Subject is { } value && GetValue(value) == unexpected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to not have value {0}{reason}, but found {1}.\",\n unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the same numeric value as .\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSameValueAs(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : struct, Enum\n {\n CurrentAssertionChain\n .ForCondition(Subject is { } value && GetValue(value) == GetValue(expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to have same value as {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the same numeric value as .\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSameValueAs(T unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : struct, Enum\n {\n CurrentAssertionChain\n .ForCondition(!(Subject is { } value && GetValue(value) == GetValue(unexpected)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to not have same value as {0}{reason}, but found {1}.\",\n unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the same name as .\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSameNameAs(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : struct, Enum\n {\n CurrentAssertionChain\n .ForCondition(Subject is { } value && GetName(value) == GetName(expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to have same name as {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the same name as .\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSameNameAs(T unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : struct, Enum\n {\n CurrentAssertionChain\n .ForCondition(!(Subject is { } value && GetName(value) == GetName(unexpected)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to not have same name as {0}{reason}, but found {1}.\",\n unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an enum has a specified flag\n /// \n /// The expected flag.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveFlag(TEnum expectedFlag,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject?.HasFlag(expectedFlag) == true)\n .FailWith(\"Expected {context:the enum} to have flag {0}{reason}, but found {1}.\", expectedFlag, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an enum does not have a specified flag\n /// \n /// The unexpected flag.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveFlag(TEnum unexpectedFlag,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject?.HasFlag(unexpectedFlag) != true)\n .FailWith(\"Expected {context:the enum} to not have flag {0}{reason}.\", unexpectedFlag);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the matches the .\n /// \n /// \n /// The predicate which must be satisfied by the .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate, nameof(predicate), \"Cannot match an enum against a predicate.\");\n\n CurrentAssertionChain\n .ForCondition(predicate.Compile()(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to match {1}{reason}, but found {0}.\", Subject, predicate.Body);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params TEnum[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(validValues, nameof(validValues),\n \"Cannot assert that an enum is one of a null list of enums\");\n\n Guard.ThrowIfArgumentIsEmpty(validValues, nameof(validValues),\n \"Cannot assert that an enum is one of an empty list of enums\");\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:the enum} to be one of {0}{reason}, but found \", validValues)\n .Then\n .ForCondition(validValues.Contains(Subject.Value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n private static decimal GetValue(T @enum)\n where T : struct, Enum\n {\n return Convert.ToDecimal(@enum, CultureInfo.InvariantCulture);\n }\n\n private static string GetName(T @enum)\n where T : struct, Enum\n {\n return @enum.ToString();\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.BeAfter.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class BeAfter\n {\n [Fact]\n public void When_asserting_subject_timeonly_is_after_earlier_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 123);\n TimeOnly expectation = new(15, 06, 03, 45);\n\n // Act/Assert\n subject.Should().BeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_after_earlier_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <15:06:03.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_after_later_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <15:06:05.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_after_later_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 05);\n\n // Act/Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_after_the_same_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 145);\n TimeOnly expectation = new(15, 06, 04, 145);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <15:06:04.145>, but found <15:06:04.145>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_after_the_same_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 123);\n TimeOnly expectation = new(15, 06, 04, 123);\n\n // Act/Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_after_earlier_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 07);\n TimeOnly expectation = new(15, 06);\n\n // Act/Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_after_earlier_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <15:06:03.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_after_the_same_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 04);\n\n // Act/Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_after_the_same_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06);\n TimeOnly expectation = new(15, 06);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <15:06:00.000>, but found <15:06:00.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_after_later_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or after <15:06:05.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_after_later_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 05);\n\n // Act/Assert\n subject.Should().NotBeOnOrAfter(expectation);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.BeAfter.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class BeAfter\n {\n [Fact]\n public void When_asserting_subject_dateonly_is_after_earlier_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act/Assert\n subject.Should().BeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_after_earlier_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_after_later_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_after_later_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act/Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_after_the_same_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_after_the_same_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_after_earlier_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act/Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_after_earlier_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_after_the_same_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_after_the_same_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_after_later_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_after_later_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act/Assert\n subject.Should().NotBeOnOrAfter(expectation);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/GuidValueFormatter.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class GuidValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is Guid;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment($\"{{{value}}}\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeAfter.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeAfter\n {\n [Fact]\n public void When_asserting_subject_datetime_is_after_earlier_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act / Assert\n subject.Should().BeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_after_later_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_after_the_same_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04>, but found <2016-06-04>.\");\n }\n }\n\n public class NotBeAfter\n {\n [Fact]\n public void When_asserting_subject_datetime_is_not_after_earlier_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_after_later_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act / Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_after_the_same_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().NotBeAfter(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/XUnitTestFramework.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// Implements the xUnit (version 2 and 3) test framework adapter.\n/// \ninternal class XUnitTestFramework(string assemblyName) : LateBoundTestFramework(loadAssembly: true)\n{\n protected internal override string AssemblyName => assemblyName;\n\n protected override string ExceptionFullName => \"Xunit.Sdk.XunitException\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeOnOrAfter.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeOnOrAfter\n {\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_after_earlier_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act / Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_after_the_same_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_after_later_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or after <2016-06-05>, but found <2016-06-04>.\");\n }\n }\n\n public class NotBeOnOrAfter\n {\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_after_earlier_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_after_the_same_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_after_later_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act / Assert\n subject.Should().NotBeOnOrAfter(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeOnOrBefore.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeOnOrBefore\n {\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_before_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act / Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_before_the_same_date_as_the_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_before_earlier_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().BeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03>, but found <2016-06-04>.\");\n }\n }\n\n public class NotBeOnOrBefore\n {\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_before_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_before_the_same_date_as_the_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_before_earlier_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act / Assert\n subject.Should().NotBeOnOrBefore(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/NullValueFormatter.cs", "namespace AwesomeAssertions.Formatting;\n\npublic class NullValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is null;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(\"\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/SingleAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class SingleAssertions : NumericAssertions\n{\n internal SingleAssertions(float value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override bool IsNaN(float value) => float.IsNaN(value);\n\n private protected override string CalculateDifferenceForFailureMessage(float subject, float expected)\n {\n float difference = subject - expected;\n return difference != 0 ? difference.ToString(\"R\", CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableSingleAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableSingleAssertions : NullableNumericAssertions\n{\n internal NullableSingleAssertions(float? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override bool IsNaN(float value) => float.IsNaN(value);\n\n private protected override string CalculateDifferenceForFailureMessage(float subject, float expected)\n {\n float difference = subject - expected;\n return difference != 0 ? difference.ToString(\"R\", CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableDoubleAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableDoubleAssertions : NullableNumericAssertions\n{\n internal NullableDoubleAssertions(double? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override bool IsNaN(double value) => double.IsNaN(value);\n\n private protected override string CalculateDifferenceForFailureMessage(double subject, double expected)\n {\n double difference = subject - expected;\n return difference != 0 ? difference.ToString(\"R\", CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeOneOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act\n Action act = () => value.Should().BeOneOf(new ClassWithCustomEqualMethod(4), new ClassWithCustomEqualMethod(5));\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be one of {ClassWithCustomEqualMethod(4), ClassWithCustomEqualMethod(5)}, but found ClassWithCustomEqualMethod(3).\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act\n Action act = () =>\n value.Should().BeOneOf([new ClassWithCustomEqualMethod(4), new ClassWithCustomEqualMethod(5)],\n \"because those are the valid values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be one of {ClassWithCustomEqualMethod(4), ClassWithCustomEqualMethod(5)} because those are the valid values, but found ClassWithCustomEqualMethod(3).\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(4);\n\n // Act / Assert\n value.Should().BeOneOf(new ClassWithCustomEqualMethod(4), new ClassWithCustomEqualMethod(5));\n }\n\n [Fact]\n public void An_untyped_value_is_one_of_the_specified_values()\n {\n // Arrange\n object value = new SomeClass(5);\n\n // Act / Assert\n value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)], new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void A_typed_value_is_one_of_the_specified_values()\n {\n // Arrange\n var value = new SomeClass(5);\n\n // Act / Assert\n value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)], new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void An_untyped_value_is_not_one_of_the_specified_values()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)],\n new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to be one of {SomeClass(4), SomeClass(5)}*I said so*SomeClass(3).\");\n }\n\n [Fact]\n public void An_untyped_value_is_not_one_of_no_values()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([], new SomeClassEqualityComparer());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_typed_value_is_not_one_of_the_specified_values()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)],\n new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to be one of {SomeClass(4), SomeClass(5)}*I said so*SomeClass(3).\");\n }\n\n [Fact]\n public void A_typed_value_is_not_one_of_no_values()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([], new SomeClassEqualityComparer());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_typed_value_is_not_the_same_type_as_the_specified_values()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)],\n new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to be one of {SomeClass(4), SomeClass(5)}*I said so*ClassWithCustomEqualMethod(3).\");\n }\n\n [Fact]\n public void An_untyped_value_requires_an_expectation()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf(null, new SomeClassEqualityComparer());\n\n // Assert\n act.Should().Throw().WithParameterName(\"validValues\");\n }\n\n [Fact]\n public void A_typed_value_requires_an_expectation()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf(null, new SomeClassEqualityComparer());\n\n // Assert\n act.Should().Throw().WithParameterName(\"validValues\");\n }\n\n [Fact]\n public void An_untyped_value_requires_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([], comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void A_typed_value_requires_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([], comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act / Assert\n value.Should().BeOneOf(value).And.NotBeNull();\n }\n\n [Fact]\n public void Can_chain_multiple_assertions()\n {\n // Arrange\n var value = new object();\n\n // Act / Assert\n value.Should().BeOneOf([value], new DumbObjectEqualityComparer()).And.NotBeNull();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeAfter.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeAfter\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_after_earlier_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_after_later_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be after <2016-06-05 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_after_the_same_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be after <2016-06-04 +0h>, but it was <2016-06-04 +0h>.\");\n }\n }\n\n public class NotBeAfter\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_after_earlier_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeAfter(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be on or before <2016-06-03 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_after_later_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_after_the_same_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeAfter(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/Guard.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class Guard\n{\n public static void ThrowIfArgumentIsNull([ValidatedNotNull][NoEnumeration] T obj,\n [CallerArgumentExpression(nameof(obj))]\n string paramName = \"\")\n {\n if (obj is null)\n {\n throw new ArgumentNullException(paramName);\n }\n }\n\n public static void ThrowIfArgumentIsNull([ValidatedNotNull][NoEnumeration] T obj, string paramName, string message)\n {\n if (obj is null)\n {\n throw new ArgumentNullException(paramName, message);\n }\n }\n\n public static void ThrowIfArgumentIsNullOrEmpty([ValidatedNotNull] string str,\n [CallerArgumentExpression(nameof(str))]\n string paramName = \"\")\n {\n if (string.IsNullOrEmpty(str))\n {\n ThrowIfArgumentIsNull(str, paramName);\n throw new ArgumentException(\"The value cannot be an empty string.\", paramName);\n }\n }\n\n public static void ThrowIfArgumentIsNullOrEmpty([ValidatedNotNull] string str, string paramName, string message)\n {\n if (string.IsNullOrEmpty(str))\n {\n ThrowIfArgumentIsNull(str, paramName, message);\n throw new ArgumentException(message, paramName);\n }\n }\n\n public static void ThrowIfArgumentIsOutOfRange(T value, [CallerArgumentExpression(nameof(value))] string paramName = \"\")\n where T : Enum\n {\n if (!Enum.IsDefined(typeof(T), value))\n {\n throw new ArgumentOutOfRangeException(paramName);\n }\n }\n\n public static void ThrowIfArgumentContainsNull(IEnumerable values,\n [CallerArgumentExpression(nameof(values))]\n string paramName = \"\")\n {\n if (values.Any(t => t is null))\n {\n throw new ArgumentNullException(paramName, \"Collection contains a null value\");\n }\n }\n\n public static void ThrowIfArgumentIsEmpty(IEnumerable values, string paramName, string message)\n {\n if (!values.Any())\n {\n throw new ArgumentException(message, paramName);\n }\n }\n\n public static void ThrowIfArgumentIsEmpty(string str, string paramName, string message)\n {\n if (str.Length == 0)\n {\n throw new ArgumentException(message, paramName);\n }\n }\n\n public static void ThrowIfArgumentIsNegative(TimeSpan timeSpan,\n [CallerArgumentExpression(nameof(timeSpan))]\n string paramName = \"\")\n {\n if (timeSpan < TimeSpan.Zero)\n {\n throw new ArgumentOutOfRangeException(paramName, \"The value must be non-negative.\");\n }\n }\n\n public static void ThrowIfArgumentIsNegative(float value, [CallerArgumentExpression(nameof(value))] string paramName = \"\")\n {\n if (value < 0)\n {\n throw new ArgumentOutOfRangeException(paramName, \"The value must be non-negative.\");\n }\n }\n\n public static void ThrowIfArgumentIsNegative(double value, [CallerArgumentExpression(nameof(value))] string paramName = \"\")\n {\n if (value < 0)\n {\n throw new ArgumentOutOfRangeException(paramName, \"The value must be non-negative.\");\n }\n }\n\n public static void ThrowIfArgumentIsNegative(decimal value, [CallerArgumentExpression(nameof(value))] string paramName = \"\")\n {\n if (value < 0)\n {\n throw new ArgumentOutOfRangeException(paramName, \"The value must be non-negative.\");\n }\n }\n\n /// \n /// Workaround to make dotnet_code_quality.null_check_validation_methods work\n /// https://github.com/dotnet/roslyn-analyzers/issues/3451#issuecomment-606690452\n /// \n [AttributeUsage(AttributeTargets.Parameter)]\n private sealed class ValidatedNotNullAttribute : Attribute;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringWildcardMatchingStrategy.cs", "using System;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringWildcardMatchingStrategy : IStringComparisonStrategy\n{\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n bool isMatch = IsMatch(subject, expected);\n\n if (isMatch != Negate)\n {\n return;\n }\n\n if (Negate)\n {\n assertionChain.FailWith($\"{ExpectationDescription}but {{1}} matches.\", expected, subject);\n }\n else\n {\n assertionChain.FailWith($\"{ExpectationDescription}but {{1}} does not.\", expected, subject);\n }\n }\n\n private bool IsMatch(string subject, string expected)\n {\n RegexOptions options = IgnoreCase\n ? RegexOptions.IgnoreCase | RegexOptions.CultureInvariant\n : RegexOptions.None;\n\n string input = CleanNewLines(subject);\n string pattern = ConvertWildcardToRegEx(CleanNewLines(expected));\n\n return Regex.IsMatch(input, pattern, options | RegexOptions.Singleline);\n }\n\n private static string ConvertWildcardToRegEx(string wildcardExpression)\n {\n return \"^\"\n + Regex.Escape(wildcardExpression)\n .Replace(\"\\\\*\", \".*\", StringComparison.Ordinal)\n .Replace(\"\\\\?\", \".\", StringComparison.Ordinal)\n + \"$\";\n }\n\n private string CleanNewLines(string input)\n {\n if (IgnoreAllNewlines)\n {\n return input.RemoveNewLines();\n }\n\n if (IgnoreNewlineStyle)\n {\n return input.RemoveNewlineStyle();\n }\n\n return input;\n }\n\n public string ExpectationDescription\n {\n get\n {\n var builder = new StringBuilder();\n\n builder\n .Append(Negate ? \"Did not expect \" : \"Expected \")\n .Append(\"{context:string}\")\n .Append(IgnoreCase ? \" to match the equivalent of\" : \" to match\")\n .Append(\" {0}{reason}, \");\n\n return builder.ToString();\n }\n }\n\n /// \n /// Gets or sets a value indicating whether the subject should not match the pattern.\n /// \n public bool Negate { get; init; }\n\n /// \n /// Gets or sets a value indicating whether the matching process should ignore any casing difference.\n /// \n public bool IgnoreCase { get; init; }\n\n /// \n /// Ignores all newline differences\n /// \n public bool IgnoreAllNewlines { get; init; }\n\n /// \n /// Ignores the difference between environment newline differences\n /// \n public bool IgnoreNewlineStyle { get; init; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeOnOrAfter.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeOnOrAfter\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_after_earlier_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_after_the_same_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_after_later_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or after <2016-06-05 +0h>, but it was <2016-06-04 +0h>.\");\n }\n }\n\n public class NotBeOnOrAfter\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_after_earlier_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_after_the_same_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_after_later_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeOnOrAfter(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeOnOrBefore.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeOnOrBefore\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_before_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_on_or_before_the_same_date_as_the_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_before_earlier_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03 +0h>, but it was <2016-06-04 +0h>.\");\n }\n }\n\n public class NotBeOnOrBefore\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_before_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_on_or_before_the_same_date_as_the_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_before_earlier_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeOnOrBefore(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.BeBefore.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class BeBefore\n {\n [Fact]\n public void When_asserting_subject_is_not_before_earlier_expected_dateonly_it_should_succeed()\n {\n // Arrange\n DateOnly expected = new(2016, 06, 03);\n DateOnly subject = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_before_the_same_dateonly_it_should_throw()\n {\n // Arrange\n DateOnly expected = new(2016, 06, 04);\n DateOnly subject = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_before_the_same_dateonly_it_should_succeed()\n {\n // Arrange\n DateOnly expected = new(2016, 06, 04);\n DateOnly subject = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_before_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act/Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_before_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_dateonly_is_on_or_before_the_same_date_as_the_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_before_the_same_date_as_the_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_before_earlier_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().BeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_before_earlier_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act/Assert\n subject.Should().NotBeOnOrBefore(expectation);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.BeBefore.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class BeBefore\n {\n [Fact]\n public void When_asserting_subject_is_not_before_earlier_expected_timeonly_it_should_succeed()\n {\n // Arrange\n TimeOnly expected = new(15, 06, 03);\n TimeOnly subject = new(15, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_before_the_same_timeonly_it_should_throw()\n {\n // Arrange\n TimeOnly expected = new(15, 06, 04);\n TimeOnly subject = new(15, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <15:06:04.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_before_the_same_timeonly_it_should_succeed()\n {\n // Arrange\n TimeOnly expected = new(15, 06, 04);\n TimeOnly subject = new(15, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_before_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 175);\n TimeOnly expectation = new(15, 06, 05, 23);\n\n // Act/Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_before_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 150);\n TimeOnly expectation = new(15, 06, 05, 340);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <15:06:05.340>, but found <15:06:04.150>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_timeonly_is_on_or_before_the_same_time_as_the_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 04);\n\n // Act/Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_before_the_same_time_as_the_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 123);\n TimeOnly expectation = new(15, 06, 04, 123);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <15:06:04.123>, but found <15:06:04.123>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_before_earlier_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 07);\n TimeOnly expectation = new(15, 06);\n\n // Act\n Action act = () => subject.Should().BeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <15:06:00.000>, but found <15:07:00.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_before_earlier_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 03);\n\n // Act/Assert\n subject.Should().NotBeOnOrBefore(expectation);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/LateBoundTestFramework.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.IO;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Execution;\n\ninternal abstract class LateBoundTestFramework : ITestFramework\n{\n private readonly bool loadAssembly;\n private Func exceptionFactory;\n\n protected LateBoundTestFramework(bool loadAssembly = false)\n {\n this.loadAssembly = loadAssembly;\n exceptionFactory = _ => throw new InvalidOperationException($\"{nameof(IsAvailable)} must be called first.\");\n }\n\n [DoesNotReturn]\n public void Throw(string message) => throw exceptionFactory(message);\n\n public bool IsAvailable\n {\n get\n {\n var assembly = FindExceptionAssembly();\n var exceptionType = assembly?.GetType(ExceptionFullName);\n\n exceptionFactory = exceptionType != null\n ? message => (Exception)Activator.CreateInstance(exceptionType, message)\n : _ => throw new InvalidOperationException($\"{GetType().Name} is not available\");\n\n return exceptionType is not null;\n }\n }\n\n private Assembly FindExceptionAssembly()\n {\n var assembly = Array.Find(AppDomain.CurrentDomain.GetAssemblies(), a => a.GetName().Name == AssemblyName);\n\n if (assembly is null && loadAssembly)\n {\n try\n {\n return Assembly.Load(new AssemblyName(AssemblyName));\n }\n catch (FileNotFoundException)\n {\n return null;\n }\n catch (FileLoadException)\n {\n return null;\n }\n }\n\n return assembly;\n }\n\n protected internal abstract string AssemblyName { get; }\n\n protected abstract string ExceptionFullName { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeXmlSerializable.cs", "using System;\nusing System.Globalization;\nusing System.Xml;\nusing System.Xml.Schema;\nusing System.Xml.Serialization;\nusing AwesomeAssertions.Extensions;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeXmlSerializable\n {\n [Fact]\n public void When_an_object_is_xml_serializable_it_should_succeed()\n {\n // Arrange\n var subject = new XmlSerializableClass\n {\n Name = \"John\",\n Id = 1\n };\n\n // Act / Assert\n subject.Should().BeXmlSerializable();\n }\n\n [Fact]\n public void When_an_object_is_not_xml_serializable_it_should_fail()\n {\n // Arrange\n var subject = new NonPublicClass\n {\n Name = \"John\"\n };\n\n // Act\n Action act = () => subject.Should().BeXmlSerializable(\"we need to store it on {0}\", \"disk\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*to be serializable because we need to store it on disk, but serialization failed with:*NonPublicClass*\");\n }\n\n [Fact]\n public void When_an_object_is_xml_serializable_but_doesnt_restore_all_properties_it_should_fail()\n {\n // Arrange\n var subject = new XmlSerializableClassNotRestoringAllProperties\n {\n Name = \"John\",\n BirthDay = 20.September(1973)\n };\n\n // Act\n Action act = () => subject.Should().BeXmlSerializable();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be serializable, but serialization failed with:*Name*to be*\");\n }\n }\n\n public class XmlSerializableClass\n {\n [UsedImplicitly]\n public string Name { get; set; }\n\n public int Id;\n }\n\n public class XmlSerializableClassNotRestoringAllProperties : IXmlSerializable\n {\n [UsedImplicitly]\n public string Name { get; set; }\n\n public DateTime BirthDay { get; set; }\n\n public XmlSchema GetSchema()\n {\n return null;\n }\n\n public void ReadXml(XmlReader reader)\n {\n BirthDay = DateTime.Parse(reader.ReadElementContentAsString(), CultureInfo.InvariantCulture);\n }\n\n public void WriteXml(XmlWriter writer)\n {\n writer.WriteString(BirthDay.ToString(CultureInfo.InvariantCulture));\n }\n }\n\n internal class NonPublicClass\n {\n [UsedImplicitly]\n public string Name { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ExpressionExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class ExpressionExtensions\n{\n /// \n /// Gets the of an returning a property.\n /// \n /// is .\n public static PropertyInfo GetPropertyInfo(this Expression> expression)\n {\n Guard.ThrowIfArgumentIsNull(expression, nameof(expression), \"Expected a property expression, but found .\");\n\n MemberInfo memberInfo = AttemptToGetMemberInfoFromExpression(expression);\n\n if (memberInfo is not PropertyInfo propertyInfo)\n {\n throw new ArgumentException($\"Cannot use <{expression.Body}> when a property expression is expected.\",\n nameof(expression));\n }\n\n return propertyInfo;\n }\n\n private static MemberInfo AttemptToGetMemberInfoFromExpression(Expression> expression) =>\n (((expression.Body as UnaryExpression)?.Operand ?? expression.Body) as MemberExpression)?.Member;\n\n /// \n /// Gets one or more dotted paths of property names representing the property expression, including the declaring type.\n /// \n /// \n /// E.g. [\"Parent.Child.Sibling.Name\"] or [\"A.Dotted.Path1\", \"A.Dotted.Path2\"].\n /// \n /// is .\n#pragma warning disable MA0051\n public static IEnumerable GetMemberPaths(\n this Expression> expression)\n#pragma warning restore MA0051\n {\n Guard.ThrowIfArgumentIsNull(expression, nameof(expression), \"Expected an expression, but found .\");\n\n string singlePath = null;\n List selectors = [];\n List declaringTypes = [];\n Expression node = expression;\n\n while (node is not null)\n {\n#pragma warning disable IDE0010 // System.Linq.Expressions.ExpressionType has many members we do not care about\n switch (node.NodeType)\n#pragma warning restore IDE0010\n {\n case ExpressionType.Lambda:\n node = ((LambdaExpression)node).Body;\n break;\n\n case ExpressionType.Convert:\n case ExpressionType.ConvertChecked:\n var unaryExpression = (UnaryExpression)node;\n node = unaryExpression.Operand;\n break;\n\n case ExpressionType.MemberAccess:\n var memberExpression = (MemberExpression)node;\n node = memberExpression.Expression;\n\n singlePath = $\"{memberExpression.Member.Name}.{singlePath}\";\n declaringTypes.Add(memberExpression.Member.DeclaringType);\n break;\n\n case ExpressionType.ArrayIndex:\n var binaryExpression = (BinaryExpression)node;\n var indexExpression = (ConstantExpression)binaryExpression.Right;\n node = binaryExpression.Left;\n\n singlePath = $\"[{indexExpression.Value}].{singlePath}\";\n break;\n\n case ExpressionType.Parameter:\n node = null;\n break;\n\n case ExpressionType.Call:\n var methodCallExpression = (MethodCallExpression)node;\n\n if (methodCallExpression is not\n { Method.Name: \"get_Item\", Arguments: [ConstantExpression argumentExpression] })\n {\n throw new ArgumentException(GetUnsupportedExpressionMessage(expression.Body), nameof(expression));\n }\n\n node = methodCallExpression.Object;\n singlePath = $\"[{argumentExpression.Value}].{singlePath}\";\n break;\n case ExpressionType.New:\n var newExpression = (NewExpression)node;\n\n foreach (Expression member in newExpression.Arguments)\n {\n var expr = member.ToString();\n selectors.Add(expr[expr.IndexOf('.', StringComparison.Ordinal)..]);\n declaringTypes.Add(((MemberExpression)member).Member.DeclaringType);\n }\n\n node = null;\n break;\n\n default:\n throw new ArgumentException(GetUnsupportedExpressionMessage(expression.Body), nameof(expression));\n }\n }\n\n Type declaringType = declaringTypes.FirstOrDefault() ?? typeof(TDeclaringType);\n\n if (singlePath is null)\n {\n#if NET47 || NETSTANDARD2_0\n return selectors.Select(selector =>\n GetNewInstance(declaringType, selector)).ToList();\n#else\n return selectors.ConvertAll(selector =>\n GetNewInstance(declaringType, selector));\n#endif\n }\n\n return [GetNewInstance(declaringType, singlePath)];\n }\n\n private static MemberPath GetNewInstance(Type declaringType, string dottedPath) =>\n new(typeof(TReflectedType), declaringType, dottedPath.Trim('.').Replace(\".[\", \"[\", StringComparison.Ordinal));\n\n /// \n /// Gets the first dotted path of property names collected by \n /// from a given property expression, including the declaring type.\n /// \n /// \n /// E.g. Parent.Child.Sibling.Name.\n /// \n /// is .\n public static MemberPath GetMemberPath(\n this Expression> expression)\n {\n return expression.GetMemberPaths().FirstOrDefault() ?? new MemberPath(\"\");\n }\n\n /// \n /// Validates that the expression can be used to construct a .\n /// \n /// is .\n public static void ValidateMemberPath(\n this Expression> expression)\n {\n Guard.ThrowIfArgumentIsNull(expression, nameof(expression), \"Expected an expression, but found .\");\n\n Expression node = expression;\n\n while (node is not null)\n {\n#pragma warning disable IDE0010 // System.Linq.Expressions.ExpressionType has many members we do not care about\n switch (node.NodeType)\n#pragma warning restore IDE0010\n {\n case ExpressionType.Lambda:\n node = ((LambdaExpression)node).Body;\n break;\n\n case ExpressionType.Convert:\n case ExpressionType.ConvertChecked:\n var unaryExpression = (UnaryExpression)node;\n node = unaryExpression.Operand;\n break;\n\n case ExpressionType.MemberAccess:\n var memberExpression = (MemberExpression)node;\n node = memberExpression.Expression;\n\n break;\n\n case ExpressionType.ArrayIndex:\n var binaryExpression = (BinaryExpression)node;\n node = binaryExpression.Left;\n\n break;\n\n case ExpressionType.Parameter:\n node = null;\n break;\n\n case ExpressionType.Call:\n var methodCallExpression = (MethodCallExpression)node;\n\n if (methodCallExpression is not { Method.Name: \"get_Item\", Arguments: [ConstantExpression] })\n {\n throw new ArgumentException(GetUnsupportedExpressionMessage(expression.Body), nameof(expression));\n }\n\n node = methodCallExpression.Object;\n break;\n\n default:\n throw new ArgumentException(GetUnsupportedExpressionMessage(expression.Body), nameof(expression));\n }\n }\n }\n\n private static string GetUnsupportedExpressionMessage(Expression expression) =>\n $\"Expression <{expression}> cannot be used to select a member.\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeAssignableTo.cs", "using System;\nusing AwesomeAssertions.Specs.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeAssignableTo specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeAssignableTo\n {\n [Fact]\n public void When_its_own_type_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_its_base_type_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_implemented_interface_type_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_an_unrelated_type_it_fails()\n {\n // Arrange\n Type someType = typeof(DummyImplementingClass);\n Action act = () => someType.Should().BeAssignableTo(\"we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected someType *.DummyImplementingClass to be assignable to *.DateTime *failure message*\" +\n \", but it is not.\");\n }\n\n [Fact]\n public void When_its_own_type_instance_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo(typeof(DummyImplementingClass));\n }\n\n [Fact]\n public void When_its_base_type_instance_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo(typeof(DummyBaseClass));\n }\n\n [Fact]\n public void When_an_implemented_interface_type_instance_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo(typeof(IDisposable));\n }\n\n [Fact]\n public void When_an_unrelated_type_instance_it_fails()\n {\n // Arrange\n Type someType = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n someType.Should().BeAssignableTo(typeof(DateTime), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*.DummyImplementingClass to be assignable to *.DateTime *failure message*\");\n }\n\n [Fact]\n public void When_constructed_of_open_generic_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(IDummyInterface).Should().BeAssignableTo(typeof(IDummyInterface<>));\n }\n\n [Fact]\n public void When_implementation_of_open_generic_interface_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(ClassWithGenericBaseType).Should().BeAssignableTo(typeof(IDummyInterface<>));\n }\n\n [Fact]\n public void When_derived_of_open_generic_class_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(ClassWithGenericBaseType).Should().BeAssignableTo(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_interface_it_fails()\n {\n // Arrange\n Type someType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n someType.Should().BeAssignableTo(typeof(IDummyInterface<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected someType *.IDummyInterface to be assignable to *.IDummyInterface *failure message*\" +\n \", but it is not.\");\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_type_it_fails()\n {\n // Arrange\n Type someType = typeof(ClassWithAttribute);\n\n Action act = () =>\n someType.Should().BeAssignableTo(typeof(DummyBaseType<>), \"we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\"*.ClassWithAttribute to be assignable to *.DummyBaseType* *failure message*\");\n }\n\n [Fact]\n public void When_asserting_an_open_generic_class_is_assignable_to_itself_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyBaseType<>).Should().BeAssignableTo(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_a_type_to_be_assignable_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act = () =>\n type.Should().BeAssignableTo(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"type\");\n }\n }\n\n public class NotBeAssignableTo\n {\n [Fact]\n public void When_its_own_type_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.DummyImplementingClass *failure message*\");\n }\n\n [Fact]\n public void When_its_base_type_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.DummyBaseClass *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_implemented_interface_type_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.IDisposable *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_an_unrelated_type_and_asserting_not_assignable_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().NotBeAssignableTo();\n }\n\n [Fact]\n public void When_its_own_type_instance_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(DummyImplementingClass), \"we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.DummyImplementingClass *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_its_base_type_instance_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(DummyBaseClass), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.DummyBaseClass *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_an_implemented_interface_type_instance_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(IDisposable), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.IDisposable *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_an_unrelated_type_instance_and_asserting_not_assignable_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().NotBeAssignableTo(typeof(DateTime));\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_interface_and_asserting_not_assignable_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(ClassWithAttribute).Should().NotBeAssignableTo(typeof(IDummyInterface<>));\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_class_and_asserting_not_assignable_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(ClassWithAttribute).Should().NotBeAssignableTo(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_implementation_of_open_generic_interface_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithGenericBaseType);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(IDummyInterface<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithGenericBaseType to not be assignable to *.IDummyInterface *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_derived_from_open_generic_class_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithGenericBaseType);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(IDummyInterface<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithGenericBaseType to not be assignable to *.IDummyInterface *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_type_not_to_be_assignable_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act =\n () => type.Should().NotBeAssignableTo(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"type\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringEndStrategy.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringEndStrategy : IStringComparisonStrategy\n{\n private readonly IEqualityComparer comparer;\n private readonly string predicateDescription;\n\n public StringEndStrategy(IEqualityComparer comparer, string predicateDescription)\n {\n this.comparer = comparer;\n this.predicateDescription = predicateDescription;\n }\n\n public string ExpectationDescription => $\"Expected {{context:string}} to {predicateDescription} \";\n\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n assertionChain\n .ForCondition(subject!.Length >= expected.Length)\n .FailWith($\"{ExpectationDescription}{{0}}{{reason}}, but {{1}} is too short.\", expected, subject);\n\n if (!assertionChain.Succeeded)\n {\n return;\n }\n\n int indexOfMismatch = subject.Substring(subject.Length - expected.Length).IndexOfFirstMismatch(expected, comparer);\n\n if (indexOfMismatch < 0)\n {\n return;\n }\n\n assertionChain.FailWith(\n $\"{ExpectationDescription}{{0}}{{reason}}, but {{1}} differs near {subject.IndexedSegmentAt(indexOfMismatch)}.\",\n expected, subject);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/ExecutionTimeAssertionsSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Specialized;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class ExecutionTimeAssertionsSpecs\n{\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_less_than_or_equal_to_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(610)).Should().BeLessThanOrEqualTo(500.Milliseconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(610)) should be less than or equal to 500ms because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_less_than_or_equal_to_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(0)).Should().BeLessThanOrEqualTo(500.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_less_than_or_equal_to_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(510);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThanOrEqualTo(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than or equal to 100ms, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_less_than_or_equal_to_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeLessThanOrEqualTo(1.Seconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_throw_if_there_is_less_than_or_equal_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThanOrEqualTo(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than or equal to 100ms, but it required more than*\");\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () =>\n subject.ExecutionTimeOf(s => s.AddRange(new object[] { })).Should().BeLessThanOrEqualTo(1.Nanoseconds());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(0))\n .Should().BeLessThanOrEqualTo(500.Milliseconds())\n .And.BeCloseTo(0.Seconds(), 500.Milliseconds());\n }\n }\n\n public class BeLessThan\n {\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_less_than_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(610)).Should().BeLessThan(500.Milliseconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(610)) should be less than 500ms because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_less_than_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(0)).Should().BeLessThan(500.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_less_than_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(510);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than 100ms, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_async_action_is_not_less_than_a_limit_it_should_throw()\n {\n // Arrange\n Func someAction = () => Task.Delay(TimeSpan.FromMilliseconds(150));\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than 100ms, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_less_than_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeLessThan(2.Seconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_async_action_is_less_than_a_limit_it_should_not_throw()\n {\n // Arrange\n Func someAction = () => Task.Delay(TimeSpan.FromMilliseconds(100));\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeLessThan(20.Seconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_throw_if_there_is_less_than_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than 100ms, but it required more than*\");\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.AddRange(new object[] { })).Should().BeLessThan(1.Nanoseconds());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n }\n\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_greater_than_or_equal_to_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(100)).Should().BeGreaterThanOrEqualTo(1.Seconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(100)) should be greater than or equal to 1s because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_greater_than_or_equal_to_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(100)).Should().BeGreaterThanOrEqualTo(50.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_greater_than_or_equal_to_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeGreaterThanOrEqualTo(1.Seconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be greater than or equal to 1s, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_greater_than_or_equal_to_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeGreaterThanOrEqualTo(50.Milliseconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_not_throw_if_there_is_greater_than_or_equal_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeGreaterThanOrEqualTo(100.Milliseconds());\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () =>\n subject.ExecutionTimeOf(s => s.AddRange(new object[] { })).Should().BeGreaterThanOrEqualTo(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(100))\n .Should().BeGreaterThanOrEqualTo(50.Milliseconds())\n .And.BeCloseTo(0.Seconds(), 500.Milliseconds());\n }\n }\n\n public class BeGreaterThan\n {\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_greater_than_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(100)).Should().BeGreaterThan(1.Seconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(100)) should be greater than 1s because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_greater_than_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(200)).Should().BeGreaterThan(100.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_greater_than_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeGreaterThan(1.Seconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be greater than 1s, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_greater_than_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(200);\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeGreaterThan(100.Milliseconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_not_throw_if_there_is_greater_than_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeGreaterThan(100.Milliseconds());\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.AddRange(new object[] { })).Should().BeGreaterThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n }\n\n public class BeCloseTo\n {\n [Fact]\n public void When_asserting_that_execution_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(200)).Should().BeCloseTo(100.Milliseconds(),\n -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_close_to_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(200)).Should().BeCloseTo(100.Milliseconds(),\n 50.Milliseconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(200)) should be within 50ms from 100ms because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_close_to_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n var timer = new TestTimer(() => 210.Milliseconds());\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(0), () => timer).Should().BeCloseTo(200.Milliseconds(),\n 150.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_close_to_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(200);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeCloseTo(100.Milliseconds(), 50.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be within 50ms from 100ms, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_close_to_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => { };\n var timer = new TestTimer(() => 210.Milliseconds());\n\n // Act / Assert\n someAction.ExecutionTime(() => timer).Should().BeCloseTo(200.Milliseconds(), 15.Milliseconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_throw_if_there_is_be_close_to_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeCloseTo(100.Milliseconds(), 50.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be within 50ms from 100ms, but it required*\");\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.AddRange(new object[] { }))\n .Should().BeCloseTo(1.Days(), 50.Milliseconds());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n }\n\n public class ExecutingTime\n {\n [Fact]\n public void When_action_runs_inside_execution_time_exceptions_are_captured_and_rethrown()\n {\n // Arrange\n Action someAction = () => throw new ArgumentException(\"Let's say somebody called the wrong method.\");\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(200.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\"Let's say somebody called the wrong method.\");\n }\n\n [Fact]\n public void Stopwatch_is_not_stopped_after_first_execution_time_assertion()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(300);\n\n // Act / Assert\n // I know it's not meant to be used like this,\n // but since you can, it should still give consistent results\n ExecutionTime time = someAction.ExecutionTime();\n time.Should().BeGreaterThan(100.Milliseconds());\n time.Should().BeGreaterThan(200.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_on_null_execution_it_should_throw()\n {\n // Arrange\n ExecutionTime executionTime = null;\n\n // Act\n Func act = () => new ExecutionTimeAssertions(executionTime, AssertionChain.GetOrCreate());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"executionTime\");\n }\n\n [Fact]\n public void When_asserting_on_null_action_it_should_throw()\n {\n // Arrange\n Action someAction = null;\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n\n [Fact]\n public void When_asserting_on_null_func_it_should_throw()\n {\n // Arrange\n Func someFunc = null;\n\n // Act\n Action act = () => someFunc.ExecutionTime().Should().BeLessThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n\n [Fact]\n public void When_asserting_execution_time_of_null_action_it_should_throw()\n {\n // Arrange\n object subject = null;\n\n // Act\n var act = () => subject.ExecutionTimeOf(s => s.ToString()).Should().BeLessThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"subject\");\n }\n\n [Fact]\n public void When_asserting_execution_time_of_null_it_should_throw()\n {\n // Arrange\n var subject = new object();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(null).Should().BeLessThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var subject = new object();\n\n // Act\n var act = () => subject.ExecutionTimeOf(s => s.ToString()).Should().Equals(1.Seconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Equals is not part of Awesome Assertions. Did you mean BeLessThanOrEqualTo() or BeGreaterThanOrEqualTo() instead?\");\n }\n }\n\n internal class SleepingClass\n {\n public void Sleep(int milliseconds)\n {\n Thread.Sleep(milliseconds);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/ContextDataDictionary.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents a collection of data items that are associated with an .\n/// \ninternal class ContextDataDictionary\n{\n private readonly List items = [];\n\n public IDictionary GetReportable()\n {\n return items.Where(item => item.Reportable).ToDictionary(item => item.Key, item => item.Value);\n }\n\n public string AsStringOrDefault(string key)\n {\n DataItem item = items.SingleOrDefault(i => i.Key == key);\n\n if (item is not null)\n {\n if (item.RequiresFormatting)\n {\n return Formatter.ToString(item.Value);\n }\n\n return item.Value.ToString();\n }\n\n return null;\n }\n\n public void Add(ContextDataDictionary contextDataDictionary)\n {\n foreach (DataItem item in contextDataDictionary.items)\n {\n Add(item.Clone());\n }\n }\n\n public void Add(DataItem item)\n {\n int existingItemIndex = items.FindIndex(i => i.Key == item.Key);\n if (existingItemIndex >= 0)\n {\n items[existingItemIndex] = item;\n }\n else\n {\n items.Add(item);\n }\n }\n\n public class DataItem(string key, object value, bool reportable, bool requiresFormatting)\n {\n public string Key { get; } = key;\n\n public object Value { get; } = value;\n\n public bool Reportable { get; } = reportable;\n\n public bool RequiresFormatting { get; } = requiresFormatting;\n\n public DataItem Clone()\n {\n object clone = Value is ICloneable2 cloneable ? cloneable.Clone() : Value;\n return new DataItem(Key, clone, Reportable, RequiresFormatting);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringValidatorSupportingNull.cs", "using System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringValidatorSupportingNull\n{\n private readonly IStringComparisonStrategy comparisonStrategy;\n private AssertionChain assertionChain;\n\n public StringValidatorSupportingNull(AssertionChain assertionChain, IStringComparisonStrategy comparisonStrategy,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n {\n this.comparisonStrategy = comparisonStrategy;\n this.assertionChain = assertionChain.BecauseOf(because, becauseArgs);\n }\n\n public void Validate(string subject, string expected)\n {\n if (expected?.IsLongOrMultiline() == true ||\n subject?.IsLongOrMultiline() == true)\n {\n assertionChain = assertionChain.UsingLineBreaks;\n }\n\n comparisonStrategy.ValidateAgainstMismatch(assertionChain, subject, expected);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MethodInfoAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class MethodInfoAssertions : MethodBaseAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public MethodInfoAssertions(MethodInfo methodInfo, AssertionChain assertionChain)\n : base(methodInfo, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the selected method is virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected method to be virtual{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(!Subject.IsNonVirtual())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected method {SubjectDescription} to be virtual{{reason}}, but it is not virtual.\"));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected method is not virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected method not to be virtual{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(Subject.IsNonVirtual())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected method {SubjectDescription} not to be virtual{{reason}}, but it is.\"));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected method is async.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAsync([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected method to be async{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(Subject.IsAsync())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected method {SubjectDescription} to be async{{reason}}, but it is not.\"));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected method is not async.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAsync([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected method not to be async{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(!Subject.IsAsync())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected method {SubjectDescription} not to be async{{reason}}, but it is.\"));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected method returns void.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint> ReturnVoid(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the return type of method to be void{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(typeof(void) == Subject!.ReturnType)\n .BecauseOf(because, becauseArgs)\n .FailWith($\"Expected the return type of method {Subject.Name} to be void{{reason}}, but it is {{0}}.\",\n Subject.ReturnType);\n }\n\n return new AndConstraint>(this);\n }\n\n /// \n /// Asserts that the selected method returns .\n /// \n /// The expected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint> Return(Type returnType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(returnType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the return type of method to be {0}{reason}, but {context:member} is .\", returnType);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(returnType == Subject!.ReturnType)\n .BecauseOf(because, becauseArgs)\n .FailWith($\"Expected the return type of method {Subject.Name} to be {{0}}{{reason}}, but it is {{1}}.\",\n returnType, Subject.ReturnType);\n }\n\n return new AndConstraint>(this);\n }\n\n /// \n /// Asserts that the selected method returns .\n /// \n /// The expected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint> Return(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return Return(typeof(TReturn), because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected method does not return void.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint> NotReturnVoid(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the return type of method not to be void{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(typeof(void) != Subject!.ReturnType)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the return type of method \" + Subject.Name + \" not to be void{reason}, but it is.\");\n }\n\n return new AndConstraint>(this);\n }\n\n /// \n /// Asserts that the selected method does not return .\n /// \n /// The unexpected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint> NotReturn(Type returnType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(returnType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n \"Expected the return type of method not to be {0}{reason}, but {context:member} is .\", returnType);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(returnType != Subject!.ReturnType)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected the return type of method \" + Subject.Name + \" not to be {0}{reason}, but it is.\", returnType);\n }\n\n return new AndConstraint>(this);\n }\n\n /// \n /// Asserts that the selected method does not return .\n /// \n /// The unexpected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint> NotReturn(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotReturn(typeof(TReturn), because, becauseArgs);\n }\n\n internal static string GetDescriptionFor(MethodInfo method) =>\n $\"{method.ReturnType.AsFormattableShortType().ToFormattedString()} {method.DeclaringType.ToFormattedString()}.{method.Name}\";\n\n private protected override string SubjectDescription => GetDescriptionFor(Subject);\n\n protected override string Identifier => \"method\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveDay.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveDay\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_day_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 31;\n\n // Act / Assert\n subject.Should().HaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_day_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 30;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 30, but found 31.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_day_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 22, but found a DateTime.\");\n }\n }\n\n public class NotHaveDay\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_day_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 31;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 31, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_day_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 30;\n\n // Act / Assert\n subject.Should().NotHaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_day_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 22, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveMonth.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveMonth\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_month_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 12;\n\n // Act / Assert\n subject.Should().HaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_a_month_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 11;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 11, but found 12.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_month_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 12, but found a DateTime.\");\n }\n }\n\n public class NotHaveMonth\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_month_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_a_month_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 11;\n\n // Act / Assert\n subject.Should().NotHaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_month_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveYear.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveYear\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_year_with_the_same_value_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 2009;\n\n // Act / Assert\n subject.Should().HaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_year_with_a_different_value_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found 2009.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_year_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found .\");\n }\n }\n\n public class NotHaveYear\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_year_with_the_same_value_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 2009;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2009, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_year_with_a_different_value_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 2008;\n\n // Act / Assert\n subject.Should().NotHaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_year_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2008, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateTimeOffsetAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeOffsetAssertions\n : DateTimeOffsetAssertions\n{\n public DateTimeOffsetAssertions(DateTimeOffset? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeOffsetAssertions\n where TAssertions : DateTimeOffsetAssertions\n{\n public DateTimeOffsetAssertions(DateTimeOffset? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public DateTimeOffset? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current represents the same point in time as the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to represent the same point in time as {0}{reason}, \",\n expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject == expected)\n .FailWith(\"but {0} does not.\", Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current represents the same point in time as the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateTimeOffset? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (!expected.HasValue)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.HasValue)\n .FailWith(\"Expected {context:the date and time} to be {reason}, but it was {0}.\", Subject);\n }\n else\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to represent the same point in time as {0}{reason}, \",\n expected, chain => chain.ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject == expected)\n .FailWith(\"but {0} does not.\", Subject));\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not represent the same point in time as the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:the date and time} to represent the same point in time as {0}{reason}, but it did.\",\n unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not represent the same point in time as the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateTimeOffset? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:the date and time} to represent the same point in time as {0}{reason}, but it did.\",\n unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value, including its offset.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeExactly(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be exactly {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.EqualsExact(expected))\n .FailWith(\"but it was {0}.\", Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value, including its offset.\n /// Comparison is performed using \n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeExactly(DateTimeOffset? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (!expected.HasValue)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.HasValue)\n .FailWith(\"Expected {context:the date and time} to be {reason}, but it was {0}.\", Subject);\n }\n else\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be exactly {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.EqualsExact(expected.Value))\n .FailWith(\"but it was {0}.\", Subject));\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not exactly equal to the value.\n /// Comparison is performed using \n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeExactly(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject?.EqualsExact(unexpected) != true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:the date and time} to be exactly {0}{reason}, but it was.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeExactly(DateTimeOffset? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(!((Subject == null && unexpected == null) ||\n (Subject != null && unexpected != null && Subject.Value.EqualsExact(unexpected.Value))))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:the date and time} to be exactly {0}{reason}, but it was.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The expected time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(DateTimeOffset nearbyTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n long distanceToMinInTicks = (nearbyTime - DateTimeOffset.MinValue).Ticks;\n DateTimeOffset minimumValue = nearbyTime.AddTicks(-Math.Min(precision.Ticks, distanceToMinInTicks));\n\n long distanceToMaxInTicks = (DateTimeOffset.MaxValue - nearbyTime).Ticks;\n DateTimeOffset maximumValue = nearbyTime.AddTicks(Math.Min(precision.Ticks, distanceToMaxInTicks));\n\n TimeSpan? difference = (Subject - nearbyTime)?.Duration();\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be within {0} from {1}{reason}\", precision, nearbyTime,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject >= minimumValue && Subject <= maximumValue)\n .FailWith(\", but {0} was off by {1}.\", Subject, difference));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values must differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint NotBeCloseTo(DateTimeOffset distantTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n long distanceToMinInTicks = (distantTime - DateTimeOffset.MinValue).Ticks;\n DateTimeOffset minimumValue = distantTime.AddTicks(-Math.Min(precision.Ticks, distanceToMinInTicks));\n\n long distanceToMaxInTicks = (DateTimeOffset.MaxValue - distantTime).Ticks;\n DateTimeOffset maximumValue = distantTime.AddTicks(Math.Min(precision.Ticks, distanceToMaxInTicks));\n\n CurrentAssertionChain\n .ForCondition(Subject < minimumValue || Subject > maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:the date and time} to be within {0} from {1}{reason}, but it was {2}.\",\n precision,\n distantTime, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is before the specified value.\n /// \n /// The that the current value is expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeBefore(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject < expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be before {0}{reason}, but it was {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not before the specified value.\n /// \n /// The that the current value is not expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeBefore(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or before the specified value.\n /// \n /// The that the current value is expected to be on or before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrBefore(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject <= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be on or before {0}{reason}, but it was {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor before the specified value.\n /// \n /// The that the current value is not expected to be on nor before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrBefore(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is after the specified value.\n /// \n /// The that the current value is expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAfter(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject > expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be after {0}{reason}, but it was {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not after the specified value.\n /// \n /// The that the current value is not expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAfter(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or after the specified value.\n /// \n /// The that the current value is expected to be on or after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrAfter(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject >= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be on or after {0}{reason}, but it was {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor after the specified value.\n /// \n /// The that the current value is expected not to be on nor after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrAfter(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has the year.\n /// \n /// The expected year of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveYear(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the year part of {context:the date} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Year == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Year));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the year.\n /// \n /// The year that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveYear(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the year part of {context:the date} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Year != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the month.\n /// \n /// The expected month of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMonth(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the month part of {context:the date} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Month == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Month));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the month.\n /// \n /// The month that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMonth(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the month part of {context:the date} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Month != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the day.\n /// \n /// The expected day of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveDay(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the day part of {context:the date} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Day == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Day));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the day.\n /// \n /// The day that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveDay(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the day part of {context:the date} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Day != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the hour.\n /// \n /// The expected hour of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveHour(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the hour part of {context:the time} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Hour == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Hour));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the hour.\n /// \n /// The hour that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveHour(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the hour part of {context:the time} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Hour != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the minute.\n /// \n /// The expected minutes of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMinute(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the minute part of {context:the time} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Minute == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Minute));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the minute.\n /// \n /// The minute that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMinute(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the minute part of {context:the time} to be {0}{reason}, \", unexpected,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Minute != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the second.\n /// \n /// The expected seconds of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSecond(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the seconds part of {context:the time} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Second == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Second));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the second.\n /// \n /// The second that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSecond(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the seconds part of {context:the time} to be {0}{reason}, \", unexpected,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Second != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the offset.\n /// \n /// The expected offset of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveOffset(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the offset of {context:the date} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Offset == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Offset));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the offset.\n /// \n /// The offset that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveOffset(TimeSpan unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the offset of {context:the date} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Offset != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// exceeds the specified compared to another .\n /// \n /// \n /// The amount of time that the current should exceed compared to another .\n /// \n public DateTimeOffsetRangeAssertions BeMoreThan(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.MoreThan, timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// is equal to or exceeds the specified compared to another .\n /// \n /// \n /// The amount of time that the current should be equal or exceed compared to\n /// another .\n /// \n public DateTimeOffsetRangeAssertions BeAtLeast(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.AtLeast, timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// differs exactly the specified compared to another .\n /// \n /// \n /// The amount of time that the current should differ exactly compared to another .\n /// \n public DateTimeOffsetRangeAssertions BeExactly(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.Exactly, timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// is within the specified compared to another .\n /// \n /// \n /// The amount of time that the current should be within another .\n /// \n public DateTimeOffsetRangeAssertions BeWithin(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.Within, timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// differs at maximum the specified compared to another .\n /// \n /// \n /// The maximum amount of time that the current should differ compared to another .\n /// \n public DateTimeOffsetRangeAssertions BeLessThan(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.LessThan, timeSpan);\n }\n\n /// \n /// Asserts that the current has the date.\n /// \n /// The expected date portion of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSameDateAs(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n DateTime expectedDate = expected.Date;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the date part of {context:the date and time} to be {0}{reason}, \", expectedDate,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\", expectedDate)\n .Then\n .ForCondition(Subject.Value.Date == expectedDate)\n .FailWith(\"but it was {0}.\", Subject.Value.Date));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not the date.\n /// \n /// The date that is not to match the date portion of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSameDateAs(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n DateTime unexpectedDate = unexpected.Date;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the date part of {context:the date and time} to be {0}{reason}, \", unexpectedDate,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Date != unexpectedDate)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateTimeOffset?[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateTimeOffset[] validValues)\n {\n return BeOneOf(validValues.Cast());\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOneOf(validValues.Cast(), because, becauseArgs);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be one of {0}{reason}, but it was {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/ByteAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class ByteAssertions : NumericAssertions\n{\n internal ByteAssertions(byte value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(byte subject, byte expected)\n {\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveDay.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveDay\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_day_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 31;\n\n // Act / Assert\n subject.Should().HaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_day_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 30;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 30, but it was 31.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_day_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveDay\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_day_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 31;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 31, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_day_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 30;\n\n // Act / Assert\n subject.Should().NotHaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_day_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveMonth.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveMonth\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_month_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 12;\n\n // Act / Assert\n subject.Should().HaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_a_month_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 11;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 11, but it was 12.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_month_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 12, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveMonth\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_month_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_a_month_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 11;\n\n // Act / Assert\n subject.Should().NotHaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_month_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveSecond.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveSecond\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_seconds_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 0;\n\n // Act / Assert\n subject.Should().HaveSecond(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_seconds_with_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 1;\n\n // Act\n Action act = () => subject.Should().HaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 1, but found 0.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_second_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 22, but found a DateTime.\");\n }\n }\n\n public class NotHaveSecond\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_seconds_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 0;\n\n // Act\n Action act = () => subject.Should().NotHaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 0, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_seconds_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 1;\n\n // Act / Assert\n subject.Should().NotHaveSecond(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_second_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 22, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveOffset.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveOffset\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_offset_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.FromHours(7));\n TimeSpan expectation = TimeSpan.FromHours(7);\n\n // Act / Assert\n subject.Should().HaveOffset(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_offset_with_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 10), TimeSpan.Zero);\n TimeSpan expectation = TimeSpan.FromHours(3);\n\n // Act\n Action act = () => subject.Should().HaveOffset(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the offset of subject to be 3h, but it was default.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_offset_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n TimeSpan expectation = TimeSpan.FromHours(3);\n\n // Act\n Action act = () => subject.Should().HaveOffset(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the offset of subject to be 3h, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveOffset\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_offset_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.FromHours(7));\n TimeSpan expectation = TimeSpan.FromHours(7);\n\n // Act\n Action act = () => subject.Should().NotHaveOffset(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the offset of subject to be 7h, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_offset_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n TimeSpan expectation = TimeSpan.FromHours(3);\n\n // Act / Assert\n subject.Should().NotHaveOffset(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_offset_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n TimeSpan expectation = TimeSpan.FromHours(3);\n\n // Act\n Action act = () => subject.Should().NotHaveOffset(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the offset of subject to be 3h, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveMinute.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveMinute\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_minutes_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 59;\n\n // Act / Assert\n subject.Should().HaveMinute(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_minutes_with_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 58;\n\n // Act\n Action act = () => subject.Should().HaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minute part of subject to be 58, but found 59.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_minute_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minute part of subject to be 22, but found a DateTime.\");\n }\n }\n\n public class NotHaveMinute\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_minutes_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 59;\n\n // Act\n Action act = () => subject.Should().NotHaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minute part of subject to be 59, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_minutes_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 58;\n\n // Act / Assert\n subject.Should().NotHaveMinute(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_minute_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minute part of subject to be 22, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveHour.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveHour\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_hour_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 23;\n\n // Act / Assert\n subject.Should().HaveHour(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_hour_with_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hour part of subject to be 22, but found 23.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_hour_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hour part of subject to be 22, but found a DateTime.\");\n }\n }\n\n public class NotHaveHour\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_hour_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 23;\n\n // Act\n Action act = () => subject.Should().NotHaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hour part of subject to be 23, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_hour_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 22;\n\n // Act / Assert\n subject.Should().NotHaveHour(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_hour_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hour part of subject to be 22, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/FunctionExceptionAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n#if NET47\nusing AwesomeAssertions.Specs.Common;\n#endif\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class FunctionExceptionAssertionSpecs\n{\n [Fact]\n public void When_subject_is_null_when_not_expecting_an_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Action testAction = () =>\n {\n using var _ = new AssertionScope();\n action.Should().NotThrow(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n testAction.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_method_throws_an_empty_AggregateException_it_should_fail()\n {\n // Arrange\n Func act = () => throw new AggregateException();\n\n // Act\n Action act2 = () => act.Should().NotThrow();\n\n // Assert\n act2.Should().Throw();\n }\n\n#pragma warning disable xUnit1026 // Theory methods should use all of their parameters\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public void When_the_expected_exception_is_wrapped_it_should_succeed(Func action, T _)\n where T : Exception\n {\n // Act/Assert\n action.Should().Throw();\n }\n\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public void When_the_expected_exception_is_not_wrapped_it_should_fail(Func action, T _)\n where T : Exception\n {\n // Act\n Action act2 = () => action.Should().NotThrow();\n\n // Assert\n act2.Should().Throw();\n }\n#pragma warning restore xUnit1026 // Theory methods should use all of their parameters\n\n public static TheoryData, Exception> AggregateExceptionTestData()\n {\n Func[] tasks =\n [\n AggregateExceptionWithLeftNestedException,\n AggregateExceptionWithRightNestedException\n ];\n\n Exception[] types =\n [\n new AggregateException(),\n new ArgumentNullException(),\n new InvalidOperationException()\n ];\n\n var data = new TheoryData, Exception>();\n\n foreach (var task in tasks)\n {\n foreach (var type in types)\n {\n data.Add(task, type);\n }\n }\n\n data.Add(EmptyAggregateException, new AggregateException());\n\n return data;\n }\n\n private static int AggregateExceptionWithLeftNestedException()\n {\n var ex1 = new AggregateException(new InvalidOperationException());\n var ex2 = new ArgumentNullException();\n var wrapped = new AggregateException(ex1, ex2);\n\n throw wrapped;\n }\n\n private static int AggregateExceptionWithRightNestedException()\n {\n var ex1 = new ArgumentNullException();\n var ex2 = new AggregateException(new InvalidOperationException());\n var wrapped = new AggregateException(ex1, ex2);\n\n throw wrapped;\n }\n\n private static int EmptyAggregateException()\n {\n throw new AggregateException();\n }\n\n [Fact]\n public void Function_Assertions_should_expose_subject()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Func subject = f.Should().Subject;\n\n // Assert\n subject.Should().BeSameAs(f);\n }\n\n #region Throw\n\n [Fact]\n public void When_subject_is_null_when_an_exception_should_be_thrown_it_should_throw()\n {\n // Arrange\n Func act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n act.Should().Throw(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_function_throws_the_expected_exception_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act / Assert\n f.Should().Throw();\n }\n\n [Fact]\n public void When_function_throws_subclass_of_the_expected_exception_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act / Assert\n f.Should().Throw();\n }\n\n [Fact]\n public void When_function_does_not_throw_expected_exception_it_should_fail()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Action action = () => f.Should().Throw();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_not_throw_expected_exception_but_throws_aggregate_it_should_fail_with_inner_exception()\n {\n // Arrange\n Func f = () => throw new AggregateException(new ArgumentNullException());\n\n // Act\n Action action = () => f.Should().Throw();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_throw_expected_exception_but_in_aggregate_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new AggregateException(new ArgumentNullException());\n\n // Act / Assert\n f.Should().Throw();\n }\n\n [Fact]\n public void\n When_function_does_not_throw_expected_exception_but_throws_aggregate_in_aggregate_it_should_fail_with_inner_exception_one_level_deep()\n {\n // Arrange\n Func f = () => throw new AggregateException(new AggregateException(new ArgumentNullException()));\n\n // Act\n Action action = () => f.Should().Throw();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_throw_expected_exception_but_in_aggregate_in_aggregate_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new AggregateException(new AggregateException(new ArgumentNullException()));\n\n // Act / Assert\n f.Should().Throw();\n }\n\n [Fact]\n public void When_function_does_not_throw_any_exception_it_should_fail()\n {\n // Arrange\n Func f = () => 12;\n\n // Act\n Action action = () => f.Should().Throw(\"that's what I {0}\", \"said\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*that's what I said*but*no exception*\");\n }\n\n #endregion\n\n #region ThrowExactly\n\n [Fact]\n public void When_subject_is_null_when_an_exact_exception_should_be_thrown_it_should_throw()\n {\n // Arrange\n Func act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n act.Should().ThrowExactly(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_function_throws_the_expected_exact_exception_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act / Assert\n f.Should().ThrowExactly();\n }\n\n [Fact]\n public void When_function_throws_aggregate_exception_with_inner_exception_of_the_expected_exact_exception_it_should_fail()\n {\n // Arrange\n Func f = () => throw new AggregateException(new ArgumentException());\n\n // Act\n Action action = () => f.Should().ThrowExactly();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*ArgumentException*but*AggregateException*\");\n }\n\n [Fact]\n public void When_function_throws_subclass_of_the_expected_exact_exception_it_should_fail()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Action action = () => f.Should().ThrowExactly();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*ArgumentException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_not_throw_expected_exact_exception_it_should_fail()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Action action = () => f.Should().ThrowExactly();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_not_throw_any_exception_when_expected_exact_it_should_fail()\n {\n // Arrange\n Func f = () => 12;\n\n // Act\n Action action = () => f.Should().ThrowExactly(\"that's what I {0}\", \"said\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*that's what I said*but*no exception*\");\n }\n\n #endregion\n\n #region NotThrow\n\n [Fact]\n public void When_subject_is_null_when_an_exception_should_not_be_thrown_it_should_throw()\n {\n // Arrange\n Func act = null;\n\n // Act\n Action action = () => act.Should().NotThrow(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public void When_subject_is_null_when_a_generic_exception_should_not_be_thrown_it_should_throw()\n {\n // Arrange\n Func act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n act.Should().NotThrow(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_function_does_not_throw_exception_and_that_was_expected_it_should_succeed_then_continue_assertion()\n {\n // Arrange\n Func f = () => 12;\n\n // Act / Assert\n f.Should().NotThrow().Which.Should().Be(12);\n }\n\n [Fact]\n public void When_function_throw_exception_and_that_was_not_expected_it_should_fail()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Action action = () => f.Should().NotThrow(\"that's what he {0}\", \"told me\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*no*exception*that's what he told me*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_throw_aggregate_exception_and_that_was_not_expected_it_should_fail_with_inner_exception_in_message()\n {\n // Arrange\n Func f = () => throw new AggregateException(new ArgumentNullException());\n\n // Act\n Action action = () => f.Should().NotThrow(\"that's what he {0}\", \"told me\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*no*exception*that's what he told me*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void\n When_function_throw_aggregate_in_aggregate_exception_and_that_was_not_expected_it_should_fail_with_most_inner_exception_in_message()\n {\n // Arrange\n Func f = () => throw new AggregateException(new AggregateException(new ArgumentNullException()));\n\n // Act\n Action action = () => f.Should().NotThrow(\"that's what he {0}\", \"told me\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*no*exception*that's what he told me*but*ArgumentNullException*\");\n }\n\n #endregion\n\n #region NotThrowAfter\n\n [Fact]\n public void When_subject_is_null_it_should_throw()\n {\n // Arrange\n var waitTime = 0.Milliseconds();\n var pollInterval = 0.Milliseconds();\n Func action = null;\n\n // Act\n Action testAction = () =>\n {\n using var _ = new AssertionScope();\n action.Should().NotThrowAfter(waitTime, pollInterval, \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n testAction.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_wait_time_is_negative_it_should_throw()\n {\n // Arrange\n var waitTime = -1.Milliseconds();\n var pollInterval = 10.Milliseconds();\n Func someFunc = () => 0;\n\n // Act\n Action action = () =>\n someFunc.Should().NotThrowAfter(waitTime, pollInterval);\n\n // Assert\n action.Should().Throw()\n .WithParameterName(\"waitTime\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_poll_interval_is_negative_it_should_throw()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = -1.Milliseconds();\n Func someAction = () => 0;\n\n // Act\n Action action = () =>\n someAction.Should().NotThrowAfter(waitTime, pollInterval);\n\n // Assert\n action.Should().Throw()\n .WithParameterName(\"pollInterval\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_but_it_was_it_should_throw()\n {\n // Arrange\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n Func throwLongerThanWaitTime = () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n return 0;\n };\n\n // Act\n Action action = () =>\n throwLongerThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect any exceptions after 100ms because we passed valid arguments*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_and_none_was_it_should_not_throw()\n {\n // Arrange\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n Func throwShorterThanWaitTime = () =>\n {\n if (timer.Elapsed <= waitTime.Divide(2))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n return 0;\n };\n\n // Act\n throwShorterThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval);\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_the_func_result_should_be_returned()\n {\n // Arrange\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n Func throwShorterThanWaitTime = () =>\n {\n if (timer.Elapsed <= waitTime.Divide(2))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n return 42;\n };\n\n // Act\n Action act = () => throwShorterThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval)\n .Which.Should().Be(43);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected throwShorterThanWaitTime.Result to be 43*\");\n }\n\n [Fact]\n public void When_an_assertion_fails_on_NotThrowAfter_succeeding_message_should_be_included()\n {\n // Arrange\n var waitTime = TimeSpan.Zero;\n var pollInterval = TimeSpan.Zero;\n Func throwingFunction = () => throw new Exception();\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n throwingFunction.Should().NotThrowAfter(waitTime, pollInterval)\n .And.BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Did not expect any exceptions after*\");\n }\n\n #endregion\n\n #region NotThrow\n\n [Fact]\n public void\n When_function_does_not_throw_at_all_when_some_particular_exception_was_not_expected_it_should_succeed_but_then_cannot_continue_assertion()\n {\n // Arrange\n Func f = () => 12;\n\n // Act / Assert\n f.Should().NotThrow();\n }\n\n [Fact]\n public void When_function_does_throw_exception_and_that_exception_was_not_expected_it_should_fail()\n {\n // Arrange\n Func f = () => throw new InvalidOperationException(\"custom message\");\n\n // Act\n Action action = () => f.Should().NotThrow(\"it was so {0}\", \"fast\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"*Did not expect System.InvalidOperationException because it was so fast, but found System.InvalidOperationException: custom message*\");\n }\n\n [Fact]\n public void When_function_throw_one_exception_but_other_was_not_expected_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n f.Should().NotThrow();\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableByteAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableByteAssertions : NullableNumericAssertions\n{\n internal NullableByteAssertions(byte? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(byte subject, byte expected)\n {\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveYear.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveYear\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_year_with_the_same_value_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 06, 04), TimeSpan.Zero);\n int expectation = 2009;\n\n // Act / Assert\n subject.Should().HaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_year_with_a_different_value_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 06, 04), TimeSpan.Zero);\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but it was 2009.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_year_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveYear\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_year_with_the_same_value_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 06, 04), TimeSpan.Zero);\n int expectation = 2009;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2009, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_year_with_a_different_value_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 06, 04), TimeSpan.Zero);\n int expectation = 2008;\n\n // Act / Assert\n subject.Should().NotHaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_year_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2008, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.HaveHours.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class HaveHours\n {\n [Fact]\n public void When_asserting_subject_timeonly_should_have_hours_with_the_same_value_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 15;\n\n // Act/Assert\n subject.Should().HaveHours(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_hours_with_the_same_value_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 15;\n\n // Act\n Action act = () => subject.Should().NotHaveHours(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hours part of subject to be 15, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_have_hours_with_a_different_value_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 14;\n\n // Act\n Action act = () => subject.Should().HaveHours(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hours part of subject to be 14, but found 15.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_hours_with_a_different_value_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(21, 12, 31);\n const int expectation = 23;\n\n // Act/Assert\n subject.Should().NotHaveHours(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_have_hours_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 21;\n\n // Act\n Action act = () => subject.Should().HaveHours(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hours part of subject to be 21, but found .\");\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_not_have_hours_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 19;\n\n // Act\n Action act = () => subject.Should().NotHaveHours(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hours part of subject to be 19, but found a TimeOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/SByteAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class SByteAssertions : NumericAssertions\n{\n internal SByteAssertions(sbyte value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(sbyte subject, sbyte expected)\n {\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateTimeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeAssertions : DateTimeAssertions\n{\n public DateTimeAssertions(DateTime? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeAssertions\n where TAssertions : DateTimeAssertions\n{\n public DateTimeAssertions(DateTime? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public DateTime? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateTime expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateTime? expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateTime? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The expected time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(DateTime nearbyTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n long distanceToMinInTicks = (nearbyTime - DateTime.MinValue).Ticks;\n DateTime minimumValue = nearbyTime.AddTicks(-Math.Min(precision.Ticks, distanceToMinInTicks));\n\n long distanceToMaxInTicks = (DateTime.MaxValue - nearbyTime).Ticks;\n DateTime maximumValue = nearbyTime.AddTicks(Math.Min(precision.Ticks, distanceToMaxInTicks));\n\n TimeSpan? difference = (Subject - nearbyTime)?.Duration();\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be within {0} from {1}{reason}\", precision, nearbyTime,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject >= minimumValue && Subject <= maximumValue)\n .FailWith(\", but {0} was off by {1}.\", Subject, difference));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values must differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint NotBeCloseTo(DateTime distantTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n long distanceToMinInTicks = (distantTime - DateTime.MinValue).Ticks;\n DateTime minimumValue = distantTime.AddTicks(-Math.Min(precision.Ticks, distanceToMinInTicks));\n\n long distanceToMaxInTicks = (DateTime.MaxValue - distantTime).Ticks;\n DateTime maximumValue = distantTime.AddTicks(Math.Min(precision.Ticks, distanceToMaxInTicks));\n\n CurrentAssertionChain\n .ForCondition(Subject < minimumValue || Subject > maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:the date and time} to be within {0} from {1}{reason}, but it was {2}.\",\n precision,\n distantTime, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is before the specified value.\n /// \n /// The that the current value is expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeBefore(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject < expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not before the specified value.\n /// \n /// The that the current value is not expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeBefore(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or before the specified value.\n /// \n /// The that the current value is expected to be on or before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrBefore(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject <= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be on or before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor before the specified value.\n /// \n /// The that the current value is not expected to be on nor before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrBefore(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is after the specified value.\n /// \n /// The that the current value is expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAfter(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject > expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not after the specified value.\n /// \n /// The that the current value is not expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAfter(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or after the specified value.\n /// \n /// The that the current value is expected to be on or after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrAfter(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject >= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be on or after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor after the specified value.\n /// \n /// The that the current value is expected not to be on nor after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrAfter(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has the year.\n /// \n /// The expected year of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveYear(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the year part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject.Value.Year == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Year));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the year.\n /// \n /// The year that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveYear(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.HasValue)\n .FailWith(\"Did not expect the year part of {context:the date} to be {0}{reason}, but found a DateTime.\",\n unexpected)\n .Then\n .ForCondition(Subject.Value.Year != unexpected)\n .FailWith(\"Did not expect the year part of {context:the date} to be {0}{reason}, but it was.\", unexpected,\n Subject.Value.Year);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the month.\n /// \n /// The expected month of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMonth(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the month part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Month == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Month));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the month.\n /// \n /// The month that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMonth(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the month part of {context:the date} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Month != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the day.\n /// \n /// The expected day of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveDay(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the day part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Day == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Day));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the day.\n /// \n /// The day that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveDay(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the day part of {context:the date} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Day != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the hour.\n /// \n /// The expected hour of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveHour(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the hour part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Hour == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Hour));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the hour.\n /// \n /// The hour that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveHour(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the hour part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\", unexpected)\n .Then\n .ForCondition(Subject.Value.Hour != unexpected)\n .FailWith(\", but it was.\", unexpected, Subject.Value.Hour));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the minute.\n /// \n /// The expected minutes of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMinute(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the minute part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Minute == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Minute));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the minute.\n /// \n /// The minute that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMinute(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the minute part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\", unexpected)\n .Then\n .ForCondition(Subject.Value.Minute != unexpected)\n .FailWith(\", but it was.\", unexpected, Subject.Value.Minute));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the second.\n /// \n /// The expected seconds of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSecond(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the seconds part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Second == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Second));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the second.\n /// \n /// The second that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSecond(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the seconds part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Second != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// exceeds the specified compared to another .\n /// \n /// \n /// The amount of time that the current should exceed compared to another .\n /// \n public DateTimeRangeAssertions BeMoreThan(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.MoreThan,\n timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// is equal to or exceeds the specified compared to another .\n /// \n /// \n /// The amount of time that the current should be equal or exceed compared to\n /// another .\n /// \n public DateTimeRangeAssertions BeAtLeast(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.AtLeast,\n timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// differs exactly the specified compared to another .\n /// \n /// \n /// The amount of time that the current should differ exactly compared to another .\n /// \n public DateTimeRangeAssertions BeExactly(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.Exactly,\n timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// is within the specified compared to another .\n /// \n /// \n /// The amount of time that the current should be within another .\n /// \n public DateTimeRangeAssertions BeWithin(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.Within,\n timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// differs at maximum the specified compared to another .\n /// \n /// \n /// The maximum amount of time that the current should differ compared to another .\n /// \n public DateTimeRangeAssertions BeLessThan(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.LessThan,\n timeSpan);\n }\n\n /// \n /// Asserts that the current has the date.\n /// \n /// The expected date portion of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSameDateAs(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n DateTime expectedDate = expected.Date;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the date part of {context:the date and time} to be {0}{reason}\", expectedDate,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\", expectedDate)\n .Then\n .ForCondition(Subject.Value.Date == expectedDate)\n .FailWith(\", but found {1}.\", expectedDate, Subject.Value));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not the date.\n /// \n /// The date that is not to match the date portion of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSameDateAs(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n DateTime unexpectedDate = unexpected.Date;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the date part of {context:the date and time} to be {0}{reason}\", unexpectedDate,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Date != unexpectedDate)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateTime?[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateTime[] validValues)\n {\n return BeOneOf(validValues.Cast());\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOneOf(validValues.Cast(), because, becauseArgs);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the represents a value in the .\n /// \n /// \n /// The expected that the current value must represent.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeIn(DateTimeKind expectedKind,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be in \" + expectedKind + \"{reason}\", chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Kind == expectedKind)\n .FailWith(\", but found \" + Subject.Value.Kind + \".\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the does not represent a value in a specific kind.\n /// \n /// \n /// The that the current value should not represent.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeIn(DateTimeKind unexpectedKind,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:the date and time} to be in \" + unexpectedKind + \"{reason}\", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(subject => subject.GetValueOrDefault().Kind != unexpectedKind)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.HaveSeconds.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class HaveSeconds\n {\n [Fact]\n public void When_asserting_subject_timeonly_should_have_seconds_with_the_same_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(14, 12, 31);\n const int expectation = 31;\n\n // Act/Assert\n subject.Should().HaveSeconds(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_seconds_with_the_same_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(14, 12, 31);\n const int expectation = 31;\n\n // Act\n Action act = () => subject.Should().NotHaveSeconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 31, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_have_seconds_with_a_different_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 30;\n\n // Act\n Action act = () => subject.Should().HaveSeconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 30, but found 31.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_seconds_with_a_different_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 30;\n\n // Act/Assert\n subject.Should().NotHaveSeconds(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_have_seconds_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveSeconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 22, but found a TimeOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_not_have_seconds_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveSeconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 22, but found a TimeOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveSecond.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveSecond\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_seconds_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 0;\n\n // Act / Assert\n subject.Should().HaveSecond(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_seconds_with_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 1;\n\n // Act\n Action act = () => subject.Should().HaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 1, but it was 0.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_second_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveSecond\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_seconds_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 0;\n\n // Act\n Action act = () => subject.Should().NotHaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 0, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_seconds_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 1;\n\n // Act / Assert\n subject.Should().NotHaveSecond(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_second_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.HaveMinutes.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class HaveMinutes\n {\n [Fact]\n public void When_asserting_subject_timeonly_should_have_minutes_with_the_same_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(21, 12, 31);\n const int expectation = 12;\n\n // Act/Assert\n subject.Should().HaveMinutes(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_minutes_with_the_same_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(21, 12, 31);\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMinutes(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minutes part of subject to be 12, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_have_a_minute_with_a_different_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 11;\n\n // Act\n Action act = () => subject.Should().HaveMinutes(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minutes part of subject to be 11, but found 12.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_a_minute_with_a_different_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 11;\n\n // Act/Assert\n subject.Should().NotHaveMinutes(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_have_minutes_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMinutes(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minutes part of subject to be 12, but found a TimeOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_not_have_minutes_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMinutes(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minutes part of subject to be 12, but found a TimeOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.HaveDay.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class HaveDay\n {\n [Fact]\n public void When_asserting_subject_dateonly_should_have_day_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 31;\n\n // Act/Assert\n subject.Should().HaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_day_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 31;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 31, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_have_day_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 30;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 30, but found 31.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_day_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 30;\n\n // Act/Assert\n subject.Should().NotHaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_have_day_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 22, but found a DateOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_not_have_day_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 22, but found a DateOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveHour.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveHour\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_hour_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 23;\n\n // Act / Assert\n subject.Should().HaveHour(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_hour_with_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hour part of subject to be 22, but it was 23.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_hour_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hour part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveHour\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_hour_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 23;\n\n // Act\n Action act = () => subject.Should().NotHaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hour part of subject to be 23, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_hour_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 22;\n\n // Act / Assert\n subject.Should().NotHaveHour(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_hour_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hour part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveMinute.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveMinute\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_minutes_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 59;\n\n // Act / Assert\n subject.Should().HaveMinute(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_minutes_with_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 58;\n\n // Act\n Action act = () => subject.Should().HaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minute part of subject to be 58, but it was 59.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_minute_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minute part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveMinute\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_minutes_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 59;\n\n // Act\n Action act = () => subject.Should().NotHaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minute part of subject to be 59, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_minutes_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 58;\n\n // Act / Assert\n subject.Should().NotHaveMinute(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_minute_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minute part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.HaveMonth.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class HaveMonth\n {\n [Fact]\n public void When_asserting_subject_dateonly_should_have_month_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 12;\n\n // Act/Assert\n subject.Should().HaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_month_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_have_a_month_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 11;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 11, but found 12.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_a_month_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 11;\n\n // Act/Assert\n subject.Should().NotHaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_have_month_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 12, but found a DateOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_not_have_month_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but found a DateOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableSByteAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableSByteAssertions : NullableNumericAssertions\n{\n internal NullableSByteAssertions(sbyte? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(sbyte subject, sbyte expected)\n {\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.HaveYear.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class HaveYear\n {\n [Fact]\n public void When_asserting_subject_dateonly_should_have_year_with_the_same_value_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 2009;\n\n // Act/Assert\n subject.Should().HaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_year_with_the_same_value_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 2009;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2009, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_have_year_with_a_different_value_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found 2009.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_year_with_a_different_value_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 2008;\n\n // Act/Assert\n subject.Should().NotHaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_have_year_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found .\");\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_not_have_year_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2008, but found a DateOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.HaveMilliseconds.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class HaveMilliseconds\n {\n [Fact]\n public void When_asserting_subject_timeonly_should_have_milliseconds_with_the_same_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(14, 12, 31, 123);\n const int expectation = 123;\n\n // Act/Assert\n subject.Should().HaveMilliseconds(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_milliseconds_with_the_same_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(14, 12, 31, 445);\n const int expectation = 445;\n\n // Act\n Action act = () => subject.Should().NotHaveMilliseconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the milliseconds part of subject to be 445, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_have_milliseconds_with_a_different_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31, 555);\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMilliseconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the milliseconds part of subject to be 12, but found 555.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_milliseconds_with_a_different_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31, 445);\n const int expectation = 31;\n\n // Act/Assert\n subject.Should().NotHaveMilliseconds(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_have_milliseconds_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveMilliseconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the milliseconds part of subject to be 22, but found a TimeOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_not_have_milliseconds_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveMilliseconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the milliseconds part of subject to be 22, but found a TimeOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.BeEquivalentTo.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class BeEquivalentTo\n {\n [Fact]\n public void When_asserting_collections_to_be_equivalent_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act =\n () => collection.Should()\n .BeEquivalentTo(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*not to be *\");\n }\n\n [Fact]\n public void When_collections_with_duplicates_are_not_equivalent_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\", \"one\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\", \"three\"];\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1[3]*to be *\\\"one\\\"*\\\"three\\\"*\");\n }\n\n [Fact]\n public void When_testing_for_equivalence_against_empty_collection_it_should_throw()\n {\n // Arrange\n IEnumerable subject = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = new string[0];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject*to be a collection with 0 item(s), but*contains 3 item(s)*\");\n }\n\n [Fact]\n public void When_testing_for_equivalence_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = null;\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1*to be , but found {\\\"one\\\", \\\"two\\\", \\\"three\\\"}*\");\n }\n\n [Fact]\n public void When_two_collections_are_both_empty_it_should_treat_them_as_equivalent()\n {\n // Arrange\n IEnumerable subject = new string[0];\n IEnumerable otherCollection = new string[0];\n\n // Act / Assert\n subject.Should().BeEquivalentTo(otherCollection);\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_elements_it_should_treat_them_as_equivalent()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"three\", \"two\", \"one\"];\n\n // Act / Assert\n collection1.Should().BeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_two_arrays_contain_the_same_elements_it_should_treat_them_as_equivalent()\n {\n // Arrange\n string[] array1 = [\"one\", \"two\", \"three\"];\n string[] array2 = [\"three\", \"two\", \"one\"];\n\n // Act / Assert\n array1.Should().BeEquivalentTo(array2);\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_not_equivalent_to_a_different_collection()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"three\", \"one\"];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equivalent_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable actual = null;\n IEnumerable expectation = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expectation,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual not to be equivalent because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collections_are_unexpectedly_equivalent_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"three\", \"one\", \"two\"];\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 {\\\"one\\\", \\\"two\\\", \\\"three\\\"} not*equivalent*{\\\"three\\\", \\\"one\\\", \\\"two\\\"}.\");\n }\n\n [Fact]\n public void When_non_empty_collection_is_not_expected_to_be_equivalent_to_an_empty_collection_it_should_succeed()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = new string[0];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_testing_collections_not_to_be_equivalent_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = null;\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify inequivalence against a collection.*\");\n }\n\n [Fact]\n public void When_testing_collections_not_to_be_equivalent_against_same_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable collection1 = collection;\n\n // Act\n Action act = () => collection.Should().NotBeEquivalentTo(collection1,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not to be equivalent*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Streams/BufferedStreamAssertions.cs", "using System.Diagnostics;\nusing System.IO;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Streams;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n///\n[DebuggerNonUserCode]\npublic class BufferedStreamAssertions : BufferedStreamAssertions\n{\n public BufferedStreamAssertions(BufferedStream stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n }\n}\n\npublic class BufferedStreamAssertions : StreamAssertions\n where TAssertions : BufferedStreamAssertions\n{\n#if NET6_0_OR_GREATER || NETSTANDARD2_1\n\n private readonly AssertionChain assertionChain;\n\n public BufferedStreamAssertions(BufferedStream stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current has the buffer size.\n /// \n /// The expected buffer size of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveBufferSize(int expected,\n [System.Diagnostics.CodeAnalysis.StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the buffer size of {context:stream} to be {0}{reason}, but found a reference.\",\n expected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.BufferSize == expected)\n .FailWith(\"Expected the buffer size of {context:stream} to be {0}{reason}, but it was {1}.\",\n expected, Subject.BufferSize);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have a buffer size of .\n /// \n /// The unexpected buffer size of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveBufferSize(int unexpected,\n [System.Diagnostics.CodeAnalysis.StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the buffer size of {context:stream} not to be {0}{reason}, but found a reference.\",\n unexpected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.BufferSize != unexpected)\n .FailWith(\"Expected the buffer size of {context:stream} not to be {0}{reason}, but it was.\",\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n#else\n public BufferedStreamAssertions(BufferedStream stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n }\n#endif\n\n protected override string Identifier => \"buffered stream\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.Equal.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]Equal specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class Equal\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_equal_to_the_same_collection()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3];\n\n // Act / Assert\n collection1.Should().Equal(collection2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_is_equal_to_the_same_list_of_elements()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Equal(1, 2, 3);\n }\n\n [Fact]\n public void When_both_collections_are_null_it_should_succeed()\n {\n // Arrange\n int[] nullColl = null;\n\n // Act / Assert\n nullColl.Should().Equal(null);\n }\n\n [Fact]\n public void When_two_collections_containing_nulls_are_equal_it_should_not_throw()\n {\n // Arrange\n var subject = new List { \"aaa\", null };\n var expected = new List { \"aaa\", null };\n\n // Act / Assert\n subject.Should().Equal(expected);\n }\n\n [Fact]\n public void When_two_collections_are_not_equal_because_one_item_differs_it_should_throw_using_the_reason()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 5];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {1, 2, 5} because we want to test the failure message, but {1, 2, 3} differs at index 2.\");\n }\n\n [Fact]\n public void\n When_two_collections_are_not_equal_because_the_actual_collection_contains_more_items_it_should_throw_using_the_reason()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {1, 2} because we want to test the failure message, but {1, 2, 3} contains 1 item(s) too many.\");\n }\n\n [Fact]\n public void\n When_two_collections_are_not_equal_because_the_actual_collection_contains_less_items_it_should_throw_using_the_reason()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3, 4];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {1, 2, 3, 4} because we want to test the failure message, but {1, 2, 3} contains 1 item(s) less.\");\n }\n\n [Fact]\n public void When_two_multidimensional_collections_are_not_equal_and_it_should_format_the_collections_properly()\n {\n // Arrange\n object[][] collection1 = [[1, 2], [3, 4]];\n object[][] collection2 = [[5, 6], [7, 8]];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {{5, 6}, {7, 8}}, but {{1, 2}, {3, 4}} differs at index 0.\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equal_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n collection.Should().Equal(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be equal to {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equal_but_expected_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] collection1 = null;\n\n // Act\n Action act = () =>\n collection.Should().Equal(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare collection with .*\")\n .WithParameterName(\"expectation\");\n }\n\n [Fact]\n public void When_an_empty_collection_is_compared_for_equality_to_a_non_empty_collection_it_should_throw()\n {\n // Arrange\n int[] collection1 = [];\n int[] collection2 = [1, 2, 3];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {1, 2, 3}, but found empty collection.\");\n }\n\n [Fact]\n public void When_a_non_empty_collection_is_compared_for_equality_to_an_empty_collection_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {empty}, but found {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_all_items_match_according_to_a_predicate_it_should_succeed()\n {\n // Arrange\n var actual = new List { \"ONE\", \"TWO\", \"THREE\", \"FOUR\" };\n\n var expected = new[]\n {\n new { Value = \"One\" },\n new { Value = \"Two\" },\n new { Value = \"Three\" },\n new { Value = \"Four\" }\n };\n\n // Act / Assert\n actual.Should().Equal(expected,\n (a, e) => string.Equals(a, e.Value, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_any_item_does_not_match_according_to_a_predicate_it_should_throw()\n {\n // Arrange\n var actual = new List { \"ONE\", \"TWO\", \"THREE\", \"FOUR\" };\n\n var expected = new[]\n {\n new { Value = \"One\" },\n new { Value = \"Two\" },\n new { Value = \"Three\" },\n new { Value = \"Five\" }\n };\n\n // Act\n Action action = () => actual.Should().Equal(expected,\n (a, e) => string.Equals(a, e.Value, StringComparison.OrdinalIgnoreCase));\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"*Expected*equal to*, but*differs at index 3.*\");\n }\n\n [Fact]\n public void When_both_collections_are_empty_it_should_them_as_equal()\n {\n // Arrange\n var actual = new List();\n var expected = new List();\n\n // Act / Assert\n actual.Should().Equal(expected);\n }\n\n [Fact]\n public void When_asserting_identical_collections_to_be_equal_it_should_enumerate_the_subject_only_once()\n {\n // Arrange\n var actual = new CountingGenericEnumerable([1, 2, 3]);\n int[] expected = [1, 2, 3];\n\n // Act\n actual.Should().Equal(expected);\n\n // Assert\n actual.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_identical_collections_to_not_be_equal_it_should_enumerate_the_subject_only_once()\n {\n // Arrange\n var actual = new CountingGenericEnumerable([1, 2, 3]);\n int[] expected = [1, 2, 3];\n\n // Act\n try\n {\n actual.Should().NotEqual(expected);\n }\n catch\n {\n /* we don't care about the exception, we just need to check the enumeration count */\n }\n\n // Assert\n actual.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_different_collections_to_be_equal_it_should_enumerate_the_subject_once()\n {\n // Arrange\n var actual = new CountingGenericEnumerable([1, 2, 3]);\n int[] expected = [1, 2, 4];\n\n // Act\n try\n {\n actual.Should().Equal(expected);\n }\n catch\n {\n /* we don't care about the exception, we just need to check the enumeration count */\n }\n\n // Assert\n actual.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_different_collections_to_not_be_equal_it_should_enumerate_the_subject_only_once()\n {\n // Arrange\n var actual = new CountingGenericEnumerable([1, 2, 3]);\n int[] expected = [1, 2, 4];\n\n // Act\n actual.Should().NotEqual(expected);\n\n // Assert\n actual.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void\n When_asserting_equality_with_a_collection_built_from_params_arguments_that_are_assignable_to_the_subjects_type_parameter_it_should_succeed_by_treating_the_arguments_as_of_that_type()\n {\n // Arrange\n byte[] byteArray = [0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10];\n\n // Act / Assert\n byteArray.Should().Equal(0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10);\n }\n }\n\n public class NotEqual\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_not_equal_to_a_different_collection()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1, 2];\n\n // Act / Assert\n collection1.Should()\n .NotEqual(collection2);\n }\n\n [Fact]\n public void When_two_equal_collections_are_not_expected_to_be_equal_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3];\n\n // Act\n Action act = () => collection1.Should().NotEqual(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect collections {1, 2, 3} and {1, 2, 3} to be equal.\");\n }\n\n [Fact]\n public void When_two_equal_collections_are_not_expected_to_be_equal_it_should_report_a_clear_explanation()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3];\n\n // Act\n Action act = () => collection1.Should().NotEqual(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect collections {1, 2, 3} and {1, 2, 3} to be equal because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_subject_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotEqual(collection1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collections not to be equal because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_but_expected_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] collection1 = null;\n\n // Act\n Action act =\n () => collection.Should().NotEqual(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare collection with .*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_but_both_collections_reference_the_same_object_it_should_throw()\n {\n string[] collection1 = [\"one\", \"two\", \"three\"];\n var collection2 = collection1;\n\n // Act\n Action act = () =>\n collection1.Should().NotEqual(collection2, \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collections not to be equal because we want to test the behaviour with same objects, but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_two_collections_not_to_be_equal_because_the_actual_collection_contains_more_items_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2];\n\n // Act / Assert\n collection1.Should().NotEqual(collection2);\n }\n\n [Fact]\n public void When_asserting_two_collections_not_to_be_equal_because_the_actual_collection_contains_less_items_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3, 4];\n\n // Act / Assert\n collection1.Should().NotEqual(collection2);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/InnerExceptionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class InnerExceptionSpecs\n{\n [Fact]\n public void When_subject_throws_an_exception_with_the_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw(new Exception(\"\", new ArgumentException()));\n\n // Act / Assert\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException();\n }\n\n [Fact]\n public void When_subject_throws_an_exception_with_the_expected_inner_base_exception_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw(new Exception(\"\", new ArgumentNullException()));\n\n // Act / Assert\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException();\n }\n\n [Fact]\n public void When_subject_throws_an_exception_with_the_expected_inner_exception_from_argument_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw(new Exception(\"\", new ArgumentException()));\n\n // Act / Assert\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException(typeof(ArgumentException));\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_no_parameters_when_subject_throws_subclass_of_expected_inner_exception_it_should_throw_with_clear_description()\n {\n // Arrange\n var innerException = new ArgumentNullException(\"InnerExceptionMessage\", (Exception)null);\n\n Action act = () => throw new BadImageFormatException(\"\", innerException);\n\n try\n {\n // Act\n act.Should().Throw()\n .WithInnerExceptionExactly();\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\"Expected*ArgumentException*found*ArgumentNullException*InnerExceptionMessage*\");\n }\n }\n\n [Fact]\n public void WithInnerExceptionExactly_no_parameters_when_subject_throws_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new BadImageFormatException(\"\", new ArgumentNullException());\n\n // Act / Assert\n act.Should().Throw()\n .WithInnerExceptionExactly();\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_when_subject_throws_subclass_of_expected_inner_exception_it_should_throw_with_clear_description()\n {\n // Arrange\n var innerException = new ArgumentNullException(\"InnerExceptionMessage\", (Exception)null);\n\n Action act = () => throw new BadImageFormatException(\"\", innerException);\n\n try\n {\n // Act\n act.Should().Throw()\n .WithInnerExceptionExactly(\"because {0} should do just that\", \"the action\");\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should()\n .Match(\"Expected*ArgumentException*the action should do just that*ArgumentNullException*InnerExceptionMessage*\");\n }\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_with_type_exception_when_subject_throws_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new BadImageFormatException(\"\", new ArgumentNullException());\n\n // Act / Assert\n act.Should().Throw()\n .WithInnerExceptionExactly(typeof(ArgumentNullException), \"because {0} should do just that\", \"the action\");\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_with_type_exception_no_parameters_when_subject_throws_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new BadImageFormatException(\"\", new ArgumentNullException());\n\n // Act / Assert\n act.Should().Throw()\n .WithInnerExceptionExactly(typeof(ArgumentNullException));\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_with_type_exception_when_subject_throws_subclass_of_expected_inner_exception_it_should_throw_with_clear_description()\n {\n // Arrange\n var innerException = new ArgumentNullException(\"InnerExceptionMessage\", (Exception)null);\n\n Action act = () => throw new BadImageFormatException(\"\", innerException);\n\n try\n {\n // Act\n act.Should().Throw()\n .WithInnerExceptionExactly(typeof(ArgumentException), \"because {0} should do just that\", \"the action\");\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should()\n .Match(\"Expected*ArgumentException*the action should do just that*ArgumentNullException*InnerExceptionMessage*\");\n }\n }\n\n [Fact]\n public void WithInnerExceptionExactly_when_subject_throws_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new BadImageFormatException(\"\", new ArgumentNullException());\n\n // Act / Assert\n act.Should().Throw()\n .WithInnerExceptionExactly(\"because {0} should do just that\", \"the action\");\n }\n\n [Fact]\n public void An_exception_without_the_expected_inner_exception_has_a_descriptive_message()\n {\n // Arrange\n Action subject = () => throw new BadImageFormatException(\"\");\n\n // Act\n Action act = () => subject.Should().Throw()\n .WithInnerExceptionExactly(\"some {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*some message*no inner exception*\");\n }\n\n [Fact]\n public void When_subject_throws_an_exception_with_an_unexpected_inner_exception_it_should_throw_with_clear_description()\n {\n // Arrange\n var innerException = new NullReferenceException(\"InnerExceptionMessage\");\n\n Does testSubject = Does.Throw(new Exception(\"\", innerException));\n\n try\n {\n // Act\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException(\"because {0} should do just that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException exc)\n {\n // Assert\n exc.Message.Should().Match(\n \"Expected*ArgumentException*Does.Do should do just that*NullReferenceException*InnerExceptionMessage*\");\n }\n }\n\n [Fact]\n public void When_subject_throws_an_exception_without_expected_inner_exception_it_should_throw_with_clear_description()\n {\n try\n {\n Does testSubject = Does.Throw();\n\n testSubject.Invoking(x => x.Do()).Should().Throw()\n .WithInnerException(\"because {0} should do that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n ex.Message.Should().Be(\n \"Expected inner System.InvalidOperationException because Does.Do should do that, but the thrown exception has no inner exception.\");\n }\n }\n\n [Fact]\n public void When_an_inner_exception_matches_exactly_it_should_allow_chaining_more_asserts_on_that_exception_type()\n {\n // Act\n Action act = () =>\n throw new ArgumentException(\"OuterMessage\", new InvalidOperationException(\"InnerMessage\"));\n\n // Assert\n act\n .Should().ThrowExactly()\n .WithInnerExceptionExactly()\n .Where(i => i.Message == \"InnerMessage\");\n }\n\n [Fact]\n public void\n When_an_inner_exception_matches_exactly_it_should_allow_chaining_more_asserts_on_that_exception_type_from_argument()\n {\n // Act\n Action act = () =>\n throw new ArgumentException(\"OuterMessage\", new InvalidOperationException(\"InnerMessage\"));\n\n // Assert\n act\n .Should().ThrowExactly()\n .WithInnerExceptionExactly(typeof(InvalidOperationException))\n .Where(i => i.Message == \"InnerMessage\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_it_should_throw()\n {\n // Arrange\n Action act = () => throw new Exception();\n\n // Act\n Action act2 = () => act.Should().Throw()\n .Where(exceptionExpression: null);\n\n // Act\n act2.Should().ThrowExactly()\n .WithParameterName(\"exceptionExpression\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.SatisfyRespectively.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The SatisfyRespectively specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class SatisfyRespectively\n {\n [Fact]\n public void When_collection_asserting_against_null_inspectors_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify against a collection of inspectors*\");\n }\n\n [Fact]\n public void When_collection_asserting_against_empty_inspectors_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify against an empty collection of inspectors*\");\n }\n\n [Fact]\n public void When_collection_which_is_asserting_against_inspectors_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n collection.Should().SatisfyRespectively(\n new Action[] { x => x.Should().Be(1) }, \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to satisfy all inspectors because we want to test the failure message, but collection is .\");\n }\n\n [Fact]\n public void When_collection_which_is_asserting_against_inspectors_is_empty_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(new Action[] { x => x.Should().Be(1) },\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to satisfy all inspectors because we want to test the failure message, but collection is empty.\");\n }\n\n [Fact]\n public void When_asserting_collection_satisfies_all_inspectors_it_should_succeed()\n {\n // Arrange\n Customer[] collection = [new Customer { Age = 21, Name = \"John\" }, new Customer { Age = 22, Name = \"Jane\" }];\n\n // Act / Assert\n collection.Should().SatisfyRespectively(\n value =>\n {\n value.Age.Should().Be(21);\n value.Name.Should().Be(\"John\");\n },\n value =>\n {\n value.Age.Should().Be(22);\n value.Name.Should().Be(\"Jane\");\n });\n }\n\n [Fact]\n public void When_asserting_collection_does_not_satisfy_any_inspector_it_should_throw()\n {\n // Arrange\n CustomerWithItems[] customers =\n [\n new CustomerWithItems { Age = 21, Items = [1, 2] },\n new CustomerWithItems { Age = 22, Items = [3] }\n ];\n\n // Act\n Action act = () => customers.Should().SatisfyRespectively(\n new Action[]\n {\n customer =>\n {\n customer.Age.Should().BeLessThan(21);\n\n customer.Items.Should().SatisfyRespectively(\n item => item.Should().Be(2),\n item => item.Should().Be(1));\n },\n customer =>\n {\n customer.Age.Should().BeLessThan(22);\n customer.Items.Should().SatisfyRespectively(item => item.Should().Be(2));\n }\n }, \"because we want to test {0}\", \"nested assertions\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected customers to satisfy all inspectors because we want to test nested assertions, but some inspectors are not satisfied:\n *At index 0:\n *Expected customer.Age to be less than 21, but found 21\n *Expected customer.Items to satisfy all inspectors, but some inspectors are not satisfied:\n *At index 0:\n *Expected item to be 2, but found 1\n *At index 1:\n *Expected item to be 1, but found 2\n *At index 1:\n *Expected customer.Age to be less than 22, but found 22\n *Expected customer.Items to satisfy all inspectors, but some inspectors are not satisfied:\n *At index 0:\n *Expected item to be 2, but found 3\n \"\"\");\n }\n\n [Fact]\n public void When_inspector_message_is_not_reformatable_it_should_not_throw()\n {\n // Arrange\n byte[][] subject = [[1]];\n\n // Act\n Action act = () => subject.Should().SatisfyRespectively(e => e.Should().BeEquivalentTo(new byte[] { 2, 3, 4 }));\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_inspectors_count_does_not_equal_asserting_collection_length_it_should_throw_with_a_useful_message()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(\n new Action[] { value => value.Should().Be(1), value => value.Should().Be(2) },\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain exactly 2 items*we want to test the failure message*, but it contains 3 items\");\n }\n\n [Fact]\n public void When_inspectors_count_does_not_equal_asserting_collection_length_it_should_fail_with_a_useful_message()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(\n new Action[] { value => value.Should().Be(1), }, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*because we want to test the failure*\");\n }\n }\n\n private class Customer\n {\n private string PrivateProperty { get; }\n\n protected string ProtectedProperty { get; set; }\n\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n\n public long Id { get; set; }\n\n public void SetProtected(string value)\n {\n ProtectedProperty = value;\n }\n\n public Customer()\n {\n }\n\n public Customer(string privateProperty)\n {\n PrivateProperty = privateProperty;\n }\n }\n\n private class CustomerWithItems : Customer\n {\n public int[] Items { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.Contain.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]Contain specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class Contain\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_contains_an_item_from_the_collection()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Contain(1);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_contains_multiple_items_from_the_collection_in_any_order()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Contain([2, 1]);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_single_item_it_should_throw_with_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain(4, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain 4 because we do.\");\n }\n\n [Fact]\n public void When_asserting_collection_does_contain_item_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().Contain(1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_another_collection_it_should_throw_with_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain([3, 4, 5], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain {3, 4, 5} because we do, but could not find {4, 5}.\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_single_element_collection_it_should_throw_with_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain([4], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain 4 because we do.\");\n }\n\n [Fact]\n public void\n When_a_collection_does_not_contain_other_collection_with_assertion_scope_it_should_throw_with_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().Contain([4]);\n collection.Should().Contain([5, 6]);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*to contain 4*to contain {5, 6}*\");\n }\n\n [Fact]\n public void When_the_contents_of_a_collection_are_checked_against_an_empty_collection_it_should_throw_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain([]);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify containment against an empty collection*\");\n }\n\n [Fact]\n public void When_asserting_collection_does_contain_a_list_of_items_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().Contain([1, 2], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to contain {1, 2} *failure message*, but found .\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_Contain_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().Contain(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_an_expected_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain(item => item > 3, \"at least {0} item should be larger than 3\", 1);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to have an item matching (item > 3) because at least 1 item should be larger than 3.\");\n }\n\n [Fact]\n public void When_collection_does_contain_an_expected_item_matching_a_predicate_it_should_allow_chaining_it()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain(item => item == 2).Which.Should().BeGreaterThan(4);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*greater*4*2*\");\n }\n\n [Fact]\n public void Can_chain_another_assertion_on_the_single_result()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain(item => item == 2).Which.Should().BeGreaterThan(4);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection[1]*greater*4*2*\");\n }\n\n [Fact]\n public void When_collection_does_contain_an_expected_item_matching_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Contain(item => item == 2);\n }\n\n [Fact]\n public void When_a_collection_of_strings_contains_the_expected_string_it_should_not_throw()\n {\n // Arrange\n IEnumerable strings = [\"string1\", \"string2\", \"string3\"];\n\n // Act / Assert\n strings.Should().Contain(\"string2\");\n }\n\n [Fact]\n public void When_a_collection_of_strings_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n IEnumerable strings = [\"string1\", \"string2\", \"string3\"];\n\n // Act\n Action act = () => strings.Should().Contain(\"string4\", \"because {0} is required\", \"4\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings {\\\"string1\\\", \\\"string2\\\", \\\"string3\\\"} to contain \\\"string4\\\" because 4 is required.\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_some_values_but_collection_is_null_it_should_throw()\n {\n // Arrange\n const IEnumerable strings = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n strings.Should().Contain(\"string4\", \"because we're checking how it reacts to a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings to contain \\\"string4\\\" because we're checking how it reacts to a null subject, but found .\");\n }\n\n [Fact]\n public void When_the_multiple_matching_objects_exists_it_continuation_using_the_matched_value_should_fail()\n {\n // Arrange\n DateTime now = DateTime.Now;\n\n IEnumerable collection = [now, DateTime.SpecifyKind(now, DateTimeKind.Unspecified)];\n\n // Act\n Action act = () => collection.Should().Contain(now).Which.Kind.Should().Be(DateTimeKind.Local);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_collection_contains_values_according_to_predicate_but_collection_is_null_it_should_throw()\n {\n // Arrange\n const IEnumerable strings = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n strings.Should().Contain(x => x == \"xxx\", \"because we're checking how it reacts to a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings to contain (x == \\\"xxx\\\") because we're checking how it reacts to a null subject, but found .\");\n }\n }\n\n public class NotContain\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_does_not_contain_an_item_that_is_not_in_the_collection()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContain(4);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_does_not_contain_any_items_that_is_not_in_the_collection()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContain([4, 5]);\n }\n\n [Fact]\n public void When_collection_contains_an_unexpected_item_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContain(1, \"because we {0} like it, but found it anyhow\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to not contain 1 because we don't like it, but found it anyhow.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotContain_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotContain(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_collection_does_contain_an_unexpected_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContain(item => item == 2, \"because {0}s are evil\", 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to not have any items matching (item == 2) because 2s are evil,*{2}*\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_an_unexpected_item_matching_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContain(item => item == 4);\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_item_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContain(1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to not contain 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_contains_unexpected_item_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should()\n .NotContain([2], \"because we {0} like them\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to not contain 2 because we don't like them.\");\n }\n\n [Fact]\n public void When_collection_contains_unexpected_items_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should()\n .NotContain([1, 2, 4], \"because we {0} like them\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to not contain {1, 2, 4} because we don't like them, but found {1, 2}.\");\n }\n\n [Fact]\n public void Assertion_scopes_do_not_affect_chained_calls()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContain([1, 2]).And.NotContain([3]);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but found {1, 2}.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_an_empty_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContain([]);\n\n // Assert\n act.Should().Throw().WithMessage(\"Cannot verify*\");\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_predicate_item_against_null_collection_it_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContain(item => item == 4, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to contain (item == 4) *failure message*, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_a_list_of_items_against_null_collection_it_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContain([1, 2, 4], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to not contain {1, 2, 4} *failure message*, but found .\");\n }\n\n [Fact]\n public void\n When_asserting_collection_doesnt_contain_values_according_to_predicate_but_collection_is_null_it_should_throw()\n {\n // Arrange\n const IEnumerable strings = null;\n\n // Act\n Action act =\n () => strings.Should().NotContain(x => x == \"xxx\", \"because we're checking how it reacts to a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings not to contain (x == \\\"xxx\\\") because we're checking how it reacts to a null subject, but found .\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_the_expected_item_it_should_not_be_enumerated_twice()\n {\n // Arrange\n var collection = new OneTimeEnumerable(1, 2, 3);\n\n // Act\n Action act = () => collection.Should().Contain(4);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection*to contain 4.\");\n }\n\n [Fact]\n public void When_a_collection_contains_the_unexpected_item_it_should_not_be_enumerated_twice()\n {\n // Arrange\n var collection = new OneTimeEnumerable(1, 2, 3);\n\n // Act\n Action act = () => collection.Should().NotContain(2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection*to not contain 2.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.ContainEquivalentOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]ContainEquivalentOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class ContainEquivalentOf\n {\n [Fact]\n public void Succeed_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing test.\";\n string expect = \"TEST\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_contain_another()\n {\n // Arrange\n string actual = \" this is a string containing test.\";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing test. \";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing \\rA\\nB\\r\\nC.\\n\";\n string expect = \"A\\r\\nB\\nC\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n }\n\n [InlineData(\"aa\", \"A\")]\n [InlineData(\"aCCa\", \"acca\")]\n [Theory]\n public void Should_pass_when_contains_equivalent_of(string actual, string equivalentSubstring)\n {\n // Assert\n actual.Should().ContainEquivalentOf(equivalentSubstring);\n }\n\n [Fact]\n public void Should_fail_contain_equivalent_of_when_not_contains()\n {\n // Act\n Action act = () =>\n \"a\".Should().ContainEquivalentOf(\"aa\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string \\\"a\\\" to contain the equivalent of \\\"aa\\\" at least 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void Should_throw_when_null_equivalent_is_expected()\n {\n // Act\n Action act = () =>\n \"a\".Should().ContainEquivalentOf(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void Should_throw_when_empty_equivalent_is_expected()\n {\n // Act\n Action act = () =>\n \"a\".Should().ContainEquivalentOf(\"\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert string containment against an empty string.*\")\n .WithParameterName(\"expected\");\n }\n\n public class ContainEquivalentOfExactly\n {\n [Fact]\n public void When_containment_equivalent_of_once_is_asserted_against_null_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"a\";\n string expectedSubstring = null;\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Once());\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_exactly_once_is_asserted_and_actual_value_is_null_then_it_should_throw_earlier()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act\n Action act = () =>\n actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Once(), \"that is {0}\", \"required\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * to contain the equivalent of \\\"XyZ\\\" exactly 1 time because that is required, but found it 0 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_exactly_is_asserted_and_actual_value_contains_the_expected_string_exactly_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_exactly_is_asserted_and_actual_value_contains_the_expected_string_but_not_exactly_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Times(3));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" exactly 3 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_exactly_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEf\\\" to contain the equivalent of \\\"xyS\\\" exactly 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void When_containment_equivalent_of_exactly_once_is_asserted_against_an_empty_string_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"a\";\n string expectedSubstring = \"\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Once());\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against an empty string.*\");\n }\n }\n }\n\n public class ContainEquivalentOfAtLeast\n {\n [Fact]\n public void\n When_string_containment_equivalent_of_at_least_is_asserted_and_actual_value_contains_the_expected_string_at_least_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, AtLeast.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_least_is_asserted_and_actual_value_contains_the_expected_string_but_not_at_least_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, AtLeast.Times(3));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" at least 3 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_least_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, AtLeast.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEf\\\" to contain the equivalent of \\\"xyS\\\" at least 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_least_once_is_asserted_and_actual_value_is_null_then_it_should_throw_earlier()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, AtLeast.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain the equivalent of \\\"XyZ\\\" at least 1 time, but found it 0 times.\");\n }\n }\n\n public class ContainEquivalentOfMoreThan\n {\n [Fact]\n public void\n When_string_containment_equivalent_of_more_than_is_asserted_and_actual_value_contains_the_expected_string_more_than_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, MoreThan.Times(1));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_more_than_is_asserted_and_actual_value_contains_the_expected_string_but_not_more_than_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, MoreThan.Times(2));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" more than 2 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_more_than_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, MoreThan.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEf\\\" to contain the equivalent of \\\"xyS\\\" more than 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_more_than_once_is_asserted_and_actual_value_is_null_then_it_should_throw_earlier()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, MoreThan.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain the equivalent of \\\"XyZ\\\" more than 1 time, but found it 0 times.\");\n }\n }\n\n public class ContainEquivalentOfAtMost\n {\n [Fact]\n public void\n When_string_containment_equivalent_of_at_most_is_asserted_and_actual_value_contains_the_expected_string_at_most_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, AtMost.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_most_is_asserted_and_actual_value_contains_the_expected_string_but_not_at_most_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, AtMost.Times(1));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" at most 1 time, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_most_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, AtMost.Once());\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_most_once_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, AtMost.Once());\n }\n }\n\n public class ContainEquivalentOfLessThan\n {\n [Fact]\n public void\n When_string_containment_equivalent_of_less_than_is_asserted_and_actual_value_contains_the_expected_string_less_than_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, LessThan.Times(3));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_less_than_is_asserted_and_actual_value_contains_the_expected_string_but_not_less_than_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, LessThan.Times(2));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" less than 2 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_less_than_twice_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, LessThan.Twice());\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_less_than_twice_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, LessThan.Twice());\n }\n }\n\n public class NotContainEquivalentOf\n {\n [Fact]\n public void Succeed_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act / Assert\n actual.Should().NotContainEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_not_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing test.\";\n string expect = \"TEST\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_not_contain_another()\n {\n // Arrange\n string actual = \" this is a string containing test.\";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_not_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing test. \";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_not_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing \\rA\\nB\\r\\nC.\\n\";\n string expect = \"\\nA\\r\\nB\\rC\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_asserting_string_does_not_contain_equivalent_of_null()\n {\n // Act\n Action act = () =>\n \"a\".Should().NotContainEquivalentOf(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect string to contain the equivalent of , but found \\\"a\\\".\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_string_does_not_contain_equivalent_of_empty()\n {\n // Act\n Action act = () =>\n \"a\".Should().NotContainEquivalentOf(\"\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect string to contain the equivalent of \\\"\\\", but found \\\"a\\\".\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_string_does_not_contain_equivalent_of_another_string_but_it_does()\n {\n // Act\n Action act = () =>\n \"Hello, world!\".Should().NotContainEquivalentOf(\", worLD!\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect string to contain the equivalent of \\\", worLD!\\\" but found \\\"Hello, world!\\\".\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_string_does_not_contain_equivalent_of_another_string()\n {\n // Act / Assert\n \"aAa\".Should().NotContainEquivalentOf(\"aa \");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/CheckIfMemberIsBrowsableBenchmarks.cs", "using System.ComponentModel;\nusing System.Reflection;\nusing BenchmarkDotNet.Attributes;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\npublic class CheckIfMemberIsBrowsableBenchmarks\n{\n [Params(true, false)]\n public bool IsBrowsable { get; set; }\n\n public int BrowsableField;\n\n [EditorBrowsable(EditorBrowsableState.Never)]\n public int NonBrowsableField;\n\n public FieldInfo SubjectField => typeof(CheckIfMemberIsBrowsableBenchmarks)\n .GetField(IsBrowsable ? nameof(BrowsableField) : nameof(NonBrowsableField));\n\n [Benchmark]\n public bool CheckIfMemberIsBrowsable()\n {\n return SubjectField.GetCustomAttribute() is not { State: EditorBrowsableState.Never };\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/TimeOnlyAssertions.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class TimeOnlyAssertions : TimeOnlyAssertions\n{\n public TimeOnlyAssertions(TimeOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class TimeOnlyAssertions\n where TAssertions : TimeOnlyAssertions\n{\n public TimeOnlyAssertions(TimeOnly? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public TimeOnly? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TimeOnly? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TimeOnly? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is within the specified time\n /// from the specified value.\n /// \n /// \n /// The expected time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(TimeOnly nearbyTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n TimeSpan? difference = Subject != null\n ? MinimumDifference(Subject.Value, nearbyTime)\n : null;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the time} to be within {0} from {1}{reason}, \", precision, nearbyTime,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(Subject?.IsCloseTo(nearbyTime, precision) == true)\n .FailWith(\"but {0} was off by {1}.\", Subject, difference));\n\n return new AndConstraint((TAssertions)this);\n }\n\n private static TimeSpan? MinimumDifference(TimeOnly a, TimeOnly b)\n {\n var diff1 = a - b;\n var diff2 = b - a;\n\n return diff1 < diff2 ? diff1 : diff2;\n }\n\n /// \n /// Asserts that the current is not within the specified time\n /// from the specified value.\n /// \n /// \n /// The time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values must differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint NotBeCloseTo(TimeOnly distantTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:the time} to be within {0} from {1}{reason}, \", precision, distantTime,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(Subject?.IsCloseTo(distantTime, precision) == false)\n .FailWith(\"but it was {0}.\", Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is before the specified value.\n /// \n /// The that the current value is expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeBefore(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject < expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not before the specified value.\n /// \n /// The that the current value is not expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeBefore(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or before the specified value.\n /// \n /// The that the current value is expected to be on or before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrBefore(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject <= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be on or before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor before the specified value.\n /// \n /// The that the current value is not expected to be on nor before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrBefore(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is after the specified value.\n /// \n /// The that the current value is expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAfter(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject > expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not after the specified value.\n /// \n /// The that the current value is not expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAfter(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or after the specified value.\n /// \n /// The that the current value is expected to be on or after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrAfter(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject >= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be on or after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor after the specified value.\n /// \n /// The that the current value is expected not to be on nor after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrAfter(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has the hour.\n /// \n /// The expected hour of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveHours(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the hours part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject.Value.Hour == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Hour));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the hour.\n /// \n /// The hour that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveHours(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.HasValue)\n .FailWith(\"Did not expect the hours part of {context:the time} to be {0}{reason}, but found a TimeOnly.\",\n unexpected)\n .Then\n .ForCondition(Subject.Value.Hour != unexpected)\n .FailWith(\"Did not expect the hours part of {context:the time} to be {0}{reason}, but it was.\", unexpected,\n Subject.Value.Hour);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the minute.\n /// \n /// The expected minute of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMinutes(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the minutes part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Minute == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Minute));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the minute.\n /// \n /// The minute that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMinutes(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the minutes part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Minute != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the second.\n /// \n /// The expected second of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSeconds(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the seconds part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Second == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Second));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the second.\n /// \n /// The second that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSeconds(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the seconds part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Second != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the millisecond.\n /// \n /// The expected millisecond of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMilliseconds(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the milliseconds part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Millisecond == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Millisecond));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the millisecond.\n /// \n /// The millisecond that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMilliseconds(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the milliseconds part of {context:the time} to be {0}{reason}\", unexpected,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Millisecond != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params TimeOnly?[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params TimeOnly[] validValues)\n {\n return BeOneOf(validValues.Cast());\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOneOf(validValues.Cast(), because, becauseArgs);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/OuterExceptionSpecs.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class OuterExceptionSpecs\n{\n [Fact]\n public void When_subject_throws_expected_exception_with_an_expected_message_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"some message\"));\n\n // Act / Assert\n testSubject.Invoking(x => x.Do()).Should().Throw().WithMessage(\"some message\");\n }\n\n [Fact]\n public void When_subject_throws_expected_exception_but_with_unexpected_message_it_should_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"some\"));\n\n try\n {\n // Act\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithMessage(\"some message\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of*\\\"some message\\\", but*\\\"some\\\" does not*\");\n }\n }\n\n [Fact]\n public void When_subject_throws_expected_exception_with_message_starting_with_expected_message_it_should_not_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"expected message\"));\n\n // Act\n Action action = testSubject.Do;\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"expected mes*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_subject_throws_expected_exception_with_message_that_does_not_start_with_expected_message_it_should_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"OxpectOd message\"));\n\n // Act\n Action action = () => testSubject\n .Invoking(s => s.Do())\n .Should().Throw()\n .WithMessage(\"Expected mes\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected exception message to match the equivalent of*\\\"Expected mes*\\\", but*\\\"OxpectOd message\\\" does not*\");\n }\n\n [Fact]\n public void\n When_subject_throws_expected_exception_with_message_starting_with_expected_equivalent_message_it_should_not_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"Expected Message\"));\n\n // Act\n Action action = testSubject.Do;\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"expected mes*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_subject_throws_expected_exception_with_message_that_does_not_start_with_equivalent_message_it_should_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"OxpectOd message\"));\n\n // Act\n Action action = () => testSubject\n .Invoking(s => s.Do())\n .Should().Throw()\n .WithMessage(\"expected mes\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected exception message to match the equivalent of*\\\"expected mes*\\\", but*\\\"OxpectOd message\\\" does not*\");\n }\n\n [Fact]\n public void When_subject_throws_some_exception_with_unexpected_message_it_should_throw_with_clear_description()\n {\n // Arrange\n Does subjectThatThrows = Does.Throw(new InvalidOperationException(\"message1\"));\n\n try\n {\n // Act\n subjectThatThrows\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithMessage(\"message2\", \"because we want to test the failure {0}\", \"message\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of \\\"message2\\\" because we want to test the failure message, but \\\"message1\\\" does not*\");\n }\n }\n\n [Fact]\n public void When_subject_throws_some_exception_with_an_empty_message_it_should_throw_with_clear_description()\n {\n // Arrange\n Does subjectThatThrows = Does.Throw(new InvalidOperationException(\"\"));\n\n try\n {\n // Act\n subjectThatThrows\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithMessage(\"message2\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of \\\"message2\\\"*, but \\\"\\\"*\");\n }\n }\n\n [Fact]\n public void\n When_subject_throws_some_exception_with_message_which_contains_complete_expected_exception_and_more_it_should_throw()\n {\n // Arrange\n Does subjectThatThrows = Does.Throw(new ArgumentNullException(\"someParam\", \"message2\"));\n\n try\n {\n // Act\n subjectThatThrows\n .Invoking(x => x.Do(\"something\"))\n .Should().Throw()\n .WithMessage(\"message2\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of*\\\"message2\\\", but*message2*someParam*\");\n }\n }\n\n [Fact]\n public void When_no_exception_was_thrown_but_one_was_expected_it_should_clearly_report_that()\n {\n try\n {\n // Arrange\n Does testSubject = Does.NotThrow();\n\n // Act\n testSubject.Invoking(x => x.Do()).Should().Throw(\"because {0} should do that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Be(\n \"Expected a to be thrown because Does.Do should do that, but no exception was thrown.\");\n }\n }\n\n [Fact]\n public void When_subject_throws_another_exception_than_expected_it_should_include_details_of_that_exception()\n {\n // Arrange\n var actualException = new ArgumentException();\n\n Does testSubject = Does.Throw(actualException);\n\n try\n {\n // Act\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw(\"because {0} should throw that one\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().StartWith(\n \"Expected a to be thrown because Does.Do should throw that one, but found :\");\n\n ex.Message.Should().Contain(actualException.Message);\n }\n }\n\n [Fact]\n public void When_subject_throws_exception_with_message_with_braces_but_a_different_message_is_expected_it_should_report_that()\n {\n // Arrange\n Does subjectThatThrows = Does.Throw(new Exception(\"message with {}\"));\n\n try\n {\n // Act\n subjectThatThrows\n .Invoking(x => x.Do(\"something\"))\n .Should().Throw()\n .WithMessage(\"message without\");\n\n throw new XunitException(\"this point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of*\\\"message without\\\"*, but*\\\"message with {}*\");\n }\n }\n\n [Fact]\n public void When_asserting_with_an_aggregate_exception_type_the_asserts_should_occur_against_the_aggregate_exception()\n {\n // Arrange\n Does testSubject = Does.Throw(new AggregateException(\"Outer Message\", new Exception(\"Inner Message\")));\n\n // Act\n Action act = testSubject.Do;\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Outer Message*\")\n .WithInnerException()\n .WithMessage(\"Inner Message\");\n }\n\n [Fact]\n public void\n When_asserting_with_an_aggregate_exception_and_inner_exception_type_from_argument_the_asserts_should_occur_against_the_aggregate_exception()\n {\n // Arrange\n Does testSubject = Does.Throw(new AggregateException(\"Outer Message\", new Exception(\"Inner Message\")));\n\n // Act\n Action act = testSubject.Do;\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Outer Message*\")\n .WithInnerException(typeof(Exception))\n .WithMessage(\"Inner Message\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainInOrder.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]ContainInOrder specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class ContainInOrder\n {\n [Fact]\n public void When_two_collections_contain_the_same_items_in_the_same_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n collection.Should().ContainInOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_collection_contains_null_value_it_should_not_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act / Assert\n collection.Should().ContainInOrder(1, null, \"string\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act / Assert\n collection.Should().ContainInOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act / Assert\n collection.Should().ContainInOrder(1, 2, 1, 2, 12, 2, 2);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 3, 12, 2, 2];\n\n // Act\n Action act = () => collection.Should().ContainInOrder(1, 2, 1, 1, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 3, 12, 2, 2} to contain items {1, 2, 1, 1, 2} in order, but 1 (index 3) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInOrder([3, 1], \"because we said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain items {3, 1} in order because we said so, but 1 (index 1) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInOrder([4, 1], \"we failed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain items {4, 1} in order because we failed, \" +\n \"but 4 (index 0) did not appear (in the right order).\");\n }\n\n [Fact]\n public void Even_with_an_assertion_scope_only_the_first_failure_in_a_chained_assertion_is_reported()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n new[] { 1, 2, 3 }.Should().ContainInOrder(4).And.ContainInOrder(5);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\"*but 4 (index 0) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_ordered_containment_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify ordered containment against a collection.*\");\n }\n\n [Fact]\n public void Collections_contain_the_empty_sequence()\n {\n // Assert\n new[] { 1 }.Should().ContainInOrder();\n }\n\n [Fact]\n public void Collections_do_not_not_contain_the_empty_sequence()\n {\n // Assert\n new[] { 1 }.Should().NotContainInOrder();\n }\n\n [Fact]\n public void When_asserting_collection_contains_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] ints = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n ints.Should().ContainInOrder([4], \"because we're checking how it reacts to a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected ints to contain {4} in order because we're checking how it reacts to a null subject, but found .\");\n }\n }\n\n public class NotContainInOrder\n {\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInOrder(2, 1);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInOrder(4, 1);\n }\n\n [Fact]\n public void When_a_collection_contains_less_items_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2];\n\n // Act / Assert\n collection.Should().NotContainInOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 3, 12, 2, 2];\n\n // Act / Assert\n collection.Should().NotContainInOrder(1, 2, 1, 1, 2);\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(4);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder([1, 2, 3], \"that's what we expect\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 2, 3} to not contain items {1, 2, 3} in order because that's what we expect, \" +\n \"but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_not_contain_in_order_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainInOrder([1, 2, 3], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_collection_contains_contain_the_same_items_in_the_same_order_with_null_value_it_should_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(1, null, \"string\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, , 2, \\\"string\\\"} to not contain items {1, , \\\"string\\\"} in order, \" +\n \"but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3, 2} to not contain items {1, 2, 3} in order, \" +\n \"but items appeared in order ending at index 2.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(1, 2, 1, 2, 12, 2, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 2, 12, 2, 2} to not contain items {1, 2, 1, 2, 12, 2, 2} in order, \" +\n \"but items appeared in order ending at index 6.\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_absence_of_ordered_containment_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment against a collection.*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeLessThan.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeLessThan\n {\n [Fact]\n public void A_float_can_never_be_less_than_NaN()\n {\n // Arrange\n float? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeLessThan(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_another_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_less_than_NaN()\n {\n // Arrange\n double? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeLessThan(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_another_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Theory]\n [InlineData(5, -1)]\n [InlineData(10, 5)]\n [InlineData(10, -1)]\n public void To_test_the_remaining_paths_for_difference_on_nullable_int(int? subject, int expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeLessThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5L, -1L)]\n [InlineData(10L, 5L)]\n [InlineData(10L, -1L)]\n public void To_test_the_remaining_paths_for_difference_on_nullable_long(long? subject, long expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeLessThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringStartStrategy.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringStartStrategy : IStringComparisonStrategy\n{\n private readonly IEqualityComparer comparer;\n private readonly string predicateDescription;\n\n public StringStartStrategy(IEqualityComparer comparer, string predicateDescription)\n {\n this.comparer = comparer;\n this.predicateDescription = predicateDescription;\n }\n\n public string ExpectationDescription => $\"Expected {{context:string}} to {predicateDescription} \";\n\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n assertionChain\n .ForCondition(subject.Length >= expected.Length)\n .FailWith($\"{ExpectationDescription}{{0}}{{reason}}, but {{1}} is too short.\", expected, subject);\n\n if (!assertionChain.Succeeded)\n {\n return;\n }\n\n int indexOfMismatch = subject.IndexOfFirstMismatch(expected, comparer);\n\n if (indexOfMismatch < 0 || indexOfMismatch >= expected.Length)\n {\n return;\n }\n\n assertionChain.FailWith(\n $\"{ExpectationDescription}{{0}}{{reason}}, but {{1}} differs near {subject.IndexedSegmentAt(indexOfMismatch)}.\",\n expected, subject);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/EnumAssertionSpecs.cs", "using System;\nusing System.Reflection;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic enum EnumULong : ulong\n{\n Int64Max = long.MaxValue,\n UInt64LessOne = ulong.MaxValue - 1,\n UInt64Max = ulong.MaxValue\n}\n\npublic enum EnumLong : long\n{\n Int64Max = long.MaxValue,\n Int64LessOne = long.MaxValue - 1\n}\n\npublic class EnumAssertionSpecs\n{\n public class HaveFlag\n {\n [Fact]\n public void When_enum_has_the_expected_flag_it_should_succeed()\n {\n // Arrange\n TestEnum someObject = TestEnum.One | TestEnum.Two;\n\n // Act / Assert\n someObject.Should().HaveFlag(TestEnum.One);\n }\n\n [Fact]\n public void When_null_enum_does_not_have_the_expected_flag_it_should_fail()\n {\n // Arrange\n TestEnum? someObject = null;\n\n // Act\n Action act = () => someObject.Should().HaveFlag(TestEnum.Three);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_enum_does_not_have_specified_flag_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TestEnum someObject = TestEnum.One | TestEnum.Two;\n\n // Act\n Action act = () => someObject.Should().HaveFlag(TestEnum.Three, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected*have flag TestEnum.Three {value: 4}*because we want to test the failure message*but found TestEnum.One|Two {value: 3}.\");\n }\n }\n\n public class NotHaveFlag\n {\n [Fact]\n public void When_enum_does_not_have_the_unexpected_flag_it_should_succeed()\n {\n // Arrange\n TestEnum someObject = TestEnum.One | TestEnum.Two;\n\n // Act / Assert\n someObject.Should().NotHaveFlag(TestEnum.Three);\n }\n\n [Fact]\n public void When_enum_does_have_specified_flag_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TestEnum someObject = TestEnum.One | TestEnum.Two;\n\n // Act\n Action act = () => someObject.Should().NotHaveFlag(TestEnum.Two, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected*someObject*to not have flag TestEnum.Two {value: 2}*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_null_enum_does_not_have_the_expected_flag_it_should_not_fail()\n {\n // Arrange\n TestEnum? someObject = null;\n\n // Act / Assert\n someObject.Should().NotHaveFlag(TestEnum.Three);\n }\n }\n\n [Flags]\n public enum TestEnum\n {\n None = 0,\n One = 1,\n Two = 2,\n Three = 4\n }\n\n [Flags]\n public enum OtherEnum\n {\n Default,\n First,\n Second\n }\n\n public class Be\n {\n [Fact]\n public void When_enums_are_equal_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnum expected = MyEnum.One;\n\n // Act / Assert\n subject.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(null, null)]\n [InlineData(MyEnum.One, MyEnum.One)]\n public void When_nullable_enums_are_equal_it_should_succeed(MyEnum? subject, MyEnum? expected)\n {\n // Act / Assert\n subject.Should().Be(expected);\n }\n\n [Fact]\n public void When_a_null_enum_and_an_enum_are_unequal_it_should_throw()\n {\n // Arrange\n MyEnum? subject = null;\n MyEnum expected = MyEnum.Two;\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_enums_are_unequal_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnum expected = MyEnum.Two;\n\n // Act\n Action act = () => subject.Should().Be(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*subject*because we want to test the failure message*\");\n }\n\n [Theory]\n [InlineData(null, MyEnum.One)]\n [InlineData(MyEnum.One, null)]\n [InlineData(MyEnum.One, MyEnum.Two)]\n public void When_nullable_enums_are_equal_it_should_throw(MyEnum? subject, MyEnum? expected)\n {\n // Act\n Action act = () => subject.Should().Be(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_enums_are_unequal_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnum expected = MyEnum.Two;\n\n // Act / Assert\n subject.Should().NotBe(expected);\n }\n\n [Fact]\n public void When_a_null_enum_and_an_enum_are_unequal_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = null;\n MyEnum expected = MyEnum.Two;\n\n // Act / Assert\n subject.Should().NotBe(expected);\n }\n\n [Theory]\n [InlineData(null, MyEnum.One)]\n [InlineData(MyEnum.One, null)]\n [InlineData(MyEnum.One, MyEnum.Two)]\n public void When_nullable_enums_are_unequal_it_should_succeed(MyEnum? subject, MyEnum? expected)\n {\n // Act / Assert\n subject.Should().NotBe(expected);\n }\n\n [Fact]\n public void When_enums_are_equal_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnum expected = MyEnum.One;\n\n // Act\n Action act = () => subject.Should().NotBe(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Theory]\n [InlineData(null, null)]\n [InlineData(MyEnum.One, MyEnum.One)]\n public void When_nullable_enums_are_unequal_it_should_throw(MyEnum? subject, MyEnum? expected)\n {\n // Act\n Action act = () => subject.Should().NotBe(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public enum MyEnum\n {\n One = 1,\n Two = 2\n }\n\n public class HaveValue\n {\n [Fact]\n public void When_enum_has_the_expected_value_it_should_succeed()\n {\n // Arrange\n TestEnum someObject = TestEnum.One;\n\n // Act / Assert\n someObject.Should().HaveValue(1);\n }\n\n [Fact]\n public void When_null_enum_does_not_have_the_expected_value_it_should_fail()\n {\n // Arrange\n TestEnum? someObject = null;\n\n // Act\n Action act = () => someObject.Should().HaveValue(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_enum_does_not_have_specified_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TestEnum someObject = TestEnum.One;\n\n // Act\n Action act = () => someObject.Should().HaveValue(3, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*have value 3*because we want to test the failure message*but found*\");\n }\n\n [Fact]\n public void When_nullable_enum_has_value_it_should_be_chainable()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n\n // Act / Assert\n subject.Should().HaveValue()\n .Which.Should().Be(MyEnum.One);\n }\n\n [Fact]\n public void When_nullable_enum_does_not_have_value_it_should_throw()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n Action act = () => subject.Should().HaveValue(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotHaveValue\n {\n [Fact]\n public void When_enum_does_not_have_the_unexpected_value_it_should_succeed()\n {\n // Arrange\n TestEnum someObject = TestEnum.One;\n\n // Act / Assert\n someObject.Should().NotHaveValue(3);\n }\n\n [Fact]\n public void When_enum_does_have_specified_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TestEnum someObject = TestEnum.One;\n\n // Act\n Action act = () => someObject.Should().NotHaveValue(1, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*someObject*to not have value 1*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_null_enum_does_not_have_the_expected_value_it_should_not_fail()\n {\n // Arrange\n TestEnum? someObject = null;\n\n // Act / Assert\n someObject.Should().NotHaveValue(3);\n }\n\n [Fact]\n public void When_nullable_enum_does_not_have_value_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act / Assert\n subject.Should().NotHaveValue();\n }\n\n [Fact]\n public void When_nullable_enum_has_value_it_should_throw()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n\n // Act\n Action act = () => subject.Should().NotHaveValue(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class HaveSameValueAs\n {\n [Fact]\n public void When_enums_have_equal_values_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherOne;\n\n // Act / Assert\n subject.Should().HaveSameValueAs(expected);\n }\n\n [Fact]\n public void When_nullable_enums_have_equal_values_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherOne;\n\n // Act / Assert\n subject.Should().HaveSameValueAs(expected);\n }\n\n [Fact]\n public void When_enums_have_equal_values_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherTwo;\n\n // Act\n Action act = () => subject.Should().HaveSameValueAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Theory]\n [InlineData(null, MyEnumOtherName.OtherOne)]\n [InlineData(MyEnum.One, MyEnumOtherName.OtherTwo)]\n public void When_nullable_enums_have_equal_values_it_should_throw(MyEnum? subject, MyEnumOtherName expected)\n {\n // Act\n Action act = () => subject.Should().HaveSameValueAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotHaveSameValueAs\n {\n [Fact]\n public void When_enum_have_unequal_values_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherTwo;\n\n // Act / Assert\n subject.Should().NotHaveSameValueAs(expected);\n }\n\n [Theory]\n [InlineData(null, MyEnumOtherName.OtherOne)]\n [InlineData(MyEnum.One, MyEnumOtherName.OtherTwo)]\n public void When_nullable_enums_have_unequal_values_it_should_succeed(MyEnum? subject, MyEnumOtherName expected)\n {\n // Act / Assert\n subject.Should().NotHaveSameValueAs(expected);\n }\n\n [Fact]\n public void When_enums_have_unequal_values_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherOne;\n\n // Act\n Action act = () => subject.Should().NotHaveSameValueAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_nullable_enums_have_unequal_values_it_should_throw()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherOne;\n\n // Act\n Action act = () => subject.Should().NotHaveSameValueAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public enum MyEnumOtherName\n {\n OtherOne = 1,\n OtherTwo = 2\n }\n\n public class HaveSameNameAs\n {\n [Fact]\n public void When_enums_have_equal_names_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.One;\n\n // Act / Assert\n subject.Should().HaveSameNameAs(expected);\n }\n\n [Fact]\n public void When_nullable_enums_have_equal_names_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.One;\n\n // Act / Assert\n subject.Should().HaveSameNameAs(expected);\n }\n\n [Fact]\n public void When_enums_have_equal_names_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.Two;\n\n // Act\n Action act = () => subject.Should().HaveSameNameAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Theory]\n [InlineData(null, MyEnumOtherValue.One)]\n [InlineData(MyEnum.One, MyEnumOtherValue.Two)]\n public void When_nullable_enums_have_equal_names_it_should_throw(MyEnum? subject, MyEnumOtherValue expected)\n {\n // Act\n Action act = () => subject.Should().HaveSameNameAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotHaveSameNameAs\n {\n [Fact]\n public void When_senum_have_unequal_names_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.Two;\n\n // Act / Assert\n subject.Should().NotHaveSameNameAs(expected);\n }\n\n [Theory]\n [InlineData(null, MyEnumOtherValue.One)]\n [InlineData(MyEnum.One, MyEnumOtherValue.Two)]\n public void When_nullable_enums_have_unequal_names_it_should_succeed(MyEnum? subject, MyEnumOtherValue expected)\n {\n // Act / Assert\n subject.Should().NotHaveSameNameAs(expected);\n }\n\n [Fact]\n public void When_enums_have_unequal_names_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.One;\n\n // Act\n Action act = () => subject.Should().NotHaveSameNameAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_nullable_enums_have_unequal_names_it_should_throw()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.One;\n\n // Act\n Action act = () => subject.Should().NotHaveSameNameAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public enum MyEnumOtherValue\n {\n One = 11,\n Two = 22\n }\n\n public class BeNull\n {\n [Fact]\n public void When_nullable_enum_is_null_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act / Assert\n subject.Should().BeNull();\n }\n\n [Fact]\n public void When_nullable_enum_is_not_null_it_should_throw()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n\n // Act\n Action act = () => subject.Should().BeNull(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_nullable_enum_is_not_null_it_should_be_chainable()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n\n // Act / Assert\n subject.Should().NotBeNull()\n .Which.Should().Be(MyEnum.One);\n }\n\n [Fact]\n public void When_nullable_enum_is_null_it_should_throw()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n Action act = () => subject.Should().NotBeNull(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class Match\n {\n [Fact]\n public void An_enum_matching_the_predicate_should_not_throw()\n {\n // Arrange\n BindingFlags flags = BindingFlags.Public;\n\n // Act / Assert\n flags.Should().Match(x => x == BindingFlags.Public);\n }\n\n [Fact]\n public void An_enum_not_matching_the_predicate_should_throw_with_the_predicate_in_the_message()\n {\n // Arrange\n BindingFlags flags = BindingFlags.Public;\n\n // Act\n Action act = () => flags.Should().Match(x => x == BindingFlags.Static, \"that's what we need\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Static*because that's what we need*found*Public*\");\n }\n\n [Fact]\n public void An_enum_cannot_be_compared_with_a_null_predicate()\n {\n // Act\n Action act = () => BindingFlags.Public.Should().Match(null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*null*predicate*\");\n }\n }\n\n public class BeOneOf\n {\n [Fact]\n public void An_enum_that_is_one_of_the_expected_values_should_not_throw()\n {\n // Arrange\n BindingFlags flags = BindingFlags.Public;\n\n // Act / Assert\n flags.Should().BeOneOf(BindingFlags.Public, BindingFlags.ExactBinding);\n }\n\n [Fact]\n public void Throws_when_the_enums_is_not_one_of_the_expected_enums()\n {\n // Arrange\n BindingFlags flags = BindingFlags.DeclaredOnly;\n\n // Act / Assert\n Action act = () =>\n flags.Should().BeOneOf([BindingFlags.Public, BindingFlags.ExactBinding], \"that's what we need\");\n\n act.Should()\n .Throw()\n .WithMessage(\"Expected*Public*ExactBinding*because that's what we need*found*DeclaredOnly*\");\n }\n\n [Fact]\n public void An_enum_cannot_be_part_of_an_empty_list()\n {\n // Arrange\n BindingFlags flags = BindingFlags.DeclaredOnly;\n\n // Act / Assert\n Action act = () => flags.Should().BeOneOf([]);\n\n act.Should()\n .Throw()\n .WithMessage(\"Cannot*empty list of enums*\");\n }\n\n [Fact]\n public void An_enum_cannot_be_part_of_a_null_list()\n {\n // Arrange\n BindingFlags flags = BindingFlags.DeclaredOnly;\n\n // Act / Assert\n Action act = () => flags.Should().BeOneOf(null);\n\n act.Should()\n .Throw()\n .WithMessage(\"Cannot*null list of enums*\");\n }\n }\n\n public class BeDefined\n {\n [Fact]\n public void A_valid_entry_of_an_enum_is_defined()\n {\n // Arrange\n var dayOfWeek = DayOfWeek.Monday;\n\n // Act / Assert\n dayOfWeek.Should().BeDefined();\n }\n\n [Fact]\n public void If_a_value_casted_to_an_enum_type_and_it_does_not_exist_in_the_enum_it_throws()\n {\n // Arrange\n var dayOfWeek = (DayOfWeek)999;\n\n // Act\n Action act = () => dayOfWeek.Should().BeDefined(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected *to be defined in*failure message*, but it is not*\");\n }\n\n [Fact]\n public void A_null_entry_of_an_enum_throws()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n Action act = () => subject.Should().BeDefined();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected *to be defined in*, but found .\");\n }\n }\n\n public class NotBeDefined\n {\n [Fact]\n public void An_invalid_entry_of_an_enum_is_not_defined_passes()\n {\n // Arrange\n var dayOfWeek = (DayOfWeek)999;\n\n // Act / Assert\n dayOfWeek.Should().NotBeDefined();\n }\n\n [Fact]\n public void A_valid_entry_of_an_enum_is_not_defined_fails()\n {\n // Arrange\n var dayOfWeek = DayOfWeek.Monday;\n\n // Act\n Action act = () => dayOfWeek.Should().NotBeDefined();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*to be defined in*, but it is.\");\n }\n\n [Fact]\n public void A_null_value_of_an_enum_is_not_defined_and_throws()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n Action act = () => subject.Should().NotBeDefined();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect *to be defined in*, but found .\");\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n var action = () => subject.Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.Be.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_datetimeoffset_value_is_equal_to_the_same_value()\n {\n // Arrange\n DateTimeOffset dateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset sameDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_datetimeoffset_value_is_equal_to_the_same_nullable_value_be_should_succeed()\n {\n // Arrange\n DateTimeOffset dateTime = 4.June(2016).ToDateTimeOffset();\n DateTimeOffset? sameDateTime = 4.June(2016).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_both_values_are_at_their_minimum_then_it_should_succeed()\n {\n // Arrange\n DateTimeOffset dateTime = DateTimeOffset.MinValue;\n DateTimeOffset sameDateTime = DateTimeOffset.MinValue;\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_both_values_are_at_their_maximum_then_it_should_succeed()\n {\n // Arrange\n DateTimeOffset dateTime = DateTimeOffset.MaxValue;\n DateTimeOffset sameDateTime = DateTimeOffset.MaxValue;\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_datetimeoffset_value_is_equal_to_the_different_value()\n {\n // Arrange\n var dateTime = 10.March(2012).WithOffset(1.Hours());\n var otherDateTime = 11.March(2012).WithOffset(1.Hours());\n\n // Act\n Action act = () => dateTime.Should().Be(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dateTime to represent the same point in time as <2012-03-11 +1h>*failure message, but <2012-03-10 +1h> does not.\");\n }\n\n [Fact]\n public void When_datetimeoffset_value_is_equal_to_the_different_nullable_value_be_should_failed()\n {\n // Arrange\n DateTimeOffset dateTime = 10.March(2012).WithOffset(1.Hours());\n DateTimeOffset? otherDateTime = 11.March(2012).WithOffset(1.Hours());\n\n // Act\n Action act = () => dateTime.Should().Be(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dateTime to represent the same point in time as <2012-03-11 +1h>*failure message, but <2012-03-10 +1h> does not.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetimeoffset_value_equals_the_same_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset? nullableDateTimeB = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetimeoffset_null_value_equals_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = null;\n DateTimeOffset? nullableDateTimeB = null;\n\n // Act / Assert\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_equals_a_different_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset? nullableDateTimeB = new DateTime(2016, 06, 06).ToDateTimeOffset();\n\n // Act\n Action action = () =>\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_datetimeoffset_null_value_is_equal_to_another_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n DateTimeOffset expectation = 27.March(2016).ToDateTimeOffset(1.Hours());\n\n // Act\n Action action = () =>\n nullableDateTime.Should().Be(expectation, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateTime to represent the same point in time as <2016-03-27 +1h> because we want to test the failure message, but found a DateTimeOffset.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_non_null_value_is_equal_to_null_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = 27.March(2016).ToDateTimeOffset(1.Hours());\n DateTimeOffset? expectation = null;\n\n // Act\n Action action = () =>\n nullableDateTime.Should().Be(expectation, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateTime to be because we want to test the failure message, but it was <2016-03-27 +1h>.\");\n }\n\n [Fact]\n public void\n When_asserting_different_date_time_offsets_representing_the_same_world_time_it_should_succeed()\n {\n // Arrange\n var specificDate = 1.May(2008).At(6, 32);\n\n var dateWithFiveHourOffset = new DateTimeOffset(specificDate - 5.Hours(), -5.Hours());\n\n var dateWithSixHourOffset = new DateTimeOffset(specificDate - 6.Hours(), -6.Hours());\n\n // Act / Assert\n dateWithFiveHourOffset.Should().Be(dateWithSixHourOffset);\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Should_succeed_when_asserting_datetimeoffset_value_is_not_equal_to_a_different_value()\n {\n // Arrange\n DateTimeOffset dateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset otherDateTime = new DateTime(2016, 06, 05).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().NotBe(otherDateTime);\n }\n\n [Fact]\n public void When_datetimeoffset_value_is_not_equal_to_a_nullable_different_value_notbe_should_succeed()\n {\n // Arrange\n DateTimeOffset dateTime = 4.June(2016).ToDateTimeOffset();\n DateTimeOffset? otherDateTime = 5.June(2016).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().NotBe(otherDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_datetimeoffset_value_is_not_equal_to_the_same_value()\n {\n // Arrange\n var dateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n var sameDateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n\n // Act\n Action act =\n () => dateTime.Should().NotBe(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dateTime to represent the same point in time as <2012-03-10 +1h> because we want to test the failure message, but it did.\");\n }\n\n [Fact]\n public void When_datetimeoffset_value_is_not_equal_to_the_same_nullable_value_notbe_should_failed()\n {\n // Arrange\n DateTimeOffset dateTime = new(10.March(2012), 1.Hours());\n DateTimeOffset? sameDateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n\n // Act\n Action act =\n () => dateTime.Should().NotBe(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dateTime to represent the same point in time as <2012-03-10 +1h> because we want to test the failure message, but it did.\");\n }\n\n [Fact]\n public void\n When_asserting_different_date_time_offsets_representing_different_world_times_it_should_not_succeed()\n {\n // Arrange\n var specificDate = 1.May(2008).At(6, 32);\n\n var dateWithZeroHourOffset = new DateTimeOffset(specificDate, TimeSpan.Zero);\n var dateWithOneHourOffset = new DateTimeOffset(specificDate, 1.Hours());\n\n // Act / Assert\n dateWithZeroHourOffset.Should().NotBe(dateWithOneHourOffset);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.Be.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]Be specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_both_values_are_the_same_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().Be(\"ABC\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_are_null_it_should_succeed()\n {\n // Arrange\n string actualString = null;\n string expectedString = null;\n\n // Act / Assert\n actualString.Should().Be(expectedString);\n }\n\n [Fact]\n public void When_two_strings_differ_unexpectedly_it_should_throw()\n {\n // Act\n Action act = () => \"ADC\".Should().Be(\"ABC\", \"because we {0}\", \"do\");\n\n // Assert\n // we want one assertion with the full message.\n act.Should().Throw().Which.Message.Should().Be(\"\"\"\n Expected string to be the same string because we do, but they differ at index 1:\n ↓ (actual)\n \"ADC\"\n \"ABC\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_two_strings_differ_unexpectedly_containing_double_curly_closing_braces_it_should_throw()\n {\n const string expect = \"}}\";\n const string actual = \"}}}}\";\n\n // Act\n Action act = () => actual.Should().Be(expect);\n\n // Assert\n act.Should().Throw().WithMessage(\"*differ at index 2*}}}}\\\"*\\\"}}\\\"*\");\n }\n\n [Fact]\n public void When_two_strings_differ_unexpectedly_containing_double_curly_opening_braces_it_should_throw()\n {\n const string expect = \"{{\";\n const string actual = \"{{{{\";\n\n // Act\n Action act = () => actual.Should().Be(expect);\n\n // Assert\n act.Should().Throw().WithMessage(\"*differ at index 2*{{{{\\\"*\\\"{{\\\"*\");\n }\n\n [Fact]\n public void When_the_expected_string_is_shorter_than_the_actual_string_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().Be(\"AB\");\n\n // Assert\n act.Should().Throw().Which.Message.Should().Be(\"\"\"\n Expected string to be the same string, but they differ at index 2:\n ↓ (actual)\n \"ABC\"\n \"AB\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_the_expected_string_is_longer_than_the_actual_string_it_should_throw()\n {\n // Act\n Action act = () => \"AB\".Should().Be(\"ABC\");\n\n // Assert\n act.Should().Throw().Which.Message.Should().Be(\"\"\"\n Expected string to be the same string, but they differ at index 2:\n ↓ (actual)\n \"AB\"\n \"ABC\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_the_expected_string_is_empty_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().Be(\"\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*index 0*\");\n }\n\n [Fact]\n public void When_the_subject_string_is_empty_it_should_throw()\n {\n // Act\n Action act = () => \"\".Should().Be(\"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*index 0*\");\n }\n\n [Fact]\n public void When_string_is_expected_to_equal_null_it_should_throw()\n {\n // Act\n Action act = () => \"AB\".Should().Be(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be , but found \\\"AB\\\".\");\n }\n\n [Fact]\n public void When_string_is_expected_to_be_null_it_should_throw()\n {\n // Act\n Action act = () => \"AB\".Should().BeNull(\"we like {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be because we like null, but found \\\"AB\\\".\");\n }\n\n [Fact]\n public void When_the_expected_string_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().Be(\"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString to be \\\"ABC\\\", but found .\");\n }\n\n [Fact]\n public void When_the_expected_string_is_the_same_but_with_trailing_spaces_it_should_throw_with_clear_error_message()\n {\n // Act\n Action act = () => \"ABC\".Should().Be(\"ABC \", \"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be \\\"ABC \\\" because I say so, but it misses some extra whitespace at the end.\");\n }\n\n [Fact]\n public void\n When_the_actual_string_is_the_same_as_the_expected_but_with_trailing_spaces_it_should_throw_with_clear_error_message()\n {\n // Act\n Action act = () => \"ABC \".Should().Be(\"ABC\", \"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be \\\"ABC\\\" because I say so, but it has unexpected whitespace at the end.\");\n }\n\n [Fact]\n public void When_two_strings_differ_and_one_of_them_is_long_it_should_display_both_strings_on_separate_line()\n {\n // Act\n Action act = () => \"1234567890\".Should().Be(\"0987654321\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected string to be the same string, but they differ at index 0:\n ↓ (actual)\n \"1234567890\"\n \"0987654321\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_two_strings_differ_and_one_of_them_is_multiline_it_should_display_both_strings_on_separate_line()\n {\n // Act\n Action act = () => \"A\\r\\nB\".Should().Be(\"A\\r\\nC\");\n\n // Assert\n act.Should().Throw().Which.Message.Should().Be(\"\"\"\n Expected string to be the same string, but they differ on line 2 and column 1 (index 3):\n ↓ (actual)\n \"A\\r\\nB\"\n \"A\\r\\nC\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void Use_arrows_for_text_longer_than_8_characters()\n {\n const string subject = \"this is a long text that differs in between two words\";\n const string expected = \"this is a long text which differs in between two words\";\n\n // Act\n Action act = () => subject.Should().Be(expected, \"because we use arrows now\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected subject to be the same string because we use arrows now, but they differ at index 20:\n ↓ (actual)\n \"…is a long text that differs in between two words\"\n \"…is a long text which differs in between two words\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void Only_add_ellipsis_for_long_text()\n {\n const string subject = \"this is a long text that has more than 60 characters so it requires ellipsis\";\n const string expected = \"this was too short\";\n\n // Act\n Action act = () => subject.Should().Be(expected, \"because we use arrows now\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected subject to be the same string because we use arrows now, but they differ at index 5:\n ↓ (actual)\n \"this is a long text that has more than 60 characters so it…\"\n \"this was too short\"\n ↑ (expected).\n \"\"\");\n }\n\n [Theory]\n [InlineData(\"ThisIsUsedTo Check a difference after 5 characters\")]\n [InlineData(\"ThisIsUsedTo CheckADifferenc e after 15 characters\")]\n public void Will_look_for_a_word_boundary_between_5_and_15_characters_before_the_mismatching_index_to_highlight_the_mismatch(string expected)\n {\n const string subject = \"ThisIsUsedTo CheckADifferenceInThe WordBoundaryAlgorithm\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"…CheckADifferenceInThe*\");\n }\n\n [Theory]\n [InlineData(\"ThisIsUsedTo Chec k a difference after 4 characters\", \"\\\"…sedTo CheckADifferen\")]\n [InlineData(\"ThisIsUsedTo CheckADifference after 16 characters\", \"\\\"…Difference\")]\n public void Will_fallback_to_10_characters_if_no_word_boundary_can_be_found_before_the_mismatching_index(\n string expected, string expectedMessagePart)\n {\n const string subject = \"ThisIsUsedTo CheckADifferenceInThe WordBoundaryAlgorithm\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage($\"*{expectedMessagePart}*\");\n }\n\n [Theory]\n [InlineData(\"This Is A LongTextWithMoreThan60CharactersWhichIs after 10 + 35 characters\")]\n [InlineData(\"This Is A LongTextWithMoreThan60Ch after 10 + 50 characters\")]\n public void Will_look_for_a_word_boundary_between_45_and_60_characters_after_the_mismatching_index_to_highlight_the_mismatch(string expected)\n {\n const string subject = \"This Is A LongTextWithMoreThan60CharactersWhichIsUsedToCheckADifferenceAtTheEndOfThe WordBoundaryAlgorithm\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*AtTheEndOfThe…\\\"*\");\n }\n\n [Fact]\n public void An_empty_string_is_always_shorter_than_a_long_text()\n {\n // Act\n Action act = () => \"\".Should().Be(\"ThisIsALongText\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*differ at index 0*\\\"\\\"*\\\"ThisIsALongText\\\"**\");\n }\n\n [Fact]\n public void A_mismatch_below_index_11_includes_all_text_preceding_the_index_in_the_failure()\n {\n // Act\n Action act = () => \"This is a long text\".Should().Be(\"This is a text that differs at index 10\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"This is a long*\");\n }\n\n [Theory]\n [InlineData(\"This Is A LongTextWithMoreThan60C that differs with 60 characters remaining\", \"oreThan60CharactersWhichIsUsedToCheckADifferenceAt…\\\"\")]\n [InlineData(\"This Is A LongTextWithMoreThan60Ch IsALongTextIsUsedToCheckADiffere after 10 + 16 characters\", \"reThan60CharactersWhichIsUsedToCheckADifferenceAtTheEndOfThe…\\\"\")]\n public void Will_fallback_to_50_characters_if_no_word_boundary_can_be_found_after_the_mismatching_index(\n string expected, string expectedMessagePart)\n {\n const string subject = \"This Is A LongTextWithMoreThan60CharactersWhichIsUsedToCheckADifferenceAtTheEndOfThe WordBoundaryAlgorithm\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage($\"*{expectedMessagePart}*\");\n }\n\n [Fact]\n public void Mismatches_in_multiline_text_includes_the_line_number()\n {\n var expectedIndex = 100 + (4 * Environment.NewLine.Length);\n\n var subject = \"\"\"\n @startuml\n Alice -> Bob : Authentication Request\n Bob --> Alice : Authentication Response\n\n Alice -> Bob : Another authentication Request\n Alice <-- Bob : Another authentication Response\n @enduml\n \"\"\";\n\n var expected = \"\"\"\n @startuml\n Alice -> Bob : Authentication Request\n Bob --> Alice : Authentication Response\n\n Alice -> Bob : Invalid authentication Request\n Alice <-- Bob : Another authentication Response\n @enduml\n \"\"\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage($\"\"\"\n Expected subject to be the same string, but they differ on line 5 and column 16 (index {expectedIndex}):\n ↓ (actual)\n \"…-> Bob : Another authentication Request*\\nAlice <-- Bob :…\"\n \"…-> Bob : Invalid authentication Request*\\nAlice <-- Bob :…\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_differing_actual_and_expected_string_contain_braces_they_are_formatted_correctly()\n {\n // Act\n Action act = () => \"public class Foo { }\".Should().Be(\"public class Bar { }\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Foo { }*Bar { }*↑ (expected).\", \"because no formatting warning must be appended\");\n }\n\n [Fact]\n public void When_the_longer_expected_string_and_actual_string_contain_braces_they_are_formatted_correctly()\n {\n // Act\n Action act = () => \"public class Foo { }\".Should().Be(\"public class Foo { };\");\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"\"\"\n *\"…class Foo { }\"\n *\"…class Foo { };\"\n *(expected).\n \"\"\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_different_strings_are_expected_to_differ_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string unexpected = \"DEF\";\n\n // Act / Assert\n actual.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void When_equal_strings_are_expected_to_differ_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().NotBe(\"ABC\", \"because we don't like {0}\", \"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string not to be \\\"ABC\\\" because we don't like ABC.\");\n }\n\n [Fact]\n public void When_non_empty_string_is_not_equal_to_empty_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string unexpected = \"\";\n\n // Act / Assert\n actual.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void When_empty_string_is_not_supposed_to_be_equal_to_empty_it_should_throw()\n {\n // Arrange\n string actual = \"\";\n string unexpected = \"\";\n\n // Act\n Action act = () => actual.Should().NotBe(unexpected);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual not to be \\\"\\\".\");\n }\n\n [Fact]\n public void When_valid_string_is_not_supposed_to_be_null_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string unexpected = null;\n\n // Act / Assert\n actual.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void When_null_string_is_not_supposed_to_be_equal_to_null_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().NotBe(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to be .\");\n }\n\n [Fact]\n public void When_null_string_is_not_supposed_to_be_null_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().NotBeNull(\"we don't like {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to be because we don't like null.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/GlobalConfigurationSpecs.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Configuration;\nusing AwesomeAssertions.Execution;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\n[Collection(\"ConfigurationSpecs\")]\npublic sealed class GlobalConfigurationSpecs : IDisposable\n{\n [Fact]\n public void Concurrently_accessing_the_configuration_is_safe()\n {\n // Act\n Action act = () => Parallel.For(\n 0,\n 10000,\n new ParallelOptions\n {\n MaxDegreeOfParallelism = 8\n },\n __ =>\n {\n AssertionConfiguration.Current.Formatting.ValueFormatterAssembly = string.Empty;\n _ = AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode;\n }\n );\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Can_override_the_runtime_test_framework_implementation()\n {\n // Arrange\n AssertionEngine.TestFramework = new NotImplementedTestFramework();\n\n // Act\n var act = () => 1.Should().Be(2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_override_the_runtime_test_framework()\n {\n // Arrange\n AssertionEngine.Configuration.TestFramework = TestFramework.NUnit;\n\n // Act\n var act = () => 1.Should().Be(2);\n\n // Assert\n act.Should().Throw().WithMessage(\"*nunit.framework*\");\n }\n\n private class NotImplementedTestFramework : ITestFramework\n {\n public bool IsAvailable => true;\n\n public void Throw(string message) => throw new NotImplementedException();\n }\n\n public void Dispose() => AssertionEngine.ResetToDefaults();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.AllSatisfy.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The AllSatisfy specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class AllSatisfy\n {\n [Fact]\n public void A_null_inspector_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().AllSatisfy(null);\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Cannot verify against a inspector*\");\n }\n\n [Fact]\n public void A_null_collection_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllSatisfy(x => x.Should().Be(1), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\n \"Expected collection to contain only items satisfying the inspector because we want to test the failure message, but collection is .\");\n }\n\n [Fact]\n public void An_empty_collection_should_succeed()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act / Assert\n collection.Should().AllSatisfy(x => x.Should().Be(1));\n }\n\n [Fact]\n public void All_items_satisfying_inspector_should_succeed()\n {\n // Arrange\n Customer[] collection = [new Customer { Age = 21, Name = \"John\" }, new Customer { Age = 21, Name = \"Jane\" }];\n\n // Act / Assert\n collection.Should().AllSatisfy(x => x.Age.Should().Be(21));\n }\n\n [Fact]\n public void Any_items_not_satisfying_inspector_should_throw()\n {\n // Arrange\n CustomerWithItems[] customers =\n [\n new CustomerWithItems { Age = 21, Items = [1, 2] },\n new CustomerWithItems { Age = 22, Items = [3] }\n ];\n\n // Act\n Action act = () => customers.Should()\n .AllSatisfy(\n customer =>\n {\n customer.Age.Should().BeLessThan(21);\n\n customer.Items.Should()\n .AllSatisfy(item => item.Should().Be(3));\n },\n \"because we want to test {0}\",\n \"nested assertions\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"\"\"\n Expected customers to contain only items satisfying the inspector because we want to test nested assertions:\n *At index 0:\n *Expected customer.Age to be less than 21, but found 21\n *Expected customer.Items to contain only items satisfying the inspector:\n *At index 0:\n *Expected item to be 3, but found 1\n *At index 1:\n *Expected item to be 3, but found 2\n *At index 1:\n *Expected customer.Age to be less than 21, but found 22 (difference of 1)\n \"\"\");\n }\n\n [Fact]\n public void Inspector_message_that_is_not_reformatable_should_not_throw()\n {\n // Arrange\n byte[][] subject = [[1]];\n\n // Act\n Action act = () => subject.Should().AllSatisfy(e => e.Should().BeEquivalentTo(new byte[] { 2, 3, 4 }));\n\n // Assert\n act.Should().NotThrow();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/XUnit2.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing Xunit;\n\nnamespace XUnit2.Specs;\n\npublic class FrameworkSpecs\n{\n [Fact]\n public void When_xunit2_is_used_it_should_throw_xunit_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"Xunit.Sdk.XunitException\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeLessThan.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeLessThan\n {\n [Fact]\n public void When_a_value_is_less_than_greater_value_it_should_not_throw()\n {\n // Arrange\n int value = 1;\n int greaterValue = 2;\n\n // Act / Assert\n value.Should().BeLessThan(greaterValue);\n }\n\n [Fact]\n public void When_a_value_is_less_than_smaller_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act\n Action act = () => value.Should().BeLessThan(smallerValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_less_than_same_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int sameValue = 2;\n\n // Act\n Action act = () => value.Should().BeLessThan(sameValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_less_than_smaller_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act\n Action act = () => value.Should().BeLessThan(smallerValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be less than 1 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_another_float()\n {\n // Act\n Action act = () => float.NaN.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_can_never_be_less_than_NaN()\n {\n // Act\n Action act = () => 3.4F.Should().BeLessThan(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_another_double()\n {\n // Act\n Action act = () => double.NaN.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_less_than_NaN()\n {\n // Act\n Action act = () => 3.4D.Should().BeLessThan(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_less_than_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Theory]\n [InlineData(5, -1)]\n [InlineData(10, 5)]\n [InlineData(10, -1)]\n public void To_test_the_remaining_paths_for_difference_on_int(int subject, int expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeLessThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5L, -1L)]\n [InlineData(10L, 5L)]\n [InlineData(10L, -1L)]\n public void To_test_the_remaining_paths_for_difference_on_long(long subject, long expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeLessThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeSubsetOf.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeSubsetOf specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeSubsetOf\n {\n [Fact]\n public void When_collection_is_subset_of_a_specified_collection_it_should_not_throw()\n {\n // Arrange\n int[] subset = [1, 2];\n int[] superset = [1, 2, 3];\n\n // Act / Assert\n subset.Should().BeSubsetOf(superset);\n }\n\n [Fact]\n public void When_collection_is_not_a_subset_of_another_it_should_throw_with_the_reason()\n {\n // Arrange\n int[] subset = [1, 2, 3, 6];\n int[] superset = [1, 2, 4, 5];\n\n // Act\n Action act = () => subset.Should().BeSubsetOf(superset, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subset to be a subset of {1, 2, 4, 5} because we want to test the failure message, \" +\n \"but items {3, 6} are not part of the superset.\");\n }\n\n [Fact]\n public void When_an_empty_collection_is_tested_against_a_superset_it_should_succeed()\n {\n // Arrange\n int[] subset = [];\n int[] superset = [1, 2, 4, 5];\n\n // Act / Assert\n subset.Should().BeSubsetOf(superset);\n }\n\n [Fact]\n public void When_a_subset_is_tested_against_a_null_superset_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n int[] subset = [1, 2, 3];\n int[] superset = null;\n\n // Act\n Action act = () => subset.Should().BeSubsetOf(superset);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify a subset against a collection.*\");\n }\n\n [Fact]\n public void When_a_set_is_expected_to_be_not_a_subset_it_should_succeed()\n {\n // Arrange\n int[] subject = [1, 2, 4];\n int[] otherSet = [1, 2, 3];\n\n // Act / Assert\n subject.Should().NotBeSubsetOf(otherSet);\n }\n }\n\n public class NotBeSubsetOf\n {\n [Fact]\n public void When_an_empty_set_is_not_supposed_to_be_a_subset_of_another_set_it_should_throw()\n {\n // Arrange\n int[] subject = [];\n int[] otherSet = [1, 2, 3];\n\n // Act\n Action act = () => subject.Should().NotBeSubsetOf(otherSet);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect subject {empty} to be a subset of {1, 2, 3}.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_is_not_subset_of_a_superset_collection()\n {\n // Arrange\n int[] subject = [1, 2];\n int[] otherSet = [1, 2, 3];\n\n // Act\n Action act = () => subject.Should().NotBeSubsetOf(otherSet, \"because I'm {0}\", \"mistaken\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect subject {1, 2} to be a subset of {1, 2, 3} because I'm mistaken.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_subset_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().BeSubsetOf(collection1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be a subset of {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_subset_against_same_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n var collection1 = collection;\n\n // Act\n Action act = () => collection.Should().NotBeSubsetOf(collection1,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect*to be a subset of*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_subset_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotBeSubsetOf([1, 2, 3], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert a collection against a subset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/BooleanAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class BooleanAssertions\n : BooleanAssertions\n{\n public BooleanAssertions(bool? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class BooleanAssertions\n where TAssertions : BooleanAssertions\n{\n public BooleanAssertions(bool? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public bool? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeFalse([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == false)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:boolean} to be {0}{reason}, but found {1}.\", false, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeTrue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:boolean} to be {0}{reason}, but found {1}.\", true, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is equal to the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(bool expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:boolean} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is not equal to the specified value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(bool unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:boolean} not to be {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value implies the specified value.\n /// \n /// The right hand side of the implication\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Imply(bool consequent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n bool? antecedent = Subject;\n\n CurrentAssertionChain\n .ForCondition(antecedent is not null)\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:antecedent} ({0}) to imply consequent ({1}){reason}, \", antecedent, consequent,\n chain => chain\n .FailWith(\"but found null.\")\n .Then\n .ForCondition(!antecedent.Value || consequent)\n .FailWith(\"but it did not.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Streams/StreamAssertionSpecs.cs", "using System;\nusing System.IO;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Streams;\n\npublic class StreamAssertionSpecs\n{\n public class BeWritable\n {\n [Fact]\n public void When_having_a_writable_stream_be_writable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Writable = true };\n\n // Act / Assert\n stream.Should().BeWritable();\n }\n\n [Fact]\n public void When_having_a_non_writable_stream_be_writable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Writable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeWritable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be writable *failure message*, but it was not.\");\n }\n\n [Fact]\n public void When_null_be_writable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeWritable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be writable *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeWritable\n {\n [Fact]\n public void When_having_a_non_writable_stream_be_not_writable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Writable = false };\n\n // Act / Assert\n stream.Should().NotBeWritable();\n }\n\n [Fact]\n public void When_having_a_writable_stream_be_not_writable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Writable = true };\n\n // Act\n Action act = () =>\n stream.Should().NotBeWritable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be writable *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_writable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeWritable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be writable *failure message*, but found a reference.\");\n }\n }\n\n public class BeSeekable\n {\n [Fact]\n public void When_having_a_seekable_stream_be_seekable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true };\n\n // Act / Assert\n stream.Should().BeSeekable();\n }\n\n [Fact]\n public void When_having_a_non_seekable_stream_be_seekable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeSeekable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be seekable *failure message*, but it was not.\");\n }\n\n [Fact]\n public void When_null_be_seekable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeSeekable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be seekable *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeSeekable\n {\n [Fact]\n public void When_having_a_non_seekable_stream_be_not_seekable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = false };\n\n // Act / Assert\n stream.Should().NotBeSeekable();\n }\n\n [Fact]\n public void When_having_a_seekable_stream_be_not_seekable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true };\n\n // Act\n Action act = () =>\n stream.Should().NotBeSeekable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be seekable *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_seekable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeSeekable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be seekable *failure message*, but found a reference.\");\n }\n }\n\n public class BeReadable\n {\n [Fact]\n public void When_having_a_readable_stream_be_readable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = true };\n\n // Act / Assert\n stream.Should().BeReadable();\n }\n\n [Fact]\n public void When_having_a_non_readable_stream_be_readable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeReadable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be readable *failure message*, but it was not.\");\n }\n\n [Fact]\n public void When_null_be_readable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeReadable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be readable *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeReadable\n {\n [Fact]\n public void When_having_a_non_readable_stream_be_not_readable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = false };\n\n // Act / Assert\n stream.Should().NotBeReadable();\n }\n\n [Fact]\n public void When_having_a_readable_stream_be_not_readable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = true };\n\n // Act\n Action act = () =>\n stream.Should().NotBeReadable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be readable *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_readable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeReadable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be readable *failure message*, but found a reference.\");\n }\n }\n\n public class HavePosition\n {\n [Fact]\n public void When_a_stream_has_the_expected_position_it_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, Position = 10 };\n\n // Act / Assert\n stream.Should().HavePosition(10);\n }\n\n [Fact]\n public void When_a_stream_has_the_unexpected_position_it_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, Position = 1 };\n\n // Act\n Action act = () =>\n stream.Should().HavePosition(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream to be 10* *failure message*, but it was 1*.\");\n }\n\n [Fact]\n public void When_null_have_position_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().HavePosition(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream to be 10* *failure message*, but found a reference.\");\n }\n\n [Theory]\n [MemberData(nameof(GetPositionExceptions), MemberType = typeof(StreamAssertionSpecs))]\n public void When_a_throwing_stream_should_have_a_position_it_should_fail(Exception exception)\n {\n // Arrange\n using var stream = new ExceptingStream(exception);\n\n // Act\n Action act = () =>\n stream.Should().HavePosition(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream to be 10* *failure message*, \" +\n \"but it failed with*GetPositionExceptionMessage*\");\n }\n }\n\n public class NotHavePosition\n {\n [Fact]\n public void When_a_stream_does_not_have_an_unexpected_position_it_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, Position = 1 };\n\n // Act / Assert\n stream.Should().NotHavePosition(10);\n }\n\n [Fact]\n public void When_a_stream_does_have_the_unexpected_position_it_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, Position = 10 };\n\n // Act\n Action act = () =>\n stream.Should().NotHavePosition(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream not to be 10* *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_have_position_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotHavePosition(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream not to be 10* *failure message*, but found a reference.\");\n }\n\n [Theory]\n [MemberData(nameof(GetPositionExceptions), MemberType = typeof(StreamAssertionSpecs))]\n public void When_a_throwing_stream_should_not_have_a_position_it_should_fail(Exception exception)\n {\n // Arrange\n using var stream = new ExceptingStream(exception);\n\n // Act\n Action act = () =>\n stream.Should().NotHavePosition(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream not to be 10* *failure message*, \" +\n \"but it failed with*GetPositionExceptionMessage*\");\n }\n }\n\n public static TheoryData GetPositionExceptions => new()\n {\n // https://docs.microsoft.com/en-us/dotnet/api/system.io.stream.position#exceptions\n new IOException(\"GetPositionExceptionMessage\"),\n new NotSupportedException(\"GetPositionExceptionMessage\"),\n new ObjectDisposedException(\"GetPositionExceptionMessage\")\n };\n\n public class HaveLength\n {\n [Fact]\n public void When_a_stream_has_the_expected_length_it_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, WithLength = 10 };\n\n // Act / Assert\n stream.Should().HaveLength(10);\n }\n\n [Fact]\n public void When_a_stream_has_an_unexpected_length_it_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, WithLength = 1 };\n\n // Act\n Action act = () =>\n stream.Should().HaveLength(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream to be 10* *failure message*, but it was 1*.\");\n }\n\n [Fact]\n public void When_null_have_length_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().HaveLength(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream to be 10* *failure message*, but found a reference.\");\n }\n\n [Theory]\n [MemberData(nameof(GetLengthExceptions), MemberType = typeof(StreamAssertionSpecs))]\n public void When_a_throwing_stream_should_have_a_length_it_should_fail(Exception exception)\n {\n // Arrange\n using var stream = new ExceptingStream(exception);\n\n // Act\n Action act = () =>\n stream.Should().HaveLength(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream to be 10* *failure message*, \" +\n \"but it failed with*GetLengthExceptionMessage*\");\n }\n }\n\n public class NotHaveLength\n {\n [Fact]\n public void When_a_stream_does_not_have_an_unexpected_length_it_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, WithLength = 1 };\n\n // Act / Assert\n stream.Should().NotHaveLength(10);\n }\n\n [Fact]\n public void When_a_stream_does_have_the_unexpected_length_it_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, WithLength = 10 };\n\n // Act\n Action act = () =>\n stream.Should().NotHaveLength(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream not to be 10* *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_have_length_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotHaveLength(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream not to be 10* *failure message*, but found a reference.\");\n }\n\n [Theory]\n [MemberData(nameof(GetLengthExceptions), MemberType = typeof(StreamAssertionSpecs))]\n public void When_a_throwing_stream_should_not_have_a_length_it_should_fail(Exception exception)\n {\n // Arrange\n using var stream = new ExceptingStream(exception);\n\n // Act\n Action act = () =>\n stream.Should().NotHaveLength(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream not to be 10* *failure message*, \" +\n \"but it failed with*GetLengthExceptionMessage*\");\n }\n }\n\n public static TheoryData GetLengthExceptions => new()\n {\n // https://docs.microsoft.com/en-us/dotnet/api/system.io.stream.length#exceptions\n new IOException(\"GetLengthExceptionMessage\"),\n new NotSupportedException(\"GetLengthExceptionMessage\"),\n new ObjectDisposedException(\"GetLengthExceptionMessage\")\n };\n\n public class BeReadOnly\n {\n [Fact]\n public void When_having_a_readonly_stream_be_read_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = false };\n\n // Act / Assert\n stream.Should().BeReadOnly();\n }\n\n [Fact]\n public void When_having_a_writable_stream_be_read_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = true };\n\n // Act\n Action act = () =>\n stream.Should().BeReadOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be read-only *failure message*, but it was writable or not readable.\");\n }\n\n [Fact]\n public void When_having_a_non_readable_stream_be_read_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeReadOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be read-only *failure message*, but it was writable or not readable.\");\n }\n\n [Fact]\n public void When_null_be_read_only_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeReadOnly(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be read-only *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeReadOnly\n {\n [Fact]\n public void When_having_a_non_readable_stream_be_not_read_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = false };\n\n // Act / Assert\n stream.Should().NotBeReadOnly();\n }\n\n [Fact]\n public void When_having_a_writable_stream_be_not_read_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = true };\n\n // Act / Assert\n stream.Should().NotBeReadOnly();\n }\n\n [Fact]\n public void When_having_a_readonly_stream_be_not_read_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = false };\n\n // Act\n Action act = () =>\n stream.Should().NotBeReadOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be read-only *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_read_only_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeReadOnly(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be read-only *failure message*, but found a reference.\");\n }\n }\n\n public class BeWriteOnly\n {\n [Fact]\n public void When_having_a_writeonly_stream_be_write_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = true };\n\n // Act / Assert\n stream.Should().BeWriteOnly();\n }\n\n [Fact]\n public void When_having_a_readable_stream_be_write_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = true };\n\n // Act\n Action act = () =>\n stream.Should().BeWriteOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be write-only *failure message*, but it was readable or not writable.\");\n }\n\n [Fact]\n public void When_having_a_non_writable_stream_be_write_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeWriteOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be write-only *failure message*, but it was readable or not writable.\");\n }\n\n [Fact]\n public void When_null_be_write_only_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeWriteOnly(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be write-only *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeWriteOnly\n {\n [Fact]\n public void When_having_a_non_writable_stream_be_not_write_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = false };\n\n // Act / Assert\n stream.Should().NotBeWriteOnly();\n }\n\n [Fact]\n public void When_having_a_readable_stream_be_not_write_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = true };\n\n // Act / Assert\n stream.Should().NotBeWriteOnly();\n }\n\n [Fact]\n public void When_having_a_writeonly_stream_be_not_write_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = true };\n\n // Act\n Action act = () =>\n stream.Should().NotBeWriteOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be write-only *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_write_only_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeWriteOnly(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be write-only *failure message*, but found a reference.\");\n }\n }\n}\n\ninternal class ExceptingStream : Stream\n{\n private readonly Exception exception;\n\n public ExceptingStream(Exception exception)\n {\n this.exception = exception;\n }\n\n public override bool CanRead => true;\n\n public override bool CanSeek => true;\n\n public override bool CanWrite => true;\n\n public override long Length => throw exception;\n\n public override long Position\n {\n get => throw exception;\n set => throw new NotImplementedException();\n }\n\n public override void Flush() => throw new NotImplementedException();\n\n public override int Read(byte[] buffer, int offset, int count) => throw new NotImplementedException();\n\n public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException();\n\n public override void SetLength(long value) => throw new NotImplementedException();\n\n public override void Write(byte[] buffer, int offset, int count) => throw new NotImplementedException();\n}\n\ninternal class TestStream : Stream\n{\n public bool Readable { private get; set; }\n\n public bool Seekable { private get; set; }\n\n public bool Writable { private get; set; }\n\n public long WithLength { private get; set; }\n\n public override bool CanRead => Readable;\n\n public override bool CanSeek => Seekable;\n\n public override bool CanWrite => Writable;\n\n public override long Length => WithLength;\n\n public override long Position { get; set; }\n\n public override void Flush() => throw new NotImplementedException();\n\n public override int Read(byte[] buffer, int offset, int count) => throw new NotImplementedException();\n\n public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException();\n\n public override void SetLength(long value) => throw new NotImplementedException();\n\n public override void Write(byte[] buffer, int offset, int count) => throw new NotImplementedException();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/TestFrameworkFactory.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Configuration;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Determines the test framework, either by scanning the current app domain for known test framework assemblies or by\n/// passing the framework name directly.\n/// \ninternal static class TestFrameworkFactory\n{\n private static readonly Dictionary Frameworks = new()\n {\n [TestFramework.MSpec] = new MSpecFramework(),\n [TestFramework.NUnit] = new NUnitTestFramework(),\n [TestFramework.MsTest] = new MSTestFrameworkV2(),\n\n // Keep TUnitFramework and XUnitTestFramework last as they use a try/catch approach\n [TestFramework.TUnit] = new TUnitFramework(),\n [TestFramework.XUnit2] = new XUnitTestFramework(\"xunit.assert\"),\n [TestFramework.XUnit3] = new XUnitTestFramework(\"xunit.v3.assert\"),\n };\n\n public static ITestFramework GetFramework(TestFramework? testFrameWork)\n {\n ITestFramework framework = null;\n\n if (testFrameWork is not null)\n {\n framework = AttemptToDetectUsingSetting((TestFramework)testFrameWork);\n }\n\n framework ??= AttemptToDetectUsingDynamicScanning();\n\n return framework ?? new FallbackTestFramework();\n }\n\n private static ITestFramework AttemptToDetectUsingSetting(TestFramework framework)\n {\n if (!Frameworks.TryGetValue(framework, out ITestFramework implementation))\n {\n string frameworks = string.Join(\", \", Frameworks.Keys);\n var message =\n $\"AwesomeAssertions was configured to use the test framework '{framework}' but this is not supported. \" +\n $\"Please use one of the supported frameworks: {frameworks}.\";\n\n throw new InvalidOperationException(message);\n }\n\n if (!implementation.IsAvailable)\n {\n string frameworks = string.Join(\", \", Frameworks.Keys);\n\n var innerMessage = implementation is LateBoundTestFramework lateBoundTestFramework\n ? $\"the required assembly '{lateBoundTestFramework.AssemblyName}' could not be found\"\n : \"it could not be found\";\n\n var message =\n $\"AwesomeAssertions was configured to use the test framework '{framework}' but {innerMessage}. \" +\n $\"Please use one of the supported frameworks: {frameworks}.\";\n\n throw new InvalidOperationException(message);\n }\n\n return implementation;\n }\n\n private static ITestFramework AttemptToDetectUsingDynamicScanning()\n {\n return Frameworks.Values.FirstOrDefault(framework => framework.IsAvailable);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AssertionFailureSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class AssertionFailureSpecs\n{\n private static readonly string AssertionsTestSubClassName = typeof(AssertionsTestSubClass).Name;\n\n [Fact]\n public void When_reason_starts_with_because_it_should_not_do_anything()\n {\n // Arrange\n var assertions = new AssertionsTestSubClass();\n\n // Act\n Action action = () =>\n assertions.AssertFail(\"because {0} should always fail.\", AssertionsTestSubClassName);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected it to fail because AssertionsTestSubClass should always fail.\");\n }\n\n [Fact]\n public void When_reason_does_not_start_with_because_it_should_be_added()\n {\n // Arrange\n var assertions = new AssertionsTestSubClass();\n\n // Act\n Action action = () =>\n assertions.AssertFail(\"{0} should always fail.\", AssertionsTestSubClassName);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected it to fail because AssertionsTestSubClass should always fail.\");\n }\n\n [Fact]\n public void When_reason_starts_with_because_but_is_prefixed_with_blanks_it_should_not_do_anything()\n {\n // Arrange\n var assertions = new AssertionsTestSubClass();\n\n // Act\n Action action = () =>\n assertions.AssertFail(\"\\r\\nbecause {0} should always fail.\", AssertionsTestSubClassName);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected it to fail\\r\\nbecause AssertionsTestSubClass should always fail.\");\n }\n\n [Fact]\n public void When_reason_does_not_start_with_because_but_is_prefixed_with_blanks_it_should_add_because_after_the_blanks()\n {\n // Arrange\n var assertions = new AssertionsTestSubClass();\n\n // Act\n Action action = () =>\n assertions.AssertFail(\"\\r\\n{0} should always fail.\", AssertionsTestSubClassName);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected it to fail\\r\\nbecause AssertionsTestSubClass should always fail.\");\n }\n\n internal class AssertionsTestSubClass\n {\n private readonly AssertionChain assertionChain = AssertionChain.GetOrCreate();\n\n public void AssertFail(string because, params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected it to fail{reason}\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/ThrowAssertionsSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class ThrowAssertionsSpecs\n{\n [Fact]\n public void When_subject_throws_expected_exception_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw();\n\n // Act / Assert\n testSubject.Invoking(x => x.Do()).Should().Throw();\n }\n\n [Fact]\n public void When_func_throws_expected_exception_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw();\n\n // Act / Assert\n testSubject.Invoking(x => x.Return()).Should().Throw();\n }\n\n [Fact]\n public void When_action_throws_expected_exception_it_should_not_do_anything()\n {\n // Arrange\n var act = new Action(() => throw new InvalidOperationException(\"Some exception\"));\n\n // Act / Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_does_not_throw_exception_but_one_was_expected_it_should_throw_with_clear_description()\n {\n try\n {\n Does testSubject = Does.NotThrow();\n\n testSubject.Invoking(x => x.Do()).Should().Throw();\n\n throw new XunitException(\"Should().Throw() did not throw\");\n }\n catch (XunitException ex)\n {\n ex.Message.Should().Be(\n \"Expected a to be thrown, but no exception was thrown.\");\n }\n }\n\n [Fact]\n public void When_func_does_not_throw_exception_but_one_was_expected_it_should_throw_with_clear_description()\n {\n try\n {\n Does testSubject = Does.NotThrow();\n\n testSubject.Invoking(x => x.Return()).Should().Throw();\n\n throw new XunitException(\"Should().Throw() did not throw\");\n }\n catch (XunitException ex)\n {\n ex.Message.Should().Be(\n \"Expected a to be thrown, but no exception was thrown.\");\n }\n }\n\n [Fact]\n public void When_func_does_not_throw_it_should_be_chainable()\n {\n // Arrange\n Does testSubject = Does.NotThrow();\n\n // Act / Assert\n testSubject.Invoking(x => x.Return()).Should().NotThrow()\n .Which.Should().Be(42);\n }\n\n [Fact]\n public void When_action_does_not_throw_exception_but_one_was_expected_it_should_throw_with_clear_description()\n {\n try\n {\n var act = new Action(() => { });\n\n act.Should().Throw();\n\n throw new XunitException(\"Should().Throw() did not throw\");\n }\n catch (XunitException ex)\n {\n ex.Message.Should().Be(\n \"Expected a to be thrown, but no exception was thrown.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainInConsecutiveOrder.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]ContainInOrder specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class ContainInConsecutiveOrder\n {\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_explicit_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_the_second_collection_contains_just_1_item_included_in_the_first_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(2);\n }\n\n [Fact]\n public void\n When_the_first_collection_contains_a_partial_duplicate_sequence_at_the_start_without_affecting_the_explicit_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 3, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_explicit_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(1, 2, 1, 2, 12, 2, 2);\n }\n\n [Fact]\n public void When_checking_for_an_empty_list_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder();\n }\n\n [Fact]\n public void When_collection_contains_null_value_it_should_not_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(1, null, 2, \"string\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_but_not_in_the_same_explicit_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n Action act = () => collection.Should().ContainInConsecutiveOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 2, 3} to contain items {1, 2, 3} in order, but 3 (index 2) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_the_second_collection_contains_just_1_item_not_included_in_the_first_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n Action act = () => collection.Should().ContainInConsecutiveOrder(4);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 2, 3} to contain items {4} in order, but 4 (index 0) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_end_of_first_collection_is_a_partial_match_of_second_at_end_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 3, 1, 2];\n\n // Act / Assert\n Action act = () => collection.Should().ContainInConsecutiveOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 3, 1, 2} to contain items {1, 2, 3} in order, but 3 (index 2) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 3, 12, 2, 2];\n\n // Act\n Action act = () => collection.Should().ContainInConsecutiveOrder(1, 2, 1, 1, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 2, 3, 12, 2, 2} to contain items {1, 2, 1, 1, 2} in order, but 1 (index 3) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInConsecutiveOrder([3, 1], \"because we said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain items {3, 1} in order because we said so, but 1 (index 1) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInConsecutiveOrder([4, 1], \"we failed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain items {4, 1} in order because we failed, \" +\n \"but 4 (index 0) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_ordered_containment_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInConsecutiveOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify ordered containment against a collection.*\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n collection.Should()\n .ContainInConsecutiveOrder([4], \"because we're checking how it reacts to a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain {4} in order because we're checking how it reacts to a null subject, but found .\");\n }\n }\n\n public class NotContainInConsecutiveOrder\n {\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(2, 1);\n }\n\n [Fact]\n public void When_the_second_collection_contains_just_1_item_not_included_in_the_first_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(4);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(4, 1);\n }\n\n [Fact]\n public void When_checking_for_an_empty_list_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder();\n }\n\n [Fact]\n public void When_a_collection_contains_less_items_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 3, 12, 2, 2];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(1, 2, 1, 1, 2);\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_not_in_the_same_explicit_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 2, 3];\n\n // Act\n collection.Should().NotContainInConsecutiveOrder([1, 2, 3], \"that's what we expect\");\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(4);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_not_contain_in_order_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainInConsecutiveOrder([1, 2, 3], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_collection_and_contains_contain_the_same_items_in_the_same_order_with_null_value_it_should_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(1, null, 2, \"string\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, , 2, \\\"string\\\"} to not contain items {1, , 2, \\\"string\\\"} in consecutive order, \" +\n \"but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_the_second_collection_contains_just_1_item_included_in_the_first_it_should_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, , 2, \\\"string\\\"} to not contain items {2} in consecutive order, \" +\n \"but items appeared in order ending at index 2.\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3, 2} to not contain items {1, 2, 3} in consecutive order, \" +\n \"but items appeared in order ending at index 2.\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_not_at_start_without_affecting_the_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 3, 4, 5, 1, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 2, 3, 4, 5, 1, 2} to not contain items {1, 2, 3} in consecutive order, \" +\n \"but items appeared in order ending at index 4.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(1, 2, 1, 2, 12, 2, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 2, 12, 2, 2} to not contain items {1, 2, 1, 2, 12, 2, 2} in consecutive order, \" +\n \"but items appeared in order ending at index 6.\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_absence_of_ordered_containment_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment against a collection.*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeInAscendingOrder.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeInAscendingOrder specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeInAscendingOrder\n {\n [Fact]\n public void When_asserting_a_null_collection_to_be_in_ascending_order_it_should_throw()\n {\n // Arrange\n List result = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n result.Should().BeInAscendingOrder();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*but found *\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_ascendingly_ordered_collection_are_ordered_ascending_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ascendingly_ordered_collection_are_ordered_ascending_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_unordered_collection_are_ordered_ascending_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 6, 12, 15, 12, 17, 26];\n\n // Act\n Action action = () => collection.Should().BeInAscendingOrder(\"because numbers are ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to be in ascending order because numbers are ordered,\" +\n \" but found {1, 6, 12, 15, 12, 17, 26} where item at index 3 is in wrong order.\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_ascending_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 6, 12, 15, 12, 17, 26];\n\n // Act\n Action action = () => collection.Should().BeInAscendingOrder(Comparer.Default, \"because numbers are ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to be in ascending order because numbers are ordered,\" +\n \" but found {1, 6, 12, 15, 12, 17, 26} where item at index 3 is in wrong order.\");\n }\n\n [Fact]\n public void Items_can_be_ordered_by_the_identity_function()\n {\n // Arrange\n int[] collection = [1, 2];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(x => x);\n }\n\n [Fact]\n public void When_asserting_empty_collection_with_no_parameters_ordered_in_ascending_it_should_succeed()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder();\n }\n\n [Fact]\n public void When_asserting_empty_collection_by_property_expression_ordered_in_ascending_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(o => o.Number);\n }\n\n [Fact]\n public void When_asserting_single_element_collection_with_no_parameters_ordered_in_ascending_it_should_succeed()\n {\n // Arrange\n int[] collection = [42];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder();\n }\n\n [Fact]\n public void When_asserting_single_element_collection_by_property_expression_ordered_in_ascending_it_should_succeed()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(o => o.Number);\n }\n\n [Fact]\n public void Can_use_a_cast_expression_in_the_ordering_expression()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act & Assert\n collection.Should().BeInAscendingOrder(o => (float)o.Number);\n }\n\n [Fact]\n public void Can_use_an_index_into_a_list_in_the_ordering_expression()\n {\n // Arrange\n List[] collection =\n [\n [new() { Text = \"a\", Number = 1 }]\n ];\n\n // Act & Assert\n collection.Should().BeInAscendingOrder(o => o[0].Number);\n }\n\n [Fact]\n public void Can_use_an_index_into_an_array_in_the_ordering_expression()\n {\n // Arrange\n SomeClass[][] collection =\n [\n [new SomeClass { Text = \"a\", Number = 1 }]\n ];\n\n // Act & Assert\n collection.Should().BeInAscendingOrder(o => o[0].Number);\n }\n\n [Fact]\n public void Unsupported_ordering_expressions_are_invalid()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.Number > 1);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Expression <*> cannot be used to select a member.*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_ascending_using_the_specified_property_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.Text, \"it should be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*ordered*Text*should be sorted*a*b*c*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_ascending_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act\n Action act = () =>\n collection.Should().BeInAscendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase, \"it should be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*ordered*Text*should be sorted*a*b*c*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ascendingly_ordered_collection_are_ordered_ascending_using_the_specified_property_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(o => o.Numeric);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ascendingly_ordered_collection_are_ordered_ascending_using_the_specified_property_and_the_given_comparer_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(o => o.Numeric, Comparer.Default);\n }\n\n [Fact]\n public void When_strings_are_in_ascending_order_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"alpha\", \"beta\", \"theta\"];\n\n // Act / Assert\n strings.Should().BeInAscendingOrder();\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_it_should_throw()\n {\n // Arrange\n string[] strings = [\"theta\", \"alpha\", \"beta\"];\n\n // Act\n Action act = () => strings.Should().BeInAscendingOrder(\"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*ascending*of reasons*index 0*\");\n }\n\n [Fact]\n public void When_strings_are_in_ascending_order_according_to_a_custom_comparer_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"alpha\", \"beta\", \"theta\"];\n\n // Act / Assert\n strings.Should().BeInAscendingOrder(new ByLastCharacterComparer());\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_according_to_a_custom_comparer_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"thomas\"];\n\n // Act\n Action act = () => strings.Should().BeInAscendingOrder(new ByLastCharacterComparer(), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*ascending*of reasons*index 1*\");\n }\n\n [Fact]\n public void When_strings_are_in_ascending_order_according_to_a_custom_lambda_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"alpha\", \"beta\", \"theta\"];\n\n // Act / Assert\n strings.Should().BeInAscendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]));\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_according_to_a_custom_lambda_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"thomas\"];\n\n // Act\n Action act = () =>\n strings.Should().BeInAscendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*ascending*of reasons*index 1*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_null_collection_are_ordered_using_the_specified_property_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.Text);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Text*found*null*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_null_collection_are_ordered_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(Comparer.Default);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*found*null*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_null_collection_are_ordered_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*Text*found*null*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_collection_are_ordered_and_the_specified_property_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder((Expression>)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert collection ordering without specifying a property*\")\n .WithParameterName(\"propertyExpression\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_collection_are_ordered_and_the_given_comparer_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(comparer: null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert collection ordering without specifying a comparer*\")\n .WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_ay_collection_are_ordered_using_an_invalid_property_expression_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.GetHashCode());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expression*o.GetHashCode()*cannot be used to select a member*\");\n }\n }\n\n public class NotBeInAscendingOrder\n {\n [Fact]\n public void When_asserting_a_null_collection_to_not_be_in_ascending_order_it_should_throw()\n {\n // Arrange\n List result = null;\n\n // Act\n Action act = () => result.Should().NotBeInAscendingOrder();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*but found *\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_unordered_collection_are_not_in_ascending_order_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 5, 3];\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_not_in_ascending_order_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 5, 3];\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_ascendingly_ordered_collection_are_not_in_ascending_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act\n Action action = () => collection.Should().NotBeInAscendingOrder(\"because numbers are not ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order because numbers are not ordered,\" +\n \" but found {1, 2, 2, 3}.\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ascendingly_ordered_collection_are_not_in_ascending_order_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act\n Action action = () =>\n collection.Should().NotBeInAscendingOrder(Comparer.Default, \"because numbers are not ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order because numbers are not ordered,\" +\n \" but found {1, 2, 2, 3}.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_by_property_expression_to_not_be_ordered_in_ascending_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.Number);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection {empty} to not be ordered \\\"by Number\\\" and not result in {empty}.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_with_no_parameters_not_be_ordered_in_ascending_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(\"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order because I say so, but found {empty}.\");\n }\n\n [Fact]\n public void When_asserting_single_element_collection_with_no_parameters_not_be_ordered_in_ascending_it_should_throw()\n {\n // Arrange\n int[] collection = [42];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order, but found {42}.\");\n }\n\n [Fact]\n public void\n When_asserting_single_element_collection_by_property_expression_to_not_be_ordered_in_ascending_it_should_throw()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.Number);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_ascending_ordered_collection_are_not_ordered_ascending_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(Comparer.Default, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order*should not be sorted*1*2*3*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_ascendingly_ordered_collection_are_not_ordered_ascending_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n int[] collection = [3, 2, 1];\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_ascending_ordered_collection_are_not_ordered_ascending_using_the_specified_property_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"a\", Numeric = 3 },\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 }\n };\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.Text, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*a*b*c*not be ordered*Text*should not be sorted*a*b*c*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ordered_collection_are_not_ordered_ascending_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"A\", Numeric = 1 },\n new { Text = \"b\", Numeric = 2 },\n new { Text = \"C\", Numeric = 3 }\n };\n\n // Act\n Action act = () =>\n collection.Should()\n .NotBeInAscendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*A*b*C*not be ordered*Text*should not be sorted*A*b*C*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_ascendingly_ordered_collection_are_not_ordered_ascending_using_the_specified_property_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 3 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 1 }\n };\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder(o => o.Numeric);\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_ascendingly_ordered_collection_are_not_ordered_ascending_using_the_specified_property_and_the_given_comparer_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 3 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 1 }\n };\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder(o => o.Numeric, Comparer.Default);\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"beta\", \"alpha\", \"theta\"];\n\n // Act / Assert\n strings.Should().NotBeInAscendingOrder();\n }\n\n [Fact]\n public void When_strings_are_in_ascending_order_unexpectedly_it_should_throw()\n {\n // Arrange\n string[] strings = [\"alpha\", \"beta\", \"theta\"];\n\n // Act\n Action act = () => strings.Should().NotBeInAscendingOrder(\"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*ascending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_according_to_a_custom_comparer_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"barbara\"];\n\n // Act / Assert\n strings.Should().NotBeInAscendingOrder(new ByLastCharacterComparer());\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_ascending_order_according_to_a_custom_comparer_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"thomas\", \"roy\"];\n\n // Act\n Action act = () => strings.Should().NotBeInAscendingOrder(new ByLastCharacterComparer(), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*ascending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_according_to_a_custom_lambda_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"thomas\"];\n\n // Act / Assert\n strings.Should().NotBeInAscendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]));\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_ascending_order_according_to_a_custom_lambda_it_should_throw()\n {\n // Arrange\n string[] strings = [\"barbara\", \"dennis\", \"roy\"];\n\n // Act\n Action act = () =>\n strings.Should().NotBeInAscendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*ascending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_null_collection_are_not_ordered_using_the_specified_property_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotBeInAscendingOrder(o => o.Text);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Text*found*null*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_null_collection_are_not_ordered_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotBeInAscendingOrder(Comparer.Default);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*found*null*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_null_collection_are_not_ordered_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Text*found*null*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_collection_are_not_ordered_and_the_specified_property_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder((Expression>)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert collection ordering without specifying a property*propertyExpression*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_collection_are_not_ordered_and_the_given_comparer_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(comparer: null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert collection ordering without specifying a comparer*comparer*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_ay_collection_are_not_ordered_using_an_invalid_property_expression_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.GetHashCode());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expression*o.GetHashCode()*cannot be used to select a member*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/IValueFormatter.cs", "namespace AwesomeAssertions.Formatting;\n\n/// \n/// Represents a strategy for formatting an arbitrary value into a human-readable string representation.\n/// \n/// \n/// Add custom formatters using .\n/// \npublic interface IValueFormatter\n{\n /// \n /// Indicates\n /// whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n bool CanHandle(object value);\n\n /// \n /// Returns a human-readable representation of .\n /// \n /// The value to format into a human-readable representation\n /// \n /// An object to write the textual representation to.\n /// \n /// \n /// Contains additional information that the implementation should take into account.\n /// \n /// \n /// Allows the formatter to recursively format any child objects.\n /// \n /// \n /// DO NOT CALL directly, but use \n /// instead. This will ensure cyclic dependencies are properly detected.\n /// Also, the may throw\n /// an that must be ignored by implementations of this interface.\n /// \n void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensibility/AssertionEngineInitializerAttribute.cs", "using System;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Extensibility;\n\n/// \n/// Can be added to an assembly so it gets a change to initialize Awesome Assertions before the first assertion happens.\n/// \n[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\npublic sealed class AssertionEngineInitializerAttribute : Attribute\n{\n private readonly string methodName;\n private readonly Type type;\n\n /// \n /// Defines the static void-returning and parameterless method that should be invoked before the first assertion happens.\n /// \n#pragma warning disable CA1019\n public AssertionEngineInitializerAttribute(Type type, string methodName)\n#pragma warning restore CA1019\n {\n this.type = type;\n this.methodName = methodName;\n }\n\n internal void Initialize()\n {\n type?.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static)?.Invoke(obj: null, parameters: null);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/GivenSelector.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents a chaining object returned from to continue the assertion using\n/// an object returned by a selector.\n/// \npublic class GivenSelector\n{\n private readonly AssertionChain assertionChain;\n private readonly T selector;\n\n internal GivenSelector(Func selector, AssertionChain assertionChain)\n {\n this.assertionChain = assertionChain;\n\n this.selector = assertionChain.Succeeded ? selector() : default;\n }\n\n public bool Succeeded => assertionChain.Succeeded;\n\n /// \n /// Specify the condition that must be satisfied upon the subject selected through a prior selector.\n /// \n /// \n /// If the assertion will be treated as successful and no exceptions will be thrown.\n /// \n /// \n /// The condition will not be evaluated if the prior assertion failed,\n /// nor will throw any exceptions.\n /// \n /// is .\n public GivenSelector ForCondition(Func predicate)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n if (assertionChain.Succeeded)\n {\n assertionChain.ForCondition(predicate(selector));\n }\n\n return this;\n }\n\n public GivenSelector ForConstraint(OccurrenceConstraint constraint, Func func)\n {\n Guard.ThrowIfArgumentIsNull(func);\n\n if (assertionChain.Succeeded)\n {\n assertionChain.ForConstraint(constraint, func(selector));\n }\n\n return this;\n }\n\n public GivenSelector Given(Func selector)\n {\n Guard.ThrowIfArgumentIsNull(selector);\n\n return new GivenSelector(() => selector(this.selector), assertionChain);\n }\n\n public ContinuationOfGiven FailWith(string message)\n {\n return FailWith(message, Array.Empty());\n }\n\n public ContinuationOfGiven FailWith(string message, params Func[] args)\n {\n if (assertionChain.PreviousAssertionSucceeded)\n {\n object[] mappedArguments = args.Select(a => a(selector)).ToArray();\n return FailWith(message, mappedArguments);\n }\n\n return new ContinuationOfGiven(this);\n }\n\n public ContinuationOfGiven FailWith(string message, params object[] args)\n {\n assertionChain.FailWith(message, args);\n return new ContinuationOfGiven(this);\n }\n\n public ContinuationOfGiven FailWith(Func message)\n {\n assertionChain.FailWith(message(selector));\n return new ContinuationOfGiven(this);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainSingle.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The ContainSingle specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n [Fact]\n public void When_injecting_a_null_predicate_into_ContainSingle_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().ContainSingle(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_a_collection_contains_a_single_item_matching_a_predicate_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n Expression> expression = item => item == 2;\n\n // Act / Assert\n collection.Should().ContainSingle(expression);\n }\n\n [Fact]\n public void When_asserting_an_empty_collection_contains_a_single_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n Expression> expression = item => item == 2;\n\n // Act\n Action act = () => collection.Should().ContainSingle(expression);\n\n // Assert\n string expectedMessage =\n \"Expected collection to contain a single item matching (item == 2), but the collection is empty.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_asserting_a_null_collection_contains_a_single_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n Expression> expression = item => item == 2;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainSingle(expression);\n };\n\n // Assert\n string expectedMessage =\n \"Expected collection to contain a single item matching (item == 2), but found .\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_non_empty_collection_does_not_contain_a_single_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 3];\n Expression> expression = item => item == 2;\n\n // Act\n Action act = () => collection.Should().ContainSingle(expression);\n\n // Assert\n string expectedMessage =\n \"Expected collection to contain a single item matching (item == 2), but no such item was found.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_non_empty_collection_contains_more_than_a_single_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 2, 2, 3];\n Expression> expression = item => item == 2;\n\n // Act\n Action act = () => collection.Should().ContainSingle(expression);\n\n // Assert\n string expectedMessage =\n \"Expected collection to contain a single item matching (item == 2), but 3 such items were found.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_single_item_matching_a_predicate_is_found_it_should_allow_continuation()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().ContainSingle(item => item == 2).Which.Should().BeGreaterThan(4);\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected collection[0]*greater*4*2*\");\n }\n\n [Fact]\n public void Chained_assertions_are_never_called_when_the_initial_assertion_failed()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainSingle(item => item == 4).Which.Should().BeGreaterThan(4);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to contain a single item matching (item == 4), but no such item was found.\");\n }\n\n [Fact]\n public void When_single_item_contains_brackets_it_should_format_them_properly()\n {\n // Arrange\n IEnumerable collection = [\"\"];\n\n // Act\n Action act = () => collection.Should().ContainSingle(item => item == \"{123}\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain a single item matching (item == \\\"{123}\\\"), but no such item was found.\");\n }\n\n [Fact]\n public void When_single_item_contains_string_interpolation_it_should_format_brackets_properly()\n {\n // Arrange\n IEnumerable collection = [\"\"];\n\n // Act\n Action act = () => collection.Should().ContainSingle(item => item == $\"{123}\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain a single item matching (item == \\\"123\\\"), but no such item was found.\");\n }\n\n [Fact]\n public void When_a_collection_contains_a_single_item_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [1];\n\n // Act / Assert\n collection.Should().ContainSingle();\n }\n\n [Fact]\n public void When_asserting_an_empty_collection_contains_a_single_item_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().ContainSingle(\"more is not allowed\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to contain a single item because more is not allowed, but the collection is empty.\");\n }\n\n [Fact]\n public void When_asserting_a_null_collection_contains_a_single_item_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainSingle(\"more is not allowed\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to contain a single item because more is not allowed, but found .\");\n }\n\n [Fact]\n public void When_non_empty_collection_does_not_contain_a_single_item_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 3];\n\n // Act\n Action act = () => collection.Should().ContainSingle();\n\n // Assert\n const string expectedMessage = \"Expected collection to contain a single item, but found {1, 3}.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_non_empty_collection_contains_more_than_a_single_item_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().ContainSingle();\n\n // Assert\n const string expectedMessage = \"Expected collection to contain a single item, but found {1, 2}.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_single_item_is_found_it_should_allow_continuation()\n {\n // Arrange\n IEnumerable collection = [3];\n\n // Act\n Action act = () => collection.Should().ContainSingle().Which.Should().BeGreaterThan(4);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection[0] to be greater than 4, but found 3.\");\n }\n\n [Fact]\n public void When_collection_is_IEnumerable_it_should_be_evaluated_only_once_with_predicate()\n {\n // Arrange\n IEnumerable collection = new OneTimeEnumerable(1);\n\n // Act / Assert\n collection.Should().ContainSingle(_ => true);\n }\n\n [Fact]\n public void When_collection_is_IEnumerable_it_should_be_evaluated_only_once()\n {\n // Arrange\n IEnumerable collection = new OneTimeEnumerable(1);\n\n // Act / Assert\n collection.Should().ContainSingle();\n }\n\n [Fact]\n public void When_an_assertion_fails_on_ContainSingle_succeeding_message_should_be_included()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var values = new List();\n values.Should().ContainSingle();\n values.Should().ContainSingle();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to contain a single item, but the collection is empty*\" +\n \"Expected*to contain a single item, but the collection is empty*\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateOnlyAssertions.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class DateOnlyAssertions : DateOnlyAssertions\n{\n public DateOnlyAssertions(DateOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class DateOnlyAssertions\n where TAssertions : DateOnlyAssertions\n{\n public DateOnlyAssertions(DateOnly? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public DateOnly? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateOnly expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateOnly? expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateOnly unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateOnly? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is before the specified value.\n /// \n /// The that the current value is expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeBefore(DateOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject < expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not before the specified value.\n /// \n /// The that the current value is not expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeBefore(DateOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or before the specified value.\n /// \n /// The that the current value is expected to be on or before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrBefore(DateOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject <= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be on or before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor before the specified value.\n /// \n /// The that the current value is not expected to be on nor before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrBefore(DateOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is after the specified value.\n /// \n /// The that the current value is expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAfter(DateOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject > expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not after the specified value.\n /// \n /// The that the current value is not expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAfter(DateOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or after the specified value.\n /// \n /// The that the current value is expected to be on or after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrAfter(DateOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject >= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be on or after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor after the specified value.\n /// \n /// The that the current value is expected not to be on nor after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrAfter(DateOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has the year.\n /// \n /// The expected year of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveYear(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the year part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject.Value.Year == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Year));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the year.\n /// \n /// The year that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveYear(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.HasValue)\n .FailWith(\"Did not expect the year part of {context:the date} to be {0}{reason}, but found a DateOnly.\",\n unexpected)\n .Then\n .ForCondition(Subject.Value.Year != unexpected)\n .FailWith(\"Did not expect the year part of {context:the date} to be {0}{reason}, but it was.\", unexpected,\n Subject.Value.Year);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the month.\n /// \n /// The expected month of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMonth(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the month part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateOnly.\")\n .Then\n .ForCondition(Subject.Value.Month == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Month));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the month.\n /// \n /// The month that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMonth(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the month part of {context:the date} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateOnly.\")\n .Then\n .ForCondition(Subject.Value.Month != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the day.\n /// \n /// The expected day of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveDay(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the day part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateOnly.\")\n .Then\n .ForCondition(Subject.Value.Day == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Day));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the day.\n /// \n /// The day that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveDay(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the day part of {context:the date} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateOnly.\")\n .Then\n .ForCondition(Subject.Value.Day != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateOnly?[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateOnly[] validValues)\n {\n return BeOneOf(validValues.Cast());\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOneOf(validValues.Cast(), because, becauseArgs);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeIn.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeIn\n {\n [Fact]\n public void When_asserting_subject_datetime_represents_its_own_kind_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00, DateTimeKind.Local);\n\n // Act / Assert\n subject.Should().BeIn(DateTimeKind.Local);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_represents_a_different_kind_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00, DateTimeKind.Local);\n\n // Act\n Action act = () => subject.Should().BeIn(DateTimeKind.Utc);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be in Utc, but found Local.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_represents_a_specific_kind_it_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n\n // Act\n Action act = () => subject.Should().BeIn(DateTimeKind.Utc);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be in Utc, but found a DateTime.\");\n }\n }\n\n public class NotBeIn\n {\n [Fact]\n public void Date_is_not_in_kind()\n {\n // Arrange\n DateTime subject = 5.January(2024).AsLocal();\n\n // Act / Assert\n subject.Should().NotBeIn(DateTimeKind.Utc);\n }\n\n [Fact]\n public void Date_is_in_kind_but_should_not()\n {\n // Arrange\n DateTime subject = 5.January(2024).AsLocal();\n\n // Act\n Action act = () => subject.Should().NotBeIn(DateTimeKind.Local);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect subject to be in Local, but it was.\");\n }\n\n [Fact]\n public void Date_is_null_on_kind_check()\n {\n // Arrange\n DateTime? subject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().NotBeIn(DateTimeKind.Utc);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not**\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Streams/StreamAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.IO;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Streams;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class StreamAssertions : StreamAssertions\n{\n public StreamAssertions(Stream stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class StreamAssertions : ReferenceTypeAssertions\n where TSubject : Stream\n where TAssertions : StreamAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public StreamAssertions(TSubject stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n protected override string Identifier => \"stream\";\n\n /// \n /// Asserts that the current is writable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeWritable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be writable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanWrite)\n .FailWith(\"Expected {context:stream} to be writable{reason}, but it was not.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not writable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeWritable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be writable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanWrite)\n .FailWith(\"Expected {context:stream} not to be writable{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is seekable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSeekable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be seekable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanSeek)\n .FailWith(\"Expected {context:stream} to be seekable{reason}, but it was not.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not seekable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSeekable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be seekable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanSeek)\n .FailWith(\"Expected {context:stream} not to be seekable{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is readable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeReadable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be readable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanRead)\n .FailWith(\"Expected {context:stream} to be readable{reason}, but it was not.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not readable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeReadable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be readable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanRead)\n .FailWith(\"Expected {context:stream} not to be readable{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the position.\n /// \n /// The expected position of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HavePosition(long expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the position of {context:stream} to be {0}{reason}, but found a reference.\",\n expected);\n\n if (assertionChain.Succeeded)\n {\n long position;\n\n try\n {\n position = Subject!.Position;\n }\n catch (Exception exception)\n when (exception is IOException or NotSupportedException or ObjectDisposedException)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the position of {context:stream} to be {0}{reason}, but it failed with:\"\n + Environment.NewLine + \"{1}\",\n expected, exception.Message);\n\n return new AndConstraint((TAssertions)this);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(position == expected)\n .FailWith(\"Expected the position of {context:stream} to be {0}{reason}, but it was {1}.\",\n expected, position);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have an position.\n /// \n /// The unexpected position of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHavePosition(long unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the position of {context:stream} not to be {0}{reason}, but found a reference.\",\n unexpected);\n\n if (assertionChain.Succeeded)\n {\n long position;\n\n try\n {\n position = Subject!.Position;\n }\n catch (Exception exception)\n when (exception is IOException or NotSupportedException or ObjectDisposedException)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the position of {context:stream} not to be {0}{reason}, but it failed with:\"\n + Environment.NewLine + \"{1}\",\n unexpected, exception.Message);\n\n return new AndConstraint((TAssertions)this);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(position != unexpected)\n .FailWith(\"Expected the position of {context:stream} not to be {0}{reason}, but it was.\",\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the length.\n /// \n /// The expected length of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveLength(long expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the length of {context:stream} to be {0}{reason}, but found a reference.\",\n expected);\n\n if (assertionChain.Succeeded)\n {\n long length;\n\n try\n {\n length = Subject!.Length;\n }\n catch (Exception exception)\n when (exception is IOException or NotSupportedException or ObjectDisposedException)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the length of {context:stream} to be {0}{reason}, but it failed with:\"\n + Environment.NewLine + \"{1}\",\n expected, exception.Message);\n\n return new AndConstraint((TAssertions)this);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(length == expected)\n .FailWith(\"Expected the length of {context:stream} to be {0}{reason}, but it was {1}.\",\n expected, length);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have an length.\n /// \n /// The unexpected length of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveLength(long unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the length of {context:stream} not to be {0}{reason}, but found a reference.\",\n unexpected);\n\n if (assertionChain.Succeeded)\n {\n long length;\n\n try\n {\n length = Subject!.Length;\n }\n catch (Exception exception)\n when (exception is IOException or NotSupportedException or ObjectDisposedException)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the length of {context:stream} not to be {0}{reason}, but it failed with:\"\n + Environment.NewLine + \"{1}\",\n unexpected, exception.Message);\n\n return new AndConstraint((TAssertions)this);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(length != unexpected)\n .FailWith(\"Expected the length of {context:stream} not to be {0}{reason}, but it was.\",\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is read-only.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeReadOnly([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be read-only{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanWrite && Subject.CanRead)\n .FailWith(\"Expected {context:stream} to be read-only{reason}, but it was writable or not readable.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not read-only.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeReadOnly([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be read-only{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanWrite || !Subject.CanRead)\n .FailWith(\"Expected {context:stream} not to be read-only{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is write-only.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeWriteOnly([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be write-only{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanWrite && !Subject.CanRead)\n .FailWith(\"Expected {context:stream} to be write-only{reason}, but it was readable or not writable.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not write-only.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeWriteOnly([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be write-only{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanWrite || Subject.CanRead)\n .FailWith(\"Expected {context:stream} not to be write-only{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.Equal.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class Equal\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_equal_to_the_same_collection()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection1.Should().Equal(collection2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_is_equal_to_the_same_list_of_elements()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().Equal(\"one\", \"two\", \"three\");\n }\n\n [Fact]\n public void When_all_items_match_according_to_a_predicate_it_should_succeed()\n {\n // Arrange\n var actual = new List { \"ONE\", \"TWO\", \"THREE\", \"FOUR\" };\n var expected = new List { \"One\", \"Two\", \"Three\", \"Four\" };\n\n // Act / Assert\n actual.Should().Equal(expected,\n (a, e) => string.Equals(a, e, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_an_empty_collection_is_compared_for_equality_to_a_non_empty_collection_it_should_throw()\n {\n // Arrange\n var collection1 = new string[0];\n IEnumerable collection2 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {\\\"one\\\", \\\"two\\\", \\\"three\\\"}, but found empty collection.\");\n }\n\n [Fact]\n public void When_any_item_does_not_match_according_to_a_predicate_it_should_throw()\n {\n // Arrange\n var actual = new List { \"ONE\", \"TWO\", \"THREE\", \"FOUR\" };\n var expected = new List { \"One\", \"Two\", \"Three\", \"Five\" };\n\n // Act\n Action action = () => actual.Should().Equal(expected,\n (a, e) => string.Equals(a, e, StringComparison.OrdinalIgnoreCase));\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Expected*equal to*, but*differs at index 3.\");\n }\n\n [Fact]\n public void When_injecting_a_null_comparer_it_should_throw()\n {\n // Arrange\n var actual = new List();\n var expected = new List();\n\n // Act\n Action action = () => actual.Should().Equal(expected, equalityComparison: null);\n\n // Assert\n action\n .Should().ThrowExactly()\n .WithParameterName(\"equalityComparison\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equal_but_expected_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable collection1 = null;\n\n // Act\n Action act = () =>\n collection.Should().Equal(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare collection with .*\")\n .WithParameterName(\"expectation\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equal_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () =>\n collection.Should().Equal(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be equal to {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_both_collections_are_null_it_should_succeed()\n {\n // Arrange\n IEnumerable nullColl = null;\n\n // Act / Assert\n nullColl.Should().Equal(null);\n }\n\n [Fact]\n public void When_two_collections_are_not_equal_because_one_item_differs_it_should_throw_using_the_reason()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"five\"];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {\\\"one\\\", \\\"two\\\", \\\"five\\\"} because we want to test the failure message, but {\\\"one\\\", \\\"two\\\", \\\"three\\\"} differs at index 2.\");\n }\n\n [Fact]\n public void\n When_two_collections_are_not_equal_because_the_actual_collection_contains_less_items_it_should_throw_using_the_reason()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\", \"four\"];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {\\\"one\\\", \\\"two\\\", \\\"three\\\", \\\"four\\\"} because we want to test the failure message, but {\\\"one\\\", \\\"two\\\", \\\"three\\\"} contains 1 item(s) less.\");\n }\n\n [Fact]\n public void\n When_two_collections_are_not_equal_because_the_actual_collection_contains_more_items_it_should_throw_using_the_reason()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\"];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {\\\"one\\\", \\\"two\\\"} because we want to test the failure message, but {\\\"one\\\", \\\"two\\\", \\\"three\\\"} contains 1 item(s) too many.\");\n }\n\n [Fact]\n public void When_two_collections_containing_nulls_are_equal_it_should_not_throw()\n {\n // Arrange\n var subject = new List { \"aaa\", null };\n var expected = new List { \"aaa\", null };\n\n // Act / Assert\n subject.Should().Equal(expected);\n }\n }\n\n public class NotEqual\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_not_equal_to_a_different_collection()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"three\", \"one\", \"two\"];\n\n // Act / Assert\n collection1.Should()\n .NotEqual(collection2);\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_but_both_collections_reference_the_same_object_it_should_throw()\n {\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = collection1;\n\n // Act\n Action act = () =>\n collection1.Should().NotEqual(collection2, \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collections not to be equal because we want to test the behaviour with same objects, but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_but_expected_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable collection1 = null;\n\n // Act\n Action act =\n () => collection.Should().NotEqual(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare collection with .*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_subject_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act =\n () => collection.Should().NotEqual(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collections not to be equal because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_two_equal_collections_are_not_expected_to_be_equal_it_should_report_a_clear_explanation()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection1.Should().NotEqual(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect collections {\\\"one\\\", \\\"two\\\", \\\"three\\\"} and {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to be equal because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_two_equal_collections_are_not_expected_to_be_equal_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection1.Should().NotEqual(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect collections {\\\"one\\\", \\\"two\\\", \\\"three\\\"} and {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to be equal.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/AsyncFunctionExceptionAssertionSpecs.cs", "// ReSharper disable AsyncVoidLambda\n\nusing System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n#if NET47\nusing AwesomeAssertions.Specs.Common;\n#endif\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class AsyncFunctionExceptionAssertionSpecs\n{\n [Fact]\n public void When_getting_the_subject_it_should_remain_unchanged()\n {\n // Arrange\n Func subject = () => Task.FromResult(42);\n\n // Act\n Action action = () => subject.Should().Subject.As().Should().BeSameAs(subject);\n\n // Assert\n action.Should().NotThrow(\"the Subject should remain the same\");\n }\n\n [Fact]\n public async Task When_subject_is_null_when_expecting_an_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().ThrowAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_subject_is_null_when_not_expecting_a_generic_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().NotThrowAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_subject_is_null_when_not_expecting_an_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().NotThrowAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_async_method_throws_an_empty_AggregateException_it_should_fail()\n {\n // Arrange\n Func act = () => throw new AggregateException();\n\n // Act\n Func act2 = () => act.Should().NotThrowAsync();\n\n // Assert\n await act2.Should().ThrowAsync();\n }\n\n [Collection(\"UIFacts\")]\n public partial class UIFacts\n {\n [UIFact]\n public async Task When_async_method_throws_an_empty_AggregateException_on_UI_thread_it_should_fail()\n {\n // Arrange\n Func act = () => throw new AggregateException();\n\n // Act\n Func act2 = () => act.Should().NotThrowAsync();\n\n // Assert\n await act2.Should().ThrowAsync();\n }\n }\n\n [Fact]\n public async Task When_async_method_throws_a_nested_AggregateException_it_should_provide_the_message()\n {\n // Arrange\n Func act = () => throw new AggregateException(new ArgumentException(\"That was wrong.\"));\n\n // Act & Assert\n await act.Should().ThrowAsync().WithMessage(\"That was wrong.\");\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task When_async_method_throws_a_nested_AggregateException_on_UI_thread_it_should_provide_the_message()\n {\n // Arrange\n Func act = () => throw new AggregateException(new ArgumentException(\"That was wrong.\"));\n\n // Act & Assert\n await act.Should().ThrowAsync().WithMessage(\"That was wrong.\");\n }\n }\n\n [Fact]\n public async Task When_async_method_throws_a_flat_AggregateException_it_should_provide_the_message()\n {\n // Arrange\n Func act = () => throw new AggregateException(\"That was wrong as well.\");\n\n // Act & Assert\n await act.Should().ThrowAsync().WithMessage(\"That was wrong as well.\");\n }\n\n [Fact]\n public async Task When_async_method_throws_a_nested_AggregateException_it_should_provide_unwrapped_exception_to_predicate()\n {\n // Arrange\n Func act = () => throw new AggregateException(new ArgumentException(\"That was wrong.\"));\n\n // Act & Assert\n await act.Should().ThrowAsync()\n .Where(i => i.Message == \"That was wrong.\");\n }\n\n [Fact]\n public async Task When_async_method_throws_a_flat_AggregateException_it_should_provide_it_to_predicate()\n {\n // Arrange\n Func act = () => throw new AggregateException(\"That was wrong as well.\");\n\n // Act & Assert\n await act.Should().ThrowAsync()\n .Where(i => i.Message == \"That was wrong as well.\");\n }\n\n#pragma warning disable xUnit1026 // Theory methods should use all of their parameters\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public async Task When_the_expected_exception_is_wrapped_async_it_should_succeed(Func action, T _)\n where T : Exception\n {\n // Act/Assert\n await action.Should().ThrowAsync();\n }\n\n [UITheory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public async Task When_the_expected_exception_is_wrapped_on_UI_thread_async_it_should_succeed(Func action, T _)\n where T : Exception\n {\n // Act/Assert\n await action.Should().ThrowAsync();\n }\n\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public async Task When_the_expected_exception_is_not_wrapped_async_it_should_fail(Func action, T _)\n where T : Exception\n {\n // Act\n Func act2 = () => action.Should().NotThrowAsync();\n\n // Assert\n await act2.Should().ThrowAsync();\n }\n\n [UITheory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public async Task When_the_expected_exception_is_not_wrapped_on_UI_thread_async_it_should_fail(Func action, T _)\n where T : Exception\n {\n // Act\n Func act2 = () => action.Should().NotThrowAsync();\n\n // Assert\n await act2.Should().ThrowAsync();\n }\n#pragma warning restore xUnit1026 // Theory methods should use all of their parameters\n\n public static TheoryData, Exception> AggregateExceptionTestData()\n {\n Func[] tasks =\n [\n AggregateExceptionWithLeftNestedException,\n AggregateExceptionWithRightNestedException\n ];\n\n Exception[] types =\n [\n new AggregateException(),\n new ArgumentNullException(),\n new InvalidOperationException()\n ];\n\n var data = new TheoryData, Exception>();\n\n foreach (var task in tasks)\n {\n foreach (var type in types)\n {\n data.Add(task, type);\n }\n }\n\n data.Add(EmptyAggregateException, new AggregateException());\n\n return data;\n }\n\n private static Task AggregateExceptionWithLeftNestedException()\n {\n var ex1 = new AggregateException(new InvalidOperationException());\n var ex2 = new ArgumentNullException();\n var wrapped = new AggregateException(ex1, ex2);\n\n return FromException(wrapped);\n }\n\n private static Task AggregateExceptionWithRightNestedException()\n {\n var ex1 = new ArgumentNullException();\n var ex2 = new AggregateException(new InvalidOperationException());\n var wrapped = new AggregateException(ex1, ex2);\n\n return FromException(wrapped);\n }\n\n private static Task EmptyAggregateException()\n {\n return FromException(new AggregateException());\n }\n\n private static Task FromException(AggregateException exception)\n {\n return Task.FromException(exception);\n }\n\n [Fact]\n public async Task When_subject_throws_subclass_of_expected_exact_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.ArgumentNullException.\");\n }\n\n [Fact]\n public async Task When_subject_ValueTask_throws_subclass_of_expected_exact_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.ArgumentNullException.\");\n }\n\n [Fact]\n public async Task When_subject_throws_aggregate_exception_and_not_expected_exact_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAggregateExceptionAsync())\n .Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.AggregateException.\");\n }\n\n [Fact]\n public async Task When_subject_throws_aggregate_exception_and_not_expected_exact_exception_through_ValueTask_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAggregateExceptionAsyncValueTask())\n .Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.AggregateException.\");\n }\n\n [Fact]\n public async Task When_subject_throws_the_expected_exact_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act / Assert\n await asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().ThrowExactlyAsync();\n }\n\n [Fact]\n public async Task When_subject_throws_the_expected_exact_exception_through_ValueTask_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act / Assert\n await asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().ThrowExactlyAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_expected_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_expected_exception_through_ValueTask_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_subject_is_null_it_should_be_null()\n {\n // Arrange\n Func subject = null;\n\n // Act\n Func action = () => subject.Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"*found *\");\n }\n\n [Fact]\n public async Task When_async_method_throws_async_expected_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_expected_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.SucceedAsync())\n .Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected a to be thrown because IFoo.Do should do that, but no exception was thrown.\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_expected_exception_through_ValueTask_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.SucceedAsyncValueTask())\n .Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected a to be thrown because IFoo.Do should do that, but no exception was thrown.\");\n }\n\n [Fact]\n public async Task When_async_method_throws_unexpected_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected a to be thrown because IFoo.Do should do that, but found *\");\n }\n\n [Fact]\n public async Task When_async_method_throws_unexpected_exception_through_ValueTask_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected a to be thrown because IFoo.Do should do that, but found *\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_exception_and_that_was_expected_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.SucceedAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_exception_through_ValueTask_and_that_was_expected_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.SucceedAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_async_exception_and_that_was_expected_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.SucceedAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task When_async_method_does_not_throw_async_exception_on_UI_thread_and_that_was_expected_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.SucceedAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n }\n\n [Fact]\n public async Task When_subject_throws_subclass_of_expected_async_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n }\n\n [Fact]\n public async Task When_function_of_task_int_in_async_method_throws_the_expected_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Func> f = () => asyncObject.ThrowTaskIntAsync(true);\n\n // Act / Assert\n await f.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_function_of_task_int_in_async_method_throws_not_excepted_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Func> f = () => asyncObject.ThrowTaskIntAsync(true);\n\n // Act / Assert\n await f.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_subject_is_null_when_expecting_an_exact_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().ThrowExactlyAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_subject_throws_subclass_of_expected_async_exact_exception_it_should_throw()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n Func testAction = () => action.Should().ThrowExactlyAsync(\"ABCDE\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*ArgumentException*ABCDE*ArgumentNullException*\");\n }\n\n [Fact]\n public async Task When_subject_throws_aggregate_exception_instead_of_exact_exception_it_should_throw()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAggregateExceptionAsync();\n Func testAction = () => action.Should().ThrowExactlyAsync(\"ABCDE\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*ArgumentException*ABCDE*AggregateException*\");\n }\n\n [Fact]\n public async Task When_subject_throws_expected_async_exact_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task When_subject_throws_on_UI_thread_expected_async_exact_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n }\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_and_no_exception_was_expected_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exception, but found System.ArgumentException*\");\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_through_ValueTask_and_no_exception_was_expected_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exception, but found System.ArgumentException*\");\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_and_expected_not_to_throw_another_one_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task\n When_async_method_throws_exception_through_ValueTask_and_expected_not_to_throw_another_one_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_and_expected_not_to_throw_async_another_one_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(_ => asyncObject.SucceedAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task\n When_async_method_succeeds_and_expected_not_to_throw_particular_exception_through_ValueTask_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(_ => asyncObject.SucceedAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_expected_not_to_be_thrown_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect System.ArgumentException, but found*\");\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_expected_through_ValueTask_not_to_be_thrown_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect System.ArgumentException, but found*\");\n }\n\n [Fact]\n public async Task When_async_method_of_T_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(_ => asyncObject.ReturnTaskInt())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_ValueTask_async_method_of_T_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(_ => asyncObject.ReturnValueTaskInt())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_of_T_throws_exception_expected_not_to_be_thrown_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowTaskIntAsync(true))\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect System.ArgumentException, but found System.ArgumentException*\");\n }\n\n [Fact]\n public async Task When_ValueTask_async_method_of_T_throws_exception_expected_not_to_be_thrown_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowValueTaskIntAsync(true))\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect System.ArgumentException, but found System.ArgumentException*\");\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_inner_exception_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new InvalidOperationException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerException();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_inner_exception_from_argument_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new InvalidOperationException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerException(typeof(InvalidOperationException));\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_inner_exception_exactly_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerExceptionExactly();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_inner_exception_exactly_defined_in_arguments_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerExceptionExactly(typeof(ArgumentException));\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_aggregate_exception_containing_expected_exception_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new InvalidOperationException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_exception_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async();\n\n // Act\n Func action = () => task\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_the_expected_inner_exception_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerException();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*InvalidOperation*Argument*\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_the_expected_inner_exception_from_argument_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerException(typeof(InvalidOperationException));\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*InvalidOperation*Argument*\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_the_expected_inner_exception_exactly_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentNullException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerExceptionExactly();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*ArgumentException*ArgumentNullException*\");\n }\n\n [Fact]\n public async Task\n When_async_method_does_not_throw_the_expected_inner_exception_exactly_defined_in_arguments_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentNullException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerExceptionExactly(typeof(ArgumentException));\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*ArgumentException*ArgumentNullException*\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_the_expected_exception_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async();\n\n // Act\n Func action = () => task\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*InvalidOperation*Argument*\");\n }\n\n#pragma warning disable MA0147\n [Fact]\n public void When_asserting_async_void_method_should_throw_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Action asyncVoidMethod = async () => await asyncObject.IncompleteTask();\n\n // Act\n Action action = () => asyncVoidMethod.Should().Throw();\n\n // Assert\n action.Should().Throw(\"*async*void*\");\n }\n\n [Fact]\n public void When_asserting_async_void_method_should_throw_exactly_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Action asyncVoidMethod = async () => await asyncObject.IncompleteTask();\n\n // Act\n Action action = () => asyncVoidMethod.Should().ThrowExactly();\n\n // Assert\n action.Should().Throw(\"*async*void*\");\n }\n\n [Fact]\n public void When_asserting_async_void_method_should_not_throw_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Action asyncVoidMethod = async () => await asyncObject.IncompleteTask();\n\n // Act\n Action action = () => asyncVoidMethod.Should().NotThrow();\n\n // Assert\n action.Should().Throw(\"*async*void*\");\n }\n\n [Fact]\n public void When_asserting_async_void_method_should_not_throw_specific_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Action asyncVoidMethod = async () => await asyncObject.IncompleteTask();\n\n // Act\n Action action = () => asyncVoidMethod.Should().NotThrow();\n\n // Assert\n action.Should().Throw(\"*async*void*\");\n }\n#pragma warning restore MA0147\n\n [Fact]\n public async Task When_a_method_throws_with_a_matching_parameter_name_it_should_succeed()\n {\n // Arrange\n Func task = () => new AsyncClass().ThrowAsync(new ArgumentNullException(\"someParameter\"));\n\n // Act\n Func act = () =>\n task.Should().ThrowAsync()\n .WithParameterName(\"someParameter\");\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_a_method_throws_with_a_non_matching_parameter_name_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n Func task = () => new AsyncClass().ThrowAsync(new ArgumentNullException(\"someOtherParameter\"));\n\n // Act\n Func act = () =>\n task.Should().ThrowAsync()\n .WithParameterName(\"someParameter\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n await act.Should().ThrowAsync()\n .WithMessage(\"*with parameter name \\\"someParameter\\\"*we want to test the failure message*\\\"someOtherParameter\\\"*\");\n }\n\n #region NotThrowAfterAsync\n\n [Fact]\n public async Task When_wait_time_is_zero_for_async_func_executed_with_wait_it_should_not_throw()\n {\n // Arrange\n var waitTime = 0.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var asyncObject = new AsyncClass();\n Func someFunc = () => asyncObject.SucceedAsync();\n\n // Act\n Func act = () => someFunc.Should(clock).NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_poll_interval_is_zero_for_async_func_executed_with_wait_it_should_not_throw()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = 0.Milliseconds();\n\n var clock = new FakeClock();\n var asyncObject = new AsyncClass();\n Func someFunc = () => asyncObject.SucceedAsync();\n\n // Act\n Func act = () => someFunc.Should(clock).NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_subject_is_null_for_async_func_it_should_throw()\n {\n // Arrange\n var waitTime = 0.Milliseconds();\n var pollInterval = 0.Milliseconds();\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().NotThrowAfterAsync(waitTime, pollInterval,\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_wait_time_is_negative_for_async_func_it_should_throw()\n {\n // Arrange\n var waitTime = -1.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n var asyncObject = new AsyncClass();\n Func someFunc = () => asyncObject.SucceedAsync();\n\n // Act\n Func act = () => someFunc.Should().NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().ThrowAsync()\n .WithParameterName(\"waitTime\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public async Task When_poll_interval_is_negative_for_async_func_it_should_throw()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = -1.Milliseconds();\n\n var asyncObject = new AsyncClass();\n Func someFunc = () => asyncObject.SucceedAsync();\n\n // Act\n Func act = () => someFunc.Should().NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().ThrowAsync()\n .WithParameterName(\"pollInterval\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public async Task When_no_exception_should_be_thrown_for_null_async_func_after_wait_time_it_should_throw()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n Func func = null;\n\n // Act\n Func action = () => func.Should()\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"*but found *\");\n }\n\n [Fact]\n public async Task When_no_exception_should_be_thrown_for_async_func_after_wait_time_but_it_was_it_should_throw()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.CompleteAfter(waitTime);\n\n Func throwLongerThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n };\n\n // Act\n Func action = () => throwLongerThanWaitTime.Should(clock)\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exceptions after 2s because we passed valid arguments*\");\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task\n When_no_exception_should_be_thrown_on_UI_thread_for_async_func_after_wait_time_but_it_was_it_should_throw()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.CompleteAfter(waitTime);\n\n Func throwLongerThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n };\n\n // Act\n Func action = () => throwLongerThanWaitTime.Should(clock)\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exceptions after 2s because we passed valid arguments*\");\n }\n }\n\n [Fact]\n public async Task When_no_exception_should_be_thrown_for_async_func_after_wait_time_and_none_was_it_should_not_throw()\n {\n // Arrange\n var waitTime = 6.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.Delay(waitTime);\n\n Func throwShorterThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Divide(12))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n };\n\n // Act\n Func act = () => throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task\n When_no_exception_should_be_thrown_on_UI_thread_for_async_func_after_wait_time_and_none_was_it_should_not_throw()\n {\n // Arrange\n var waitTime = 6.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.Delay(waitTime);\n\n Func throwShorterThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Divide(12))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n };\n\n // Act\n Func act = () => throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n }\n\n #endregion\n}\n\ninternal class AsyncClass\n{\n public Task ThrowAsync()\n where TException : Exception, new() =>\n ThrowAsync(new TException());\n\n public Task ThrowAsync(Exception exception) =>\n Throw.Async(exception);\n\n public ValueTask ThrowAsyncValueTask()\n where TException : Exception, new() =>\n Throw.AsyncValueTask(new TException());\n\n public Task ThrowAggregateExceptionAsync()\n where TException : Exception, new() =>\n Throw.Async(new AggregateException(new TException()));\n\n public ValueTask ThrowAggregateExceptionAsyncValueTask()\n where TException : Exception, new() =>\n Throw.AsyncValueTask(new AggregateException(new TException()));\n\n public async Task SucceedAsync()\n {\n await Task.FromResult(0);\n }\n\n public async ValueTask SucceedAsyncValueTask()\n {\n await Task.FromResult(0);\n }\n\n public Task ReturnTaskInt()\n {\n return Task.FromResult(0);\n }\n\n public ValueTask ReturnValueTaskInt()\n {\n return new ValueTask(0);\n }\n\n public Task IncompleteTask()\n {\n return new TaskCompletionSource().Task;\n }\n\n public async Task ThrowTaskIntAsync(bool throwException)\n where TException : Exception, new()\n {\n await Task.Yield();\n\n if (throwException)\n {\n throw new TException();\n }\n\n return 123;\n }\n\n public async ValueTask ThrowValueTaskIntAsync(bool throwException)\n where TException : Exception, new()\n {\n await Task.Yield();\n\n if (throwException)\n {\n throw new TException();\n }\n\n return 123;\n }\n}\n\ninternal static class Throw\n{\n public static Task Async()\n where TException : Exception, new() =>\n Async(new TException());\n\n public static async Task Async(Exception expcetion)\n {\n await Task.Yield();\n throw expcetion;\n }\n\n public static async ValueTask AsyncValueTask(Exception expcetion)\n {\n await Task.Yield();\n throw expcetion;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCountGreaterThanOrEqualTo.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveCountGreaterThanOrEqualTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCountGreaterThanOrEqualTo\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_greater_than_or_equal_to_less_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountGreaterThanOrEqualTo(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_greater_than_or_equal_to_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCountGreaterThanOrEqualTo(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_collection_has_a_count_greater_than_or_equal_to_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () =>\n collection.Should().HaveCountGreaterThanOrEqualTo(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain at least 4 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_greater_than_or_equal_to_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCountGreaterThanOrEqualTo(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*at least*1*we want to test the behaviour with a null subject*found *\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountGreaterThanOrEqualTo(3).And.Contain(1);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/ExceptionAssertionsExtensions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq.Expressions;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Specialized;\n\nnamespace AwesomeAssertions;\n\npublic static class ExceptionAssertionsExtensions\n{\n#pragma warning disable AV1755 // \"Name of async method ... should end with Async\"; Async suffix is too noisy in fluent API\n\n /// \n /// Asserts that the thrown exception has a message that matches .\n /// \n /// The containing the thrown exception.\n /// \n /// The wildcard pattern with which the exception message is matched, where * and ? have special meanings.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithMessage(\n this Task> task,\n string expectedWildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n return (await task).WithMessage(expectedWildcardPattern, because, becauseArgs);\n }\n\n /// \n /// Asserts that the exception matches a particular condition.\n /// \n /// The containing the thrown exception.\n /// \n /// The condition that the exception must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> Where(\n this Task> task,\n Expression> exceptionExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n return (await task).Where(exceptionExpression, because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of type .\n /// \n /// The expected type of the exception.\n /// The expected type of the inner exception.\n /// The containing the thrown exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithInnerException(\n this Task> task,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n where TInnerException : Exception\n {\n return (await task).WithInnerException(because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of type .\n /// \n /// The expected type of the exception.\n /// The containing the thrown exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithInnerException(\n this Task> task,\n Type innerException,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n return (await task).WithInnerException(innerException, because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of the exact type (and not a derived exception type).\n /// \n /// The expected type of the exception.\n /// The expected type of the inner exception.\n /// The containing the thrown exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithInnerExceptionExactly(\n this Task> task,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n where TInnerException : Exception\n {\n return (await task).WithInnerExceptionExactly(because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of the exact type (and not a derived exception type).\n /// \n /// The expected type of the exception.\n /// The containing the thrown exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithInnerExceptionExactly(\n this Task> task,\n Type innerException,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n return (await task).WithInnerExceptionExactly(innerException, because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception has a parameter which name matches .\n /// \n /// The containing the thrown exception.\n /// The expected name of the parameter\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static ExceptionAssertions WithParameterName(\n this ExceptionAssertions parent,\n string paramName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : ArgumentException\n {\n AssertionChain\n .GetOrCreate()\n .ForCondition(parent.Which.ParamName == paramName)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected exception with parameter name {0}{reason}, but found {1}.\", paramName, parent.Which.ParamName);\n\n return parent;\n }\n\n /// \n /// Asserts that the thrown exception has a parameter which name matches .\n /// \n /// The containing the thrown exception.\n /// The expected name of the parameter\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithParameterName(\n this Task> task,\n string paramName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : ArgumentException\n {\n return (await task).WithParameterName(paramName, because, becauseArgs);\n }\n\n#pragma warning restore AV1755\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCountLessThanOrEqualTo.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveCountLessOrEqualTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCountLessThanOrEqualTo\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_less_than_or_equal_to_less_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountLessThanOrEqualTo(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_less_than_or_equal_to_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCountLessThanOrEqualTo(2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_collection_has_a_count_less_than_or_equal_to_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () =>\n collection.Should().HaveCountLessThanOrEqualTo(2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain at most 2 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_less_than_or_equal_to_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCountLessThanOrEqualTo(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*at most*1*we want to test the behaviour with a null subject*found *\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountLessThanOrEqualTo(3).And.Contain(1);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/MiscellaneousExceptionSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class MiscellaneousExceptionSpecs\n{\n [Fact]\n public void When_getting_value_of_property_of_thrown_exception_it_should_return_value_of_property()\n {\n // Arrange\n const string SomeParamNameValue = \"param\";\n Does target = Does.Throw(new ExceptionWithProperties(SomeParamNameValue));\n\n // Act\n Action act = target.Do;\n\n // Assert\n act.Should().Throw().And.Property.Should().Be(SomeParamNameValue);\n }\n\n [Fact]\n public void When_validating_a_subject_against_multiple_conditions_it_should_support_chaining()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"message\", new ArgumentException(\"inner message\")));\n\n // Act / Assert\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException()\n .WithMessage(\"inner message\");\n }\n\n [Fact]\n public void When_a_yielding_enumerable_throws_an_expected_exception_it_should_not_throw()\n {\n // Act\n Func> act = () => MethodThatUsesYield(\"aaa!aaa\");\n\n // Assert\n act.Enumerating().Should().Throw();\n }\n\n private static IEnumerable MethodThatUsesYield(string bar)\n {\n foreach (var character in bar)\n {\n if (character.Equals('!'))\n {\n throw new Exception(\"No exclamation marks allowed.\");\n }\n\n yield return char.ToUpperInvariant(character);\n }\n }\n\n [Fact]\n public void When_custom_condition_is_not_met_it_should_throw()\n {\n // Arrange\n Action act = () => throw new ArgumentException(\"\");\n\n try\n {\n // Act\n act\n .Should().Throw()\n .Where(e => e.Message.Length > 0, \"an exception must have a message\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException exc)\n {\n // Assert\n exc.Message.Should().StartWith(\n \"Expected exception where (e.Message.Length > 0) because an exception must have a message, but the condition was not met\");\n }\n }\n\n [Fact]\n public void When_a_2nd_condition_is_not_met_it_should_throw()\n {\n // Arrange\n Action act = () => throw new ArgumentException(\"Fail\");\n\n try\n {\n // Act\n act\n .Should().Throw()\n .Where(e => e.Message.Length > 0)\n .Where(e => e.Message == \"Error\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException exc)\n {\n // Assert\n exc.Message.Should().StartWith(\n \"Expected exception where (e.Message == \\\"Error\\\"), but the condition was not met\");\n }\n catch (Exception exc)\n {\n exc.Message.Should().StartWith(\n \"Expected exception where (e.Message == \\\"Error\\\"), but the condition was not met\");\n }\n }\n\n [Fact]\n public void When_custom_condition_is_met_it_should_not_throw()\n {\n // Arrange / Act\n Action act = () => throw new ArgumentException(\"\");\n\n // Assert\n act\n .Should().Throw()\n .Where(e => e.Message.Length == 0);\n }\n\n [Fact]\n public void When_two_exceptions_are_thrown_and_the_assertion_assumes_there_can_only_be_one_it_should_fail()\n {\n // Arrange\n Does testSubject = Does.Throw(new AggregateException(new Exception(), new Exception()));\n Action throwingMethod = testSubject.Do;\n\n // Act\n Action action = () => throwingMethod.Should().Throw().And.Message.Should();\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_an_exception_of_a_different_type_is_thrown_it_should_include_the_type_of_the_thrown_exception()\n {\n // Arrange\n Action throwException = () => throw new ExceptionWithEmptyToString();\n\n // Act\n Action act =\n () => throwException.Should().Throw();\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*System.ArgumentNullException*{typeof(ExceptionWithEmptyToString)}*\");\n }\n\n [Fact]\n public void When_a_method_throws_with_a_matching_parameter_name_it_should_succeed()\n {\n // Arrange\n Action throwException = () => throw new ArgumentNullException(\"someParameter\");\n\n // Act / Assert\n throwException.Should().Throw()\n .WithParameterName(\"someParameter\");\n }\n\n [Fact]\n public void When_a_method_throws_with_a_non_matching_parameter_name_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n Action throwException = () => throw new ArgumentNullException(\"someOtherParameter\");\n\n // Act\n Action act = () =>\n throwException.Should().Throw()\n .WithParameterName(\"someParameter\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*with parameter name \\\"someParameter\\\"*we want to test the failure message*\\\"someOtherParameter\\\"*\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveElementAt.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveElementAt specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveElementAt\n {\n [Fact]\n public void When_collection_has_expected_element_at_specific_index_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveElementAt(1, 2);\n }\n\n [Fact]\n public void Can_chain_another_assertion_on_the_selected_element()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n var act = () => collection.Should().HaveElementAt(index: 1, element: 2).Which.Should().Be(3);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection[1] to be 3, but found 2.\");\n }\n\n [Fact]\n public void When_collection_does_not_have_the_expected_element_at_specific_index_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveElementAt(1, 3, \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected 3 at index 1 because we put it there, but found 2.\");\n }\n\n [Fact]\n public void When_collection_does_not_have_an_element_at_the_specific_index_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveElementAt(4, 3, \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected 3 at index 4 because we put it there, but found no element.\");\n }\n\n [Fact]\n public void When_asserting_collection_has_element_at_specific_index_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveElementAt(1, 1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have element at index 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_element_at_specific_index_was_found_it_should_allow_chaining()\n {\n // Arrange\n var expectedElement = new\n {\n SomeProperty = \"hello\"\n };\n\n var collection = new[]\n {\n expectedElement\n };\n\n // Act\n Action act = () => collection.Should()\n .HaveElementAt(0, expectedElement)\n .Which\n .Should().BeAssignableTo();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*assignable*string*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeEmpty.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeEmpty specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void When_collection_is_empty_as_expected_it_should_not_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().BeEmpty();\n }\n\n [Fact]\n public void When_collection_is_not_empty_unexpectedly_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().BeEmpty(\"that's what we expect\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be empty because that's what we expect, but found at least one item*1*\");\n }\n\n [Fact]\n public void When_asserting_collection_with_items_is_not_empty_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotBeEmpty();\n }\n\n [Fact]\n public void When_asserting_collection_with_items_is_not_empty_it_should_enumerate_the_collection_only_once()\n {\n // Arrange\n var trackingEnumerable = new TrackingTestEnumerable(1, 2, 3);\n\n // Act\n trackingEnumerable.Should().NotBeEmpty();\n\n // Assert\n trackingEnumerable.Enumerator.LoopCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_collection_without_items_is_not_empty_it_should_fail()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_collection_without_items_is_not_empty_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to be empty because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().BeEmpty(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to be empty *failure message*, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([]);\n\n // Act\n collection.Should().BeEmpty();\n\n // Assert\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_non_empty_collection_is_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([1, 2, 3]);\n\n // Act\n Action act = () => collection.Should().BeEmpty();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be empty, but found at least one item {1}.\");\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotBeEmpty(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to be empty *failure message*, but found .\");\n }\n\n [Fact]\n public void When_asserting_an_infinite_collection_to_be_empty_it_should_throw_correctly()\n {\n // Arrange\n var collection = new InfiniteEnumerable();\n\n // Act\n Action act = () => collection.Should().BeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void When_asserting_collection_to_be_not_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotBeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_not_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([42]);\n\n // Act\n collection.Should().NotBeEmpty();\n\n // Assert\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n }\n\n private sealed class InfiniteEnumerable : IEnumerable\n {\n public IEnumerator GetEnumerator() => new InfiniteEnumerator();\n\n IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n }\n\n private sealed class InfiniteEnumerator : IEnumerator\n {\n public bool MoveNext() => true;\n\n public void Reset() { }\n\n public object Current => new();\n\n object IEnumerator.Current => Current;\n\n public void Dispose() { }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.StartWith.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The StartWith specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class StartWith\n {\n [Fact]\n public void When_collection_does_not_start_with_a_specific_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().StartWith(\"ryan\", \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*ryan*because of some reason*but*john*\");\n }\n\n [Fact]\n public void When_collection_does_not_start_with_a_null_sequence_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\"];\n\n // Act\n Action act = () => collection.Should().StartWith((IEnumerable)null);\n\n // Assert\n act.Should().Throw()\n .Which.ParamName.Should().Be(\"expectation\");\n }\n\n [Fact]\n public void When_collection_does_not_start_with_a_null_sequence_using_a_comparer_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\"];\n\n // Act\n Action act = () => collection.Should().StartWith((IEnumerable)null, (_, _) => true);\n\n // Assert\n act.Should().Throw()\n .Which.ParamName.Should().Be(\"expectation\");\n }\n\n [Fact]\n public void When_collection_does_not_start_with_a_specific_element_in_a_sequence_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().StartWith([\"john\", \"ryan\", \"jane\"], \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*ryan*because of some reason*but*differs at index 1*\");\n }\n\n [Fact]\n public void\n When_collection_does_not_start_with_a_specific_element_in_a_sequence_using_custom_equality_comparison_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().StartWith([\"john\", \"ryan\", \"jane\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.Ordinal), \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*ryan*because of some reason*but*differs at index 1*\");\n }\n\n [Fact]\n public void When_collection_starts_with_the_specific_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith(\"john\");\n }\n\n [Fact]\n public void When_collection_starts_with_the_specific_sequence_of_elements_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith([\"john\", \"bill\"]);\n }\n\n [Fact]\n public void\n When_collection_starts_with_the_specific_sequence_of_elements_using_custom_equality_comparison_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith([\"JoHn\", \"bIlL\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_collection_starts_with_the_specific_null_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [null, \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith((string)null);\n }\n\n [Fact]\n public void When_non_empty_collection_starts_with_the_empty_sequence_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith(new string[] { });\n }\n\n [Fact]\n public void When_empty_collection_starts_with_the_empty_sequence_it_should_not_throw()\n {\n // Arrange\n string[] collection = [];\n\n // Act / Assert\n collection.Should().StartWith(new string[] { });\n }\n\n [Fact]\n public void When_collection_starts_with_the_specific_sequence_with_null_elements_it_should_not_throw()\n {\n // Arrange\n string[] collection = [null, \"john\", null, \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith([null, \"john\", null, \"bill\"]);\n }\n\n [Fact]\n public void\n When_collection_starts_with_the_specific_sequence_with_null_elements_using_custom_equality_comparison_it_should_not_throw()\n {\n // Arrange\n string[] collection = [null, \"john\", null, \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith([null, \"JoHn\", null, \"bIlL\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_collection_starts_with_null_but_that_wasnt_expected_it_should_throw()\n {\n // Arrange\n string[] collection = [null, \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().StartWith(\"john\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*john*but*null*\");\n }\n\n [Fact]\n public void When_null_collection_is_expected_to_start_with_an_element_it_should_throw()\n {\n // Arrange\n string[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().StartWith(\"john\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*john*but*collection*null*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventHandlerFactory.cs", "using System;\nusing System.Reflection;\nusing System.Reflection.Emit;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Static methods that aid in generic event subscription\n/// \ninternal static class EventHandlerFactory\n{\n /// \n /// Generates an eventhandler for an event of type eventSignature that calls RegisterEvent on recorder\n /// when invoked.\n /// \n public static Delegate GenerateHandler(Type eventSignature, EventRecorder recorder)\n {\n Type returnType = GetDelegateReturnType(eventSignature);\n Type[] parameters = GetDelegateParameterTypes(eventSignature);\n\n Module module = recorder.GetType()\n .Module;\n\n var eventHandler = new DynamicMethod(\n eventSignature.Name + \"DynamicHandler\",\n returnType,\n AppendParameterListThisReference(parameters),\n module);\n\n MethodInfo methodToCall = typeof(EventRecorder).GetMethod(nameof(EventRecorder.RecordEvent),\n BindingFlags.Instance | BindingFlags.Public);\n\n ILGenerator ilGen = eventHandler.GetILGenerator();\n\n // Make room for the one and only local variable in our function\n ilGen.DeclareLocal(typeof(object[]));\n\n // Create the object array for the parameters and store in local var index 0\n ilGen.Emit(OpCodes.Ldc_I4, parameters.Length);\n ilGen.Emit(OpCodes.Newarr, typeof(object));\n ilGen.Emit(OpCodes.Stloc_0);\n\n for (var index = 0; index < parameters.Length; index++)\n {\n // Push the object array onto the evaluation stack\n ilGen.Emit(OpCodes.Ldloc_0);\n\n // Push the array index to store our parameter in onto the evaluation stack\n ilGen.Emit(OpCodes.Ldc_I4, index);\n\n // Load the parameter\n ilGen.Emit(OpCodes.Ldarg, index + 1);\n\n // Box value-type parameters\n if (parameters[index].IsValueType)\n {\n ilGen.Emit(OpCodes.Box, parameters[index]);\n }\n\n // Store the parameter in the object array\n ilGen.Emit(OpCodes.Stelem_Ref);\n }\n\n // Push the this-reference on the stack as param 0 for calling the handler\n ilGen.Emit(OpCodes.Ldarg_0);\n\n // Push the object array onto the stack as param 1 for calling the handler\n ilGen.Emit(OpCodes.Ldloc_0);\n\n // Call the handler\n ilGen.EmitCall(OpCodes.Callvirt, methodToCall, null);\n\n ilGen.Emit(OpCodes.Ret);\n\n return eventHandler.CreateDelegate(eventSignature, recorder);\n }\n\n /// \n /// Finds the Return Type of a Delegate.\n /// \n private static Type GetDelegateReturnType(Type d)\n {\n MethodInfo invoke = DelegateInvokeMethod(d);\n return invoke.ReturnType;\n }\n\n /// \n /// Returns an Array of Types that make up a delegate's parameter signature.\n /// \n private static Type[] GetDelegateParameterTypes(Type d)\n {\n MethodInfo invoke = DelegateInvokeMethod(d);\n\n ParameterInfo[] parameterInfo = invoke.GetParameters();\n var parameters = new Type[parameterInfo.Length];\n\n for (var index = 0; index < parameterInfo.Length; index++)\n {\n parameters[index] = parameterInfo[index].ParameterType;\n }\n\n return parameters;\n }\n\n /// \n /// Returns an array of types appended with an EventRecorder reference at the beginning.\n /// \n private static Type[] AppendParameterListThisReference(Type[] parameters)\n {\n var newList = new Type[parameters.Length + 1];\n newList[0] = typeof(EventRecorder);\n\n for (var index = 0; index < parameters.Length; index++)\n {\n newList[index + 1] = parameters[index];\n }\n\n return newList;\n }\n\n /// \n /// Returns T/F Dependent on a Type Being a Delegate.\n /// \n private static bool TypeIsDelegate(Type d)\n {\n if (d.BaseType != typeof(MulticastDelegate))\n {\n return false;\n }\n\n MethodInfo invoke = d.GetMethod(\"Invoke\");\n return invoke is not null;\n }\n\n /// \n /// Returns the MethodInfo for the Delegate's \"Invoke\" Method.\n /// \n private static MethodInfo DelegateInvokeMethod(Type d)\n {\n if (!TypeIsDelegate(d))\n {\n throw new ArgumentException(\"Type is not a Delegate!\", nameof(d));\n }\n\n MethodInfo invoke = d.GetMethod(\"Invoke\");\n return invoke;\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/Program.cs", "using System.Globalization;\nusing BenchmarkDotNet.Configs;\nusing BenchmarkDotNet.Exporters.Csv;\nusing BenchmarkDotNet.Reports;\nusing BenchmarkDotNet.Running;\nusing Perfolizer.Horology;\nusing Perfolizer.Metrology;\n\nnamespace Benchmarks;\n\ninternal static class Program\n{\n public static void Main()\n {\n var exporter = new CsvExporter(\n CsvSeparator.CurrentCulture,\n new SummaryStyle(\n cultureInfo: CultureInfo.GetCultureInfo(\"nl-NL\"),\n printUnitsInHeader: true,\n sizeUnit: SizeUnit.KB,\n timeUnit: TimeUnit.Microsecond,\n printUnitsInContent: false\n ));\n\n var config = ManualConfig.CreateMinimumViable().AddExporter(exporter);\n\n _ = BenchmarkRunner.Run(config);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/GuidAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the correct state.\n/// \n[DebuggerNonUserCode]\npublic class GuidAssertions : GuidAssertions\n{\n public GuidAssertions(Guid? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the correct state.\n/// \n[DebuggerNonUserCode]\npublic class GuidAssertions\n where TAssertions : GuidAssertions\n{\n public GuidAssertions(Guid? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public Guid? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n #region BeEmpty / NotBeEmpty\n\n /// \n /// Asserts that the is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == Guid.Empty)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:Guid} to be empty{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is { } value && value != Guid.Empty)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:Guid} to be empty{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region Be / NotBe\n\n /// \n /// Asserts that the is equal to the GUID.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The format of is invalid.\n public AndConstraint Be(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (!Guid.TryParse(expected, out Guid expectedGuid))\n {\n throw new ArgumentException($\"Unable to parse \\\"{expected}\\\" as a valid GUID\", nameof(expected));\n }\n\n return Be(expectedGuid, because, becauseArgs);\n }\n\n /// \n /// Asserts that the is equal to the GUID.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(Guid expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:Guid} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is not equal to the GUID.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The format of is invalid.\n public AndConstraint NotBe(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (!Guid.TryParse(unexpected, out Guid unexpectedGuid))\n {\n throw new ArgumentException($\"Unable to parse \\\"{unexpected}\\\" as a valid GUID\", nameof(unexpected));\n }\n\n return NotBe(unexpectedGuid, because, becauseArgs);\n }\n\n /// \n /// Asserts that the is not equal to the GUID.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(Guid unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:Guid} to be {0}{reason}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() or BeOneOf() instead?\");\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XDocumentFormatterSpecs.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XDocumentFormatterSpecs\n{\n [Fact]\n public void When_element_has_root_element_it_should_include_it_in_the_output()\n {\n // Act\n var document = XDocument.Parse(\n @\"\n \n \n \");\n\n string result = Formatter.ToString(document);\n\n // Assert\n result.Should().Be(\"\");\n }\n\n [Fact]\n public void When_element_has_no_root_element_it_should_include_it_in_the_output()\n {\n // Act\n var document = new XDocument();\n\n string result = Formatter.ToString(document);\n\n // Assert\n result.Should().Be(\"[XML document without root element]\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCount.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCount\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCount(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_that_is_different_from_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCount(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_dictionary_has_a_count_that_is_different_from_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () => dictionary.Should().HaveCount(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain 4 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_has_a_count_larger_than_the_minimum_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCount(c => c >= 3);\n }\n\n [Fact]\n public void When_dictionary_has_a_count_that_not_matches_the_predicate_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCount(c => c >= 4, \"a minimum of 4 is required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to have a count (c >= 4) because a minimum of 4 is required, but count is 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_matched_against_a_null_predicate_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCount(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare collection count against a predicate.*\");\n }\n\n [Fact]\n public void When_dictionary_count_is_matched_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().HaveCount(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain 1 item(s) because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_dictionary_count_is_matched_against_a_predicate_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().HaveCount(c => c < 3, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain (c < 3) items because we want to test the behaviour with a null subject, but found .\");\n }\n }\n\n public class NotHaveCount\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_different_from_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().NotHaveCount(2);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotHaveCount(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_dictionary_has_a_count_that_equals_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () => dictionary.Should().NotHaveCount(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*not contain*3*because we want to test the failure message*3*\");\n }\n\n [Fact]\n public void When_dictionary_count_is_same_than_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().NotHaveCount(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*not contain*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/XmlAssertionExtensions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Xml;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Xml;\n\nnamespace AwesomeAssertions;\n\n[DebuggerNonUserCode]\npublic static class XmlAssertionExtensions\n{\n public static XmlNodeAssertions Should([NotNull] this XmlNode actualValue)\n {\n return new XmlNodeAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n public static XmlElementAssertions Should([NotNull] this XmlElement actualValue)\n {\n return new XmlElementAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveSameCount.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]HaveSameCount specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveSameCount\n {\n [Fact]\n public void When_both_collections_have_the_same_number_elements_it_should_succeed()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 5, 6];\n\n // Act / Assert\n firstCollection.Should().HaveSameCount(secondCollection);\n }\n\n [Fact]\n public void When_both_collections_do_not_have_the_same_number_of_elements_it_should_fail()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 6];\n\n // Act\n Action act = () => firstCollection.Should().HaveSameCount(secondCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to have 2 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_comparing_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 6];\n\n // Act\n Action act = () => firstCollection.Should().HaveSameCount(secondCollection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to have 2 item(s) because we want to test the reason, but found 3.\");\n }\n\n [Fact]\n public void When_asserting_collections_to_have_same_count_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveSameCount(collection1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have the same count as {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collections_to_have_same_count_against_an_other_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = null;\n\n // Act\n Action act = () => collection.Should().HaveSameCount(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n }\n\n public class NotHaveSameCount\n {\n [Fact]\n public void When_asserting_not_same_count_and_collections_have_different_number_elements_it_should_succeed()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 6];\n\n // Act / Assert\n firstCollection.Should().NotHaveSameCount(secondCollection);\n }\n\n [Fact]\n public void When_asserting_not_same_count_and_both_collections_have_the_same_number_elements_it_should_fail()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 5, 6];\n\n // Act\n Action act = () => firstCollection.Should().NotHaveSameCount(secondCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to not have 3 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_comparing_not_same_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 5, 6];\n\n // Act\n Action act = () => firstCollection.Should().NotHaveSameCount(secondCollection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to not have 3 item(s) because we want to test the reason, but found 3.\");\n }\n\n [Fact]\n public void When_asserting_collections_to_not_have_same_count_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotHaveSameCount(collection1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to not have the same count as {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collections_to_not_have_same_count_against_an_other_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = null;\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n\n [Fact]\n public void\n When_asserting_collections_to_not_have_same_count_but_both_collections_references_the_same_object_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n var collection1 = collection;\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(collection1,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not have the same count*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.EndWith.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The EndWith specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class EndWith\n {\n [Fact]\n public void When_collection_does_not_end_with_a_specific_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().EndWith(\"ryan\", \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*ryan*because of some reason*but*mike*\");\n }\n\n [Fact]\n public void When_collection_does_end_with_a_specific_element_and_because_format_is_incorrect_it_should_not_fail()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act / Assert\n#pragma warning disable CA2241\n // ReSharper disable FormatStringProblem\n collection.Should().EndWith(\"mike\", \"of some reason {0,abc}\", 1, 2);\n\n // ReSharper restore FormatStringProblem\n#pragma warning restore CA2241\n }\n\n [Fact]\n public void When_collection_does_not_end_with_a_specific_element_in_a_sequence_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().EndWith([\"bill\", \"ryan\", \"mike\"], \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*ryan*because of some reason*but*differs at index 2*\");\n }\n\n [Fact]\n public void When_collection_does_not_end_with_a_null_sequence_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\"];\n\n // Act\n Action act = () => collection.Should().EndWith((IEnumerable)null);\n\n // Assert\n act.Should().Throw()\n .Which.ParamName.Should().Be(\"expectation\");\n }\n\n [Fact]\n public void When_collection_does_not_end_with_a_null_sequence_using_a_comparer_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\"];\n\n // Act\n Action act = () => collection.Should().EndWith((IEnumerable)null, (_, _) => true);\n\n // Assert\n act.Should().Throw()\n .Which.ParamName.Should().Be(\"expectation\");\n }\n\n [Fact]\n public void\n When_collection_does_not_end_with_a_specific_element_in_a_sequence_using_custom_equality_comparison_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().EndWith([\"bill\", \"ryan\", \"mike\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.Ordinal), \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*ryan*because of some reason*but*differs at index 2*\");\n }\n\n [Fact]\n public void When_collection_ends_with_the_specific_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().EndWith(\"mike\");\n }\n\n [Fact]\n public void When_collection_ends_with_the_specific_sequence_of_elements_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().EndWith([\"jane\", \"mike\"]);\n }\n\n [Fact]\n public void\n When_collection_ends_with_the_specific_sequence_of_elements_using_custom_equality_comparison_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().EndWith([\"JaNe\", \"mIkE\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_collection_ends_with_the_specific_null_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"jane\", \"mike\", null];\n\n // Act / Assert\n collection.Should().EndWith((string)null);\n }\n\n [Fact]\n public void When_collection_ends_with_the_specific_sequence_with_null_elements_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", null, \"mike\", null];\n\n // Act / Assert\n collection.Should().EndWith([\"jane\", null, \"mike\", null]);\n }\n\n [Fact]\n public void\n When_collection_ends_with_the_specific_sequence_with_null_elements_using_custom_equality_comparison_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", null, \"mike\", null];\n\n // Act / Assert\n collection.Should().EndWith([\"JaNe\", null, \"mIkE\", null],\n (s1, s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_collection_ends_with_null_but_that_wasnt_expected_it_should_throw()\n {\n // Arrange\n string[] collection = [\"jane\", \"mike\", null];\n\n // Act\n Action act = () => collection.Should().EndWith(\"john\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*john*but*null*\");\n }\n\n [Fact]\n public void When_null_collection_is_expected_to_end_with_an_element_it_should_throw()\n {\n // Arrange\n string[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().EndWith(\"john\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*john*but*collection*null*\");\n }\n\n [Fact]\n public void When_non_empty_collection_ends_with_the_empty_sequence_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().EndWith(new string[] { });\n }\n\n [Fact]\n public void When_empty_collection_ends_with_the_empty_sequence_it_should_not_throw()\n {\n // Arrange\n string[] collection = [];\n\n // Act / Assert\n collection.Should().EndWith(new string[] { });\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.Contain.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class Contain\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_single_key_value_pair()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\")\n };\n\n // Act / Assert\n dictionary.Should().Contain(keyValuePairs);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_multiple_key_value_pair()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\",\n [4] = \"Four\"\n };\n\n var expectedKeyValuePair1 = new KeyValuePair(2, \"Two\");\n var expectedKeyValuePair2 = new KeyValuePair(3, \"Three\");\n\n // Act / Assert\n dictionary.Should().Contain(expectedKeyValuePair1, expectedKeyValuePair2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_multiple_key_value_pairs()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\"),\n new(2, \"Two\")\n };\n\n // Act / Assert\n dictionary.Should().Contain(keyValuePairs);\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_single_value_for_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\"),\n new(2, \"Three\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"Three\\\" at key 2 because we do, but found \\\"Two\\\".\");\n }\n\n [Fact]\n public void\n When_a_dictionary_does_not_contain_multiple_values_for_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"Two\"),\n new(2, \"Three\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain {[1, Two], [2, Three]} because we do, but dictionary differs at keys {1, 2}.\");\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_single_key_for_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(3, \"Three\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain key 3 because we do.\");\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_multiple_keys_for_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\"),\n new(3, \"Three\"),\n new(4, \"Four\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain key(s) {1, 3, 4} because we do, but could not find keys {3, 4}.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_contains_key_value_pairs_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n List> keyValuePairs =\n [\n new KeyValuePair(1, \"One\"),\n new KeyValuePair(1, \"Two\")\n ];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().Contain(keyValuePairs, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain key/value pairs {[1, One], [1, Two]} because we want to test the behaviour with a null subject, but dictionary is .\");\n }\n\n [Fact]\n public void When_asserting_dictionary_contains_key_value_pairs_but_expected_key_value_pairs_are_empty_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n List> keyValuePairs = [];\n\n // Act\n Action act = () => dictionary1.Should().Contain(keyValuePairs,\n \"because we want to test the behaviour with an empty set of key/value pairs\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify key containment against an empty collection of key/value pairs*\");\n }\n\n [Fact]\n public void When_asserting_dictionary_contains_key_value_pairs_but_expected_key_value_pairs_are_null_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n List> keyValuePairs = null;\n\n // Act\n Action act = () =>\n dictionary1.Should().Contain(keyValuePairs, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare dictionary with .*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_dictionary_contains_expected_value_at_specific_key_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().Contain(1, \"One\");\n }\n\n [Fact]\n public void When_dictionary_contains_expected_null_at_specific_key_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = null\n };\n\n // Act / Assert\n dictionary.Should().Contain(1, null);\n }\n\n [Fact]\n public void When_dictionary_contains_expected_key_value_pairs_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n var items = new List>\n {\n new(1, \"One\"),\n new(2, \"Two\")\n };\n\n dictionary.Should().Contain(items);\n }\n\n [Fact]\n public void When_dictionary_contains_expected_key_value_pair_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n var item = new KeyValuePair(1, \"One\");\n dictionary.Should().Contain(item);\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_the_expected_value_at_specific_key_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n var item = new KeyValuePair(1, \"Two\");\n Action act = () => dictionary.Should().Contain(item, \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"Two\\\" at key 1 because we put it there, but found \\\"One\\\".\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_the_key_value_pairs_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var items = new List>\n {\n new(1, \"Two\"),\n new(2, \"Three\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(items, \"we put them {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain {[1, Two], [2, Three]} because we put them there, but dictionary differs at keys {1, 2}.\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_the_key_value_pair_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(1, \"Two\", \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"Two\\\" at key 1 because we put it there, but found \\\"One\\\".\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_an_value_at_the_specific_key_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(3, \"Two\", \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"Two\\\" at key 3 because we put it there, but the key was not found.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_contains_value_at_specific_key_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().Contain(1, \"One\", \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"One\\\" at key 1 because we want to test the behaviour with a null subject, but dictionary is .\");\n }\n\n [Fact]\n public void When_a_dictionary_like_collection_contains_the_default_key_it_should_succeed()\n {\n // Arrange\n var subject = new List>\n { new(0, 0) };\n\n // Act / Assert\n subject.Should().Contain(0, 0);\n }\n }\n\n public class NotContain\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_does_not_contain_single_key_value_pair()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(3, \"Three\")\n };\n\n // Act / Assert\n dictionary.Should().NotContain(keyValuePairs);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_does_not_contain_multiple_key_value_pair()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var unexpectedKeyValuePair1 = new KeyValuePair(3, \"Three\");\n var unexpectedKeyValuePair2 = new KeyValuePair(4, \"Four\");\n\n // Act / Assert\n dictionary.Should().NotContain(unexpectedKeyValuePair1, unexpectedKeyValuePair2);\n }\n\n [Fact]\n public void\n Should_succeed_when_asserting_dictionary_does_not_contain_single_key_value_pair_with_existing_key_but_different_value()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"Two\")\n };\n\n // Act / Assert\n dictionary.Should().NotContain(keyValuePairs);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_does_not_contain_multiple_key_value_pairs()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(3, \"Three\"),\n new(4, \"Four\")\n };\n\n // Act / Assert\n dictionary.Should().NotContain(keyValuePairs);\n }\n\n [Fact]\n public void\n Should_succeed_when_asserting_dictionary_does_not_contain_multiple_key_value_pairs_with_existing_keys_but_different_values()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"Three\"),\n new(2, \"Four\")\n };\n\n // Act / Assert\n dictionary.Should().NotContain(keyValuePairs);\n }\n\n [Fact]\n public void When_a_dictionary_does_contain_single_key_value_pair_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\")\n };\n\n // Act\n Action act = () => dictionary.Should().NotContain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain value \\\"One\\\" at key 1 because we do, but found it anyhow.\");\n }\n\n [Fact]\n public void When_a_dictionary_does_contain_multiple_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\"),\n new(2, \"Two\")\n };\n\n // Act\n Action act = () => dictionary.Should().NotContain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain key/value pairs {[1, One], [2, Two]} because we do, but found them anyhow.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_does_not_contain_key_value_pairs_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n List> keyValuePairs =\n [\n new KeyValuePair(1, \"One\"),\n new KeyValuePair(1, \"Two\")\n ];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContain(keyValuePairs, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain key/value pairs {[1, One], [1, Two]} because we want to test the behaviour with a null subject, but dictionary is .\");\n }\n\n [Fact]\n public void\n When_asserting_dictionary_does_not_contain_key_value_pairs_but_expected_key_value_pairs_are_empty_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n List> keyValuePair = [];\n\n // Act\n Action act = () => dictionary1.Should().NotContain(keyValuePair,\n \"because we want to test the behaviour with an empty set of key/value pairs\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify key containment against an empty collection of key/value pairs*\");\n }\n\n [Fact]\n public void\n When_asserting_dictionary_does_not_contain_key_value_pairs_but_expected_key_value_pairs_are_null_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n List> keyValuePairs = null;\n\n // Act\n Action act = () =>\n dictionary1.Should().NotContain(keyValuePairs, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare dictionary with .*\")\n .WithParameterName(\"items\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_unexpected_value_or_key_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().NotContain(3, \"Three\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_unexpected_value_at_existing_key_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().NotContain(2, \"Three\");\n }\n\n [Fact]\n public void When_dictionary_does_not_have_the_unexpected_value_but_null_at_existing_key_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = null\n };\n\n // Act / Assert\n dictionary.Should().NotContain(1, \"other\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_unexpected_key_value_pairs_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n var items = new List>\n {\n new(3, \"Three\"),\n new(4, \"Four\")\n };\n\n dictionary.Should().NotContain(items);\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_unexpected_key_value_pair_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n var item = new KeyValuePair(3, \"Three\");\n dictionary.Should().NotContain(item);\n }\n\n [Fact]\n public void When_dictionary_contains_the_unexpected_value_at_specific_key_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n var item = new KeyValuePair(1, \"One\");\n Action act = () => dictionary.Should().NotContain(item, \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain value \\\"One\\\" at key 1 because we put it there, but found it anyhow.\");\n }\n\n [Fact]\n public void When_dictionary_contains_the_key_value_pairs_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n var items = new List>\n {\n new(1, \"One\"),\n new(2, \"Two\")\n };\n\n Action act = () => dictionary.Should().NotContain(items, \"we did not put them {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain key/value pairs {[1, One], [2, Two]} because we did not put them there, but found them anyhow.\");\n }\n\n [Fact]\n public void When_dictionary_contains_the_key_value_pair_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContain(1, \"One\", \"we did not put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain value \\\"One\\\" at key 1 because we did not put it there, but found it anyhow.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_does_not_contain_value_at_specific_key_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContain(1, \"One\", \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain value \\\"One\\\" at key 1 because we want to test the behaviour with a null subject, but dictionary is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringContainsStrategy.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringContainsStrategy : IStringComparisonStrategy\n{\n private readonly IEqualityComparer comparer;\n private readonly OccurrenceConstraint occurrenceConstraint;\n\n public StringContainsStrategy(IEqualityComparer comparer, OccurrenceConstraint occurrenceConstraint)\n {\n this.comparer = comparer;\n this.occurrenceConstraint = occurrenceConstraint;\n }\n\n public string ExpectationDescription => \"Expected {context:string} {0} to contain the equivalent of \";\n\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n int actual = subject.CountSubstring(expected, comparer);\n\n assertionChain\n .ForConstraint(occurrenceConstraint, actual)\n .FailWith(\n $\"{ExpectationDescription}{{1}} {{expectedOccurrence}}{{reason}}, but found it {actual.Times()}.\",\n subject, expected);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.ContainValue.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class ContainValue\n {\n [Fact]\n public void When_dictionary_contains_expected_value_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().ContainValue(\"One\");\n }\n\n [Fact]\n public void Can_continue_asserting_on_a_single_matching_item()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValue(\"One\").Which.Should().Be(\"Two\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Expected dictionary[1] to be*\\\"One\\\"*\\\"Two\\\"*\");\n }\n\n [Fact]\n public void Null_dictionaries_do_not_contain_any_values()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().ContainValue(\"One\", \"because {0}\", \"we do\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dictionary to contain values {\\\"One\\\"} because we do, but found .\");\n }\n\n [Fact]\n public void When_dictionary_contains_expected_null_value_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = null\n };\n\n // Act / Assert\n dictionary.Should().ContainValue(null);\n }\n\n [Fact]\n public void When_the_specified_value_exists_it_should_allow_continuation_using_that_value()\n {\n // Arrange\n var myClass = new MyClass\n {\n SomeProperty = 0\n };\n\n var dictionary = new Dictionary\n {\n [1] = myClass\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValue(myClass).Which.SomeProperty.Should().BeGreaterThan(0);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*greater*0*0*\");\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_single_value_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValue(\"Three\", \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain value \\\"Three\\\" because we do.\");\n }\n }\n\n public class NotContainValue\n {\n [Fact]\n public void When_dictionary_does_not_contain_a_value_that_is_not_in_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValue(\"Three\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_dictionary_contains_an_unexpected_value_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValue(\"One\", \"because we {0} like it\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} not to contain value \\\"One\\\" because we don't like it, but found it anyhow.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_does_not_contain_value_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContainValue(\"One\", \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain value \\\"One\\\" because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.ContainKey.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class ContainKey\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_a_key_from_the_dictionary()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().ContainKey(1);\n }\n\n [Fact]\n public void When_a_dictionary_has_custom_equality_comparer_the_contains_key_assertion_should_work_accordingly()\n {\n // Arrange\n var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase)\n {\n [\"One\"] = \"One\",\n [\"Two\"] = \"Two\"\n };\n\n // Act\n\n // Assert\n dictionary.Should().ContainKey(\"One\");\n dictionary.Should().ContainKey(\"ONE\");\n dictionary.Should().ContainKey(\"one\");\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_single_key_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainKey(3, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain key 3 because we do.\");\n }\n\n [Fact]\n public void When_the_requested_key_exists_it_should_allow_continuation_with_the_value()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [\"Key\"] = new() { SomeProperty = 3 }\n };\n\n // Act\n Action act = () => dictionary.Should().ContainKey(\"Key\").WhoseValue.Should().Be(4);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*4*3*.\");\n }\n\n [Fact]\n public void When_an_assertion_fails_on_ContainKey_succeeding_message_should_be_included()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var values = new Dictionary();\n values.Should().ContainKey(0);\n values.Should().ContainKey(1);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to contain key 0*Expected*to contain key 1*\");\n }\n }\n\n public class NotContainKey\n {\n [Fact]\n public void When_dictionary_does_not_contain_a_key_that_is_not_in_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKey(4);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_dictionary_contains_an_unexpected_key_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKey(1, \"because we {0} like it\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} not to contain key 1 because we don't like it, but found it anyhow.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_does_not_contain_key_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContainKey(1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain key 1 because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableNumericAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableNumericAssertions : NullableNumericAssertions>\n where T : struct, IComparable\n{\n public NullableNumericAssertions(T? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableNumericAssertions : NumericAssertionsBase\n where T : struct, IComparable\n where TAssertions : NullableNumericAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableNumericAssertions(T? value, AssertionChain assertionChain)\n : base(assertionChain)\n {\n Subject = value;\n this.assertionChain = assertionChain;\n }\n\n public override T? Subject { get; }\n\n /// \n /// Asserts that a nullable numeric value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected a value{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable numeric value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable numeric value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable numeric value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that the is satisfied.\n /// \n /// \n /// The predicate which must be satisfied\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .ForCondition(predicate.Compile()(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected value to match {0}{reason}, but found {1}.\", predicate, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCountGreaterThan.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveCountGreaterThan specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCountGreaterThan\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_greater_than_less_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountGreaterThan(2);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_greater_than_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCountGreaterThan(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_has_a_count_greater_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () =>\n collection.Should().HaveCountGreaterThan(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain more than 3 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_greater_than_and_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCountGreaterThan(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*more than*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCountLessThan.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveCountLessThan specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCountLessThan\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_less_than_less_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountLessThan(4);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_less_than_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCountLessThan(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_has_a_count_less_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () => collection.Should().HaveCountLessThan(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain fewer than 3 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_less_than_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCountLessThan(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*fewer than*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/TypeReflector.cs", "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class TypeReflector\n{\n public static IEnumerable GetAllTypesFromAppDomain(Func predicate)\n {\n return AppDomain.CurrentDomain\n .GetAssemblies()\n .Where(a => !IsDynamic(a) && IsRelevant(a) && predicate(a))\n .SelectMany(GetExportedTypes).ToArray();\n }\n\n private static bool IsRelevant(Assembly ass)\n {\n string assemblyName = ass.GetName().Name;\n\n return\n assemblyName is not null &&\n !assemblyName.StartsWith(\"microsoft.\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"xunit\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"jetbrains.\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"system\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"mscorlib\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"newtonsoft\", StringComparison.OrdinalIgnoreCase);\n }\n\n private static bool IsDynamic(Assembly assembly)\n {\n return assembly.GetType().FullName is \"System.Reflection.Emit.AssemblyBuilder\"\n or \"System.Reflection.Emit.InternalAssemblyBuilder\";\n }\n\n private static IEnumerable GetExportedTypes(Assembly assembly)\n {\n try\n {\n return assembly.GetExportedTypes();\n }\n catch (ReflectionTypeLoadException ex)\n {\n return ex.Types;\n }\n catch (FileLoadException)\n {\n return [];\n }\n catch (Exception)\n {\n return [];\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.Satisfy.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The Satisfy specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class Satisfy\n {\n [Fact]\n public void When_collection_element_at_each_position_matches_predicate_at_same_position_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 1,\n element => element == 2,\n element => element == 3);\n }\n\n [Fact]\n public void When_collection_element_at_each_position_matches_predicate_at_reverse_position_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 3,\n element => element == 2,\n element => element == 1);\n }\n\n [Fact]\n public void When_one_element_does_not_have_matching_predicate_Satisfy_should_throw()\n {\n // Arrange\n int[] collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().Satisfy(\n element => element == 3,\n element => element == 1,\n element => element == 2);\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected collection to satisfy all predicates, but:\n *The following predicates did not have matching elements:\n *(element == 3)\n \"\"\");\n }\n\n [Fact]\n public void\n When_some_predicates_have_multiple_matching_elements_and_most_restricitve_predicates_are_last_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 4];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 1 || element == 2 || element == 3 || element == 4,\n element => element == 1 || element == 2 || element == 3,\n element => element == 1 || element == 2,\n element => element == 1);\n }\n\n [Fact]\n public void\n When_some_predicates_have_multiple_matching_elements_and_most_restricitve_predicates_are_first_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 4];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 1,\n element => element == 1 || element == 2,\n element => element == 1 || element == 2 || element == 3,\n element => element == 1 || element == 2 || element == 3 || element == 4);\n }\n\n [Fact]\n public void When_second_predicate_matches_first_and_last_element_and_solution_exists_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 1,\n element => element == 1 || element == 3,\n element => element == 2);\n }\n\n [Fact]\n public void\n When_assertion_fails_then_failure_message_must_contain_predicates_without_matching_elements_and_elements_without_matching_predicates()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\", Number = 1 },\n new SomeClass { Text = \"two\", Number = 3 },\n new SomeClass { Text = \"three\", Number = 3 },\n new SomeClass { Text = \"four\", Number = 4 },\n ];\n\n // Act\n Action act = () => collection.Should().Satisfy(\n new Expression>[]\n {\n element => element.Text == \"four\" && element.Number == 4,\n element => element.Text == \"two\" && element.Number == 2,\n },\n because: \"we want to test formatting ({0})\",\n becauseArgs: \"args\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected collection to satisfy all predicates because we want to test formatting (args), but:\n *The following predicates did not have matching elements:\n *(element.Text == \"two\") AndAlso (element.Number == 2)\n *The following elements did not match any predicate:\n *Index: 0, Element:*AwesomeAssertions.Specs.Collections.CollectionAssertionSpecs+SomeClass*{*Number = 1*Text = \"one\"*}\n *Index: 1, Element:*AwesomeAssertions.Specs.Collections.CollectionAssertionSpecs+SomeClass*{*Number = 3*Text = \"two\"*}\n *Index: 2, Element:*AwesomeAssertions.Specs.Collections.CollectionAssertionSpecs+SomeClass*{*Number = 3*Text = \"three\"*}\n \"\"\");\n }\n\n [Fact]\n public void When_Satisfy_asserting_against_null_inspectors_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().Satisfy(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify against a collection of predicates*\");\n }\n\n [Fact]\n public void When_asserting_against_empty_inspectors_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().Satisfy();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify against an empty collection of predicates*\");\n }\n\n [Fact]\n public void When_asserting_collection_which_is_null_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n collection.Should().Satisfy(\n new Expression>[]\n {\n element => element == 1,\n element => element == 2,\n },\n because: \"we want to test the failure message ({0})\",\n becauseArgs: \"args\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to satisfy all predicates because we want to test the failure message (args), but collection is .\");\n }\n\n [Fact]\n public void When_asserting_collection_which_is_empty_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().Satisfy(\n new Expression>[]\n {\n element => element == 1,\n element => element == 2,\n },\n because: \"we want to test the failure message ({0})\",\n becauseArgs: \"args\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to satisfy all predicates because we want to test the failure message (args), but collection is empty.\");\n }\n\n [Fact]\n public void When_elements_are_integers_assertion_fails_then_failure_message_must_be_readable()\n {\n // Arrange\n var collection = new List { 1, 2, 3 };\n\n // Act\n Action act = () => collection.Should().Satisfy(\n element => element == 2);\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected collection to satisfy all predicates, but:\n *The following elements did not match any predicate:\n *Index: 0, Element: 1\n *Index: 2, Element: 3\n \"\"\");\n }\n }\n\n private class SomeClass\n {\n public string Text { get; set; }\n\n public int Number { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/SimpleTimeSpanAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class SimpleTimeSpanAssertions : SimpleTimeSpanAssertions\n{\n public SimpleTimeSpanAssertions(TimeSpan? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class SimpleTimeSpanAssertions\n where TAssertions : SimpleTimeSpanAssertions\n{\n public SimpleTimeSpanAssertions(TimeSpan? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public TimeSpan? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the time difference of the current is greater than zero.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BePositive([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject > TimeSpan.Zero)\n .FailWith(\"Expected {context:time} to be positive{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is less than zero.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNegative([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject < TimeSpan.Zero)\n .FailWith(\"Expected {context:time} to be negative{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is equal to the\n /// specified time.\n /// \n /// The expected time difference\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(expected == Subject)\n .FailWith(\"Expected {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is not equal to the\n /// specified time.\n /// \n /// The unexpected time difference\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TimeSpan unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(unexpected != Subject)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is less than the\n /// specified time.\n /// \n /// The time difference to which the current value will be compared\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThan(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject < expected)\n .FailWith(\"Expected {context:time} to be less than {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is less than or equal to the\n /// specified time.\n /// \n /// The time difference to which the current value will be compared\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThanOrEqualTo(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject <= expected)\n .FailWith(\"Expected {context:time} to be less than or equal to {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is greater than the\n /// specified time.\n /// \n /// The time difference to which the current value will be compared\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThan(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject > expected)\n .FailWith(\"Expected {context:time} to be greater than {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is greater than or equal to the\n /// specified time.\n /// \n /// The time difference to which the current value will be compared\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThanOrEqualTo(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject >= expected)\n .FailWith(\"Expected {context:time} to be greater than or equal to {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The expected time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(TimeSpan nearbyTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n TimeSpan minimumValue = nearbyTime - precision;\n TimeSpan maximumValue = nearbyTime + precision;\n\n CurrentAssertionChain\n .ForCondition(Subject >= minimumValue && Subject.Value <= maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be within {0} from {1}{reason}, but found {2}.\",\n precision,\n nearbyTime, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint NotBeCloseTo(TimeSpan distantTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n TimeSpan minimumValue = distantTime - precision;\n TimeSpan maximumValue = distantTime + precision;\n\n CurrentAssertionChain\n .ForCondition(Subject < minimumValue || Subject > maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to not be within {0} from {1}{reason}, but found {2}.\",\n precision,\n distantTime, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeCloseTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeCloseTo\n {\n [InlineData(sbyte.MinValue, sbyte.MinValue, 0)]\n [InlineData(sbyte.MinValue, sbyte.MinValue, 1)]\n [InlineData(sbyte.MinValue, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, sbyte.MinValue + 1, 1)]\n [InlineData(sbyte.MinValue, sbyte.MinValue + 1, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, -1, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue + 1, sbyte.MinValue, 1)]\n [InlineData(sbyte.MinValue + 1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue + 1, 0, sbyte.MaxValue)]\n [InlineData(-1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, sbyte.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, sbyte.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, sbyte.MaxValue)]\n [InlineData(0, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(0, sbyte.MinValue + 1, sbyte.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, sbyte.MaxValue)]\n [InlineData(1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue - 1, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MaxValue - 1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, 0, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, 1, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, 0)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue - 1, 1)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue - 1, sbyte.MaxValue)]\n [Theory]\n public void When_a_sbyte_value_is_close_to_expected_value_it_should_succeed(sbyte actual, sbyte nearbyValue,\n byte delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(sbyte.MinValue, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MinValue, 0, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, 1, sbyte.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(0, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MinValue, 1)]\n [InlineData(sbyte.MaxValue, -1, sbyte.MaxValue)]\n [Theory]\n public void When_a_sbyte_value_is_not_close_to_expected_value_it_should_fail(sbyte actual, sbyte nearbyValue,\n byte delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_sbyte_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n sbyte actual = 1;\n sbyte nearbyValue = 4;\n byte delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_a_sbyte_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n sbyte actual = sbyte.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(short.MinValue, short.MinValue, 0)]\n [InlineData(short.MinValue, short.MinValue, 1)]\n [InlineData(short.MinValue, short.MinValue, short.MaxValue)]\n [InlineData(short.MinValue, short.MinValue + 1, 1)]\n [InlineData(short.MinValue, short.MinValue + 1, short.MaxValue)]\n [InlineData(short.MinValue, -1, short.MaxValue)]\n [InlineData(short.MinValue + 1, short.MinValue, 1)]\n [InlineData(short.MinValue + 1, short.MinValue, short.MaxValue)]\n [InlineData(short.MinValue + 1, 0, short.MaxValue)]\n [InlineData(-1, short.MinValue, short.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, short.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, short.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, short.MaxValue)]\n [InlineData(0, short.MaxValue, short.MaxValue)]\n [InlineData(0, short.MinValue + 1, short.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, short.MaxValue)]\n [InlineData(1, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue - 1, short.MaxValue, 1)]\n [InlineData(short.MaxValue - 1, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue, 0, short.MaxValue)]\n [InlineData(short.MaxValue, 1, short.MaxValue)]\n [InlineData(short.MaxValue, short.MaxValue, 0)]\n [InlineData(short.MaxValue, short.MaxValue, 1)]\n [InlineData(short.MaxValue, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue, short.MaxValue - 1, 1)]\n [InlineData(short.MaxValue, short.MaxValue - 1, short.MaxValue)]\n [Theory]\n public void When_a_short_value_is_close_to_expected_value_it_should_succeed(short actual, short nearbyValue,\n ushort delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(short.MinValue, short.MaxValue, 1)]\n [InlineData(short.MinValue, 0, short.MaxValue)]\n [InlineData(short.MinValue, 1, short.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, short.MaxValue, short.MaxValue)]\n [InlineData(0, short.MinValue, short.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, short.MinValue, short.MaxValue)]\n [InlineData(short.MaxValue, short.MinValue, 1)]\n [InlineData(short.MaxValue, -1, short.MaxValue)]\n [Theory]\n public void When_a_short_value_is_not_close_to_expected_value_it_should_fail(short actual, short nearbyValue,\n ushort delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_short_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n short actual = 1;\n short nearbyValue = 4;\n ushort delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_a_short_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n short actual = short.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(int.MinValue, int.MinValue, 0)]\n [InlineData(int.MinValue, int.MinValue, 1)]\n [InlineData(int.MinValue, int.MinValue, int.MaxValue)]\n [InlineData(int.MinValue, int.MinValue + 1, 1)]\n [InlineData(int.MinValue, int.MinValue + 1, int.MaxValue)]\n [InlineData(int.MinValue, -1, int.MaxValue)]\n [InlineData(int.MinValue + 1, int.MinValue, 1)]\n [InlineData(int.MinValue + 1, int.MinValue, int.MaxValue)]\n [InlineData(int.MinValue + 1, 0, int.MaxValue)]\n [InlineData(-1, int.MinValue, int.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, int.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, int.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, int.MaxValue)]\n [InlineData(0, int.MaxValue, int.MaxValue)]\n [InlineData(0, int.MinValue + 1, int.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, int.MaxValue)]\n [InlineData(1, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue - 1, int.MaxValue, 1)]\n [InlineData(int.MaxValue - 1, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue, 0, int.MaxValue)]\n [InlineData(int.MaxValue, 1, int.MaxValue)]\n [InlineData(int.MaxValue, int.MaxValue, 0)]\n [InlineData(int.MaxValue, int.MaxValue, 1)]\n [InlineData(int.MaxValue, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue, int.MaxValue - 1, 1)]\n [InlineData(int.MaxValue, int.MaxValue - 1, int.MaxValue)]\n [Theory]\n public void When_an_int_value_is_close_to_expected_value_it_should_succeed(int actual, int nearbyValue, uint delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(int.MinValue, int.MaxValue, 1)]\n [InlineData(int.MinValue, 0, int.MaxValue)]\n [InlineData(int.MinValue, 1, int.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, int.MaxValue, int.MaxValue)]\n [InlineData(0, int.MinValue, int.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, int.MinValue, int.MaxValue)]\n [InlineData(int.MaxValue, int.MinValue, 1)]\n [InlineData(int.MaxValue, -1, int.MaxValue)]\n [Theory]\n public void When_an_int_value_is_not_close_to_expected_value_it_should_fail(int actual, int nearbyValue, uint delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_int_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n int actual = 1;\n int nearbyValue = 4;\n uint delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_an_int_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n int actual = int.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(long.MinValue, long.MinValue, 0)]\n [InlineData(long.MinValue, long.MinValue, 1)]\n [InlineData(long.MinValue, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(long.MinValue, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue, long.MinValue, ulong.MaxValue)]\n [InlineData(long.MinValue, long.MinValue + 1, 1)]\n [InlineData(long.MinValue, long.MinValue + 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MinValue + 1, ulong.MaxValue / 2)]\n [InlineData(long.MinValue, long.MinValue + 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue, long.MinValue + 1, ulong.MaxValue)]\n [InlineData(long.MinValue, -1, long.MaxValue)]\n [InlineData(long.MinValue + 1, long.MinValue, 1)]\n [InlineData(long.MinValue + 1, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue + 1, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(long.MinValue + 1, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue + 1, long.MinValue, ulong.MaxValue)]\n [InlineData(long.MinValue + 1, 0, ulong.MaxValue / 2)]\n [InlineData(long.MinValue + 1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue + 1, 0, ulong.MaxValue)]\n [InlineData(long.MinValue, long.MaxValue, ulong.MaxValue)]\n [InlineData(-1, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(-1, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(-1, long.MinValue, ulong.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(-1, 0, ulong.MaxValue / 2)]\n [InlineData(-1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(-1, 0, ulong.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, -1, ulong.MaxValue / 2)]\n [InlineData(0, -1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, -1, ulong.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, 1, ulong.MaxValue / 2)]\n [InlineData(0, 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, 1, ulong.MaxValue)]\n [InlineData(0, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(0, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, long.MaxValue, ulong.MaxValue)]\n [InlineData(0, long.MinValue + 1, ulong.MaxValue / 2)]\n [InlineData(0, long.MinValue + 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, long.MinValue + 1, ulong.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(1, 0, ulong.MaxValue / 2)]\n [InlineData(1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(1, 0, ulong.MaxValue)]\n [InlineData(1, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(1, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(1, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(1, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue - 1, long.MaxValue, 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue - 1, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue, 0, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, 0, ulong.MaxValue)]\n [InlineData(long.MaxValue, 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, 1, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, 1, ulong.MaxValue)]\n [InlineData(long.MaxValue, long.MaxValue, 0)]\n [InlineData(long.MaxValue, long.MaxValue, 1)]\n [InlineData(long.MaxValue, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue, long.MaxValue - 1, 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, long.MaxValue - 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, ulong.MaxValue)]\n [Theory]\n public void When_a_long_value_is_close_to_expected_value_it_should_succeed(long actual, long nearbyValue, ulong delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(long.MinValue, long.MaxValue, 1)]\n [InlineData(long.MinValue, 0, long.MaxValue)]\n [InlineData(long.MinValue, 1, long.MaxValue)]\n [InlineData(long.MinValue + 1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, long.MaxValue, long.MaxValue)]\n [InlineData(-1, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, long.MinValue, long.MaxValue)]\n [InlineData(0, long.MinValue + 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, long.MinValue, long.MaxValue)]\n [InlineData(long.MaxValue, long.MinValue, 1)]\n [InlineData(long.MaxValue, -1, long.MaxValue)]\n [InlineData(long.MaxValue, 0, (ulong.MaxValue / 2) - 1)]\n [Theory]\n public void When_a_long_value_is_not_close_to_expected_value_it_should_fail(long actual, long nearbyValue,\n ulong delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_long_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n long actual = 1;\n long nearbyValue = 4;\n ulong delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_a_long_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n long actual = long.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, byte.MaxValue, byte.MaxValue)]\n [InlineData(byte.MinValue, byte.MinValue + 1, byte.MaxValue)]\n [InlineData(byte.MinValue + 1, 0, byte.MaxValue)]\n [InlineData(byte.MinValue + 1, byte.MinValue, 1)]\n [InlineData(byte.MinValue + 1, byte.MinValue, byte.MaxValue)]\n [InlineData(byte.MaxValue - 1, byte.MaxValue, 1)]\n [InlineData(byte.MaxValue - 1, byte.MaxValue, byte.MaxValue)]\n [InlineData(byte.MaxValue, 0, byte.MaxValue)]\n [InlineData(byte.MaxValue, 1, byte.MaxValue)]\n [InlineData(byte.MaxValue, byte.MaxValue - 1, 1)]\n [InlineData(byte.MaxValue, byte.MaxValue - 1, byte.MaxValue)]\n [InlineData(byte.MaxValue, byte.MaxValue, 0)]\n [InlineData(byte.MaxValue, byte.MaxValue, 1)]\n [Theory]\n public void When_a_byte_value_is_close_to_expected_value_it_should_succeed(byte actual, byte nearbyValue, byte delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(byte.MinValue, byte.MaxValue, 1)]\n [InlineData(byte.MaxValue, byte.MinValue, 1)]\n [Theory]\n public void When_a_byte_value_is_not_close_to_expected_value_it_should_fail(byte actual, byte nearbyValue, byte delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_byte_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n byte actual = 1;\n byte nearbyValue = 4;\n byte delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_a_byte_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n byte actual = byte.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, ushort.MaxValue, ushort.MaxValue)]\n [InlineData(ushort.MinValue, ushort.MinValue + 1, ushort.MaxValue)]\n [InlineData(ushort.MinValue + 1, 0, ushort.MaxValue)]\n [InlineData(ushort.MinValue + 1, ushort.MinValue, 1)]\n [InlineData(ushort.MinValue + 1, ushort.MinValue, ushort.MaxValue)]\n [InlineData(ushort.MaxValue - 1, ushort.MaxValue, 1)]\n [InlineData(ushort.MaxValue - 1, ushort.MaxValue, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, 0, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, 1, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, ushort.MaxValue - 1, 1)]\n [InlineData(ushort.MaxValue, ushort.MaxValue - 1, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, ushort.MaxValue, 0)]\n [InlineData(ushort.MaxValue, ushort.MaxValue, 1)]\n [Theory]\n public void When_an_ushort_value_is_close_to_expected_value_it_should_succeed(ushort actual, ushort nearbyValue,\n ushort delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(ushort.MinValue, ushort.MaxValue, 1)]\n [InlineData(ushort.MaxValue, ushort.MinValue, 1)]\n [Theory]\n public void When_an_ushort_value_is_not_close_to_expected_value_it_should_fail(ushort actual, ushort nearbyValue,\n ushort delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_ushort_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n ushort actual = 1;\n ushort nearbyValue = 4;\n ushort delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_an_ushort_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n ushort actual = ushort.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, uint.MaxValue, uint.MaxValue)]\n [InlineData(uint.MinValue, uint.MinValue + 1, uint.MaxValue)]\n [InlineData(uint.MinValue + 1, 0, uint.MaxValue)]\n [InlineData(uint.MinValue + 1, uint.MinValue, 1)]\n [InlineData(uint.MinValue + 1, uint.MinValue, uint.MaxValue)]\n [InlineData(uint.MaxValue - 1, uint.MaxValue, 1)]\n [InlineData(uint.MaxValue - 1, uint.MaxValue, uint.MaxValue)]\n [InlineData(uint.MaxValue, 0, uint.MaxValue)]\n [InlineData(uint.MaxValue, 1, uint.MaxValue)]\n [InlineData(uint.MaxValue, uint.MaxValue - 1, 1)]\n [InlineData(uint.MaxValue, uint.MaxValue - 1, uint.MaxValue)]\n [InlineData(uint.MaxValue, uint.MaxValue, 0)]\n [InlineData(uint.MaxValue, uint.MaxValue, 1)]\n [Theory]\n public void When_an_uint_value_is_close_to_expected_value_it_should_succeed(uint actual, uint nearbyValue, uint delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(uint.MinValue, uint.MaxValue, 1)]\n [InlineData(uint.MaxValue, uint.MinValue, 1)]\n [Theory]\n public void When_an_uint_value_is_not_close_to_expected_value_it_should_fail(uint actual, uint nearbyValue,\n uint delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_uint_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n uint actual = 1;\n uint nearbyValue = 4;\n uint delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_an_uint_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n uint actual = uint.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, ulong.MaxValue, ulong.MaxValue)]\n [InlineData(ulong.MinValue, ulong.MinValue + 1, ulong.MaxValue)]\n [InlineData(ulong.MinValue + 1, 0, ulong.MaxValue)]\n [InlineData(ulong.MinValue + 1, ulong.MinValue, 1)]\n [InlineData(ulong.MinValue + 1, ulong.MinValue, ulong.MaxValue)]\n [InlineData(ulong.MaxValue - 1, ulong.MaxValue, 1)]\n [InlineData(ulong.MaxValue - 1, ulong.MaxValue, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, 0, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, 1, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, ulong.MaxValue - 1, 1)]\n [InlineData(ulong.MaxValue, ulong.MaxValue - 1, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, ulong.MaxValue, 0)]\n [InlineData(ulong.MaxValue, ulong.MaxValue, 1)]\n [Theory]\n public void When_an_ulong_value_is_close_to_expected_value_it_should_succeed(ulong actual, ulong nearbyValue,\n ulong delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(ulong.MinValue, ulong.MaxValue, 1)]\n [InlineData(ulong.MaxValue, ulong.MinValue, 1)]\n [Theory]\n public void When_an_ulong_value_is_not_close_to_expected_value_it_should_fail(ulong actual, ulong nearbyValue,\n ulong delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_ulong_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n ulong actual = 1;\n ulong nearbyValue = 4;\n ulong delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_an_ulong_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n ulong actual = ulong.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n }\n\n public class NotBeCloseTo\n {\n [InlineData(sbyte.MinValue, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MinValue, 0, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, 1, sbyte.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(0, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MinValue, 1)]\n [InlineData(sbyte.MaxValue, -1, sbyte.MaxValue)]\n [Theory]\n public void When_a_sbyte_value_is_not_close_to_expected_value_it_should_succeed(sbyte actual, sbyte distantValue,\n byte delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(sbyte.MinValue, sbyte.MinValue, 0)]\n [InlineData(sbyte.MinValue, sbyte.MinValue, 1)]\n [InlineData(sbyte.MinValue, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, sbyte.MinValue + 1, 1)]\n [InlineData(sbyte.MinValue, sbyte.MinValue + 1, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, -1, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue + 1, sbyte.MinValue, 1)]\n [InlineData(sbyte.MinValue + 1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue + 1, 0, sbyte.MaxValue)]\n [InlineData(-1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, sbyte.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, sbyte.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, sbyte.MaxValue)]\n [InlineData(0, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(0, sbyte.MinValue + 1, sbyte.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, sbyte.MaxValue)]\n [InlineData(1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue - 1, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MaxValue - 1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, 0, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, 1, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, 0)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue - 1, 1)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue - 1, sbyte.MaxValue)]\n [Theory]\n public void When_a_sbyte_value_is_close_to_expected_value_it_should_fail(sbyte actual, sbyte distantValue, byte delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_sbyte_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n sbyte actual = 1;\n sbyte nearbyValue = 3;\n byte delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_a_sbyte_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n sbyte actual = sbyte.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(short.MinValue, short.MaxValue, 1)]\n [InlineData(short.MinValue, 0, short.MaxValue)]\n [InlineData(short.MinValue, 1, short.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, short.MaxValue, short.MaxValue)]\n [InlineData(0, short.MinValue, short.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, short.MinValue, short.MaxValue)]\n [InlineData(short.MaxValue, short.MinValue, 1)]\n [InlineData(short.MaxValue, -1, short.MaxValue)]\n [Theory]\n public void When_a_short_value_is_not_close_to_expected_value_it_should_succeed(short actual, short distantValue,\n ushort delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(short.MinValue, short.MinValue, 0)]\n [InlineData(short.MinValue, short.MinValue, 1)]\n [InlineData(short.MinValue, short.MinValue, short.MaxValue)]\n [InlineData(short.MinValue, short.MinValue + 1, 1)]\n [InlineData(short.MinValue, short.MinValue + 1, short.MaxValue)]\n [InlineData(short.MinValue, -1, short.MaxValue)]\n [InlineData(short.MinValue + 1, short.MinValue, 1)]\n [InlineData(short.MinValue + 1, short.MinValue, short.MaxValue)]\n [InlineData(short.MinValue + 1, 0, short.MaxValue)]\n [InlineData(-1, short.MinValue, short.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, short.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, short.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, short.MaxValue)]\n [InlineData(0, short.MaxValue, short.MaxValue)]\n [InlineData(0, short.MinValue + 1, short.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, short.MaxValue)]\n [InlineData(1, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue - 1, short.MaxValue, 1)]\n [InlineData(short.MaxValue - 1, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue, 0, short.MaxValue)]\n [InlineData(short.MaxValue, 1, short.MaxValue)]\n [InlineData(short.MaxValue, short.MaxValue, 0)]\n [InlineData(short.MaxValue, short.MaxValue, 1)]\n [InlineData(short.MaxValue, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue, short.MaxValue - 1, 1)]\n [InlineData(short.MaxValue, short.MaxValue - 1, short.MaxValue)]\n [Theory]\n public void When_a_short_value_is_close_to_expected_value_it_should_fail(short actual, short distantValue,\n ushort delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_short_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n short actual = 1;\n short nearbyValue = 3;\n ushort delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_a_short_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n short actual = short.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(int.MinValue, int.MaxValue, 1)]\n [InlineData(int.MinValue, 0, int.MaxValue)]\n [InlineData(int.MinValue, 1, int.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, int.MaxValue, int.MaxValue)]\n [InlineData(0, int.MinValue, int.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, int.MinValue, int.MaxValue)]\n [InlineData(int.MaxValue, int.MinValue, 1)]\n [InlineData(int.MaxValue, -1, int.MaxValue)]\n [Theory]\n public void When_an_int_value_is_not_close_to_expected_value_it_should_succeed(int actual, int distantValue,\n uint delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(int.MinValue, int.MinValue, 0)]\n [InlineData(int.MinValue, int.MinValue, 1)]\n [InlineData(int.MinValue, int.MinValue, int.MaxValue)]\n [InlineData(int.MinValue, int.MinValue + 1, 1)]\n [InlineData(int.MinValue, int.MinValue + 1, int.MaxValue)]\n [InlineData(int.MinValue, -1, int.MaxValue)]\n [InlineData(int.MinValue + 1, int.MinValue, 1)]\n [InlineData(int.MinValue + 1, int.MinValue, int.MaxValue)]\n [InlineData(int.MinValue + 1, 0, int.MaxValue)]\n [InlineData(-1, int.MinValue, int.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, int.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, int.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, int.MaxValue)]\n [InlineData(0, int.MaxValue, int.MaxValue)]\n [InlineData(0, int.MinValue + 1, int.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, int.MaxValue)]\n [InlineData(1, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue - 1, int.MaxValue, 1)]\n [InlineData(int.MaxValue - 1, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue, 0, int.MaxValue)]\n [InlineData(int.MaxValue, 1, int.MaxValue)]\n [InlineData(int.MaxValue, int.MaxValue, 0)]\n [InlineData(int.MaxValue, int.MaxValue, 1)]\n [InlineData(int.MaxValue, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue, int.MaxValue - 1, 1)]\n [InlineData(int.MaxValue, int.MaxValue - 1, int.MaxValue)]\n [Theory]\n public void When_an_int_value_is_close_to_expected_value_it_should_fail(int actual, int distantValue, uint delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_int_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n int actual = 1;\n int nearbyValue = 3;\n uint delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_an_int_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n int actual = int.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(long.MinValue, long.MaxValue, 1)]\n [InlineData(long.MinValue, 0, long.MaxValue)]\n [InlineData(long.MinValue, 1, long.MaxValue)]\n [InlineData(long.MinValue + 1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, long.MaxValue, long.MaxValue)]\n [InlineData(-1, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, long.MinValue, long.MaxValue)]\n [InlineData(0, long.MinValue + 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, long.MinValue, long.MaxValue)]\n [InlineData(long.MaxValue, long.MinValue, 1)]\n [InlineData(long.MaxValue, -1, long.MaxValue)]\n [InlineData(long.MaxValue, 0, (ulong.MaxValue / 2) - 1)]\n [Theory]\n public void When_a_long_value_is_not_close_to_expected_value_it_should_succeed(long actual, long distantValue,\n ulong delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(long.MinValue, long.MinValue, 0)]\n [InlineData(long.MinValue, long.MinValue, 1)]\n [InlineData(long.MinValue, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(long.MinValue, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue, long.MinValue, ulong.MaxValue)]\n [InlineData(long.MinValue, long.MinValue + 1, 1)]\n [InlineData(long.MinValue, long.MinValue + 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MinValue + 1, ulong.MaxValue / 2)]\n [InlineData(long.MinValue, long.MinValue + 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue, long.MinValue + 1, ulong.MaxValue)]\n [InlineData(long.MinValue, -1, long.MaxValue)]\n [InlineData(long.MinValue + 1, long.MinValue, 1)]\n [InlineData(long.MinValue + 1, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue + 1, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(long.MinValue + 1, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue + 1, long.MinValue, ulong.MaxValue)]\n [InlineData(long.MinValue + 1, 0, ulong.MaxValue / 2)]\n [InlineData(long.MinValue + 1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue + 1, 0, ulong.MaxValue)]\n [InlineData(long.MinValue, long.MaxValue, ulong.MaxValue)]\n [InlineData(-1, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(-1, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(-1, long.MinValue, ulong.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(-1, 0, ulong.MaxValue / 2)]\n [InlineData(-1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(-1, 0, ulong.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, -1, ulong.MaxValue / 2)]\n [InlineData(0, -1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, -1, ulong.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, 1, ulong.MaxValue / 2)]\n [InlineData(0, 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, 1, ulong.MaxValue)]\n [InlineData(0, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(0, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, long.MaxValue, ulong.MaxValue)]\n [InlineData(0, long.MinValue + 1, ulong.MaxValue / 2)]\n [InlineData(0, long.MinValue + 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, long.MinValue + 1, ulong.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(1, 0, ulong.MaxValue / 2)]\n [InlineData(1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(1, 0, ulong.MaxValue)]\n [InlineData(1, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(1, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(1, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(1, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue - 1, long.MaxValue, 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue - 1, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue, 0, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, 0, ulong.MaxValue)]\n [InlineData(long.MaxValue, 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, 1, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, 1, ulong.MaxValue)]\n [InlineData(long.MaxValue, long.MaxValue, 0)]\n [InlineData(long.MaxValue, long.MaxValue, 1)]\n [InlineData(long.MaxValue, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue, long.MaxValue - 1, 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, long.MaxValue - 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, ulong.MaxValue)]\n [Theory]\n public void When_a_long_value_is_close_to_expected_value_it_should_fail(long actual, long distantValue, ulong delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_long_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n long actual = 1;\n long nearbyValue = 3;\n ulong delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_a_long_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n long actual = long.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(byte.MinValue, byte.MaxValue, 1)]\n [InlineData(byte.MaxValue, byte.MinValue, 1)]\n [Theory]\n public void When_a_byte_value_is_not_close_to_expected_value_it_should_succeed(byte actual, byte distantValue,\n byte delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, byte.MaxValue, byte.MaxValue)]\n [InlineData(byte.MinValue, byte.MinValue + 1, byte.MaxValue)]\n [InlineData(byte.MinValue + 1, 0, byte.MaxValue)]\n [InlineData(byte.MinValue + 1, byte.MinValue, 1)]\n [InlineData(byte.MinValue + 1, byte.MinValue, byte.MaxValue)]\n [InlineData(byte.MaxValue - 1, byte.MaxValue, 1)]\n [InlineData(byte.MaxValue - 1, byte.MaxValue, byte.MaxValue)]\n [InlineData(byte.MaxValue, 0, byte.MaxValue)]\n [InlineData(byte.MaxValue, 1, byte.MaxValue)]\n [InlineData(byte.MaxValue, byte.MaxValue - 1, 1)]\n [InlineData(byte.MaxValue, byte.MaxValue - 1, byte.MaxValue)]\n [InlineData(byte.MaxValue, byte.MaxValue, 0)]\n [InlineData(byte.MaxValue, byte.MaxValue, 1)]\n [Theory]\n public void When_a_byte_value_is_close_to_expected_value_it_should_fail(byte actual, byte distantValue, byte delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_byte_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n byte actual = 1;\n byte nearbyValue = 3;\n byte delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_a_byte_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n byte actual = byte.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(ushort.MinValue, ushort.MaxValue, 1)]\n [InlineData(ushort.MaxValue, ushort.MinValue, 1)]\n [Theory]\n public void When_an_ushort_value_is_not_close_to_expected_value_it_should_succeed(ushort actual, ushort distantValue,\n ushort delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, ushort.MaxValue, ushort.MaxValue)]\n [InlineData(ushort.MinValue, ushort.MinValue + 1, ushort.MaxValue)]\n [InlineData(ushort.MinValue + 1, 0, ushort.MaxValue)]\n [InlineData(ushort.MinValue + 1, ushort.MinValue, 1)]\n [InlineData(ushort.MinValue + 1, ushort.MinValue, ushort.MaxValue)]\n [InlineData(ushort.MaxValue - 1, ushort.MaxValue, 1)]\n [InlineData(ushort.MaxValue - 1, ushort.MaxValue, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, 0, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, 1, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, ushort.MaxValue - 1, 1)]\n [InlineData(ushort.MaxValue, ushort.MaxValue - 1, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, ushort.MaxValue, 0)]\n [InlineData(ushort.MaxValue, ushort.MaxValue, 1)]\n [Theory]\n public void When_an_ushort_value_is_close_to_expected_value_it_should_fail(ushort actual, ushort distantValue,\n ushort delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_ushort_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n ushort actual = 1;\n ushort nearbyValue = 3;\n ushort delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_an_ushort_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n ushort actual = ushort.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(uint.MinValue, uint.MaxValue, 1)]\n [InlineData(uint.MaxValue, uint.MinValue, 1)]\n [Theory]\n public void When_an_uint_value_is_not_close_to_expected_value_it_should_succeed(uint actual, uint distantValue,\n uint delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, uint.MaxValue, uint.MaxValue)]\n [InlineData(uint.MinValue, uint.MinValue + 1, uint.MaxValue)]\n [InlineData(uint.MinValue + 1, 0, uint.MaxValue)]\n [InlineData(uint.MinValue + 1, uint.MinValue, 1)]\n [InlineData(uint.MinValue + 1, uint.MinValue, uint.MaxValue)]\n [InlineData(uint.MaxValue - 1, uint.MaxValue, 1)]\n [InlineData(uint.MaxValue - 1, uint.MaxValue, uint.MaxValue)]\n [InlineData(uint.MaxValue, 0, uint.MaxValue)]\n [InlineData(uint.MaxValue, 1, uint.MaxValue)]\n [InlineData(uint.MaxValue, uint.MaxValue - 1, 1)]\n [InlineData(uint.MaxValue, uint.MaxValue - 1, uint.MaxValue)]\n [InlineData(uint.MaxValue, uint.MaxValue, 0)]\n [InlineData(uint.MaxValue, uint.MaxValue, 1)]\n [Theory]\n public void When_an_uint_value_is_close_to_expected_value_it_should_fail(uint actual, uint distantValue, uint delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_uint_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n uint actual = 1;\n uint nearbyValue = 3;\n uint delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_an_uint_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n uint actual = uint.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(ulong.MinValue, ulong.MaxValue, 1)]\n [InlineData(ulong.MaxValue, ulong.MinValue, 1)]\n [Theory]\n public void When_an_ulong_value_is_not_close_to_expected_value_it_should_succeed(ulong actual, ulong distantValue,\n ulong delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, ulong.MaxValue, ulong.MaxValue)]\n [InlineData(ulong.MinValue, ulong.MinValue + 1, ulong.MaxValue)]\n [InlineData(ulong.MinValue + 1, 0, ulong.MaxValue)]\n [InlineData(ulong.MinValue + 1, ulong.MinValue, 1)]\n [InlineData(ulong.MinValue + 1, ulong.MinValue, ulong.MaxValue)]\n [InlineData(ulong.MaxValue - 1, ulong.MaxValue, 1)]\n [InlineData(ulong.MaxValue - 1, ulong.MaxValue, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, 0, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, 1, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, ulong.MaxValue - 1, 1)]\n [InlineData(ulong.MaxValue, ulong.MaxValue - 1, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, ulong.MaxValue, 0)]\n [InlineData(ulong.MaxValue, ulong.MaxValue, 1)]\n [Theory]\n public void When_an_ulong_value_is_close_to_expected_value_it_should_fail(ulong actual, ulong distantValue,\n ulong delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_ulong_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n ulong actual = 1;\n ulong nearbyValue = 3;\n ulong delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_an_ulong_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n ulong actual = ulong.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveSameCount.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveSameCount\n {\n [Fact]\n public void When_dictionary_and_collection_have_the_same_number_elements_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 5, 6];\n\n // Act / Assert\n dictionary.Should().HaveSameCount(collection);\n }\n\n [Fact]\n public void When_dictionary_and_collection_do_not_have_the_same_number_of_elements_it_should_fail()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 6];\n\n // Act\n Action act = () => dictionary.Should().HaveSameCount(collection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to have 2 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_comparing_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 6];\n\n // Act\n Action act = () => dictionary.Should().HaveSameCount(collection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to have 2 item(s) because we want to test the reason, but found 3.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_and_collection_have_same_count_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => dictionary.Should().HaveSameCount(collection,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to have the same count as {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_dictionary_and_collection_have_same_count_against_a_null_collection_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = null;\n\n // Act\n Action act = () => dictionary.Should().HaveSameCount(collection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n }\n\n public class NotHaveSameCount\n {\n [Fact]\n public void When_asserting_not_same_count_and_collections_have_different_number_elements_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 6];\n\n // Act / Assert\n dictionary.Should().NotHaveSameCount(collection);\n }\n\n [Fact]\n public void When_asserting_not_same_count_and_both_collections_have_the_same_number_elements_it_should_fail()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 5, 6];\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not have 3 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_comparing_not_same_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 5, 6];\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not have 3 item(s) because we want to test the reason, but found 3.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_and_collection_to_not_have_same_count_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not have the same count as {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_dictionary_and_collection_to_not_have_same_count_against_a_null_collection_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = null;\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n\n [Fact]\n public void\n When_asserting_dictionary_and_collection_to_not_have_same_count_but_both_reference_the_same_object_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n var collection = dictionary;\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not have the same count*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.OnlyContain.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The OnlyContain specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class OnlyContain\n {\n [Fact]\n public void When_a_collection_does_not_contain_the_unexpected_items_it_should_not_be_enumerated_twice()\n {\n // Arrange\n var collection = new OneTimeEnumerable(1, 2, 3);\n\n // Act\n Action act = () => collection.Should().OnlyContain(i => i > 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain only items matching*\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_OnlyContain_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().OnlyContain(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_a_collection_contains_items_not_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [2, 12, 3, 11, 2];\n\n // Act\n Action act = () => collection.Should().OnlyContain(i => i <= 10, \"10 is the maximum\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain only items matching (i <= 10) because 10 is the maximum, but {12, 11} do(es) not match.\");\n }\n\n [Fact]\n public void When_a_collection_is_empty_and_should_contain_only_items_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable strings = [];\n\n // Act / Assert\n strings.Should().OnlyContain(e => e.Length > 0);\n }\n\n [Fact]\n public void When_a_collection_contains_only_items_matching_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [2, 9, 3, 8, 2];\n\n // Act / Assert\n collection.Should().OnlyContain(i => i <= 10);\n }\n\n [Fact]\n public void When_a_collection_is_null_then_only_contains_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyContain(i => i <= 10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to contain only items matching (i <= 10) *failure message*,\" +\n \" but the collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/ExtensibilitySpecs.cs", "using System;\nusing AwesomeAssertions.Primitives;\nusing ExampleExtensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class ExtensibilitySpecs\n{\n [Fact]\n public void Methods_marked_as_custom_assertion_are_ignored_during_caller_identification()\n {\n // Arrange\n var myClient = new MyCustomer\n {\n Active = false\n };\n\n // Act\n Action act = () => myClient.Should().BeActive(\"because we don't work with old clients\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected myClient to be true because we don't work with old clients, but found False.\");\n }\n\n [Fact]\n public void Methods_in_assemblies_marked_as_custom_assertion_are_ignored_during_caller_identification()\n {\n // Arrange\n string palindrome = \"fluent\";\n\n // Act\n Action act = () => palindrome.Should().BePalindromic();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected palindrome to be*tneulf*\");\n }\n\n [Fact]\n public void Methods_and_generated_methods_in_classes_marked_as_custom_assertions_are_ignored_during_caller_identification()\n {\n string expectedSubjectName = \"any\";\n\n // Act\n Action act = () => expectedSubjectName.Should().MethodWithGeneratedDisplayClass();\n\n // Arrange\n act.Should().Throw()\n .WithMessage(\"Expected expectedSubjectName something, failure \\\"message\\\"\");\n }\n}\n\n[CustomAssertions]\npublic static class CustomAssertionExtensions\n{\n public static void MethodWithGeneratedDisplayClass(this StringAssertions assertions)\n {\n assertions.CurrentAssertionChain\n .WithExpectation(\"Expected {context:FallbackIdentifier} something\", chain =>\n chain\n .ForCondition(condition: false)\n .FailWith(\", failure {0}\", \"message\")\n );\n }\n}\n\ninternal class MyCustomer\n{\n public bool Active { get; set; }\n}\n\ninternal static class MyCustomerExtensions\n{\n public static MyCustomerAssertions Should(this MyCustomer customer)\n {\n return new MyCustomerAssertions(customer);\n }\n}\n\ninternal class MyCustomerAssertions\n{\n private readonly MyCustomer customer;\n\n public MyCustomerAssertions(MyCustomer customer)\n {\n this.customer = customer;\n }\n\n [CustomAssertion]\n public void BeActive(string because = \"\", params object[] becauseArgs)\n {\n customer.Active.Should().BeTrue(because, becauseArgs);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeEquivalentTo.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeEquivalentTo\n {\n [Fact]\n public void Can_ignore_casing_while_comparing_objects_with_string_properties()\n {\n // Arrange\n var actual = new { foo = \"test\" };\n var expectation = new { foo = \"TEST\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_objects_with_string_properties()\n {\n // Arrange\n var actual = new { foo = \" test\" };\n var expectation = new { foo = \"test\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_objects_with_string_properties()\n {\n // Arrange\n var actual = new { foo = \"test \" };\n var expectation = new { foo = \"test\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_objects_with_string_properties()\n {\n // Arrange\n var actual = new { foo = \"A\\nB\\r\\nC\" };\n var expectation = new { foo = \"A\\r\\nB\\nC\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringNewlineStyle());\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainItemsAssignableTo.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The ContainItemsAssignableTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class ContainItemsAssignableTo\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_with_all_items_of_same_type_only_contains_item_of_one_type()\n {\n // Arrange\n string[] collection = [\"1\", \"2\", \"3\"];\n\n // Act / Assert\n collection.Should().ContainItemsAssignableTo();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_with_items_of_different_types_contains_item_of_expected_type()\n {\n // Arrange\n var collection = new List\n {\n 1,\n \"2\"\n };\n\n // Act / Assert\n collection.Should().ContainItemsAssignableTo();\n }\n\n [Fact]\n public void When_asserting_collection_contains_item_assignable_to_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainItemsAssignableTo(\"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain at least one element assignable to type string because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_a_collection_is_empty_an_exception_should_be_thrown()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().ContainItemsAssignableTo();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to contain at least one element assignable to type int, but found {empty}.\");\n }\n\n [Fact]\n public void Should_throw_exception_when_asserting_collection_for_missing_item_type()\n {\n var collection = new object[] { \"1\", 1.0m };\n\n Action act = () => collection.Should().ContainItemsAssignableTo();\n\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to contain at least one element assignable to type int, but found {string, decimal}.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.AllBeEquivalentTo.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class CollectionAssertionSpecs\n{\n public class AllBeEquivalentTo\n {\n [Fact]\n public void Can_ignore_casing_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"test\", \"tEst\", \"Test\", \"TEst\", \"teST\" };\n var expectation = \"test\";\n\n // Act / Assert\n actual.Should().AllBeEquivalentTo(expectation, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \" test\", \"test\", \"\\ttest\", \"\\ntest\", \" \\t \\n test\" };\n var expectation = \"test\";\n\n // Act / Assert\n actual.Should().AllBeEquivalentTo(expectation, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"test \", \"test\", \"test\\t\", \"test\\n\", \"test \\t \\n \" };\n var expectation = \"test\";\n\n // Act / Assert\n actual.Should().AllBeEquivalentTo(expectation, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"A\\nB\\nC\", \"A\\r\\nB\\r\\nC\", \"A\\r\\nB\\nC\", \"A\\nB\\r\\nC\" };\n var expectation = \"A\\nB\\nC\";\n\n // Act / Assert\n actual.Should().AllBeEquivalentTo(expectation, o => o.IgnoringNewlineStyle());\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/ConstructorInfoAssertions.cs", "using System.Diagnostics;\nusing System.Reflection;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class ConstructorInfoAssertions : MethodBaseAssertions\n{\n /// \n /// Initializes a new instance of the class.\n /// \n /// The constructorInfo from which to select properties.\n /// \n public ConstructorInfoAssertions(ConstructorInfo constructorInfo, AssertionChain assertionChain)\n : base(constructorInfo, assertionChain)\n {\n }\n\n private protected override string SubjectDescription => GetDescriptionFor(Subject);\n\n protected override string Identifier => \"constructor\";\n\n private static string GetDescriptionFor(ConstructorInfo constructorInfo)\n {\n return $\"{constructorInfo.DeclaringType}({GetParameterString(constructorInfo)})\";\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/BeEquivalentToBenchmarks.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Collections;\nusing BenchmarkDotNet.Attributes;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\n[RyuJitX86Job]\npublic class BeEquivalentToBenchmarks\n{\n private List list;\n private List list2;\n\n [Params(10, 100, 1_000, 5_000, 10_000)]\n public int N { get; set; }\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n int objectCount = 0;\n\n list = Enumerable.Range(0, N).Select(_ => Nested.Create(1, ref objectCount)).ToList();\n\n objectCount = 0;\n\n list2 = Enumerable.Range(0, N).Select(_ => Nested.Create(1, ref objectCount)).ToList();\n }\n\n [Benchmark]\n public AndConstraint> BeEquivalentTo() => list.Should().BeEquivalentTo(list2);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/Clock.cs", "using System;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Default implementation for for production use.\n/// \ninternal class Clock : IClock\n{\n public void Delay(TimeSpan timeToDelay) => Task.Delay(timeToDelay).GetAwaiter().GetResult();\n\n public Task DelayAsync(TimeSpan delay, CancellationToken cancellationToken)\n {\n return Task.Delay(delay, cancellationToken);\n }\n\n public ITimer StartTimer() => new StopwatchTimer();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/SimpleTimeSpanAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic class SimpleTimeSpanAssertionSpecs\n{\n [Fact]\n public void When_asserting_positive_value_to_be_positive_it_should_succeed()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds();\n\n // Act / Assert\n timeSpan.Should().BePositive();\n }\n\n [Fact]\n public void When_asserting_negative_value_to_be_positive_it_should_fail()\n {\n // Arrange\n TimeSpan negatedTimeSpan = 1.Seconds().Negate();\n\n // Act\n Action act = () => negatedTimeSpan.Should().BePositive();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_zero_value_to_be_positive_it_should_fail()\n {\n // Arrange\n TimeSpan negatedTimeSpan = 0.Seconds();\n\n // Act\n Action act = () => negatedTimeSpan.Should().BePositive();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_positive_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n\n // Act\n Action act = () => nullTimeSpan.Should().BePositive(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be positive because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_negative_value_to_be_positive_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds().Negate();\n\n // Act\n Action act = () => timeSpan.Should().BePositive(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected timeSpan to be positive because we want to test the failure message, but found -1s.\");\n }\n\n [Fact]\n public void When_asserting_negative_value_to_be_negative_it_should_succeed()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds().Negate();\n\n // Act / Assert\n timeSpan.Should().BeNegative();\n }\n\n [Fact]\n public void When_asserting_positive_value_to_be_negative_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n\n // Act\n Action act = () => actual.Should().BeNegative();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_zero_value_to_be_negative_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 0.Seconds();\n\n // Act\n Action act = () => actual.Should().BeNegative();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_negative_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n\n // Act\n Action act = () => nullTimeSpan.Should().BeNegative(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be negative because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_positive_value_to_be_negative_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds();\n\n // Act\n Action act = () => timeSpan.Should().BeNegative(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected timeSpan to be negative because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_equal_to_same_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n var expected = TimeSpan.FromSeconds(1);\n\n // Act / Assert\n actual.Should().Be(expected);\n }\n\n [Fact]\n public void When_asserting_value_to_be_equal_to_different_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan expected = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_null_is_not_equal_to_another_value()\n {\n // Arrange\n var subject = new SimpleTimeSpanAssertions(null, AssertionChain.GetOrCreate());\n TimeSpan expected = 2.Seconds();\n\n // Act\n Action act = () => subject.Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_equal_to_different_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => nullTimeSpan.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_equal_to_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds();\n\n // Act\n Action act = () => timeSpan.Should().Be(2.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected 2s because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_not_equal_to_different_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan unexpected = 2.Seconds();\n\n // Act / Assert\n actual.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_not_equal_to_different_value_it_should_succeed()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act / Assert\n nullTimeSpan.Should().NotBe(expected);\n }\n\n [Fact]\n public void When_asserting_value_to_be_not_equal_to_the_same_value_it_should_fail()\n {\n // Arrange\n var oneSecond = 1.Seconds();\n\n // Act\n Action act = () => oneSecond.Should().NotBe(oneSecond);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_not_equal_to_the_same_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var oneSecond = 1.Seconds();\n\n // Act\n Action act = () => oneSecond.Should().NotBe(oneSecond, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect 1s because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_smaller_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n TimeSpan smaller = 1.Seconds();\n\n // Act / Assert\n actual.Should().BeGreaterThan(smaller);\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_greater_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan expected = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().BeGreaterThan(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_greater_than_other_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => nullTimeSpan.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be greater than 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_same_value_it_should_fail()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act\n Action act = () => twoSeconds.Should().BeGreaterThan(twoSeconds);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_greater_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n\n // Act\n Action act = () => actual.Should().BeGreaterThan(2.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be greater than 2s because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_or_equal_to_smaller_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n TimeSpan smaller = 1.Seconds();\n\n // Act / Assert\n actual.Should().BeGreaterThanOrEqualTo(smaller);\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_greater_than_or_equal_to_other_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () =>\n nullTimeSpan.Should().BeGreaterThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be greater than or equal to 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_or_equal_to_same_value_it_should_succeed()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act / Assert\n twoSeconds.Should().BeGreaterThanOrEqualTo(twoSeconds);\n }\n\n [Fact]\n public void Chaining_after_one_assertion_1()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act / Assert\n twoSeconds.Should().BeGreaterThanOrEqualTo(twoSeconds).And.Be(2.Seconds());\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_or_equal_to_greater_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan expected = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().BeGreaterThanOrEqualTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_or_equal_to_greater_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n\n // Act\n Action act = () =>\n actual.Should().BeGreaterThanOrEqualTo(2.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be greater than or equal to 2s because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_greater_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan greater = 2.Seconds();\n\n // Act / Assert\n actual.Should().BeLessThan(greater);\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_smaller_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => actual.Should().BeLessThan(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_less_than_other_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => nullTimeSpan.Should().BeLessThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be less than 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_same_value_it_should_fail()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act\n Action act = () => twoSeconds.Should().BeLessThan(twoSeconds);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_smaller_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().BeLessThan(1.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be less than 1s because we want to test the failure message, but found 2s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_or_equal_to_greater_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan greater = 2.Seconds();\n\n // Act / Assert\n actual.Should().BeLessThanOrEqualTo(greater);\n }\n\n [Fact]\n public void Chaining_after_one_assertion_2()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan greater = 2.Seconds();\n\n // Act / Assert\n actual.Should().BeLessThanOrEqualTo(greater).And.Be(1.Seconds());\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_less_than_or_equal_to_other_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () =>\n nullTimeSpan.Should().BeLessThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be less than or equal to 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_or_equal_to_same_value_it_should_succeed()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act / Assert\n twoSeconds.Should().BeLessThanOrEqualTo(twoSeconds);\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_or_equal_to_smaller_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => actual.Should().BeLessThanOrEqualTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_or_equal_to_smaller_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().BeLessThanOrEqualTo(1.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be less than or equal to 1s because we want to test the failure message, but found 2s.\");\n }\n\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n TimeSpan someTimeSpan = 2.Seconds();\n\n // Act\n Action act = () => someTimeSpan.Should().Equals(someTimeSpan);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n\n #region Be Close To\n\n [Fact]\n public void When_asserting_that_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 980);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_time_is_less_then_but_close_to_another_value_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 980);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_time_is_greater_then_but_close_to_another_value_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 020);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_time_is_less_then_and_not_close_to_another_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 979);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds(), \"we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from 1d, 12h, 15m and 31s because we want to test the error message, but found 1d, 12h, 15m, 30s and 979ms.\");\n }\n\n [Fact]\n public void When_time_is_greater_then_and_not_close_to_another_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 021);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds(), \"we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from 1d, 12h, 15m and 31s because we want to test the error message, but found 1d, 12h, 15m, 31s and 21ms.\");\n }\n\n [Fact]\n public void When_time_is_within_specified_number_of_milliseconds_from_another_value_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 035);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n }\n\n [Fact]\n public void When_a_null_time_is_asserted_to_be_close_to_another_it_should_throw()\n {\n // Arrange\n TimeSpan? time = null;\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n [Fact]\n public void When_time_away_from_another_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 979);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () =>\n time.Should().BeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20), \"we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from 1d, 12h, 15m and 31s because we want to test the error message, but found 1d, 12h, 15m, 30s and 979ms.\");\n }\n\n #endregion\n\n #region Not Be Close To\n\n [Fact]\n public void When_asserting_that_time_is_not_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 980);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_a_later_time_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 980);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected time to not be within 20ms from 1d, 12h, 15m and 31s, but found 1d, 12h, 15m, 30s and 980ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 020);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected time to not be within 20ms from 1d, 12h, 15m and 31s, but found 1d, 12h, 15m, 31s and 20ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_by_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 020);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected time to not be within 20ms from 1d, 12h, 15m and 31s, but found 1d, 12h, 15m, 31s and 20ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_another_value_that_is_later_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 979);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 021);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_by_35ms_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 035);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected time to not be within 35ms from 1d, 12h, 15m and 31s, but found 1d, 12h, 15m, 31s and 35ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_time_is_not_close_to_another_it_should_throw()\n {\n // Arrange\n TimeSpan? time = null;\n TimeSpan nearbyTime = TimeSpan.FromHours(1);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/CallerStatementBuilder.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class CallerStatementBuilder\n{\n private readonly StringBuilder statement;\n private readonly List priorityOrderedParsingStrategies;\n private ParsingState parsingState = ParsingState.InProgress;\n\n internal CallerStatementBuilder()\n {\n statement = new StringBuilder();\n\n priorityOrderedParsingStrategies =\n [\n new QuotesParsingStrategy(),\n new MultiLineCommentParsingStrategy(),\n new SingleLineCommentParsingStrategy(),\n new SemicolonParsingStrategy(),\n new ShouldCallParsingStrategy(),\n new AwaitParsingStrategy(),\n new AddNonEmptySymbolParsingStrategy()\n ];\n }\n\n internal void Append(string symbols)\n {\n using var symbolEnumerator = symbols.GetEnumerator();\n\n while (symbolEnumerator.MoveNext() && parsingState != ParsingState.Done)\n {\n var hasParsingStrategyWaitingForEndContext = priorityOrderedParsingStrategies\n .Exists(s => s.IsWaitingForContextEnd());\n\n parsingState = ParsingState.InProgress;\n\n foreach (var parsingStrategy in\n priorityOrderedParsingStrategies\n .SkipWhile(parsingStrategy =>\n hasParsingStrategyWaitingForEndContext\n && !parsingStrategy.IsWaitingForContextEnd()))\n {\n parsingState = parsingStrategy.Parse(symbolEnumerator.Current, statement);\n\n if (parsingState != ParsingState.InProgress)\n {\n break;\n }\n }\n }\n\n if (IsDone())\n {\n return;\n }\n\n priorityOrderedParsingStrategies\n .ForEach(strategy => strategy.NotifyEndOfLineReached());\n }\n\n internal bool IsDone() => parsingState == ParsingState.Done;\n\n public override string ToString() => statement.ToString();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/TaskCompletionSourceAssertionsBase.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Specialized;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n/// \n/// Implements base functionality for assertions on TaskCompletionSource.\n/// \npublic class TaskCompletionSourceAssertionsBase\n{\n protected TaskCompletionSourceAssertionsBase(IClock clock)\n {\n Clock = clock ?? throw new ArgumentNullException(nameof(clock));\n }\n\n private protected IClock Clock { get; }\n\n /// \n [SuppressMessage(\"Design\", \"CA1065:Do not raise exceptions in unexpected locations\")]\n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean CompleteWithinAsync() instead?\");\n\n /// \n /// Monitors the specified task whether it completes withing the remaining time span.\n /// \n private protected async Task CompletesWithinTimeoutAsync(Task target, TimeSpan remainingTime)\n {\n using var timeoutCancellationTokenSource = new CancellationTokenSource();\n\n Task completedTask =\n await Task.WhenAny(target, Clock.DelayAsync(remainingTime, timeoutCancellationTokenSource.Token));\n\n if (completedTask != target)\n {\n return false;\n }\n\n // cancel the clock\n#pragma warning disable CA1849 // Call async methods when in an async method: Is not a drop-in replacement in this case, but may cause problems.\n timeoutCancellationTokenSource.Cancel();\n#pragma warning restore CA1849 // Call async methods when in an async method\n return true;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/NotThrowSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\n#if NET47\nusing AwesomeAssertions.Specs.Common;\n#endif\nusing Xunit;\nusing Xunit.Sdk;\nusing static AwesomeAssertions.Extensions.FluentTimeSpanExtensions;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class NotThrowSpecs\n{\n [Fact]\n public void When_subject_is_null_when_an_exception_should_not_be_thrown_it_should_throw()\n {\n // Arrange\n Action act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n act.Should().NotThrow(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_a_specific_exception_should_not_be_thrown_but_it_was_it_should_throw()\n {\n // Arrange\n Does foo = Does.Throw(new ArgumentException(\"An exception was forced\"));\n\n // Act\n Action action =\n () => foo.Invoking(f => f.Do()).Should().NotThrow(\"we passed valid arguments\");\n\n // Assert\n action\n .Should().Throw().WithMessage(\n \"Did not expect System.ArgumentException because we passed valid arguments, \" +\n \"but found System.ArgumentException: An exception was forced*\");\n }\n\n [Fact]\n public void When_a_specific_exception_should_not_be_thrown_but_another_was_it_should_succeed()\n {\n // Arrange\n Does foo = Does.Throw();\n\n // Act / Assert\n foo.Invoking(f => f.Do()).Should().NotThrow();\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_but_it_was_it_should_throw()\n {\n // Arrange\n Does foo = Does.Throw(new ArgumentException(\"An exception was forced\"));\n\n // Act\n Action action = () => foo.Invoking(f => f.Do()).Should().NotThrow(\"we passed valid arguments\");\n\n // Assert\n action\n .Should().Throw().WithMessage(\n \"Did not expect any exception because we passed valid arguments, \" +\n \"but found System.ArgumentException: An exception was forced*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_and_none_was_it_should_not_throw()\n {\n // Arrange\n Does foo = Does.NotThrow();\n\n // Act / Assert\n foo.Invoking(f => f.Do()).Should().NotThrow();\n }\n\n [Fact]\n public void When_subject_is_null_when_it_should_not_throw_it_should_throw()\n {\n // Arrange\n Action act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n\n act.Should().NotThrowAfter(0.Milliseconds(), 0.Milliseconds(),\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n#pragma warning disable CS1998, MA0147\n [Fact]\n public void When_subject_is_async_it_should_throw()\n {\n // Arrange\n Action someAsyncAction = async () => { };\n\n // Act\n Action action = () =>\n someAsyncAction.Should().NotThrowAfter(1.Milliseconds(), 1.Milliseconds());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Cannot use action assertions on an async void method.*\");\n }\n#pragma warning restore CS1998, MA0147\n\n [Fact]\n public void When_wait_time_is_negative_it_should_throw()\n {\n // Arrange\n var waitTime = -1.Milliseconds();\n var pollInterval = 10.Milliseconds();\n Action someAction = () => { };\n\n // Act\n Action action = () =>\n someAction.Should().NotThrowAfter(waitTime, pollInterval);\n\n // Assert\n action.Should().Throw()\n .WithParameterName(\"waitTime\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_poll_interval_is_negative_it_should_throw()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = -1.Milliseconds();\n Action someAction = () => { };\n\n // Act\n Action action = () =>\n someAction.Should().NotThrowAfter(waitTime, pollInterval);\n\n // Assert\n action.Should().Throw()\n .WithParameterName(\"pollInterval\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_but_it_was_it_should_throw()\n {\n // Arrange\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n\n Action throwLongerThanWaitTime = () =>\n {\n if (timer.Elapsed < waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n };\n\n // Act\n Action action = () =>\n throwLongerThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect any exceptions after 100ms because we passed valid arguments*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_and_none_was_it_should_not_throw()\n {\n // Arrange\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n Action throwShorterThanWaitTime = () =>\n {\n if (timer.Elapsed <= waitTime.Divide(2))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n };\n\n // Act / Assert\n throwShorterThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/GivenSelectorExtensions.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Execution;\n\ninternal static class GivenSelectorExtensions\n{\n public static ContinuationOfGiven> AssertCollectionIsNotNull(\n this GivenSelector> givenSelector)\n {\n return givenSelector\n .ForCondition(items => items is not null)\n .FailWith(\"but found collection is .\");\n }\n\n public static ContinuationOfGiven> AssertEitherCollectionIsNotEmpty(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .ForCondition(items => items.Count > 0 || length == 0)\n .FailWith(\"but found empty collection.\")\n .Then\n .ForCondition(items => items.Count == 0 || length > 0)\n .FailWith(\"but found {0}.\", items => items);\n }\n\n public static ContinuationOfGiven> AssertCollectionHasEnoughItems(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .Given(items => items.ConvertOrCastToCollection())\n .AssertCollectionHasEnoughItems(length);\n }\n\n public static ContinuationOfGiven> AssertCollectionHasEnoughItems(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .ForCondition(items => items.Count >= length)\n .FailWith(\"but {0} contains {1} item(s) less.\", items => items, items => length - items.Count);\n }\n\n public static ContinuationOfGiven> AssertCollectionHasNotTooManyItems(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .ForCondition(items => items.Count <= length)\n .FailWith(\"but {0} contains {1} item(s) too many.\", items => items, items => items.Count - length);\n }\n\n public static ContinuationOfGiven> AssertCollectionsHaveSameCount(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .AssertEitherCollectionIsNotEmpty(length)\n .Then\n .AssertCollectionHasEnoughItems(length)\n .Then\n .AssertCollectionHasNotTooManyItems(length);\n }\n\n public static ContinuationOfGiven> AssertCollectionsHaveSameItems(\n this GivenSelector> givenSelector,\n ICollection expected, Func, ICollection, int> findIndex)\n {\n return givenSelector\n .Given>(actual => new CollectionWithIndex(actual, findIndex(actual, expected)))\n .ForCondition(diff => diff.As>().Index == -1)\n .FailWith(\"but {0} differs at index {1}.\",\n diff => diff.As>().Items,\n diff => diff.As>().Index);\n }\n\n private sealed class CollectionWithIndex : ICollection\n {\n public ICollection Items { get; }\n\n public int Index { get; }\n\n public CollectionWithIndex(ICollection items, int index)\n {\n Items = items;\n Index = index;\n }\n\n public int Count => Items.Count;\n\n public bool IsReadOnly => Items.IsReadOnly;\n\n public void Add(T item) => Items.Add(item);\n\n public void Clear() => Items.Clear();\n\n public bool Contains(T item) => Items.Contains(item);\n\n public void CopyTo(T[] array, int arrayIndex) => Items.CopyTo(array, arrayIndex);\n\n public IEnumerator GetEnumerator() => Items.GetEnumerator();\n\n public bool Remove(T item) => Items.Remove(item);\n\n IEnumerator IEnumerable.GetEnumerator() => Items.GetEnumerator();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.EndWithEquivalentOf.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]EndWithEquivalentOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class EndWithEquivalentOf\n {\n [Fact]\n public void Succeed_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act\n Action act = () => actual.Should().EndWithEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_end_with_another()\n {\n // Arrange\n string actual = \"prefix for test\";\n string expect = \"TEST\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_end_with_another()\n {\n // Arrange\n string actual = \" prefix for test\";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_end_with_another()\n {\n // Arrange\n string actual = \"prefix for test \";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_end_with_another()\n {\n // Arrange\n string actual = \"prefix for \\rA\\nB\\r\\nC\";\n string expect = \"A\\r\\nB\\nC\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n }\n\n [Fact]\n public void When_suffix_of_string_differs_by_case_only_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedSuffix = \"bC\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expectedSuffix);\n }\n\n [Fact]\n public void When_end_of_string_differs_by_case_only_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedSuffix = \"AbC\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expectedSuffix);\n }\n\n [Fact]\n public void When_end_of_string_does_not_meet_equivalent_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWithEquivalentOf(\"ab\", \"because it should end\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to end with equivalent of \\\"ab\\\" because it should end, but \\\"ABC\\\" differs near \\\"ABC\\\" (index 0).\");\n }\n\n [Fact]\n public void When_end_of_string_is_compared_with_equivalent_of_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWithEquivalentOf(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare string end equivalence with .*\");\n }\n\n [Fact]\n public void When_end_of_string_is_compared_with_equivalent_of_empty_string_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().EndWithEquivalentOf(\"\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_equivalent_of_string_that_is_longer_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWithEquivalentOf(\"00abc\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to end with equivalent of \" +\n \"\\\"00abc\\\", but \" +\n \"\\\"ABC\\\" is too short.\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_equivalent_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someString.Should().EndWithEquivalentOf(\"abC\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString to end with equivalent of \\\"abC\\\", but found .\");\n }\n }\n\n public class NotEndWithEquivalentOf\n {\n [Fact]\n public void Succeed_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act / Assert\n actual.Should().NotEndWithEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_not_end_with_another()\n {\n // Arrange\n string actual = \"prefix for test\";\n string expect = \"TEST\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_not_end_with_another()\n {\n // Arrange\n string actual = \" prefix for test\";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_not_end_with_another()\n {\n // Arrange\n string actual = \"prefix for test \";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_not_end_with_another()\n {\n // Arrange\n string actual = \"prefix for \\rA\\nB\\r\\nC\\n\";\n string expect = \"A\\r\\nB\\nC\\r\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_equivalent_of_a_value_and_it_does_not_it_should_succeed()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().NotEndWithEquivalentOf(\"aB\");\n }\n\n [Fact]\n public void\n When_asserting_string_does_not_end_with_equivalent_of_a_value_but_it_does_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWithEquivalentOf(\"Bc\", \"because of some {0}\", \"reason\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to end with equivalent of \\\"Bc\\\" because of some reason, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_equivalent_of_a_value_that_is_null_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWithEquivalentOf(null);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Cannot compare end of string with .*\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_equivalent_of_a_value_that_is_empty_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWithEquivalentOf(\"\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to end with equivalent of \\\"\\\", but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_equivalent_of_a_value_and_actual_value_is_null_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someString.Should().NotEndWithEquivalentOf(\"Abc\", \"some {0}\", \"reason\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to end with equivalent of \\\"Abc\\\"*some reason*, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.MatchRegex.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]MatchRegex specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class MatchRegex\n {\n [Fact]\n public void When_a_string_matches_a_regular_expression_string_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n // ReSharper disable once StringLiteralTypo\n subject.Should().MatchRegex(\"h.*\\\\sworld.$\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_a_string_does_not_match_a_regular_expression_string_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(\"h.*\\\\sworld?$\", \"that's the universal greeting\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected subject to match regex*\\\"h.*\\\\sworld?$\\\" because that's the universal greeting, but*\\\"hello world!\\\" does not match.\");\n }\n\n [Fact]\n public void When_a_null_string_is_matched_against_a_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () => subject.Should().MatchRegex(\".*\", \"because it should be a string\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match regex*\\\".*\\\" because it should be a string, but it was .\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_a_null_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchRegex((string)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the BeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_invalid_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n string invalidRegex = \".**\"; // Use local variable for this invalid regex to avoid static R# analysis errors\n\n // Act\n Action act = () => subject.Should().MatchRegex(invalidRegex);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match subject against \\\".**\\\" because it is not a valid regular expression.*\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_invalid_regex_string_it_should_only_have_one_failure_message()\n {\n // Arrange\n string subject = \"hello world!\";\n string invalidRegex = \".**\"; // Use local variable for this invalid regex to avoid static R# analysis errors\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(invalidRegex);\n };\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Contain(\"is not a valid regular expression\")\n .And.NotContain(\"does not match\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_empty_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_matches_a_regular_expression_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n // ReSharper disable once StringLiteralTypo\n subject.Should().MatchRegex(new Regex(\"h.*\\\\sworld.$\"));\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_a_string_does_not_match_a_regular_expression_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(new Regex(\"h.*\\\\sworld?$\"), \"that's the universal greeting\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected subject to match regex*\\\"h.*\\\\sworld?$\\\" because that's the universal greeting, but*\\\"hello world!\\\" does not match.\");\n }\n\n [Fact]\n public void When_a_null_string_is_matched_against_a_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(new Regex(\".*\"), \"because it should be a string\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match regex*\\\".*\\\" because it should be a string, but it was .\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_a_null_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchRegex((Regex)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the BeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_empty_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(new Regex(string.Empty));\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_matched_and_the_count_of_matches_fits_into_the_expected_it_passes()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act / Assert\n subject.Should().MatchRegex(new Regex(\"hello.*\"), AtLeast.Once());\n }\n\n [Fact]\n public void When_a_string_is_matched_and_the_count_of_matches_do_not_fit_the_expected_it_fails()\n {\n // Arrange\n string subject = \"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt \" +\n \"ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et \" +\n \"ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(\"Lorem.*\", Exactly.Twice());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject*Lorem*to match regex*\\\"Lorem.*\\\" exactly 2 times, but found it 1 time*\");\n }\n\n [Fact]\n public void When_a_string_is_matched_and_the_expected_count_is_zero_and_string_not_matches_it_passes()\n {\n // Arrange\n string subject = \"a\";\n\n // Act / Assert\n subject.Should().MatchRegex(\"b\", Exactly.Times(0));\n }\n\n [Fact]\n public void When_a_string_is_matched_and_the_expected_count_is_zero_and_string_matches_it_fails()\n {\n // Arrange\n string subject = \"a\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(\"a\", Exactly.Times(0));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject*a*to match regex*\\\"a\\\" exactly 0 times, but found it 1 time*\");\n }\n\n [Fact]\n public void When_the_subject_is_null_it_fails()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(\".*\", Exactly.Times(0), \"because it should be a string\");\n };\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Expected subject to match regex*\\\".*\\\" because it should be a string, but it was .\");\n }\n\n [Fact]\n public void When_the_subject_is_empty_and_expected_count_is_zero_it_passes()\n {\n // Arrange\n string subject = string.Empty;\n\n // Act / Assert\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(\"a\", Exactly.Times(0));\n }\n\n [Fact]\n public void When_the_subject_is_empty_and_expected_count_is_more_than_zero_it_fails()\n {\n // Arrange\n string subject = string.Empty;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(\".+\", AtLeast.Once());\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject*to match regex* at least 1 time, but found it 0 times*\");\n }\n\n [Fact]\n public void When_regex_is_null_it_fails_and_ignores_occurrences()\n {\n // Arrange\n string subject = \"a\";\n\n // Act\n Action act = () => subject.Should().MatchRegex((Regex)null, Exactly.Times(0));\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the BeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_regex_is_empty_it_fails_and_ignores_occurrences()\n {\n // Arrange\n string subject = \"a\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(string.Empty, Exactly.Times(0));\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_regex_is_invalid_it_fails_and_ignores_occurrences()\n {\n // Arrange\n string subject = \"a\";\n\n // Act\n#pragma warning disable RE0001 // Invalid regex pattern\n Action act = () => subject.Should().MatchRegex(\".**\", Exactly.Times(0));\n#pragma warning restore RE0001 // Invalid regex pattern\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match subject against \\\".**\\\" because it is not a valid regular expression.*\");\n }\n }\n\n public class NotMatchRegex\n {\n [Fact]\n public void When_a_string_does_not_match_a_regular_expression_string_and_it_shouldnt_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n subject.Should().NotMatchRegex(\".*earth.*\");\n }\n\n [Fact]\n public void When_a_string_matches_a_regular_expression_string_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(\".*world.*\", \"because that's illegal\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect subject to match regex*\\\".*world.*\\\" because that's illegal, but*\\\"hello world!\\\" matches.\");\n }\n\n [Fact]\n public void When_a_null_string_is_negatively_matched_against_a_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(\".*\", \"because it should not be a string\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to not match regex*\\\".*\\\" because it should not be a string, but it was .\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_a_null_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex((string)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the NotBeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_invalid_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n string invalidRegex = \".**\"; // Use local variable for this invalid regex to avoid static R# analysis errors\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(invalidRegex);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match subject against \\\".**\\\" because it is not a valid regular expression.*\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_invalid_regex_string_it_only_contain_one_failure_message()\n {\n // Arrange\n string subject = \"hello world!\";\n string invalidRegex = \".**\"; // Use local variable for this invalid regex to avoid static R# analysis errors\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().NotMatchRegex(invalidRegex);\n };\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Contain(\"is not a valid regular expression\")\n .And.NotContain(\"matches\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_empty_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty regex pattern. Provide a regex pattern or use the NotBeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_does_not_match_a_regular_expression_and_it_shouldnt_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n subject.Should().NotMatchRegex(new Regex(\".*earth.*\"));\n }\n\n [Fact]\n public void When_a_string_matches_a_regular_expression_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(new Regex(\".*world.*\"), \"because that's illegal\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect subject to match regex*\\\".*world.*\\\" because that's illegal, but*\\\"hello world!\\\" matches.\");\n }\n\n [Fact]\n public void When_a_null_string_is_negatively_matched_against_a_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().NotMatchRegex(new Regex(\".*\"), \"because it should not be a string\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to not match regex*\\\".*\\\" because it should not be a string, but it was .\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_a_null_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex((Regex)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the NotBeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_empty_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(new Regex(string.Empty));\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty regex pattern. Provide a regex pattern or use the NotBeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.OnlyHaveUniqueItems.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The OnlyHaveUniqueItems specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class OnlyHaveUniqueItems\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_with_unique_items_contains_only_unique_items()\n {\n // Arrange\n int[] collection = [1, 2, 3, 4];\n\n // Act / Assert\n collection.Should().OnlyHaveUniqueItems();\n }\n\n [Fact]\n public void When_a_collection_contains_duplicate_items_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 3];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(\"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we don't like duplicates, but item 3 is not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_duplicate_items_it_supports_chaining()\n {\n // Arrange\n int[] collection = [1, 2, 3, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems().And.HaveCount(c => c > 1);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but item 3 is not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_multiple_duplicate_items_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3, 3];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(\"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we don't like duplicates, but items {2, 3} are not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_multiple_duplicate_items_it_supports_chaining()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems().And.HaveCount(c => c > 1);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but items {2, 3} are not unique.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_only_have_unique_items_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems(\"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_OnlyHaveUniqueItems_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_with_a_predicate_a_collection_with_unique_items_contains_only_unique_items()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"three\" },\n new SomeClass { Text = \"four\" }\n ];\n\n // Act / Assert\n collection.Should().OnlyHaveUniqueItems(e => e.Text);\n }\n\n [Fact]\n public void When_a_collection_contains_duplicate_items_with_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"three\" },\n new SomeClass { Text = \"three\" }\n ];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(e => e.Text, \"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items*on e.Text*because we don't like duplicates, but item*three*is not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_multiple_duplicate_items_with_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"three\" },\n new SomeClass { Text = \"three\" }\n ];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(e => e.Text, \"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items*on e.Text*because we don't like duplicates, but items*two*two*three*three*are not unique.\");\n }\n\n [Fact]\n public void Only_the_first_failing_assertion_in_a_chain_is_reported()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\", Number = 1 },\n new SomeClass { Text = \"two\", Number = 2 },\n new SomeClass { Text = \"two\", Number = 2 },\n new SomeClass { Text = \"three\", Number = 3 },\n new SomeClass { Text = \"three\", Number = 4 }\n ];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems(e => e.Text).And.OnlyHaveUniqueItems(e => e.Number);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*have unique items on e.Text*\");\n }\n\n [Fact]\n public void\n When_asserting_with_a_predicate_a_collection_to_only_have_unique_items_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems(e => e.Text, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/OccurrenceConstraintSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class OccurrenceConstraintSpecs\n{\n public static TheoryData PassingConstraints => new()\n {\n { AtLeast.Once(), 1 },\n { AtLeast.Once(), 2 },\n { AtLeast.Twice(), 2 },\n { AtLeast.Twice(), 3 },\n { AtLeast.Thrice(), 3 },\n { AtLeast.Thrice(), 4 },\n { AtLeast.Times(4), 4 },\n { AtLeast.Times(4), 5 },\n { 4.TimesOrMore(), 4 },\n { 4.TimesOrMore(), 5 },\n { AtMost.Once(), 0 },\n { AtMost.Once(), 1 },\n { AtMost.Twice(), 1 },\n { AtMost.Twice(), 2 },\n { AtMost.Thrice(), 2 },\n { AtMost.Thrice(), 3 },\n { AtMost.Times(4), 3 },\n { AtMost.Times(4), 4 },\n { 4.TimesOrLess(), 4 },\n { 4.TimesOrLess(), 1 },\n { Exactly.Once(), 1 },\n { Exactly.Twice(), 2 },\n { Exactly.Thrice(), 3 },\n { Exactly.Times(4), 4 },\n { 4.TimesExactly(), 4 },\n { LessThan.Twice(), 1 },\n { LessThan.Thrice(), 2 },\n { LessThan.Times(4), 3 },\n { MoreThan.Once(), 2 },\n { MoreThan.Twice(), 3 },\n { MoreThan.Thrice(), 4 },\n { MoreThan.Times(4), 5 }\n };\n\n [Theory]\n [MemberData(nameof(PassingConstraints))]\n public void Occurrence_constraint_passes(OccurrenceConstraint constraint, int occurrences)\n {\n // Act / Assert\n AssertionChain.GetOrCreate()\n .ForConstraint(constraint, occurrences)\n .FailWith(\"\");\n }\n\n public static TheoryData FailingConstraints => new()\n {\n { AtLeast.Once(), 0 },\n { AtLeast.Twice(), 1 },\n { AtLeast.Thrice(), 2 },\n { AtLeast.Times(4), 3 },\n { 4.TimesOrMore(), 3 },\n { AtMost.Once(), 2 },\n { AtMost.Twice(), 3 },\n { AtMost.Thrice(), 4 },\n { AtMost.Times(4), 5 },\n { 4.TimesOrLess(), 5 },\n { Exactly.Once(), 0 },\n { Exactly.Once(), 2 },\n { Exactly.Twice(), 1 },\n { Exactly.Twice(), 3 },\n { Exactly.Thrice(), 2 },\n { Exactly.Thrice(), 4 },\n { Exactly.Times(4), 3 },\n { Exactly.Times(4), 5 },\n { 4.TimesExactly(), 1 },\n { LessThan.Twice(), 2 },\n { LessThan.Twice(), 3 },\n { LessThan.Thrice(), 3 },\n { LessThan.Thrice(), 4 },\n { LessThan.Times(4), 4 },\n { LessThan.Times(4), 5 },\n { MoreThan.Once(), 0 },\n { MoreThan.Once(), 1 },\n { MoreThan.Twice(), 1 },\n { MoreThan.Twice(), 2 },\n { MoreThan.Thrice(), 2 },\n { MoreThan.Thrice(), 3 },\n { MoreThan.Times(4), 3 },\n { MoreThan.Times(4), 4 },\n };\n\n [Theory]\n [MemberData(nameof(FailingConstraints))]\n public void Occurrence_constraint_fails(OccurrenceConstraint constraint, int occurrences)\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForConstraint(constraint, occurrences)\n .FailWith($\"Expected occurrence to be {constraint.Mode} {constraint.ExpectedCount}, but it was {occurrences}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected occurrence to be *, but it was *\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/FindAssembly.cs", "using System;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Specs;\n\npublic static class FindAssembly\n{\n public static Assembly Containing() => typeof(T).Assembly;\n\n public static Assembly Stub(string publicKey) => new AssemblyStub(publicKey);\n\n private sealed class AssemblyStub : Assembly\n {\n private readonly AssemblyName assemblyName = new();\n\n public override string FullName => nameof(AssemblyStub);\n\n public AssemblyStub(string publicKey)\n {\n assemblyName.SetPublicKey(FromHexString(publicKey));\n }\n\n public override AssemblyName GetName() => assemblyName;\n\n#if NET6_0_OR_GREATER\n private static byte[] FromHexString(string chars)\n => chars is null\n ? null\n : Convert.FromHexString(chars);\n#else\n private static byte[] FromHexString(string chars)\n {\n if (chars is null)\n {\n return null;\n }\n\n var bytes = new byte[chars.Length / 2];\n\n for (var i = 0; i < bytes.Length; i++)\n {\n var bits = chars.Substring(i * 2, 2);\n bytes[i] = Convert.ToByte(bits, 16);\n }\n\n return bytes;\n }\n#endif\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AssertionExtensions.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Specialized;\n\nnamespace AwesomeAssertions.Specs;\n\ninternal static class AssertionExtensions\n{\n private static readonly AggregateExceptionExtractor Extractor = new();\n\n public static NonGenericAsyncFunctionAssertions Should(this Func action, IClock clock)\n {\n return new NonGenericAsyncFunctionAssertions(action, Extractor, AssertionChain.GetOrCreate(), clock);\n }\n\n public static GenericAsyncFunctionAssertions Should(this Func> action, IClock clock)\n {\n return new GenericAsyncFunctionAssertions(action, Extractor, AssertionChain.GetOrCreate(), clock);\n }\n\n public static ActionAssertions Should(this Action action, IClock clock)\n {\n return new ActionAssertions(action, Extractor, AssertionChain.GetOrCreate(), clock);\n }\n\n public static FunctionAssertions Should(this Func func, IClock clock)\n {\n return new FunctionAssertions(func, Extractor, AssertionChain.GetOrCreate(), clock);\n }\n\n public static TaskCompletionSourceAssertions Should(this TaskCompletionSource tcs, IClock clock)\n {\n return new TaskCompletionSourceAssertions(tcs, AssertionChain.GetOrCreate(), clock);\n }\n\n#if NET6_0_OR_GREATER\n public static TaskCompletionSourceAssertions Should(this TaskCompletionSource tcs, IClock clock)\n {\n return new TaskCompletionSourceAssertions(tcs, AssertionChain.GetOrCreate(), clock);\n }\n\n#endif\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventRecorder.cs", "using System;\nusing System.Collections;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Reflection;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Records activity for a single event.\n/// \n[DebuggerNonUserCode]\ninternal sealed class EventRecorder : IEventRecording, IDisposable\n{\n private readonly Func utcNow;\n private readonly BlockingCollection raisedEvents = [];\n private readonly object lockable = new();\n private Action cleanup;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The object events are recorded from\n /// The name of the event that's recorded\n /// A delegate to get the current date and time in UTC format.\n /// Class used to generate a sequence in a thread-safe manner.\n public EventRecorder(object eventRaiser, string eventName, Func utcNow,\n ThreadSafeSequenceGenerator sequenceGenerator)\n {\n this.utcNow = utcNow;\n EventObject = eventRaiser;\n EventName = eventName;\n this.sequenceGenerator = sequenceGenerator;\n }\n\n /// \n /// The object events are recorded from\n /// \n public object EventObject { get; private set; }\n\n /// \n public string EventName { get; }\n\n private readonly ThreadSafeSequenceGenerator sequenceGenerator;\n\n public Type EventHandlerType { get; private set; }\n\n public void Attach(WeakReference subject, EventInfo eventInfo)\n {\n EventHandlerType = eventInfo.EventHandlerType;\n\n Delegate handler = EventHandlerFactory.GenerateHandler(eventInfo.EventHandlerType, this);\n eventInfo.AddEventHandler(subject.Target, handler);\n\n cleanup = () =>\n {\n if (subject.Target is not null)\n {\n eventInfo.RemoveEventHandler(subject.Target, handler);\n }\n };\n }\n\n public void Dispose()\n {\n Action localCleanup = cleanup;\n if (localCleanup is not null)\n {\n localCleanup();\n cleanup = null;\n EventObject = null;\n raisedEvents.Dispose();\n }\n }\n\n /// \n /// Called by the auto-generated IL, to record information about a raised event.\n /// \n [UsedImplicitly]\n public void RecordEvent(params object[] parameters)\n {\n lock (lockable)\n {\n raisedEvents.Add(new RecordedEvent(utcNow(), sequenceGenerator.Increment(), parameters));\n }\n }\n\n /// \n /// Resets recorder to clear records of events raised so far.\n /// \n public void Reset()\n {\n lock (lockable)\n {\n while (raisedEvents.Count > 0)\n {\n raisedEvents.TryTake(out _);\n }\n }\n }\n\n IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n\n public IEnumerator GetEnumerator()\n {\n foreach (RecordedEvent @event in raisedEvents.ToArray())\n {\n yield return new OccurredEvent\n {\n EventName = EventName,\n Parameters = @event.Parameters,\n TimestampUtc = @event.TimestampUtc,\n Sequence = @event.Sequence\n };\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CustomAssertionsAttribute.cs", "using System;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Marks a class as containing extensions to Awesome Assertions that either uses the built-in assertions\n/// internally, or directly uses AssertionChain.\n/// \n[AttributeUsage(AttributeTargets.Class)]\npublic sealed class CustomAssertionsAttribute : Attribute;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CustomAssertionsAssemblyAttribute.cs", "using System;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Marks an assembly as containing extensions to Awesome Assertions that either uses the built-in assertions\n/// internally, or directly uses AssertionChain.\n/// \n[AttributeUsage(AttributeTargets.Assembly)]\npublic sealed class CustomAssertionsAssemblyAttribute : Attribute;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.HaveCount.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class HaveCount\n {\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_that_is_different_from_the_number_of_items()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveCount(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().HaveCount(3);\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should()\n .HaveCount(3)\n .And\n .HaveElementAt(1, \"two\")\n .And.NotContain(\"four\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_null_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveCount(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare collection count against a predicate.*\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_predicate_and_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act =\n () => collection.Should().HaveCount(c => c < 3, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain (c < 3) items because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_and_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().HaveCount(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain 1 item(s) because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_has_a_count_larger_than_the_minimum_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().HaveCount(c => c >= 3);\n }\n\n [Fact]\n public void\n When_collection_has_a_count_that_is_different_from_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action action = () => collection.Should().HaveCount(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain 4 item(s) because we want to test the failure message, but found 3: {\\\"one\\\", \\\"two\\\", \\\"three\\\"}.\");\n }\n\n [Fact]\n public void When_collection_has_a_count_that_not_matches_the_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveCount(c => c >= 4, \"a minimum of 4 is required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have a count (c >= 4) because a minimum of 4 is required, but count is 3: {\\\"one\\\", \\\"two\\\", \\\"three\\\"}.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeEquivalentTo.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeEquivalentTo specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeEquivalentTo\n {\n [Fact]\n public void Succeed_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_comparing_strings_to_be_equivalent()\n {\n // Arrange\n string actual = \"test\";\n string expect = \"TEST\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_strings_to_be_equivalent()\n {\n // Arrange\n string actual = \" test\";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_strings_to_be_equivalent()\n {\n // Arrange\n string actual = \"test \";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_strings_to_be_equivalent()\n {\n // Arrange\n string actual = \"A\\nB\\r\\nC\";\n string expect = \"A\\r\\nB\\nC\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.IgnoringNewlineStyle());\n }\n\n [Fact]\n public void When_strings_are_the_same_while_ignoring_case_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedEquivalent = \"abc\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectedEquivalent);\n }\n\n [Fact]\n public void When_strings_differ_other_than_by_case_it_should_throw()\n {\n // Act\n Action act = () => \"ADC\".Should().BeEquivalentTo(\"abc\", \"we will test {0} + {1}\", 1, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent *because we will test 1 + 2, but*index 1*\\\"ADC\\\"*\\\"abc\\\"*.\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_non_null_string_is_expected_to_be_equivalent_to_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABCDEF\".Should().BeEquivalentTo(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent to , but found \\\"ABCDEF\\\".\");\n }\n\n [Fact]\n public void When_non_empty_string_is_expected_to_be_equivalent_to_empty_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().BeEquivalentTo(\"\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent * index 0*\\\"ABC\\\"*\\\"\\\"*.\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_is_equivalent_but_too_short_it_should_throw()\n {\n // Act\n Action act = () => \"AB\".Should().BeEquivalentTo(\"ABCD\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent *index 2*\\\"AB\\\"*\\\"ABCD\\\"*.\");\n }\n\n [Fact]\n public void When_string_equivalence_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().BeEquivalentTo(\"abc\", \"we will test {0} + {1}\", 1, 2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someString to be equivalent to \\\"abc\\\" because we will test 1 + 2, but found .\");\n }\n\n [Fact]\n public void\n When_the_expected_string_is_equivalent_to_the_actual_string_but_with_trailing_spaces_it_should_throw_with_clear_error_message()\n {\n // Act\n Action act = () => \"ABC\".Should().BeEquivalentTo(\"abc \", \"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent to \\\"abc \\\" because I say so, but it misses some extra whitespace at the end.\");\n }\n\n [Fact]\n public void\n When_the_actual_string_equivalent_to_the_expected_but_with_trailing_spaces_it_should_throw_with_clear_error_message()\n {\n // Act\n Action act = () => \"ABC \".Should().BeEquivalentTo(\"abc\", \"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent to \\\"abc\\\" because I say so, but it has unexpected whitespace at the end.\");\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void Succeed_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act / Assert\n actual.Should().NotBeEquivalentTo(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_comparing_strings_to_not_be_equivalent()\n {\n // Arrange\n string actual = \"test\";\n string expect = \"TEST\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_strings_to_not_be_equivalent()\n {\n // Arrange\n string actual = \" test\";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_strings_to_not_be_equivalent()\n {\n // Arrange\n string actual = \"test \";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_strings_to_not_be_equivalent()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n\";\n string expect = \"\\nA\\r\\nB\\nC\\r\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_strings_are_the_same_while_ignoring_case_it_should_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string unexpected = \"abc\";\n\n // Act\n Action action = () => actual.Should().NotBeEquivalentTo(unexpected, \"because I say {0}\", \"so\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected actual not to be equivalent to \\\"abc\\\" because I say so, but they are.\");\n }\n\n [Fact]\n public void When_strings_differ_other_than_by_case_it_should_not_throw()\n {\n // Act / Assert\n \"ADC\".Should().NotBeEquivalentTo(\"abc\");\n }\n\n [Fact]\n public void When_non_null_string_is_expected_to_be_equivalent_to_null_it_should_not_throw()\n {\n // Act / Assert\n \"ABCDEF\".Should().NotBeEquivalentTo(null);\n }\n\n [Fact]\n public void When_non_empty_string_is_expected_to_be_equivalent_to_empty_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().NotBeEquivalentTo(\"\");\n }\n\n [Fact]\n public void When_string_is_equivalent_but_too_short_it_should_not_throw()\n {\n // Act / Assert\n \"AB\".Should().NotBeEquivalentTo(\"ABCD\");\n }\n\n [Fact]\n public void When_string_equivalence_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string someString = null;\n\n // Act / Assert\n someString.Should().NotBeEquivalentTo(\"abc\");\n }\n\n [Fact]\n public void When_the_expected_string_is_equivalent_to_the_actual_string_but_with_trailing_spaces_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().NotBeEquivalentTo(\"abc \");\n }\n\n [Fact]\n public void When_the_actual_string_equivalent_to_the_expected_but_with_trailing_spaces_it_should_not_throw()\n {\n // Act / Assert\n \"ABC \".Should().NotBeEquivalentTo(\"abc\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.BeEmpty.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_without_items_is_empty()\n {\n // Arrange\n var dictionary = new Dictionary();\n\n // Act / Assert\n dictionary.Should().BeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_with_items_is_empty()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\"\n };\n\n // Act\n Action act = () => dictionary.Should().BeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_dictionary_with_items_is_empty()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\"\n };\n\n // Act\n Action act = () => dictionary.Should().BeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected dictionary to be empty because we want to test the failure message, but found at least one item {[1, One]}.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_to_be_empty_but_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().BeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void When_asserting_dictionary_with_items_is_not_empty_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\"\n };\n\n // Act / Assert\n dictionary.Should().NotBeEmpty();\n }\n\n#if !NET5_0_OR_GREATER\n [Fact]\n public void When_asserting_dictionary_with_items_is_not_empty_it_should_enumerate_the_dictionary_only_once()\n {\n // Arrange\n var trackingDictionary = new TrackingTestDictionary(new KeyValuePair(1, \"One\"));\n\n // Act\n trackingDictionary.Should().NotBeEmpty();\n\n // Assert\n trackingDictionary.Enumerator.LoopCount.Should().Be(1);\n }\n\n#endif\n\n [Fact]\n public void When_asserting_dictionary_without_items_is_not_empty_it_should_fail()\n {\n // Arrange\n var dictionary = new Dictionary();\n\n // Act\n Action act = () => dictionary.Should().NotBeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_dictionary_without_items_is_not_empty_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary();\n\n // Act\n Action act = () => dictionary.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dictionary not to be empty because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_to_be_not_empty_but_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().NotBeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.AllBeAssignableTo.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The AllBeAssignableTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class AllBeAssignableTo\n {\n [Fact]\n public void When_the_types_in_a_collection_is_matched_against_a_null_type_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expectedType\");\n }\n\n [Fact]\n public void All_items_in_an_empty_collection_are_assignable_to_a_generic_type()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_collection_is_null_then_all_be_assignable_to_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllBeAssignableTo(typeof(object), \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be object *failure message*, but found collection is .\");\n }\n\n [Fact]\n public void All_items_in_an_empty_collection_are_assignable_to_a_type()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo(typeof(int));\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_expected_type_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo(typeof(int));\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_expected_generic_type_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_matching_a_collection_against_a_type_it_should_return_the_casted_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo()\n .Which.Should().Equal(1, 2, 3);\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_the_type_or_subtype_it_should_succeed()\n {\n // Arrange\n var collection = new object[] { new Exception(), new ArgumentException(\"foo\") };\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_one_of_the_types_does_not_match_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { 1, \"2\", 3 };\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(typeof(int), \"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found {int, string, int}.\");\n }\n\n [Fact]\n public void When_one_of_the_types_does_not_match_the_generic_type_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { 1, \"2\", 3 };\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found {int, string, int}.\");\n }\n\n [Fact]\n public void When_one_of_the_elements_is_null_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { 1, null, 3 };\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found a null element.\");\n }\n\n [Fact]\n public void When_collection_is_of_matching_types_it_should_succeed()\n {\n // Arrange\n Type[] collection = [typeof(Exception), typeof(ArgumentException)];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_collection_of_types_contains_one_type_that_does_not_match_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n Type[] collection = [typeof(int), typeof(string), typeof(int)];\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found {int, string, int}.\");\n }\n\n [Fact]\n public void When_collection_of_types_and_objects_are_all_of_matching_types_it_should_succeed()\n {\n // Arrange\n var collection = new object[] { typeof(int), 2, typeof(int) };\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_collection_of_different_types_and_objects_are_all_assignable_to_type_it_should_succeed()\n {\n // Arrange\n var collection = new object[] { typeof(Exception), new ArgumentException(\"foo\") };\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_collection_is_null_then_all_be_assignable_toOfT_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllBeAssignableTo(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be object *failure message*, but found collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CustomAssertionAttribute.cs", "using System;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Marks a method as an extension to Awesome Assertions that either uses the built-in assertions\n/// internally, or directly uses AssertionChain.\n/// \n[AttributeUsage(AttributeTargets.Method)]\n#pragma warning disable CA1813 // Avoid unsealed attributes. This type has shipped.\npublic class CustomAssertionAttribute : Attribute;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableBooleanAssertions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableBooleanAssertions : NullableBooleanAssertions\n{\n public NullableBooleanAssertions(bool? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableBooleanAssertions : BooleanAssertions\n where TAssertions : NullableBooleanAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableBooleanAssertions(bool? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable boolean value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected a value{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable boolean value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable boolean value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable boolean value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that the value is equal to the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(bool? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is not equal to the specified value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(bool? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable boolean} not to be {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeFalse([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not false)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable boolean} not to be {0}{reason}, but found {1}.\", false, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeTrue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable boolean} not to be {0}{reason}, but found {1}.\", true, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/AwaitParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class AwaitParsingStrategy : IParsingStrategy\n{\n private const string KeywordToSkip = \"await \";\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (IsLongEnoughToContainOurKeyword(statement) && EndsWithOurKeyword(statement))\n {\n statement.Remove(statement.Length - KeywordToSkip.Length, KeywordToSkip.Length);\n }\n\n return ParsingState.InProgress;\n }\n\n private static bool EndsWithOurKeyword(StringBuilder statement)\n {\n var leftIndex = statement.Length - 1;\n var rightIndex = KeywordToSkip.Length - 1;\n\n for (var offset = 0; offset < KeywordToSkip.Length; offset++)\n {\n if (statement[leftIndex - offset] != KeywordToSkip[rightIndex - offset])\n {\n return false;\n }\n }\n\n return true;\n }\n\n private static bool IsLongEnoughToContainOurKeyword(StringBuilder statement) => statement.Length >= KeywordToSkip.Length;\n\n public bool IsWaitingForContextEnd()\n {\n return false;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.Contain.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]Contain specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class Contain\n {\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_contains_the_expected_string_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring);\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_does_not_contain_an_expected_string_it_should_throw()\n {\n // Act\n Action act = () => \"ABCDEF\".Should().Contain(\"XYZ\", \"that is {0}\", \"required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string \\\"ABCDEF\\\" to contain \\\"XYZ\\\" because that is required.\");\n }\n\n [Fact]\n public void When_containment_is_asserted_against_null_it_should_throw()\n {\n // Act\n Action act = () => \"a\".Should().Contain(null);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_containment_is_asserted_against_an_empty_string_it_should_throw()\n {\n // Act\n Action act = () => \"a\".Should().Contain(\"\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against an empty string.*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_string_containment_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().Contain(\"XYZ\", \"that is {0}\", \"required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString to contain \\\"XYZ\\\" because that is required.\");\n }\n\n public class ContainExactly\n {\n [Fact]\n public void\n When_string_containment_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Once(), \"that is {0}\", \"required\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * \\\"ABCDEF\\\" to contain \\\"XYS\\\" exactly 1 time because that is required, but found it 0 times.\");\n }\n\n [Fact]\n public void When_containment_once_is_asserted_against_null_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"a\";\n string expectedSubstring = null;\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Once());\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\");\n }\n\n [Fact]\n public void When_string_containment_once_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain \\\"XYZ\\\" exactly 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void When_string_containment_exactly_is_asserted_and_expected_value_is_negative_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Times(-1));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected count cannot be negative.*\");\n }\n\n [Fact]\n public void\n When_string_containment_exactly_is_asserted_and_actual_value_contains_the_expected_string_exactly_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, Exactly.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_exactly_is_asserted_and_actual_value_contains_the_expected_string_but_not_exactly_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Times(3));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" exactly 3 times, but found it 2 times.\");\n }\n }\n\n public class ContainAtLeast\n {\n [Fact]\n public void\n When_string_containment_at_least_is_asserted_and_actual_value_contains_the_expected_string_at_least_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, AtLeast.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_at_least_is_asserted_and_actual_value_contains_the_expected_string_but_not_at_least_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, AtLeast.Times(3));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" at least 3 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_at_least_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, AtLeast.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEF\\\" to contain \\\"XYS\\\" at least 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void When_string_containment_at_least_once_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, AtLeast.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain \\\"XYZ\\\" at least 1 time, but found it 0 times.\");\n }\n }\n\n public class ContainMoreThan\n {\n [Fact]\n public void\n When_string_containment_more_than_is_asserted_and_actual_value_contains_the_expected_string_more_than_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, MoreThan.Times(1));\n }\n\n [Fact]\n public void\n When_string_containment_more_than_is_asserted_and_actual_value_contains_the_expected_string_but_not_more_than_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, MoreThan.Times(2));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" more than 2 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_more_than_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, MoreThan.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEF\\\" to contain \\\"XYS\\\" more than 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void When_string_containment_more_than_once_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, MoreThan.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain \\\"XYZ\\\" more than 1 time, but found it 0 times.\");\n }\n }\n\n public class ContainAtMost\n {\n [Fact]\n public void\n When_string_containment_at_most_is_asserted_and_actual_value_contains_the_expected_string_at_most_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, AtMost.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_at_most_is_asserted_and_actual_value_contains_the_expected_string_but_not_at_most_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, AtMost.Times(1));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" at most 1 time, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_at_most_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, AtMost.Once());\n }\n\n [Fact]\n public void When_string_containment_at_most_once_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, AtMost.Once());\n }\n }\n\n public class ContainsLessThan\n {\n [Fact]\n public void\n When_string_containment_less_than_is_asserted_and_actual_value_contains_the_expected_string_less_than_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, LessThan.Times(3));\n }\n\n [Fact]\n public void\n When_string_containment_less_than_is_asserted_and_actual_value_contains_the_expected_string_but_not_less_than_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, LessThan.Times(2));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" less than 2 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_less_than_twice_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, LessThan.Twice());\n }\n\n [Fact]\n public void When_string_containment_less_than_twice_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, LessThan.Twice());\n }\n }\n }\n\n public class NotContain\n {\n [Fact]\n public void When_string_does_not_contain_the_unexpected_string_it_should_succeed()\n {\n // Act / Assert\n \"a\".Should().NotContain(\"A\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_contains_unexpected_fragment_it_should_throw()\n {\n // Act\n Action act = () => \"abcd\".Should().NotContain(\"bc\", \"it was not expected {0}\", \"today\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect string \\\"abcd\\\" to contain \\\"bc\\\" because it was not expected today.\");\n }\n\n [Fact]\n public void When_exclusion_is_asserted_against_null_it_should_throw()\n {\n // Act\n Action act = () => \"a\".Should().NotContain(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void When_exclusion_is_asserted_against_an_empty_string_it_should_throw()\n {\n // Act\n Action act = () => \"a\".Should().NotContain(\"\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert string containment against an empty string.*\")\n .WithParameterName(\"unexpected\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.NotContainNulls.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The NotContainNulls specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class NotContainNulls\n {\n [Fact]\n public void When_collection_does_not_contain_nulls_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainNulls();\n }\n\n [Fact]\n public void When_collection_contains_nulls_that_are_unexpected_it_should_throw()\n {\n // Arrange\n object[] collection = [new object(), null];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because they are evil, but found one at index 1.\");\n }\n\n [Fact]\n public void When_collection_contains_nulls_that_are_unexpected_it_supports_chaining()\n {\n // Arrange\n object[] collection = [new object(), null];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainNulls().And.HaveCount(c => c > 1);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but found one*\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_nulls_that_are_unexpected_it_should_throw()\n {\n // Arrange\n object[] collection = [new object(), null, new object(), null];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s*because they are evil*{1, 3}*\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_nulls_that_are_unexpected_it_supports_chaining()\n {\n // Arrange\n object[] collection = [new object(), null, new object(), null];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainNulls().And.HaveCount(c => c > 1);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but found several*\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_nulls_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because we want to test the behaviour with a null subject, but collection is .\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotContainNulls_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_nulls_with_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"three\" }\n ];\n\n // Act / Assert\n collection.Should().NotContainNulls(e => e.Text);\n }\n\n [Fact]\n public void When_collection_contains_nulls_that_are_unexpected_with_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"\" },\n new SomeClass { Text = null }\n ];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(e => e.Text, \"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s*on e.Text*because they are evil*Text = *\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_nulls_that_are_unexpected_with_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"\" },\n new SomeClass { Text = null },\n new SomeClass { Text = \"\" },\n new SomeClass { Text = null }\n ];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(e => e.Text, \"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s*on e.Text*because they are evil*Text = *Text = *\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_nulls_but_collection_is_null_it_should_fail()\n {\n // Arrange\n SomeClass[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainNulls(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s *failure message*, but collection is .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_nulls_with_predicate_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainNulls(e => e.Text, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because we want to test the behaviour with a null subject, but collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/EnumAssertionsExtensions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.Contracts;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Contains an extension method for custom assertions in unit tests related to Enum objects.\n/// \n[DebuggerNonUserCode]\npublic static class EnumAssertionsExtensions\n{\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static EnumAssertions Should(this TEnum @enum)\n where TEnum : struct, Enum\n {\n return new EnumAssertions(@enum, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NullableEnumAssertions Should(this TEnum? @enum)\n where TEnum : struct, Enum\n {\n return new NullableEnumAssertions(@enum, AssertionChain.GetOrCreate());\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCountGreaterThan.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCountGreaterThan\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_greater_than_less_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCountGreaterThan(2);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_greater_than_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCountGreaterThan(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_dictionary_has_a_count_greater_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () =>\n dictionary.Should().HaveCountGreaterThan(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain more than 3 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_greater_than_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().HaveCountGreaterThan(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*more than*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/EnumerableExtensionsSpecs.cs", "using AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class EnumerableExtensionsSpecs\n{\n public static TheoryData JoinUsingWritingStyleTestCases => new()\n {\n { [], \"\" },\n { [\"test\"], \"test\" },\n { [\"test\", \"test2\"], \"test and test2\" },\n { [\"test\", \"test2\", \"test3\"], \"test, test2 and test3\" },\n { [\"test\", \"test2\", \"test3\", \"test4\"], \"test, test2, test3 and test4\" }\n };\n\n [Theory]\n [MemberData(nameof(JoinUsingWritingStyleTestCases))]\n public void JoinUsingWritingStyle_should_format_correctly(string[] input, string expectation)\n {\n // Act\n var result = input.JoinUsingWritingStyle();\n\n // Assert\n result.Should().Be(expectation);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCountLessThan.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCountLessThan\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_less_than_less_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCountLessThan(4);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_less_than_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCountLessThan(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_dictionary_has_a_count_less_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () => dictionary.Should().HaveCountLessThan(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain fewer than 3 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_less_than_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().HaveCountLessThan(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*fewer than*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/AllTypes.cs", "using System.Reflection;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Static class that allows for a 'fluent' selection of the types from an .\n/// \n/// \n/// AllTypes.From(myAssembly)
\n/// .ThatImplement<ISomeInterface>
\n/// .Should()
\n/// .BeDecoratedWith<SomeAttribute>()\n///
\npublic static class AllTypes\n{\n /// \n /// Returns a for selecting the types that are visible outside the\n /// specified .\n /// \n /// The assembly from which to select the types.\n public static TypeSelector From(Assembly assembly)\n {\n return assembly.Types();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/DictionaryHelpers.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class DictionaryHelpers\n{\n public static IEnumerable GetKeys(this TCollection collection)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary.Keys,\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary.Keys,\n _ => collection.Select(kvp => kvp.Key).ToList(),\n };\n }\n\n public static IEnumerable GetValues(this TCollection collection)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary.Values,\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary.Values,\n _ => collection.Select(kvp => kvp.Value).ToList(),\n };\n }\n\n public static bool ContainsKey(this TCollection collection, TKey key)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary.ContainsKey(key),\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary.ContainsKey(key),\n _ => ContainsKey(collection, key),\n };\n\n static bool ContainsKey(TCollection collection, TKey key)\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n return collection.Any(kvp => areSameOrEqual(kvp.Key, key));\n }\n }\n\n public static bool TryGetValue(this TCollection collection, TKey key, out TValue value)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary.TryGetValue(key, out value),\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary.TryGetValue(key, out value),\n _ => TryGetValue(collection, key, out value),\n };\n\n static bool TryGetValue(TCollection collection, TKey key, out TValue value)\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n foreach (var kvp in collection)\n {\n if (areSameOrEqual(kvp.Key, key))\n {\n value = kvp.Value;\n return true;\n }\n }\n\n value = default;\n return false;\n }\n }\n\n public static TValue GetValue(this TCollection collection, TKey key)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary[key],\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary[key],\n _ => GetValue(collection, key),\n };\n\n static TValue GetValue(TCollection collection, TKey key)\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n return collection.First(kvp => areSameOrEqual(kvp.Key, key)).Value;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.Parsable.cs", "#if NET8_0_OR_GREATER\nusing System;\nusing System.Globalization;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class StringAssertionSpecs\n{\n public class BeParsableInto\n {\n [Fact]\n public void Anything_which_is_no_int_is_not_parsable_into_an_int()\n {\n // Arrange\n string sut = \"aaa\";\n\n // Act\n Action act = () => sut.Should().BeParsableInto(\"we want to test the {0}\", \"failure message\")\n .Which.Should().Be(0);\n\n // Assert\n act.Should().Throw().WithMessage(\"*aaa*int*we want*failure message*could not*\");\n }\n\n [Theory]\n [InlineData(\"de-AT\", \"12,34\")]\n [InlineData(\"en-US\", \"12.34\")]\n public void A_floating_point_string_is_parsable_into_a_floating_point_value_in_various_cultures(\n string cultureName,\n string subject)\n {\n // Arrange\n\n // Act / Assert\n subject.Should().BeParsableInto(new CultureInfo(cultureName))\n .Which.Should().Be(12.34M);\n }\n\n [Fact]\n public void A_string_is_not_parsable_into_an_int_even_with_a_culture_defined()\n {\n // Arrange\n string sut = \"aaa\";\n\n // Act\n Action act = () =>\n sut.Should().BeParsableInto(new CultureInfo(\"de-AT\"));\n\n // Assert\n act.Should().Throw().WithMessage(\"*aaa*int*the input string*was not in a correct format*\");\n }\n\n [Theory]\n [InlineData(\"de-AT\", \"12.34\")]\n [InlineData(\"en-US\", \"12,34\")]\n public void A_floating_point_string_is_not_parsable_into_a_floating_point_value_in_various_cultures(\n string cultureName,\n string subject)\n {\n // Arrange\n\n // Act / Assert\n Action act = () => subject.Should().BeParsableInto(new CultureInfo(cultureName))\n .Which.Should().Be(12.34M);\n\n act.Should().Throw();\n }\n }\n\n public class NotBeParsableInto\n {\n [Fact]\n public void An_invalid_guid_string_is_not_parsable_into_a_guid()\n {\n // Arrange\n string sut = \"95e117d5bb0d4b16a1c7a11eea0284a\";\n\n // Act / Assert\n sut.Should().NotBeParsableInto();\n }\n\n [Fact]\n public void An_integer_string_is_parsable_into_an_int_but_throws_when_not_expected_to()\n {\n // Arrange\n string sut = \"1\";\n\n // Act\n Action act = () => sut.Should().NotBeParsableInto(\"we want to test the {0}\", \"failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*1*int*we want*failure message*could*\");\n }\n\n [Fact]\n public void A_string_is_not_parsable_into_an_int_even_with_culture_info_defined()\n {\n // Arrange\n string sut = \"aaa\";\n\n // Act / Assert\n sut.Should().NotBeParsableInto(new CultureInfo(\"de-DE\"));\n }\n\n [Fact]\n public void An_integer_string_is_parsable_into_an_int_but_throws_when_not_expected_to_with_culture_defined()\n {\n // Arrange\n string sut = \"1\";\n\n // Act\n Action act = () => sut.Should().NotBeParsableInto(new CultureInfo(\"de-DE\"));\n\n // Assert\n act.Should().Throw().WithMessage(\"*1*int*but it could*\");\n }\n }\n}\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeNaN.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeNaN\n {\n [Fact]\n public void NaN_is_equal_to_NaN_when_its_a_float()\n {\n // Arrange\n float actual = float.NaN;\n\n // Act / Assert\n actual.Should().BeNaN();\n }\n\n [InlineData(-1f)]\n [InlineData(0f)]\n [InlineData(1f)]\n [InlineData(float.MinValue)]\n [InlineData(float.MaxValue)]\n [InlineData(float.Epsilon)]\n [InlineData(float.NegativeInfinity)]\n [InlineData(float.PositiveInfinity)]\n [Theory]\n public void Should_fail_when_asserting_normal_float_value_to_be_NaN(float actual)\n {\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_normal_float_value_to_be_NaN()\n {\n // Arrange\n float actual = 1;\n\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual to be NaN, but found 1F.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_NaN_as_float()\n {\n // Arrange\n float actual = float.NaN;\n\n // Act / Assert\n actual.Should().BeNaN()\n .And.Be(actual);\n }\n\n [Fact]\n public void NaN_is_equal_to_NaN_when_its_a_double()\n {\n // Arrange\n double actual = double.NaN;\n\n // Act / Assert\n actual.Should().BeNaN();\n }\n\n [InlineData(-1d)]\n [InlineData(0d)]\n [InlineData(1d)]\n [InlineData(double.MinValue)]\n [InlineData(double.MaxValue)]\n [InlineData(double.Epsilon)]\n [InlineData(double.NegativeInfinity)]\n [InlineData(double.PositiveInfinity)]\n [Theory]\n public void Should_fail_when_asserting_normal_double_value_to_be_NaN(double actual)\n {\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_normal_double_value_to_be_NaN()\n {\n // Arrange\n double actual = 1;\n\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual to be NaN, but found 1.0.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_NaN_as_double()\n {\n // Arrange\n double actual = double.NaN;\n\n // Act / Assert\n actual.Should().BeNaN()\n .And.Be(actual);\n }\n\n [Fact]\n public void NaN_is_equal_to_NaN_when_its_a_nullable_float()\n {\n // Arrange\n float? actual = float.NaN;\n\n // Act / Assert\n actual.Should().BeNaN();\n }\n\n [InlineData(null)]\n [InlineData(-1f)]\n [InlineData(0f)]\n [InlineData(1f)]\n [InlineData(float.MinValue)]\n [InlineData(float.MaxValue)]\n [InlineData(float.Epsilon)]\n [InlineData(float.NegativeInfinity)]\n [InlineData(float.PositiveInfinity)]\n [Theory]\n public void Should_fail_when_asserting_nullable_normal_float_value_to_be_NaN(float? actual)\n {\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_nullable_normal_float_value_to_be_NaN()\n {\n // Arrange\n float? actual = 1;\n\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual to be NaN, but found 1F.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_NaN_as_nullable_float()\n {\n // Arrange\n float? actual = float.NaN;\n\n // Act / Assert\n actual.Should().BeNaN()\n .And.Be(actual);\n }\n\n [Fact]\n public void NaN_is_equal_to_NaN_when_its_a_nullable_double()\n {\n // Arrange\n double? actual = double.NaN;\n\n // Act / Assert\n actual.Should().BeNaN();\n }\n\n [InlineData(null)]\n [InlineData(-1d)]\n [InlineData(0d)]\n [InlineData(1d)]\n [InlineData(double.MinValue)]\n [InlineData(double.MaxValue)]\n [InlineData(double.Epsilon)]\n [InlineData(double.NegativeInfinity)]\n [InlineData(double.PositiveInfinity)]\n [Theory]\n public void Should_fail_when_asserting_nullable_normal_double_value_to_be_NaN(double? actual)\n {\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_nullable_normal_double_value_to_be_NaN()\n {\n // Arrange\n double? actual = 1;\n\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual to be NaN, but found 1.0.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_NaN_as_nullable_double()\n {\n // Arrange\n double? actual = double.NaN;\n\n // Act / Assert\n actual.Should().BeNaN()\n .And.Be(actual);\n }\n }\n\n public class NotBeNaN\n {\n [InlineData(-1f)]\n [InlineData(0f)]\n [InlineData(1f)]\n [InlineData(float.MinValue)]\n [InlineData(float.MaxValue)]\n [InlineData(float.Epsilon)]\n [InlineData(float.NegativeInfinity)]\n [InlineData(float.PositiveInfinity)]\n [Theory]\n public void Normal_float_is_never_equal_to_NaN(float actual)\n {\n // Act / Assert\n actual.Should().NotBeNaN();\n }\n\n [Fact]\n public void Should_fail_when_asserting_NaN_as_float()\n {\n // Arrange\n float actual = float.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_NaN_as_float()\n {\n // Arrange\n float actual = float.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect actual to be NaN.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_normal_float_value()\n {\n // Arrange\n float actual = 1;\n\n // Act / Assert\n actual.Should().NotBeNaN()\n .And.Be(actual);\n }\n\n [InlineData(-1d)]\n [InlineData(0d)]\n [InlineData(1d)]\n [InlineData(double.MinValue)]\n [InlineData(double.MaxValue)]\n [InlineData(double.Epsilon)]\n [InlineData(double.NegativeInfinity)]\n [InlineData(double.PositiveInfinity)]\n [Theory]\n public void Normal_double_is_never_equal_to_NaN(double actual)\n {\n // Act / Assert\n actual.Should().NotBeNaN();\n }\n\n [Fact]\n public void Should_fail_when_asserting_NaN_as_double()\n {\n // Arrange\n double actual = double.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_NaN_as_double()\n {\n // Arrange\n double actual = double.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect actual to be NaN.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_normal_double_value()\n {\n // Arrange\n double actual = 1;\n\n // Act / Assert\n actual.Should().NotBeNaN()\n .And.Be(actual);\n }\n\n [InlineData(null)]\n [InlineData(-1f)]\n [InlineData(0f)]\n [InlineData(1f)]\n [InlineData(float.MinValue)]\n [InlineData(float.MaxValue)]\n [InlineData(float.Epsilon)]\n [InlineData(float.NegativeInfinity)]\n [InlineData(float.PositiveInfinity)]\n [Theory]\n public void Normal_nullable_float_is_never_equal_to_NaN(float? actual)\n {\n // Act / Assert\n actual.Should().NotBeNaN();\n }\n\n [Fact]\n public void Should_fail_when_asserting_NaN_as_nullable_float()\n {\n // Arrange\n float? actual = float.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_NaN_as_nullable_float()\n {\n // Arrange\n float? actual = float.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect actual to be NaN.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_normal_nullable_float_value()\n {\n // Arrange\n float? actual = 1;\n\n // Act / Assert\n actual.Should().NotBeNaN()\n .And.Be(actual);\n }\n\n [InlineData(null)]\n [InlineData(-1d)]\n [InlineData(0d)]\n [InlineData(1d)]\n [InlineData(double.MinValue)]\n [InlineData(double.MaxValue)]\n [InlineData(double.Epsilon)]\n [InlineData(double.NegativeInfinity)]\n [InlineData(double.PositiveInfinity)]\n [Theory]\n public void Normal_nullable_double_is_never_equal_to_NaN(double? actual)\n {\n // Act / Assert\n actual.Should().NotBeNaN();\n }\n\n [Fact]\n public void Should_fail_when_asserting_NaN_as_nullable_double()\n {\n // Arrange\n double? actual = double.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_NaN_as_nullable_double()\n {\n // Arrange\n double? actual = double.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect actual to be NaN.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_normal_nullable_double_value()\n {\n // Arrange\n double? actual = 1;\n\n // Act / Assert\n actual.Should().NotBeNaN()\n .And.Be(actual);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.StartWithEquivalentOf.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]StartWithEquivalentOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class StartWithEquivalentOf\n {\n [Fact]\n public void Succeed_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act\n Action act = () => actual.Should().StartWithEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_start_with_another()\n {\n // Arrange\n string actual = \"test with suffix\";\n string expect = \"TEST\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_start_with_another()\n {\n // Arrange\n string actual = \" test with suffix\";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_start_with_another()\n {\n // Arrange\n string actual = \"test with suffix \";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_start_with_another()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n with suffix\";\n string expect = \"\\r\\nA\\rB\\nC\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n }\n\n [Fact]\n public void When_start_of_string_differs_by_case_only_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedPrefix = \"Ab\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expectedPrefix);\n }\n\n [Fact]\n public void When_start_of_string_does_not_meet_equivalent_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWithEquivalentOf(\"bc\", \"because it should start\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with equivalent of \\\"bc\\\" because it should start, but \\\"ABC\\\" differs near \\\"ABC\\\" (index 0).\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void\n When_start_of_string_does_not_meet_equivalent_and_one_of_them_is_long_it_should_display_both_strings_on_separate_line()\n {\n // Act\n Action act = () => \"ABCDEFGHI\".Should().StartWithEquivalentOf(\"abcddfghi\", \"it should {0}\", \"start\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with equivalent of \" +\n \"*\\\"abcddfghi\\\" because it should start, but \" +\n \"*\\\"ABCDEFGHI\\\" differs near \\\"EFG\\\" (index 4).\");\n }\n\n [Fact]\n public void When_start_of_string_is_compared_with_equivalent_of_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWithEquivalentOf(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare string start equivalence with .*\");\n }\n\n [Fact]\n public void When_start_of_string_is_compared_with_equivalent_of_empty_string_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().StartWithEquivalentOf(\"\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_start_of_string_is_compared_with_equivalent_of_string_that_is_longer_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWithEquivalentOf(\"abcdef\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with equivalent of \" +\n \"\\\"abcdef\\\", but \" +\n \"\\\"ABC\\\" is too short.\");\n }\n\n [Fact]\n public void When_string_start_is_compared_with_equivalent_and_actual_value_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().StartWithEquivalentOf(\"AbC\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someString to start with equivalent of \\\"AbC\\\", but found .\");\n }\n }\n\n public class NotStartWithEquivalentOf\n {\n [Fact]\n public void Succeed_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act / Assert\n actual.Should().NotStartWithEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_not_start_with_another()\n {\n // Arrange\n string actual = \"test with suffix\";\n string expect = \"TEST\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_not_start_with_another()\n {\n // Arrange\n string actual = \" test with suffix\";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_not_start_with_another()\n {\n // Arrange\n string actual = \"test with suffix \";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_not_start_with_another()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n with suffix\";\n string expect = \"\\nA\\r\\nB\\rC\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_equivalent_of_a_value_and_it_does_not_it_should_succeed()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().NotStartWithEquivalentOf(\"Bc\");\n }\n\n [Fact]\n public void\n When_asserting_string_does_not_start_with_equivalent_of_a_value_but_it_does_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWithEquivalentOf(\"aB\", \"because of some reason\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to start with equivalent of \\\"aB\\\" because of some reason, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_equivalent_of_a_value_that_is_null_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWithEquivalentOf(null);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Cannot compare start of string with .*\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_equivalent_of_a_value_that_is_empty_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWithEquivalentOf(\"\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to start with equivalent of \\\"\\\", but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_equivalent_of_a_value_and_actual_value_is_null_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () => someString.Should().NotStartWithEquivalentOf(\"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to start with equivalent of \\\"ABC\\\", but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCountLessThanOrEqualTo.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCountLessThanOrEqualTo\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_less_than_or_equal_to_less_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCountLessThanOrEqualTo(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_less_than_or_equal_to_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCountLessThanOrEqualTo(2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_dictionary_has_a_count_less_than_or_equal_to_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () =>\n dictionary.Should().HaveCountLessThanOrEqualTo(2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain at most 2 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_less_than_or_equal_to_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n dictionary.Should().HaveCountLessThanOrEqualTo(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*at most*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCountGreaterThanOrEqualTo.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCountGreaterThanOrEqualTo\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_greater_than_or_equal_to_less_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCountGreaterThanOrEqualTo(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_greater_than_or_equal_to_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCountGreaterThanOrEqualTo(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_dictionary_has_a_count_greater_than_or_equal_to_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () =>\n dictionary.Should().HaveCountGreaterThanOrEqualTo(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain at least 4 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_greater_than_or_equal_to_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n dictionary.Should().HaveCountGreaterThanOrEqualTo(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*at least*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.EndWith.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]EndWith specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class EndWith\n {\n [Fact]\n public void When_asserting_string_ends_with_a_suffix_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedSuffix = \"BC\";\n\n // Act / Assert\n actual.Should().EndWith(expectedSuffix);\n }\n\n [Fact]\n public void When_asserting_string_ends_with_the_same_value_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedSuffix = \"ABC\";\n\n // Act / Assert\n actual.Should().EndWith(expectedSuffix);\n }\n\n [Fact]\n public void When_string_does_not_end_with_expected_phrase_it_should_throw()\n {\n // Act\n Action act = () =>\n {\n using var a = new AssertionScope();\n \"ABC\".Should().EndWith(\"AB\", \"it should\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to end with \\\"AB\\\" because it should, but \\\"ABC\\\" differs near \\\"ABC\\\" (index 0).\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWith(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare string end with .*\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_empty_string_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().EndWith(\"\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_string_that_is_longer_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWith(\"00ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to end with \" +\n \"\\\"00ABC\\\", but \" +\n \"\\\"ABC\\\" is too short.\");\n }\n\n [Fact]\n public void Correctly_stop_further_execution_when_inside_assertion_scope()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n \"ABC\".Should().EndWith(\"00ABC\").And.EndWith(\"CBA00\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*\\\"00ABC\\\"*\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someString.Should().EndWith(\"ABC\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString to end with \\\"ABC\\\", but found .\");\n }\n }\n\n public class NotEndWith\n {\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_and_it_does_not_it_should_succeed()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().NotEndWith(\"AB\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_but_it_does_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWith(\"BC\", \"because of some {0}\", \"reason\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to end with \\\"BC\\\" because of some reason, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_that_is_null_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWith(null);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Cannot compare end of string with .*\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_that_is_empty_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWith(\"\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to end with \\\"\\\", but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_and_actual_value_is_null_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someString.Should().NotEndWith(\"ABC\", \"some {0}\", \"reason\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to end with \\\"ABC\\\"*some reason*, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericDifferenceAssertionsSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic class NumericDifferenceAssertionsSpecs\n{\n public class Be\n {\n [Theory]\n [InlineData(8, 5)]\n [InlineData(1, 9)]\n public void The_difference_between_small_ints_is_not_included_in_the_message(int value, int expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"Expected value to be {expected} because we want to test the failure message, but found {value}.\");\n }\n\n [Theory]\n [InlineData(50, 20, 30)]\n [InlineData(20, 50, -30)]\n [InlineData(123, -123, 246)]\n [InlineData(-123, 123, -246)]\n public void The_difference_between_ints_is_included_in_the_message(int value, int expected, int expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected} because we want to test the failure message, but found {value} (difference of {expectedDifference}).\");\n }\n\n [Theory]\n [InlineData(8, 5)]\n [InlineData(1, 9)]\n public void The_difference_between_small_nullable_ints_is_not_included_in_the_message(int? value, int expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"Expected value to be {expected} because we want to test the failure message, but found {value}.\");\n }\n\n [Fact]\n public void The_difference_between_int_and_null_is_not_included_in_the_message()\n {\n // Arrange\n int? value = null;\n const int expected = 12;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 12 because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void The_difference_between_null_and_int_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 12;\n int? nullableValue = null;\n\n // Act\n Action act = () =>\n value.Should().Be(nullableValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be because we want to test the failure message, but found 12.\");\n }\n\n [Theory]\n [InlineData(50, 20, 30)]\n [InlineData(20, 50, -30)]\n [InlineData(123, -123, 246)]\n [InlineData(-123, 123, -246)]\n public void The_difference_between_nullable_ints_is_included_in_the_message(int? value, int expected,\n int expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected} because we want to test the failure message, but found {value} (difference of {expectedDifference}).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_uints_is_included_in_the_message()\n {\n // Arrange\n uint? value = 29;\n const uint expected = 19;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 19u because we want to test the failure message, but found 29u (difference of 10).\");\n }\n\n [Theory]\n [InlineData(8, 5)]\n [InlineData(1, 9)]\n public void The_difference_between_small_longs_is_not_included_in_the_message(long value, long expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}L because we want to test the failure message, but found {value}L.\");\n }\n\n [Theory]\n [InlineData(50, 20, 30)]\n [InlineData(20, 50, -30)]\n public void The_difference_between_longs_is_included_in_the_message(long value, long expected, long expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}L because we want to test the failure message, but found {value}L (difference of {expectedDifference}).\");\n }\n\n [Theory]\n [InlineData(8L, 5)]\n [InlineData(1L, 9)]\n public void The_difference_between_small_nullable_longs_is_not_included_in_the_message(long? value, long expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}L because we want to test the failure message, but found {value}L.\");\n }\n\n [Theory]\n [InlineData(50L, 20, 30)]\n [InlineData(20L, 50, -30)]\n public void The_difference_between_nullable_longs_is_included_in_the_message(long? value, long expected,\n long expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}L because we want to test the failure message, but found {value}L (difference of {expectedDifference}).\");\n }\n\n [Theory]\n [InlineData(8, 5)]\n [InlineData(1, 9)]\n public void The_difference_between_small_shorts_is_not_included_in_the_message(short value, short expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}s because we want to test the failure message, but found {value}s.\");\n }\n\n [Theory]\n [InlineData(50, 20, 30)]\n [InlineData(20, 50, -30)]\n public void The_difference_between_shorts_is_included_in_the_message(short value, short expected,\n short expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}s because we want to test the failure message, but found {value}s (difference of {expectedDifference}).\");\n }\n\n [Fact]\n public void The_difference_between_small_nullable_shorts_is_not_included_in_the_message()\n {\n // Arrange\n short? value = 2;\n const short expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 1s because we want to test the failure message, but found 2s.\");\n }\n\n [Fact]\n public void The_difference_between_nullable_shorts_is_included_in_the_message()\n {\n // Arrange\n short? value = 15;\n const short expected = 2;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 2s because we want to test the failure message, but found 15s (difference of 13).\");\n }\n\n [Fact]\n public void The_difference_between_small_ulongs_is_not_included_in_the_message()\n {\n // Arrange\n const ulong value = 9;\n const ulong expected = 4;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 4UL because we want to test the failure message, but found 9UL.\");\n }\n\n [Fact]\n public void The_difference_between_ulongs_is_included_in_the_message()\n {\n // Arrange\n const ulong value = 50;\n const ulong expected = 20;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 20UL because we want to test the failure message, but found 50UL (difference of 30).\");\n }\n\n [Fact]\n public void The_difference_between_small_nullable_ulongs_is_not_included_in_the_message()\n {\n // Arrange\n ulong? value = 7;\n const ulong expected = 4;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 4UL because we want to test the failure message, but found 7UL.\");\n }\n\n [Fact]\n public void The_difference_between_nullable_ulongs_is_included_in_the_message()\n {\n // Arrange\n ulong? value = 50;\n const ulong expected = 20;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 20UL because we want to test the failure message, but found 50UL (difference of 30).\");\n }\n\n [Fact]\n public void The_difference_between_ushorts_is_included_in_the_message()\n {\n // Arrange\n ushort? value = 11;\n const ushort expected = 2;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 2us because we want to test the failure message, but found 11us (difference of 9).\");\n }\n\n [Fact]\n public void The_difference_between_doubles_is_included_in_the_message()\n {\n // Arrange\n const double value = 1.5;\n const double expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1.0 because we want to test the failure message, but found 1.5 (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_doubles_is_included_in_the_message()\n {\n // Arrange\n double? value = 1.5;\n const double expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1.0 because we want to test the failure message, but found 1.5 (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_floats_is_included_in_the_message()\n {\n // Arrange\n const float value = 1.5F;\n const float expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1F because we want to test the failure message, but found 1.5F (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_floats_is_included_in_the_message()\n {\n // Arrange\n float? value = 1.5F;\n const float expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1F because we want to test the failure message, but found 1.5F (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_decimals_is_included_in_the_message()\n {\n // Arrange\n const decimal value = 1.5m;\n const decimal expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1m because we want to test the failure message, but found 1.5m (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_decimals_is_included_in_the_message()\n {\n // Arrange\n decimal? value = 1.5m;\n const decimal expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1m because we want to test the failure message, but found 1.5m (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_sbytes_is_included_in_the_message()\n {\n // Arrange\n const sbyte value = 1;\n const sbyte expected = 3;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 3y because we want to test the failure message, but found 1y (difference of -2).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_sbytes_is_included_in_the_message()\n {\n // Arrange\n sbyte? value = 1;\n const sbyte expected = 3;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 3y because we want to test the failure message, but found 1y (difference of -2).\");\n }\n }\n\n public class BeLessThan\n {\n [Fact]\n public void The_difference_between_equal_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 15;\n const int expected = 15;\n\n // Act\n Action act = () =>\n value.Should().BeLessThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be less than 15 because we want to test the failure message, but found 15.\");\n }\n\n [Fact]\n public void The_difference_between_small_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 4;\n const int expected = 2;\n\n // Act\n Action act = () =>\n value.Should().BeLessThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be less than 2 because we want to test the failure message, but found 4.\");\n }\n\n [Fact]\n public void The_difference_between_ints_is_included_in_the_message()\n {\n // Arrange\n const int value = 52;\n const int expected = 22;\n\n // Act\n Action act = () =>\n value.Should().BeLessThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be less than 22 because we want to test the failure message, but found 52 (difference of 30).\");\n }\n }\n\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void The_difference_between_small_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 4;\n const int expected = 2;\n\n // Act\n Action act = () =>\n value.Should().BeLessThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be less than or equal to 2 because we want to test the failure message, but found 4.\");\n }\n\n [Fact]\n public void The_difference_between_ints_is_included_in_the_message()\n {\n // Arrange\n const int value = 52;\n const int expected = 22;\n\n // Act\n Action act = () =>\n value.Should().BeLessThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be less than or equal to 22 because we want to test the failure message, but found 52 (difference of 30).\");\n }\n }\n\n public class BeGreaterThan\n {\n [Fact]\n public void The_difference_between_equal_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 15;\n const int expected = 15;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 15 because we want to test the failure message, but found 15.\");\n }\n\n [Fact]\n public void The_difference_between_small_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 2;\n const int expected = 4;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 4 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void The_difference_between_ints_is_included_in_the_message()\n {\n // Arrange\n const int value = 22;\n const int expected = 52;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than 52 because we want to test the failure message, but found 22 (difference of -30).\");\n }\n\n [Fact]\n public void The_difference_between_equal_nullable_uints_is_not_included_in_the_message()\n {\n // Arrange\n uint? value = 15;\n const uint expected = 15;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 15u because we want to test the failure message, but found 15u.\");\n }\n\n [Fact]\n public void The_difference_between_equal_doubles_is_not_included_in_the_message()\n {\n // Arrange\n const double value = 1.3;\n const double expected = 1.3;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 1.3 because we want to test the failure message, but found 1.3.\");\n }\n\n [Fact]\n public void The_difference_between_equal_floats_is_not_included_in_the_message()\n {\n // Arrange\n const float value = 2.3F;\n const float expected = 2.3F;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than 2.3F because we want to test the failure message, but found 2.3F.\");\n }\n\n [Fact]\n public void The_difference_between_equal_ushorts_is_not_included_in_the_message()\n {\n // Arrange\n ushort? value = 11;\n const ushort expected = 11;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than 11us because we want to test the failure message, but found 11us.\");\n }\n\n [Fact]\n public void The_difference_between_equal_sbytes_is_not_included_in_the_message()\n {\n // Arrange\n const sbyte value = 3;\n const sbyte expected = 3;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 3y because we want to test the failure message, but found 3y.\");\n }\n\n [Fact]\n public void The_difference_between_equal_nullable_ulongs_is_not_included_in_the_message()\n {\n // Arrange\n ulong? value = 15;\n const ulong expected = 15;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than 15UL because we want to test the failure message, but found 15UL.\");\n }\n }\n\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void The_difference_between_small_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 2;\n const int expected = 4;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than or equal to 4 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void The_difference_between_ints_is_included_in_the_message()\n {\n // Arrange\n const int value = 22;\n const int expected = 52;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than or equal to 52 because we want to test the failure message, but found 22 (difference of -30).\");\n }\n }\n\n public class Overflow\n {\n [Fact]\n public void The_difference_between_overflowed_ints_is_included_in_the_message()\n {\n // Act\n Action act = () =>\n int.MinValue.Should().Be(int.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected int.MinValue to be 2147483647*found -2147483648 (difference of -4294967295).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_ints_is_included_in_the_message()\n {\n // Arrange\n int? minValue = int.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(int.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected minValue to be 2147483647*found -2147483648 (difference of -4294967295).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_uints_is_included_in_the_message()\n {\n // Act\n Action act = () =>\n uint.MinValue.Should().Be(uint.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected uint.MinValue to be 4294967295u*found 0u (difference of -4294967295).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_uints_is_included_in_the_message()\n {\n // Arrange\n uint? minValue = uint.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(uint.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected minValue to be 4294967295u*found 0u (difference of -4294967295).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_longs_is_included_in_the_message()\n {\n // Act\n Action act = () =>\n long.MinValue.Should().Be(long.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected long.MinValue to be 9223372036854775807L*found -9223372036854775808L (difference of -18446744073709551615).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_longs_is_included_in_the_message()\n {\n // Arrange\n long? minValue = long.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(long.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected minValue to be 9223372036854775807L*found -9223372036854775808L (difference of -18446744073709551615).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_ulongs_is_included_in_the_message()\n {\n // Act\n Action act = () =>\n ulong.MinValue.Should().Be(ulong.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected ulong.MinValue to be 18446744073709551615UL*found 0UL (difference of -18446744073709551615).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_ulongs_is_included_in_the_message()\n {\n // Arrange\n ulong? minValue = ulong.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(ulong.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected minValue to be 18446744073709551615UL*found 0UL (difference of -18446744073709551615).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_decimals_is_not_included_in_the_message()\n {\n // Act\n Action act = () =>\n decimal.MinValue.Should().Be(decimal.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected decimal.MinValue to be 79228162514264337593543950335M*found -79228162514264337593543950335M.\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_decimals_is_not_included_in_the_message()\n {\n // Arrange\n decimal? minValue = decimal.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(decimal.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected minValue to be 79228162514264337593543950335M*found -79228162514264337593543950335M.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/DelegateAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class DelegateAssertionSpecs\n{\n [Fact]\n public void Null_clock_throws_exception()\n {\n // Arrange\n Func subject = () => 1;\n\n // Act\n var act = void () => subject.Should(clock: null).NotThrow();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"clock\");\n }\n\n public class Throw\n {\n [Fact]\n public void Allow_additional_assertions_on_return_value()\n {\n // Arrange\n var exception = new Exception(\"foo\");\n Action subject = () => throw exception;\n\n // Act / Assert\n subject.Should().Throw()\n .Which.Message.Should().Be(\"foo\");\n }\n }\n\n public class ThrowExactly\n {\n [Fact]\n public void Does_not_continue_assertion_on_exact_exception_type()\n {\n // Arrange\n var a = () => { };\n\n // Act\n using var scope = new AssertionScope();\n a.Should().ThrowExactly();\n\n // Assert\n scope.Discard().Should().ContainSingle()\n .Which.Should().Match(\"*InvalidOperationException*no exception*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeStatic.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeStatic specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeStatic\n {\n [Fact]\n public void When_type_is_static_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(Static).Should().BeStatic();\n }\n\n [Theory]\n [InlineData(typeof(ClassWithoutMembers), \"Expected type *.ClassWithoutMembers to be static.\")]\n [InlineData(typeof(Sealed), \"Expected type *.Sealed to be static.\")]\n [InlineData(typeof(Abstract), \"Expected type *.Abstract to be static.\")]\n public void When_type_is_not_static_it_fails(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeStatic();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_type_is_not_static_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act\n Action act = () => type.Should().BeStatic(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.ClassWithoutMembers to be static *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_BeStatic_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeStatic();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_be_static_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().BeStatic(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be static *failure message*, but type is .\");\n }\n }\n\n public class NotBeStatic\n {\n [Theory]\n [InlineData(typeof(ClassWithoutMembers))]\n [InlineData(typeof(Sealed))]\n [InlineData(typeof(Abstract))]\n public void When_type_is_not_static_it_succeeds(Type type)\n {\n // Arrange / Act / Assert\n type.Should().NotBeStatic();\n }\n\n [Fact]\n public void When_type_is_static_it_fails()\n {\n // Arrange\n var type = typeof(Static);\n\n // Act\n Action act = () => type.Should().NotBeStatic();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Static not to be static.\");\n }\n\n [Fact]\n public void When_type_is_static_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(Static);\n\n // Act\n Action act = () => type.Should().NotBeStatic(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Static not to be static *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_NotBeStatic_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().NotBeStatic();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_not_be_static_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotBeStatic(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be static *failure message*, but type is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeAbstract.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeAbstract specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeAbstract\n {\n [Fact]\n public void When_type_is_abstract_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(Abstract).Should().BeAbstract();\n }\n\n [Theory]\n [InlineData(typeof(ClassWithoutMembers), \"Expected type *.ClassWithoutMembers to be abstract.\")]\n [InlineData(typeof(Sealed), \"Expected type *.Sealed to be abstract.\")]\n [InlineData(typeof(Static), \"Expected type *.Static to be abstract.\")]\n public void When_type_is_not_abstract_it_fails(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeAbstract();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_type_is_not_abstract_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act\n Action act = () => type.Should().BeAbstract(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.ClassWithoutMembers to be abstract *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_BeAbstract_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeAbstract();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_be_abstract_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().BeAbstract(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be abstract *failure message*, but type is .\");\n }\n }\n\n public class NotBeAbstract\n {\n [Theory]\n [InlineData(typeof(ClassWithoutMembers))]\n [InlineData(typeof(Sealed))]\n [InlineData(typeof(Static))]\n public void When_type_is_not_abstract_it_succeeds(Type type)\n {\n // Arrange / Act / Assert\n type.Should().NotBeAbstract();\n }\n\n [Fact]\n public void When_type_is_abstract_it_fails()\n {\n // Arrange\n var type = typeof(Abstract);\n\n // Act\n Action act = () => type.Should().NotBeAbstract();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Abstract not to be abstract.\");\n }\n\n [Fact]\n public void When_type_is_abstract_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(Abstract);\n\n // Act\n Action act = () => type.Should().NotBeAbstract(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Abstract not to be abstract *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_NotBeAbstract_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().NotBeAbstract();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_not_be_abstract_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotBeAbstract(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be abstract *failure message*, but type is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.Equal.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class Equal\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_is_equal_to_the_same_dictionary()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary1.Should().Equal(dictionary2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_with_null_value_is_equal_to_the_same_dictionary()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = null\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = null\n };\n\n // Act / Assert\n dictionary1.Should().Equal(dictionary2);\n }\n\n [Fact]\n public void When_asserting_dictionaries_to_be_equal_but_subject_dictionary_misses_a_value_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [22] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().Equal(dictionary2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [22] = \\\"Two\\\"} because we want to test the failure message, but could not find keys {22}.\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_to_be_equal_but_subject_dictionary_has_extra_key_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().Equal(dictionary2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [2] = \\\"Two\\\"} because we want to test the failure message, but found additional keys {3}.\");\n }\n\n [Fact]\n public void When_two_dictionaries_are_not_equal_by_values_it_should_throw_using_the_reason()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary1.Should().Equal(dictionary2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [2] = \\\"Three\\\"} because we want to test the failure message, but {[1] = \\\"One\\\", [2] = \\\"Two\\\"} differs at key 2.\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_to_be_equal_but_subject_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary1 = null;\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary1.Should().Equal(dictionary2, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [2] = \\\"Two\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_to_be_equal_but_expected_dictionary_is_null_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n Dictionary dictionary2 = null;\n\n // Act\n Action act = () =>\n dictionary1.Should().Equal(dictionary2, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare dictionary with .*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_an_empty_dictionary_is_compared_for_equality_to_a_non_empty_dictionary_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary();\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().Equal(dictionary2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [2] = \\\"Two\\\"}, but could not find keys {1, 2}.\");\n }\n }\n\n public class NotEqual\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_is_not_equal_to_a_dictionary_with_different_key()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [22] = \"Two\"\n };\n\n // Act / Assert\n dictionary1.Should().NotEqual(dictionary2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_is_not_equal_to_a_dictionary_with_different_value()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = null\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary1.Should().NotEqual(dictionary2);\n }\n\n [Fact]\n public void When_two_equal_dictionaries_are_not_expected_to_be_equal_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().NotEqual(dictionary2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dictionaries {[1] = \\\"One\\\", [2] = \\\"Two\\\"} and {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to be equal.\");\n }\n\n [Fact]\n public void When_two_equal_dictionaries_are_not_expected_to_be_equal_it_should_report_a_clear_explanation()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().NotEqual(dictionary2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dictionaries {[1] = \\\"One\\\", [2] = \\\"Two\\\"} and {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to be equal because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_not_to_be_equal_subject_but_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary1 = null;\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary1.Should().NotEqual(dictionary2, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionaries not to be equal because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_not_to_be_equal_but_expected_dictionary_is_null_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n Dictionary dictionary2 = null;\n\n // Act\n Action act =\n () => dictionary1.Should().NotEqual(dictionary2, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare dictionary with .*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void\n When_asserting_dictionaries_not_to_be_equal_subject_but_both_dictionaries_reference_the_same_object_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = dictionary1;\n\n // Act\n Action act =\n () => dictionary1.Should().NotEqual(dictionary2, \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionaries not to be equal because we want to test the behaviour with same objects, but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/Issue1657.cs", "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Collections;\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Jobs;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\n[SimpleJob(RuntimeMoniker.Net472)]\n[SimpleJob(RuntimeMoniker.Net80)]\npublic class Issue1657\n{\n private List list;\n private List list2;\n\n [Params(1, 10, 50)]\n public int N { get; set; }\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n list = Enumerable.Range(0, N).Select(i => GetObject(i)).ToList();\n list2 = Enumerable.Range(0, N).Select(i => GetObject(N - 1 - i)).ToList();\n }\n\n [Benchmark]\n public AndConstraint> BeEquivalentTo() =>\n list.Should().BeEquivalentTo(list2);\n\n private static ExampleObject GetObject(int i)\n {\n string iToString = i.ToString(\"D2\", CultureInfo.InvariantCulture);\n return new ExampleObject\n {\n Id = iToString,\n Value1 = iToString,\n Value2 = iToString,\n Value3 = iToString,\n Value4 = iToString,\n Value5 = iToString,\n Value6 = iToString,\n Value7 = iToString,\n Value8 = iToString,\n Value9 = iToString,\n Value10 = iToString,\n Value11 = iToString,\n Value12 = iToString,\n };\n }\n}\n\npublic class ExampleObject\n{\n public string Id { get; set; }\n\n public string Value1 { get; set; }\n\n public string Value2 { get; set; }\n\n public string Value3 { get; set; }\n\n public string Value4 { get; set; }\n\n public string Value5 { get; set; }\n\n public string Value6 { get; set; }\n\n public string Value7 { get; set; }\n\n public string Value8 { get; set; }\n\n public string Value9 { get; set; }\n\n public string Value10 { get; set; }\n\n public string Value11 { get; set; }\n\n public string Value12 { get; set; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeInDescendingOrder.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeInDescendingOrder specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeInDescendingOrder\n {\n [Fact]\n public void When_asserting_the_items_in_an_descendingly_ordered_collection_are_ordered_descending_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"z\", \"y\", \"x\"];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder();\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_unordered_collection_are_ordered_descending_it_should_throw()\n {\n // Arrange\n string[] collection = [\"z\", \"x\", \"y\"];\n\n // Act\n Action action = () => collection.Should().BeInDescendingOrder(\"because letters are ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to be in descending order because letters are ordered,\" +\n \" but found {\\\"z\\\", \\\"x\\\", \\\"y\\\"} where item at index 1 is in wrong order.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_by_property_expression_ordered_in_descending_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(o => o.Number);\n }\n\n [Fact]\n public void When_asserting_empty_collection_with_no_parameters_ordered_in_descending_it_should_succeed()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder();\n }\n\n [Fact]\n public void When_asserting_single_element_collection_with_no_parameters_ordered_in_descending_it_should_succeed()\n {\n // Arrange\n int[] collection = [42];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder();\n }\n\n [Fact]\n public void When_asserting_single_element_collection_by_property_expression_ordered_in_descending_it_should_succeed()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(o => o.Number);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_descending_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n string[] collection = [\"z\", \"x\", \"y\"];\n\n // Act\n Action action = () =>\n collection.Should().BeInDescendingOrder(Comparer.Default, \"because letters are ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to be in descending order because letters are ordered,\" +\n \" but found {\\\"z\\\", \\\"x\\\", \\\"y\\\"} where item at index 1 is in wrong order.\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_descendingly_ordered_collection_are_ordered_descending_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"z\", \"y\", \"x\"];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_descending_using_the_specified_property_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act\n Action act = () => collection.Should().BeInDescendingOrder(o => o.Text, \"it should be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*ordered*Text*should be sorted*c*b*a*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_descending_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act\n Action act = () =>\n collection.Should().BeInDescendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase, \"it should be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*ordered*Text*should be sorted*c*b*a*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_descendingly_ordered_collection_are_ordered_descending_using_the_specified_property_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 3 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 1 }\n };\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(o => o.Numeric);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_descendingly_ordered_collection_are_ordered_descending_using_the_specified_property_and_the_given_comparer_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 3 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 1 }\n };\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(o => o.Numeric, Comparer.Default);\n }\n\n [Fact]\n public void When_strings_are_in_descending_order_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"theta\", \"beta\", \"alpha\"];\n\n // Act / Assert\n strings.Should().BeInDescendingOrder();\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_it_should_throw()\n {\n // Arrange\n string[] strings = [\"theta\", \"alpha\", \"beta\"];\n\n // Act\n Action act = () => strings.Should().BeInDescendingOrder(\"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*descending*of reasons*index 1*\");\n }\n\n [Fact]\n public void When_strings_are_in_descending_order_based_on_a_custom_comparer_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"barbara\"];\n\n // Act / Assert\n strings.Should().BeInDescendingOrder(new ByLastCharacterComparer());\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_based_on_a_custom_comparer_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"barbara\"];\n\n // Act\n Action act = () => strings.Should().BeInDescendingOrder(new ByLastCharacterComparer(), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*descending*of reasons*index 0*\");\n }\n\n [Fact]\n public void When_strings_are_in_descending_order_based_on_a_custom_lambda_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"barbara\"];\n\n // Act / Assert\n strings.Should().BeInDescendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]));\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_based_on_a_custom_lambda_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"barbara\"];\n\n // Act\n Action act = () =>\n strings.Should().BeInDescendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*descending*of reasons*index 0*\");\n }\n }\n\n public class NotBeInDescendingOrder\n {\n [Fact]\n public void When_asserting_the_items_in_an_unordered_collection_are_not_in_descending_order_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"x\", \"y\", \"x\"];\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_not_in_descending_order_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"x\", \"y\", \"x\"];\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_descending_ordered_collection_are_not_in_descending_order_it_should_throw()\n {\n // Arrange\n string[] collection = [\"c\", \"b\", \"a\"];\n\n // Act\n Action action = () => collection.Should().NotBeInDescendingOrder(\"because numbers are not ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order because numbers are not ordered,\" +\n \" but found {\\\"c\\\", \\\"b\\\", \\\"a\\\"}.\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_descending_ordered_collection_are_not_in_descending_order_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n string[] collection = [\"c\", \"b\", \"a\"];\n\n // Act\n Action action = () =>\n collection.Should().NotBeInDescendingOrder(Comparer.Default, \"because numbers are not ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order because numbers are not ordered,\" +\n \" but found {\\\"c\\\", \\\"b\\\", \\\"a\\\"}.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_by_property_expression_to_not_be_ordered_in_descending_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(o => o.Number);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection {empty} to not be ordered \\\"by Number\\\" and not result in {empty}.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_with_no_parameters_not_be_ordered_in_descending_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(\"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order because I say so, but found {empty}.\");\n }\n\n [Fact]\n public void When_asserting_single_element_collection_with_no_parameters_not_be_ordered_in_descending_it_should_throw()\n {\n // Arrange\n int[] collection = [42];\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order, but found {42}.\");\n }\n\n [Fact]\n public void\n When_asserting_single_element_collection_by_property_expression_to_not_be_ordered_in_descending_it_should_throw()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(o => o.Number);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_descending_ordered_collection_are_not_ordered_descending_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n int[] collection = [3, 2, 1];\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(Comparer.Default, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order*should not be sorted*3*2*1*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_descendingly_ordered_collection_are_not_ordered_descending_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_descending_ordered_collection_are_not_ordered_descending_using_the_specified_property_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"c\", Numeric = 3 },\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"a\", Numeric = 2 }\n };\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(o => o.Text, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*not be ordered*Text*should not be sorted*c*b*a*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ordered_collection_are_not_ordered_descending_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"C\", Numeric = 1 },\n new { Text = \"b\", Numeric = 2 },\n new { Text = \"A\", Numeric = 3 }\n };\n\n // Act\n Action act = () =>\n collection.Should()\n .NotBeInDescendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*C*b*A*not be ordered*Text*should not be sorted*C*b*A*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_descendingly_ordered_collection_are_not_ordered_descending_using_the_specified_property_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder(o => o.Numeric);\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_descendingly_ordered_collection_are_not_ordered_descending_using_the_specified_property_and_the_given_comparer_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder(o => o.Numeric, Comparer.Default);\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"beta\", \"theta\", \"alpha\"];\n\n // Act / Assert\n strings.Should().NotBeInDescendingOrder();\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_descending_order_it_should_throw()\n {\n // Arrange\n string[] strings = [\"theta\", \"beta\", \"alpha\"];\n\n // Act\n Action act = () => strings.Should().NotBeInDescendingOrder(\"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*descending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_based_on_a_custom_comparer_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"roy\", \"barbara\", \"dennis\"];\n\n // Act / Assert\n strings.Should().NotBeInDescendingOrder(new ByLastCharacterComparer());\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_descending_order_based_on_a_custom_comparer_it_should_throw()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"barbara\"];\n\n // Act\n Action act = () => strings.Should().NotBeInDescendingOrder(new ByLastCharacterComparer(), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*descending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_based_on_a_custom_lambda_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"barbara\"];\n\n // Act / Assert\n strings.Should().NotBeInDescendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]));\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_descending_order_based_on_a_custom_lambda_it_should_throw()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"barbara\"];\n\n // Act\n Action act = () =>\n strings.Should().NotBeInDescendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*descending*of reasons*but found*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeSealed.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeSealed specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeSealed\n {\n [Fact]\n public void When_type_is_sealed_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(Sealed).Should().BeSealed();\n }\n\n [Theory]\n [InlineData(typeof(ClassWithoutMembers), \"Expected type *.ClassWithoutMembers to be sealed.\")]\n [InlineData(typeof(Abstract), \"Expected type *.Abstract to be sealed.\")]\n [InlineData(typeof(Static), \"Expected type *.Static to be sealed.\")]\n public void When_type_is_not_sealed_it_fails(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeSealed();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_type_is_not_sealed_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act\n Action act = () => type.Should().BeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.ClassWithoutMembers to be sealed *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_BeSealed_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeSealed();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_be_sealed_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().BeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be sealed *failure message*, but type is .\");\n }\n }\n\n public class NotBeSealed\n {\n [Theory]\n [InlineData(typeof(ClassWithoutMembers))]\n [InlineData(typeof(Abstract))]\n [InlineData(typeof(Static))]\n public void When_type_is_not_sealed_it_succeeds(Type type)\n {\n // Arrange / Act / Assert\n type.Should().NotBeSealed();\n }\n\n [Fact]\n public void When_type_is_sealed_it_fails()\n {\n // Arrange\n var type = typeof(Sealed);\n\n // Act\n Action act = () => type.Should().NotBeSealed();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Sealed not to be sealed.\");\n }\n\n [Fact]\n public void When_type_is_sealed_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(Sealed);\n\n // Act\n Action act = () => type.Should().NotBeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Sealed not to be sealed *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_NotBeSealed_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().NotBeSealed();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_not_be_sealed_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotBeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be sealed *failure message*, but type is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ObjectExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class ObjectExtensions\n{\n public static Func GetComparer()\n {\n if (typeof(T).IsValueType)\n {\n // Avoid causing any boxing for value types\n return (actual, expected) => EqualityComparer.Default.Equals(actual, expected);\n }\n\n if (typeof(T) != typeof(object))\n {\n // CompareNumerics is only relevant for numerics boxed in an object.\n return (actual, expected) => actual is null\n ? expected is null\n : expected is not null && EqualityComparer.Default.Equals(actual, expected);\n }\n\n return (actual, expected) => actual is null\n ? expected is null\n : expected is not null\n && (EqualityComparer.Default.Equals(actual, expected) || CompareNumerics(actual, expected));\n }\n\n private static bool CompareNumerics(object actual, object expected)\n {\n Type expectedType = expected.GetType();\n Type actualType = actual.GetType();\n\n return actualType != expectedType\n && actual.IsNumericType()\n && expected.IsNumericType()\n && CanConvert(actual, expected, actualType, expectedType)\n && CanConvert(expected, actual, expectedType, actualType);\n }\n\n private static bool CanConvert(object source, object target, Type sourceType, Type targetType)\n {\n try\n {\n var converted = source.ConvertTo(targetType);\n\n return source.Equals(converted.ConvertTo(sourceType))\n && converted.Equals(target);\n }\n catch\n {\n // ignored\n return false;\n }\n }\n\n private static object ConvertTo(this object source, Type targetType)\n {\n return Convert.ChangeType(source, targetType, CultureInfo.InvariantCulture);\n }\n\n private static bool IsNumericType(this object obj)\n {\n // \"is not null\" is due to https://github.com/dotnet/runtime/issues/47920#issuecomment-774481505\n return obj is not null and (\n int or\n long or\n float or\n double or\n decimal or\n sbyte or\n byte or\n short or\n ushort or\n uint or\n ulong);\n }\n\n /// \n /// Convenience method to format an object to a string using the class.\n /// \n public static string ToFormattedString(this object source)\n {\n return Formatter.ToString(source);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/FluentDateTimeSpecs.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class FluentDateTimeSpecs\n{\n [Fact]\n public void When_fluently_specifying_a_date_in_january_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.January(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 1, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_february_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.February(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 2, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_march_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.March(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 3, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_april_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.April(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 4, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_may_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.May(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 5, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_june_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.June(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 6, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_july_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.July(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 7, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_august_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.August(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 8, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_september_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.September(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 9, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_october_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.October(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 10, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_november_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.November(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 11, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_december_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.December(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 12, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_and_time_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime dateTime = 10.December(2011).At(09, 30, 45, 123, 456, 700);\n\n // Assert\n dateTime.Should().Be(new DateTime(2011, 12, 10, 9, 30, 45, 123).AddMicroseconds(456).AddNanoseconds(700));\n dateTime.Microsecond().Should().Be(456);\n dateTime.Nanosecond().Should().Be(700);\n dateTime.Should().BeIn(DateTimeKind.Unspecified);\n }\n\n [Fact]\n public void When_fluently_specifying_a_datetimeoffset_and_time_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTimeOffset dateTime = 10.December(2011).ToDateTimeOffset().At(09, 30, 45, 123, 456, 700);\n\n // Assert\n dateTime.Should().Be(new DateTimeOffset(2011, 12, 10, 9, 30, 45, 123, TimeSpan.Zero).AddMicroseconds(456)\n .AddNanoseconds(700));\n\n dateTime.Microsecond().Should().Be(456);\n dateTime.Nanosecond().Should().Be(700);\n }\n\n [InlineData(-1)]\n [InlineData(1000)]\n [Theory]\n public void When_fluently_specifying_a_datetime_with_out_of_range_microseconds_it_should_throw(int microseconds)\n {\n // Act\n string expectedParameterName = \"microseconds\";\n Action act = () => 10.December(2011).At(0, 0, 0, 0, microseconds);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(expectedParameterName);\n }\n\n [InlineData(0)]\n [InlineData(999)]\n [Theory]\n public void When_fluently_specifying_a_datetime_with_inrange_microseconds_it_should_not_throw(int microseconds)\n {\n // Act\n Action act = () => 10.December(2011).At(0, 0, 0, 0, microseconds);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [InlineData(-1)]\n [InlineData(1000)]\n [Theory]\n public void When_fluently_specifying_a_datetime_with_out_of_range_nanoseconds_it_should_throw(int nanoseconds)\n {\n // Act\n var expectedParameterName = \"nanoseconds\";\n Action act = () => 10.December(2011).At(0, 0, 0, 0, 0, nanoseconds);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(expectedParameterName);\n }\n\n [InlineData(0)]\n [InlineData(999)]\n [Theory]\n public void When_fluently_specifying_a_datetime_with_inrange_nanoseconds_it_should_not_throw(int nanoseconds)\n {\n // Act\n Action act = () => 10.December(2011).At(0, 0, 0, 0, 0, nanoseconds);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [InlineData(-1)]\n [InlineData(1000)]\n [Theory]\n public void When_fluently_specifying_a_datetimeoffset_with_out_of_range_microseconds_it_should_throw(int microseconds)\n {\n // Act\n var expectedParameterName = \"microseconds\";\n Action act = () => 10.December(2011).ToDateTimeOffset().At(0, 0, 0, 0, microseconds);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(expectedParameterName);\n }\n\n [InlineData(0)]\n [InlineData(999)]\n [Theory]\n public void When_fluently_specifying_a_datetimeoffset_with_inrange_microseconds_it_should_not_throw(int microseconds)\n {\n // Act\n Action act = () => 10.December(2011).ToDateTimeOffset().At(0, 0, 0, 0, microseconds);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [InlineData(-1)]\n [InlineData(1000)]\n [Theory]\n public void When_fluently_specifying_a_datetimeoffset_with_out_of_range_nanoseconds_it_should_throw(int nanoseconds)\n {\n // Act\n var expectedParameterName = \"nanoseconds\";\n Action act = () => 10.December(2011).ToDateTimeOffset().At(0, 0, 0, 0, 0, nanoseconds);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(expectedParameterName);\n }\n\n [InlineData(0)]\n [InlineData(999)]\n [Theory]\n public void When_fluently_specifying_a_datetimeoffset_with_inrange_nanoseconds_it_should_not_throw(int nanoseconds)\n {\n // Act\n Action act = () => 10.December(2011).ToDateTimeOffset().At(0, 0, 0, 0, 0, nanoseconds);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_and_time_as_utc_it_should_return_the_date_time_value_with_utc_kind()\n {\n // Act\n DateTime dateTime = 10.December(2011).At(09, 30, 45, 123, 456, 700).AsUtc();\n\n // Assert\n dateTime.Should().Be(new DateTime(2011, 12, 10, 9, 30, 45, 123).AddMicroseconds(456).AddNanoseconds(700));\n dateTime.Microsecond().Should().Be(456);\n dateTime.Nanosecond().Should().Be(700);\n dateTime.Should().BeIn(DateTimeKind.Utc);\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_and_time_as_local_it_should_return_the_date_time_value_with_local_kind()\n {\n // Act\n DateTime dateTime = 10.December(2011).At(09, 30, 45, 123, 456, 700).AsLocal();\n\n // Assert\n dateTime.Should().Be(new DateTime(2011, 12, 10, 9, 30, 45, 123).AddMicroseconds(456).AddNanoseconds(700));\n dateTime.Microsecond().Should().Be(456);\n dateTime.Nanosecond().Should().Be(700);\n dateTime.Should().BeIn(DateTimeKind.Local);\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_and_timespan_it_should_return_the_correct_date_time_value()\n {\n // Act\n var time = 9.Hours().And(30.Minutes()).And(45.Seconds());\n DateTime dateTime = 10.December(2011).At(time);\n\n // Assert\n dateTime.Should().Be(new DateTime(2011, 12, 10, 9, 30, 45));\n }\n\n [Fact]\n public void Specyfing_the_time_of_day_retains_the_full_precision()\n {\n // Act\n DateTime subject = 10.December(2011).At(1.Ticks());\n DateTime expected = 10.December(2011) + 1.Ticks();\n\n // Assert\n subject.Should().Be(expected);\n }\n\n [Fact]\n public void Specifying_the_time_of_day_retains_the_datetime_kind()\n {\n // Act\n DateTime dateTime = 10.December(2011).AsUtc().At(TimeSpan.Zero);\n\n // Assert\n dateTime.Should().BeIn(DateTimeKind.Utc);\n }\n\n [Fact]\n public void Specifying_the_time_of_day_in_hours_and_minutes_retains_the_datetime_kind()\n {\n // Act\n DateTime dateTime = 10.December(2011).AsUtc().At(0, 0);\n\n // Assert\n dateTime.Should().BeIn(DateTimeKind.Utc);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.IntersectWith.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]IntersectWith specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class IntersectWith\n {\n [Fact]\n public void When_asserting_the_items_in_an_two_intersecting_collections_intersect_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = [3, 4, 5];\n\n // Act / Assert\n collection.Should().IntersectWith(otherCollection);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_non_intersecting_collections_intersect_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = [4, 5];\n\n // Act\n Action action = () => collection.Should().IntersectWith(otherCollection, \"they should share items\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to intersect with {4, 5} because they should share items,\" +\n \" but {1, 2, 3} does not contain any shared items.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_intersect_with_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().IntersectWith([4, 5], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to intersect with {4, 5} *failure message*, but found .\");\n }\n }\n\n public class NotIntersectWith\n {\n [Fact]\n public void When_asserting_the_items_in_an_two_non_intersecting_collections_do_not_intersect_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = [4, 5];\n\n // Act / Assert\n collection.Should().NotIntersectWith(otherCollection);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_intersecting_collections_do_not_intersect_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = [2, 3, 4];\n\n // Act\n Action action = () => collection.Should().NotIntersectWith(otherCollection, \"they should not share items\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to intersect with {2, 3, 4} because they should not share items,\" +\n \" but found the following shared items {2, 3}.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_intersect_with_same_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n var otherCollection = collection;\n\n // Act\n Action act = () => collection.Should().NotIntersectWith(otherCollection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect*to intersect with*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_not_intersect_with_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotIntersectWith([4, 5], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to intersect with {4, 5} *failure message*, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.AllBeOfType.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The AllBeOfType specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class AllBeOfType\n {\n [Fact]\n public void When_the_types_in_a_collection_is_matched_against_a_null_type_exactly_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().AllBeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expectedType\");\n }\n\n [Fact]\n public void All_items_in_an_empty_collection_are_of_a_generic_type()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().AllBeOfType();\n }\n\n [Fact]\n public void All_items_in_an_empty_collection_are_of_a_type()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().AllBeOfType(typeof(int));\n }\n\n [Fact]\n public void When_collection_is_null_then_all_be_of_type_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllBeOfType(typeof(object), \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be object *failure message*, but found collection is .\");\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_expected_type_exactly_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeOfType(typeof(int));\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_expected_generic_type_exactly_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeOfType();\n }\n\n [Fact]\n public void When_matching_a_collection_against_an_exact_type_it_should_return_the_casted_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeOfType()\n .Which.Should().Equal(1, 2, 3);\n }\n\n [Fact]\n public void When_one_of_the_types_does_not_match_exactly_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { new Exception(), new ArgumentException(\"foo\") };\n\n // Act\n Action act = () => collection.Should().AllBeOfType(typeof(Exception), \"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be System.Exception because they are of different type, but found {System.Exception, System.ArgumentException}.\");\n }\n\n [Fact]\n public void When_one_of_the_types_does_not_match_exactly_the_generic_type_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { new Exception(), new ArgumentException(\"foo\") };\n\n // Act\n Action act = () => collection.Should().AllBeOfType(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be System.Exception because they are of different type, but found {System.Exception, System.ArgumentException}.\");\n }\n\n [Fact]\n public void When_one_of_the_elements_is_null_for_an_exact_match_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { 1, null, 3 };\n\n // Act\n Action act = () => collection.Should().AllBeOfType(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found a null element.\");\n }\n\n [Fact]\n public void When_collection_of_types_match_expected_type_exactly_it_should_succeed()\n {\n // Arrange\n Type[] collection = [typeof(int), typeof(int), typeof(int)];\n\n // Act / Assert\n collection.Should().AllBeOfType();\n }\n\n [Fact]\n public void When_collection_of_types_and_objects_match_type_exactly_it_should_succeed()\n {\n // Arrange\n var collection = new object[] { typeof(ArgumentException), new ArgumentException(\"foo\") };\n\n // Act / Assert\n collection.Should().AllBeOfType();\n }\n\n [Fact]\n public void When_collection_of_types_and_objects_do_not_match_type_exactly_it_should_throw()\n {\n // Arrange\n var collection = new object[] { typeof(Exception), new ArgumentException(\"foo\") };\n\n // Act\n Action act = () => collection.Should().AllBeOfType();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be System.ArgumentException, but found {System.Exception, System.ArgumentException}.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_all_be_of_typeOfT_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllBeOfType(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be object *failure message*, but found collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.BeSubsetOf.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class BeSubsetOf\n {\n [Fact]\n public void When_a_subset_is_tested_against_a_null_superset_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n IEnumerable subset = [\"one\", \"two\", \"three\"];\n IEnumerable superset = null;\n\n // Act\n Action act = () => subset.Should().BeSubsetOf(superset);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify a subset against a collection.*\");\n }\n\n [Fact]\n public void When_an_empty_collection_is_tested_against_a_superset_it_should_succeed()\n {\n // Arrange\n IEnumerable subset = new string[0];\n IEnumerable superset = [\"one\", \"two\", \"four\", \"five\"];\n\n // Act / Assert\n subset.Should().BeSubsetOf(superset);\n }\n\n [Fact]\n public void When_asserting_collection_to_be_subset_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act =\n () => collection.Should().BeSubsetOf(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be a subset of {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_is_not_a_subset_of_another_it_should_throw_with_the_reason()\n {\n // Arrange\n IEnumerable subset = [\"one\", \"two\", \"three\", \"six\"];\n IEnumerable superset = [\"one\", \"two\", \"four\", \"five\"];\n\n // Act\n Action act = () => subset.Should().BeSubsetOf(superset, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subset to be a subset of {\\\"one\\\", \\\"two\\\", \\\"four\\\", \\\"five\\\"} because we want to test the failure message, \" +\n \"but items {\\\"three\\\", \\\"six\\\"} are not part of the superset.\");\n }\n\n [Fact]\n public void When_collection_is_subset_of_a_specified_collection_it_should_not_throw()\n {\n // Arrange\n IEnumerable subset = [\"one\", \"two\"];\n IEnumerable superset = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n subset.Should().BeSubsetOf(superset);\n }\n }\n\n public class NotBeSubsetOf\n {\n [Fact]\n public void Should_fail_when_asserting_collection_is_not_subset_of_a_superset_collection()\n {\n // Arrange\n IEnumerable subject = [\"one\", \"two\"];\n IEnumerable otherSet = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => subject.Should().NotBeSubsetOf(otherSet, \"because I'm {0}\", \"mistaken\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect subject {\\\"one\\\", \\\"two\\\"} to be a subset of {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because I'm mistaken.\");\n }\n\n [Fact]\n public void When_a_set_is_expected_to_be_not_a_subset_it_should_succeed()\n {\n // Arrange\n IEnumerable subject = [\"one\", \"two\", \"four\"];\n IEnumerable otherSet = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n subject.Should().NotBeSubsetOf(otherSet);\n }\n\n [Fact]\n public void When_an_empty_set_is_not_supposed_to_be_a_subset_of_another_set_it_should_throw()\n {\n // Arrange\n IEnumerable subject = [];\n IEnumerable otherSet = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => subject.Should().NotBeSubsetOf(otherSet);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect subject {empty} to be a subset of {\\\"one\\\", \\\"two\\\", \\\"three\\\"}.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_subset_against_same_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = collection;\n\n // Act\n Action act = () => collection.Should().NotBeSubsetOf(otherCollection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect*to be a subset of*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableEnumAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \npublic class NullableEnumAssertions : NullableEnumAssertions>\n where TEnum : struct, Enum\n{\n public NullableEnumAssertions(TEnum? subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \npublic class NullableEnumAssertions : EnumAssertions\n where TEnum : struct, Enum\n where TAssertions : NullableEnumAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableEnumAssertions(TEnum? subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable enum} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndWhichConstraint((TAssertions)this, Subject.GetValueOrDefault(), assertionChain, \".Value\");\n }\n\n /// \n /// Asserts that a nullable is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:nullable enum} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/IParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\n/// \n/// Represents a stateful parsing strategy that is used to help identify the \"caller\" to use in an assertion message.\n/// \n/// \n/// The strategies will be instantiated at the beginning of a \"caller identification\" task, and will live until\n/// the statement can be identified (and thus some are stateful).\n/// \ninternal interface IParsingStrategy\n{\n /// \n /// Given a symbol, the parsing strategy should add/remove from the statement if needed, and then return\n /// - InProgress if the symbol isn't relevant to the strategies (so other strategies can be tried)\n /// - Handled if an action has been taken (and no other strategies should be used for this symbol)\n /// - Done if the statement is complete, and thus further symbols should be read.\n /// \n ParsingState Parse(char symbol, StringBuilder statement);\n\n /// \n /// Returns true if strategy is in the middle of a context (ex: strategy read \"/*\" and is waiting for \"*/\"\n /// \n bool IsWaitingForContextEnd();\n\n /// \n /// Used to notify the strategy that we have reached the end of the line (very useful to detect the end of\n /// a single line comment).\n /// \n void NotifyEndOfLineReached();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeSameDateAs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeSameDateAs\n {\n [Fact]\n public void When_asserting_subject_datetime_should_be_same_date_as_another_with_the_same_date_it_should_succeed()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31, 4, 5, 6);\n\n // Act / Assert\n subject.Should().BeSameDateAs(new DateTime(2009, 12, 31));\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_should_be_same_as_another_with_same_date_but_different_time_it_should_succeed()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31, 4, 5, 6);\n\n // Act / Assert\n subject.Should().BeSameDateAs(new DateTime(2009, 12, 31, 11, 15, 11));\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_to_be_same_date_as_another_datetime_it_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n\n // Act\n Action act = () => subject.Should().BeSameDateAs(new DateTime(2009, 12, 31));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected the date part of subject to be <2009-12-31>, but found a DateTime.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_same_date_as_another_but_it_doesnt_it_should_throw()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31);\n\n // Act\n Action act = () => subject.Should().BeSameDateAs(new DateTime(2009, 12, 30));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected the date part of subject to be <2009-12-30>, but found <2009-12-31>.\");\n }\n }\n\n public class NotBeSameDateAs\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_be_same_date_as_another_with_the_same_date_it_should_throw()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31, 4, 5, 6);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(new DateTime(2009, 12, 31));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_should_not_be_same_as_another_with_same_date_but_different_time_it_should_throw()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31, 4, 5, 6);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(new DateTime(2009, 12, 31, 11, 15, 11));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_to_not_be_same_date_as_another_datetime_it_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(new DateTime(2009, 12, 31));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect the date part of subject to be <2009-12-31>, but found a DateTime.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_same_date_as_another_but_it_doesnt_it_should_succeed()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31);\n\n // Act / Assert\n subject.Should().NotBeSameDateAs(new DateTime(2009, 12, 30));\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeCloseTo.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeCloseTo\n {\n [Fact]\n public void When_asserting_that_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().BeCloseTo(dateTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_later_datetime_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_an_earlier_datetime_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks + 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_MinValue_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTime.MinValue;\n var actual = new DateTime(dateTime.Ticks + 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_MaxValue_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTime.MaxValue;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_a_later_datetime_it_should_succeed()\n {\n // Arrange\n DateTime time = DateTime.SpecifyKind(new DateTime(2016, 06, 04).At(12, 15, 30, 980), DateTimeKind.Unspecified);\n DateTime nearbyTime = DateTime.SpecifyKind(new DateTime(2016, 06, 04).At(12, 15, 31), DateTimeKind.Utc);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_an_earlier_datetime_it_should_succeed()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 020);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_another_value_that_is_later_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 30, 979);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31>, but <2012-03-13 12:15:30.979> was off by 21ms.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_is_close_to_another_value_that_is_later_by_more_than_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 30, 979);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31>, but <2012-03-13 12:15:30.979> was off by 21ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 31, 021);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31>, but <2012-03-13 12:15:31.021> was off by 21ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_an_earlier_datetime_by_35ms_it_should_succeed()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 035);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_is_close_to_another_it_should_throw()\n {\n // Arrange\n DateTime? time = null;\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_the_minimum_datetime_it_should_succeed()\n {\n // Arrange\n DateTime time = DateTime.MinValue + 50.Milliseconds();\n DateTime nearbyTime = DateTime.MinValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_the_maximum_datetime_it_should_succeed()\n {\n // Arrange\n DateTime time = DateTime.MaxValue - 50.Milliseconds();\n DateTime nearbyTime = DateTime.MaxValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n }\n\n public class NotBeCloseTo\n {\n [Fact]\n public void When_asserting_that_time_is_not_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_later_datetime_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_an_earlier_datetime_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks + 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_MinValue_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTime.MinValue;\n var actual = new DateTime(dateTime.Ticks + 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_MaxValue_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTime.MaxValue;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_a_later_datetime_it_should_throw()\n {\n // Arrange\n DateTime time = DateTime.SpecifyKind(new DateTime(2016, 06, 04).At(12, 15, 30, 980), DateTimeKind.Unspecified);\n DateTime nearbyTime = DateTime.SpecifyKind(new DateTime(2016, 06, 04).At(12, 15, 31), DateTimeKind.Utc);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31>, but it was <2016-06-04 12:15:30.980>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_an_earlier_datetime_it_should_throw()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 020);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31>, but it was <2016-06-04 12:15:31.020>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_an_earlier_datetime_by_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 020);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31>, but it was <2016-06-04 12:15:31.020>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_is_not_close_to_another_value_that_is_later_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 30, 979);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_is_not_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 31, 021);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_an_earlier_datetime_by_35ms_it_should_throw()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 035);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 35ms from <2016-06-04 12:15:31>, but it was <2016-06-04 12:15:31.035>.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_is_not_close_to_another_it_should_throw()\n {\n // Arrange\n DateTime? time = null;\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*, but it was .\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_the_minimum_datetime_it_should_throw()\n {\n // Arrange\n DateTime time = DateTime.MinValue + 50.Milliseconds();\n DateTime nearbyTime = DateTime.MinValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 100ms from <0001-01-01 00:00:00.000>, but it was <00:00:00.050>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_the_maximum_datetime_it_should_throw()\n {\n // Arrange\n DateTime time = DateTime.MaxValue - 50.Milliseconds();\n DateTime nearbyTime = DateTime.MaxValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 100ms from <9999-12-31 23:59:59.9999999>, but it was <9999-12-31 23:59:59.9499999>.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableSimpleTimeSpanAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableSimpleTimeSpanAssertions : NullableSimpleTimeSpanAssertions\n{\n public NullableSimpleTimeSpanAssertions(TimeSpan? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableSimpleTimeSpanAssertions : SimpleTimeSpanAssertions\n where TAssertions : NullableSimpleTimeSpanAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableSimpleTimeSpanAssertions(TimeSpan? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected a value{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that the value is equal to the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TimeSpan? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.HaveLength.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The HaveLength specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class HaveLength\n {\n [Fact]\n public void Should_succeed_when_asserting_string_length_to_be_equal_to_the_same_value()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act / Assert\n actual.Should().HaveLength(3);\n }\n\n [Fact]\n public void When_asserting_string_length_on_null_string_it_should_fail()\n {\n // Arrange\n string actual = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n actual.Should().HaveLength(0, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual with length 0 *failure message*, but found .\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_string_length_to_be_equal_to_different_value()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n actual.Should().HaveLength(1, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual with length 1 *failure message*, but found string \\\"ABC\\\" with length 3.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/MethodBaseAssertionSpecs.cs", "using System;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class MethodBaseAssertionSpecs\n{\n public class Return\n {\n [Fact]\n public void When_asserting_an_int_method_returns_int_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().Return(typeof(int));\n }\n\n [Fact]\n public void When_asserting_an_int_method_returns_string_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(typeof(string), \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method IntMethod to be string because we want to test the \" +\n \"error message, but it is int.\");\n }\n\n [Fact]\n public void When_asserting_a_void_method_returns_string_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"VoidMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(typeof(string), \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method VoidMethod to be string because we want to test the \" +\n \"error message, but it is void.\");\n }\n\n [Fact]\n public void When_subject_is_null_return_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the return type of method to be string *failure message*, but methodInfo is .\");\n }\n\n [Fact]\n public void When_asserting_method_return_type_is_null_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"returnType\");\n }\n }\n\n public class NotReturn\n {\n [Fact]\n public void When_asserting_an_int_method_does_not_return_string_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().NotReturn(typeof(string));\n }\n\n [Fact]\n public void When_asserting_an_int_method_does_not_return_int_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(typeof(int), \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of*IntMethod*not to be int*because we want to test the \" +\n \"error message, but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_return_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the return type of method not to be string *failure message*, but methodInfo is .\");\n }\n\n [Fact]\n public void When_asserting_method_return_type_is_not_null_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"returnType\");\n }\n }\n\n public class ReturnOfT\n {\n [Fact]\n public void When_asserting_an_int_method_returnsOfT_int_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().Return();\n }\n\n [Fact]\n public void When_asserting_an_int_method_returnsOfT_string_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method IntMethod to be string because we want to test the \" +\n \"error message, but it is int.\");\n }\n\n [Fact]\n public void When_subject_is_null_returnOfT_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method to be string *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotReturnOfT\n {\n [Fact]\n public void When_asserting_an_int_method_does_not_returnsOfT_string_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().NotReturn();\n }\n\n [Fact]\n public void When_asserting_an_int_method_does_not_returnsOfT_int_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of*IntMethod*not to be int*because we want to test the \" +\n \"error message, but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_returnOfT_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the return type of method not to be string *failure message*, but methodInfo is .\");\n }\n }\n\n public class ReturnVoid\n {\n [Fact]\n public void When_asserting_a_void_method_returns_void_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"VoidMethod\");\n\n // Act / Assert\n methodInfo.Should().ReturnVoid();\n }\n\n [Fact]\n public void When_asserting_an_int_method_returns_void_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().ReturnVoid(\"because we want to test the error message {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the return type of method IntMethod to be void because we want to test the error message \" +\n \"message, but it is int.\");\n }\n\n [Fact]\n public void When_subject_is_null_return_void_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().ReturnVoid(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method to be void *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotReturnVoid\n {\n [Fact]\n public void When_asserting_an_int_method_does_not_return_void_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().NotReturnVoid();\n }\n\n [Fact]\n public void When_asserting_a_void_method_does_not_return_void_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"VoidMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturnVoid(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of*VoidMethod*not to be void*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_subject_is_null_not_return_void_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturnVoid(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method not to be void *failure message*, but methodInfo is .\");\n }\n }\n\n public class HaveAccessModifier\n {\n [Fact]\n public void When_asserting_a_private_member_is_private_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act / Assert\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_private_protected_member_is_private_protected_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateProtectedMethod\");\n\n // Act / Assert\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.PrivateProtected);\n }\n\n [Fact]\n public void When_asserting_a_private_member_is_protected_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should()\n .HaveAccessModifier(CSharpAccessModifier.Protected, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.PrivateMethod to be Protected because we want to test the error message\" +\n \", but it is Private.\");\n }\n\n [Fact]\n public void When_asserting_a_protected_member_is_protected_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"ProtectedSetProperty\");\n\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act / Assert\n setMethod.Should().HaveAccessModifier(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_protected_member_is_public_it_throws_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"ProtectedSetProperty\");\n\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act\n Action act = () =>\n setMethod\n .Should()\n .HaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.set_ProtectedSetProperty to be Public because we want to test the error message\" +\n \", but it is Protected.\");\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_public_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetProperty\");\n\n MethodInfo getMethod = propertyInfo.GetMethod;\n\n // Act / Assert\n getMethod.Should().HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_internal_it_throws_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetProperty\");\n\n MethodInfo getMethod = propertyInfo.GetMethod;\n\n // Act\n Action act = () =>\n getMethod\n .Should()\n .HaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.get_PublicGetProperty to be Internal because we want to test the error message, but it\" +\n \" is Public.\");\n }\n\n [Fact]\n public void When_asserting_an_internal_member_is_internal_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"InternalMethod\");\n\n // Act / Assert\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void When_asserting_an_internal_member_is_protectedInternal_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"InternalMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.ProtectedInternal, \"because we want to test the\" +\n \" error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.InternalMethod to be ProtectedInternal because we want to test the error message, but\" +\n \" it is Internal.\");\n }\n\n [Fact]\n public void When_asserting_a_protected_internal_member_is_protected_internal_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"ProtectedInternalMethod\");\n\n // Act / Assert\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_a_protected_internal_member_is_private_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"ProtectedInternalMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.Private, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.ProtectedInternalMethod to be Private because we want to test the error message, but it is \" +\n \"ProtectedInternal.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_access_modifier_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method to be Public *failure message*, but methodInfo is .\");\n }\n\n [Fact]\n public void When_asserting_method_has_access_modifier_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().HaveAccessModifier((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n\n public class NotHaveAccessModifier\n {\n [Fact]\n public void When_asserting_a_private_member_is_not_protected_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act / Assert\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_private_member_is_not_private_protected_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act / Assert\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.PrivateProtected);\n }\n\n [Fact]\n public void When_asserting_a_private_member_is_not_private_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Private, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method TestClass.PrivateMethod not to be Private*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_asserting_a_protected_member_is_not_internal_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"ProtectedSetProperty\");\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act / Assert\n setMethod.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void When_asserting_a_protected_member_is_not_protected_it_throws_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"ProtectedSetProperty\");\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act\n Action act = () =>\n setMethod\n .Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Protected, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.set_ProtectedSetProperty not to be Protected*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_not_private_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetProperty\");\n MethodInfo getMethod = propertyInfo.GetMethod;\n\n // Act / Assert\n getMethod.Should().NotHaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_private_protected_member_is_not_private_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetPrivateProtectedSet\");\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act / Assert\n setMethod.Should().NotHaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_not_public_it_throws_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetProperty\");\n MethodInfo getMethod = propertyInfo.GetMethod;\n\n // Act\n Action act = () =>\n getMethod\n .Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method TestClass.get_PublicGetProperty not to be Public*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_asserting_an_internal_member_is_not_protectedInternal_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"InternalMethod\");\n\n // Act / Assert\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_an_internal_member_is_not_internal_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"InternalMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal, \"because we want to test the\" +\n \" error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method TestClass.InternalMethod not to be Internal*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_asserting_a_protected_internal_member_is_not_public_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"ProtectedInternalMethod\");\n\n // Act / Assert\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_protected_internal_member_is_not_protected_internal_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"ProtectedInternalMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.ProtectedInternal, \"we want to test the error {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.ProtectedInternalMethod not to be ProtectedInternal*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_subject_is_not_null_have_access_modifier_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotHaveAccessModifier(\n CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method not to be Public *failure message*, but methodInfo is .\");\n }\n\n [Fact]\n public void When_asserting_method_does_not_have_access_modifier_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotHaveAccessModifier((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class TestClass\n{\n public void VoidMethod() { }\n\n public int IntMethod() { return 0; }\n\n private void PrivateMethod() { }\n\n public string PublicGetProperty { get; private set; }\n\n protected string ProtectedSetProperty { private get; set; }\n\n public string PublicGetPrivateProtectedSet { get; private protected set; }\n\n internal string InternalMethod() { return null; }\n\n protected internal void ProtectedInternalMethod() { }\n\n private protected void PrivateProtectedMethod() { }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedTheoryAttribute.cs", "using Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\n[XunitTestCaseDiscoverer(\"AwesomeAssertions.Specs.CultureAwareTesting.CulturedTheoryAttributeDiscoverer\",\n \"AwesomeAssertions.Specs\")]\npublic sealed class CulturedTheoryAttribute : TheoryAttribute\n{\n#pragma warning disable CA1019 // Define accessors for attribute arguments\n public CulturedTheoryAttribute(params string[] _) { }\n#pragma warning restore CA1019 // Define accessors for attribute arguments\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeCloseTo.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeCloseTo\n {\n [Fact]\n public void When_asserting_that_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().BeCloseTo(dateTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_later_datetimeoffset_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_an_earlier_datetimeoffset_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks + 1, TimeSpan.Zero);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_MinValue_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTimeOffset.MinValue;\n var actual = new DateTimeOffset(dateTime.Ticks + 1, TimeSpan.Zero);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_MaxValue_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTimeOffset.MaxValue;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_a_later_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 30, 980, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_an_earlier_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 31, 020, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_close_to_another_value_that_is_later_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 30, 979).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31 +1H>, but <2012-03-13 12:15:30.979 +1H> was off by 21ms.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 021).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31 +1h>, but <2012-03-13 12:15:31.021 +1h> was off by 21ms.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_close_to_another_value_that_is_earlier_by_more_than_a_35ms_timespan_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 036).WithOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).WithOffset(1.Hours());\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(35));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 35ms from <2012-03-13 12:15:31 +1h>, but <2012-03-13 12:15:31.036 +1h> was off by 36ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_an_earlier_datetimeoffset_by_35ms_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 035).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_is_close_to_another_it_should_throw()\n {\n // Arrange\n DateTimeOffset? time = null;\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(5.Hours());\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_the_maximum_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = DateTimeOffset.MaxValue - 50.Milliseconds();\n DateTimeOffset nearbyTime = DateTimeOffset.MaxValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_the_minimum_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = DateTimeOffset.MinValue + 50.Milliseconds();\n DateTimeOffset nearbyTime = DateTimeOffset.MinValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n }\n\n public class NotBeCloseTo\n {\n [Fact]\n public void When_asserting_that_time_is_not_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_later_datetimeoffset_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_an_earlier_datetimeoffset_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks + 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_MinValue_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTimeOffset.MinValue;\n var actual = new DateTimeOffset(dateTime.Ticks + 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_MaxValue_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTimeOffset.MaxValue;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_a_later_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 30, 980, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31 +0h>, but it was <2016-06-04 12:15:30.980 +0h>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_not_close_to_a_later_datetimeoffset_by_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 30, 980, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31 +0h>, but it was <2016-06-04 12:15:30.980 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_an_earlier_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 31, 020, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31 +0h>, but it was <2016-06-04 12:15:31.020 +0h>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_not_close_to_another_value_that_is_later_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 30, 979).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_not_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 021).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_an_earlier_datetimeoffset_by_35ms_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 035).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 35ms from <2012-03-13 12:15:31 +1h>, but it was <2012-03-13 12:15:31.035 +1h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_is_not_close_to_another_it_should_throw()\n {\n // Arrange\n DateTimeOffset? time = null;\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(5.Hours());\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*, but it was .\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_the_minimum_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = DateTimeOffset.MinValue + 50.Milliseconds();\n DateTimeOffset nearbyTime = DateTimeOffset.MinValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 100ms from <0001-01-01 00:00:00.000>, but it was <00:00:00.050 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_the_maximum_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = DateTimeOffset.MaxValue - 50.Milliseconds();\n DateTimeOffset nearbyTime = DateTimeOffset.MaxValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 100ms from <9999-12-31 23:59:59.9999999 +0h>, but it was <9999-12-31 23:59:59.9499999 +0h>.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.HaveSameCount.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class HaveSameCount\n {\n [Fact]\n public void When_asserting_collections_to_have_same_count_against_an_other_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = null;\n\n // Act\n Action act = () => collection.Should().HaveSameCount(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n\n [Fact]\n public void When_asserting_collections_to_have_same_count_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveSameCount(collection1,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have the same count as {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_both_collections_do_not_have_the_same_number_of_elements_it_should_fail()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"six\"];\n\n // Act\n Action act = () => firstCollection.Should().HaveSameCount(secondCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to have 2 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_both_collections_have_the_same_number_elements_it_should_succeed()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"five\", \"six\"];\n\n // Act / Assert\n firstCollection.Should().HaveSameCount(secondCollection);\n }\n\n [Fact]\n public void When_comparing_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"six\"];\n\n // Act\n Action act = () => firstCollection.Should().HaveSameCount(secondCollection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to have 2 item(s) because we want to test the reason, but found 3.\");\n }\n }\n\n public class NotHaveSameCount\n {\n [Fact]\n public void When_asserting_collections_to_not_have_same_count_against_an_other_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = null;\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n\n [Fact]\n public void When_asserting_collections_to_not_have_same_count_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(collection1,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to not have the same count as {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void\n When_asserting_collections_to_not_have_same_count_but_both_collections_references_the_same_object_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = collection;\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(otherCollection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not have the same count*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_not_same_count_and_both_collections_have_the_same_number_elements_it_should_fail()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"five\", \"six\"];\n\n // Act\n Action act = () => firstCollection.Should().NotHaveSameCount(secondCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to not have 3 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_asserting_not_same_count_and_collections_have_different_number_elements_it_should_succeed()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"six\"];\n\n // Act / Assert\n firstCollection.Should().NotHaveSameCount(secondCollection);\n }\n\n [Fact]\n public void When_comparing_not_same_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"five\", \"six\"];\n\n // Act\n Action act = () => firstCollection.Should().NotHaveSameCount(secondCollection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to not have 3 item(s) because we want to test the reason, but found 3.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedFactAttribute.cs", "using Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\n[XunitTestCaseDiscoverer(\"AwesomeAssertions.Specs.CultureAwareTesting.CulturedFactAttributeDiscoverer\", \"AwesomeAssertions.Specs\")]\npublic sealed class CulturedFactAttribute : FactAttribute\n{\n#pragma warning disable CA1019 // Define accessors for attribute arguments\n public CulturedFactAttribute(params string[] _) { }\n#pragma warning restore CA1019 // Define accessors for attribute arguments\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeAssignableTo.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeAssignableTo\n {\n [Fact]\n public void When_object_type_is_matched_against_null_type_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeAssignableTo(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"type\");\n }\n\n [Fact]\n public void When_its_own_type_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_its_base_type_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_an_implemented_interface_type_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_an_unrelated_type_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n Action act = () => someObject.Should().BeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to {typeof(DateTime)}*failure message*{typeof(DummyImplementingClass)} is not*\");\n }\n\n [Fact]\n public void When_to_the_expected_type_it_should_cast_the_returned_object_for_chaining()\n {\n // Arrange\n var someObject = new Exception(\"Actual Message\");\n\n // Act\n Action act = () => someObject.Should().BeAssignableTo().Which.Message.Should().Be(\"Other Message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Expected*Actual*Other*\");\n }\n\n [Fact]\n public void When_a_null_instance_is_asserted_to_be_assignableOfT_it_should_fail()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someObject.Should().BeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to {typeof(DateTime)}*failure message*found *\");\n }\n\n [Fact]\n public void When_its_own_type_instance_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo(typeof(DummyImplementingClass));\n }\n\n [Fact]\n public void When_its_base_type_instance_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo(typeof(DummyBaseClass));\n }\n\n [Fact]\n public void When_an_implemented_interface_type_instance_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo(typeof(IDisposable));\n }\n\n [Fact]\n public void When_an_implemented_open_generic_interface_type_instance_it_should_succeed()\n {\n // Arrange\n var someObject = new List();\n\n // Act / Assert\n someObject.Should().BeAssignableTo(typeof(IList<>));\n }\n\n [Fact]\n public void When_a_null_instance_is_asserted_to_be_assignable_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someObject.Should().BeAssignableTo(typeof(DateTime), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to {typeof(DateTime)}*failure message*found *\");\n }\n\n [Fact]\n public void When_an_unrelated_type_instance_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().BeAssignableTo(typeof(DateTime), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to {typeof(DateTime)}*failure message*{typeof(DummyImplementingClass)} is not*\");\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_type_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().BeAssignableTo(typeof(IList<>), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to System.Collections.Generic.IList*failure message*{typeof(DummyImplementingClass)} is not*\");\n }\n\n [Fact]\n public void When_an_assertion_fails_on_BeAssignableTo_succeeding_message_should_be_included()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var item = string.Empty;\n item.Should().BeAssignableTo();\n item.Should().BeAssignableTo();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * to be assignable to int, but string is not.*\" +\n \"Expected * to be assignable to long, but string is not.\");\n }\n }\n\n public class NotBeAssignableTo\n {\n [Fact]\n public void When_object_type_is_matched_negatively_against_null_type_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().NotBeAssignableTo(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"type\");\n }\n\n [Fact]\n public void When_its_own_type_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should()\n .NotBeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n $\"*not be assignable to {typeof(DummyImplementingClass)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void When_its_base_type_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n $\"*not be assignable to {typeof(DummyBaseClass)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void When_an_implemented_interface_type_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*not be assignable to {typeof(IDisposable)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void When_an_unrelated_type_and_asserting_not_assignable_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().NotBeAssignableTo();\n }\n\n [Fact]\n public void\n When_not_to_the_unexpected_type_and_asserting_not_assignable_it_should_not_cast_the_returned_object_for_chaining()\n {\n // Arrange\n var someObject = new Exception(\"Actual Message\");\n\n // Act\n Action act = () => someObject.Should().NotBeAssignableTo()\n .And.Subject.Should().BeOfType()\n .Which.Message.Should().Be(\"Other Message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Expected*Actual*Other*\");\n }\n\n [Fact]\n public void When_its_own_type_instance_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(typeof(DummyImplementingClass), \"because we want to test the failure {0}\",\n \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n $\"*not be assignable to {typeof(DummyImplementingClass)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void When_its_base_type_instance_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should()\n .NotBeAssignableTo(typeof(DummyBaseClass), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n $\"*not be assignable to {typeof(DummyBaseClass)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void\n When_an_implemented_interface_type_instance_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(typeof(IDisposable), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*not be assignable to {typeof(IDisposable)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void\n When_an_implemented_open_generic_interface_type_instance_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new List();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(typeof(IList<>), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\"*not be assignable to System.Collections.Generic.IList*failure message*System.Collections.Generic.List is*\");\n }\n\n [Fact]\n public void When_a_null_instance_is_asserted_to_not_be_assignable_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someObject.Should().NotBeAssignableTo(typeof(DateTime), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*not be assignable to {typeof(DateTime)}*failure message*found *\");\n }\n\n [Fact]\n public void When_an_unrelated_type_instance_and_asserting_not_assignable_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().NotBeAssignableTo(typeof(DateTime), \"because we want to test the failure {0}\", \"message\");\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_type_and_asserting_not_assignable_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().NotBeAssignableTo(typeof(IList<>), \"because we want to test the failure {0}\", \"message\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/MultiLineCommentParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class MultiLineCommentParsingStrategy : IParsingStrategy\n{\n private bool isCommentContext;\n private char? commentContextPreviousChar;\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (isCommentContext)\n {\n var isEndOfMultilineComment = symbol is '/' && commentContextPreviousChar is '*';\n\n if (isEndOfMultilineComment)\n {\n isCommentContext = false;\n commentContextPreviousChar = null;\n }\n else\n {\n commentContextPreviousChar = symbol;\n }\n\n return ParsingState.GoToNextSymbol;\n }\n\n var isStartOfMultilineComment = symbol is '*' && statement is [.., '/'];\n\n if (isStartOfMultilineComment)\n {\n statement.Remove(statement.Length - 1, 1);\n isCommentContext = true;\n return ParsingState.GoToNextSymbol;\n }\n\n return ParsingState.InProgress;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return isCommentContext;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.ContainKeys.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class ContainKeys\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_multiple_keys_from_the_dictionary()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().ContainKeys(2, 1);\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_a_list_of_keys_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainKeys([2, 3], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain keys {2, 3} because we do, but could not find {3}.\");\n }\n\n [Fact]\n public void Null_dictionaries_do_not_contain_any_keys()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().ContainKeys([2, 3], \"because {0}\", \"we do\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain keys {2, 3} because we do, but found .\");\n }\n\n [Fact]\n public void\n When_the_contents_of_a_dictionary_are_checked_against_an_empty_list_of_keys_it_should_throw_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainKeys();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify key containment against an empty sequence*\");\n }\n }\n\n public class NotContainKeys\n {\n [Fact]\n public void When_dictionary_does_not_contain_multiple_keys_from_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys(3, 4);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_dictionary_contains_a_list_of_keys_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys([2, 3], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to not contain keys {2, 3} because we do, but found {2}.\");\n }\n\n [Fact]\n public void When_a_dictionary_contains_exactly_one_of_the_keys_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys([2], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to not contain key 2 because we do.\");\n }\n\n [Fact]\n public void Null_dictionaries_do_not_contain_any_keys()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContainKeys([2], \"because {0}\", \"we do\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain keys {2} because we do, but found .\");\n }\n\n [Fact]\n public void\n When_the_noncontents_of_a_dictionary_are_checked_against_an_empty_list_of_keys_it_should_throw_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify key containment against an empty sequence*\");\n }\n\n [Fact]\n public void\n When_a_dictionary_checks_a_list_of_keys_not_to_be_present_it_will_honor_the_case_sensitive_equality_comparer_of_the_dictionary()\n {\n // Arrange\n var dictionary = new Dictionary(StringComparer.Ordinal)\n {\n [\"ONE\"] = \"One\",\n [\"TWO\"] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys(\"One\", \"Two\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void\n When_a_dictionary_checks_a_list_of_keys_not_to_be_present_it_will_honor_the_case_insensitive_equality_comparer_of_the_dictionary()\n {\n // Arrange\n var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase)\n {\n [\"ONE\"] = \"One\",\n [\"TWO\"] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys(\"One\", \"Two\");\n\n // Assert\n act.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveExplicitConversionOperator.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveExplicitConversionOperator specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveExplicitConversionOperator\n {\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operator_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(byte);\n\n // Act / Assert\n type.Should()\n .HaveExplicitConversionOperator(sourceType, targetType)\n .Which.Should()\n .NotBeNull();\n }\n\n [Fact]\n public void Can_chain_an_additional_assertion_on_the_implicit_conversion_operator()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(byte);\n\n // Act\n Action act = () => type\n .Should().HaveExplicitConversionOperator(sourceType, targetType)\n .Which.Should().HaveAccessModifier(CSharpAccessModifier.Private);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method explicit operator byte(TypeWithConversionOperators) to be Private, but it is Public.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operator_which_it_does_not_it_fails_with_a_useful_message()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(string);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(\n sourceType, targetType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_conversion_operator_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(\n typeof(TypeWithConversionOperators), typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operator_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(null, typeof(string));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"sourceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operator_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(typeof(TypeWithConversionOperators), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"targetType\");\n }\n }\n\n public class HaveExplicitConversionOperatorOfT\n {\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operatorOfT_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act / Assert\n type.Should()\n .HaveExplicitConversionOperator()\n .Which.Should()\n .NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operatorOfT_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_conversion_operatorOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but type is .\");\n }\n }\n\n public class NotHaveExplicitConversionOperator\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operator_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(string);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitConversionOperator(sourceType, targetType);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operator_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(byte);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(\n sourceType, targetType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit byte(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_conversion_operator_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(\n typeof(TypeWithConversionOperators), typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operator_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(null, typeof(string));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"sourceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operator_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(typeof(TypeWithConversionOperators), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"targetType\");\n }\n }\n\n public class NotHaveExplicitConversionOperatorOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operatorOfT_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitConversionOperator();\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operatorOfT_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit byte(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but it does.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/MaximumMatchingSolution.cs", "using System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// The class defines the solution (output) for the maximum matching problem.\n/// See documentation of for more details.\n/// \n/// The type of elements which must be matched with predicates.\ninternal class MaximumMatchingSolution\n{\n private readonly Dictionary, Element> elementsByMatchedPredicate;\n private readonly MaximumMatchingProblem problem;\n\n public MaximumMatchingSolution(\n MaximumMatchingProblem problem,\n Dictionary, Element> elementsByMatchedPredicate)\n {\n this.problem = problem;\n this.elementsByMatchedPredicate = elementsByMatchedPredicate;\n }\n\n public bool UnmatchedPredicatesExist => problem.Predicates.Count != elementsByMatchedPredicate.Count;\n\n public bool UnmatchedElementsExist => problem.Elements.Count != elementsByMatchedPredicate.Count;\n\n public List> GetUnmatchedPredicates()\n {\n return problem.Predicates.Except(elementsByMatchedPredicate.Keys).ToList();\n }\n\n public List> GetUnmatchedElements()\n {\n return problem.Elements.Except(elementsByMatchedPredicate.Values).ToList();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensions/FluentDateTimeExtensions.cs", "using System;\nusing System.Diagnostics;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Extensions;\n\n/// \n/// Extension methods on to allow for a more fluent way of specifying a .\n/// \n/// \n/// Instead of
\n///
\n/// new DateTime(2011, 3, 10)
\n///
\n/// you can write 3.March(2011)
\n///
\n/// Or even
\n///
\n/// 3.March(2011).At(09, 30)\n///
\n/// \n[DebuggerNonUserCode]\npublic static class FluentDateTimeExtensions\n{\n /// \n /// Returns a new value for the specified and \n /// in the month January.\n /// \n public static DateTime January(this int day, int year)\n {\n return new DateTime(year, 1, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month February.\n /// \n public static DateTime February(this int day, int year)\n {\n return new DateTime(year, 2, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month March.\n /// \n public static DateTime March(this int day, int year)\n {\n return new DateTime(year, 3, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month April.\n /// \n public static DateTime April(this int day, int year)\n {\n return new DateTime(year, 4, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month May.\n /// \n public static DateTime May(this int day, int year)\n {\n return new DateTime(year, 5, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month June.\n /// \n public static DateTime June(this int day, int year)\n {\n return new DateTime(year, 6, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month July.\n /// \n public static DateTime July(this int day, int year)\n {\n return new DateTime(year, 7, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month August.\n /// \n public static DateTime August(this int day, int year)\n {\n return new DateTime(year, 8, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month September.\n /// \n public static DateTime September(this int day, int year)\n {\n return new DateTime(year, 9, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month October.\n /// \n public static DateTime October(this int day, int year)\n {\n return new DateTime(year, 10, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month November.\n /// \n public static DateTime November(this int day, int year)\n {\n return new DateTime(year, 11, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month December.\n /// \n public static DateTime December(this int day, int year)\n {\n return new DateTime(year, 12, day);\n }\n\n /// \n /// Returns a new value for the specified and .\n /// \n public static DateTime At(this DateTime date, TimeSpan time)\n {\n return date.Date + time;\n }\n\n /// \n /// Returns a new value for the specified and time with the specified\n /// , and optionally .\n /// \n public static DateTime At(this DateTime date, int hours, int minutes, int seconds = 0, int milliseconds = 0,\n int microseconds = 0, int nanoseconds = 0)\n {\n if (microseconds is < 0 or > 999)\n {\n throw new ArgumentOutOfRangeException(nameof(microseconds), \"Valid values are between 0 and 999\");\n }\n\n if (nanoseconds is < 0 or > 999)\n {\n throw new ArgumentOutOfRangeException(nameof(nanoseconds), \"Valid values are between 0 and 999\");\n }\n\n var value = new DateTime(date.Year, date.Month, date.Day, hours, minutes, seconds, milliseconds, date.Kind);\n\n if (microseconds != 0)\n {\n value += microseconds.Microseconds();\n }\n\n if (nanoseconds != 0)\n {\n value += nanoseconds.Nanoseconds();\n }\n\n return value;\n }\n\n /// \n /// Returns a new value for the specified and time with the specified\n /// , and optionally .\n /// \n public static DateTimeOffset At(this DateTimeOffset date, int hours, int minutes, int seconds = 0, int milliseconds = 0,\n int microseconds = 0, int nanoseconds = 0)\n {\n if (microseconds is < 0 or > 999)\n {\n throw new ArgumentOutOfRangeException(nameof(microseconds), \"Valid values are between 0 and 999\");\n }\n\n if (nanoseconds is < 0 or > 999)\n {\n throw new ArgumentOutOfRangeException(nameof(nanoseconds), \"Valid values are between 0 and 999\");\n }\n\n var value = new DateTimeOffset(date.Year, date.Month, date.Day, hours, minutes, seconds, milliseconds, date.Offset);\n\n if (microseconds != 0)\n {\n value += microseconds.Microseconds();\n }\n\n if (nanoseconds != 0)\n {\n value += nanoseconds.Nanoseconds();\n }\n\n return value;\n }\n\n /// \n /// Returns a new value for the specified and time with\n /// the kind set to .\n /// \n public static DateTime AsUtc(this DateTime dateTime)\n {\n return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);\n }\n\n /// \n /// Returns a new value for the specified and time with\n /// the kind set to .\n /// \n public static DateTime AsLocal(this DateTime dateTime)\n {\n return DateTime.SpecifyKind(dateTime, DateTimeKind.Local);\n }\n\n /// \n /// Returns a new value that is the current before the\n /// specified .\n /// \n public static DateTime Before(this TimeSpan timeDifference, DateTime sourceDateTime)\n {\n return sourceDateTime - timeDifference;\n }\n\n /// \n /// Returns a new value that is the current after the\n /// specified .\n /// \n public static DateTime After(this TimeSpan timeDifference, DateTime sourceDateTime)\n {\n return sourceDateTime + timeDifference;\n }\n\n /// \n /// Gets the nanoseconds component of the date represented by the current structure.\n /// \n public static int Nanosecond(this DateTime self)\n {\n return self.Ticks.Ticks().Nanoseconds();\n }\n\n /// \n /// Gets the nanoseconds component of the date represented by the current structure.\n /// \n public static int Nanosecond(this DateTimeOffset self)\n {\n return self.Ticks.Ticks().Nanoseconds();\n }\n\n /// \n /// Returns a new that adds the specified number of nanoseconds to the value of this instance.\n /// \n public static DateTime AddNanoseconds(this DateTime self, long nanoseconds)\n {\n return self + nanoseconds.Nanoseconds();\n }\n\n /// \n /// Returns a new that adds the specified number of nanoseconds to the value of this instance.\n /// \n public static DateTimeOffset AddNanoseconds(this DateTimeOffset self, long nanoseconds)\n {\n return self + nanoseconds.Nanoseconds();\n }\n\n /// \n /// Gets the microseconds component of the date represented by the current structure.\n /// \n public static int Microsecond(this DateTime self)\n {\n return self.Ticks.Ticks().Microseconds();\n }\n\n /// \n /// Gets the microseconds component of the date represented by the current structure.\n /// \n public static int Microsecond(this DateTimeOffset self)\n {\n return self.Ticks.Ticks().Microseconds();\n }\n\n /// \n /// Returns a new that adds the specified number of microseconds to the value of this instance.\n /// \n public static DateTime AddMicroseconds(this DateTime self, long microseconds)\n {\n return self + microseconds.Microseconds();\n }\n\n /// \n /// Returns a new that adds the specified number of microseconds to the value of this instance.\n /// \n public static DateTimeOffset AddMicroseconds(this DateTimeOffset self, long microseconds)\n {\n return self + microseconds.Microseconds();\n }\n\n /// \n /// Returns new that uses \n /// as its datetime and as its offset.\n /// \n public static DateTimeOffset WithOffset(this DateTime self, TimeSpan offset)\n {\n return self.ToDateTimeOffset(offset);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.StartWith.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]StartWith specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class StartWith\n {\n [Fact]\n public void When_asserting_string_starts_with_the_same_value_it_should_not_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().StartWith(\"AB\");\n }\n\n [Fact]\n public void When_expected_string_is_the_same_value_it_should_not_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().StartWith(value);\n }\n\n [Fact]\n public void When_string_does_not_start_with_expected_phrase_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWith(\"ABB\", \"it should {0}\", \"start\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with \\\"ABB\\\" because it should start,\" +\n \" but \\\"ABC\\\" differs near \\\"C\\\" (index 2).\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void\n When_string_does_not_start_with_expected_phrase_and_one_of_them_is_long_it_should_display_both_strings_on_separate_line()\n {\n // Act\n Action act = () => \"ABCDEFGHI\".Should().StartWith(\"ABCDDFGHI\", \"it should {0}\", \"start\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with \" +\n \"*\\\"ABCDDFGHI\\\" because it should start, but \" +\n \"*\\\"ABCDEFGHI\\\" differs near \\\"EFG\\\" (index 4).\");\n }\n\n [Fact]\n public void When_string_start_is_compared_with_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWith(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare start of string with .*\");\n }\n\n [Fact]\n public void When_string_start_is_compared_with_empty_string_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().StartWith(\"\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_start_is_compared_with_string_that_is_longer_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWith(\"ABCDEF\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with \\\"ABCDEF\\\", but \\\"ABC\\\" is too short.\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void Correctly_stop_further_execution_when_inside_assertion_scope()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n \"ABC\".Should().StartWith(\"ABCDEF\").And.StartWith(\"FEDCBA\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*\\\"ABCDEF\\\"*\");\n }\n\n [Fact]\n public void When_string_start_is_compared_and_actual_value_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().StartWith(\"ABC\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someString to start with \\\"ABC\\\", but found .\");\n }\n }\n\n public class NotStartWith\n {\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_and_it_does_not_it_should_succeed()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().NotStartWith(\"DE\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_but_it_does_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWith(\"AB\", \"because of some reason\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to start with \\\"AB\\\" because of some reason, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_that_is_null_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWith(null);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Cannot compare start of string with .*\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_that_is_empty_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWith(\"\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to start with \\\"\\\", but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_and_actual_value_is_null_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().NotStartWith(\"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to start with \\\"ABC\\\", but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Streams/BufferedStreamAssertionSpecs.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing System.IO;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Streams;\n\npublic class BufferedStreamAssertionSpecs\n{\n public class HaveBufferSize\n {\n [Fact]\n public void When_a_stream_has_the_expected_buffer_size_it_should_succeed()\n {\n // Arrange\n using var stream = new BufferedStream(new MemoryStream(), 10);\n\n // Act / Assert\n stream.Should().HaveBufferSize(10);\n }\n\n [Fact]\n public void When_a_stream_has_an_unexpected_buffer_size_should_fail()\n {\n // Arrange\n using var stream = new BufferedStream(new MemoryStream(), 1);\n\n // Act\n Action act = () =>\n stream.Should().HaveBufferSize(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the buffer size of stream to be 10 *failure message*, but it was 1.\");\n }\n\n [Fact]\n public void When_null_have_buffer_size_should_fail()\n {\n // Arrange\n BufferedStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().HaveBufferSize(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the buffer size of stream to be 10 *failure message*, but found a reference.\");\n }\n }\n\n public class NotHaveBufferSize\n {\n [Fact]\n public void When_a_stream_does_not_have_an_unexpected_buffer_size_it_should_succeed()\n {\n // Arrange\n using var stream = new BufferedStream(new MemoryStream(), 1);\n\n // Act / Assert\n stream.Should().NotHaveBufferSize(10);\n }\n\n [Fact]\n public void When_a_stream_does_have_the_unexpected_buffer_size_it_should_fail()\n {\n // Arrange\n using var stream = new BufferedStream(new MemoryStream(), 10);\n\n // Act\n Action act = () =>\n stream.Should().NotHaveBufferSize(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the buffer size of stream not to be 10 *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_have_buffer_size_should_fail()\n {\n // Arrange\n BufferedStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotHaveBufferSize(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the buffer size of stream not to be 10 *failure message*, but found a reference.\");\n }\n }\n}\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.Be.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void A_value_is_equal_to_the_same_value()\n {\n // Arrange\n int value = 1;\n int sameValue = 1;\n\n // Act\n value.Should().Be(sameValue);\n }\n\n [Fact]\n public void A_value_is_not_equal_to_another_value()\n {\n // Arrange\n int value = 1;\n int differentValue = 2;\n\n // Act\n Action act = () => value.Should().Be(differentValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 2 because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void A_value_is_equal_to_the_same_nullable_value()\n {\n // Arrange\n int value = 2;\n int? nullableValue = 2;\n\n // Act\n value.Should().Be(nullableValue);\n }\n\n [Fact]\n public void A_value_is_not_equal_to_null()\n {\n // Arrange\n int value = 2;\n int? nullableValue = null;\n\n // Act\n Action act = () => value.Should().Be(nullableValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*, but found 2.\");\n }\n\n [Fact]\n public void Null_is_not_equal_to_another_nullable_value()\n {\n // Arrange\n int? value = 2;\n\n // Act\n Action action = () => ((int?)null).Should().Be(value);\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Expected*2, but found .\");\n }\n\n [InlineData(0, 0)]\n [InlineData(null, null)]\n [Theory]\n public void A_nullable_value_is_equal_to_the_same_nullable_value(int? subject, int? expected)\n {\n // Act / Assert\n subject.Should().Be(expected);\n }\n\n [InlineData(0, 1)]\n [InlineData(0, null)]\n [InlineData(null, 0)]\n [Theory]\n public void A_nullable_value_is_not_equal_to_another_nullable_value(int? subject, int? expected)\n {\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Null_is_not_equal_to_another_value()\n {\n // Arrange\n int? subject = null;\n int expected = 1;\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_that_a_float_value_is_equal_to_a_different_value_it_should_throw()\n {\n // Arrange\n float value = 3.5F;\n\n // Act\n Action act = () => value.Should().Be(3.4F, \"we want to test the error message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be *3.4* because we want to test the error message, but found *3.5*\");\n }\n\n [Fact]\n public void When_asserting_that_a_float_value_is_equal_to_the_same_value_it_should_not_throw()\n {\n // Arrange\n float value = 3.5F;\n\n // Act / Assert\n value.Should().Be(3.5F);\n }\n\n [Fact]\n public void When_asserting_that_a_null_float_value_is_equal_to_some_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n\n // Act\n Action act = () => value.Should().Be(3.5F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be *3.5* but found .\");\n }\n\n [Fact]\n public void When_asserting_that_a_double_value_is_equal_to_a_different_value_it_should_throw()\n {\n // Arrange\n double value = 3.5;\n\n // Act\n Action act = () => value.Should().Be(3.4, \"we want to test the error message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 3.4 because we want to test the error message, but found 3.5*.\");\n }\n\n [Fact]\n public void When_asserting_that_a_double_value_is_equal_to_the_same_value_it_should_not_throw()\n {\n // Arrange\n double value = 3.5;\n\n // Act / Assert\n value.Should().Be(3.5);\n }\n\n [Fact]\n public void When_asserting_that_a_null_double_value_is_equal_to_some_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n\n // Act\n Action act = () => value.Should().Be(3.5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 3.5, but found .\");\n }\n\n [Fact]\n public void When_asserting_that_a_decimal_value_is_equal_to_a_different_value_it_should_throw()\n {\n // Arrange\n decimal value = 3.5m;\n\n // Act\n Action act = () => value.Should().Be(3.4m, \"we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected value to be*3.4* because we want to test the error message, but found*3.5*\");\n }\n\n [Fact]\n public void When_asserting_that_a_decimal_value_is_equal_to_the_same_value_it_should_not_throw()\n {\n // Arrange\n decimal value = 3.5m;\n\n // Act / Assert\n value.Should().Be(3.5m);\n }\n\n [Fact]\n public void When_asserting_that_a_null_decimal_value_is_equal_to_some_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n decimal someValue = 3.5m;\n\n // Act\n Action act = () => value.Should().Be(someValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be*3.5*, but found .\");\n }\n\n [Fact]\n public void Nan_is_never_equal_to_a_normal_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().Be(3.4F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be *3.4F, but found NaN*\");\n }\n\n [Fact]\n public void NaN_can_be_compared_to_NaN_when_its_a_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n value.Should().Be(float.NaN);\n }\n\n [Fact]\n public void Nan_is_never_equal_to_a_normal_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().Be(3.4D);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be *3.4, but found NaN*\");\n }\n\n [Fact]\n public void NaN_can_be_compared_to_NaN_when_its_a_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n value.Should().Be(double.NaN);\n }\n }\n\n public class NotBe\n {\n [InlineData(1, 2)]\n [InlineData(null, 2)]\n [Theory]\n public void A_nullable_value_is_not_equal_to_another_value(int? subject, int unexpected)\n {\n // Act\n subject.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void A_value_is_not_different_from_the_same_value()\n {\n // Arrange\n int value = 1;\n int sameValue = 1;\n\n // Act\n Action act = () => value.Should().NotBe(sameValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Did not expect value to be 1 because we want to test the failure message.\");\n }\n\n [InlineData(null, null)]\n [InlineData(0, 0)]\n [Theory]\n public void A_nullable_value_is_not_different_from_the_same_value(int? subject, int? unexpected)\n {\n // Act\n Action act = () => subject.Should().NotBe(unexpected);\n\n // Assert\n act.Should().Throw();\n }\n\n [InlineData(0, 1)]\n [InlineData(0, null)]\n [InlineData(null, 0)]\n [Theory]\n public void A_nullable_value_is_different_from_another_value(int? subject, int? unexpected)\n {\n // Act / Assert\n subject.Should().NotBe(unexpected);\n }\n }\n\n public class Bytes\n {\n [Fact]\n public void When_asserting_a_byte_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n byte value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_sbyte_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n sbyte value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_short_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n short value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_an_ushort_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n ushort value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_an_uint_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n uint value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_long_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n long value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_an_ulong_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n ulong value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n }\n\n public class NullableBytes\n {\n [Fact]\n public void When_asserting_a_nullable_byte_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n byte? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_sbyte_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n sbyte? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_short_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n short? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_ushort_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n ushort? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_uint_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n uint? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_long_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n long? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_nullable_ulong_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n ulong? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/TestFrameworkFactorySpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\nusing TestFramework = AwesomeAssertions.Configuration.TestFramework;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\npublic class TestFrameworkFactorySpecs\n{\n [Fact]\n public void When_running_xunit_test_implicitly_it_should_be_detected()\n {\n // Arrange\n var testFramework = TestFrameworkFactory.GetFramework(null);\n\n // Act\n Action act = () => testFramework.Throw(\"MyMessage\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_running_xunit_test_explicitly_it_should_be_detected()\n {\n // Arrange\n var testFramework = TestFrameworkFactory.GetFramework(TestFramework.XUnit2);\n\n // Act\n Action act = () => testFramework.Throw(\"MyMessage\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_running_test_with_unknown_test_framework_it_should_throw()\n {\n // Act\n Action act = () => TestFrameworkFactory.GetFramework((TestFramework)42);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*the test framework '42' but this is not supported*\");\n }\n\n [Fact]\n public void When_running_test_with_late_bound_but_unavailable_test_framework_it_should_throw()\n {\n // Act\n Action act = () => TestFrameworkFactory.GetFramework(TestFramework.NUnit);\n\n act.Should().Throw()\n .WithMessage(\"*test framework 'nunit' but the required assembly 'nunit.framework' could not be found*\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/AddNonEmptySymbolParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class AddNonEmptySymbolParsingStrategy : IParsingStrategy\n{\n private Mode mode = Mode.RemoveAllWhitespace;\n private char? precedingSymbol;\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (!char.IsWhiteSpace(symbol))\n {\n statement.Append(symbol);\n mode = Mode.RemoveSuperfluousWhitespace;\n }\n else if (mode is Mode.RemoveSuperfluousWhitespace)\n {\n if (precedingSymbol is { } value && !char.IsWhiteSpace(value))\n {\n statement.Append(symbol);\n }\n }\n else\n {\n // skip the rest\n }\n\n precedingSymbol = symbol;\n\n return ParsingState.GoToNextSymbol;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return false;\n }\n\n public void NotifyEndOfLineReached()\n {\n // Assume all new lines start with whitespace\n mode = Mode.RemoveAllWhitespace;\n }\n\n private enum Mode\n {\n /// \n /// Remove all whitespace until we find a non-whitespace character\n /// \n RemoveAllWhitespace,\n\n /// \n /// Only keep one whitespace character if more than one follow each other.\n /// \n RemoveSuperfluousWhitespace,\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveImplicitConversionOperator.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveImplicitConversionOperator specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveImplicitConversionOperator\n {\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operator_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(int);\n\n // Act / Assert\n type.Should()\n .HaveImplicitConversionOperator(sourceType, targetType)\n .Which.Should()\n .NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operator_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(string);\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(\n sourceType, targetType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_implicit_conversion_operator_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(\n typeof(TypeWithConversionOperators), typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operator_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(null, typeof(string));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"sourceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operator_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(typeof(TypeWithConversionOperators), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"targetType\");\n }\n }\n\n public class HaveImplicitConversionOperatorOfT\n {\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operatorOfT_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act / Assert\n type.Should()\n .HaveImplicitConversionOperator()\n .Which.Should()\n .NotBeNull();\n }\n\n [Fact]\n public void Can_chain_an_additional_assertion_on_the_implicit_conversion_operator()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveImplicitConversionOperator()\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.Internal);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method implicit operator int(TypeWithConversionOperators) to be Internal, but it is Public.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operatorOfT_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_implicit_conversion_operatorOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but type is .\");\n }\n }\n\n public class NotHaveImplicitConversionOperator\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operator_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(string);\n\n // Act / Assert\n type.Should()\n .NotHaveImplicitConversionOperator(sourceType, targetType);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operator_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(int);\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(\n sourceType, targetType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit int(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_implicit_conversion_operator_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(\n typeof(TypeWithConversionOperators), typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operator_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(null, typeof(string));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"sourceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operator_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(typeof(TypeWithConversionOperators), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"targetType\");\n }\n }\n\n public class NotHaveImplicitConversionOperatorOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operatorOfT_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act / Assert\n type.Should()\n .NotHaveImplicitConversionOperator();\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operatorOfT_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit int(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_implicit_conversion_operatorOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but type is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AggregateExceptionExtractor.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Specialized;\n\nnamespace AwesomeAssertions;\n\npublic class AggregateExceptionExtractor : IExtractExceptions\n{\n public IEnumerable OfType(Exception actualException)\n where T : Exception\n {\n if (typeof(T).IsSameOrInherits(typeof(AggregateException)))\n {\n return actualException is T exception ? [exception] : [];\n }\n\n return GetExtractedExceptions(actualException);\n }\n\n private static List GetExtractedExceptions(Exception actualException)\n where T : Exception\n {\n var exceptions = new List();\n\n if (actualException is AggregateException aggregateException)\n {\n AggregateException flattenedExceptions = aggregateException.Flatten();\n\n exceptions.AddRange(flattenedExceptions.InnerExceptions.OfType());\n }\n else if (actualException is T genericException)\n {\n exceptions.Add(genericException);\n }\n\n return exceptions;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/SingleLineCommentParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class SingleLineCommentParsingStrategy : IParsingStrategy\n{\n private bool isCommentContext;\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (isCommentContext)\n {\n return ParsingState.GoToNextSymbol;\n }\n\n var doesSymbolStartComment = symbol is '/' && statement is [.., '/'];\n\n if (!doesSymbolStartComment)\n {\n return ParsingState.InProgress;\n }\n\n isCommentContext = true;\n statement.Remove(statement.Length - 1, 1);\n return ParsingState.GoToNextSymbol;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return isCommentContext;\n }\n\n public void NotifyEndOfLineReached()\n {\n if (isCommentContext)\n {\n isCommentContext = false;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.ContainInOrder.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class ContainInOrder\n {\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"one\", \"three\", \"twelve\", \"two\", \"two\"];\n\n // Act\n Action act = () => collection.Should().ContainInOrder(\"one\", \"two\", \"one\", \"one\", \"two\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"one\\\", \\\"three\\\", \\\"twelve\\\", \\\"two\\\", \\\"two\\\"} to contain items {\\\"one\\\", \\\"two\\\", \\\"one\\\", \\\"one\\\", \\\"two\\\"} in order, but \\\"one\\\" (index 3) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { \"one\", \"two\", \"three\" }.Should().ContainInOrder([\"four\", \"one\"], \"we failed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to contain items {\\\"four\\\", \\\"one\\\"} in order because we failed, \" +\n \"but \\\"four\\\" (index 0) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable strings = null;\n\n // Act\n Action act =\n () => strings.Should()\n .ContainInOrder([\"string4\"], \"because we're checking how it reacts to a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings to contain {\\\"string4\\\"} in order because we're checking how it reacts to a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_contains_null_value_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", null, \"two\", \"string\"];\n\n // Act / Assert\n collection.Should().ContainInOrder(\"one\", null, \"string\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_ordered_containment_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { \"one\", \"two\", \"three\" }.Should().ContainInOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify ordered containment against a collection.*\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\", \"two\"];\n\n // Act / Assert\n collection.Should().ContainInOrder(\"one\", \"two\", \"three\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"one\", \"two\", \"twelve\", \"two\", \"two\"];\n\n // Act / Assert\n collection.Should().ContainInOrder(\"one\", \"two\", \"one\", \"two\", \"twelve\", \"two\", \"two\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () =>\n new[] { \"one\", \"two\", \"three\" }.Should().ContainInOrder([\"three\", \"one\"], \"because we said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to contain items {\\\"three\\\", \\\"one\\\"} in order because we said so, but \\\"one\\\" (index 1) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_in_the_same_order_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().ContainInOrder(\"one\", \"two\", \"three\");\n }\n }\n\n public class NotContainInOrder\n {\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotContainInOrder(\"two\", \"one\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotContainInOrder(\"four\", \"one\");\n }\n\n [Fact]\n public void When_a_collection_contains_less_items_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\"];\n\n // Act / Assert\n collection.Should().NotContainInOrder(\"one\", \"two\", \"three\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"one\", \"three\", \"twelve\", \"two\", \"two\"];\n\n // Act / Assert\n collection.Should().NotContainInOrder(\"one\", \"two\", \"one\", \"one\", \"two\");\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(\"four\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder([\"one\", \"two\", \"three\"], \"that's what we expect\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"two\\\", \\\"three\\\"} to not contain items {\\\"one\\\", \\\"two\\\", \\\"three\\\"} \" +\n \"in order because that's what we expect, but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_collection_contains_contain_the_same_items_in_the_same_order_with_null_value_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", null, \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(\"one\", null, \"three\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", , \\\"two\\\", \\\"three\\\"} to not contain items {\\\"one\\\", , \\\"three\\\"} in order, \" +\n \"but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\", \"two\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(\"one\", \"two\", \"three\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\", \\\"two\\\"} to not contain items {\\\"one\\\", \\\"two\\\", \\\"three\\\"} in order, \" +\n \"but items appeared in order ending at index 2.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"one\", \"twelve\", \"two\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(\"one\", \"two\", \"one\", \"twelve\", \"two\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"one\\\", \\\"twelve\\\", \\\"two\\\"} to not contain items \" +\n \"{\\\"one\\\", \\\"two\\\", \\\"one\\\", \\\"twelve\\\", \\\"two\\\"} in order, but items appeared in order ending at index 4.\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_absence_of_ordered_containment_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment against a collection.*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ValueFormatterAttribute.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Marks a static method as a kind of for a particular type.\n/// \n[AttributeUsage(AttributeTargets.Method)]\n#pragma warning disable CA1813 // Avoid unsealed attributes. This type has shipped.\npublic class ValueFormatterAttribute : Attribute;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/DefaultAssertionStrategy.cs", "using System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Execution;\n\n[ExcludeFromCodeCoverage]\ninternal class DefaultAssertionStrategy : IAssertionStrategy\n{\n /// \n /// Returns the messages for the assertion failures that happened until now.\n /// \n public IEnumerable FailureMessages => [];\n\n /// \n /// Instructs the strategy to handle a assertion failure.\n /// \n public void HandleFailure(string message)\n {\n AssertionEngine.TestFramework.Throw(message);\n }\n\n /// \n /// Discards and returns the failure messages that happened up to now.\n /// \n public IEnumerable DiscardFailures() => [];\n\n /// \n /// Will throw a combined exception for any failures have been collected.\n /// \n public void ThrowIfAny(IDictionary context)\n {\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/FailReason.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// Represents the assertion fail reason. Contains the message and arguments for message's numbered placeholders.\n/// \n/// \n/// In addition to the numbered -style placeholders, messages may contain a\n/// few specialized placeholders as well. For instance, {reason} will be replaced with the reason of the\n/// assertion as passed to .\n/// \n/// Other named placeholders will be replaced with the scope data passed through\n/// .\n/// \n/// \n/// Finally, a description of the current subject can be passed through the {context:description} placeholder.\n/// This is used in the message if no explicit context is specified through the constructor.\n/// \n/// \n/// Note that only 10 args are supported in combination with a {reason}.\n/// \n/// \npublic class FailReason\n{\n /// \n /// Initializes a new instance of the class.\n /// \n /// \n /// \n /// \n public FailReason(string message, params object[] args)\n {\n Message = message;\n Args = args;\n }\n\n /// \n /// Message to be displayed in case of failed assertion. May contain numbered\n /// -style placeholders as well as specialized placeholders.\n /// \n public string Message { get; }\n\n /// \n /// Arguments for the numbered -style placeholders of .\n /// \n public object[] Args { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.MatchEquivalentOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]MatchEquivalentOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class MatchEquivalentOf\n {\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_match_another()\n {\n // Arrange\n string actual = \"test\";\n string expect = \"T*T\";\n\n // Act / Assert\n actual.Should().MatchEquivalentOf(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_match_another()\n {\n // Arrange\n string actual = \" test\";\n string expect = \"t*t\";\n\n // Act / Assert\n actual.Should().MatchEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_match_another()\n {\n // Arrange\n string actual = \"test \";\n string expect = \"t*t\";\n\n // Act / Assert\n actual.Should().MatchEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_match_another()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n\";\n string expect = \"\\nA\\r\\n?\\nC\\r\";\n\n // Act / Assert\n actual.Should().MatchEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n }\n\n [Fact]\n public void When_a_string_does_not_match_the_equivalent_of_a_wildcard_pattern_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchEquivalentOf(\"h*earth!\", \"that's the universal greeting\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to match the equivalent of*\\\"h*earth!\\\" \" +\n \"because that's the universal greeting, but*\\\"hello world!\\\" does not.\");\n }\n\n [Fact]\n public void When_a_string_does_match_the_equivalent_of_a_wildcard_pattern_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n subject.Should().MatchEquivalentOf(\"h*WORLD?\");\n }\n\n [Fact]\n public void When_a_string_with_newline_matches_the_equivalent_of_a_wildcard_pattern_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello\\r\\nworld!\";\n\n // Act / Assert\n subject.Should().MatchEquivalentOf(\"helloworld!\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_the_equivalent_of_null_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().MatchEquivalentOf(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a wildcard pattern or use the BeNull method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_the_equivalent_of_an_empty_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().MatchEquivalentOf(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n }\n\n public class NotMatchEquivalentOf\n {\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_not_match_another()\n {\n // Arrange\n string actual = \"test\";\n string expect = \"T*T\";\n\n // Act\n Action act = () => actual.Should().NotMatchEquivalentOf(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_not_match_another()\n {\n // Arrange\n string actual = \" test\";\n string expect = \"t*t\";\n\n // Act\n Action act = () => actual.Should().NotMatchEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_not_match_another()\n {\n // Arrange\n string actual = \"test \";\n string expect = \"t*t\";\n\n // Act\n Action act = () => actual.Should().NotMatchEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_not_match_another()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n\";\n string expect = \"\\nA\\r\\n?\\nC\\r\";\n\n // Act\n Action act = () => actual.Should().NotMatchEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_string_is_not_equivalent_to_a_pattern_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n string subject = \"Hello Earth\";\n\n // Act / Assert\n subject.Should().NotMatchEquivalentOf(\"*World*\");\n }\n\n [Fact]\n public void When_a_string_does_match_the_equivalent_of_a_pattern_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello WORLD\";\n\n // Act\n Action act = () => subject.Should().NotMatchEquivalentOf(\"*world*\", \"because that's illegal\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Did not expect subject to match the equivalent of*\\\"*world*\\\" because that's illegal, \" +\n \"but*\\\"hello WORLD\\\" matches.\");\n }\n\n [Fact]\n public void When_a_string_with_newlines_does_match_the_equivalent_of_a_pattern_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello\\r\\nworld!\";\n\n // Act\n Action act = () => subject.Should().NotMatchEquivalentOf(\"helloworld!\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_a_string_is_negatively_matched_against_the_equivalent_of_null_pattern_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatchEquivalentOf(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void\n When_a_string_is_negatively_matched_against_the_equivalent_of_an_empty_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatchEquivalentOf(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void Does_not_treat_escaped_newlines_as_newlines()\n {\n // Arrange\n string actual = \"te\\r\\nst\";\n string expect = \"te\\\\r\\\\nst\";\n\n // Act / Assert\n actual.Should().NotMatchEquivalentOf(expect);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.BeCloseTo.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class BeCloseTo\n {\n [Fact]\n public void When_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().BeCloseTo(time, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_time_is_close_to_a_later_time_by_one_tick_it_should_succeed()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(time, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_time_is_close_to_an_earlier_time_by_one_tick_it_should_succeed()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks + 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(time, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_subject_time_is_close_to_the_minimum_time_it_should_succeed()\n {\n // Arrange\n TimeOnly time = TimeOnly.MinValue.Add(50.Milliseconds());\n TimeOnly nearbyTime = TimeOnly.MinValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n\n [Fact]\n public void When_subject_time_is_close_to_the_maximum_time_it_should_succeed()\n {\n // Arrange\n TimeOnly time = TimeOnly.MaxValue.Add(-50.Milliseconds());\n TimeOnly nearbyTime = TimeOnly.MaxValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n\n [Fact]\n public void When_subject_time_is_close_to_another_value_that_is_later_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 30, 979);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <12:15:31.000>, but <12:15:30.979> was off by 21ms.\");\n }\n\n [Fact]\n public void When_subject_time_is_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 021);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <12:15:31.000>, but <12:15:31.021> was off by 21ms.\");\n }\n\n [Fact]\n public void When_subject_time_is_close_to_an_earlier_time_by_35ms_it_should_succeed()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 035);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n }\n\n [Fact]\n public void A_time_is_close_to_a_later_time_when_passing_midnight()\n {\n // Arrange\n TimeOnly time = new(23, 59, 0);\n TimeOnly nearbyTime = new(0, 1, 0);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 2.Minutes());\n }\n\n [Fact]\n public void A_time_is_close_to_an_earlier_time_when_passing_midnight()\n {\n // Arrange\n TimeOnly time = new(0, 1, 0);\n TimeOnly nearbyTime = new(23, 59, 0);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 2.Minutes());\n }\n\n [Fact]\n public void A_time_outside_of_the_precision_to_a_later_time_when_passing_midnight_fails()\n {\n // Arrange\n TimeOnly time = new(23, 58, 59);\n TimeOnly nearbyTime = new(0, 1, 0);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 2.Minutes());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to be within 2m from <00:01:00.000>*, but <23:58:59.000> was off by 2m and 1s*\");\n }\n\n [Fact]\n public void A_time_outside_of_the_precision_to_an_earlier_time_when_passing_midnight_fails()\n {\n // Arrange\n TimeOnly time = new(0, 1, 0);\n TimeOnly nearbyTime = new(23, 58, 59);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 2.Minutes());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to be within 2m from <23:58:59.000>*, but <00:01:00.000> was off by 2m and 1s*\");\n }\n\n [Fact]\n public void When_subject_nulltime_is_close_to_another_it_should_throw()\n {\n // Arrange\n TimeOnly? time = null;\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n [Fact]\n public void A_null_time_inside_an_assertion_scope_fails()\n {\n // Arrange\n TimeOnly? time = null;\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n }\n\n public class NotBeCloseTo\n {\n [Fact]\n public void A_null_time_is_never_unclose_to_an_other_time()\n {\n // Arrange\n TimeOnly? time = null;\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*, but found .\");\n }\n\n [Fact]\n public void A_null_time_inside_an_assertion_scope_is_never_unclose_to_an_other_time()\n {\n // Arrange\n TimeOnly? time = null;\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*, but found .\");\n }\n\n [Fact]\n public void When_time_is_not_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_time_is_close_to_a_later_time_by_one_tick_it_should_fail()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_time_is_close_to_an_earlier_time_by_one_tick_it_should_fail()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks + 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_time_is_close_to_a_min_value_by_one_tick_it_should_fail()\n {\n // Arrange\n var time = TimeOnly.MinValue;\n var actual = new TimeOnly(time.Ticks + 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_time_is_close_to_a_max_value_by_one_tick_it_should_fail()\n {\n // Arrange\n var time = TimeOnly.MaxValue;\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 020);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 20ms from <12:15:31.000>, but it was <12:15:31.020>.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_by_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 020);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 20ms from <12:15:31.000>, but it was <12:15:31.020>.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_another_value_that_is_later_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n TimeOnly time = new(12, 15, 30, 979);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void\n When_asserting_subject_time_is_not_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 021);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_an_earlier_datetime_by_35ms_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 035);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 35ms from <12:15:31.000>, but it was <12:15:31.035>.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_the_minimum_time_it_should_throw()\n {\n // Arrange\n TimeOnly time = TimeOnly.MinValue.Add(50.Milliseconds());\n TimeOnly nearbyTime = TimeOnly.MinValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 100ms from <00:00:00.000>, but it was <00:00:00.050>.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_the_maximum_time_it_should_throw()\n {\n // Arrange\n TimeOnly time = TimeOnly.MaxValue.Add(-50.Milliseconds());\n TimeOnly nearbyTime = TimeOnly.MaxValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 100ms from <23:59:59.999>, but it was <23:59:59.949>.\");\n }\n\n [Fact]\n public void A_time_is_not_close_to_a_later_time_when_passing_midnight()\n {\n // Arrange\n TimeOnly time = new(23, 58, 0);\n TimeOnly nearbyTime = new(0, 1, 0);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 2.Minutes());\n }\n\n [Fact]\n public void A_time_is_not_close_to_an_earlier_time_when_passing_midnight()\n {\n // Arrange\n TimeOnly time = new(0, 2, 0);\n TimeOnly nearbyTime = new(23, 59, 0);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 2.Minutes());\n }\n\n [Fact]\n public void A_time_inside_of_the_precision_to_a_later_time_when_passing_midnight_fails()\n {\n // Arrange\n TimeOnly time = new(23, 59, 0);\n TimeOnly nearbyTime = new(0, 1, 0);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 2.Minutes());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect * to be within 2m from <00:01:00.000>*, but it was <23:59:00.000>*\");\n }\n\n [Fact]\n public void A_time_inside_of_the_precision_to_an_earlier_time_when_passing_midnight_fails()\n {\n // Arrange\n TimeOnly time = new(0, 1, 0);\n TimeOnly nearbyTime = new(23, 59, 0);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 2.Minutes());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect * to be within 2m from <23:59:00.000>*, but it was <00:01:00.000>*\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/FilteredEventRecording.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Events;\n\ninternal class FilteredEventRecording : IEventRecording\n{\n private readonly OccurredEvent[] occurredEvents;\n\n public FilteredEventRecording(IEventRecording eventRecorder, IEnumerable events)\n {\n EventObject = eventRecorder.EventObject;\n EventName = eventRecorder.EventName;\n EventHandlerType = eventRecorder.EventHandlerType;\n\n occurredEvents = events.ToArray();\n }\n\n public object EventObject { get; }\n\n public string EventName { get; }\n\n public Type EventHandlerType { get; }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public IEnumerator GetEnumerator()\n {\n foreach (var occurredEvent in occurredEvents)\n {\n yield return new OccurredEvent\n {\n EventName = EventName,\n Parameters = occurredEvent.Parameters,\n TimestampUtc = occurredEvent.TimestampUtc\n };\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeOneOf.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n\n // Act\n Action action = () => value.Should().BeOneOf(value + 1.Days(), value + 4.Hours());\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value to be one of {<2017-01-01 +1h>, <2016-12-31 04:00:00 +1h>}, but it was <2016-12-31 +1h>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_param_values_follow_up_assertions_works()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n\n // Act / Assert\n value.Should().BeOneOf(value, value + 1.Hours())\n .And.Be(31.December(2016).WithOffset(1.Hours()));\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_nullable_params_values_follow_up_assertions_works()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n\n // Act / Assert\n value.Should().BeOneOf(null, value, value + 1.Hours())\n .And.Be(31.December(2016).WithOffset(1.Hours()));\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_enumerable_values_follow_up_assertions_works()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n IEnumerable expected = [value, value + 1.Hours()];\n\n // Act / Assert\n value.Should().BeOneOf(expected)\n .And.Be(31.December(2016).WithOffset(1.Hours()));\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_nullable_enumerable_follow_up_assertions_works()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n IEnumerable expected = [null, value, value + 1.Hours()];\n\n // Act / Assert\n value.Should().BeOneOf(expected)\n .And.Be(31.December(2016).WithOffset(1.Hours()));\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n DateTimeOffset value = 31.December(2016).WithOffset(1.Hours());\n\n // Act\n Action action = () => value.Should().BeOneOf(new[] { value + 1.Days(), value + 2.Days() }, \"because it's true\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value to be one of {<2017-01-01 +1h>, <2017-01-02 +1h>} because it's true, but it was <2016-12-31 +1h>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n DateTimeOffset value = new(2016, 12, 30, 23, 58, 57, TimeSpan.FromHours(4));\n\n // Act / Assert\n value.Should().BeOneOf(new DateTimeOffset(2216, 1, 30, 0, 5, 7, TimeSpan.FromHours(2)),\n new DateTimeOffset(2016, 12, 30, 23, 58, 57, TimeSpan.FromHours(4)));\n }\n\n [Fact]\n public void When_a_null_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateTimeOffset? value = null;\n\n // Act\n Action action = () => value.Should().BeOneOf(new DateTimeOffset(2216, 1, 30, 0, 5, 7, TimeSpan.FromHours(1)),\n new DateTimeOffset(2016, 2, 10, 2, 45, 7, TimeSpan.FromHours(2)));\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value to be one of {<2216-01-30 00:05:07 +1h>, <2016-02-10 02:45:07 +2h>}, but it was .\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_datetimeoffset_is_null()\n {\n // Arrange\n DateTimeOffset? value = null;\n\n // Act / Assert\n value.Should().BeOneOf(new DateTimeOffset(2216, 1, 30, 0, 5, 7, TimeSpan.Zero), null);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeNullOrEmpty.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeNullOrEmpty specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeNullOrEmpty\n {\n [Fact]\n public void\n When_asserting_a_null_collection_to_be_null_or_empty_it_should_succeed()\n {\n // Arrange\n int[] collection = null;\n\n // Act / Assert\n collection.Should().BeNullOrEmpty();\n }\n\n [Fact]\n public void\n When_asserting_an_empty_collection_to_be_null_or_empty_it_should_succeed()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().BeNullOrEmpty();\n }\n\n [Fact]\n public void\n When_asserting_non_empty_collection_to_be_null_or_empty_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().BeNullOrEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to be null or empty because we want to test the failure message, but found at least one item {1}.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_null_or_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([]);\n\n // Act\n collection.Should().BeNullOrEmpty();\n\n // Assert\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_non_empty_collection_is_null_or_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([1, 2, 3]);\n\n // Act\n Action act = () => collection.Should().BeNullOrEmpty();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be null or empty, but found at least one item {1}.\");\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n }\n\n public class NotBeNullOrEmpty\n {\n [Fact]\n public void\n When_asserting_non_empty_collection_to_not_be_null_or_empty_it_should_succeed()\n {\n // Arrange\n object[] collection = [new object()];\n\n // Act / Assert\n collection.Should().NotBeNullOrEmpty();\n }\n\n [Fact]\n public void\n When_asserting_null_collection_to_not_be_null_or_empty_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotBeNullOrEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_empty_collection_to_not_be_null_or_empty_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeNullOrEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_null_or_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([42]);\n\n // Act\n collection.Should().NotBeNullOrEmpty();\n\n // Assert\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XElementFormatterSpecs.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XElementFormatterSpecs\n{\n [Fact]\n public void When_element_has_attributes_it_should_include_them_in_the_output()\n {\n // Act\n var element = XElement.Parse(@\"\");\n string result = Formatter.ToString(element);\n\n // Assert\n result.Should().Be(@\"\");\n }\n\n [Fact]\n public void When_element_has_child_element_it_should_not_include_them_in_the_output()\n {\n // Act\n var element = XElement.Parse(\"\"\"\n \n \n \n \"\"\");\n\n string result = Formatter.ToString(element);\n\n // Assert\n result.Should().Be(@\"\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/ShouldCallParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class ShouldCallParsingStrategy : IParsingStrategy\n{\n private const string ShouldCall = \".Should\";\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (statement.Length >= ShouldCall.Length + 1)\n {\n var leftIndex = statement.Length - 2;\n var rightIndex = ShouldCall.Length - 1;\n\n for (var i = 0; i < ShouldCall.Length; i++)\n {\n if (statement[leftIndex - i] != ShouldCall[rightIndex - i])\n {\n return ParsingState.InProgress;\n }\n }\n\n if (statement[^1] is not ('(' or '.'))\n {\n return ParsingState.InProgress;\n }\n\n statement.Remove(statement.Length - (ShouldCall.Length + 1), ShouldCall.Length + 1);\n return ParsingState.Done;\n }\n\n return ParsingState.InProgress;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return false;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.Be.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_datetime_value_is_equal_to_the_same_value()\n {\n // Arrange\n DateTime dateTime = new(2016, 06, 04);\n DateTime sameDateTime = new(2016, 06, 04);\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_datetime_value_is_equal_to_the_same_nullable_value_be_should_succeed()\n {\n // Arrange\n DateTime dateTime = 4.June(2016);\n DateTime? sameDateTime = 4.June(2016);\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_both_values_are_at_their_minimum_then_it_should_succeed()\n {\n // Arrange\n DateTime dateTime = DateTime.MinValue;\n DateTime sameDateTime = DateTime.MinValue;\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_both_values_are_at_their_maximum_then_it_should_succeed()\n {\n // Arrange\n DateTime dateTime = DateTime.MaxValue;\n DateTime sameDateTime = DateTime.MaxValue;\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_datetime_value_is_equal_to_the_different_value()\n {\n // Arrange\n var dateTime = new DateTime(2012, 03, 10);\n var otherDateTime = new DateTime(2012, 03, 11);\n\n // Act\n Action act = () => dateTime.Should().Be(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dateTime to be <2012-03-11>*failure message, but found <2012-03-10>.\");\n }\n\n [Fact]\n public void When_datetime_value_is_equal_to_the_different_nullable_value_be_should_failed()\n {\n // Arrange\n DateTime dateTime = 10.March(2012);\n DateTime? otherDateTime = 11.March(2012);\n\n // Act\n Action act = () => dateTime.Should().Be(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dateTime to be <2012-03-11>*failure message, but found <2012-03-10>.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_equals_the_same_value()\n {\n // Arrange\n DateTime? nullableDateTimeA = new DateTime(2016, 06, 04);\n DateTime? nullableDateTimeB = new DateTime(2016, 06, 04);\n\n // Act / Assert\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n }\n\n [Fact]\n public void When_a_nullable_date_time_is_equal_to_a_normal_date_time_but_the_kinds_differ_it_should_still_succeed()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2014, 4, 20, 9, 11, 0, DateTimeKind.Unspecified);\n DateTime normalDateTime = new(2014, 4, 20, 9, 11, 0, DateTimeKind.Utc);\n\n // Act / Assert\n nullableDateTime.Should().Be(normalDateTime);\n }\n\n [Fact]\n public void When_two_date_times_are_equal_but_the_kinds_differ_it_should_still_succeed()\n {\n // Arrange\n DateTime dateTimeA = new(2014, 4, 20, 9, 11, 0, DateTimeKind.Unspecified);\n DateTime dateTimeB = new(2014, 4, 20, 9, 11, 0, DateTimeKind.Utc);\n\n // Act / Assert\n dateTimeA.Should().Be(dateTimeB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_null_value_equals_null()\n {\n // Arrange\n DateTime? nullableDateTimeA = null;\n DateTime? nullableDateTimeB = null;\n\n // Act / Assert\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n DateTime? nullableDateTimeA = new DateTime(2016, 06, 04);\n DateTime? nullableDateTimeB = new DateTime(2016, 06, 06);\n\n // Act\n Action action = () =>\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_datetime_null_value_is_equal_to_another_value()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act\n Action action = () =>\n nullableDateTime.Should().Be(new DateTime(2016, 06, 04), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateTime to be <2016-06-04> because we want to test the failure message, but found .\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Should_succeed_when_asserting_datetime_value_is_not_equal_to_a_different_value()\n {\n // Arrange\n DateTime dateTime = new(2016, 06, 04);\n DateTime otherDateTime = new(2016, 06, 05);\n\n // Act / Assert\n dateTime.Should().NotBe(otherDateTime);\n }\n\n [Fact]\n public void When_datetime_value_is_not_equal_to_a_different_nullable_value_notbe_should_succeed()\n {\n // Arrange\n DateTime dateTime = 4.June(2016);\n DateTime? otherDateTime = 5.June(2016);\n\n // Act / Assert\n dateTime.Should().NotBe(otherDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_datetime_value_is_not_equal_to_the_same_value()\n {\n // Arrange\n var dateTime = DateTime.SpecifyKind(10.March(2012).At(10, 00), DateTimeKind.Local);\n var sameDateTime = DateTime.SpecifyKind(10.March(2012).At(10, 00), DateTimeKind.Utc);\n\n // Act\n Action act =\n () => dateTime.Should().NotBe(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected dateTime not to be <2012-03-10 10:00:00> because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void When_datetime_value_is_not_equal_to_the_same_nullable_value_notbe_should_failed()\n {\n // Arrange\n DateTime dateTime = DateTime.SpecifyKind(10.March(2012).At(10, 00), DateTimeKind.Local);\n DateTime? sameDateTime = DateTime.SpecifyKind(10.March(2012).At(10, 00), DateTimeKind.Utc);\n\n // Act\n Action act =\n () => dateTime.Should().NotBe(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected dateTime not to be <2012-03-10 10:00:00> because we want to test the failure message, but it is.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NumericAssertions.cs", "using System;\nusing System.Diagnostics;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NumericAssertions : NumericAssertions>\n where T : struct, IComparable\n{\n public NumericAssertions(T value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NumericAssertions : NumericAssertionsBase\n where T : struct, IComparable\n where TAssertions : NumericAssertions\n{\n public NumericAssertions(T value, AssertionChain assertionChain)\n : base(assertionChain)\n {\n Subject = value;\n }\n\n public override T Subject { get; }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/XUnit3Core.Specs/FrameworkSpecs.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions;\nusing Xunit;\n\nnamespace XUnit3Core.Specs;\n\npublic class FrameworkSpecs\n{\n [Fact]\n public void When_xunit3_without_xunit_assert_is_used_it_should_throw_IAssertionException_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n exception.GetType().GetInterfaces().Select(e => e.Name).Should().Contain(\"IAssertionException\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableGuidAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableGuidAssertions : NullableGuidAssertions\n{\n public NullableGuidAssertions(Guid? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableGuidAssertions : GuidAssertions\n where TAssertions : NullableGuidAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableGuidAssertions(Guid? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected a value{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that the value is equal to the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(Guid? expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:Guid} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/GuidAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic class GuidAssertionSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_empty_guid_is_empty()\n {\n // Arrange\n Guid guid = Guid.Empty;\n\n // Act / Assert\n guid.Should().BeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_non_empty_guid_is_empty()\n {\n // Arrange\n var guid = new Guid(\"12345678-1234-1234-1234-123456789012\");\n\n // Act\n Action act = () => guid.Should().BeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Guid to be empty because we want to test the failure message, but found {12345678-1234-1234-1234-123456789012}.\");\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_non_empty_guid_is_not_empty()\n {\n // Arrange\n var guid = new Guid(\"12345678-1234-1234-1234-123456789012\");\n\n // Act / Assert\n guid.Should().NotBeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_empty_guid_is_not_empty()\n {\n // Act\n Action act = () => Guid.Empty.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect Guid.Empty to be empty because we want to test the failure message.\");\n }\n }\n\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_guid_equals_the_same_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n var sameGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act / Assert\n guid.Should().Be(sameGuid);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_guid_equals_the_same_guid_in_string_format()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act / Assert\n guid.Should().Be(\"11111111-aaaa-bbbb-cccc-999999999999\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_guid_equals_a_different_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n var differentGuid = new Guid(\"55555555-ffff-eeee-dddd-444444444444\");\n\n // Act\n Action act = () => guid.Should().Be(differentGuid, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Guid to be {55555555-ffff-eeee-dddd-444444444444} because we want to test the failure message, but found {11111111-aaaa-bbbb-cccc-999999999999}.\");\n }\n\n [Fact]\n public void Should_throw_when_asserting_guid_equals_a_string_that_is_not_a_valid_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => guid.Should().Be(string.Empty, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expected\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Should_succeed_when_asserting_guid_does_not_equal_a_different_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n var differentGuid = new Guid(\"55555555-ffff-eeee-dddd-444444444444\");\n\n // Act / Assert\n guid.Should().NotBe(differentGuid);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_guid_does_not_equal_the_same_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n var sameGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => guid.Should().NotBe(sameGuid, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect Guid to be {11111111-aaaa-bbbb-cccc-999999999999} because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_throw_when_asserting_guid_does_not_equal_a_string_that_is_not_a_valid_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => guid.Should().NotBe(string.Empty, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_guid_does_not_equal_a_different_guid_in_string_format()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act / Assert\n guid.Should().NotBe(\"55555555-ffff-eeee-dddd-444444444444\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_guid_does_not_equal_the_same_guid_in_string_format()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () =>\n guid.Should().NotBe(\"11111111-aaaa-bbbb-cccc-999999999999\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect Guid to be {11111111-aaaa-bbbb-cccc-999999999999} *failure message*.\");\n }\n }\n\n public class ChainingConstraint\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n Guid guid = Guid.NewGuid();\n\n // Act / Assert\n guid.Should()\n .NotBeEmpty()\n .And.Be(guid);\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n Guid subject = Guid.Empty;\n\n // Act\n Action action = () => subject.Should().Equals(subject);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() or BeOneOf() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeBefore.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeBefore\n {\n [Fact]\n public void When_asserting_a_point_of_time_is_before_a_later_point_it_should_succeed()\n {\n // Arrange\n DateTime earlierDate = DateTime.SpecifyKind(new DateTime(2016, 06, 04), DateTimeKind.Unspecified);\n DateTime laterDate = DateTime.SpecifyKind(new DateTime(2016, 06, 04, 0, 5, 0), DateTimeKind.Utc);\n\n // Act / Assert\n earlierDate.Should().BeBefore(laterDate);\n }\n\n [Fact]\n public void When_asserting_subject_is_before_earlier_expected_datetime_it_should_throw()\n {\n // Arrange\n DateTime expected = new(2016, 06, 03);\n DateTime subject = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_before_the_same_datetime_it_should_throw()\n {\n // Arrange\n DateTime expected = new(2016, 06, 04);\n DateTime subject = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04>, but found <2016-06-04>.\");\n }\n }\n\n public class NotBeBefore\n {\n [Fact]\n public void When_asserting_a_point_of_time_is_not_before_another_it_should_throw()\n {\n // Arrange\n DateTime earlierDate = DateTime.SpecifyKind(new DateTime(2016, 06, 04), DateTimeKind.Unspecified);\n DateTime laterDate = DateTime.SpecifyKind(new DateTime(2016, 06, 04, 0, 5, 0), DateTimeKind.Utc);\n\n // Act\n Action act = () => earlierDate.Should().NotBeBefore(laterDate);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected earlierDate to be on or after <2016-06-04 00:05:00>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_is_not_before_earlier_expected_datetime_it_should_succeed()\n {\n // Arrange\n DateTime expected = new(2016, 06, 03);\n DateTime subject = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_before_the_same_datetime_it_should_succeed()\n {\n // Arrange\n DateTime expected = new(2016, 06, 04);\n DateTime subject = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().NotBeBefore(expected);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveMethod.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveMethod specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveMethod\n {\n [Fact]\n public void When_asserting_a_type_has_a_method_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveMethod(\"VoidMethod\", [])\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.Private)\n .And.ReturnVoid();\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(\n \"NonExistentMethod\", [typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method *ClassWithNoMembers.NonExistentMethod(int, System.Type) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_with_different_parameter_types_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(\n \"VoidMethod\", [typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method *.ClassWithMembers.VoidMethod(int, System.Type) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_method_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(\"Name\", [typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method type.Name(string) to exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(null, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(string.Empty, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(\"Name\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n\n public class NotHaveMethod\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act / Assert\n type.Should().NotHaveMethod(\"NonExistentMethod\", []);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_which_it_has_with_different_parameter_types_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should().NotHaveMethod(\"VoidMethod\", [typeof(int)]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_that_method_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(\"VoidMethod\", [], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method Void *.ClassWithMembers.VoidMethod() to not exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_method_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(\"Name\", [typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method type.Name(string) to not exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(null, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(string.Empty, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(\"Name\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensions/FluentTimeSpanExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Extensions;\n\n/// \n/// Extension methods on to allow for a more fluent way of specifying a .\n/// \n/// \n/// Instead of
\n///
\n/// TimeSpan.FromHours(12)
\n///
\n/// you can write
\n///
\n/// 12.Hours()
\n///
\n/// Or even
\n///
\n/// 12.Hours().And(30.Minutes()).\n///
\n/// \npublic static class FluentTimeSpanExtensions\n{\n /// \n /// Represents the number of ticks that are in 1 microsecond.\n /// \n public const long TicksPerMicrosecond = TimeSpan.TicksPerMillisecond / 1000;\n\n /// \n /// Represents the number of ticks that are in 1 nanosecond.\n /// \n public const double TicksPerNanosecond = TicksPerMicrosecond / 1000d;\n\n /// \n /// Returns a based on a number of ticks.\n /// \n public static TimeSpan Ticks(this int ticks)\n {\n return TimeSpan.FromTicks(ticks);\n }\n\n /// \n /// Returns a based on a number of ticks.\n /// \n public static TimeSpan Ticks(this long ticks)\n {\n return TimeSpan.FromTicks(ticks);\n }\n\n /// \n /// Gets the nanoseconds component of the time interval represented by the current structure.\n /// \n public static int Nanoseconds(this TimeSpan self)\n {\n return (int)((self.Ticks % TicksPerMicrosecond) * (1d / TicksPerNanosecond));\n }\n\n /// \n /// Returns a based on a number of nanoseconds.\n /// \n /// \n /// .NET's smallest resolutions is 100 nanoseconds. Any nanoseconds passed in\n /// lower than .NET's resolution will be rounded using the default rounding\n /// algorithm in Math.Round().\n /// \n public static TimeSpan Nanoseconds(this int nanoseconds)\n {\n return ((long)Math.Round(nanoseconds * TicksPerNanosecond)).Ticks();\n }\n\n /// \n /// Returns a based on a number of nanoseconds.\n /// \n /// \n /// .NET's smallest resolutions is 100 nanoseconds. Any nanoseconds passed in\n /// lower than .NET's resolution will be rounded using the default rounding\n /// algorithm in Math.Round().\n /// \n public static TimeSpan Nanoseconds(this long nanoseconds)\n {\n return ((long)Math.Round(nanoseconds * TicksPerNanosecond)).Ticks();\n }\n\n /// \n /// Gets the value of the current structure expressed in whole and fractional nanoseconds.\n /// \n public static double TotalNanoseconds(this TimeSpan self)\n {\n return self.Ticks * (1d / TicksPerNanosecond);\n }\n\n /// \n /// Gets the microseconds component of the time interval represented by the current structure.\n /// \n public static int Microseconds(this TimeSpan self)\n {\n return (int)((self.Ticks % TimeSpan.TicksPerMillisecond) * (1d / TicksPerMicrosecond));\n }\n\n /// \n /// Returns a based on a number of microseconds.\n /// \n public static TimeSpan Microseconds(this int microseconds)\n {\n return (microseconds * TicksPerMicrosecond).Ticks();\n }\n\n /// \n /// Returns a based on a number of microseconds.\n /// \n public static TimeSpan Microseconds(this long microseconds)\n {\n return (microseconds * TicksPerMicrosecond).Ticks();\n }\n\n /// \n /// Gets the value of the current structure expressed in whole and fractional microseconds.\n /// \n public static double TotalMicroseconds(this TimeSpan self)\n {\n return self.Ticks * (1d / TicksPerMicrosecond);\n }\n\n /// \n /// Returns a based on a number of milliseconds.\n /// \n public static TimeSpan Milliseconds(this int milliseconds)\n {\n return TimeSpan.FromMilliseconds(milliseconds);\n }\n\n /// \n /// Returns a based on a number of milliseconds.\n /// \n public static TimeSpan Milliseconds(this double milliseconds)\n {\n return TimeSpan.FromMilliseconds(milliseconds);\n }\n\n /// \n /// Returns a based on a number of seconds.\n /// \n public static TimeSpan Seconds(this int seconds)\n {\n return TimeSpan.FromSeconds(seconds);\n }\n\n /// \n /// Returns a based on a number of seconds.\n /// \n public static TimeSpan Seconds(this double seconds)\n {\n return TimeSpan.FromSeconds(seconds);\n }\n\n /// \n /// Returns a based on a number of seconds, and add the specified\n /// .\n /// \n public static TimeSpan Seconds(this int seconds, TimeSpan offset)\n {\n return TimeSpan.FromSeconds(seconds).Add(offset);\n }\n\n /// \n /// Returns a based on a number of minutes.\n /// \n public static TimeSpan Minutes(this int minutes)\n {\n return TimeSpan.FromMinutes(minutes);\n }\n\n /// \n /// Returns a based on a number of minutes.\n /// \n public static TimeSpan Minutes(this double minutes)\n {\n return TimeSpan.FromMinutes(minutes);\n }\n\n /// \n /// Returns a based on a number of minutes, and add the specified\n /// .\n /// \n public static TimeSpan Minutes(this int minutes, TimeSpan offset)\n {\n return TimeSpan.FromMinutes(minutes).Add(offset);\n }\n\n /// \n /// Returns a based on a number of hours.\n /// \n public static TimeSpan Hours(this int hours)\n {\n return TimeSpan.FromHours(hours);\n }\n\n /// \n /// Returns a based on a number of hours.\n /// \n public static TimeSpan Hours(this double hours)\n {\n return TimeSpan.FromHours(hours);\n }\n\n /// \n /// Returns a based on a number of hours, and add the specified\n /// .\n /// \n public static TimeSpan Hours(this int hours, TimeSpan offset)\n {\n return TimeSpan.FromHours(hours).Add(offset);\n }\n\n /// \n /// Returns a based on a number of days.\n /// \n public static TimeSpan Days(this int days)\n {\n return TimeSpan.FromDays(days);\n }\n\n /// \n /// Returns a based on a number of days.\n /// \n public static TimeSpan Days(this double days)\n {\n return TimeSpan.FromDays(days);\n }\n\n /// \n /// Returns a based on a number of days, and add the specified\n /// .\n /// \n public static TimeSpan Days(this int days, TimeSpan offset)\n {\n return TimeSpan.FromDays(days).Add(offset);\n }\n\n /// \n /// Convenience method for chaining multiple calls to the methods provided by this class.\n /// \n /// \n /// 23.Hours().And(59.Minutes())\n /// \n public static TimeSpan And(this TimeSpan sourceTime, TimeSpan offset)\n {\n return sourceTime.Add(offset);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeBefore.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeBefore\n {\n [Fact]\n public void When_asserting_a_point_of_time_is_before_a_later_point_it_should_succeed()\n {\n // Arrange\n DateTimeOffset earlierDate = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset laterDate = new(new DateTime(2016, 06, 04, 0, 5, 0), TimeSpan.Zero);\n\n // Act / Assert\n earlierDate.Should().BeBefore(laterDate);\n }\n\n [Fact]\n public void When_asserting_subject_is_before_earlier_expected_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset expected = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_before_the_same_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset expected = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04 +0h>, but it was <2016-06-04 +0h>.\");\n }\n }\n\n public class NotBeBefore\n {\n [Fact]\n public void When_asserting_a_point_of_time_is_not_before_another_it_should_throw()\n {\n // Arrange\n DateTimeOffset earlierDate = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset laterDate = new(new DateTime(2016, 06, 04, 0, 5, 0), TimeSpan.Zero);\n\n // Act\n Action act = () => earlierDate.Should().NotBeBefore(laterDate);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected earlierDate to be on or after <2016-06-04 00:05:00 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_is_not_before_earlier_expected_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset expected = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_before_the_same_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset expected = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeBefore(expected);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/FluentActionsSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Xunit;\nusing static AwesomeAssertions.FluentActions;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class FluentActionsSpecs\n{\n [Fact]\n public void Invoking_works_with_action()\n {\n // Arrange / Act / Assert\n Invoking(() => Throws()).Should().Throw();\n }\n\n [Fact]\n public void Invoking_works_with_func()\n {\n // Arrange / Act / Assert\n Invoking(() => Throws(0)).Should().Throw();\n }\n\n [Fact]\n public async Task Awaiting_works_with_action()\n {\n // Arrange / Act / Assert\n await Awaiting(() => ThrowsAsync()).Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Awaiting_works_with_func()\n {\n // Arrange / Act / Assert\n await Awaiting(() => ThrowsAsync(0)).Should().ThrowAsync();\n }\n\n [Fact]\n public void Enumerating_works_with_general()\n {\n // Arrange / Act / Assert\n Enumerating(() => ThrowsAfterFirst()).Should().Throw();\n }\n\n [Fact]\n public void Enumerating_works_with_specialized()\n {\n // Arrange / Act / Assert\n Enumerating(() => ThrowsAfterFirst(0)).Should().Throw();\n }\n\n [Fact]\n public void Enumerating_works_with_enumerable_func()\n {\n // Arrange\n var actual = new Example();\n\n // Act / Assert\n actual.Enumerating(x => x.DoSomething()).Should().Throw();\n }\n\n private class Example\n {\n public IEnumerable DoSomething()\n {\n var range = Enumerable.Range(0, 10);\n\n return range.Select(Twice);\n }\n\n private int Twice(int arg)\n {\n if (arg == 5)\n {\n throw new InvalidOperationException();\n }\n\n return 2 * arg;\n }\n }\n\n private static void Throws()\n {\n throw new InvalidOperationException();\n }\n\n private static int Throws(int _)\n {\n throw new InvalidOperationException();\n }\n\n private static async Task ThrowsAsync()\n {\n await Task.Yield();\n throw new InvalidOperationException();\n }\n\n private static async Task ThrowsAsync(int _)\n {\n await Task.Yield();\n throw new InvalidOperationException();\n }\n\n private static IEnumerable ThrowsAfterFirst()\n {\n yield return 0;\n throw new InvalidOperationException();\n }\n\n private static IEnumerable ThrowsAfterFirst(int number)\n {\n yield return number;\n throw new InvalidOperationException();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XmlNodeFormatterSpecs.cs", "using System;\nusing System.Xml;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XmlNodeFormatterSpecs\n{\n [Fact]\n public void When_a_node_is_20_chars_long_it_should_not_be_trimmed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(@\"\");\n\n // Act\n string result = Formatter.ToString(xmlDoc);\n\n // Assert\n result.Should().Be(@\"\" + Environment.NewLine);\n }\n\n [Fact]\n public void When_a_node_is_longer_then_20_chars_it_should_be_trimmed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(@\"\");\n\n // Act\n string result = Formatter.ToString(xmlDoc);\n\n // Assert\n result.Should().Be(@\"\n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableTimeOnlyAssertions : NullableTimeOnlyAssertions\n{\n public NullableTimeOnlyAssertions(TimeOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableTimeOnlyAssertions : TimeOnlyAssertions\n where TAssertions : NullableTimeOnlyAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableTimeOnlyAssertions(TimeOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable time} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:nullable time} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableDateOnlyAssertions.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableDateOnlyAssertions : NullableDateOnlyAssertions\n{\n public NullableDateOnlyAssertions(DateOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableDateOnlyAssertions : DateOnlyAssertions\n where TAssertions : NullableDateOnlyAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableDateOnlyAssertions(DateOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable date} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:nullable date} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableDateTimeAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableDateTimeAssertions : NullableDateTimeAssertions\n{\n public NullableDateTimeAssertions(DateTime? expected, AssertionChain assertionChain)\n : base(expected, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableDateTimeAssertions : DateTimeAssertions\n where TAssertions : NullableDateTimeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableDateTimeAssertions(DateTime? expected, AssertionChain assertionChain)\n : base(expected, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable date and time} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:nullable date and time} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableDateTimeOffsetAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableDateTimeOffsetAssertions : NullableDateTimeOffsetAssertions\n{\n public NullableDateTimeOffsetAssertions(DateTimeOffset? expected, AssertionChain assertionChain)\n : base(expected, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableDateTimeOffsetAssertions : DateTimeOffsetAssertions\n where TAssertions : NullableDateTimeOffsetAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableDateTimeOffsetAssertions(DateTimeOffset? expected, AssertionChain assertionChain)\n : base(expected, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:variable} to have a value{reason}, but found {0}\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:variable} to have a value{reason}, but found {0}\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeOfType.cs", "using System;\nusing AssemblyA;\nusing AssemblyB;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeOfType\n {\n [Fact]\n public void When_object_type_is_matched_against_null_type_exactly_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expectedType\");\n }\n\n [Fact]\n public void When_object_type_is_exactly_equal_to_the_specified_type_it_should_not_fail()\n {\n // Arrange\n var someObject = new Exception();\n\n // Act / Assert\n someObject.Should().BeOfType();\n }\n\n [Fact]\n public void When_object_type_is_value_type_and_matches_received_type_should_not_fail_and_assert_correctly()\n {\n // Arrange\n int valueTypeObject = 42;\n\n // Act / Assert\n valueTypeObject.Should().BeOfType(typeof(int));\n }\n\n [Fact]\n public void When_object_is_matched_against_a_null_type_it_should_throw()\n {\n // Arrange\n int valueTypeObject = 42;\n\n // Act\n Action act = () => valueTypeObject.Should().BeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expectedType\");\n }\n\n [Fact]\n public void When_null_object_is_matched_against_a_type_it_should_throw()\n {\n // Arrange\n int? valueTypeObject = null;\n\n // Act\n Action act = () =>\n valueTypeObject.Should().BeOfType(typeof(int), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*type to be int*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_object_type_is_value_type_and_doesnt_match_received_type_should_fail()\n {\n // Arrange\n int valueTypeObject = 42;\n Type doubleType = typeof(double);\n\n // Act\n Action act = () => valueTypeObject.Should().BeOfType(doubleType);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be double, but found int.\");\n }\n\n [Fact]\n public void When_object_is_of_the_expected_type_it_should_cast_the_returned_object_for_chaining()\n {\n // Arrange\n var someObject = new Exception(\"Actual Message\");\n\n // Act\n Action act = () => someObject.Should().BeOfType().Which.Message.Should().Be(\"Other Message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Expected*Actual*Other*\");\n }\n\n [Fact]\n public void When_object_type_is_different_than_expected_type_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeOfType(\"because they are {0} {1}\", \"of different\", \"type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found object.\");\n }\n\n [Fact]\n public void When_asserting_the_type_of_a_null_object_it_should_throw()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () => someObject.Should().BeOfType();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someObject to be int, but found .\");\n }\n\n [Fact]\n public void\n When_object_type_is_same_as_expected_type_but_in_different_assembly_it_should_fail_with_assembly_qualified_name()\n {\n // Arrange\n var typeFromOtherAssembly =\n new ClassA().ReturnClassC();\n\n // Act\n#pragma warning disable 436 // disable the warning on conflicting types, as this is the intention for the spec\n\n Action act = () =>\n typeFromOtherAssembly.Should().BeOfType();\n\n#pragma warning restore 436\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to be [AssemblyB.ClassC, AwesomeAssertions.Specs*], but found [AssemblyB.ClassC, AssemblyB*].\");\n }\n\n [Fact]\n public void When_object_type_is_a_subclass_of_the_expected_type_it_should_fail()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act\n Action act = () => someObject.Should().BeOfType();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be AwesomeAssertions*DummyBaseClass, but found AwesomeAssertions*DummyImplementingClass.\");\n }\n }\n\n public class NotBeOfType\n {\n [Fact]\n public void When_object_type_is_matched_negatively_against_null_type_exactly_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().NotBeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"unexpectedType\");\n }\n\n [Fact]\n public void When_object_is_matched_negatively_against_a_null_type_it_should_throw()\n {\n // Arrange\n int valueTypeObject = 42;\n\n // Act\n Action act = () => valueTypeObject.Should().NotBeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"unexpectedType\");\n }\n\n [Fact]\n public void\n When_object_type_is_value_type_and_doesnt_match_received_type_as_expected_should_not_fail_and_assert_correctly()\n {\n // Arrange\n int valueTypeObject = 42;\n\n // Act / Assert\n valueTypeObject.Should().NotBeOfType(typeof(double));\n }\n\n [Fact]\n public void When_null_object_is_matched_negatively_against_a_type_it_should_throw()\n {\n // Arrange\n int? valueTypeObject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n valueTypeObject.Should().NotBeOfType(typeof(int), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*type not to be int *because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_object_type_is_value_type_and_matches_received_type_not_as_expected_should_fail()\n {\n // Arrange\n int valueTypeObject = 42;\n var expectedType = typeof(int);\n\n // Act\n Action act = () => valueTypeObject.Should().NotBeOfType(expectedType);\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected type not to be [{expectedType.AssemblyQualifiedName}], but it is.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/QuotesParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class QuotesParsingStrategy : IParsingStrategy\n{\n private char isQuoteEscapeSymbol = '\\\\';\n private bool isQuoteContext;\n private char? previousChar;\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (symbol is '\"')\n {\n if (isQuoteContext)\n {\n if (previousChar != isQuoteEscapeSymbol)\n {\n isQuoteContext = false;\n isQuoteEscapeSymbol = '\\\\';\n previousChar = null;\n statement.Append(symbol);\n return ParsingState.GoToNextSymbol;\n }\n }\n else\n {\n isQuoteContext = true;\n\n if (IsVerbatim(statement))\n {\n isQuoteEscapeSymbol = '\"';\n }\n }\n }\n\n if (isQuoteContext)\n {\n statement.Append(symbol);\n }\n\n previousChar = symbol;\n return isQuoteContext ? ParsingState.GoToNextSymbol : ParsingState.InProgress;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return isQuoteContext;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n\n private bool IsVerbatim(StringBuilder statement)\n {\n return (previousChar is '@' && statement is [.., '$', '@'])\n || (previousChar is '$' && statement is [.., '@', '$']);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/ActionAssertionSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class ActionAssertionSpecs\n{\n [Fact]\n public void Null_clock_throws_exception()\n {\n // Arrange\n Action subject = () => { };\n\n // Act\n var act = void () => subject.Should(clock: null).NotThrow();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"clock\");\n }\n\n public class Throw\n {\n [Fact]\n public void Allow_additional_assertions_on_return_value()\n {\n // Arrange\n var exception = new Exception(\"foo\");\n Action subject = () => throw exception;\n\n // Act / Assert\n subject.Should().Throw()\n .Which.Message.Should().Be(\"foo\");\n }\n }\n\n public class NotThrow\n {\n [Fact]\n public void Allow_additional_assertions_on_return_value()\n {\n // Arrange\n Action subject = () => { };\n\n // Act / Assert\n subject.Should().NotThrow()\n .And.NotBeNull();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/FakeClock.cs", "using System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\n#if NET8_0_OR_GREATER\nusing ITimer = AwesomeAssertions.Common.ITimer;\n#endif\n\nnamespace AwesomeAssertions.Specs;\n\n/// \n/// Implementation of for testing purposes only.\n/// \n/// \n/// It allows you to control the \"current\" date and time for test purposes.\n/// \ninternal class FakeClock : IClock\n{\n private readonly TaskCompletionSource delayTask = new();\n\n private TimeSpan elapsedTime = TimeSpan.Zero;\n\n Task IClock.DelayAsync(TimeSpan delay, CancellationToken cancellationToken)\n {\n elapsedTime += delay;\n return delayTask.Task;\n }\n\n public ITimer StartTimer() => new TestTimer(() => elapsedTime);\n\n /// \n /// Advances the internal clock.\n /// \n public void Delay(TimeSpan timeToDelay)\n {\n elapsedTime += timeToDelay;\n }\n\n /// \n /// Simulates the completion of the pending delay task.\n /// \n public void Complete()\n {\n // the value is not relevant\n delayTask.SetResult(true);\n }\n\n /// \n /// Simulates the completion of the pending delay task after the internal clock has been advanced.\n /// \n public void CompleteAfter(TimeSpan timeSpan)\n {\n Delay(timeSpan);\n\n // the value is not relevant\n delayTask.SetResult(true);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveConstructor.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveConstructor specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveConstructor\n {\n [Fact]\n public void When_asserting_a_type_has_a_constructor_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveConstructor([typeof(string)])\n .Which.Should().HaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_constructor_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveConstructor([typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected constructor *ClassWithNoMembers(int, System.Type) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_constructor_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveConstructor([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor type(string) to exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_constructor_of_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveConstructor(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n\n public class NotHaveConstructor\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_a_constructor_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act / Assert\n type.Should()\n .NotHaveConstructor([typeof(string)]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_constructor_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveConstructor([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected constructor *.ClassWithMembers(string) not to exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_constructor_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveConstructor([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor type(string) not to exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_constructor_of_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveConstructor(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.ContainValues.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class ContainValues\n {\n [Fact]\n public void When_dictionary_contains_multiple_values_from_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValues(\"Two\", \"One\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_a_number_of_values_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValues([\"Two\", \"Three\"], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain values {\\\"Two\\\", \\\"Three\\\"} because we do, but could not find \\\"Three\\\".\");\n }\n\n [Fact]\n public void\n When_the_contents_of_a_dictionary_are_checked_against_an_empty_list_of_values_it_should_throw_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValues();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify value containment against an empty sequence*\");\n }\n }\n\n [Fact]\n public void Can_run_another_assertion_on_the_result()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValues(\"Two\", \"One\").Which.Should().Contain(\"Three\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected dictionary[1 and 2]*to contain*Three*\");\n }\n\n public class NotContainValues\n {\n [Fact]\n public void When_dictionary_does_not_contain_multiple_values_that_is_not_in_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValues(\"Three\", \"Four\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_dictionary_contains_a_exactly_one_of_the_values_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValues([\"Two\"], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to not contain value \\\"Two\\\" because we do.\");\n }\n\n [Fact]\n public void When_a_dictionary_contains_a_number_of_values_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValues([\"Two\", \"Three\"], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to not contain value {\\\"Two\\\", \\\"Three\\\"} because we do, but found {\\\"Two\\\"}.\");\n }\n\n [Fact]\n public void\n When_the_noncontents_of_a_dictionary_are_checked_against_an_empty_list_of_values_it_should_throw_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValues();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify value containment with an empty sequence*\");\n }\n\n [Fact]\n public void Null_dictionaries_do_not_contain_any_values()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContainValues([\"Two\", \"Three\"], \"because {0}\", \"we do\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain values {\\\"Two\\\", \\\"Three\\\"} because we do, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/MultidimensionalArrayFormatterSpecs.cs", "using System;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class MultidimensionalArrayFormatterSpecs\n{\n [Theory]\n [MemberData(nameof(MultiDimensionalArrayData))]\n public void When_formatting_a_multi_dimensional_array_it_should_show_structure(object value, string expected)\n {\n // Arrange\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Match(expected);\n }\n\n public static TheoryData MultiDimensionalArrayData => new()\n {\n {\n new int[0, 0],\n \"{empty}\"\n },\n {\n new[,]\n {\n { 1, 2 },\n { 3, 4 }\n },\n \"{{1, 2}, {3, 4}}\"\n },\n {\n new[,,]\n {\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n },\n {\n { 7, 8, 9 },\n { 10, 11, 12 }\n }\n },\n \"{{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}}\"\n },\n };\n\n [Fact]\n public void When_formatting_a_multi_dimensional_array_with_bounds_it_should_show_structure()\n {\n // Arrange\n int[] lengthsArray = [2, 3, 4];\n int[] boundsArray = [1, 5, 7];\n var value = Array.CreateInstance(typeof(string), lengthsArray, boundsArray);\n\n for (int i = value.GetLowerBound(0); i <= value.GetUpperBound(0); i++)\n {\n for (int j = value.GetLowerBound(1); j <= value.GetUpperBound(1); j++)\n {\n for (int k = value.GetLowerBound(2); k <= value.GetUpperBound(2); k++)\n {\n int[] indices = [i, j, k];\n value.SetValue($\"{i}-{j}-{k}\", indices);\n }\n }\n }\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Match(\n \"{{{'1-5-7', '1-5-8', '1-5-9', '1-5-10'}, {'1-6-7', '1-6-8', '1-6-9', '1-6-10'}, {'1-7-7', '1-7-8', '1-7-9', '1-7-10'}}, {{'2-5-7', '2-5-8', '2-5-9', '2-5-10'}, {'2-6-7', '2-6-8', '2-6-9', '2-6-10'}, {'2-7-7', '2-7-8', '2-7-9', '2-7-10'}}}\"\n .Replace(\"'\", \"\\\"\"));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/MemberPathSegmentEqualityComparer.cs", "#if NET6_0_OR_GREATER || NETSTANDARD2_1\nusing System;\n#endif\nusing System.Collections.Generic;\nusing System.Text.RegularExpressions;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Compares two segments of a .\n/// Sets the equal with any numeric index qualifier.\n/// All other comparisons are default string equality.\n/// \ninternal class MemberPathSegmentEqualityComparer : IEqualityComparer\n{\n private const string AnyIndexQualifier = \"*\";\n private static readonly Regex IndexQualifierRegex = new(\"^[0-9]+$\");\n\n /// \n /// Compares two segments of a .\n /// \n /// Left part of the comparison.\n /// Right part of the comparison.\n /// True if segments are equal, false if not.\n public bool Equals(string x, string y)\n {\n if (x == AnyIndexQualifier)\n {\n return IsIndexQualifier(y);\n }\n\n if (y == AnyIndexQualifier)\n {\n return IsIndexQualifier(x);\n }\n\n return x == y;\n }\n\n private static bool IsIndexQualifier(string segment) =>\n segment == AnyIndexQualifier || IndexQualifierRegex.IsMatch(segment);\n\n public int GetHashCode(string obj)\n {\n#if NET6_0_OR_GREATER || NETSTANDARD2_1\n return obj.GetHashCode(StringComparison.Ordinal);\n#else\n return obj.GetHashCode();\n#endif\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.Contain.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class Contain\n {\n [Fact]\n public void When_a_collection_does_not_contain_another_collection_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain([\"three\", \"four\", \"five\"], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to contain {\\\"three\\\", \\\"four\\\", \\\"five\\\"} because we do, but could not find {\\\"four\\\", \\\"five\\\"}.\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_single_item_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain(\"four\", \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to contain \\\"four\\\" because we do.\");\n }\n\n [Fact]\n public void\n When_asserting_a_string_collection_contains_an_element_it_should_allow_specifying_the_reason_via_named_parameter()\n {\n // Arrange\n var expected = new List { \"hello\", \"world\" };\n var actual = new List { \"hello\", \"world\" };\n\n // Act / Assert\n actual.Should().Contain(expected, \"they are in the collection\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_an_item_from_the_collection_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().Contain(\"one\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_multiple_items_from_the_collection_in_any_order_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain([\"two\", \"one\"]);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_the_contents_of_a_collection_are_checked_against_an_empty_collection_it_should_throw_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain(new string[0]);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify containment against an empty collection*\");\n }\n\n [Fact]\n public void When_the_expected_object_exists_it_should_allow_chaining_additional_assertions()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain(\"one\").Which.Should().HaveLength(4);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*length*4*3*\");\n }\n }\n\n public class NotContain\n {\n [Fact]\n public void When_asserting_collection_does_not_contain_item_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should()\n .NotContain(\"one\", \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to not contain \\\"one\\\" because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_contains_an_unexpected_item_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContain(\"one\", \"because we {0} like it, but found it anyhow\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to not contain \\\"one\\\" because we don't like it, but found it anyhow.\");\n }\n\n [Fact]\n public void When_collection_does_contain_an_unexpected_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContain(item => item == \"two\", \"because {0}s are evil\", \"two\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to not have any items matching (item == \\\"two\\\") because twos are evil,*{\\\"two\\\"}*\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_an_item_that_is_not_in_the_collection_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContain(\"four\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_collection_does_not_contain_an_unexpected_item_matching_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotContain(item => item == \"four\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.cs", "using System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class StringAssertionSpecs\n{\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_chaining_multiple_assertions_it_should_assert_all_conditions()\n {\n // Arrange\n string actual = \"ABCDEFGHI\";\n string prefix = \"AB\";\n string suffix = \"HI\";\n string substring = \"EF\";\n int length = 9;\n\n // Act / Assert\n actual.Should()\n .StartWith(prefix).And\n .EndWith(suffix).And\n .Contain(substring).And\n .HaveLength(length);\n }\n\n private sealed class AlwaysMatchingEqualityComparer : IEqualityComparer\n {\n public bool Equals(string x, string y)\n {\n return true;\n }\n\n public int GetHashCode(string obj)\n {\n return obj.GetHashCode();\n }\n }\n\n private sealed class NeverMatchingEqualityComparer : IEqualityComparer\n {\n public bool Equals(string x, string y)\n {\n return false;\n }\n\n public int GetHashCode(string obj)\n {\n return obj.GetHashCode();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Collections;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// This part of the class contains assertions of general generic string collections\n/// \npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n [Fact]\n public void When_using_StringCollectionAssertions_the_AndConstraint_should_have_the_correct_type()\n {\n // Arrange\n MethodInfo[] methodInfo =\n typeof(StringCollectionAssertions>).GetMethods(\n BindingFlags.Public | BindingFlags.Instance);\n\n // Act\n var methods =\n from method in methodInfo\n where !method.IsSpecialName // Exclude Properties\n where method.DeclaringType != typeof(object)\n where method.Name != \"Equals\"\n select new { method.Name, method.ReturnType };\n\n // Assert\n Type[] expectedTypes =\n [\n typeof(AndConstraint>>),\n typeof(AndConstraint>)\n ];\n\n methods.Should().OnlyContain(method => expectedTypes.Any(e => e.IsAssignableFrom(method.ReturnType)));\n }\n\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var someCollection = new List { \"one\", \"two\", \"three\" };\n\n // Act\n Action action = () => someCollection.Should().Equals(someCollection);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Equals is not part of Awesome Assertions. Did you mean BeSameAs(), Equal(), or BeEquivalentTo() instead?\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeApproximately.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeApproximately\n {\n [Fact]\n public void When_approximating_a_nullable_double_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_approximating_two_nullable_doubles_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 3.14;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_nullable_double_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act / Assert\n value.Should().BeApproximately(3.14, 0.1);\n }\n\n [Fact]\n public void When_nullable_double_is_indeed_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 3.142;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void When_nullable_double_is_null_approximating_a_nullable_null_value_it_should_not_throw()\n {\n // Arrange\n double? value = null;\n double? expected = null;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void When_nullable_double_with_value_is_not_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n double? value = 13;\n double? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*12.0*0.1*13.0*\");\n }\n\n [Fact]\n public void When_nullable_double_is_null_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n double? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 12.0 +/- 0.1, but it was .\");\n }\n\n [Fact]\n public void When_nullable_double_is_not_null_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n double? value = 12;\n double? expected = null;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate +/- 0.1, but it was 12.0.\");\n }\n\n [Fact]\n public void When_nullable_double_has_no_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n value.Should().BeApproximately(3.14, 0.001);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 3.14 +/- 0.001, but it was .\");\n }\n\n [Fact]\n public void When_nullable_double_is_not_approximating_a_value_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(1.0, 0.1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to approximate 1.0 +/- 0.1, but 3.14* differed by*\");\n }\n\n [Fact]\n public void A_double_cannot_approximate_NaN()\n {\n // Arrange\n double? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.NaN, 0.1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_approximating_a_nullable_float_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_approximating_two_nullable_floats_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = 3.14F;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_nullable_float_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act / Assert\n value.Should().BeApproximately(3.14F, 0.1F);\n }\n\n [Fact]\n public void When_nullable_float_is_indeed_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n float? value = 3.1415927f;\n float? expected = 3.142f;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1f);\n }\n\n [Fact]\n public void When_nullable_float_is_null_approximating_a_nullable_null_value_it_should_not_throw()\n {\n // Arrange\n float? value = null;\n float? expected = null;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1f);\n }\n\n [Fact]\n public void When_nullable_float_with_value_is_not_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n float? value = 13;\n float? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1f);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*12*0.1*13*\");\n }\n\n [Fact]\n public void When_nullable_float_is_null_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n float? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1f);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 12F +/- 0.1F, but it was .\");\n }\n\n [Fact]\n public void When_nullable_float_is_not_null_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n float? value = 12;\n float? expected = null;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1f);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate +/- 0.1F, but it was 12F.\");\n }\n\n [Fact]\n public void When_nullable_float_has_no_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n value.Should().BeApproximately(3.14F, 0.001F);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 3.14F +/- 0.001F, but it was .\");\n }\n\n [Fact]\n public void When_nullable_float_is_not_approximating_a_value_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(1.0F, 0.1F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to approximate *1* +/- *0.1* but 3.14* differed by*\");\n }\n\n [Fact]\n public void A_float_cannot_approximate_NaN()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.NaN, 0.1F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_approximating_a_nullable_decimal_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14m, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_approximating_two_nullable_decimals_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 3.14m;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_nullable_decimal_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act / Assert\n value.Should().BeApproximately(3.14m, 0.1m);\n }\n\n [Fact]\n public void When_nullable_decimal_is_indeed_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 3.142m;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void When_nullable_decimal_is_null_approximating_a_nullable_null_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = null;\n decimal? expected = null;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void When_nullable_decimal_with_value_is_not_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n decimal? value = 13;\n decimal? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*12*0.1*13*\");\n }\n\n [Fact]\n public void When_nullable_decimal_is_null_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n decimal? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 12M +/- 0.1M, but it was .\");\n }\n\n [Fact]\n public void When_nullable_decimal_is_not_null_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n decimal? value = 12;\n decimal? expected = null;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate +/- 0.1M, but it was 12M.\");\n }\n\n [Fact]\n public void When_nullable_decimal_has_no_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n value.Should().BeApproximately(3.14m, 0.001m);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to approximate*3.14* +/-*0.001*, but it was .\");\n }\n\n [Fact]\n public void When_nullable_decimal_is_not_approximating_a_value_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().BeApproximately(1.0m, 0.1m);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to approximate*1.0* +/-*0.1*, but 3.14* differed by*\");\n }\n }\n\n public class NotBeApproximately\n {\n [Fact]\n public void When_not_approximating_a_nullable_double_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_not_approximating_two_nullable_doubles_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 3.14;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_is_not_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act / Assert\n value.Should().NotBeApproximately(1.0, 0.1);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_has_no_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14, 0.001);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_is_indeed_approximating_a_value_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, 0.1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to not approximate 3.14 +/- 0.1, but 3.14*only differed by*\");\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_nullable_double_is_not_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 1.0;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_is_not_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_null_double_is_not_approximating_a_nullable_double_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n double? expected = 20.0;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_null_double_is_not_approximating_a_null_value_it_should_not_throw()\n {\n // Arrange\n double? value = null;\n double? expected = null;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*null*0.1*but*null*\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_is_approximating_a_nullable_value_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 3.1;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_double_cannot_approximate_NaN()\n {\n // Arrange\n double? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.NaN, 0.1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_not_approximating_a_nullable_float_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_not_approximating_two_nullable_floats_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = 3.14F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_is_not_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act / Assert\n value.Should().NotBeApproximately(1.0F, 0.1F);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_has_no_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14F, 0.001F);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_is_indeed_approximating_a_value_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, 0.1F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to not approximate *3.14F* +/- *0.1F* but 3.14* only differed by*\");\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_nullable_float_is_not_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = 1.0F;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1F);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_is_not_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1F);\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_null_float_is_not_approximating_a_nullable_float_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n float? expected = 20.0f;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1F);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_null_float_is_not_approximating_a_null_value_it_should_not_throw()\n {\n // Arrange\n float? value = null;\n float? expected = null;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1F);\n\n // Assert\n act.Should().Throw(\"Expected**+/-*0.1F**\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_is_approximating_a_nullable_value_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = 3.1F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_float_cannot_approximate_NaN()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.NaN, 0.1F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_not_approximating_a_nullable_decimal_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14m, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_not_approximating_two_nullable_decimals_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 3.14m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_is_not_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act / Assert\n value.Should().NotBeApproximately(1.0m, 0.1m);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_has_no_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14m, 0.001m);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_is_indeed_approximating_a_value_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14m, 0.1m);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to not approximate*3.14* +/-*0.1*, but*3.14*only differed by*\");\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_nullable_decimal_is_not_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 1.0m;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_is_not_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_null_decimal_is_not_approximating_a_nullable_decimal_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n decimal? expected = 20.0m;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_null_decimal_is_not_approximating_a_null_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = null;\n decimal? expected = null;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected**0.1M**\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_is_approximating_a_nullable_value_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 3.1m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.BeEmpty.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void Should_fail_when_asserting_collection_with_items_is_empty()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().BeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_without_items_is_empty()\n {\n // Arrange\n IEnumerable collection = new string[0];\n\n // Act / Assert\n collection.Should().BeEmpty();\n }\n\n [Fact]\n public void When_asserting_collection_to_be_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().BeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_the_collection_is_not_empty_unexpectedly_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().BeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected collection to be empty because we want to test the failure message, but found at least one item*one*\");\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void When_asserting_collection_to_be_not_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().NotBeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_with_items_is_not_empty_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotBeEmpty();\n }\n\n [Fact]\n public void When_asserting_collection_without_items_is_not_empty_it_should_fail()\n {\n // Arrange\n IEnumerable collection = new string[0];\n\n // Act\n Action act = () => collection.Should().NotBeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_collection_without_items_is_not_empty_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n IEnumerable collection = new string[0];\n\n // Act\n Action act = () => collection.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to be empty because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/MaximumMatchingProblem.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// The class defines input for the maximum matching problem.\n/// The input is a list of predicates and a list of elements.\n/// The goal of the problem is to find such mapping between predicates and elements that would maximize number of matches.\n/// A predicate can be mapped with only one element.\n/// An element can be mapped with only one predicate.\n/// \n/// The type of elements which must be matched with predicates.\ninternal class MaximumMatchingProblem\n{\n public MaximumMatchingProblem(\n IEnumerable>> predicates,\n IEnumerable elements)\n {\n Predicates.AddRange(predicates.Select((predicate, index) => new Predicate(predicate, index)));\n Elements.AddRange(elements.Select((element, index) => new Element(element, index)));\n }\n\n public List> Predicates { get; } = [];\n\n public List> Elements { get; } = [];\n\n public MaximumMatchingSolution Solve() => new MaximumMatchingSolver(this).Solve();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveElementSucceeding.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveElementSucceeding specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveElementSucceeding\n {\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_collection_has_the_correct_element_succeeding_another_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementSucceeding(\"cris\", \"mick\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_collection_has_the_wrong_element_succeeding_another_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(\"mick\", \"cris\", \"because of some reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*succeed*mick*because*reason*found*john*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_nothing_is_succeeding_an_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(\"john\", \"jane\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*jane*succeed*john*found*nothing*\");\n }\n\n [Fact]\n public void When_expecting_an_element_to_succeed_another_but_the_collection_is_empty_it_should_throw()\n {\n // Arrange\n var collection = new string[0];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(\"mick\", \"cris\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*succeed*mick*collection*empty*\");\n }\n\n [Fact]\n public void When_a_null_element_is_succeeding_another_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementSucceeding(\"mick\", null);\n }\n\n [Fact]\n public void When_a_null_element_is_not_succeeding_another_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(\"mick\", null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*null*succeed*mick*but found*john*\");\n }\n\n [Fact]\n public void When_an_element_is_succeeding_a_null_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementSucceeding(null, \"john\");\n }\n\n [Fact]\n public void When_an_element_is_not_succeeding_a_null_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(null, \"cris\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*succeed*null*but found*john*\");\n }\n\n [Fact]\n public void When_collection_is_null_then_have_element_succeeding_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveElementSucceeding(\"mick\", \"cris\", \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to have \\\"cris\\\" succeed \\\"mick\\\" *failure message*, but the collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveExplicitProperty.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveExplicitProperty specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveExplicitProperty\n {\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_property_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitProperty(interfaceType, \"ExplicitStringProperty\");\n }\n\n [Fact]\n public void\n When_asserting_a_type_explicitly_implements_a_property_which_it_implements_implicitly_and_explicitly_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitProperty(interfaceType, \"ExplicitImplicitStringProperty\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_property_which_it_implements_implicitly_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitProperty(interfaceType, \"ImplicitStringProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to explicitly implement \" +\n \"*.IExplicitInterface.ImplicitStringProperty, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_property_which_it_does_not_implement_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitProperty(interfaceType, \"NonExistentProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to explicitly implement \" +\n \"*.IExplicitInterface.NonExistentProperty, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_property_from_an_unimplemented_interface_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitProperty(interfaceType, \"NonExistentProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassExplicitlyImplementingInterface to implement interface *.IDummyInterface\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_property_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(\n typeof(IExplicitInterface), \"ExplicitStringProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to explicitly implement *.IExplicitInterface.ExplicitStringProperty *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_property_inherited_by_null_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(null, \"ExplicitStringProperty\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(typeof(IExplicitInterface), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(typeof(IExplicitInterface), string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void Does_not_continue_assertion_on_explicit_interface_implementation_if_not_implemented_at_all()\n {\n var act = () =>\n {\n using var _ = new AssertionScope();\n typeof(int).Should().HaveExplicitProperty(typeof(IExplicitInterface), \"Foo\");\n };\n\n act.Should().Throw()\n .WithMessage(\"Expected type int to*implement *IExplicitInterface, but it does not.\");\n }\n }\n\n public class HaveExplicitPropertyOfT\n {\n [Fact]\n public void When_asserting_a_type_explicitlyOfT_implements_a_property_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitProperty(\"ExplicitStringProperty\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicitlyOfT_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicitlyOfT_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_propertyOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(\n \"ExplicitStringProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to explicitly implement *.IExplicitInterface.ExplicitStringProperty *failure message*\" +\n \", but type is .\");\n }\n }\n\n public class NotHaveExplicitProperty\n {\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_property_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"ExplicitStringProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitStringProperty, but it does.\");\n }\n\n [Fact]\n public void\n When_asserting_a_type_does_not_explicitly_implement_a_property_which_it_implements_implicitly_and_explicitly_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"ExplicitImplicitStringProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitImplicitStringProperty, but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_property_which_it_implements_implicitly_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"ImplicitStringProperty\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_property_which_it_does_not_implement_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"NonExistentProperty\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_property_from_an_unimplemented_interface_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"NonExistentProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassExplicitlyImplementingInterface to implement interface *.IDummyInterface\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_property_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(\n typeof(IExplicitInterface), \"ExplicitStringProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to not explicitly implement *IExplicitInterface.ExplicitStringProperty *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_property_inherited_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(null, \"ExplicitStringProperty\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(typeof(IExplicitInterface), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(typeof(IExplicitInterface), string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void Does_not_continue_assertion_on_explicit_interface_implementation_if_implemented()\n {\n var act = () =>\n {\n using var _ = new AssertionScope();\n typeof(ClassExplicitlyImplementingInterface)\n .Should().NotHaveExplicitProperty(typeof(IExplicitInterface), \"ExplicitStringProperty\");\n };\n\n act.Should().Throw()\n .WithMessage(\"Expected *ClassExplicitlyImplementingInterface* to*implement \" +\n \"*IExplicitInterface.ExplicitStringProperty, but it does.\");\n }\n }\n\n public class NotHaveExplicitPropertyOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_explicitlyOfT_implement_a_property_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitProperty(\"ExplicitStringProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitStringProperty, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_propertyOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(\n \"ExplicitStringProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to not explicitly implement *.IExplicitInterface.ExplicitStringProperty *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicitlyOfT_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicitlyOfT_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveElementPreceding.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveElementPreceding specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveElementPreceding\n {\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_collection_has_the_correct_element_preceding_another_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementPreceding(\"mick\", \"cris\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_collection_has_the_wrong_element_preceding_another_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(\"john\", \"cris\", \"because of some reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*precede*john*because*reason*found*mick*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_nothing_is_preceding_an_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(\"cris\", \"jane\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*jane*precede*cris*found*nothing*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_expecting_an_element_to_precede_another_but_collection_is_empty_it_should_throw()\n {\n // Arrange\n var collection = new string[0];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(\"mick\", \"cris\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*precede*mick*collection*empty*\");\n }\n\n [Fact]\n public void When_a_null_element_is_preceding_another_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [null, \"mick\", \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementPreceding(\"mick\", null);\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_a_null_element_is_not_preceding_another_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(\"mick\", null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*null*precede*mick*but found*cris*\");\n }\n\n [Fact]\n public void When_an_element_is_preceding_a_null_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementPreceding(null, \"mick\");\n }\n\n [Fact]\n public void When_an_element_is_not_preceding_a_null_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(null, \"cris\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*precede*null*but found*mick*\");\n }\n\n [Fact]\n public void When_collection_is_null_then_have_element_preceding_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveElementPreceding(\"mick\", \"cris\", \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to have \\\"cris\\\" precede \\\"mick\\\" *failure message*, but the collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/EnumerableExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class EnumerableExtensions\n{\n public static ICollection ConvertOrCastToCollection(this IEnumerable source)\n {\n return source as ICollection ?? source.ToList();\n }\n\n public static IList ConvertOrCastToList(this IEnumerable source)\n {\n return source as IList ?? source.ToList();\n }\n\n /// \n /// Searches for the first different element in two sequences using specified \n /// \n /// The type of the elements of the sequence.\n /// The type of the elements of the sequence.\n /// The first sequence to compare.\n /// The second sequence to compare.\n /// Method that is used to compare 2 elements with the same index.\n /// Index at which two sequences have elements that are not equal, or -1 if enumerables are equal\n public static int IndexOfFirstDifferenceWith(this IEnumerable first, IEnumerable second,\n Func equalityComparison)\n {\n using IEnumerator firstEnumerator = first.GetEnumerator();\n using IEnumerator secondEnumerator = second.GetEnumerator();\n int index = 0;\n\n while (true)\n {\n bool isFirstCompleted = !firstEnumerator.MoveNext();\n bool isSecondCompleted = !secondEnumerator.MoveNext();\n\n if (isFirstCompleted && isSecondCompleted)\n {\n return -1;\n }\n\n if (isFirstCompleted != isSecondCompleted)\n {\n return index;\n }\n\n if (!equalityComparison(firstEnumerator.Current, secondEnumerator.Current))\n {\n return index;\n }\n\n index++;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TypeFormattingExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\ninternal static class TypeFormattingExtensions\n{\n /// \n /// Gets a type which can be formatted to a type definition like Dictionary<TKey, TValue>\n /// \n /// The original type\n /// The type's definition if generic, or the original type.\n public static Type AsFormattableTypeDefinition(this Type type)\n {\n if (type is not null && type.IsGenericType && !type.IsGenericTypeDefinition)\n {\n return type.GetGenericTypeDefinition();\n }\n\n return type;\n }\n\n /// \n /// Gets a type which can be formatted to a type definition like Dictionary<TKey, TValue> without namespaces.\n /// \n /// The original type\n /// A value representing the type's definition if generic, or the original type for formatting.\n public static object AsFormattableShortTypeDefinition(this Type type)\n {\n if (type is null)\n {\n return null;\n }\n\n return new ShortTypeValue(type.AsFormattableTypeDefinition());\n }\n\n /// \n /// Gets a wrapper for formatting a type without namespaces.\n /// \n /// The original type\n /// A value representing the incoming type for formatting without namespaces.\n public static ShortTypeValue AsFormattableShortType(this Type type) =>\n type is null ? null : new ShortTypeValue(type);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class ChainingConstraint\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n DateTimeOffset yesterday = new DateTime(2016, 06, 03).ToDateTimeOffset();\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTime.Should()\n .HaveValue()\n .And\n .BeAfter(yesterday);\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n DateTimeOffset someDateTimeOffset = new(2022, 9, 25, 13, 48, 42, 0, TimeSpan.Zero);\n\n // Act\n var action = () => someDateTimeOffset.Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/CollectionEqualBenchmarks.cs", "using System.Collections.Generic;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Common;\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Jobs;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\n[SimpleJob(RuntimeMoniker.Net472)]\n[SimpleJob(RuntimeMoniker.Net80)]\npublic class CollectionEqualBenchmarks\n{\n private IEnumerable collection1;\n private IEnumerable collection2;\n\n [Params(10, 100, 1_000, 5_000, 10_000)]\n public int N { get; set; }\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n collection1 = new int[N];\n collection2 = new int[N];\n }\n\n [Benchmark(Baseline = true)]\n public void CollectionEqual_Generic()\n {\n collection1.Should().Equal(collection2);\n }\n\n [Benchmark]\n public void CollectionEqual_Optimized()\n {\n collection1.Should().Equal(collection2, ObjectExtensions.GetComparer());\n }\n\n [Benchmark]\n public void CollectionEqual_CustomComparer()\n {\n collection1.Should().Equal(collection2, (a, b) => a == b);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.Be.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_timeonly_value_is_equal_to_the_same_value()\n {\n // Arrange\n TimeOnly timeOnly = new(15, 06, 04, 146);\n TimeOnly sameTimeOnly = new(15, 06, 04, 146);\n\n // Act/Assert\n timeOnly.Should().Be(sameTimeOnly);\n }\n\n [Fact]\n public void When_timeonly_value_is_equal_to_the_same_nullable_value_be_should_succeed()\n {\n // Arrange\n TimeOnly timeOnly = new(15, 06, 04, 146);\n TimeOnly? sameTimeOnly = new(15, 06, 04, 146);\n\n // Act/Assert\n timeOnly.Should().Be(sameTimeOnly);\n }\n\n [Fact]\n public void When_both_values_are_at_their_minimum_then_it_should_succeed()\n {\n // Arrange\n TimeOnly timeOnly = TimeOnly.MinValue;\n TimeOnly sameTimeOnly = TimeOnly.MinValue;\n\n // Act/Assert\n timeOnly.Should().Be(sameTimeOnly);\n }\n\n [Fact]\n public void When_both_values_are_at_their_maximum_then_it_should_succeed()\n {\n // Arrange\n TimeOnly timeOnly = TimeOnly.MaxValue;\n TimeOnly sameTimeOnly = TimeOnly.MaxValue;\n\n // Act/Assert\n timeOnly.Should().Be(sameTimeOnly);\n }\n\n [Fact]\n public void Should_fail_when_asserting_timeonly_value_is_equal_to_the_different_value()\n {\n // Arrange\n var timeOnly = new TimeOnly(15, 03, 10);\n var otherTimeOnly = new TimeOnly(15, 03, 11);\n\n // Act\n Action act = () => timeOnly.Should().Be(otherTimeOnly, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected timeOnly to be <15:03:11.000>*failure message, but found <15:03:10.000>.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_timeonly_value_is_equal_to_the_different_value_by_milliseconds()\n {\n // Arrange\n var timeOnly = new TimeOnly(15, 03, 10, 556);\n var otherTimeOnly = new TimeOnly(15, 03, 10, 175);\n\n // Act\n Action act = () => timeOnly.Should().Be(otherTimeOnly, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected timeOnly to be <15:03:10.175>*failure message, but found <15:03:10.556>.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_equals_the_same_value()\n {\n // Arrange\n TimeOnly? nullableTimeOnlyA = new TimeOnly(15, 06, 04, 123);\n TimeOnly? nullableTimeOnlyB = new TimeOnly(15, 06, 04, 123);\n\n // Act/Assert\n nullableTimeOnlyA.Should().Be(nullableTimeOnlyB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_null_value_equals_null()\n {\n // Arrange\n TimeOnly? nullableTimeOnlyA = null;\n TimeOnly? nullableTimeOnlyB = null;\n\n // Act/Assert\n nullableTimeOnlyA.Should().Be(nullableTimeOnlyB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n TimeOnly? nullableTimeOnlyA = new TimeOnly(15, 06, 04);\n TimeOnly? nullableTimeOnlyB = new TimeOnly(15, 06, 06);\n\n // Act\n Action action = () =>\n nullableTimeOnlyA.Should().Be(nullableTimeOnlyB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_timeonly_null_value_is_equal_to_another_value()\n {\n // Arrange\n TimeOnly? nullableTimeOnly = null;\n\n // Act\n Action action = () =>\n nullableTimeOnly.Should().Be(new TimeOnly(15, 06, 04), \"because we want to test the failure {0}\",\n \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableTimeOnly to be <15:06:04.000> because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_timeonly_value_is_not_equal_to_a_different_value()\n {\n // Arrange\n TimeOnly timeOnly = new(15, 06, 04);\n TimeOnly otherTimeOnly = new(15, 06, 05);\n\n // Act/Assert\n timeOnly.Should().NotBe(otherTimeOnly);\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Different_timeonly_values_are_valid()\n {\n // Arrange\n TimeOnly time = new(19, 06, 04);\n TimeOnly otherTime = new(20, 06, 05);\n\n // Act & Assert\n time.Should().NotBe(otherTime);\n }\n\n [Fact]\n public void Different_timeonly_values_with_different_nullability_are_valid()\n {\n // Arrange\n TimeOnly time = new(19, 06, 04);\n TimeOnly? otherTime = new(19, 07, 05);\n\n // Act & Assert\n time.Should().NotBe(otherTime);\n }\n\n [Fact]\n public void Same_timeonly_values_are_invalid()\n {\n // Arrange\n TimeOnly time = new(19, 06, 04);\n TimeOnly sameTime = new(19, 06, 04);\n\n // Act\n Action act =\n () => time.Should().NotBe(sameTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time not to be <19:06:04.000> because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void Same_timeonly_values_with_different_nullability_are_invalid()\n {\n // Arrange\n TimeOnly time = new(19, 06, 04);\n TimeOnly? sameTime = new(19, 06, 04);\n\n // Act\n Action act =\n () => time.Should().NotBe(sameTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time not to be <19:06:04.000> because we want to test the failure message, but it is.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveExplicitMethod.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveExplicitMethod specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveExplicitMethod\n {\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_method_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitMethod(interfaceType, \"ExplicitMethod\", new Type[0]);\n }\n\n [Fact]\n public void\n When_asserting_a_type_explicitly_implements_a_method_which_it_implements_implicitly_and_explicitly_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitMethod(interfaceType, \"ExplicitImplicitMethod\", new Type[0]);\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_method_which_it_implements_implicitly_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitMethod(interfaceType, \"ImplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to explicitly implement \" +\n \"*.IExplicitInterface.ImplicitMethod(), but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_method_which_it_does_not_implement_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitMethod(interfaceType, \"NonExistentMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to explicitly implement \" +\n \"*.IExplicitInterface.NonExistentMethod(), but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_method_from_an_unimplemented_interface_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitMethod(interfaceType, \"NonExistentProperty\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassExplicitlyImplementingInterface to implement interface \" +\n \"*.IDummyInterface, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_method_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(\n typeof(IExplicitInterface), \"ExplicitMethod\", new Type[0], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to explicitly implement *.IExplicitInterface.ExplicitMethod() *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_method_with_a_null_interface_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(null, \"ExplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_method_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(typeof(IExplicitInterface), \"ExplicitMethod\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_method_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(typeof(IExplicitInterface), null, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_method_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(typeof(IExplicitInterface), string.Empty, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void Does_not_continue_assertion_on_explicit_interface_implementation_if_not_implemented_at_all()\n {\n var act = () =>\n {\n using var _ = new AssertionScope();\n typeof(ClassWithMembers).Should().HaveExplicitMethod(typeof(IExplicitInterface), \"Foo\", new Type[0]);\n };\n\n act.Should().Throw()\n .WithMessage(\"Expected type *ClassWithMembers* to*implement *IExplicitInterface, but it does not.\");\n }\n }\n\n public class HaveExplicitMethodOfT\n {\n [Fact]\n public void When_asserting_a_type_explicitly_implementsOfT_a_method_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitMethod(\"ExplicitMethod\", new Type[0]);\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_methodOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(\n \"ExplicitMethod\", new Type[0], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to explicitly implement *.IExplicitInterface.ExplicitMethod() *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_methodOfT_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(\"ExplicitMethod\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_methodOfT_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(null, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_methodOfT_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(string.Empty, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n\n public class NotHaveExplicitMethod\n {\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_method_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"ExplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitMethod(), but it does.\");\n }\n\n [Fact]\n public void\n When_asserting_a_type_does_not_explicitly_implement_a_method_which_it_implements_implicitly_and_explicitly_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"ExplicitImplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitImplicitMethod(), but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_method_which_it_implements_implicitly_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"ImplicitMethod\", new Type[0]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_method_which_it_does_not_implement_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"NonExistentMethod\", new Type[0]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_method_from_an_unimplemented_interface_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"NonExistentMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassExplicitlyImplementingInterface to implement interface *.IDummyInterface\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_method_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(\n typeof(IExplicitInterface), \"ExplicitMethod\", new Type[0], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to not explicitly implement *.IExplicitInterface.ExplicitMethod() *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_method_inherited_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(null, \"ExplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_method_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(typeof(IExplicitInterface), \"ExplicitMethod\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_method_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(typeof(IExplicitInterface), null, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_method_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(typeof(IExplicitInterface), string.Empty, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void Does_not_continue_assertion_on_explicit_interface_implementation_if_implemented()\n {\n var act = () =>\n {\n using var _ = new AssertionScope();\n typeof(ClassExplicitlyImplementingInterface)\n .Should().NotHaveExplicitMethod(typeof(IExplicitInterface), \"ExplicitMethod\", new Type[0]);\n };\n\n act.Should().Throw()\n .WithMessage(\"Expected *ClassExplicitlyImplementingInterface* to not*implement \" +\n \"*IExplicitInterface.ExplicitMethod(), but it does.\");\n }\n }\n\n public class NotHaveExplicitMethodOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implementOfT_a_method_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitMethod(\"ExplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitMethod(), but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_methodOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(\n \"ExplicitMethod\", new Type[0], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to not explicitly implement *.IExplicitInterface.ExplicitMethod() *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_methodOfT_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(\"ExplicitMethod\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_methodOfT_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(null, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_methodOfT_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(string.Empty, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/FormattingOptions.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class FormattingOptions\n{\n internal List ScopedFormatters { get; set; } = [];\n\n /// \n /// Indicates whether the formatter should use line breaks when the supports it.\n /// \n /// \n /// This property is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public bool UseLineBreaks { get; set; }\n\n /// \n /// Determines the depth until which the library should try to render an object graph.\n /// \n /// \n /// This property is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n /// \n /// A depth of 1 will only the display the members of the root object.\n /// \n public int MaxDepth { get; set; } = 5;\n\n /// \n /// Sets the maximum number of lines of the failure message.\n /// \n /// \n /// \n /// Because of technical reasons, the actual output may be one or two lines longer.\n /// \n /// \n /// This property is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n /// \n public int MaxLines { get; set; } = 100;\n\n /// \n /// Sets the default number of characters shown when printing the difference of two strings.\n /// \n /// \n /// \n /// The actual number of shown characters depends on the word-boundary-algorithm.
\n /// This algorithm searches for a word boundary (a blank) in the range from 5 characters previous and 10 characters after the\n /// . If found it displays a full word, otherwise it falls back to the .\n ///
\n /// \n /// This property is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n ///
\n public int StringPrintLength { get; set; } = 50;\n\n /// \n /// Removes a scoped formatter that was previously added through .\n /// \n /// A custom implementation of \n public void RemoveFormatter(IValueFormatter formatter)\n {\n ScopedFormatters.Remove(formatter);\n }\n\n /// \n /// Ensures a scoped formatter is included in the chain, which is executed before the static custom formatters and the default formatters.\n /// This also lasts only for the current until disposal.\n /// \n /// A custom implementation of \n public void AddFormatter(IValueFormatter formatter)\n {\n if (!ScopedFormatters.Contains(formatter))\n {\n ScopedFormatters.Insert(0, formatter);\n }\n }\n\n internal FormattingOptions Clone()\n {\n return new FormattingOptions\n {\n UseLineBreaks = UseLineBreaks,\n MaxDepth = MaxDepth,\n MaxLines = MaxLines,\n StringPrintLength = StringPrintLength,\n ScopedFormatters = [.. ScopedFormatters],\n };\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveAccessModifier.cs", "using System;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveAccessModifier specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveAccessModifier\n {\n [Fact]\n public void When_asserting_a_public_type_is_public_it_succeeds()\n {\n // Arrange\n Type type = typeof(IPublicInterface);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_internal_it_throws()\n {\n // Arrange\n Type type = typeof(IPublicInterface);\n\n // Act\n Action act = () =>\n type\n .Should()\n .HaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.IPublicInterface to be Internal *failure message*, but it is Public.\");\n }\n\n [Fact]\n public void An_internal_class_has_an_internal_access_modifier()\n {\n // Arrange\n Type type = typeof(InternalClass);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void An_internal_interface_has_an_internal_access_modifier()\n {\n // Arrange\n Type type = typeof(IInternalInterface);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void An_internal_struct_has_an_internal_access_modifier()\n {\n // Arrange\n Type type = typeof(InternalStruct);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void An_internal_enum_has_an_internal_access_modifier()\n {\n // Arrange\n Type type = typeof(InternalEnum);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void An_internal_class_does_not_have_a_protected_internal_modifier()\n {\n // Arrange\n Type type = typeof(InternalClass);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.InternalClass to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void A_failing_check_for_a_modifier_of_a_generic_class_includes_the_type_definition_in_the_failure_message()\n {\n // Arrange\n Type type = typeof(GenericClass);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.Private, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.GenericClass to be Private *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void An_internal_interface_does_not_have_a_protected_internal_modifier()\n {\n // Arrange\n Type type = typeof(IInternalInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type AwesomeAssertions.Specs.Types.IInternalInterface to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void An_internal_struct_does_not_have_a_protected_internal_modifier()\n {\n // Arrange\n Type type = typeof(InternalStruct);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.InternalStruct to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void An_internal_enum_does_not_have_a_protected_internal_modifier()\n {\n // Arrange\n Type type = typeof(InternalEnum);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.InternalEnum to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_private_type_is_private_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"PrivateClass\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_nested_private_type_is_protected_it_throws()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"PrivateClass\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(CSharpAccessModifier.Protected, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+PrivateClass to be Protected *failure message*, but it is Private.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_type_is_protected_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"ProtectedEnum\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_type_is_public_it_throws()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"ProtectedEnum\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(CSharpAccessModifier.Public);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+ProtectedEnum to be Public, but it is Protected.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_public_type_is_public_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.IPublicInterface);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_nested_public_member_is_internal_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.IPublicInterface);\n\n // Act\n Action act = () =>\n type\n .Should()\n .HaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+IPublicInterface to be Internal *failure message*, but it is Public.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_internal_type_is_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.InternalClass);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void When_asserting_a_nested_internal_type_is_protected_internal_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.InternalClass);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+InternalClass to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_internal_member_is_protected_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.IProtectedInternalInterface);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_internal_member_is_private_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.IProtectedInternalInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(CSharpAccessModifier.Private, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type AwesomeAssertions.Specs.Types.Nested+IProtectedInternalInterface to be Private *failure message*, but it is ProtectedInternal.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_access_modifier_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be Public *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_access_modifier_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n\n public class NotHaveAccessModifier\n {\n [Fact]\n public void When_asserting_a_public_type_is_not_private_it_succeeds()\n {\n // Arrange\n Type type = typeof(IPublicInterface);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_not_public_it_throws()\n {\n // Arrange\n Type type = typeof(IPublicInterface);\n\n // Act\n Action act = () =>\n type\n .Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.IPublicInterface not to be Public *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_an_internal_type_is_not_protected_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(InternalClass);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_an_internal_type_is_not_internal_it_throws()\n {\n // Arrange\n Type type = typeof(InternalClass);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.InternalClass not to be Internal *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_private_type_is_not_protected_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"PrivateClass\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_nested_private_type_is_not_private_it_throws()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"PrivateClass\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Private, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+PrivateClass not to be Private *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_type_is_not_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"ProtectedEnum\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_type_is_not_protected_it_throws()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"ProtectedEnum\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Protected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+ProtectedEnum not to be Protected, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_public_type_is_not_private_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.IPublicInterface);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_nested_public_member_is_not_public_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.IPublicInterface);\n\n // Act\n Action act = () =>\n type\n .Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+IPublicInterface not to be Public *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_internal_type_is_not_protected_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.InternalClass);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_a_nested_internal_type_is_not_internal_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.InternalClass);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+InternalClass not to be Internal *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_internal_member_is_not_public_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.IProtectedInternalInterface);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_internal_member_is_not_protected_internal_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.IProtectedInternalInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type AwesomeAssertions.Specs.Types.Nested+IProtectedInternalInterface not to be ProtectedInternal *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_access_modifier_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be Public *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_access_modifier_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.Be.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_dateonly_value_is_equal_to_the_same_value()\n {\n // Arrange\n DateOnly dateOnly = new(2016, 06, 04);\n DateOnly sameDateOnly = new(2016, 06, 04);\n\n // Act/Assert\n dateOnly.Should().Be(sameDateOnly);\n }\n\n [Fact]\n public void When_dateonly_value_is_equal_to_the_same_nullable_value_be_should_succeed()\n {\n // Arrange\n DateOnly dateOnly = new(2016, 06, 04);\n DateOnly? sameDateOnly = new(2016, 06, 04);\n\n // Act/Assert\n dateOnly.Should().Be(sameDateOnly);\n }\n\n [Fact]\n public void When_both_values_are_at_their_minimum_then_it_should_succeed()\n {\n // Arrange\n DateOnly dateOnly = DateOnly.MinValue;\n DateOnly sameDateOnly = DateOnly.MinValue;\n\n // Act/Assert\n dateOnly.Should().Be(sameDateOnly);\n }\n\n [Fact]\n public void When_both_values_are_at_their_maximum_then_it_should_succeed()\n {\n // Arrange\n DateOnly dateOnly = DateOnly.MaxValue;\n DateOnly sameDateOnly = DateOnly.MaxValue;\n\n // Act/Assert\n dateOnly.Should().Be(sameDateOnly);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dateonly_value_is_equal_to_the_different_value()\n {\n // Arrange\n var dateOnly = new DateOnly(2012, 03, 10);\n var otherDateOnly = new DateOnly(2012, 03, 11);\n\n // Act\n Action act = () => dateOnly.Should().Be(otherDateOnly, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dateOnly to be <2012-03-11>*failure message, but found <2012-03-10>.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_equals_the_same_value()\n {\n // Arrange\n DateOnly? nullableDateOnlyA = new DateOnly(2016, 06, 04);\n DateOnly? nullableDateOnlyB = new DateOnly(2016, 06, 04);\n\n // Act/Assert\n nullableDateOnlyA.Should().Be(nullableDateOnlyB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_null_value_equals_null()\n {\n // Arrange\n DateOnly? nullableDateOnlyA = null;\n DateOnly? nullableDateOnlyB = null;\n\n // Act/Assert\n nullableDateOnlyA.Should().Be(nullableDateOnlyB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n DateOnly? nullableDateOnlyA = new DateOnly(2016, 06, 04);\n DateOnly? nullableDateOnlyB = new DateOnly(2016, 06, 06);\n\n // Act\n Action action = () =>\n nullableDateOnlyA.Should().Be(nullableDateOnlyB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_dateonly_null_value_is_equal_to_another_value()\n {\n // Arrange\n DateOnly? nullableDateOnly = null;\n\n // Act\n Action action = () =>\n nullableDateOnly.Should().Be(new DateOnly(2016, 06, 04), \"because we want to test the failure {0}\",\n \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateOnly to be <2016-06-04> because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dateonly_value_is_not_equal_to_a_different_value()\n {\n // Arrange\n DateOnly dateOnly = new(2016, 06, 04);\n DateOnly otherDateOnly = new(2016, 06, 05);\n\n // Act/Assert\n dateOnly.Should().NotBe(otherDateOnly);\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Different_dateonly_values_are_valid()\n {\n // Arrange\n DateOnly date = new(2020, 06, 04);\n DateOnly otherDate = new(2020, 06, 05);\n\n // Act & Assert\n date.Should().NotBe(otherDate);\n }\n\n [Fact]\n public void Different_dateonly_values_with_different_nullability_are_valid()\n {\n // Arrange\n DateOnly date = new(2020, 06, 04);\n DateOnly? otherDate = new(2020, 07, 05);\n\n // Act & Assert\n date.Should().NotBe(otherDate);\n }\n\n [Fact]\n public void Same_dateonly_values_are_invalid()\n {\n // Arrange\n DateOnly date = new(2020, 06, 04);\n DateOnly sameDate = new(2020, 06, 04);\n\n // Act\n Action act =\n () => date.Should().NotBe(sameDate, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected date not to be <2020-06-04> because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void Same_dateonly_values_with_different_nullability_are_invalid()\n {\n // Arrange\n DateOnly date = new(2020, 06, 04);\n DateOnly? sameDate = new(2020, 06, 04);\n\n // Act\n Action act =\n () => date.Should().NotBe(sameDate, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected date not to be <2020-06-04> because we want to test the failure message, but it is.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.Match.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]Match specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class Match\n {\n [Fact]\n public void When_a_string_does_not_match_a_wildcard_pattern_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().Match(\"h*earth!\", \"that's the universal greeting\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected subject to match*\\\"h*earth!\\\" because that's the universal greeting, but*\\\"hello world!\\\" does not.\");\n }\n\n [Fact]\n public void When_a_string_does_match_a_wildcard_pattern_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n subject.Should().Match(\"h*world?\");\n }\n\n [Fact]\n public void When_a_string_does_not_match_a_wildcard_pattern_with_escaped_markers_it_should_throw()\n {\n // Arrange\n string subject = \"What! Are you deaf!\";\n\n // Act\n Action act = () => subject.Should().Match(@\"What\\? Are you deaf\\?\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match*\\\"What\\\\? Are you deaf\\\\?\\\", but*\\\"What! Are you deaf!\\\" does not.\");\n }\n\n [Fact]\n public void When_a_string_does_match_a_wildcard_pattern_but_differs_in_casing_it_should_throw()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().Match(\"*World*\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match*\\\"*World*\\\", but*\\\"hello world\\\" does not.\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_null_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().Match(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a wildcard pattern or use the BeNull method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void Null_does_not_match_to_any_string()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () => subject.Should().Match(\"*\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match *, but found .\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_empty_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().Match(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n }\n\n public class NotMatch\n {\n [Fact]\n public void When_a_string_does_not_match_a_pattern_and_it_shouldnt_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act / Assert\n subject.Should().NotMatch(\"*World*\");\n }\n\n [Fact]\n public void When_a_string_does_match_a_pattern_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatch(\"*world*\", \"because that's illegal\");\n\n // Assert\n act\n .Should().Throw().WithMessage(\n \"Did not expect subject to match*\\\"*world*\\\" because that's illegal, but*\\\"hello world\\\" matches.\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_null_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatch(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_empty_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatch(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.BeOneOf.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateOnly value = new(2016, 12, 20);\n\n // Act\n Action action = () => value.Should().BeOneOf(value.AddDays(1), value.AddMonths(-1));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<2016-12-21>, <2016-11-20>}, but found <2016-12-20>.\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n DateOnly value = new(2016, 12, 20);\n\n // Act\n Action action = () =>\n value.Should().BeOneOf(new[] { value.AddDays(1), value.AddDays(2) }, \"because it's true\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected value to be one of {<2016-12-21>, <2016-12-22>} because it's true, but found <2016-12-20>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n DateOnly value = new(2016, 12, 30);\n\n // Act/Assert\n value.Should().BeOneOf(new DateOnly(2216, 1, 30), new DateOnly(2016, 12, 30));\n }\n\n [Fact]\n public void When_a_null_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateOnly? value = null;\n\n // Act\n Action action = () => value.Should().BeOneOf(new DateOnly(2216, 1, 30), new DateOnly(1116, 4, 10));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<2216-01-30>, <1116-04-10>}, but found .\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_dateonly_is_null()\n {\n // Arrange\n DateOnly? value = null;\n\n // Act/Assert\n value.Should().BeOneOf(new DateOnly(2216, 1, 30), null);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/IgnoringFailuresAssertionStrategy.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\ninternal class IgnoringFailuresAssertionStrategy : IAssertionStrategy\n{\n public IEnumerable FailureMessages => new string[0];\n\n public void HandleFailure(string message)\n {\n }\n\n public IEnumerable DiscardFailures() => new string[0];\n\n public void ThrowIfAny(IDictionary context)\n {\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveProperty.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveProperty specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveProperty\n {\n [Fact]\n public void When_asserting_a_type_has_a_property_of_expected_type_and_name_which_it_does_then_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveProperty(typeof(string), \"PrivateWriteProtectedReadProperty\")\n .Which.Should()\n .BeWritable(CSharpAccessModifier.Private)\n .And.BeReadable(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_of_expected_name_which_it_does_then_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveProperty(\"PrivateWriteProtectedReadProperty\")\n .Which.Should()\n .BeWritable(CSharpAccessModifier.Private)\n .And.BeReadable(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void The_name_of_the_property_is_passed_to_the_chained_assertion()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () => type\n .Should().HaveProperty(typeof(string), \"PrivateWriteProtectedReadProperty\")\n .Which.Should().NotBeWritable();\n\n // Assert\n act.Should().Throw(\"Expected property PrivateWriteProtectedReadProperty not to have a setter.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_which_it_does_not_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(typeof(string), \"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected AwesomeAssertions.*ClassWithNoMembers to have a property PublicProperty of type String because we want to test the failure message, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_expected_name_which_it_does_not_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(\"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected AwesomeAssertions.*ClassWithNoMembers to have a property PublicProperty because we want to test the failure message, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_which_it_has_with_a_different_type_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveProperty(typeof(int), \"PrivateWriteProtectedReadProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property PrivateWriteProtectedReadProperty \" +\n \"to be of type int because we want to test the failure message, but it is not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_property_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(typeof(string), \"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot determine if a type has a property named PublicProperty if the type is .\");\n }\n\n [Fact]\n public void When_subject_is_null_have_property_by_name_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(\"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot determine if a type has a property named PublicProperty if the type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_of_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty((Type)null, \"PublicProperty\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"propertyType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_valid_type_and_a_null_name_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(typeof(string), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_valid_type_and_an_empty_name_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(typeof(string), string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n\n public class HavePropertyOfT\n {\n [Fact]\n public void When_asserting_a_type_has_a_propertyOfT_which_it_does_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveProperty(\"PrivateWriteProtectedReadProperty\")\n .Which.Should()\n .BeWritable(CSharpAccessModifier.Private)\n .And.BeReadable(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_propertyOfT_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_propertyOfT_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n\n public class NotHaveProperty\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_a_property_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act / Assert\n type.Should().NotHaveProperty(\"Property\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_property_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveProperty(\"PrivateWriteProtectedReadProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect AwesomeAssertions.*.ClassWithMembers to have a property PrivateWriteProtectedReadProperty because we want to test the failure message, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_property_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveProperty(\"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot determine if a type has an unexpected property named PublicProperty if the type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/DictionaryExtensions.cs", "using System;\nusing System.Collections.Generic;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\ninternal static class DictionaryExtensions\n{\n public static void Add(this IDictionary> dictionary, TKey key, TValue value) =>\n dictionary.GetOrAdd(key).Add(value);\n\n public static TValue GetOrAdd(this IDictionary dictionary, TKey key)\n where TValue : new() =>\n dictionary.GetOrAdd(key, static () => new TValue());\n\n public static TValue GetOrAdd(this IDictionary dictionary, TKey key, Func newValue)\n {\n if (!dictionary.TryGetValue(key, out TValue result))\n {\n result = newValue();\n dictionary[key] = result;\n }\n\n return result;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeLessThanOrEqualTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void When_a_value_is_less_than_or_equal_to_greater_value_it_should_not_throw()\n {\n // Arrange\n int value = 1;\n int greaterValue = 2;\n\n // Act / Assert\n value.Should().BeLessThanOrEqualTo(greaterValue);\n }\n\n [Fact]\n public void When_a_value_is_less_than_or_equal_to_same_value_it_should_not_throw()\n {\n // Arrange\n int value = 2;\n int sameValue = 2;\n\n // Act / Assert\n value.Should().BeLessThanOrEqualTo(sameValue);\n }\n\n [Fact]\n public void When_a_value_is_less_than_or_equal_to_smaller_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(smallerValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_less_than_or_equal_to_smaller_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act\n Action act = () =>\n value.Should().BeLessThanOrEqualTo(smallerValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be less than or equal to 1 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_less_than_or_equal_to_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_or_equal_to_another_float()\n {\n // Act\n Action act = () => float.NaN.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_can_never_be_less_than_or_equal_to_NaN()\n {\n // Act\n Action act = () => 3.4F.Should().BeLessThanOrEqualTo(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_or_equal_to_another_double()\n {\n // Act\n Action act = () => double.NaN.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_less_than_or_equal_to_NaN()\n {\n // Act\n Action act = () => 3.4D.Should().BeLessThanOrEqualTo(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n int value = 1;\n int greaterValue = 2;\n\n // Act / Assert\n value.Should().BeLessThanOrEqualTo(greaterValue).And.Be(1);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeGreaterThanOrEqualTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void When_a_value_is_greater_than_or_equal_to_smaller_value_it_should_not_throw()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act / Assert\n value.Should().BeGreaterThanOrEqualTo(smallerValue);\n }\n\n [Fact]\n public void When_a_value_is_greater_than_or_equal_to_same_value_it_should_not_throw()\n {\n // Arrange\n int value = 2;\n int sameValue = 2;\n\n // Act / Assert\n value.Should().BeGreaterThanOrEqualTo(sameValue);\n }\n\n [Fact]\n public void When_a_value_is_greater_than_or_equal_to_greater_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(greaterValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_greater_than_or_equal_to_greater_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n\n // Act\n Action act =\n () => value.Should()\n .BeGreaterThanOrEqualTo(greaterValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than or equal to 3 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_greater_than_or_equal_to_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_or_equal_to_another_float()\n {\n // Act\n Action act = () => float.NaN.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_cannot_be_greater_than_or_equal_to_NaN()\n {\n // Act\n Action act = () => 3.4F.Should().BeGreaterThanOrEqualTo(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_or_equal_to_another_double()\n {\n // Act\n Action act = () => double.NaN.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_greater_or_equal_to_NaN()\n {\n // Act\n Action act = () => 3.4D.Should().BeGreaterThanOrEqualTo(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act / Assert\n value.Should().BeGreaterThanOrEqualTo(smallerValue).And.Be(2);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveIndexer.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveIndexer specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveIndexer\n {\n [Fact]\n public void When_asserting_a_type_has_an_indexer_which_it_does_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveIndexer(typeof(string), [typeof(string)])\n .Which.Should()\n .BeWritable(CSharpAccessModifier.Internal)\n .And.BeReadable(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_indexer_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(\n typeof(string), [typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected string *ClassWithNoMembers[int, System.Type] to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_indexer_with_different_parameters_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(\n typeof(string), [typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected string *.ClassWithMembers[int, System.Type] to exist *failure message*, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_indexer_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(typeof(string), [typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string type[string] to exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_indexer_for_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(null, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"indexerType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_indexer_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(typeof(string), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n\n public class NotHaveIndexer\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_indexer_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act / Assert\n type.Should().NotHaveIndexer([typeof(string)]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_indexer_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveIndexer([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected indexer *.ClassWithMembers[string] to not exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_indexer_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveIndexer([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected indexer type[string] to not exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_indexer_for_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveIndexer(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Common/MemberInfoExtensions.cs", "using System;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Specs.Common;\n\ninternal static class MemberInfoExtensions\n{\n public static Type GetUnderlyingType(this MemberInfo member)\n {\n return member.MemberType switch\n {\n MemberTypes.Event => ((EventInfo)member).EventHandlerType,\n MemberTypes.Field => ((FieldInfo)member).FieldType,\n MemberTypes.Method => ((MethodInfo)member).ReturnType,\n MemberTypes.Property => ((PropertyInfo)member).PropertyType,\n _ => throw new ArgumentException(\n \"Input MemberInfo must be if type EventInfo, FieldInfo, MethodInfo, or PropertyInfo\")\n };\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.Match.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class Match\n {\n [Fact]\n public void When_value_satisfies_predicate_it_should_not_throw()\n {\n // Arrange\n int value = 1;\n\n // Act / Assert\n value.Should().Match(o => o > 0);\n }\n\n [Fact]\n public void When_value_does_not_match_the_predicate_it_should_throw()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action act = () => value.Should().Match(o => o == 0, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to match (o == 0) because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void When_value_is_matched_against_a_null_it_should_throw()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action act = () => value.Should().Match(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/IStringComparisonStrategy.cs", "using AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// The strategy used for comparing two s.\n/// \ninternal interface IStringComparisonStrategy\n{\n /// \n /// The prefix for the message when the assertion fails.\n /// \n string ExpectationDescription { get; }\n\n /// \n /// Asserts that the matches the value.\n /// \n void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/DateTimeOffsetValueFormatterSpecs.cs", "using System;\nusing System.Globalization;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class DateTimeOffsetValueFormatterSpecs\n{\n [Fact]\n public void When_time_is_not_relevant_it_should_not_be_included_in_the_output()\n {\n // Act\n string result = Formatter.ToString(new DateTime(1973, 9, 20));\n\n // Assert\n result.Should().Be(\"<1973-09-20>\");\n }\n\n [Fact]\n public void When_the_offset_is_not_relevant_it_should_not_be_included_in_the_output()\n {\n // Act\n string result = Formatter.ToString(new DateTime(1973, 9, 20, 12, 59, 59));\n\n // Assert\n result.Should().Be(\"<1973-09-20 12:59:59>\");\n }\n\n [Fact]\n public void When_the_offset_is_negative_it_should_include_it_in_the_output()\n {\n // Arrange\n DateTimeOffset date = new(1973, 9, 20, 12, 59, 59, -3.Hours());\n\n // Act\n string result = Formatter.ToString(date);\n\n // Assert\n result.Should().Be(\"<1973-09-20 12:59:59 -3h>\");\n }\n\n [Fact]\n public void When_the_offset_is_positive_it_should_include_it_in_the_output()\n {\n // Arrange / Act\n string result = Formatter.ToString(new DateTimeOffset(1973, 9, 20, 12, 59, 59, 3.Hours()));\n\n // Assert\n result.Should().Be(\"<1973-09-20 12:59:59 +3h>\");\n }\n\n [Fact]\n public void When_date_is_not_relevant_it_should_not_be_included_in_the_output()\n {\n // Act\n DateTime emptyDate = 1.January(0001);\n var dateTime = emptyDate.At(08, 20, 01);\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<08:20:01>\");\n }\n\n [InlineData(\"0001-01-02 04:05:06\", \"<0001-01-02 04:05:06>\")]\n [InlineData(\"0001-02-01 04:05:06\", \"<0001-02-01 04:05:06>\")]\n [InlineData(\"0002-01-01 04:05:06\", \"<0002-01-01 04:05:06>\")]\n [InlineData(\"0001-02-02 04:05:06\", \"<0001-02-02 04:05:06>\")]\n [InlineData(\"0002-01-02 04:05:06\", \"<0002-01-02 04:05:06>\")]\n [InlineData(\"0002-02-01 04:05:06\", \"<0002-02-01 04:05:06>\")]\n [InlineData(\"0002-02-02 04:05:06\", \"<0002-02-02 04:05:06>\")]\n [Theory]\n public void When_date_is_relevant_it_should_be_included_in_the_output(string actual, string expected)\n {\n // Arrange\n var value = DateTime.Parse(actual, CultureInfo.InvariantCulture);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Fact]\n public void When_a_full_date_and_time_is_specified_all_parts_should_be_included_in_the_output()\n {\n // Act\n var dateTime = 1.May(2012).At(20, 15, 30, 318);\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<2012-05-01 20:15:30.318>\");\n }\n\n [Theory]\n [InlineData(\"0001-02-03\", \"<0001-02-03>\")]\n [InlineData(\"0001-02-03 04:05:06\", \"<0001-02-03 04:05:06>\")]\n [InlineData(\"0001-02-03 04:05:06.123\", \"<0001-02-03 04:05:06.123>\")]\n [InlineData(\"0001-02-03 04:05:06.123456\", \"<0001-02-03 04:05:06.123456>\")]\n [InlineData(\"0001-02-03 04:05:06.1234567\", \"<0001-02-03 04:05:06.1234567>\")]\n [InlineData(\"0001-02-03 00:00:01\", \"<0001-02-03 00:00:01>\")]\n [InlineData(\"0001-02-03 00:01:00\", \"<0001-02-03 00:01:00>\")]\n [InlineData(\"0001-02-03 01:00:00\", \"<0001-02-03 01:00:00>\")]\n [InlineData(\"0001-02-03 00:00:00.1000000\", \"<0001-02-03 00:00:00.100>\")]\n [InlineData(\"0001-02-03 00:00:00.0100000\", \"<0001-02-03 00:00:00.010>\")]\n [InlineData(\"0001-02-03 00:00:00.0010000\", \"<0001-02-03 00:00:00.001>\")]\n [InlineData(\"0001-02-03 00:00:00.0001000\", \"<0001-02-03 00:00:00.000100>\")]\n [InlineData(\"0001-02-03 00:00:00.0000100\", \"<0001-02-03 00:00:00.000010>\")]\n [InlineData(\"0001-02-03 00:00:00.0000010\", \"<0001-02-03 00:00:00.000001>\")]\n [InlineData(\"0001-02-03 00:00:00.0000001\", \"<0001-02-03 00:00:00.0000001>\")]\n public void When_datetime_components_are_not_relevant_they_should_not_be_included_in_the_output(string actual,\n string expected)\n {\n // Arrange\n var value = DateTime.Parse(actual, CultureInfo.InvariantCulture);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(\"0001-02-03 +1\", \"<0001-02-03 +1h>\")]\n [InlineData(\"0001-02-03 04:05:06 +1\", \"<0001-02-03 04:05:06 +1h>\")]\n [InlineData(\"0001-02-03 04:05:06.123 +1\", \"<0001-02-03 04:05:06.123 +1h>\")]\n [InlineData(\"0001-02-03 04:05:06.123456 +1\", \"<0001-02-03 04:05:06.123456 +1h>\")]\n [InlineData(\"0001-02-03 04:05:06.1234567 +1\", \"<0001-02-03 04:05:06.1234567 +1h>\")]\n [InlineData(\"0001-02-03 00:00:01 +1\", \"<0001-02-03 00:00:01 +1h>\")]\n [InlineData(\"0001-02-03 00:01:00 +1\", \"<0001-02-03 00:01:00 +1h>\")]\n [InlineData(\"0001-02-03 01:00:00 +1\", \"<0001-02-03 01:00:00 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.1000000 +1\", \"<0001-02-03 00:00:00.100 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0100000 +1\", \"<0001-02-03 00:00:00.010 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0010000 +1\", \"<0001-02-03 00:00:00.001 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0001000 +1\", \"<0001-02-03 00:00:00.000100 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0000100 +1\", \"<0001-02-03 00:00:00.000010 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0000010 +1\", \"<0001-02-03 00:00:00.000001 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0000001 +1\", \"<0001-02-03 00:00:00.0000001 +1h>\")]\n public void When_datetimeoffset_components_are_not_relevant_they_should_not_be_included_in_the_output(string actual,\n string expected)\n {\n // Arrange\n var value = DateTimeOffset.Parse(actual, CultureInfo.InvariantCulture);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(expected);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/TimeSpanConversionExtensionSpecs.cs", "using System;\nusing System.Globalization;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class TimeSpanConversionExtensionSpecs\n{\n [Fact]\n public void When_getting_the_number_of_days_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Days();\n\n // Assert\n time.Should().Be(TimeSpan.FromDays(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_days_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Days();\n\n // Assert\n time.Should().Be(TimeSpan.FromDays(4.5));\n }\n\n [Fact]\n public void When_getting_the_number_of_hours_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Hours();\n\n // Assert\n time.Should().Be(TimeSpan.FromHours(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_hours_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Hours();\n\n // Assert\n time.Should().Be(TimeSpan.FromHours(4.5));\n }\n\n [Fact]\n public void When_getting_the_number_of_minutes_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Minutes();\n\n // Assert\n time.Should().Be(TimeSpan.FromMinutes(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_minutes_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Minutes();\n\n // Assert\n time.Should().Be(TimeSpan.FromMinutes(4.5));\n }\n\n [Fact]\n public void When_getting_the_number_of_seconds_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Seconds();\n\n // Assert\n time.Should().Be(TimeSpan.FromSeconds(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_seconds_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Seconds();\n\n // Assert\n time.Should().Be(TimeSpan.FromSeconds(4.5));\n }\n\n [Fact]\n public void Add_time_span_to_given_seconds()\n {\n // Act\n TimeSpan time = 4.Seconds(TimeSpan.FromSeconds(1));\n\n // Assert\n time.Should().Be(TimeSpan.FromSeconds(5));\n }\n\n [Fact]\n public void Subtract_time_span_from_given_seconds()\n {\n // Act\n TimeSpan time = 4.Seconds(TimeSpan.FromSeconds(-1));\n\n // Assert\n time.Should().Be(TimeSpan.FromSeconds(3));\n }\n\n [Fact]\n public void When_getting_the_nanoseconds_component_it_should_return_the_correct_value()\n {\n // Arrange\n var time = TimeSpan.Parse(\"01:02:03.1234567\", CultureInfo.InvariantCulture);\n\n // Act\n var value = time.Nanoseconds();\n\n // Assert\n value.Should().Be(700);\n }\n\n [Fact]\n public void When_getting_the_number_of_nanoseconds_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 200.Nanoseconds();\n\n // Assert\n time.Should().Be(TimeSpan.Parse(\"00:00:00.0000002\", CultureInfo.InvariantCulture));\n }\n\n [Fact]\n public void When_getting_the_number_of_nanoseconds_from_a_long_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 200L.Nanoseconds();\n\n // Assert\n time.Should().Be(TimeSpan.Parse(\"00:00:00.0000002\", CultureInfo.InvariantCulture));\n }\n\n [Fact]\n public void When_getting_the_total_number_of_nanoseconds_should_return_the_correct_double_value()\n {\n // Arrange\n TimeSpan time = 1.Milliseconds();\n\n // Act\n double total = time.TotalNanoseconds();\n\n // Assert\n total.Should().Be(1_000_000);\n }\n\n [Fact]\n public void When_getting_the_microseconds_component_it_should_return_the_correct_value()\n {\n // Arrange\n var time = TimeSpan.Parse(\"01:02:03.1234567\", CultureInfo.InvariantCulture);\n\n // Act\n var value = time.Microseconds();\n\n // Assert\n value.Should().Be(456);\n }\n\n [Fact]\n public void When_getting_the_number_of_microseconds_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Microseconds();\n\n // Assert\n time.Should().Be(TimeSpan.Parse(\"00:00:00.000004\", CultureInfo.InvariantCulture));\n }\n\n [Fact]\n public void When_getting_the_number_of_microseconds_from_a_long_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4L.Microseconds();\n\n // Assert\n time.Should().Be(TimeSpan.Parse(\"00:00:00.000004\", CultureInfo.InvariantCulture));\n }\n\n [Fact]\n public void When_getting_the_total_number_of_microseconds_should_return_the_correct_double_value()\n {\n // Arrange\n TimeSpan time = 1.Milliseconds();\n\n // Act\n double total = time.TotalMicroseconds();\n\n // Assert\n total.Should().Be(1_000);\n }\n\n [Fact]\n public void When_getting_the_number_of_milliseconds_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Milliseconds();\n\n // Assert\n time.Should().Be(TimeSpan.FromMilliseconds(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_milliseconds_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Milliseconds();\n\n // Assert\n time.Should().Be(TimeSpan.FromMilliseconds(4.5));\n }\n\n [Fact]\n public void When_getting_the_number_of_ticks_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Ticks();\n\n // Assert\n time.Should().Be(TimeSpan.FromTicks(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_ticks_from_a_long_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4L.Ticks();\n\n // Assert\n time.Should().Be(TimeSpan.FromTicks(4));\n }\n\n [Fact]\n public void When_combining_fluent_time_methods_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time1 = 23.Hours().And(59.Minutes());\n TimeSpan time2 = 23.Hours(59.Minutes()).And(20.Seconds());\n TimeSpan time3 = 1.Days(2.Hours(33.Minutes(44.Seconds()))).And(99.Milliseconds());\n\n // Assert\n time1.Should().Be(new TimeSpan(23, 59, 0));\n time2.Should().Be(new TimeSpan(23, 59, 20));\n time3.Should().Be(new TimeSpan(1, 2, 33, 44, 99));\n }\n\n [Fact]\n public void When_specifying_a_time_before_another_time_it_should_return_the_correct_time()\n {\n // Act\n DateTime now = 21.September(2011).At(07, 35);\n\n DateTime twoHoursAgo = 2.Hours().Before(now);\n\n // Assert\n twoHoursAgo.Should().Be(new DateTime(2011, 9, 21, 05, 35, 00));\n }\n\n [Fact]\n public void When_specifying_a_time_after_another_time_it_should_return_the_correct_time()\n {\n // Act\n DateTime now = 21.September(2011).At(07, 35);\n\n DateTime twoHoursLater = 2.Hours().After(now);\n\n // Assert\n twoHoursLater.Should().Be(new DateTime(2011, 9, 21, 09, 35, 00));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/Iterator.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// A smarter enumerator that can provide information about the relative location (current, first, last)\n/// of the current item within the collection without unnecessarily iterating the collection.\n/// \ninternal sealed class Iterator : IEnumerator\n{\n private const int InitialIndex = -1;\n private readonly IEnumerable enumerable;\n private readonly int? maxItems;\n private IEnumerator enumerator;\n private T current;\n private T next;\n\n private bool hasNext;\n private bool hasCurrent;\n\n private bool hasCompleted;\n\n public Iterator(IEnumerable enumerable, int maxItems = int.MaxValue)\n {\n this.enumerable = enumerable;\n this.maxItems = maxItems;\n\n Reset();\n }\n\n public void Reset()\n {\n Index = InitialIndex;\n\n enumerator = enumerable.GetEnumerator();\n hasCurrent = false;\n hasNext = false;\n hasCompleted = false;\n current = default;\n next = default;\n }\n\n public int Index { get; private set; }\n\n public bool IsFirst => Index == 0;\n\n public bool IsLast => (hasCurrent && !hasNext) || HasReachedMaxItems;\n\n object IEnumerator.Current => Current;\n\n public T Current\n {\n get\n {\n if (!hasCurrent)\n {\n throw new InvalidOperationException($\"Please call {nameof(MoveNext)} first\");\n }\n\n return current;\n }\n\n private set\n {\n current = value;\n hasCurrent = true;\n }\n }\n\n public bool MoveNext()\n {\n if (!hasCompleted && FetchCurrent())\n {\n PrefetchNext();\n return true;\n }\n\n hasCompleted = true;\n return false;\n }\n\n private bool FetchCurrent()\n {\n if (hasNext && !HasReachedMaxItems)\n {\n Current = next;\n Index++;\n\n return true;\n }\n\n if (enumerator.MoveNext() && !HasReachedMaxItems)\n {\n Current = enumerator.Current;\n Index++;\n\n return true;\n }\n\n hasCompleted = true;\n\n return false;\n }\n\n public bool HasReachedMaxItems => Index == maxItems;\n\n private void PrefetchNext()\n {\n if (enumerator.MoveNext())\n {\n next = enumerator.Current;\n hasNext = true;\n }\n else\n {\n next = default;\n hasNext = false;\n }\n }\n\n public bool IsEmpty\n {\n get\n {\n if (!hasCurrent && !hasCompleted)\n {\n throw new InvalidOperationException($\"Please call {nameof(MoveNext)} first\");\n }\n\n return Index == InitialIndex;\n }\n }\n\n public void Dispose()\n {\n enumerator.Dispose();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/SemicolonParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class SemicolonParsingStrategy : IParsingStrategy\n{\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (symbol is ';')\n {\n statement.Clear();\n return ParsingState.Done;\n }\n\n return ParsingState.InProgress;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return false;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/NullableGuidAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic class NullableGuidAssertionSpecs\n{\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_value_with_a_value_to_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act / Assert\n nullableGuid.Should().HaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_value_with_a_value_to_not_be_null()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act / Assert\n nullableGuid.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_guid_value_without_a_value_to_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act\n Action act = () => nullableGuid.Should().HaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_guid_value_without_a_value_to_not_be_null()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act\n Action act = () => nullableGuid.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_without_a_value_to_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act\n Action act = () => nullableGuid.Should().HaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_without_a_value_to_not_be_null()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act\n Action act = () => nullableGuid.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act / Assert\n nullableGuid.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_value_without_a_value_to_be_null()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act / Assert\n nullableGuid.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_guid_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act\n Action act = () => nullableGuid.Should().NotHaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_guid_value_with_a_value_to_be_null()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act\n Action act = () => nullableGuid.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_guid_is_null_while_asserting_guid_equals_another_guid()\n {\n // Arrange\n Guid? guid = null;\n var someGuid = new Guid(\"55555555-ffff-eeee-dddd-444444444444\");\n\n // Act\n Action act = () =>\n guid.Should().Be(someGuid, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Guid to be {55555555-ffff-eeee-dddd-444444444444} because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_null_equals_null()\n {\n // Arrange\n Guid? nullGuid = null;\n Guid? otherNullGuid = null;\n\n // Act / Assert\n nullGuid.Should().Be(otherNullGuid);\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => nullableGuid.Should().NotHaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect a value because we want to test the failure message, but found {11111111-aaaa-bbbb-cccc-999999999999}.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_with_a_value_to_be_null()\n {\n // Arrange\n Guid? nullableGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => nullableGuid.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect a value because we want to test the failure message, but found {11111111-aaaa-bbbb-cccc-999999999999}.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_null_equals_some_guid()\n {\n // Arrange\n Guid? nullableGuid = null;\n var someGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () =>\n nullableGuid.Should().Be(someGuid, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullableGuid to be {11111111-aaaa-bbbb-cccc-999999999999} because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act / Assert\n nullableGuid.Should()\n .HaveValue()\n .And\n .NotBeEmpty();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeDerivedFrom.cs", "using System;\nusing AwesomeAssertions.Specs.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeDerivedFrom specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeDerivedFrom\n {\n [Fact]\n public void When_asserting_a_type_is_derived_from_its_base_class_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act / Assert\n type.Should().BeDerivedFrom(typeof(DummyBaseClass));\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_unrelated_class_it_fails()\n {\n // Arrange\n var type = typeof(DummyBaseClass);\n\n // Act\n Action act = () =>\n type.Should().BeDerivedFrom(typeof(ClassWithMembers), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyBaseClass to be derived from *.ClassWithMembers *failure message*, but it is not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_interface_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act\n Action act = () =>\n type.Should().BeDerivedFrom(typeof(IDummyInterface), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatImplementsInterface to be derived from *.IDummyInterface *failure message*\" +\n \", but *.IDummyInterface is an interface.\");\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_open_generic_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyBaseType);\n\n // Act / Assert\n type.Should().BeDerivedFrom(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_open_generic_base_class_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithGenericBaseType);\n\n // Act / Assert\n type.Should().BeDerivedFrom(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_unrelated_open_generic_class_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().BeDerivedFrom(typeof(DummyBaseType<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithMembers to be derived from *.DummyBaseType* *failure message*, but it is not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_to_be_derived_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act =\n () => type.Should().BeDerivedFrom(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"baseType\");\n }\n }\n\n public class BeDerivedFromOfT\n {\n [Fact]\n public void When_asserting_a_type_is_DerivedFromOfT_its_base_class_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act / Assert\n type.Should().BeDerivedFrom();\n }\n }\n\n public class NotBeDerivedFrom\n {\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_an_unrelated_class_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyBaseClass);\n\n // Act / Assert\n type.Should().NotBeDerivedFrom(typeof(ClassWithMembers));\n }\n\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_its_base_class_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeDerivedFrom(typeof(DummyBaseClass), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass not to be derived from *.DummyBaseClass *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_an_interface_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act\n Action act = () =>\n type.Should().NotBeDerivedFrom(typeof(IDummyInterface), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatImplementsInterface not to be derived from *.IDummyInterface *failure message*\" +\n \", but *.IDummyInterface is an interface.\");\n }\n\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_an_unrelated_open_generic_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should().NotBeDerivedFrom(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_an_open_generic_type_is_not_derived_from_itself_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act / Assert\n type.Should().NotBeDerivedFrom(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_its_open_generic_it_fails()\n {\n // Arrange\n var type = typeof(DummyBaseType);\n\n // Act\n Action act = () =>\n type.Should().NotBeDerivedFrom(typeof(DummyBaseType<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyBaseType<*.ClassWithGenericBaseType> not to be derived from *.DummyBaseType \" +\n \"*failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_type_not_to_be_derived_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act =\n () => type.Should().NotBeDerivedFrom(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"baseType\");\n }\n }\n\n public class NotBeDerivedFromOfT\n {\n [Fact]\n public void When_asserting_a_type_is_not_DerivedFromOfT_an_unrelated_class_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyBaseClass);\n\n // Act / Assert\n type.Should().NotBeDerivedFrom();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeNullOrWhiteSpace.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeNullOrWhiteSpace specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeNullOrWhitespace\n {\n [InlineData(null)]\n [InlineData(\"\")]\n [InlineData(\" \")]\n [InlineData(\"\\n\\r\")]\n [Theory]\n public void When_correctly_asserting_null_or_whitespace_it_should_not_throw(string actual)\n {\n // Assert\n actual.Should().BeNullOrWhiteSpace();\n }\n\n [InlineData(\"a\")]\n [InlineData(\" a \")]\n [Theory]\n public void When_correctly_asserting_not_null_or_whitespace_it_should_not_throw(string actual)\n {\n // Assert\n actual.Should().NotBeNullOrWhiteSpace();\n }\n\n [Fact]\n public void When_a_valid_string_is_expected_to_be_null_or_whitespace_it_should_throw()\n {\n // Act\n Action act = () =>\n \" abc \".Should().BeNullOrWhiteSpace();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string to be or whitespace, but found \\\" abc \\\".\");\n }\n }\n\n public class NotBeNullOrWhitespace\n {\n [Fact]\n public void When_a_null_string_is_expected_to_not_be_null_or_whitespace_it_should_throw()\n {\n // Arrange\n string nullString = null;\n\n // Act\n Action act = () =>\n nullString.Should().NotBeNullOrWhiteSpace();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected nullString not to be or whitespace, but found .\");\n }\n\n [Fact]\n public void When_an_empty_string_is_expected_to_not_be_null_or_whitespace_it_should_throw()\n {\n // Act\n Action act = () =>\n \"\".Should().NotBeNullOrWhiteSpace();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string not to be or whitespace, but found \\\"\\\".\");\n }\n\n [Fact]\n public void When_a_whitespace_string_is_expected_to_not_be_null_or_whitespace_it_should_throw()\n {\n // Act\n Action act = () =>\n \" \".Should().NotBeNullOrWhiteSpace();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string not to be or whitespace, but found \\\" \\\".\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveDefaultConstructor.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveDefaultConstructor specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveDefaultConstructor\n {\n [Fact]\n public void When_asserting_a_type_has_a_default_constructor_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveDefaultConstructor()\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_default_constructor_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act / Assert\n type.Should()\n .HaveDefaultConstructor()\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_default_constructor_which_it_does_not_and_a_cctor_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithCctor);\n\n // Act / Assert\n type.Should()\n .HaveDefaultConstructor()\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_default_constructor_which_it_does_not_and_a_cctor_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithCctorAndNonDefaultConstructor);\n\n // Act\n Action act = () =>\n type.Should().HaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected constructor *ClassWithCctorAndNonDefaultConstructor() to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_default_constructor_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor type() to exist *failure message*, but type is .\");\n }\n }\n\n public class NotHaveDefaultConstructor\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_a_default_constructor_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithCctorAndNonDefaultConstructor);\n\n // Act / Assert\n type.Should()\n .NotHaveDefaultConstructor();\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_default_constructor_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor *.ClassWithMembers() not to exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_default_constructor_which_it_does_and_a_cctor_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithCctor);\n\n // Act\n Action act = () =>\n type.Should().NotHaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor *ClassWithCctor*() not to exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_default_constructor_which_it_does_not_and_a_cctor_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithCctorAndNonDefaultConstructor);\n\n // Act / Assert\n type.Should().NotHaveDefaultConstructor();\n }\n\n [Fact]\n public void When_subject_is_null_not_have_default_constructor_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor type() not to exist *failure message*, but type is .\");\n }\n }\n\n internal class ClassWithNoMembers;\n\n internal class ClassWithCctor;\n\n internal class ClassWithCctorAndNonDefaultConstructor\n {\n public ClassWithCctorAndNonDefaultConstructor(int _) { }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeInRange.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeInRange\n {\n [Fact]\n public void When_a_value_is_outside_a_range_it_should_throw()\n {\n // Arrange\n float value = 3.99F;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5, \"because that's the valid range\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5* because that\\'s the valid range, but found*3.99*\");\n }\n\n [Fact]\n public void When_a_value_is_inside_a_range_it_should_not_throw()\n {\n // Arrange\n int value = 4;\n\n // Act / Assert\n value.Should().BeInRange(3, 5);\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_in_range_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeInRange(0, 1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_in_range_of_two_floats()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5*, but found*NaN*\");\n }\n\n [Theory]\n [InlineData(float.NaN, 5F)]\n [InlineData(5F, float.NaN)]\n public void A_float_can_never_be_in_a_range_containing_NaN(float minimumValue, float maximumValue)\n {\n // Arrange\n float value = 4.5F;\n\n // Act\n Action act = () => value.Should().BeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*NaN*\");\n }\n\n [Fact]\n public void A_NaN_is_never_in_range_of_two_doubles()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5*, but found*NaN*\");\n }\n\n [Theory]\n [InlineData(double.NaN, 5)]\n [InlineData(5, double.NaN)]\n public void A_double_can_never_be_in_a_range_containing_NaN(double minimumValue, double maximumValue)\n {\n // Arrange\n double value = 4.5D;\n\n // Act\n Action act = () => value.Should().BeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*NaN*\");\n }\n }\n\n public class NotBeInRange\n {\n [Fact]\n public void When_a_value_is_inside_an_unexpected_range_it_should_throw()\n {\n // Arrange\n float value = 4.99F;\n\n // Act\n Action act = () => value.Should().NotBeInRange(4, 5, \"because that's the invalid range\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to not be between*4* and*5* because that\\'s the invalid range, but found*4.99*\");\n }\n\n [Fact]\n public void When_a_value_is_outside_an_unexpected_range_it_should_not_throw()\n {\n // Arrange\n float value = 3.99F;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_not_in_range_to_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().NotBeInRange(0, 1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_inside_any_range_of_floats()\n {\n // Arrange\n float value = float.NaN;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n\n [Theory]\n [InlineData(float.NaN, 1F)]\n [InlineData(1F, float.NaN)]\n public void Cannot_use_NaN_in_a_range_of_floats(float minimumValue, float maximumValue)\n {\n // Arrange\n float value = 4.5F;\n\n // Act\n Action act = () => value.Should().NotBeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_inside_any_range_of_doubles()\n {\n // Arrange\n double value = double.NaN;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n\n [Theory]\n [InlineData(double.NaN, 1D)]\n [InlineData(1D, double.NaN)]\n public void Cannot_use_NaN_in_a_range_of_doubles(double minimumValue, double maximumValue)\n {\n // Arrange\n double value = 4.5D;\n\n // Act\n Action act = () => value.Should().NotBeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.HaveElementAt.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class HaveElementAt\n {\n [Fact]\n public void When_asserting_collection_has_element_at_specific_index_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().HaveElementAt(1, \"one\",\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have element at index 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_does_not_have_an_element_at_the_specific_index_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveElementAt(4, \"three\", \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected \\\"three\\\" at index 4 because we put it there, but found no element.\");\n }\n\n [Fact]\n public void When_collection_does_not_have_the_expected_element_at_specific_index_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveElementAt(1, \"three\", \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected \\\"three\\\" at index 1 because we put it there, but found \\\"two\\\".\");\n }\n\n [Fact]\n public void When_collection_has_expected_element_at_specific_index_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().HaveElementAt(1, \"two\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n [Fact]\n public void Should_succeed_when_asserting_nullable_timeonly_value_with_value_to_have_a_value()\n {\n // Arrange\n TimeOnly? timeOnly = new(15, 06, 04);\n\n // Act/Assert\n timeOnly.Should().HaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_timeonly_value_with_value_to_not_be_null()\n {\n // Arrange\n TimeOnly? timeOnly = new(15, 06, 04);\n\n // Act/Assert\n timeOnly.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_timeonly_value_with_null_to_be_null()\n {\n // Arrange\n TimeOnly? timeOnly = null;\n\n // Act/Assert\n timeOnly.Should().BeNull();\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n TimeOnly earlierTimeOnly = new(15, 06, 03);\n TimeOnly? nullableTimeOnly = new(15, 06, 04);\n\n // Act/Assert\n nullableTimeOnly.Should()\n .HaveValue()\n .And\n .BeAfter(earlierTimeOnly);\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n TimeOnly someTimeOnly = new(21, 1);\n\n // Act\n var act = () => someTimeOnly.Should().Equals(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeInRange.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeInRange\n {\n [Theory]\n [InlineData(float.NaN, 5F)]\n [InlineData(5F, float.NaN)]\n public void A_float_can_never_be_in_a_range_containing_NaN(float minimumValue, float maximumValue)\n {\n // Arrange\n float? value = 4.5F;\n\n // Act\n Action act = () => value.Should().BeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_in_range_of_two_floats()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5*, but found*NaN*\");\n }\n\n [Theory]\n [InlineData(double.NaN, 5)]\n [InlineData(5, double.NaN)]\n public void A_double_can_never_be_in_a_range_containing_NaN(double minimumValue, double maximumValue)\n {\n // Arrange\n double? value = 4.5;\n\n // Act\n Action act = () => value.Should().BeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_in_range_of_two_doubles()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5*, but found*NaN*\");\n }\n }\n\n public class NotBeInRange\n {\n [Theory]\n [InlineData(float.NaN, 1F)]\n [InlineData(1F, float.NaN)]\n public void Cannot_use_NaN_in_a_range_of_floats(float minimumValue, float maximumValue)\n {\n // Arrange\n float? value = 4.5F;\n\n // Act\n Action act = () => value.Should().NotBeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_inside_any_range_of_floats()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n\n [Theory]\n [InlineData(double.NaN, 1D)]\n [InlineData(1D, double.NaN)]\n public void Cannot_use_NaN_in_a_range_of_doubles(double minimumValue, double maximumValue)\n {\n // Arrange\n double? value = 4.5D;\n\n // Act\n Action act = () => value.Should().NotBeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_inside_any_range_of_doubles()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/ExampleExtensions/StringAssertionExtensions.cs", "using AwesomeAssertions;\nusing AwesomeAssertions.Primitives;\n\nnamespace ExampleExtensions;\n\npublic static class StringAssertionExtensions\n{\n public static void BePalindromic(this StringAssertions assertions)\n {\n char[] charArray = assertions.Subject.ToCharArray();\n Array.Reverse(charArray);\n string reversedSubject = new string(charArray);\n\n assertions.Subject.Should().Be(reversedSubject);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.ContainMatch.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class ContainMatch\n {\n [Fact]\n public void When_collection_contains_a_match_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act / Assert\n collection.Should().ContainMatch(\"* failed\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_matches_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\", \"pack failed\"];\n\n // Act / Assert\n collection.Should().ContainMatch(\"* failed\");\n }\n\n [Fact]\n public void Can_chain_another_assertion_if_a_single_string_matches_the_pattern()\n {\n // Arrange\n IEnumerable collection = [\"build succeeded\", \"test succeeded\", \"pack failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(\"*failed*\").Which.Should().StartWith(\"test\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection[2] to start with*test*pack failed*\");\n }\n\n [Fact]\n public void Cannot_chain_another_assertion_if_multiple_strings_match_the_pattern()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\", \"pack failed\"];\n\n // Act\n Action action = () => _ = collection.Should().ContainMatch(\"* failed\").Which;\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"More than one object found. AwesomeAssertions cannot determine which object is meant.*\")\n .WithMessage(\"*Found objects:*\\\"test failed\\\"*\\\"pack failed\\\"\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_a_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(\"* stopped\", \"because {0}\", \"we do\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection {\\\"build succeded\\\", \\\"test failed\\\"} to contain a match of \\\"* stopped\\\" because we do.\");\n }\n\n [Fact]\n public void When_collection_contains_a_match_that_differs_in_casing_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(\"* Failed\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection {\\\"build succeded\\\", \\\"test failed\\\"} to contain a match of \\\"* Failed\\\".\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_for_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action action = () => collection.Should().ContainMatch(\"* failed\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection {empty} to contain a match of \\\"* failed\\\".\");\n }\n\n [Fact]\n public void When_asserting_null_collection_for_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainMatch(\"* failed\", \"because {0}\", \"we do\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to contain a match of \\\"* failed\\\" because we do, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_have_null_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Cannot match strings in collection against . Provide a wildcard pattern or use the Contain method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_asserting_collection_to_have_empty_string_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(string.Empty);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Cannot match strings in collection against an empty string. Provide a wildcard pattern or use the Contain method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n }\n\n public class NotContainMatch\n {\n [Fact]\n public void When_collection_doesnt_contain_a_match_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test\"];\n\n // Act / Assert\n collection.Should().NotContainMatch(\"* failed\");\n }\n\n [Fact]\n public void When_collection_doesnt_contain_multiple_matches_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test\", \"pack\"];\n\n // Act / Assert\n collection.Should().NotContainMatch(\"* failed\");\n }\n\n [Fact]\n public void When_collection_contains_a_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(\"* failed\", \"because {0}\", \"it shouldn't\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Did not expect collection {\\\"build succeded\\\", \\\"test failed\\\"} to contain a match of \\\"* failed\\\" because it shouldn't.\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_matches_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build failed\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(\"* failed\", \"because {0}\", \"it shouldn't\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Did not expect collection {\\\"build failed\\\", \\\"test failed\\\"} to contain a match of \\\"* failed\\\" because it shouldn't.\");\n }\n\n [Fact]\n public void When_collection_contains_a_match_with_different_casing_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(\"* Failed\");\n\n // Assert\n action.Should().NotThrow();\n }\n\n [Fact]\n public void When_asserting_collection_to_not_have_null_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Cannot match strings in collection against . Provide a wildcard pattern or use the NotContain method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_have_empty_string_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(string.Empty);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Cannot match strings in collection against an empty string. Provide a wildcard pattern or use the NotContain method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_asserting_null_collection_to_not_have_null_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainMatch(\"* Failed\", \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to contain a match of \\\"* failed\\\" *failure message*, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/BooleanAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n// ReSharper disable ConditionIsAlwaysTrueOrFalse\npublic class BooleanAssertionSpecs\n{\n public class BeTrue\n {\n [Fact]\n public void Should_succeed_when_asserting_boolean_value_true_is_true()\n {\n // Arrange\n bool boolean = true;\n\n // Act / Assert\n boolean.Should().BeTrue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_boolean_value_false_is_true()\n {\n // Arrange\n bool boolean = false;\n\n // Act\n Action action = () => boolean.Should().BeTrue();\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_boolean_value_false_is_true()\n {\n // Act\n Action action = () =>\n false.Should().BeTrue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Expected boolean to be True because we want to test the failure message, but found False.\");\n }\n }\n\n public class BeFalse\n {\n [Fact]\n public void Should_succeed_when_asserting_boolean_value_false_is_false()\n {\n // Act / Assert\n false.Should().BeFalse();\n }\n\n [Fact]\n public void Should_fail_when_asserting_boolean_value_true_is_false()\n {\n // Act\n Action action = () =>\n true.Should().BeFalse();\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_boolean_value_true_is_false()\n {\n // Act\n Action action = () =>\n true.Should().BeFalse(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected boolean to be False because we want to test the failure message, but found True.\");\n }\n }\n\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_boolean_value_to_be_equal_to_the_same_value()\n {\n // Act / Assert\n false.Should().Be(false);\n }\n\n [Fact]\n public void Should_fail_when_asserting_boolean_value_to_be_equal_to_a_different_value()\n {\n // Act\n Action action = () =>\n false.Should().Be(true);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_boolean_value_to_be_equal_to_a_different_value()\n {\n // Act\n Action action = () =>\n false.Should().Be(true, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*Expected*boolean*True*because we want to test the failure message, but found False.*\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Should_succeed_when_asserting_boolean_value_not_to_be_equal_to_the_same_value()\n {\n // Act / Assert\n true.Should().NotBe(false);\n }\n\n [Fact]\n public void Should_fail_when_asserting_boolean_value_not_to_be_equal_to_a_different_value()\n {\n // Act\n Action action = () =>\n true.Should().NotBe(true);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_boolean_value_not_to_be_equal_to_a_different_value()\n {\n // Act\n Action action = () =>\n true.Should().NotBe(true, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*Expected*boolean*True*because we want to test the failure message, but found True.*\");\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Act\n Action action = () => true.Should().Equals(true);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n }\n\n public class Imply\n {\n [Theory]\n [InlineData(false, false)]\n [InlineData(false, true)]\n [InlineData(true, true)]\n public void Antecedent_implies_consequent(bool? antecedent, bool consequent)\n {\n // Act / Assert\n antecedent.Should().Imply(consequent);\n }\n\n [Theory]\n [InlineData(null, true)]\n [InlineData(null, false)]\n [InlineData(true, false)]\n public void Antecedent_does_not_imply_consequent(bool? antecedent, bool consequent)\n {\n // Act\n Action act = () => antecedent.Should().Imply(consequent, \"because we want to test the {0}\", \"failure\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected antecedent*to imply consequent*test the failure*but*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.NotContainNulls.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class NotContainNulls\n {\n [Fact]\n public void When_asserting_collection_to_not_contain_nulls_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because we want to test the behaviour with a null subject, but collection is .\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_nulls_that_are_unexpected_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"\", null, \"\", null];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s*because they are evil*{1, 3}*\");\n }\n\n [Fact]\n public void When_collection_contains_nulls_that_are_unexpected_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"\", null];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because they are evil, but found one at index 1.\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_nulls_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotContainNulls();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/PropertyInfoExtensions.cs", "using System.Reflection;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class PropertyInfoExtensions\n{\n internal static bool IsVirtual(this PropertyInfo property)\n {\n MethodInfo methodInfo = property.GetGetMethod(nonPublic: true) ?? property.GetSetMethod(nonPublic: true);\n return !methodInfo.IsNonVirtual();\n }\n\n internal static bool IsStatic(this PropertyInfo property)\n {\n MethodInfo methodInfo = property.GetGetMethod(nonPublic: true) ?? property.GetSetMethod(nonPublic: true);\n return methodInfo.IsStatic;\n }\n\n internal static bool IsAbstract(this PropertyInfo property)\n {\n MethodInfo methodInfo = property.GetGetMethod(nonPublic: true) ?? property.GetSetMethod(nonPublic: true);\n return methodInfo.IsAbstract;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeApproximately.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeApproximately\n {\n [Fact]\n public void When_approximating_a_float_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_float_is_not_approximating_a_range_it_should_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, 0.001F, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to approximate *3.14* +/- *0.001* because rockets will crash otherwise, but *3.1415927* differed by *0.001592*\");\n }\n\n [Fact]\n public void When_float_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act / Assert\n value.Should().BeApproximately(3.14F, 0.1F);\n }\n\n [InlineData(9F)]\n [InlineData(11F)]\n [Theory]\n public void When_float_is_approximating_a_value_on_boundaries_it_should_not_throw(float value)\n {\n // Act / Assert\n value.Should().BeApproximately(10F, 1F);\n }\n\n [InlineData(9F)]\n [InlineData(11F)]\n [Theory]\n public void When_float_is_not_approximating_a_value_on_boundaries_it_should_throw(float value)\n {\n // Act\n Action act = () => value.Should().BeApproximately(10F, 0.9F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_approximating_a_float_towards_nan_it_should_not_throw()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_approximating_positive_infinity_float_towards_positive_infinity_it_should_not_throw()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act / Assert\n value.Should().BeApproximately(float.PositiveInfinity, 0.1F);\n }\n\n [Fact]\n public void When_approximating_negative_infinity_float_towards_negative_infinity_it_should_not_throw()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act / Assert\n value.Should().BeApproximately(float.NegativeInfinity, 0.1F);\n }\n\n [Fact]\n public void When_float_is_not_approximating_positive_infinity_it_should_throw()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.MaxValue, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_float_is_not_approximating_negative_infinity_it_should_throw()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void NaN_can_never_be_close_to_any_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_can_never_be_close_to_NaN()\n {\n // Arrange\n float value = float.MinValue;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.NaN, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_a_nullable_float_has_no_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, 0.001F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to approximate*3.14* +/-*0.001*, but it was .\");\n }\n\n [Fact]\n public void When_approximating_a_double_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_double_is_not_approximating_a_range_it_should_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14, 0.001, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to approximate 3.14 +/- 0.001 because rockets will crash otherwise, but 3.1415927 differed by 0.001592*\");\n }\n\n [Fact]\n public void When_double_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act / Assert\n value.Should().BeApproximately(3.14, 0.1);\n }\n\n [Fact]\n public void When_approximating_a_double_towards_nan_it_should_not_throw()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_approximating_positive_infinity_double_towards_positive_infinity_it_should_not_throw()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act / Assert\n value.Should().BeApproximately(double.PositiveInfinity, 0.1);\n }\n\n [Fact]\n public void When_approximating_negative_infinity_double_towards_negative_infinity_it_should_not_throw()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act / Assert\n value.Should().BeApproximately(double.NegativeInfinity, 0.1);\n }\n\n [Fact]\n public void When_double_is_not_approximating_positive_infinity_it_should_throw()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.MaxValue, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_double_is_not_approximating_negative_infinity_it_should_throw()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.MinValue, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [InlineData(9D)]\n [InlineData(11D)]\n [Theory]\n public void When_double_is_approximating_a_value_on_boundaries_it_should_not_throw(double value)\n {\n // Act / Assert\n value.Should().BeApproximately(10D, 1D);\n }\n\n [InlineData(9D)]\n [InlineData(11D)]\n [Theory]\n public void When_double_is_not_approximating_a_value_on_boundaries_it_should_throw(double value)\n {\n // Act\n Action act = () => value.Should().BeApproximately(10D, 0.9D);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void NaN_can_never_be_close_to_any_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_double_can_never_be_close_to_NaN()\n {\n // Arrange\n double value = double.MinValue;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.NaN, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_approximating_a_decimal_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal value = 3.1415927M;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14m, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_range_it_should_throw()\n {\n // Arrange\n decimal value = 3.5011m;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.5m, 0.001m, \"rockets will crash otherwise\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate*3.5* +/-*0.001* because rockets will crash otherwise, but *3.5011* differed by*0.0011*\");\n }\n\n [Fact]\n public void When_decimal_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n decimal value = 3.5011m;\n\n // Act / Assert\n value.Should().BeApproximately(3.5m, 0.01m);\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_value_on_lower_boundary_it_should_not_throw()\n {\n // Act\n decimal value = 9m;\n\n // Act / Assert\n value.Should().BeApproximately(10m, 1m);\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_value_on_upper_boundary_it_should_not_throw()\n {\n // Act\n decimal value = 11m;\n\n // Act / Assert\n value.Should().BeApproximately(10m, 1m);\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_on_lower_boundary_it_should_throw()\n {\n // Act\n decimal value = 9m;\n\n // Act\n Action act = () => value.Should().BeApproximately(10m, 0.9m);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_on_upper_boundary_it_should_throw()\n {\n // Act\n decimal value = 11m;\n\n // Act\n Action act = () => value.Should().BeApproximately(10m, 0.9m);\n\n // Assert\n act.Should().Throw();\n }\n }\n\n public class NotBeApproximately\n {\n [Fact]\n public void When_not_approximating_a_float_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_float_is_approximating_a_range_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, 0.1F, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to not approximate *3.14* +/- *0.1* because rockets will crash otherwise, but *3.1415927* only differed by *0.001592*\");\n }\n\n [Fact]\n public void When_float_is_not_approximating_a_value_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14F, 0.001F);\n }\n\n [Fact]\n public void When_approximating_a_float_towards_nan_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_not_approximating_a_float_towards_positive_infinity_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act / Assert\n value.Should().NotBeApproximately(float.MaxValue, 0.1F);\n }\n\n [Fact]\n public void When_not_approximating_a_float_towards_negative_infinity_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act / Assert\n value.Should().NotBeApproximately(float.MinValue, 0.1F);\n }\n\n [Fact]\n public void\n When_approximating_positive_infinity_float_towards_positive_infinity_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.PositiveInfinity, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_not_approximating_negative_infinity_float_towards_negative_infinity_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.NegativeInfinity, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [InlineData(9F)]\n [InlineData(11F)]\n [Theory]\n public void When_float_is_not_approximating_a_value_on_boundaries_it_should_not_throw(float value)\n {\n // Act / Assert\n value.Should().NotBeApproximately(10F, 0.9F);\n }\n\n [InlineData(9F)]\n [InlineData(11F)]\n [Theory]\n public void When_float_is_approximating_a_value_on_boundaries_it_should_throw(float value)\n {\n // Act\n Action act = () => value.Should().NotBeApproximately(10F, 1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_nullable_float_has_no_value_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n float? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14F, 0.001F);\n }\n\n [Fact]\n public void NaN_can_never_be_close_to_any_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_can_never_be_close_to_NaN()\n {\n // Arrange\n float value = float.MinValue;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.NaN, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_not_approximating_a_double_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_double_is_approximating_a_range_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, 0.1, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to not approximate *3.14* +/- *0.1* because rockets will crash otherwise, but *3.1415927* only differed by *0.001592*\");\n }\n\n [Fact]\n public void When_double_is_not_approximating_a_value_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14, 0.001);\n }\n\n [Fact]\n public void When_approximating_a_double_towards_nan_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_not_approximating_a_double_towards_positive_infinity_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act / Assert\n value.Should().NotBeApproximately(double.MaxValue, 0.1);\n }\n\n [Fact]\n public void When_not_approximating_a_double_towards_negative_infinity_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act / Assert\n value.Should().NotBeApproximately(double.MinValue, 0.1);\n }\n\n [Fact]\n public void\n When_approximating_positive_infinity_double_towards_positive_infinity_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.PositiveInfinity, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_not_approximating_negative_infinity_double_towards_negative_infinity_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.NegativeInfinity, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_nullable_double_has_no_value_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14, 0.001);\n }\n\n [InlineData(9D)]\n [InlineData(11D)]\n [Theory]\n public void When_double_is_not_approximating_a_value_on_boundaries_it_should_not_throw(double value)\n {\n // Act / Assert\n value.Should().NotBeApproximately(10D, 0.9D);\n }\n\n [InlineData(9D)]\n [InlineData(11D)]\n [Theory]\n public void When_double_is_approximating_a_value_on_boundaries_it_should_throw(double value)\n {\n // Act\n Action act = () => value.Should().NotBeApproximately(10D, 1D);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void NaN_can_never_be_close_to_any_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_close_to_NaN()\n {\n // Arrange\n double value = double.MinValue;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.NaN, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_not_approximating_a_decimal_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14m, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_range_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n decimal value = 3.5011m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.5m, 0.1m, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to not approximate *3.5* +/- *0.1* because rockets will crash otherwise, but *3.5011* only differed by *0.0011*\");\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n decimal value = 3.5011m;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.5m, 0.001m);\n }\n\n [Fact]\n public void When_a_nullable_decimal_has_no_value_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.5m, 0.001m);\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_on_lower_boundary_it_should_not_throw()\n {\n // Act\n decimal value = 9m;\n\n // Act / Assert\n value.Should().NotBeApproximately(10m, 0.9m);\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_on_upper_boundary_it_should_not_throw()\n {\n // Act\n decimal value = 11m;\n\n // Act / Assert\n value.Should().NotBeApproximately(10m, 0.9m);\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_value_on_lower_boundary_it_should_throw()\n {\n // Act\n decimal value = 9m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(10m, 1m);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_value_on_upper_boundary_it_should_throw()\n {\n // Act\n decimal value = 11m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(10m, 1m);\n\n // Assert\n act.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.OnlyHaveUniqueItems.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class OnlyHaveUniqueItems\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_with_unique_items_contains_only_unique_items()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\", \"four\"];\n\n // Act / Assert\n collection.Should().OnlyHaveUniqueItems();\n }\n\n [Fact]\n public void When_a_collection_contains_duplicate_items_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\", \"three\"];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(\"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we don't like duplicates, but item \\\"three\\\" is not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_multiple_duplicate_items_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"two\", \"three\", \"three\"];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(\"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we don't like duplicates, but items {\\\"two\\\", \\\"three\\\"} are not unique.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_only_have_unique_items_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act =\n () => collection.Should().OnlyHaveUniqueItems(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeEmpty.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeEmpty specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_empty_string_to_be_empty()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().BeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_non_empty_string_to_be_empty()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_non_empty_string_to_be_empty()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be empty because we want to test the failure message, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_checking_for_an_empty_string_and_it_is_null_it_should_throw()\n {\n // Arrange\n string nullString = null;\n\n // Act\n Action act = () => nullString.Should().BeEmpty(\"because strings should never be {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullString to be empty because strings should never be null, but found .\");\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_non_empty_string_to_be_filled()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act / Assert\n actual.Should().NotBeEmpty();\n }\n\n [Fact]\n public void When_asserting_null_string_to_not_be_empty_it_should_succeed()\n {\n // Arrange\n string actual = null;\n\n // Act / Assert\n actual.Should().NotBeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_empty_string_to_be_filled()\n {\n // Arrange\n string actual = \"\";\n\n // Act\n Action act = () => actual.Should().NotBeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_empty_string_to_be_filled()\n {\n // Arrange\n string actual = \"\";\n\n // Act\n Action act = () => actual.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect actual to be empty because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeOneOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n int value = 3;\n\n // Act\n Action act = () => value.Should().BeOneOf(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be one of {4, 5}, but found 3.\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 3;\n\n // Act\n Action act = () => value.Should().BeOneOf([4, 5], \"because those are the valid values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be one of {4, 5} because those are the valid values, but found 3.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n int value = 4;\n\n // Act / Assert\n value.Should().BeOneOf(4, 5);\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_one_of_to_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeOneOf(0, 1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void Two_floats_that_are_NaN_can_be_compared()\n {\n // Arrange\n float value = float.NaN;\n\n // Act / Assert\n value.Should().BeOneOf(float.NaN, 4.5F);\n }\n\n [Fact]\n public void Floats_are_never_equal_to_NaN()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeOneOf(1.5F, 4.5F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*1.5F*found*NaN*\");\n }\n\n [Fact]\n public void Two_doubles_that_are_NaN_can_be_compared()\n {\n // Arrange\n double value = double.NaN;\n\n // Act / Assert\n value.Should().BeOneOf(double.NaN, 4.5F);\n }\n\n [Fact]\n public void Doubles_are_never_equal_to_NaN()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeOneOf(1.5D, 4.5D);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*1.5*found NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeNullOrEmpty.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeNullOrEmpty specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeNullOrEmpty\n {\n [Fact]\n public void When_a_null_string_is_expected_to_be_null_or_empty_it_should_not_throw()\n {\n // Arrange\n string str = null;\n\n // Act / Assert\n str.Should().BeNullOrEmpty();\n }\n\n [Fact]\n public void When_an_empty_string_is_expected_to_be_null_or_empty_it_should_not_throw()\n {\n // Arrange\n string str = \"\";\n\n // Act / Assert\n str.Should().BeNullOrEmpty();\n }\n\n [Fact]\n public void When_a_valid_string_is_expected_to_be_null_or_empty_it_should_throw()\n {\n // Arrange\n string str = \"hello\";\n\n // Act\n Action act = () => str.Should().BeNullOrEmpty(\"it was not initialized {0}\", \"yet\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected str to be or empty because it was not initialized yet, but found \\\"hello\\\".\");\n }\n }\n\n public class NotBeNullOrEmpty\n {\n [Fact]\n public void When_a_valid_string_is_expected_to_be_not_null_or_empty_it_should_not_throw()\n {\n // Arrange\n string str = \"Hello World\";\n\n // Act / Assert\n str.Should().NotBeNullOrEmpty();\n }\n\n [Fact]\n public void When_an_empty_string_is_not_expected_to_be_null_or_empty_it_should_throw()\n {\n // Arrange\n string str = \"\";\n\n // Act\n Action act = () => str.Should().NotBeNullOrEmpty(\"a valid string is expected for {0}\", \"str\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected str not to be or empty because a valid string is expected for str, but found \\\"\\\".\");\n }\n\n [Fact]\n public void When_a_null_string_is_not_expected_to_be_null_or_empty_it_should_throw()\n {\n // Arrange\n string str = null;\n\n // Act\n Action act = () => str.Should().NotBeNullOrEmpty(\"a valid string is expected for {0}\", \"str\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected str not to be or empty because a valid string is expected for str, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/ExecutionTime.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Specialized;\n\npublic class ExecutionTime\n{\n private ITimer timer;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The action of which the execution time must be asserted.\n /// is .\n public ExecutionTime(Action action, StartTimer createTimer)\n : this(action, \"the action\", createTimer)\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The action of which the execution time must be asserted.\n /// is .\n public ExecutionTime(Func action, StartTimer createTimer)\n : this(action, \"the action\", createTimer)\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The action of which the execution time must be asserted.\n /// The description of the action to be asserted.\n /// is .\n protected ExecutionTime(Action action, string actionDescription, StartTimer createTimer)\n {\n Guard.ThrowIfArgumentIsNull(action);\n\n ActionDescription = actionDescription;\n IsRunning = true;\n\n Task = Task.Run(() =>\n {\n // move stopwatch as close to action start as possible\n // so that we have to get correct time readings\n try\n {\n using (timer = createTimer())\n {\n action();\n }\n }\n catch (Exception exception)\n {\n Exception = exception;\n }\n finally\n {\n // ensures that we stop the stopwatch even on exceptions\n IsRunning = false;\n }\n });\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The action of which the execution time must be asserted.\n /// The description of the action to be asserted.\n /// \n /// This constructor is almost exact copy of the one accepting .\n /// The original constructor shall stay in place in order to keep backward-compatibility\n /// and to avoid unnecessary wrapping action in .\n /// \n /// is .\n protected ExecutionTime(Func action, string actionDescription, StartTimer createTimer)\n {\n Guard.ThrowIfArgumentIsNull(action);\n\n ActionDescription = actionDescription;\n IsRunning = true;\n\n Task = Task.Run(async () =>\n {\n // move stopwatch as close to action start as possible\n // so that we have to get correct time readings\n try\n {\n using (timer = createTimer())\n {\n await action();\n }\n }\n catch (Exception exception)\n {\n Exception = exception;\n }\n finally\n {\n IsRunning = false;\n }\n });\n }\n\n internal TimeSpan ElapsedTime => timer?.Elapsed ?? TimeSpan.Zero;\n\n internal bool IsRunning { get; private set; }\n\n internal string ActionDescription { get; }\n\n internal Task Task { get; }\n\n internal Exception Exception { get; private set; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeUpperCased.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeUpperCased specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeUpperCased\n {\n [Fact]\n public void Upper_case_characters_are_okay()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act / Assert\n actual.Should().BeUpperCased();\n }\n\n [Fact]\n public void The_empty_string_is_okay()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().BeUpperCased();\n }\n\n [Fact]\n public void A_lower_case_string_is_not_okay()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act\n Action act = () => actual.Should().BeUpperCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Upper_case_and_caseless_characters_are_ok()\n {\n // Arrange\n string actual = \"A1!\";\n\n // Act / Assert\n actual.Should().BeUpperCased();\n }\n\n [Fact]\n public void Caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"1!漢字\";\n\n // Act / Assert\n actual.Should().BeUpperCased();\n }\n\n [Fact]\n public void The_assertion_fails_with_a_descriptive_message()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act\n Action act = () => actual.Should().BeUpperCased(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected all alphabetic characters in actual to be upper-case because we want to test the failure message, but found \\\"abc\\\".\");\n }\n\n [Fact]\n public void The_null_string_is_not_okay()\n {\n // Arrange\n string nullString = null;\n\n // Act\n Action act = () => nullString.Should().BeUpperCased(\"because strings should never be {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected all alphabetic characters in nullString to be upper-case because strings should never be null, but found .\");\n }\n }\n\n public class NotBeUpperCased\n {\n [Fact]\n public void A_mixed_case_string_is_okay()\n {\n // Arrange\n string actual = \"aBc\";\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void The_null_string_is_okay()\n {\n // Arrange\n string actual = null;\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void The_empty_string_is_okay()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void A_string_of_all_upper_case_characters_is_not_okay()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().NotBeUpperCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Upper_case_characters_with_lower_case_characters_are_okay()\n {\n // Arrange\n string actual = \"Ab1!\";\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void All_cased_characters_being_upper_case_is_not_okay()\n {\n // Arrange\n string actual = \"A1B!\";\n\n // Act\n Action act = () => actual.Should().NotBeUpperCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"1!漢字\";\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void The_assertion_fails_with_a_descriptive_message()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().NotBeUpperCased(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected some characters in actual to be lower-case because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeLowerCased.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeLowerCased specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeLowerCased\n {\n [Fact]\n public void Lower_case_characters_are_okay()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act / Assert\n actual.Should().BeLowerCased();\n }\n\n [Fact]\n public void The_empty_string_is_okay()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().BeLowerCased();\n }\n\n [Fact]\n public void Upper_case_characters_are_not_okay()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeLowerCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_mixed_case_string_is_not_okay()\n {\n // Arrange\n string actual = \"AbC\";\n\n // Act\n Action act = () => actual.Should().BeLowerCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Lower_case_and_caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"a1!\";\n\n // Act / Assert\n actual.Should().BeLowerCased();\n }\n\n [Fact]\n public void Caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"1!漢字\";\n\n // Act / Assert\n actual.Should().BeLowerCased();\n }\n\n [Fact]\n public void The_assertion_fails_with_a_descriptive_message()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeLowerCased(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected all alphabetic characters in actual to be lower cased because we want to test the failure message, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void The_null_string_is_not_okay()\n {\n // Arrange\n string nullString = null;\n\n // Act\n Action act = () => nullString.Should().BeLowerCased(\"because strings should never be {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected all alphabetic characters in nullString to be lower cased because strings should never be null, but found .\");\n }\n }\n\n public class NotBeLowerCased\n {\n [Fact]\n public void A_mixed_case_string_is_okay()\n {\n // Arrange\n string actual = \"AbC\";\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void The_null_string_is_okay()\n {\n // Arrange\n string actual = null;\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void The_empty_string_is_okay()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void A_lower_case_string_is_not_okay()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act\n Action act = () => actual.Should().NotBeLowerCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Lower_case_characters_with_upper_case_characters_are_okay()\n {\n // Arrange\n string actual = \"Ab1!\";\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void All_cased_characters_being_lower_case_is_not_okay()\n {\n // Arrange\n string actual = \"a1b!\";\n\n // Act\n Action act = () => actual.Should().NotBeLowerCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"1!漢字\";\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void The_assertion_fails_with_a_descriptive_message()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act\n Action act = () => actual.Should().NotBeLowerCased(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected some characters in actual to be upper-case because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.ContainAny.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]ContainAny specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class ContainAny\n {\n [Fact]\n public void When_containment_of_any_string_in_a_null_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().ContainAny(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*null*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_containment_of_any_string_in_an_empty_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().ContainAny();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*empty*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_and_all_of_the_strings_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act / Assert\n testString.Should().ContainAny(red, green, yellow);\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_and_only_some_of_the_strings_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string blue = \"blue\";\n var testString = $\"{red} {green}\";\n\n // Act / Assert\n testString.Should().ContainAny(red, blue, green);\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_and_none_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string blue = \"blue\";\n const string purple = \"purple\";\n var testString = $\"{red} {green}\";\n\n // Act\n Action act = () => testString.Should().ContainAny(blue, purple);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain at least one of*{blue}*{purple}*\");\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_and_there_are_equivalent_but_not_exact_matches_it_should_throw()\n {\n // Arrange\n const string redLowerCase = \"red\";\n const string redUpperCase = \"RED\";\n const string greenWithoutWhitespace = \"green\";\n const string greenWithWhitespace = \" green\";\n var testString = $\"{redLowerCase} {greenWithoutWhitespace}\";\n\n // Act\n Action act = () => testString.Should().ContainAny(redUpperCase, greenWithWhitespace);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain at least one of*{redUpperCase}*{greenWithWhitespace}*\");\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_with_reason_and_assertion_fails_then_failure_message_contains_reason()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string blue = \"blue\";\n const string purple = \"purple\";\n var testString = $\"{red} {green}\";\n\n // Act\n Action act = () => testString.Should().ContainAny([blue, purple], \"some {0} reason\", \"special\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain at least one of*{blue}*{purple}*because some special reason*\");\n }\n }\n\n public class NotContainAny\n {\n [Fact]\n public void When_exclusion_of_any_string_in_null_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().NotContainAny(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*null*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_exclusion_of_any_string_in_an_empty_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().NotContainAny();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*empty*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_exclusion_of_any_string_in_a_collection_is_asserted_and_all_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAny(red, green, yellow);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain any*{red}*{green}*{yellow}*\");\n }\n\n [Fact]\n public void\n When_exclusion_of_any_string_in_a_collection_is_asserted_and_only_some_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string purple = \"purple\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAny(red, purple, green);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain any*{red}*{green}*\");\n }\n\n [Fact]\n public void When_exclusion_of_any_strings_is_asserted_with_reason_and_assertion_fails_then_error_message_contains_reason()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAny([red], \"some {0} reason\", \"special\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain any*{red}*because*some special reason*\");\n }\n\n [Fact]\n public void\n When_exclusion_of_any_string_in_a_collection_is_asserted_and_there_are_equivalent_but_not_exact_matches_it_should_succeed()\n {\n // Arrange\n const string redLowerCase = \"red\";\n const string redUpperCase = \"RED\";\n const string greenWithoutWhitespace = \"green\";\n const string greenWithWhitespace = \" green \";\n var testString = $\"{redLowerCase} {greenWithoutWhitespace}\";\n\n // Act / Assert\n testString.Should().NotContainAny(redUpperCase, greenWithWhitespace);\n }\n\n [Fact]\n public void\n When_exclusion_of_any_string_in_a_collection_is_asserted_and_none_of_the_strings_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string purple = \"purple\";\n var testString = $\"{red} {green}\";\n\n // Act / Assert\n testString.Should().NotContainAny(yellow, purple);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.ContainAll.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]ContainAll specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class ContainAll\n {\n [Fact]\n public void When_containment_of_all_strings_in_a_null_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().ContainAll(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*null*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_containment_of_all_strings_in_an_empty_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().ContainAll();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*empty*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_containment_of_all_strings_in_a_collection_is_asserted_and_all_strings_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act / Assert\n testString.Should().ContainAll(red, green, yellow);\n }\n\n [Fact]\n public void\n When_containment_of_all_strings_in_a_collection_is_asserted_and_equivalent_but_not_exact_matches_exist_for_all_it_should_throw()\n {\n // Arrange\n const string redLowerCase = \"red\";\n const string redUpperCase = \"RED\";\n const string greenWithoutWhitespace = \"green\";\n const string greenWithWhitespace = \" green \";\n var testString = $\"{redLowerCase} {greenWithoutWhitespace}\";\n\n // Act\n Action act = () => testString.Should().ContainAll(redUpperCase, greenWithWhitespace);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain*{redUpperCase}*{greenWithWhitespace}*\");\n }\n\n [Fact]\n public void\n When_containment_of_all_strings_in_a_collection_is_asserted_and_none_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string blue = \"blue\";\n var testString = $\"{red} {green}\";\n\n // Act\n Action act = () => testString.Should().ContainAll(yellow, blue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain*{yellow}*{blue}*\");\n }\n\n [Fact]\n public void\n When_containment_of_all_strings_in_a_collection_is_asserted_with_reason_and_assertion_fails_then_failure_message_should_contain_reason()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string blue = \"blue\";\n var testString = $\"{red} {green}\";\n\n // Act\n Action act = () => testString.Should().ContainAll([yellow, blue], \"some {0} reason\", \"special\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain*{yellow}*{blue}*because some special reason*\");\n }\n\n [Fact]\n public void\n When_containment_of_all_strings_in_a_collection_is_asserted_and_only_some_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string blue = \"blue\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().ContainAll(red, blue, green);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain*{blue}*\");\n }\n }\n\n public class NotContainAll\n {\n [Fact]\n public void When_exclusion_of_all_strings_in_null_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().NotContainAll(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*null*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_exclusion_of_all_strings_in_an_empty_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().NotContainAll();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*empty*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void\n When_exclusion_of_all_strings_in_a_collection_is_asserted_and_all_strings_in_collection_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAll(red, green, yellow);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain all*{red}*{green}*{yellow}*\");\n }\n\n [Fact]\n public void When_exclusion_of_all_strings_is_asserted_with_reason_and_assertion_fails_then_error_message_contains_reason()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAll([red, green, yellow], \"some {0} reason\", \"special\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain all*{red}*{green}*{yellow}*because*some special reason*\");\n }\n\n [Fact]\n public void\n When_exclusion_of_all_strings_in_a_collection_is_asserted_and_only_some_of_the_strings_in_collection_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string purple = \"purple\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act / Assert\n testString.Should().NotContainAll(red, green, yellow, purple);\n }\n\n [Fact]\n public void\n When_exclusion_of_all_strings_in_a_collection_is_asserted_and_none_of_the_strings_in_the_collection_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string purple = \"purple\";\n var testString = $\"{red} {green}\";\n\n // Act / Assert\n testString.Should().NotContainAll(yellow, purple);\n }\n\n [Fact]\n public void\n When_exclusion_of_all_strings_in_a_collection_is_asserted_and_equivalent_but_not_exact_strings_are_present_in_collection_it_should_succeed()\n {\n // Arrange\n const string redWithoutWhitespace = \"red\";\n const string redWithWhitespace = \" red \";\n const string lowerCaseGreen = \"green\";\n const string upperCaseGreen = \"GREEN\";\n var testString = $\"{redWithoutWhitespace} {lowerCaseGreen}\";\n\n // Act / Assert\n testString.Should().NotContainAll(redWithWhitespace, upperCaseGreen);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/FallbackTestFrameworkTests.cs", "using AwesomeAssertions.Execution;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\npublic class FallbackTestFrameworkTests\n{\n [Fact]\n public void The_fallback_test_framework_is_available()\n {\n var sut = new FallbackTestFramework();\n\n sut.IsAvailable.Should().BeTrue();\n }\n\n [Fact]\n public void Throwing_with_messages_throws_the_exception()\n {\n var sut = new FallbackTestFramework();\n\n sut.Invoking(x => x.Throw(\"test message\")).Should().ThrowExactly()\n .WithMessage(\"test message\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.BeNull.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void When_dictionary_is_expected_to_be_null_and_it_is_it_should_not_throw()\n {\n // Arrange\n IDictionary someDictionary = null;\n\n // Act / Assert\n someDictionary.Should().BeNull();\n }\n\n [Fact]\n public void When_dictionary_is_expected_to_be_null_and_it_isnt_it_should_throw()\n {\n // Arrange\n var someDictionary = new Dictionary();\n\n // Act\n Action act = () => someDictionary.Should().BeNull(\"because {0} is valid\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someDictionary to be because null is valid, but found {empty}.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_a_custom_dictionary_implementation_is_expected_not_to_be_null_and_it_is_it_should_not_throw()\n {\n // Arrange\n var dictionary = new TrackingTestDictionary();\n\n // Act / Assert\n dictionary.Should().NotBeNull();\n }\n\n [Fact]\n public void When_dictionary_is_not_expected_to_be_null_and_it_isnt_it_should_not_throw()\n {\n // Arrange\n IDictionary someDictionary = new Dictionary();\n\n // Act / Assert\n someDictionary.Should().NotBeNull();\n }\n\n [Fact]\n public void When_dictionary_is_not_expected_to_be_null_and_it_is_it_should_throw()\n {\n // Arrange\n IDictionary someDictionary = null;\n\n // Act\n Action act = () => someDictionary.Should().NotBeNull(\"because {0} should not\", \"someDictionary\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someDictionary not to be because someDictionary should not.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.Be.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_equals_an_equal_value()\n {\n // Arrange\n int? nullableIntegerA = 1;\n int? nullableIntegerB = 1;\n\n // Act / Assert\n nullableIntegerA.Should().Be(nullableIntegerB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_null_value_equals_null()\n {\n // Arrange\n int? nullableIntegerA = null;\n int? nullableIntegerB = null;\n\n // Act / Assert\n nullableIntegerA.Should().Be(nullableIntegerB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n int? nullableIntegerA = 1;\n int? nullableIntegerB = 2;\n\n // Act\n Action act = () => nullableIntegerA.Should().Be(nullableIntegerB);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n int? nullableIntegerA = 1;\n int? nullableIntegerB = 2;\n\n // Act\n Action act = () =>\n nullableIntegerA.Should().Be(nullableIntegerB, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*2 because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void Nan_is_never_equal_to_a_normal_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().Be(3.4F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be *3.4F, but found NaN*\");\n }\n\n [Fact]\n public void NaN_can_be_compared_to_NaN_when_its_a_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n value.Should().Be(float.NaN);\n }\n\n [Fact]\n public void Nan_is_never_equal_to_a_normal_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().Be(3.4D);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be *3.4, but found NaN*\");\n }\n\n [Fact]\n public void NaN_can_be_compared_to_NaN_when_its_a_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n value.Should().Be(double.NaN);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/IAssertionStrategy.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Defines a strategy for handling failures in a .\n/// \npublic interface IAssertionStrategy\n{\n /// \n /// Returns the messages for the assertion failures that happened until now.\n /// \n IEnumerable FailureMessages { get; }\n\n /// \n /// Instructs the strategy to handle a assertion failure.\n /// \n void HandleFailure(string message);\n\n /// \n /// Discards and returns the failure messages that happened up to now.\n /// \n IEnumerable DiscardFailures();\n\n /// \n /// Will throw a combined exception for any failures have been collected.\n /// \n void ThrowIfAny(IDictionary context);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeNull.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_null_object_to_be_null()\n {\n // Arrange\n object someObject = null;\n\n // Act / Assert\n someObject.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_non_null_object_to_be_null()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_non_null_object_is_expected_to_be_null_it_should_fail()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .Where(e => e.Message.StartsWith(\n \"Expected someObject to be because we want to test the failure message, but found System.Object\",\n StringComparison.Ordinal));\n }\n }\n\n public class BeNotNull\n {\n [Fact]\n public void Should_succeed_when_asserting_non_null_object_not_to_be_null()\n {\n // Arrange\n var someObject = new object();\n\n // Act / Assert\n someObject.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_null_object_not_to_be_null()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () => someObject.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_null_object_not_to_be_null()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () => someObject.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someObject not to be because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/NullableBooleanAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n// ReSharper disable ConditionIsAlwaysTrueOrFalse\npublic class NullableBooleanAssertionSpecs\n{\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_have_a_value_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act / Assert\n nullableBoolean.Should().HaveValue();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_not_be_null_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act / Assert\n nullableBoolean.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_have_a_value_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action act = () => nullableBoolean.Should().HaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_not_be_null_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action act = () => nullableBoolean.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_have_a_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action act = () => nullableBoolean.Should().HaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_not_be_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action act = () => nullableBoolean.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_not_have_a_value_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act / Assert\n nullableBoolean.Should().NotHaveValue();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_be_null_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act / Assert\n nullableBoolean.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_not_have_a_value_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act\n Action act = () => nullableBoolean.Should().NotHaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_be_null_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act\n Action act = () => nullableBoolean.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_nullable_boolean_value_with_a_value_to_be_not_have_a_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act\n Action act = () => nullableBoolean.Should().NotHaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found True.\");\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_be_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act\n Action act = () => nullableBoolean.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found True.\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_is_false_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action action = () =>\n nullableBoolean.Should().BeFalse(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected nullableBoolean to be false because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_is_true_it_sShould_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action action = () =>\n nullableBoolean.Should().BeTrue(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected nullableBoolean to be true because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_to_be_equal_to_different_nullable_boolean_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n bool? differentNullableBoolean = false;\n\n // Act\n Action action = () =>\n nullableBoolean.Should().Be(differentNullableBoolean, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected False because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_not_to_be_equal_to_same_value_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n bool? differentNullableBoolean = null;\n\n // Act\n Action action = () =>\n nullableBoolean.Should().NotBe(differentNullableBoolean, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableBoolean not to be because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_to_be_equal_to_null_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = null;\n bool? otherNullableBoolean = null;\n\n // Act / Assert\n nullableBoolean.Should().Be(otherNullableBoolean);\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_not_to_be_equal_to_different_value_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = true;\n bool? otherNullableBoolean = null;\n\n // Act / Assert\n nullableBoolean.Should().NotBe(otherNullableBoolean);\n }\n\n [Fact]\n public void When_asserting_true_is_not_false_it_should_succeed()\n {\n // Arrange\n bool? trueBoolean = true;\n\n // Act / Assert\n trueBoolean.Should().NotBeFalse();\n }\n\n [Fact]\n public void When_asserting_null_is_not_false_it_should_succeed()\n {\n // Arrange\n bool? nullValue = null;\n\n // Act / Assert\n nullValue.Should().NotBeFalse();\n }\n\n [Fact]\n public void When_asserting_false_is_not_false_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? falseBoolean = false;\n\n // Act\n Action action = () =>\n falseBoolean.Should().NotBeFalse(\"we want to test the failure message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*falseBoolean*not*False*because we want to test the failure message, but found False.\");\n }\n\n [Fact]\n public void When_asserting_false_is_not_true_it_should_succeed()\n {\n // Arrange\n bool? trueBoolean = false;\n\n // Act / Assert\n trueBoolean.Should().NotBeTrue();\n }\n\n [Fact]\n public void When_asserting_null_is_not_true_it_should_succeed()\n {\n // Arrange\n bool? nullValue = null;\n\n // Act / Assert\n nullValue.Should().NotBeTrue();\n }\n\n [Fact]\n public void When_asserting_true_is_not_true_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? falseBoolean = true;\n\n // Act\n Action action = () =>\n falseBoolean.Should().NotBeTrue(\"we want to test the failure message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*falseBoolean*not*True*because we want to test the failure message, but found True.\");\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act / Assert\n nullableBoolean.Should()\n .HaveValue()\n .And\n .BeTrue();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Common/TimeSpanExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Specs.Common;\n\n/// \n/// Implements extensions to \n/// \npublic static class TimeSpanExtensions\n{\n public static TimeSpan Multiply(this TimeSpan timeSpan, double factor)\n {\n if (double.IsNaN(factor))\n {\n throw new ArgumentException(\"Argument cannot be NaN\", nameof(factor));\n }\n\n // Rounding to the nearest tick is as close to the result we would have with unlimited\n // precision as possible, and so likely to have the least potential to surprise.\n double ticks = Math.Round(timeSpan.Ticks * factor);\n\n if (ticks is > long.MaxValue or < long.MinValue)\n {\n throw new OverflowException(\"TimeSpan overflowed because the duration is too long.\");\n }\n\n return TimeSpan.FromTicks((long)ticks);\n }\n\n public static TimeSpan Divide(this TimeSpan timeSpan, double divisor)\n {\n if (double.IsNaN(divisor))\n {\n throw new ArgumentException(\"Argument cannot be NaN\", nameof(divisor));\n }\n\n double ticks = Math.Round(timeSpan.Ticks / divisor);\n\n if (ticks > long.MaxValue || ticks < long.MinValue || double.IsNaN(ticks))\n {\n throw new OverflowException(\"TimeSpan overflowed because the duration is too long.\");\n }\n\n return TimeSpan.FromTicks((long)ticks);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeNull.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetimeoffset_value_without_a_value_to_be_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n\n // Act / Assert\n nullableDateTime.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_with_a_value_to_be_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act\n Action action = () =>\n nullableDateTime.Should().BeNull();\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_nullable_datetimeoffset_value_with_a_value_not_be_null_it_should_succeed()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTime.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_without_a_value_to_not_be_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n\n // Act\n Action action = () => nullableDateTime.Should().NotBeNull();\n\n // Assert\n action.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/NullableSimpleTimeSpanAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic class NullableSimpleTimeSpanAssertionSpecs\n{\n [Fact]\n public void Should_succeed_when_asserting_nullable_TimeSpan_value_with_a_value_to_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act / Assert\n nullableTimeSpan.Should().HaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_TimeSpan_value_with_a_value_to_not_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act / Assert\n nullableTimeSpan.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_TimeSpan_value_without_a_value_to_not_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act\n Action act = () => nullableTimeSpan.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_TimeSpan_value_without_a_value_to_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act\n Action act = () => nullableTimeSpan.Should().HaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_TimeSpan_value_without_a_value_to_not_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act\n Action act = () => nullableTimeSpan.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_TimeSpan_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act / Assert\n nullableTimeSpan.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_TimeSpan_value_without_a_value_to_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act / Assert\n nullableTimeSpan.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_TimeSpan_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act\n Action act = () => nullableTimeSpan.Should().NotHaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_TimeSpan_value_with_a_value_to_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act\n Action act = () => nullableTimeSpan.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_TimeSpan_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = 1.Seconds();\n\n // Act\n Action act = () => nullableTimeSpan.Should().NotHaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_TimeSpan_value_with_a_value_to_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = 1.Seconds();\n\n // Act\n Action act = () => nullableTimeSpan.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void\n When_asserting_a_nullable_TimeSpan_is_equal_to_a_different_nullable_TimeSpan_it_should_should_throw_appropriately()\n {\n // Arrange\n TimeSpan? nullableTimeSpanA = 1.Seconds();\n TimeSpan? nullableTimeSpanB = 2.Seconds();\n\n // Act\n Action action = () => nullableTimeSpanA.Should().Be(nullableTimeSpanB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_a_nullable_TimeSpan_is_equal_to_another_a_nullable_TimeSpan_but_it_is_null_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TimeSpan? nullableTimeSpanA = null;\n TimeSpan? nullableTimeSpanB = 1.Seconds();\n\n // Act\n Action action =\n () =>\n nullableTimeSpanA.Should()\n .Be(nullableTimeSpanB, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_a_nullable_TimeSpan_is_equal_to_another_a_nullable_TimeSpan_and_both_are_null_it_should_succeed()\n {\n // Arrange\n TimeSpan? nullableTimeSpanA = null;\n TimeSpan? nullableTimeSpanB = null;\n\n // Act / Assert\n nullableTimeSpanA.Should().Be(nullableTimeSpanB);\n }\n\n [Fact]\n public void When_asserting_a_nullable_TimeSpan_is_equal_to_the_same_nullable_TimeSpan_it_should_succeed()\n {\n // Arrange\n TimeSpan? nullableTimeSpanA = default(TimeSpan);\n TimeSpan? nullableTimeSpanB = default(TimeSpan);\n\n // Act / Assert\n nullableTimeSpanA.Should().Be(nullableTimeSpanB);\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act / Assert\n nullableTimeSpan.Should()\n .HaveValue()\n .And\n .Be(default(TimeSpan));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveValue.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveValue\n {\n [Fact]\n public void When_nullable_datetimeoffset_value_with_a_value_to_have_a_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTime.Should().HaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_without_a_value_to_have_a_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n\n // Act\n Action action = () => nullableDateTime.Should().HaveValue();\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class NotHaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetimeoffset_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n\n // Act / Assert\n nullableDateTime.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act\n Action action = () =>\n nullableDateTime.Should().NotHaveValue();\n\n // Assert\n action.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.BeOneOf.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n TimeOnly value = new(15, 12, 20);\n\n // Act\n Action action = () => value.Should().BeOneOf(value.AddHours(1), value.AddMinutes(-1));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<16:12:20.000>, <15:11:20.000>}, but found <15:12:20.000>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n TimeOnly value = new(15, 12, 30);\n\n // Act/Assert\n value.Should().BeOneOf(new TimeOnly(4, 1, 30), new TimeOnly(15, 12, 30));\n }\n\n [Fact]\n public void When_a_null_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n TimeOnly? value = null;\n\n // Act\n Action action = () => value.Should().BeOneOf(new TimeOnly(15, 1, 30), new TimeOnly(5, 4, 10, 123));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<15:01:30.000>, <05:04:10.123>}, but found .\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_timeonly_is_null()\n {\n // Arrange\n TimeOnly? value = null;\n\n // Act/Assert\n value.Should().BeOneOf(new TimeOnly(15, 1, 30), null);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeOneOf.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateTime value = new(2016, 12, 30, 23, 58, 57);\n\n // Act\n Action action = () => value.Should().BeOneOf(value + 1.Days(), value + 1.Milliseconds());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected value to be one of {<2016-12-31 23:58:57>, <2016-12-30 23:58:57.001>}, but found <2016-12-30 23:58:57>.\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n DateTime value = new(2016, 12, 30, 23, 58, 57);\n\n // Act\n Action action = () =>\n value.Should().BeOneOf(new[] { value + 1.Days(), value + 1.Milliseconds() }, \"because it's true\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected value to be one of {<2016-12-31 23:58:57>, <2016-12-30 23:58:57.001>} because it's true, but found <2016-12-30 23:58:57>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n DateTime value = new(2016, 12, 30, 23, 58, 57);\n\n // Act / Assert\n value.Should().BeOneOf(new DateTime(2216, 1, 30, 0, 5, 7),\n new DateTime(2016, 12, 30, 23, 58, 57), new DateTime(2012, 3, 3));\n }\n\n [Fact]\n public void When_a_null_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateTime? value = null;\n\n // Act\n Action action = () => value.Should().BeOneOf(new DateTime(2216, 1, 30, 0, 5, 7), new DateTime(1116, 4, 10, 2, 45, 7));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<2216-01-30 00:05:07>, <1116-04-10 02:45:07>}, but found .\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_datetime_is_null()\n {\n // Arrange\n DateTime? value = null;\n\n // Act / Assert\n value.Should().BeOneOf(new DateTime(2216, 1, 30, 0, 5, 7), null);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.IntersectWith.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class IntersectWith\n {\n [Fact]\n public void When_asserting_the_items_in_an_two_intersecting_collections_intersect_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = [\"three\", \"four\", \"five\"];\n\n // Act / Assert\n collection.Should().IntersectWith(otherCollection);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_non_intersecting_collections_intersect_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = [\"four\", \"five\"];\n\n // Act\n Action action = () => collection.Should().IntersectWith(otherCollection, \"they should share items\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to intersect with {\\\"four\\\", \\\"five\\\"} because they should share items,\" +\n \" but {\\\"one\\\", \\\"two\\\", \\\"three\\\"} does not contain any shared items.\");\n }\n }\n\n public class NotIntersectWith\n {\n [Fact]\n public void When_asserting_collection_to_not_intersect_with_same_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = collection;\n\n // Act\n Action act = () => collection.Should().NotIntersectWith(otherCollection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*to intersect with*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_intersecting_collections_do_not_intersect_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = [\"two\", \"three\", \"four\"];\n\n // Act\n Action action = () => collection.Should().NotIntersectWith(otherCollection, \"they should not share items\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Did not expect collection to intersect with {\\\"two\\\", \\\"three\\\", \\\"four\\\"} because they should not share items,\" +\n \" but found the following shared items {\\\"two\\\", \\\"three\\\"}.\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_non_intersecting_collections_do_not_intersect_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = [\"four\", \"five\"];\n\n // Act / Assert\n collection.Should().NotIntersectWith(otherCollection);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/AggregateExceptionAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class AggregateExceptionAssertionSpecs\n{\n [Fact]\n public void When_the_expected_exception_is_wrapped_it_should_succeed()\n {\n // Arrange\n var exception = new AggregateException(\n new InvalidOperationException(\"Ignored\"),\n new XunitException(\"Background\"));\n\n // Act\n Action act = () => throw exception;\n\n // Assert\n act.Should().Throw().WithMessage(\"Background\");\n }\n\n [Fact]\n public void When_the_expected_exception_was_not_thrown_it_should_report_the_actual_exceptions()\n {\n // Arrange\n Action throwingOperation = () =>\n {\n throw new AggregateException(\n new InvalidOperationException(\"You can't do this\"),\n new NullReferenceException(\"Found a null\"));\n };\n\n // Act\n Action act = () => throwingOperation\n .Should().Throw()\n .WithMessage(\"Something I expected\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*InvalidOperation*You can't do this*\")\n .WithMessage(\"*NullReferenceException*Found a null*\");\n }\n\n [Fact]\n public void When_no_exception_was_expected_it_should_report_the_actual_exceptions()\n {\n // Arrange\n Action throwingOperation = () =>\n {\n throw new AggregateException(\n new InvalidOperationException(\"You can't do this\"),\n new NullReferenceException(\"Found a null\"));\n };\n\n // Act\n Action act = () => throwingOperation.Should().NotThrow();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*InvalidOperation*You can't do this*\")\n .WithMessage(\"*NullReferenceException*Found a null*\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.Implement.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]Implement specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class Implement\n {\n [Fact]\n public void When_asserting_a_type_implements_an_interface_which_it_does_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act / Assert\n type.Should().Implement(typeof(IDummyInterface));\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_implement_an_interface_which_it_does_then_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act\n Action act = () =>\n type.Should().Implement(typeof(IDummyInterface), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatDoesNotImplementInterface to implement interface *.IDummyInterface \" +\n \"*failure message*, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_implements_a_NonInterface_type_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act\n Action act = () =>\n type.Should().Implement(typeof(DateTime), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatDoesNotImplementInterface to implement interface *.DateTime *failure message*\" +\n \", but *.DateTime is not an interface.\");\n }\n\n [Fact]\n public void When_asserting_a_type_to_implement_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act = () =>\n type.Should().Implement(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void An_interface_does_not_implement_itself()\n {\n // Arrange\n var type = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should().Implement(typeof(IDummyInterface));\n\n // Assert\n act.Should().Throw();\n }\n }\n\n public class ImplementOfT\n {\n [Fact]\n public void When_asserting_a_type_implementsOfT_an_interface_which_it_does_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act / Assert\n type.Should().Implement();\n }\n }\n\n public class NotImplement\n {\n [Fact]\n public void When_asserting_a_type_does_not_implement_an_interface_which_it_does_not_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act / Assert\n type.Should().NotImplement(typeof(IDummyInterface));\n }\n\n [Fact]\n public void When_asserting_a_type_implements_an_interface_which_it_does_not_then_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act\n Action act = () =>\n type.Should().NotImplement(typeof(IDummyInterface), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatImplementsInterface to not implement interface *.IDummyInterface \" +\n \"*failure message*, but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_implement_a_NonInterface_type_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act\n Action act = () =>\n type.Should().NotImplement(typeof(DateTime), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatDoesNotImplementInterface to not implement interface *.DateTime *failure message*\" +\n \", but *.DateTime is not an interface.\");\n }\n\n [Fact]\n public void When_asserting_a_type_not_to_implement_null_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act\n Action act = () =>\n type.Should().NotImplement(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void An_interface_does_not_implement_itself()\n {\n // Arrange\n var type = typeof(IDummyInterface);\n\n // Act / Assert\n type.Should().NotImplement(typeof(IDummyInterface));\n }\n }\n\n public class NotImplementOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_implementOfT_an_interface_which_it_does_not_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act / Assert\n type.Should().NotImplement();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/Predicate.cs", "using System;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// Stores a predicate's expression and index in the maximum matching problem.\n/// \n/// The type of the element values in the maximum matching problems.\ninternal class Predicate\n{\n private readonly Func compiledExpression;\n\n public Predicate(Expression> expression, int index)\n {\n Index = index;\n Expression = expression;\n compiledExpression = expression.Compile();\n }\n\n /// \n /// The index of the predicate in the maximum matching problem.\n /// \n public int Index { get; }\n\n /// \n /// The expression of the predicate.\n /// \n public Expression> Expression { get; }\n\n /// \n /// Determines whether the predicate matches the specified element.\n /// \n public bool Matches(TValue element) => compiledExpression(element);\n\n public override string ToString() => $\"Index: {Index}, Expression: {Formatter.ToString(Expression)}\";\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/Nested.cs", "namespace Benchmarks;\n\npublic sealed class Nested\n{\n public int A { get; set; }\n\n public Nested B { get; set; }\n\n public Nested C { get; set; }\n\n#pragma warning disable AV1562 // Don't use `ref` or `out` parameters: Keep benchmark as it was\n public static Nested Create(int i, ref int objectCount)\n#pragma warning restore AV1562\n {\n if (i < 0)\n {\n return null;\n }\n\n if (i == 0)\n {\n return new Nested();\n }\n\n return new Nested\n {\n A = ++objectCount,\n B = Create(i - 1, ref objectCount),\n C = Create(i - 2, ref objectCount),\n };\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeNegative.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeNegative\n {\n [Fact]\n public void When_a_negative_value_is_negative_it_should_not_throw()\n {\n // Arrange\n int value = -1;\n\n // Act / Assert\n value.Should().BeNegative();\n }\n\n [Fact]\n public void When_a_positive_value_is_negative_it_should_throw()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_zero_value_is_negative_it_should_throw()\n {\n // Arrange\n int value = 0;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_positive_value_is_negative_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action act = () => value.Should().BeNegative(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be negative because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_negative_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_a_negative_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_a_negative_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BePositive.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BePositive\n {\n [Fact]\n public void When_a_positive_value_is_positive_it_should_not_throw()\n {\n // Arrange\n float value = 1F;\n\n // Act / Assert\n value.Should().BePositive();\n }\n\n [Fact]\n public void When_a_negative_value_is_positive_it_should_throw()\n {\n // Arrange\n double value = -1D;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_zero_value_is_positive_it_should_throw()\n {\n // Arrange\n int value = 0;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void NaN_is_never_a_positive_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_a_positive_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void When_a_negative_value_is_positive_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = -1;\n\n // Act\n Action act = () => value.Should().BePositive(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be positive because we want to test the failure message, but found -1.\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_positive_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.Match.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class Match\n {\n [Fact]\n public void When_nullable_value_satisfies_predicate_it_should_not_throw()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act / Assert\n nullableInteger.Should().Match(o => o.HasValue);\n }\n\n [Fact]\n public void When_nullable_value_does_not_match_the_predicate_it_should_throw()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () =>\n nullableInteger.Should().Match(o => !o.HasValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected value to match Not(o.HasValue) because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void When_nullable_value_is_matched_against_a_null_it_should_throw()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () => nullableInteger.Should().Match(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/TimeSpanFormatterSpecs.cs", "using System;\nusing System.Globalization;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class TimeSpanFormatterSpecs\n{\n [Fact]\n public void When_zero_time_span_it_should_return_a_literal()\n {\n // Act\n string result = Formatter.ToString(TimeSpan.Zero);\n\n // Assert\n result.Should().Be(\"default\");\n }\n\n [Fact]\n public void When_max_time_span_it_should_return_a_literal()\n {\n // Act\n string result = Formatter.ToString(TimeSpan.MaxValue);\n\n // Assert\n result.Should().Be(\"max time span\");\n }\n\n [Fact]\n public void When_min_time_span_it_should_return_a_literal()\n {\n // Act\n string result = Formatter.ToString(TimeSpan.MinValue);\n\n // Assert\n result.Should().Be(\"min time span\");\n }\n\n [Theory]\n [InlineData(\"00:00:00.0000007\", \"0.7µs\")]\n [InlineData(\"-00:00:00.0000007\", \"-0.7µs\")]\n [InlineData(\"00:00:00.000456\", \"456.0µs\")]\n [InlineData(\"-00:00:00.000456\", \"-456.0µs\")]\n [InlineData(\"00:00:00.0004567\", \"456.7µs\")]\n [InlineData(\"-00:00:00.0004567\", \"-456.7µs\")]\n [InlineData(\"00:00:00.123\", \"123ms\")]\n [InlineData(\"-00:00:00.123\", \"-123ms\")]\n [InlineData(\"00:00:00.123456\", \"123ms and 456.0µs\")]\n [InlineData(\"-00:00:00.123456\", \"-123ms and 456.0µs\")]\n [InlineData(\"00:00:00.1234567\", \"123ms and 456.7µs\")]\n [InlineData(\"-00:00:00.1234567\", \"-123ms and 456.7µs\")]\n [InlineData(\"00:00:04\", \"4s\")]\n [InlineData(\"-00:00:04\", \"-4s\")]\n [InlineData(\"00:03:04\", \"3m and 4s\")]\n [InlineData(\"-00:03:04\", \"-3m and 4s\")]\n [InlineData(\"1.02:03:04\", \"1d, 2h, 3m and 4s\")]\n [InlineData(\"-1.02:03:04\", \"-1d, 2h, 3m and 4s\")]\n [InlineData(\"01:02:03\", \"1h, 2m and 3s\")]\n [InlineData(\"-01:02:03\", \"-1h, 2m and 3s\")]\n [InlineData(\"01:02:03.123\", \"1h, 2m, 3s and 123ms\")]\n [InlineData(\"-01:02:03.123\", \"-1h, 2m, 3s and 123ms\")]\n [InlineData(\"01:02:03.123456\", \"1h, 2m, 3s, 123ms and 456.0µs\")]\n [InlineData(\"-01:02:03.123456\", \"-1h, 2m, 3s, 123ms and 456.0µs\")]\n [InlineData(\"01:02:03.1234567\", \"1h, 2m, 3s, 123ms and 456.7µs\")]\n [InlineData(\"-01:02:03.1234567\", \"-1h, 2m, 3s, 123ms and 456.7µs\")]\n public void When_timespan_components_are_not_relevant_they_should_not_be_included_in_the_output(string actual,\n string expected)\n {\n // Arrange\n var value = TimeSpan.Parse(actual, CultureInfo.InvariantCulture);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(expected);\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/NUnit4.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing NUnit.Framework;\n\nnamespace NUnit4.Specs;\n\n[TestFixture]\npublic class FrameworkSpecs\n{\n [Test]\n public void Throw_nunit_framework_exception_for_nunit4_tests()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"NUnit.Framework.AssertionException\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.NotContainItemsAssignableTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class CollectionAssertionSpecs\n{\n public class NotContainItemsAssignableTo\n {\n [Fact]\n public void Succeeds_when_the_collection_does_not_contain_items_of_the_unexpected_type()\n {\n // Arrange\n string[] collection = [\"1\", \"2\", \"3\"];\n\n // Act / Assert\n collection.Should().NotContainItemsAssignableTo();\n }\n\n [Fact]\n public void Throws_when_the_collection_contains_an_item_of_the_unexpected_type()\n {\n // Arrange\n var collection = new object[] { 1, \"2\", \"3\" };\n\n // Act\n var act = () => collection\n .Should()\n .NotContainItemsAssignableTo(\n \"because we want test that collection does not contain object of {0} type\", typeof(int));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\n \"Expected collection to not contain any elements assignable to type int \" +\n \"because we want test that collection does not contain object of System.Int32 type, \" +\n \"but found {int, string, string}.\");\n }\n\n [Fact]\n public void Succeeds_when_collection_is_empty()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().NotContainItemsAssignableTo();\n }\n\n [Fact]\n public void Throws_when_the_passed_type_argument_is_null()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n var act = () => collection.Should().NotContainItemsAssignableTo(null);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Succeed_when_type_as_parameter_is_valid_type()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainItemsAssignableTo(typeof(string));\n }\n\n [Fact]\n public void Throws_when_the_collection_is_null()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n var act = () => collection.Should().NotContainItemsAssignableTo();\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\n \"Expected collection to not contain any elements assignable to type int, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/OccurrenceConstraint.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions;\n\npublic abstract class OccurrenceConstraint\n{\n protected OccurrenceConstraint(int expectedCount)\n {\n if (expectedCount < 0)\n {\n throw new ArgumentOutOfRangeException(nameof(expectedCount), \"Expected count cannot be negative.\");\n }\n\n ExpectedCount = expectedCount;\n }\n\n internal int ExpectedCount { get; }\n\n internal abstract string Mode { get; }\n\n internal abstract bool Assert(int actual);\n\n internal void RegisterContextData(Action register)\n {\n register(\"expectedOccurrence\", $\"{Mode} {ExpectedCount.Times()}\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/EnumerableExtensions.cs", "using System.Collections.Generic;\nusing System.Text;\n\nnamespace AwesomeAssertions.Formatting;\n\ninternal static class EnumerableExtensions\n{\n internal static string JoinUsingWritingStyle(this IEnumerable items)\n {\n var buffer = new StringBuilder();\n\n T lastItem = default;\n bool first = true;\n\n foreach (var item in items)\n {\n if (first)\n {\n first = false;\n }\n else\n {\n if (buffer.Length > 0)\n {\n buffer.Append(\", \");\n }\n\n buffer.Append(lastItem);\n }\n\n lastItem = item;\n }\n\n if (buffer.Length > 0)\n {\n buffer.Append(\" and \");\n }\n\n buffer.Append(lastItem);\n\n return buffer.ToString();\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/NUnit3.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing NUnit.Framework;\n\nnamespace NUnit3.Specs;\n\n[TestFixture]\npublic class FrameworkSpecs\n{\n [Test]\n public void When_nunit3_is_used_it_should_throw_nunit_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"NUnit.Framework.AssertionException\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n [Fact]\n public void Should_succeed_when_asserting_nullable_dateonly_value_with_value_to_have_a_value()\n {\n // Arrange\n DateOnly? dateOnly = new(2016, 06, 04);\n\n // Act/Assert\n dateOnly.Should().HaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_dateonly_value_with_value_to_not_be_null()\n {\n // Arrange\n DateOnly? dateOnly = new(2016, 06, 04);\n\n // Act/Assert\n dateOnly.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_dateonly_value_with_null_to_be_null()\n {\n // Arrange\n DateOnly? dateOnly = null;\n\n // Act/Assert\n dateOnly.Should().BeNull();\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n DateOnly earlierDateOnly = new(2016, 06, 03);\n DateOnly? nullableDateOnly = new(2016, 06, 04);\n\n // Act/Assert\n nullableDateOnly.Should()\n .HaveValue()\n .And\n .BeAfter(earlierDateOnly);\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n DateOnly someDateOnly = new(2022, 9, 25);\n\n // Act\n Action action = () => someDateOnly.Should().Equals(someDateOnly);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/TestFrameworks/MSTestV2.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\n\nnamespace MSTestV2.Specs;\n\n[TestClass]\npublic class FrameworkSpecs\n{\n [TestMethod]\n public void When_mstestv2_is_used_it_should_throw_mstest_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException\");\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/TUnit.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\n\nnamespace TUnit.Specs;\n\npublic class FrameworkSpecs\n{\n [Test]\n public void When_tunit_is_used_it_should_throw_tunit_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"TUnit.Assertions.Exceptions.AssertionException\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/TimeOnlyExtensions.cs", "#if NET6_0_OR_GREATER\nusing System;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class TimeOnlyExtensions\n{\n /// \n /// Determines if is close to within a given .\n /// \n /// The time to check\n /// The time to be close to\n /// The precision that may differ from \n /// \n /// checks the right-open interval, whereas this method checks the closed interval.\n /// \n public static bool IsCloseTo(this TimeOnly subject, TimeOnly other, TimeSpan precision)\n {\n long startTicks = other.Add(-precision).Ticks;\n long endTicks = other.Add(precision).Ticks;\n long ticks = subject.Ticks;\n\n return startTicks <= endTicks\n ? startTicks <= ticks && endTicks >= ticks\n : startTicks <= ticks || endTicks >= ticks;\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Extensibility.Specs/AssertionEngineInitializer.cs", "using System;\nusing System.Threading;\n\n// With specific initialization code to invoke before the first assertion happens\n[assembly: AwesomeAssertions.Extensibility.AssertionEngineInitializer(\n typeof(AwesomeAssertions.Extensibility.Specs.AssertionEngineInitializer),\n nameof(AwesomeAssertions.Extensibility.Specs.AssertionEngineInitializer.InitializeBeforeFirstAssertion))]\n\n[assembly: AwesomeAssertions.Extensibility.AssertionEngineInitializer(\n typeof(AwesomeAssertions.Extensibility.Specs.AssertionEngineInitializer),\n nameof(AwesomeAssertions.Extensibility.Specs.AssertionEngineInitializer.InitializeBeforeFirstAssertionButThrow))]\n\nnamespace AwesomeAssertions.Extensibility.Specs;\n\npublic static class AssertionEngineInitializer\n{\n private static int shouldBeCalledOnlyOnce;\n\n public static int ShouldBeCalledOnlyOnce => shouldBeCalledOnlyOnce;\n\n public static void InitializeBeforeFirstAssertion()\n {\n Interlocked.Increment(ref shouldBeCalledOnlyOnce);\n }\n\n public static void InitializeBeforeFirstAssertionButThrow()\n {\n throw new InvalidOperationException(\"Bogus exception to make sure the engine ignores them\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeLessThanOrEqualTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void A_float_can_never_be_less_than_or_equal_to_NaN()\n {\n // Arrange\n float? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_or_equal_to_another_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_less_than_or_equal_to_NaN()\n {\n // Arrange\n double? value = 3.4;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_or_equal_to_another_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeGreaterThanOrEqualTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void A_float_can_never_be_greater_than_or_equal_to_NaN()\n {\n // Arrange\n float? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_or_equal_to_another_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_greater_than_or_equal_to_NaN()\n {\n // Arrange\n double? value = 3.4;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_or_equal_to_another_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeOneOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The BeOneOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n string value = \"abc\";\n\n // Act\n Action action = () => value.Should().BeOneOf(\"def\", \"xyz\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {\\\"def\\\", \\\"xyz\\\"}, but found \\\"abc\\\".\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n string value = \"abc\";\n\n // Act\n Action action = () => value.Should().BeOneOf([\"def\", \"xyz\"], \"because those are the valid values\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected value to be one of {\\\"def\\\", \\\"xyz\\\"} because those are the valid values, but found \\\"abc\\\".\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n string value = \"abc\";\n\n // Act / Assert\n value.Should().BeOneOf(\"abc\", \"def\", \"xyz\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class ChainingConstraint\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n DateTime earlierDateTime = new(2016, 06, 03);\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act / Assert\n nullableDateTime.Should()\n .HaveValue()\n .And\n .BeAfter(earlierDateTime);\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n DateTime someDateTime = new(2022, 9, 25, 13, 38, 42, DateTimeKind.Utc);\n\n // Act\n Action action = () => someDateTime.Should().Equals(someDateTime);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals_with_a_range()\n {\n // Arrange\n DateTime someDateTime = new(2022, 9, 25, 13, 38, 42, DateTimeKind.Utc);\n\n // Act\n Action action = () => someDateTime.Should().BeLessThan(0.Seconds()).Equals(someDateTime);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Before() or After() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeNull.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeNull specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void When_collection_is_expected_to_be_null_and_it_is_it_should_not_throw()\n {\n // Arrange\n IEnumerable someCollection = null;\n\n // Act / Assert\n someCollection.Should().BeNull();\n }\n\n [Fact]\n public void When_collection_is_expected_to_be_null_and_it_isnt_it_should_throw()\n {\n // Arrange\n IEnumerable someCollection = new string[0];\n\n // Act\n Action act = () => someCollection.Should().BeNull(\"because {0} is valid\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someCollection to be because null is valid, but found {empty}.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_collection_is_not_expected_to_be_null_and_it_isnt_it_should_not_throw()\n {\n // Arrange\n IEnumerable someCollection = new string[0];\n\n // Act / Assert\n someCollection.Should().NotBeNull();\n }\n\n [Fact]\n public void When_collection_is_not_expected_to_be_null_and_it_is_it_should_throw()\n {\n // Arrange\n IEnumerable someCollection = null;\n\n // Act\n Action act = () => someCollection.Should().NotBeNull(\"because {0} should not\", \"someCollection\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someCollection not to be because someCollection should not.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/TypeExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Types;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Extension methods for getting method and property selectors for a type.\n/// \n[DebuggerNonUserCode]\npublic static class TypeExtensions\n{\n /// \n /// Returns the types that are visible outside the specified .\n /// \n public static TypeSelector Types(this Assembly assembly)\n {\n return new TypeSelector(assembly.GetTypes());\n }\n\n /// \n /// Returns a type selector for the current .\n /// \n public static TypeSelector Types(this Type type)\n {\n return new TypeSelector(type);\n }\n\n /// \n /// Returns a type selector for the current .\n /// \n public static TypeSelector Types(this IEnumerable types)\n {\n return new TypeSelector(types);\n }\n\n /// \n /// Returns a method selector for the current .\n /// \n /// is .\n public static MethodInfoSelector Methods(this Type type)\n {\n return new MethodInfoSelector(type);\n }\n\n /// \n /// Returns a method selector for the current .\n /// \n /// is .\n public static MethodInfoSelector Methods(this TypeSelector typeSelector)\n {\n Guard.ThrowIfArgumentIsNull(typeSelector);\n\n return new MethodInfoSelector(typeSelector.ToList());\n }\n\n /// \n /// Returns a property selector for the current .\n /// \n /// is .\n public static PropertyInfoSelector Properties(this Type type)\n {\n return new PropertyInfoSelector(type);\n }\n\n /// \n /// Returns a property selector for the current .\n /// \n /// is .\n public static PropertyInfoSelector Properties(this TypeSelector typeSelector)\n {\n Guard.ThrowIfArgumentIsNull(typeSelector);\n\n return new PropertyInfoSelector(typeSelector.ToList());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Exactly.cs", "namespace AwesomeAssertions;\n\npublic static class Exactly\n{\n public static OccurrenceConstraint Once() => new ExactlyTimesConstraint(1);\n\n public static OccurrenceConstraint Twice() => new ExactlyTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new ExactlyTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new ExactlyTimesConstraint(expected);\n\n private sealed class ExactlyTimesConstraint : OccurrenceConstraint\n {\n internal ExactlyTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"exactly\";\n\n internal override bool Assert(int actual) => actual == ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AtMost.cs", "namespace AwesomeAssertions;\n\npublic static class AtMost\n{\n public static OccurrenceConstraint Once() => new AtMostTimesConstraint(1);\n\n public static OccurrenceConstraint Twice() => new AtMostTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new AtMostTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new AtMostTimesConstraint(expected);\n\n private sealed class AtMostTimesConstraint : OccurrenceConstraint\n {\n internal AtMostTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"at most\";\n\n internal override bool Assert(int actual) => actual <= ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AtLeast.cs", "namespace AwesomeAssertions;\n\npublic static class AtLeast\n{\n public static OccurrenceConstraint Once() => new AtLeastTimesConstraint(1);\n\n public static OccurrenceConstraint Twice() => new AtLeastTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new AtLeastTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new AtLeastTimesConstraint(expected);\n\n private sealed class AtLeastTimesConstraint : OccurrenceConstraint\n {\n internal AtLeastTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"at least\";\n\n internal override bool Assert(int actual) => actual >= ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/MoreThan.cs", "namespace AwesomeAssertions;\n\npublic static class MoreThan\n{\n public static OccurrenceConstraint Once() => new MoreThanTimesConstraint(1);\n\n public static OccurrenceConstraint Twice() => new MoreThanTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new MoreThanTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new MoreThanTimesConstraint(expected);\n\n private sealed class MoreThanTimesConstraint : OccurrenceConstraint\n {\n internal MoreThanTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"more than\";\n\n internal override bool Assert(int actual) => actual > ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/LessThan.cs", "namespace AwesomeAssertions;\n\npublic static class LessThan\n{\n public static OccurrenceConstraint Twice() => new LessThanTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new LessThanTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new LessThanTimesConstraint(expected);\n\n private sealed class LessThanTimesConstraint : OccurrenceConstraint\n {\n internal LessThanTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"less than\";\n\n internal override bool Assert(int actual) => actual < ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n [Fact]\n public void When_chaining_constraints_with_and_should_not_throw()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n int smallerValue = 1;\n\n // Act / Assert\n value.Should()\n .BePositive()\n .And\n .BeGreaterThan(smallerValue)\n .And\n .BeLessThan(greaterValue);\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action action = () => value.Should().Equals(1);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Configuration/TestFramework.cs", "namespace AwesomeAssertions.Configuration;\n\n/// \n/// The test frameworks supported by Awesome Assertions.\n/// \npublic enum TestFramework\n{\n XUnit2,\n XUnit3,\n TUnit,\n MsTest,\n NUnit,\n MSpec\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeNull.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetime_value_without_a_value_to_be_null()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act / Assert\n nullableDateTime.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetime_value_with_a_value_to_be_null()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act\n Action action = () =>\n nullableDateTime.Should().BeNull();\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetime_value_with_a_value_to_not_be_null()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act / Assert\n nullableDateTime.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetime_value_without_a_value_to_not_be_null()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act\n Action action = () => nullableDateTime.Should().NotBeNull();\n\n // Assert\n action.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveValue.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetime_value_with_a_value_to_have_a_value()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act / Assert\n nullableDateTime.Should().HaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetime_value_without_a_value_to_have_a_value()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act\n Action action = () => nullableDateTime.Should().HaveValue();\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class NotHaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetime_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act / Assert\n nullableDateTime.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetime_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act\n Action action = () =>\n nullableDateTime.Should().NotHaveValue();\n\n // Assert\n action.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/CSharpAccessModifierExtensions.cs", "using System;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class CSharpAccessModifierExtensions\n{\n internal static CSharpAccessModifier GetCSharpAccessModifier(this MethodBase methodBase)\n {\n if (methodBase.IsPrivate)\n {\n return CSharpAccessModifier.Private;\n }\n\n if (methodBase.IsFamily)\n {\n return CSharpAccessModifier.Protected;\n }\n\n if (methodBase.IsAssembly)\n {\n return CSharpAccessModifier.Internal;\n }\n\n if (methodBase.IsPublic)\n {\n return CSharpAccessModifier.Public;\n }\n\n if (methodBase.IsFamilyOrAssembly)\n {\n return CSharpAccessModifier.ProtectedInternal;\n }\n\n if (methodBase.IsFamilyAndAssembly)\n {\n return CSharpAccessModifier.PrivateProtected;\n }\n\n return CSharpAccessModifier.InvalidForCSharp;\n }\n\n internal static CSharpAccessModifier GetCSharpAccessModifier(this FieldInfo fieldInfo)\n {\n if (fieldInfo.IsPrivate)\n {\n return CSharpAccessModifier.Private;\n }\n\n if (fieldInfo.IsFamily)\n {\n return CSharpAccessModifier.Protected;\n }\n\n if (fieldInfo.IsAssembly)\n {\n return CSharpAccessModifier.Internal;\n }\n\n if (fieldInfo.IsPublic)\n {\n return CSharpAccessModifier.Public;\n }\n\n if (fieldInfo.IsFamilyOrAssembly)\n {\n return CSharpAccessModifier.ProtectedInternal;\n }\n\n if (fieldInfo.IsFamilyAndAssembly)\n {\n return CSharpAccessModifier.PrivateProtected;\n }\n\n return CSharpAccessModifier.InvalidForCSharp;\n }\n\n internal static CSharpAccessModifier GetCSharpAccessModifier(this Type type)\n {\n if (type.IsNestedPrivate)\n {\n return CSharpAccessModifier.Private;\n }\n\n if (type.IsNestedFamily)\n {\n return CSharpAccessModifier.Protected;\n }\n\n if (type.IsNestedAssembly || type.IsNotPublic)\n {\n return CSharpAccessModifier.Internal;\n }\n\n if (type.IsPublic || type.IsNestedPublic)\n {\n return CSharpAccessModifier.Public;\n }\n\n if (type.IsNestedFamORAssem)\n {\n return CSharpAccessModifier.ProtectedInternal;\n }\n\n return CSharpAccessModifier.InvalidForCSharp;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/AssertionFailedException.cs", "using System;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents the default exception in case no test framework is configured.\n/// \n/// The mandatory exception message\n#pragma warning disable CA1032, RCS1194 // AssertionFailedException should never be constructed with an empty message\npublic class AssertionFailedException(string message) : Exception(message), IAssertionException\n#pragma warning restore CA1032, RCS1194\n{\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AndWhichConstraintSpecs.cs", "using System;\nusing AwesomeAssertions.Collections;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class AndWhichConstraintSpecs\n{\n [Fact]\n public void When_many_objects_are_provided_accessing_which_should_throw_a_descriptive_exception()\n {\n // Arrange\n var continuation = new AndWhichConstraint(null, [\"hello\", \"world\"]);\n\n // Act\n Action act = () => _ = continuation.Which;\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"More than one object found. AwesomeAssertions cannot determine which object is meant.*\")\n .WithMessage(\"*Found objects:*\\\"hello\\\"*\\\"world\\\"\");\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/MSpec.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing Machine.Specifications;\n\nnamespace MSpec.Specs;\n\n[Subject(\"FrameworkSpecs\")]\npublic class When_mspec_is_used\n{\n Because of = () => Exception = Catch.Exception(() => 0.Should().Be(1));\n\n It should_fail = () => Exception.Should().BeAssignableTo();\n\n // Don't reference the exception type explicitly like this: Exception.Should().BeAssignableTo()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n It should_fail_with_a_specification_exception = () => Exception.GetType().FullName.Should().Be(\"Machine.Specifications.SpecificationException\");\n\n private static Exception Exception;\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeNull.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_without_a_value_to_be_null()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act / Assert\n nullableInteger.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_with_a_value_to_be_null()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () => nullableInteger.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_numeric_value_with_a_value_to_be_null()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () => nullableInteger.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found 1.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_with_value_to_not_be_null()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act / Assert\n nullableInteger.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_without_a_value_to_not_be_null()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act\n Action act = () => nullableInteger.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n Should_fail_with_descriptive_message_when_asserting_nullable_numeric_value_without_a_value_to_not_be_null()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act\n Action act = () => nullableInteger.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.BeNull.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class BeNull\n {\n [Fact]\n public void When_collection_is_expected_to_be_null_and_it_is_it_should_not_throw()\n {\n // Arrange\n IEnumerable someCollection = null;\n\n // Act / Assert\n someCollection.Should().BeNull();\n }\n\n [Fact]\n public void When_collection_is_expected_to_be_null_and_it_isnt_it_should_throw()\n {\n // Arrange\n IEnumerable someCollection = new string[0];\n\n // Act\n Action act = () => someCollection.Should().BeNull(\"because {0} is valid\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someCollection to be because null is valid, but found {empty}.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_collection_is_not_expected_to_be_null_and_it_is_it_should_throw()\n {\n // Arrange\n IEnumerable someCollection = null;\n\n // Act\n Action act = () => someCollection.Should().NotBeNull(\"because {0} should not\", \"someCollection\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someCollection not to be because someCollection should not.\");\n }\n\n [Fact]\n public void When_collection_is_not_expected_to_be_null_and_it_isnt_it_should_not_throw()\n {\n // Arrange\n IEnumerable someCollection = new string[0];\n\n // Act / Assert\n someCollection.Should().NotBeNull();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.HaveValue.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class HaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_with_value_to_have_a_value()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act / Assert\n nullableInteger.Should().HaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_without_a_value_to_have_a_value()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act\n Action act = () => nullableInteger.Should().HaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n Should_fail_with_descriptive_message_when_asserting_nullable_numeric_value_without_a_value_to_have_a_value()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act\n Action act = () => nullableInteger.Should().HaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n }\n\n public class NotHaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act / Assert\n nullableInteger.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () => nullableInteger.Should().NotHaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_nullable_value_with_unexpected_value_is_found_it_should_throw_with_message()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action action = () => nullableInteger.Should().NotHaveValue(\"it was {0} expected\", \"not\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect a value because it was not expected, but found 1.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/IEventRecording.cs", "using System;\nusing System.Collections.Generic;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Represents an (active) recording of all events that happen(ed) while monitoring an object.\n/// \npublic interface IEventRecording : IEnumerable\n{\n /// \n /// The object events are recorded from\n /// \n object EventObject { get; }\n\n /// \n /// The name of the event that's recorded\n /// \n string EventName { get; }\n\n /// \n /// The type of the event handler identified by .\n /// \n Type EventHandlerType { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.SatisfyRespectively.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class SatisfyRespectively\n {\n [Fact]\n public void When_string_collection_satisfies_all_inspectors_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"John\", \"Jane\"];\n\n // Act / Assert\n collection.Should().SatisfyRespectively(\n value => value.Should().Be(\"John\"),\n value => value.Should().Be(\"Jane\")\n );\n }\n\n [Fact]\n public void When_string_collection_does_not_satisfy_all_inspectors_it_should_throw()\n {\n // Arrange\n string[] collection = [\"Jack\", \"Jessica\"];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(new Action[]\n {\n value => value.Should().Be(\"John\"),\n value => value.Should().Be(\"Jane\")\n }, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected collection to satisfy all inspectors because we want to test the failure message, but some inspectors are not satisfied\n *Jack*John\n *Jessica*Jane*\n \"\"\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeNegative.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeNegative\n {\n [Fact]\n public void NaN_is_never_a_negative_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_a_negative_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BePositive.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BePositive\n {\n [Fact]\n public void NaN_is_never_a_positive_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_a_positive_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/MemberExecutionTime.cs", "using System;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Specialized;\n\npublic class MemberExecutionTime : ExecutionTime\n{\n /// \n /// Initializes a new instance of the class.\n /// \n /// The object that exposes the method or property.\n /// A reference to the method or property to measure the execution time of.\n /// is .\n /// is .\n public MemberExecutionTime(T subject, Expression> action, StartTimer createTimer)\n : base(() => action.Compile()(subject), \"(\" + action.Body + \")\", createTimer)\n {\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/OccurredEvent.cs", "using System;\nusing System.ComponentModel;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Represents an occurrence of a particular event.\n/// \npublic class OccurredEvent\n{\n /// \n /// The name of the event as defined on the monitored object.\n /// \n public string EventName { get; set; }\n\n /// \n /// The parameters that were passed to the event handler.\n /// \n public object[] Parameters { get; set; }\n\n /// \n /// The exact date and time of the occurrence in .\n /// \n public DateTime TimestampUtc { get; set; }\n\n /// \n /// The order in which this event was raised on the monitored object.\n /// \n public int Sequence { get; set; }\n\n /// \n /// Verifies if a property changed event is affecting a particular property.\n /// \n /// \n /// The property name for which the property changed event should have been raised.\n /// \n /// \n /// Returns if the event is affecting the property specified, otherwise.\n /// \n internal bool IsAffectingPropertyName(string propertyName)\n {\n return Parameters.OfType()\n .Any(e => string.IsNullOrEmpty(e.PropertyName) || e.PropertyName == propertyName);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.AllSatisfy.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class AllSatisfy\n {\n [Fact]\n public void All_items_satisfying_inspector_should_succeed()\n {\n // Arrange\n string[] collection = [\"John\", \"John\"];\n\n // Act / Assert\n collection.Should().AllSatisfy(value => value.Should().Be(\"John\"));\n }\n\n [Fact]\n public void Any_items_not_satisfying_inspector_should_throw()\n {\n // Arrange\n string[] collection = [\"Jack\", \"Jessica\"];\n\n // Act\n Action act = () => collection.Should()\n .AllSatisfy(\n value => value.Should().Be(\"John\"),\n \"because we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\n \"Expected collection to contain only items satisfying the inspector because we want to test the failure message:\"\n + \"*Jack*John\"\n + \"*Jessica*John*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Configuration/GlobalFormattingOptions.cs", "using AwesomeAssertions.Common;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Configuration;\n\npublic class GlobalFormattingOptions : FormattingOptions\n{\n private string valueFormatterAssembly;\n\n public string ValueFormatterAssembly\n {\n get => valueFormatterAssembly;\n set\n {\n valueFormatterAssembly = value;\n ValueFormatterDetectionMode = ValueFormatterDetectionMode.Specific;\n }\n }\n\n public ValueFormatterDetectionMode ValueFormatterDetectionMode { get; set; }\n\n internal new GlobalFormattingOptions Clone()\n {\n return new GlobalFormattingOptions\n {\n UseLineBreaks = UseLineBreaks,\n MaxDepth = MaxDepth,\n MaxLines = MaxLines,\n StringPrintLength = StringPrintLength,\n ScopedFormatters = [.. ScopedFormatters],\n ValueFormatterAssembly = ValueFormatterAssembly,\n ValueFormatterDetectionMode = ValueFormatterDetectionMode\n };\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/FallbackTestFramework.cs", "using System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Throws a generic exception in case no other test harness is detected.\n/// \ninternal class FallbackTestFramework : ITestFramework\n{\n /// \n /// Gets a value indicating whether the corresponding test framework is currently available.\n /// \n public bool IsAvailable => true;\n\n /// \n /// Throws a framework-specific exception to indicate a failing unit test.\n /// \n [DoesNotReturn]\n public void Throw(string message)\n {\n throw new AssertionFailedException(message);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/Continuation.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// Enables chaining multiple assertions on an .\n/// \npublic class Continuation\n{\n internal Continuation(AssertionChain parent)\n {\n Then = parent;\n }\n\n /// \n /// Continues the assertion chain if the previous assertion was successful.\n /// \n public AssertionChain Then { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/TUnitFramework.cs", "namespace AwesomeAssertions.Execution;\n\ninternal class TUnitFramework() : LateBoundTestFramework(loadAssembly: true)\n{\n protected override string ExceptionFullName => \"TUnit.Assertions.Exceptions.AssertionException\";\n\n protected internal override string AssemblyName => \"TUnit.Assertions\";\n}\n"], ["/AwesomeAssertions/Build/Configuration.cs", "using System.ComponentModel;\nusing Nuke.Common.Tooling;\n\n[TypeConverter(typeof(TypeConverter))]\npublic class Configuration : Enumeration\n{\n public static readonly Configuration Debug = new() { Value = nameof(Debug) };\n\n public static readonly Configuration CI = new() { Value = nameof(CI) };\n\n public static implicit operator string(Configuration configuration)\n {\n return configuration.Value;\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/LargeObjectGraphBenchmarks.cs", "using System;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Primitives;\nusing BenchmarkDotNet.Attributes;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\npublic class LargeObjectGraphBenchmarks\n{\n [Params(16, 18, 20, 24, 28)]\n public int N { get; set; }\n\n private Nested copy1;\n private Nested copy2;\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n int objectCount = 0;\n\n copy1 = Nested.Create(N, ref objectCount);\n\n objectCount = 0;\n\n copy2 = Nested.Create(N, ref objectCount);\n\n Console.WriteLine(\"N = {0} ; Graph size: {1} objects\", N, objectCount);\n }\n\n [Benchmark]\n public AndConstraint BeEquivalentTo() =>\n copy1.Should().BeEquivalentTo(copy2, config => config.AllowingInfiniteRecursion());\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventMonitorOptions.cs", "using System;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Settings for the EventMonitor.\n/// \npublic class EventMonitorOptions\n{\n /// \n /// Will ignore the events, if they throw an exception on any custom event accessor implementation. default: false.\n /// \n internal bool ShouldIgnoreEventAccessorExceptions { get; private set; }\n\n /// \n /// This will record the event, even if the event accessor add event threw an exception. To ignore exceptions in the event add accessor, call property to set it to true. default: false.\n /// \n internal bool ShouldRecordEventsWithBrokenAccessor { get; private set; }\n\n /// \n /// Func used to generate the timestamp.\n /// \n internal Func TimestampProvider { get; private set; } = () => DateTime.UtcNow;\n\n /// \n /// When called it will ignore event accessor Exceptions.\n /// \n public EventMonitorOptions IgnoringEventAccessorExceptions()\n {\n ShouldIgnoreEventAccessorExceptions = true;\n return this;\n }\n\n /// \n /// When called it will record the event even when the accessor threw an exception.\n /// \n public EventMonitorOptions RecordingEventsWithBrokenAccessor()\n {\n ShouldRecordEventsWithBrokenAccessor = true;\n return this;\n }\n\n /// \n /// Sets the timestamp provider. By default it is .\n /// \n /// The timestamp provider.\n internal EventMonitorOptions ConfigureTimestampProvider(Func timestampProvider)\n {\n if (timestampProvider != null)\n {\n TimestampProvider = timestampProvider;\n }\n\n return this;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/TimeSpanPredicate.cs", "using System;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Provides the logic and the display text for a .\n/// \ninternal class TimeSpanPredicate\n{\n private readonly Func lambda;\n\n public TimeSpanPredicate(Func lambda, string displayText)\n {\n this.lambda = lambda;\n DisplayText = displayText;\n }\n\n public string DisplayText { get; }\n\n public bool IsMatchedBy(TimeSpan actual, TimeSpan expected)\n {\n return lambda(actual, expected) && actual >= TimeSpan.Zero;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/StopwatchTimer.cs", "using System;\nusing System.Diagnostics;\n\nnamespace AwesomeAssertions.Common;\n\ninternal sealed class StopwatchTimer : ITimer\n{\n private readonly Stopwatch stopwatch = Stopwatch.StartNew();\n\n public TimeSpan Elapsed => stopwatch.Elapsed;\n\n public void Dispose()\n {\n if (stopwatch.IsRunning)\n {\n // We want to keep the elapsed time available after the timer is disposed, so disposing\n // just stops it.\n stopwatch.Stop();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/NUnitTestFramework.cs", "namespace AwesomeAssertions.Execution;\n\ninternal class NUnitTestFramework : LateBoundTestFramework\n{\n protected internal override string AssemblyName => \"nunit.framework\";\n\n protected override string ExceptionFullName => \"NUnit.Framework.AssertionException\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/MSpecFramework.cs", "namespace AwesomeAssertions.Execution;\n\ninternal class MSpecFramework : LateBoundTestFramework\n{\n protected internal override string AssemblyName => \"Machine.Specifications\";\n\n protected override string ExceptionFullName => \"Machine.Specifications.SpecificationException\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/FormatChild.cs", "namespace AwesomeAssertions.Formatting;\n\n/// \n/// Represents a method that can be used to format child values from inside an .\n/// \n/// \n/// Represents the path from the current location to the child value.\n/// \n/// \n/// The child value to format with the configured s.\n/// \npublic delegate void FormatChild(string childPath, object value, FormattedObjectGraph formattedGraph);\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/MSTestFrameworkV2.cs", "namespace AwesomeAssertions.Execution;\n\ninternal class MSTestFrameworkV2 : LateBoundTestFramework\n{\n protected override string ExceptionFullName => \"Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException\";\n\n protected internal override string AssemblyName => \"Microsoft.VisualStudio.TestPlatform.TestFramework\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ExceptionExtensions.cs", "using System;\nusing System.Reflection;\nusing System.Runtime.ExceptionServices;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class ExceptionExtensions\n{\n public static ExceptionDispatchInfo Unwrap(this TargetInvocationException exception)\n {\n Exception result = exception;\n\n while (result is TargetInvocationException)\n {\n result = result.InnerException;\n }\n\n return ExceptionDispatchInfo.Capture(result);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/IntegerExtensions.cs", "namespace AwesomeAssertions.Common;\n\ninternal static class IntegerExtensions\n{\n public static string Times(this int count) => count == 1 ? \"1 time\" : $\"{count} times\";\n\n internal static bool IsConsecutiveTo(this int startNumber, int endNumber) => endNumber == (startNumber + 1);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Polyfill/StringBuilderExtensions.cs", "#if NET47 || NETSTANDARD2_0 || NETSTANDARD2_1\n\nusing System.Collections.Generic;\n\n// ReSharper disable once CheckNamespace\nnamespace System.Text;\n\n/// \n/// Since net6.0 StringBuilder has additional overloads taking an AppendInterpolatedStringHandler\n/// and optionally an IFormatProvider.\n/// The overload here is polyfill for older target frameworks to avoid littering the code base with #ifs\n/// in order to silence analyzers about depending on the current culture instead of an invariant culture.\n/// \ninternal static class StringBuilderExtensions\n{\n public static StringBuilder AppendLine(this StringBuilder stringBuilder, IFormatProvider _, string value) =>\n stringBuilder.AppendLine(value);\n\n#if NET47 || NETSTANDARD2_0\n public static StringBuilder AppendJoin(this StringBuilder stringBuilder, string separator, IEnumerable values) =>\n stringBuilder.Append(string.Join(separator, values));\n#endif\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/ObjectCastingSpecs.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class ObjectCastingSpecs\n{\n [Fact]\n public void When_casting_an_object_using_the_as_operator_it_should_return_the_expected_type()\n {\n // Arrange\n SomeBaseClass baseInstance = new SomeDerivedClass\n {\n DerivedProperty = \"hello\"\n };\n\n // Act\n SomeDerivedClass derivedInstance = baseInstance.As();\n\n // Assert\n derivedInstance.DerivedProperty.Should().Be(\"hello\");\n }\n\n private class SomeBaseClass;\n\n private class SomeDerivedClass : SomeBaseClass\n {\n public string DerivedProperty { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/ContinuationOfGiven.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// Enables chaining multiple assertions from a call.\n/// \npublic class ContinuationOfGiven\n{\n internal ContinuationOfGiven(GivenSelector parent)\n {\n Then = parent;\n }\n\n /// \n /// Continues the assertion chain if the previous assertion was successful.\n /// \n public GivenSelector Then { get; }\n\n public bool Succeeded => Then.Succeeded;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/CSharpAccessModifier.cs", "namespace AwesomeAssertions.Common;\n\npublic enum CSharpAccessModifier\n{\n Public,\n Private,\n Protected,\n Internal,\n ProtectedInternal,\n InvalidForCSharp,\n PrivateProtected,\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/FluentActions.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Threading.Tasks;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Contains static methods to help with exception assertions on actions.\n/// \n[DebuggerNonUserCode]\npublic static class FluentActions\n{\n /// \n /// Invokes the specified action so that you can assert that it throws an exception.\n /// \n [Pure]\n public static Action Invoking(Action action) => action;\n\n /// \n /// Invokes the specified action so that you can assert that it throws an exception.\n /// \n [Pure]\n public static Func Invoking(Func func) => func;\n\n /// \n /// Invokes the specified action so that you can assert that it throws an exception.\n /// \n [Pure]\n public static Func Awaiting(Func action) => action;\n\n /// \n /// Invokes the specified action so that you can assert that it throws an exception.\n /// \n [Pure]\n public static Func> Awaiting(Func> func) => func;\n\n /// \n /// Forces enumerating a collection. Should be used to assert that a method that uses the\n /// keyword throws a particular exception.\n /// \n [Pure]\n public static Action Enumerating(Func enumerable) => enumerable.Enumerating();\n\n /// \n /// Forces enumerating a collection. Should be used to assert that a method that uses the\n /// keyword throws a particular exception.\n /// \n [Pure]\n public static Action Enumerating(Func> enumerable) => enumerable.Enumerating();\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/HasValueSemanticsBenchmarks.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing BenchmarkDotNet.Attributes;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\npublic class HasValueSemanticsBenchmarks\n{\n [Benchmark(Baseline = true)]\n public bool HasValueSemantics_ValueType() => typeof(int).HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_Object() => typeof(object).HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_OverridesEquals() => typeof(string).HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_AnonymousType() => new { }.GetType().HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_KeyValuePair() => typeof(KeyValuePair).HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_ValueTuple() => typeof((int, int)).HasValueSemantics();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/WhoseValueConstraint.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Collections;\n\npublic class WhoseValueConstraint : AndConstraint\n where TCollection : IEnumerable>\n where TAssertions : GenericDictionaryAssertions\n{\n /// \n /// Initializes a new instance of the class.\n /// \n public WhoseValueConstraint(TAssertions parentConstraint, TValue value)\n : base(parentConstraint)\n {\n WhoseValue = value;\n }\n\n /// \n /// Gets the value of the object referred to by the key.\n /// \n public TValue WhoseValue { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/InvokingFunctionSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class InvokingFunctionSpecs\n{\n [Fact]\n public void Invoking_on_null_is_not_allowed()\n {\n // Arrange\n Does someClass = null;\n\n // Act\n Action act = () => someClass.Invoking(d => d.Return());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"subject\");\n }\n\n [Fact]\n public void Invoking_with_null_is_not_allowed()\n {\n // Arrange\n Does someClass = Does.NotThrow();\n\n // Act\n Action act = () => someClass.Invoking((Func)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/FormatterSpecsDefinition.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\n// Due to the tests that (temporarily) modify the active formatters collection.\n[CollectionDefinition(\"FormatterSpecs\", DisableParallelization = true)]\npublic class FormatterSpecsDefinition;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/IMonitor.cs", "using System;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Monitors events on a given source\n/// \npublic interface IMonitor : IDisposable\n{\n /// \n /// Gets the object that is being monitored or if the object has been GCed.\n /// \n T Subject { get; }\n\n /// \n /// Clears all recorded events from the monitor and continues monitoring.\n /// \n void Clear();\n\n /// \n /// Provides access to several assertion methods.\n /// \n EventAssertions Should();\n\n IEventRecording GetRecordingFor(string eventName);\n\n /// \n /// Gets the metadata of all the events that are currently being monitored.\n /// \n EventMetadata[] MonitoredEvents { get; }\n\n /// \n /// Gets a collection of all events that have occurred since the monitor was created or\n /// was called.\n /// \n OccurredEvent[] OccurredEvents { get; }\n}\n"], ["/AwesomeAssertions/Tests/UWP.Specs/UwpSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\n\nnamespace UWP.Specs;\n\n[TestClass]\npublic class UwpSpecs\n{\n [TestMethod]\n public void Determining_caller_identity_should_not_throw_for_native_programs()\n {\n // Arrange\n Action someAction = () => throw new Exception();\n\n // Act\n Action act = () => someAction.Should().NotThrow();\n\n // Assert\n act.Should().Throw();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/DateTimeExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Common;\n\npublic static class DateTimeExtensions\n{\n /// \n /// Converts an existing to a but normalizes the \n /// so that comparisons of converted instances retain the UTC/local agnostic behavior.\n /// \n public static DateTimeOffset ToDateTimeOffset(this DateTime dateTime)\n {\n return dateTime.ToDateTimeOffset(TimeSpan.Zero);\n }\n\n public static DateTimeOffset ToDateTimeOffset(this DateTime dateTime, TimeSpan offset)\n {\n return new DateTimeOffset(DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified), offset);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/IClock.cs", "using System;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Represents an abstract timer that is used to make some of this library's timing dependent functionality better testable.\n/// \npublic interface IClock\n{\n /// \n /// Will block the current thread until a time delay has passed.\n /// \n /// The time span to wait before completing the returned task\n void Delay(TimeSpan timeToDelay);\n\n /// \n /// Creates a task that will complete after a time delay.\n /// \n /// The time span to wait before completing the returned task\n /// \n /// A task that represents the time delay.\n /// \n Task DelayAsync(TimeSpan delay, CancellationToken cancellationToken);\n\n /// \n /// Creates a timer to measure the time to complete some arbitrary executions.\n /// \n ITimer StartTimer();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/InvokingActionSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class InvokingActionSpecs\n{\n [Fact]\n public void Invoking_on_null_is_not_allowed()\n {\n // Arrange\n Does someClass = null;\n\n // Act\n Action act = () => someClass.Invoking(d => d.Do());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"subject\");\n }\n\n [Fact]\n public void Invoking_with_null_is_not_allowed()\n {\n // Arrange\n Does someClass = Does.NotThrow();\n\n // Act\n Action act = () => someClass.Invoking(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/ITestFramework.cs", "using System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents an abstraction of a particular test framework such as MSTest, nUnit, etc.\n/// \npublic interface ITestFramework\n{\n /// \n /// Gets a value indicating whether the corresponding test framework is currently available.\n /// \n bool IsAvailable { get; }\n\n /// \n /// Throws a framework-specific exception to indicate a failing unit test.\n /// \n [DoesNotReturn]\n void Throw(string message);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/ICloneable2.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// Custom version of ICloneable that works on all frameworks.\n/// \npublic interface ICloneable2\n{\n /// \n /// Creates a new object that is a copy of the current instance.\n /// \n /// \n /// A new object that is a copy of this instance.\n /// \n object Clone();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensions/OccurrenceConstraintExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Extensions;\n\n/// \n/// Provides extensions to write s with fluent syntax\n/// \npublic static class OccurrenceConstraintExtensions\n{\n /// \n /// This is the equivalent to \n /// \n /// is less than zero.\n public static OccurrenceConstraint TimesExactly(this int times)\n {\n return Exactly.Times(times);\n }\n\n /// \n /// This is the equivalent to \n /// \n /// is less than zero.\n public static OccurrenceConstraint TimesOrLess(this int times)\n {\n return AtMost.Times(times);\n }\n\n /// \n /// This is the equivalent to \n /// \n /// is less than zero.\n public static OccurrenceConstraint TimesOrMore(this int times)\n {\n return AtLeast.Times(times);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act / Assert\n nullableInteger.Should()\n .HaveValue()\n .And\n .BePositive();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/IExtractExceptions.cs", "using System;\nusing System.Collections.Generic;\n\nnamespace AwesomeAssertions.Specialized;\n\npublic interface IExtractExceptions\n{\n IEnumerable OfType(Exception actualException)\n where T : Exception;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Disposable.cs", "using System;\n\nnamespace AwesomeAssertions;\n\ninternal sealed class Disposable : IDisposable\n{\n private readonly Action action;\n\n public Disposable(Action action)\n {\n this.action = action;\n }\n\n public void Dispose()\n {\n action();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Polyfill/SystemExtensions.cs", "#if NET47 || NETSTANDARD2_0\n\n// ReSharper disable once CheckNamespace\nnamespace System;\n\ninternal static class SystemExtensions\n{\n // https://docs.microsoft.com/en-us/dotnet/api/system.string.indexof?view=netframework-4.8#System_String_IndexOf_System_Char_\n public static int IndexOf(this string str, char c, StringComparison _) =>\n str.IndexOf(c);\n\n // https://docs.microsoft.com/en-us/dotnet/api/system.string.replace?view=netframework-4.8#System_String_Replace_System_String_System_String_\n public static string Replace(this string str, string oldValue, string newValue, StringComparison _) =>\n str.Replace(oldValue, newValue);\n\n // https://docs.microsoft.com/en-us/dotnet/api/system.string.indexof?view=netframework-4.8#System_String_IndexOf_System_String_System_StringComparison_\n public static bool Contains(this string str, string value, StringComparison comparison) =>\n str.IndexOf(value, comparison) != -1;\n\n public static bool Contains(this string str, char value, StringComparison comparison) =>\n str.IndexOf(value, comparison) != -1;\n\n // https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs,1014\n public static bool StartsWith(this string str, char value) =>\n str.Length != 0 && str[0] == value;\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventMetadata.cs", "using System;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Provides the metadata of a monitored event.\n/// \npublic class EventMetadata\n{\n /// \n /// The name of the event member on the monitored object\n /// \n public string EventName { get; }\n\n /// \n /// The type of the event handler and event args.\n /// \n public Type HandlerType { get; }\n\n public EventMetadata(string eventName, Type handlerType)\n {\n EventName = eventName;\n HandlerType = handlerType;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensions/StringExtensions.cs", "namespace AwesomeAssertions.Extensions;\n\ninternal static class StringExtensions\n{\n public static string FirstCharToLower(this string str) =>\n#pragma warning disable CA1308\n string.Concat(str[0].ToString().ToLowerInvariant(), str[1..]);\n#pragma warning restore CA1308\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/RecordedEvent.cs", "using System;\nusing System.Diagnostics;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// This class is used to store data about an intercepted event\n/// \n[DebuggerNonUserCode]\ninternal class RecordedEvent\n{\n /// \n /// Default constructor stores the parameters the event was raised with\n /// \n public RecordedEvent(DateTime utcNow, int sequence, params object[] parameters)\n {\n Parameters = parameters;\n TimestampUtc = utcNow;\n Sequence = sequence;\n }\n\n /// \n /// The exact data and time in UTC format at which the event occurred.\n /// \n public DateTime TimestampUtc { get; }\n\n /// \n /// Parameters for the event\n /// \n public object[] Parameters { get; }\n\n /// \n /// The order in which this event was invoked on the monitored object.\n /// \n public int Sequence { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/ThreadSafeSequenceGenerator.cs", "using System.Threading;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Generates a sequence in a thread-safe manner.\n/// \ninternal sealed class ThreadSafeSequenceGenerator\n{\n private int sequence = -1;\n\n /// \n /// Increments the current sequence.\n /// \n public int Increment()\n {\n return Interlocked.Increment(ref sequence);\n }\n}\n"], ["/AwesomeAssertions/Tests/AssemblyA/ClassA.cs", "using AssemblyB;\n\nnamespace AssemblyA;\n\npublic class ClassA\n{\n public void DoSomething()\n {\n _ = new ClassB();\n }\n\n public ClassC ReturnClassC()\n {\n return new ClassC();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ValueFormatterDetectionMode.cs", "using AwesomeAssertions.Configuration;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Defines the modes in which custom implementations of \n/// are detected as configured through .\n/// \npublic enum ValueFormatterDetectionMode\n{\n /// \n /// Detection is disabled.\n /// \n Disabled,\n\n /// \n /// Only custom value formatters exposed through the assembly set in \n /// are detected.\n /// \n Specific,\n\n /// \n /// All custom value formatters in any assembly loaded in the current AppDomain will be detected.\n /// \n Scan,\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/Element.cs", "namespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// Stores an element's value and index in the maximum matching problem.\n/// \n/// The type of the element value.\ninternal class Element\n{\n public Element(TValue value, int index)\n {\n Index = index;\n Value = value;\n }\n\n /// \n /// The index of the element in the maximum matching problem.\n /// \n public int Index { get; }\n\n /// \n /// The value of the element in the maximum matching problem.\n /// \n public TValue Value { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/TimeSpanCondition.cs", "namespace AwesomeAssertions.Primitives;\n\npublic enum TimeSpanCondition\n{\n MoreThan,\n AtLeast,\n Exactly,\n Within,\n LessThan\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AndConstraint.cs", "using System.Diagnostics;\n\nnamespace AwesomeAssertions;\n\n[DebuggerNonUserCode]\npublic class AndConstraint\n{\n public TParent And { get; }\n\n /// \n /// Initializes a new instance of the class.\n /// \n public AndConstraint(TParent parent)\n {\n And = parent;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/TestTimer.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Specs;\n\ninternal sealed class TestTimer : ITimer\n{\n private readonly Func getElapsed;\n\n public TestTimer(Func getElapsed)\n {\n this.getElapsed = getElapsed;\n }\n\n public TimeSpan Elapsed => getElapsed();\n\n public void Dispose()\n {\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/IAssertionException.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// This is a marker interface for xUnit.net v3 to set the test failure cause as an assertion failure.\n/// See What’s New in xUnit.net v3 - Third party assertion library extension points.\n/// \ninternal interface IAssertionException;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/FormattingContext.cs", "namespace AwesomeAssertions.Formatting;\n\n/// \n/// Provides information about the current formatting action.\n/// \npublic class FormattingContext\n{\n /// \n /// Indicates whether the formatter should use line breaks when the supports it.\n /// \n public bool UseLineBreaks { get; set; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/ParsingState.cs", "namespace AwesomeAssertions.CallerIdentification;\n\ninternal enum ParsingState\n{\n InProgress,\n GoToNextSymbol,\n Done\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AssertionConfiguration.cs", "using AwesomeAssertions.Configuration;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Provides access to the global configuration and options to customize the behavior of AwesomeAssertions.\n/// \npublic static class AssertionConfiguration\n{\n public static GlobalConfiguration Current => AssertionEngine.Configuration;\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/ConfigurationSpecsDefinition.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\n// Due to tests that call the static AssertionConfiguration or AssertionEngine, we need to disable parallelization\n[CollectionDefinition(\"ConfigurationSpecs\", DisableParallelization = true)]\npublic class ConfigurationSpecsDefinition;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ShortTypeValue.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Holds a which should be formatted in short notation, i.e. without any namespaces.\n/// \n/// The type to format.\ninternal sealed class ShortTypeValue(Type type)\n{\n /// \n /// The type to format.\n /// \n public Type Type { get; } = type;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/SortOrder.cs", "namespace AwesomeAssertions.Collections;\n\ninternal enum SortOrder\n{\n Ascending,\n Descending\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ITimer.cs", "using System;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Abstracts a stopwatch so we can control time in unit tests.\n/// \npublic interface ITimer : IDisposable\n{\n /// \n /// The time elapsed since the timer was created through .\n /// \n TimeSpan Elapsed { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/MaxLinesExceededException.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\n#pragma warning disable RCS1194, CA1032 // Add constructors\npublic class MaxLinesExceededException : Exception;\n#pragma warning restore CA1032, RCS1194\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/StartTimer.cs", "namespace AwesomeAssertions.Common;\n\n/// \n/// Factory for starting a timer on demand.\n/// \npublic delegate ITimer StartTimer();\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/IsExternalInit.cs", "using System.ComponentModel;\n\n// ReSharper disable once CheckNamespace\nnamespace System.Runtime.CompilerServices;\n\n/// \n/// Reserved to be used by the compiler for tracking metadata.\n/// This class should not be used by developers in source code.\n/// \n[EditorBrowsable(EditorBrowsableState.Never)]\ninternal static class IsExternalInit;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/IsExternalInit.cs", "using System.ComponentModel;\n\n// ReSharper disable once CheckNamespace\nnamespace System.Runtime.CompilerServices;\n\n/// \n/// Reserved to be used by the compiler for tracking metadata.\n/// This class should not be used by developers in source code.\n/// \n[EditorBrowsable(EditorBrowsableState.Never)]\ninternal static class IsExternalInit;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/UIFactsDefinition.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs;\n\n// Try to stabilize UIFact tests\n[CollectionDefinition(\"UIFacts\", DisableParallelization = true)]\npublic class UIFactsDefinition;\n"], ["/AwesomeAssertions/Tests/AssemblyB/ClassB.cs", "namespace AssemblyB;\n\npublic class ClassB;\n"], ["/AwesomeAssertions/Tests/AssemblyB/ClassC.cs", "namespace AssemblyB;\n\npublic class ClassC;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Extensibility.Specs/Usings.cs", "global using Xunit;\n"]], "task_instance_info": {"created_time": "2025-08-20 19:01:30", "created_task_model": "DeepSeek-R1", "function_skeleton": "protected override EquivalencyResult OnHandle (Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator) {}", "code_description": "This code segment functions to: Compare XML attributes for equivalency within an assertion framework by retrieving target instances, configuring validation context reuse, executing equality checks with descriptive failure messages, and returning protocol-compliant verification status."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```c_sharp\n[TASK_BEGIN]\n protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subjectAttribute = (XAttribute)comparands.Subject;\n var expectedAttribute = (XAttribute)comparands.Expectation;\n\n if (subjectAttribute.Name != expectedAttribute.Name)\n {\n throw new AssertionFailedException($\"Attribute '{context.CurrentNodePath}' does not match. Expected name '{expectedAttribute.Name}', but found '{subjectAttribute.Name}'.\");\n }\n\n if (subjectAttribute.Value != expectedAttribute.Value)\n {\n throw new AssertionFailedException($\"Attribute '{context.CurrentNodePath}' does not match. Expected value '{expectedAttribute.Value}', but found '{subjectAttribute.Value}'.\");\n }\n\n return EquivalencyResult.AssertionCompleted;\n }\n[TASK_END]\n```", "inference_time": "2025-08-20 19-01-49"}, "editdistance_info": {"edit_distance": 35.8382, "calculate_time": "2025-08-20 19:01:49", "true_code_clean": "protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subject = (XAttribute)comparands.Subject;\n var expectation = (XAttribute)comparands.Expectation;\n AssertionChain.GetOrCreate().For(context).ReuseOnce();\n subject.Should().Be(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n return EquivalencyResult.EquivalencyProven;\n }", "predict_code_clean": "protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subjectAttribute = (XAttribute)comparands.Subject;\n var expectedAttribute = (XAttribute)comparands.Expectation;\n if (subjectAttribute.Name != expectedAttribute.Name)\n {\n throw new AssertionFailedException($\"Attribute '{context.CurrentNodePath}' does not match. Expected name '{expectedAttribute.Name}', but found '{subjectAttribute.Name}'.\");\n }\n if (subjectAttribute.Value != expectedAttribute.Value)\n {\n throw new AssertionFailedException($\"Attribute '{context.CurrentNodePath}' does not match. Expected value '{expectedAttribute.Value}', but found '{subjectAttribute.Value}'.\");\n }\n return EquivalencyResult.AssertionCompleted;\n }"}} {"repo_name": "AwesomeAssertions", "file_name": "/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/SimpleEqualityEquivalencyStep.cs", "inference_info": {"prefix_code": "using AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class SimpleEqualityEquivalencyStep : IEquivalencyStep\n{\n ", "suffix_code": "\n}\n", "middle_code": "public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!context.Options.IsRecursive && !context.CurrentNode.IsRoot)\n {\n AssertionChain.GetOrCreate()\n .For(context)\n .ReuseOnce();\n comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n return EquivalencyResult.EquivalencyProven;\n }\n return EquivalencyResult.ContinueWithNext;\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "c_sharp", "sub_task_type": null}, "context_code": [["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/StructuralEqualityEquivalencyStep.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class StructuralEqualityEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!context.CurrentNode.IsRoot && !context.Options.IsRecursive)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (comparands.Expectation is null)\n {\n assertionChain\n .BecauseOf(context.Reason)\n .FailWith(\n \"Expected {context:subject} to be {reason}, but found {0}.\",\n comparands.Subject);\n }\n else if (comparands.Subject is null)\n {\n assertionChain\n .BecauseOf(context.Reason)\n .FailWith(\n \"Expected {context:object} to be {0}{reason}, but found {1}.\",\n comparands.Expectation,\n comparands.Subject);\n }\n else\n {\n IMember[] selectedMembers = GetMembersFromExpectation(context.CurrentNode, comparands, context.Options).ToArray();\n\n if (context.CurrentNode.IsRoot && selectedMembers.Length == 0)\n {\n throw new InvalidOperationException(\n \"No members were found for comparison. \" +\n \"Please specify some members to include in the comparison or choose a more meaningful assertion.\");\n }\n\n foreach (IMember selectedMember in selectedMembers)\n {\n AssertMemberEquality(comparands, context, valueChildNodes, selectedMember, context.Options);\n }\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static void AssertMemberEquality(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency parent, IMember selectedMember, IEquivalencyOptions options)\n {\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n IMember matchingMember = FindMatchFor(selectedMember, context.CurrentNode, comparands.Subject, options, assertionChain);\n if (matchingMember is not null)\n {\n var nestedComparands = new Comparands\n {\n Subject = matchingMember.GetValue(comparands.Subject),\n Expectation = selectedMember.GetValue(comparands.Expectation),\n CompileTimeType = selectedMember.Type\n };\n\n // In case the matching process selected a different member on the subject,\n // adjust the current member so that assertion failures report the proper name.\n selectedMember.AdjustForRemappedSubject(matchingMember);\n\n parent.AssertEquivalencyOf(nestedComparands, context.AsNestedMember(selectedMember));\n }\n }\n\n private static IMember FindMatchFor(IMember selectedMember, INode currentNode, object subject,\n IEquivalencyOptions config, AssertionChain assertionChain)\n {\n IEnumerable query =\n from rule in config.MatchingRules\n let match = rule.Match(selectedMember, subject, currentNode, config, assertionChain)\n where match is not null\n select match;\n\n if (config.IgnoreNonBrowsableOnSubject)\n {\n query = query.Where(member => member.IsBrowsable);\n }\n\n return query.FirstOrDefault();\n }\n\n private static IEnumerable GetMembersFromExpectation(INode currentNode, Comparands comparands,\n IEquivalencyOptions options)\n {\n IEnumerable members = [];\n\n foreach (IMemberSelectionRule rule in options.SelectionRules)\n {\n members = rule.SelectMembers(currentNode, members,\n new MemberSelectionContext(comparands.CompileTimeType, comparands.RuntimeType, options));\n }\n\n return members;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/ValueTypeEquivalencyStep.cs", "using System;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Ensures that types that are marked as value types are treated as such.\n/// \npublic class ValueTypeEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n Type expectationType = comparands.GetExpectedType(context.Options);\n EqualityStrategy strategy = context.Options.GetEqualityStrategy(expectationType);\n\n bool canHandle = strategy is EqualityStrategy.Equals or EqualityStrategy.ForceEquals;\n\n if (canHandle)\n {\n context.Tracer.WriteLine(member =>\n {\n string strategyName = strategy == EqualityStrategy.Equals\n ? $\"{expectationType} overrides Equals\"\n : \"we are forced to use Equals\";\n\n return $\"Treating {member.Expectation.Description} as a value type because {strategyName}.\";\n });\n\n AssertionChain.GetOrCreate()\n .For(context)\n .ReuseOnce();\n\n comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/StringEqualityEquivalencyStep.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class StringEqualityEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n Type expectationType = comparands.GetExpectedType(context.Options);\n\n if (expectationType is null || expectationType != typeof(string))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (!ValidateAgainstNulls(assertionChain, comparands, context.CurrentNode))\n {\n return EquivalencyResult.EquivalencyProven;\n }\n\n bool subjectIsString = ValidateSubjectIsString(assertionChain, comparands, context.CurrentNode);\n\n if (subjectIsString)\n {\n string subject = (string)comparands.Subject;\n string expectation = (string)comparands.Expectation;\n\n assertionChain.ReuseOnce();\n subject.Should()\n .Be(expectation, CreateOptions(context.Options), context.Reason.FormattedMessage, context.Reason.Arguments);\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static Func, EquivalencyOptions>\n CreateOptions(IEquivalencyOptions existingOptions) =>\n o =>\n {\n if (existingOptions is EquivalencyOptions equivalencyOptions)\n {\n return equivalencyOptions;\n }\n\n if (existingOptions.IgnoreLeadingWhitespace)\n {\n o.IgnoringLeadingWhitespace();\n }\n\n if (existingOptions.IgnoreTrailingWhitespace)\n {\n o.IgnoringTrailingWhitespace();\n }\n\n if (existingOptions.IgnoreCase)\n {\n o.IgnoringCase();\n }\n\n if (existingOptions.IgnoreNewlineStyle)\n {\n o.IgnoringNewlineStyle();\n }\n\n return o;\n };\n\n private static bool ValidateAgainstNulls(AssertionChain assertionChain, Comparands comparands, INode currentNode)\n {\n object expected = comparands.Expectation;\n object subject = comparands.Subject;\n\n bool onlyOneNull = expected is null != subject is null;\n\n if (onlyOneNull)\n {\n assertionChain.FailWith(\n $\"Expected {currentNode.Subject.Description.EscapePlaceholders()} to be {{0}}{{reason}}, but found {{1}}.\", expected, subject);\n\n return false;\n }\n\n return true;\n }\n\n private static bool ValidateSubjectIsString(AssertionChain assertionChain, Comparands comparands, INode currentNode)\n {\n if (comparands.Subject is string)\n {\n return true;\n }\n\n assertionChain.FailWith(\n $\"Expected {currentNode} to be {{0}}, but found {{1}}.\",\n comparands.RuntimeType, comparands.Subject.GetType());\n\n return assertionChain.Succeeded;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EqualityComparerEquivalencyStep.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class EqualityComparerEquivalencyStep : IEquivalencyStep\n{\n private readonly IEqualityComparer comparer;\n\n public EqualityComparerEquivalencyStep(IEqualityComparer comparer)\n {\n this.comparer = comparer ?? throw new ArgumentNullException(nameof(comparer));\n }\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n var expectedType = context.Options.UseRuntimeTyping ? comparands.RuntimeType : comparands.CompileTimeType;\n\n if (expectedType != typeof(T))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (comparands.Subject is null || comparands.Expectation is null)\n {\n // The later check for `comparands.Subject is T` leads to a failure even if the expectation is null.\n return EquivalencyResult.ContinueWithNext;\n }\n\n AssertionChain.GetOrCreate()\n .For(context)\n .BecauseOf(context.Reason.FormattedMessage, context.Reason.Arguments)\n .ForCondition(comparands.Subject is T)\n .FailWith(\"Expected {context:object} to be of type {0}{because}, but found {1}\", typeof(T), comparands.Subject)\n .Then\n .Given(() => comparer.Equals((T)comparands.Subject, (T)comparands.Expectation))\n .ForCondition(isEqual => isEqual)\n .FailWith(\"Expected {context:object} to be equal to {1} according to {0}{because}, but {2} was not.\",\n comparer.ToString(), comparands.Expectation, comparands.Subject);\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n public override string ToString()\n {\n return $\"Use {comparer} for objects of type {typeof(T).ToFormattedString()}\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/GenericDictionaryEquivalencyStep.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class GenericDictionaryEquivalencyStep : IEquivalencyStep\n{\n#pragma warning disable SA1110 // Allow opening parenthesis on new line to reduce line length\n private static readonly MethodInfo AssertDictionaryEquivalenceMethod =\n new Action, IDictionary>\n (AssertDictionaryEquivalence).GetMethodInfo().GetGenericMethodDefinition();\n#pragma warning restore SA1110\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expectation is null)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n Type expectationType = comparands.GetExpectedType(context.Options);\n\n if (DictionaryInterfaceInfo.FindFrom(expectationType, \"expectation\") is not { } expectedDictionary)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (IsNonGenericDictionary(comparands.Subject))\n {\n // Because we handle non-generic dictionaries later\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (IsNotNull(assertionChain, comparands.Subject)\n && EnsureSubjectIsOfTheExpectedDictionaryType(assertionChain, comparands, expectedDictionary) is { } actualDictionary)\n {\n AssertDictionaryEquivalence(comparands, assertionChain, context, valueChildNodes, actualDictionary,\n expectedDictionary);\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static bool IsNonGenericDictionary(object subject)\n {\n if (subject is not IDictionary)\n {\n return false;\n }\n\n return !subject.GetType().GetInterfaces().Any(@interface =>\n @interface.IsGenericType && @interface.GetGenericTypeDefinition() == typeof(IDictionary<,>));\n }\n\n private static bool IsNotNull(AssertionChain assertionChain, object subject)\n {\n assertionChain\n .ForCondition(subject is not null)\n .FailWith(\"Expected {context:Subject} not to be {0}{reason}.\", new object[] { null });\n\n return assertionChain.Succeeded;\n }\n\n private static DictionaryInterfaceInfo EnsureSubjectIsOfTheExpectedDictionaryType(AssertionChain assertionChain,\n Comparands comparands,\n DictionaryInterfaceInfo expectedDictionary)\n {\n var actualDictionary = DictionaryInterfaceInfo.FindFromWithKey(comparands.Subject.GetType(), \"subject\",\n expectedDictionary.Key);\n\n if (actualDictionary is null && expectedDictionary.ConvertFrom(comparands.Subject) is { } convertedSubject)\n {\n comparands.Subject = convertedSubject;\n actualDictionary = DictionaryInterfaceInfo.FindFrom(comparands.Subject.GetType(), \"subject\");\n }\n\n if (actualDictionary is null)\n {\n assertionChain.FailWith(\n \"Expected {context:subject} to be a dictionary or collection of key-value pairs that is keyed to \" +\n \"type {0}.\", expectedDictionary.Key);\n }\n\n return actualDictionary;\n }\n\n private static void FailWithLengthDifference(\n IDictionary subject,\n IDictionary expectation,\n AssertionChain assertionChain)\n\n // Type constraint of TExpectedKey is asymmetric in regards to TSubjectKey\n // but it is valid. This constraint is implicitly enforced by the dictionary interface info which is called before\n // the AssertSameLength method.\n where TExpectedKey : TSubjectKey\n {\n KeyDifference keyDifference = CalculateKeyDifference(subject, expectation);\n\n bool hasMissingKeys = keyDifference.MissingKeys.Count > 0;\n bool hasAdditionalKeys = keyDifference.AdditionalKeys.Count > 0;\n\n assertionChain\n .WithExpectation(\"Expected {context:subject} to be a dictionary with {0} item(s){reason}, \", expectation.Count,\n chain => chain\n .ForCondition(!hasMissingKeys || hasAdditionalKeys)\n .FailWith(\"but it misses key(s) {0}\", keyDifference.MissingKeys)\n .Then\n .ForCondition(hasMissingKeys || !hasAdditionalKeys)\n .FailWith(\"but has additional key(s) {0}\", keyDifference.AdditionalKeys)\n .Then\n .ForCondition(!hasMissingKeys || !hasAdditionalKeys)\n .FailWith(\"but it misses key(s) {0} and has additional key(s) {1}\", keyDifference.MissingKeys,\n keyDifference.AdditionalKeys));\n }\n\n private static KeyDifference CalculateKeyDifference(IDictionary subject,\n IDictionary expectation)\n where TExpectedKey : TSubjectKey\n {\n var missingKeys = new List();\n var presentKeys = new HashSet();\n\n foreach (TExpectedKey expectationKey in expectation.Keys)\n {\n if (subject.ContainsKey(expectationKey))\n {\n presentKeys.Add(expectationKey);\n }\n else\n {\n missingKeys.Add(expectationKey);\n }\n }\n\n var additionalKeys = new List();\n\n foreach (TSubjectKey subjectKey in subject.Keys)\n {\n if (!presentKeys.Contains(subjectKey))\n {\n additionalKeys.Add(subjectKey);\n }\n }\n\n return new KeyDifference(missingKeys, additionalKeys);\n }\n\n private static void AssertDictionaryEquivalence(Comparands comparands, AssertionChain assertionChain,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency parent, DictionaryInterfaceInfo actualDictionary,\n DictionaryInterfaceInfo expectedDictionary)\n {\n AssertDictionaryEquivalenceMethod\n .MakeGenericMethod(actualDictionary.Key, actualDictionary.Value, expectedDictionary.Key, expectedDictionary.Value)\n .Invoke(null, [assertionChain, context, parent, context.Options, comparands.Subject, comparands.Expectation]);\n }\n\n private static void AssertDictionaryEquivalence(\n AssertionChain assertionChain,\n EquivalencyValidationContext context,\n IValidateChildNodeEquivalency parent,\n IEquivalencyOptions options,\n IDictionary subject,\n IDictionary expectation)\n where TExpectedKey : TSubjectKey\n {\n if (subject.Count != expectation.Count)\n {\n FailWithLengthDifference(subject, expectation, assertionChain);\n }\n else\n {\n foreach (TExpectedKey key in expectation.Keys)\n {\n if (subject.TryGetValue(key, out TSubjectValue subjectValue))\n {\n if (options.IsRecursive)\n {\n // Run the child assertion without affecting the current context\n using (new AssertionScope())\n {\n var nestedComparands = new Comparands(subject[key], expectation[key], typeof(TExpectedValue));\n\n parent.AssertEquivalencyOf(nestedComparands, context.AsDictionaryItem(key));\n }\n }\n else\n {\n assertionChain.ReuseOnce();\n subjectValue.Should().Be(expectation[key], context.Reason.FormattedMessage, context.Reason.Arguments);\n }\n }\n else\n {\n assertionChain\n .BecauseOf(context.Reason)\n .FailWith(\"Expected {context:subject} to contain key {0}{reason}.\", key);\n }\n }\n }\n }\n\n private sealed class KeyDifference\n {\n public KeyDifference(List missingKeys, List additionalKeys)\n {\n MissingKeys = missingKeys;\n AdditionalKeys = additionalKeys;\n }\n\n public List MissingKeys { get; }\n\n public List AdditionalKeys { get; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EnumerableEquivalencyStep.cs", "using System;\nusing System.Collections;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class EnumerableEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!IsCollection(comparands.GetExpectedType(context.Options)))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (AssertSubjectIsCollection(assertionChain, comparands.Subject))\n {\n var validator = new EnumerableEquivalencyValidator(assertionChain, valueChildNodes, context)\n {\n Recursive = context.CurrentNode.IsRoot || context.Options.IsRecursive,\n OrderingRules = context.Options.OrderingRules\n };\n\n validator.Execute(ToArray(comparands.Subject), ToArray(comparands.Expectation));\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static bool AssertSubjectIsCollection(AssertionChain assertionChain, object subject)\n {\n assertionChain\n .ForCondition(subject is not null)\n .FailWith(\"Expected a collection, but {context:Subject} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(IsCollection(subject.GetType()))\n .FailWith(\"Expected a collection, but {context:Subject} is of a non-collection type.\");\n }\n\n return assertionChain.Succeeded;\n }\n\n private static bool IsCollection(Type type)\n {\n return !typeof(string).IsAssignableFrom(type) && typeof(IEnumerable).IsAssignableFrom(type);\n }\n\n internal static object[] ToArray(object value)\n {\n if (value == null)\n {\n return null;\n }\n\n try\n {\n return ((IEnumerable)value).Cast().ToArray();\n }\n catch (InvalidOperationException) when (IsIgnorableArrayLikeType(value))\n {\n // This is probably a default ImmutableArray or an empty ArraySegment.\n return [];\n }\n }\n\n private static bool IsIgnorableArrayLikeType(object value)\n {\n var type = value.GetType();\n return type.Name.Equals(\"ImmutableArray`1\", StringComparison.Ordinal) ||\n (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(ArraySegment<>));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EnumEqualityStep.cs", "#region\n\nusing System;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\n#endregion\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class EnumEqualityStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!comparands.GetExpectedType(context.Options).IsEnum)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n assertionChain\n .ForCondition(comparands.Subject?.GetType().IsEnum == true)\n .BecauseOf(context.Reason)\n .FailWith(() =>\n {\n decimal? expectationsUnderlyingValue = ExtractDecimal(comparands.Expectation);\n string expectationName = GetDisplayNameForEnumComparison(comparands.Expectation, expectationsUnderlyingValue);\n\n return new FailReason(\n $\"Expected {{context:enum}} to be equivalent to {expectationName}{{reason}}, but found {{0}}.\",\n comparands.Subject);\n });\n\n if (assertionChain.Succeeded)\n {\n switch (context.Options.EnumEquivalencyHandling)\n {\n case EnumEquivalencyHandling.ByValue:\n HandleByValue(assertionChain, comparands, context.Reason);\n break;\n\n case EnumEquivalencyHandling.ByName:\n HandleByName(assertionChain, comparands, context.Reason);\n break;\n\n default:\n throw new InvalidOperationException($\"Do not know how to handle {context.Options.EnumEquivalencyHandling}\");\n }\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static void HandleByValue(AssertionChain assertionChain, Comparands comparands, Reason reason)\n {\n decimal? subjectsUnderlyingValue = ExtractDecimal(comparands.Subject);\n decimal? expectationsUnderlyingValue = ExtractDecimal(comparands.Expectation);\n\n assertionChain\n .ForCondition(subjectsUnderlyingValue == expectationsUnderlyingValue)\n .BecauseOf(reason)\n .FailWith(() =>\n {\n string subjectsName = GetDisplayNameForEnumComparison(comparands.Subject, subjectsUnderlyingValue);\n string expectationName = GetDisplayNameForEnumComparison(comparands.Expectation, expectationsUnderlyingValue);\n\n return new FailReason(\n $\"Expected {{context:enum}} to equal {expectationName} by value{{reason}}, but found {subjectsName}.\");\n });\n }\n\n private static void HandleByName(AssertionChain assertionChain, Comparands comparands, Reason reason)\n {\n string subject = comparands.Subject.ToString();\n string expected = comparands.Expectation.ToString();\n\n assertionChain\n .ForCondition(subject == expected)\n .BecauseOf(reason)\n .FailWith(() =>\n {\n decimal? subjectsUnderlyingValue = ExtractDecimal(comparands.Subject);\n decimal? expectationsUnderlyingValue = ExtractDecimal(comparands.Expectation);\n\n string subjectsName = GetDisplayNameForEnumComparison(comparands.Subject, subjectsUnderlyingValue);\n string expectationName = GetDisplayNameForEnumComparison(comparands.Expectation, expectationsUnderlyingValue);\n\n return new FailReason(\n $\"Expected {{context:enum}} to equal {expectationName} by name{{reason}}, but found {subjectsName}.\");\n });\n }\n\n private static string GetDisplayNameForEnumComparison(object o, decimal? v)\n {\n if (o is null || v is null)\n {\n return \"\";\n }\n\n string typePart = o.GetType().Name;\n string namePart = o.ToString().Replace(\", \", \"|\", StringComparison.Ordinal);\n string valuePart = v.Value.ToString(CultureInfo.InvariantCulture);\n return $\"{typePart}.{namePart} {{{{value: {valuePart}}}}}\";\n }\n\n private static decimal? ExtractDecimal(object o)\n {\n return o is not null ? Convert.ToDecimal(o, CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/AssertionRuleEquivalencyStep.cs", "using System;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class AssertionRuleEquivalencyStep : IEquivalencyStep\n{\n private readonly Func predicate;\n private readonly string description;\n private readonly Action> assertionAction;\n private readonly AutoConversionStep converter = new();\n\n public AssertionRuleEquivalencyStep(\n Expression> predicate,\n Action> assertionAction)\n {\n this.predicate = predicate.Compile();\n this.assertionAction = assertionAction;\n description = predicate.ToString();\n }\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n bool success = false;\n\n using (var scope = new AssertionScope())\n {\n // Try without conversion\n if (AppliesTo(comparands, context.CurrentNode))\n {\n success = ExecuteAssertion(comparands, context);\n }\n\n bool converted = false;\n\n if (!success && context.Options.ConversionSelector.RequiresConversion(comparands, context.CurrentNode))\n {\n // Convert into a child context\n context = context.Clone();\n converter.Handle(comparands, context, valueChildNodes);\n converted = true;\n }\n\n if (converted && AppliesTo(comparands, context.CurrentNode))\n {\n // Try again after conversion\n success = ExecuteAssertion(comparands, context);\n if (success)\n {\n // If the assertion succeeded after conversion, discard the failures from\n // the previous attempt. If it didn't, let the scope throw with those failures.\n scope.Discard();\n }\n }\n }\n\n return success ? EquivalencyResult.EquivalencyProven : EquivalencyResult.ContinueWithNext;\n }\n\n private bool AppliesTo(Comparands comparands, INode currentNode) => predicate(new ObjectInfo(comparands, currentNode));\n\n private bool ExecuteAssertion(Comparands comparands, IEquivalencyValidationContext context)\n {\n bool subjectIsNull = comparands.Subject is null;\n bool expectationIsNull = comparands.Expectation is null;\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n assertionChain\n .ForCondition(subjectIsNull || comparands.Subject.GetType().IsSameOrInherits(typeof(TSubject)))\n .FailWith(\"Expected \" + context.CurrentNode.Subject + \" from subject to be a {0}{reason}, but found a {1}.\",\n typeof(TSubject), comparands.Subject?.GetType())\n .Then\n .ForCondition(expectationIsNull || comparands.Expectation.GetType().IsSameOrInherits(typeof(TSubject)))\n .FailWith(\n \"Expected \" + context.CurrentNode.Subject + \" from expectation to be a {0}{reason}, but found a {1}.\",\n typeof(TSubject), comparands.Expectation?.GetType());\n\n if (assertionChain.Succeeded)\n {\n if ((subjectIsNull || expectationIsNull) && !CanBeNull())\n {\n return false;\n }\n\n // Caller identitification should not get confused about invoking a Should within the assertion action\n string callerIdentifier = context.CurrentNode.Subject.ToString();\n assertionChain.OverrideCallerIdentifier(() => callerIdentifier);\n assertionChain.ReuseOnce();\n\n assertionAction(AssertionContext.CreateFrom(comparands, context));\n return true;\n }\n\n return false;\n }\n\n private static bool CanBeNull() => !typeof(T).IsValueType || Nullable.GetUnderlyingType(typeof(T)) is not null;\n\n /// \n /// Returns a string that represents the current object.\n /// \n /// \n /// A string that represents the current object.\n /// \n /// 2\n public override string ToString()\n {\n return \"Invoke Action<\" + typeof(TSubject).Name + \"> when \" + description;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyValidator.cs", "using System;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Is responsible for validating the equivalency of a subject with another object.\n/// \ninternal class EquivalencyValidator : IValidateChildNodeEquivalency\n{\n private const int MaxDepth = 10;\n\n public void AssertEquality(Comparands comparands, EquivalencyValidationContext context)\n {\n using var scope = new AssertionScope();\n\n RecursivelyAssertEquivalencyOf(comparands, context);\n\n if (context.TraceWriter is not null)\n {\n scope.AppendTracing(context.TraceWriter.ToString());\n }\n }\n\n private void RecursivelyAssertEquivalencyOf(Comparands comparands, IEquivalencyValidationContext context)\n {\n AssertEquivalencyOf(comparands, context);\n }\n\n public void AssertEquivalencyOf(Comparands comparands, IEquivalencyValidationContext context)\n {\n var assertionChain = AssertionChain.GetOrCreate()\n .For(context)\n .BecauseOf(context.Reason);\n\n if (ShouldContinueThisDeep(context.CurrentNode, context.Options, assertionChain))\n {\n if (!context.IsCyclicReference(comparands.Expectation))\n {\n TryToProveNodesAreEquivalent(comparands, context);\n }\n else if (context.Options.CyclicReferenceHandling == CyclicReferenceHandling.ThrowException)\n {\n assertionChain.FailWith(\"Expected {context:subject} to be {0}{reason}, but it contains a cyclic reference.\", comparands.Expectation);\n }\n else\n {\n AssertEquivalencyForCyclicReference(comparands, assertionChain);\n }\n }\n }\n\n private static bool ShouldContinueThisDeep(INode currentNode, IEquivalencyOptions options,\n AssertionChain assertionChain)\n {\n bool shouldRecurse = options.AllowInfiniteRecursion || currentNode.Depth <= MaxDepth;\n\n if (!shouldRecurse)\n {\n // This will throw, unless we're inside an AssertionScope\n assertionChain.FailWith($\"The maximum recursion depth of {MaxDepth} was reached. \");\n }\n\n return shouldRecurse;\n }\n\n private static void AssertEquivalencyForCyclicReference(Comparands comparands, AssertionChain assertionChain)\n {\n // We know that at this point the expectation is a non-null cyclic reference, so we don't want to continue the recursion.\n // We still want to compare the subject with the expectation though.\n\n // If they point at the same object, then equality is proven, and it doesn't matter that there's a cyclic reference.\n if (ReferenceEquals(comparands.Subject, comparands.Expectation))\n {\n return;\n }\n\n // If the expectation is non-null and the subject isn't, they would never be equivalent, regardless of how we deal with cyclic references,\n // so we can just throw an exception here.\n if (comparands.Subject is null)\n {\n assertionChain.ReuseOnce();\n comparands.Subject.Should().BeSameAs(comparands.Expectation);\n }\n\n // If they point at different objects, and the expectation is a cyclic reference, we would never be\n // able to prove that they are equal. And since we're supposed to ignore cyclic references, we can just return here.\n }\n\n private void TryToProveNodesAreEquivalent(Comparands comparands, IEquivalencyValidationContext context)\n {\n using var _ = context.Tracer.WriteBlock(node => node.Expectation.Description);\n\n foreach (IEquivalencyStep step in AssertionConfiguration.Current.Equivalency.Plan)\n {\n var result = step.Handle(comparands, context, this);\n\n if (result == EquivalencyResult.EquivalencyProven)\n {\n context.Tracer.WriteLine(GetMessage(step));\n\n static GetTraceMessage GetMessage(IEquivalencyStep step) =>\n _ => $\"Equivalency was proven by {step.GetType().Name}\";\n\n return;\n }\n }\n\n throw new NotSupportedException(\n $\"Do not know how to compare {comparands.Subject} and {comparands.Expectation}. Please report an issue through https://awesomeassertions.org.\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/GenericEnumerableEquivalencyStep.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class GenericEnumerableEquivalencyStep : IEquivalencyStep\n{\n#pragma warning disable SA1110 // Allow opening parenthesis on new line to reduce line length\n private static readonly MethodInfo HandleMethod = new Action>\n (HandleImpl).GetMethodInfo().GetGenericMethodDefinition();\n#pragma warning restore SA1110\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n Type expectedType = comparands.GetExpectedType(context.Options);\n\n if (comparands.Expectation is null || !IsGenericCollection(expectedType))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n Type[] interfaceTypes = GetIEnumerableInterfaces(expectedType);\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n assertionChain\n .ForCondition(interfaceTypes.Length == 1)\n .FailWith(() => new FailReason(\"{context:Expectation} implements {0}, so cannot determine which one \" +\n \"to use for asserting the equivalency of the collection. \",\n interfaceTypes.Select(type => \"IEnumerable<\" + type.GetGenericArguments().Single() + \">\")));\n\n if (AssertSubjectIsCollection(assertionChain, comparands.Subject))\n {\n var validator = new EnumerableEquivalencyValidator(assertionChain, valueChildNodes, context)\n {\n Recursive = context.CurrentNode.IsRoot || context.Options.IsRecursive,\n OrderingRules = context.Options.OrderingRules\n };\n\n Type typeOfEnumeration = GetTypeOfEnumeration(expectedType);\n\n var subjectAsArray = EnumerableEquivalencyStep.ToArray(comparands.Subject);\n\n try\n {\n HandleMethod.MakeGenericMethod(typeOfEnumeration)\n .Invoke(null, [validator, subjectAsArray, comparands.Expectation]);\n }\n catch (TargetInvocationException e)\n {\n e.Unwrap().Throw();\n }\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static void HandleImpl(EnumerableEquivalencyValidator validator, object[] subject, IEnumerable expectation) =>\n validator.Execute(subject, ToArray(expectation));\n\n private static bool AssertSubjectIsCollection(AssertionChain assertionChain, object subject)\n {\n assertionChain\n .ForCondition(subject is not null)\n .FailWith(\"Expected {context:subject} not to be {0}.\", new object[] { null });\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(IsCollection(subject.GetType()))\n .FailWith(\"Expected {context:subject} to be a collection, but it was a {0}\", subject.GetType());\n }\n\n return assertionChain.Succeeded;\n }\n\n private static bool IsCollection(Type type)\n {\n return !typeof(string).IsAssignableFrom(type) && typeof(IEnumerable).IsAssignableFrom(type);\n }\n\n private static bool IsGenericCollection(Type type)\n {\n Type[] enumerableInterfaces = GetIEnumerableInterfaces(type);\n\n return !typeof(string).IsAssignableFrom(type) && enumerableInterfaces.Length > 0;\n }\n\n private static Type[] GetIEnumerableInterfaces(Type type)\n {\n // Avoid expensive calculation when the type in question can't possibly implement IEnumerable<>.\n if (Type.GetTypeCode(type) != TypeCode.Object)\n {\n return [];\n }\n\n Type soughtType = typeof(IEnumerable<>);\n\n return type.GetClosedGenericInterfaces(soughtType);\n }\n\n private static Type GetTypeOfEnumeration(Type enumerableType)\n {\n Type interfaceType = GetIEnumerableInterfaces(enumerableType).Single();\n\n return interfaceType.GetGenericArguments().Single();\n }\n\n private static T[] ToArray(IEnumerable value)\n {\n try\n {\n return value?.ToArray();\n }\n catch (InvalidOperationException) when (value.GetType().Name.Equals(\"ImmutableArray`1\", StringComparison.Ordinal))\n {\n // This is probably a default ImmutableArray\n return [];\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/DictionaryEquivalencyStep.cs", "using System.Collections;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class DictionaryEquivalencyStep : EquivalencyStep\n{\n [SuppressMessage(\"ReSharper\", \"PossibleNullReferenceException\")]\n protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subject = comparands.Subject as IDictionary;\n var expectation = comparands.Expectation as IDictionary;\n\n var assertionChain = AssertionChain.GetOrCreate().For(context);\n\n if (PreconditionsAreMet(expectation, subject, assertionChain) && expectation is not null)\n {\n foreach (object key in expectation.Keys)\n {\n if (context.Options.IsRecursive)\n {\n context.Tracer.WriteLine(member =>\n Invariant($\"Recursing into dictionary item {key} at {member.Expectation}\"));\n\n nestedValidator.AssertEquivalencyOf(new Comparands(subject[key], expectation[key], typeof(object)), context.AsDictionaryItem(key));\n }\n else\n {\n context.Tracer.WriteLine(member =>\n Invariant(\n $\"Comparing dictionary item {key} at {member.Expectation} between subject and expectation\"));\n\n assertionChain.WithCallerPostfix($\"[{key.ToFormattedString()}]\").ReuseOnce();\n subject[key].Should().Be(expectation[key], context.Reason.FormattedMessage, context.Reason.Arguments);\n }\n }\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static bool PreconditionsAreMet(IDictionary expectation, IDictionary subject, AssertionChain assertionChain)\n {\n return AssertIsDictionary(subject, assertionChain)\n && AssertEitherIsNotNull(expectation, subject, assertionChain)\n && AssertSameLength(expectation, subject, assertionChain);\n }\n\n private static bool AssertEitherIsNotNull(IDictionary expectation, IDictionary subject, AssertionChain assertionChain)\n {\n assertionChain\n .ForCondition((expectation is null && subject is null) || expectation is not null)\n .FailWith(\"Expected {context:subject} to be {0}{reason}, but found {1}.\", null, subject);\n\n return assertionChain.Succeeded;\n }\n\n private static bool AssertIsDictionary(IDictionary subject, AssertionChain assertionChain)\n {\n assertionChain\n .ForCondition(subject is not null)\n .FailWith(\"Expected {context:subject} to be a dictionary, but it is not.\");\n\n return assertionChain.Succeeded;\n }\n\n private static bool AssertSameLength(IDictionary expectation, IDictionary subject, AssertionChain assertionChain)\n {\n assertionChain\n .ForCondition(expectation is null || subject.Keys.Count == expectation.Keys.Count)\n .FailWith(\"Expected {context:subject} to be a dictionary with {0} item(s), but it only contains {1} item(s).\",\n expectation?.Keys.Count, subject?.Keys.Count);\n\n return assertionChain.Succeeded;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/XAttributeEquivalencyStep.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class XAttributeEquivalencyStep : EquivalencyStep\n{\n protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subject = (XAttribute)comparands.Subject;\n var expectation = (XAttribute)comparands.Expectation;\n\n AssertionChain.GetOrCreate().For(context).ReuseOnce();\n\n subject.Should().Be(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n\n return EquivalencyResult.EquivalencyProven;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/XElementEquivalencyStep.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class XElementEquivalencyStep : EquivalencyStep\n{\n protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subject = (XElement)comparands.Subject;\n var expectation = (XElement)comparands.Expectation;\n\n AssertionChain.GetOrCreate().For(context).ReuseOnce();\n\n subject.Should().BeEquivalentTo(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n\n return EquivalencyResult.EquivalencyProven;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/XDocumentEquivalencyStep.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\npublic class XDocumentEquivalencyStep : EquivalencyStep\n{\n protected override EquivalencyResult OnHandle(Comparands comparands,\n IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator)\n {\n var subject = (XDocument)comparands.Subject;\n var expectation = (XDocument)comparands.Expectation;\n\n AssertionChain.GetOrCreate().For(context).ReuseOnce();\n\n subject.Should().BeEquivalentTo(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n\n return EquivalencyResult.EquivalencyProven;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/AutoConversionStep.cs", "using System;\nusing System.Globalization;\nusing AwesomeAssertions.Common;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Attempts to convert the subject's property value to the expected type.\n/// \n/// \n/// Whether or not the conversion is attempted depends on the .\n/// \npublic class AutoConversionStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!context.Options.ConversionSelector.RequiresConversion(comparands, context.CurrentNode))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (comparands.Expectation is null || comparands.Subject is null)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n Type subjectType = comparands.Subject.GetType();\n Type expectationType = comparands.Expectation.GetType();\n\n if (subjectType.IsSameOrInherits(expectationType))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (TryChangeType(comparands.Subject, expectationType, out object convertedSubject))\n {\n context.Tracer.WriteLine(member =>\n Invariant($\"Converted subject {comparands.Subject} at {member.Subject} to {expectationType}\"));\n\n comparands.Subject = convertedSubject;\n }\n else\n {\n context.Tracer.WriteLine(member =>\n Invariant($\"Subject {comparands.Subject} at {member.Subject} could not be converted to {expectationType}\"));\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n\n private static bool TryChangeType(object subject, Type expectationType, out object conversionResult)\n {\n conversionResult = null;\n\n try\n {\n if (expectationType.IsEnum)\n {\n if (subject is sbyte or byte or short or ushort or int or uint or long or ulong)\n {\n conversionResult = Enum.ToObject(expectationType, subject);\n return Enum.IsDefined(expectationType, conversionResult);\n }\n\n return false;\n }\n\n conversionResult = Convert.ChangeType(subject, expectationType, CultureInfo.InvariantCulture);\n return true;\n }\n catch (FormatException)\n {\n }\n catch (InvalidCastException)\n {\n }\n\n return false;\n }\n\n public override string ToString()\n {\n return string.Empty;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MultiDimensionalArrayEquivalencyStep.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Supports recursively comparing two multi-dimensional arrays for equivalency using strict order for the array items\n/// themselves.\n/// \ninternal class MultiDimensionalArrayEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expectation is not Array expectationAsArray || expectationAsArray.Rank == 1)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (AreComparable(comparands, expectationAsArray, AssertionChain.GetOrCreate().For(context)))\n {\n if (expectationAsArray.Length == 0)\n {\n return EquivalencyResult.EquivalencyProven;\n }\n\n Digit digit = BuildDigitsRepresentingAllIndices(expectationAsArray);\n\n do\n {\n int[] indices = digit.GetIndices();\n object subject = ((Array)comparands.Subject).GetValue(indices);\n string listOfIndices = string.Join(\",\", indices);\n object expectation = expectationAsArray.GetValue(indices);\n\n IEquivalencyValidationContext itemContext = context.AsCollectionItem(listOfIndices);\n\n valueChildNodes.AssertEquivalencyOf(new Comparands(subject, expectation, typeof(object)),\n itemContext);\n }\n while (digit.Increment());\n }\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n private static Digit BuildDigitsRepresentingAllIndices(Array subjectAsArray)\n {\n return Enumerable\n .Range(0, subjectAsArray.Rank)\n .Reverse()\n .Aggregate((Digit)null, (next, rank) => new Digit(subjectAsArray.GetLength(rank), next));\n }\n\n private static bool AreComparable(Comparands comparands, Array expectationAsArray, AssertionChain assertionChain)\n {\n return\n IsArray(comparands.Subject, assertionChain) &&\n HaveSameRank(comparands.Subject, expectationAsArray, assertionChain) &&\n HaveSameDimensions(comparands.Subject, expectationAsArray, assertionChain);\n }\n\n private static bool IsArray(object type, AssertionChain assertionChain)\n {\n assertionChain\n .ForCondition(type is not null)\n .FailWith(\"Cannot compare a multi-dimensional array to .\")\n .Then\n .ForCondition(type is Array)\n .FailWith(\"Cannot compare a multi-dimensional array to something else.\");\n\n return assertionChain.Succeeded;\n }\n\n private static bool HaveSameDimensions(object subject, Array expectation, AssertionChain assertionChain)\n {\n bool sameDimensions = true;\n\n for (int dimension = 0; dimension < expectation.Rank; dimension++)\n {\n int actualLength = ((Array)subject).GetLength(dimension);\n int expectedLength = expectation.GetLength(dimension);\n\n assertionChain\n .ForCondition(expectedLength == actualLength)\n .FailWith(\"Expected dimension {0} to contain {1} item(s), but found {2}.\", dimension, expectedLength,\n actualLength);\n\n sameDimensions &= assertionChain.Succeeded;\n }\n\n return sameDimensions;\n }\n\n private static bool HaveSameRank(object subject, Array expectation, AssertionChain assertionChain)\n {\n var subjectAsArray = (Array)subject;\n\n assertionChain\n .ForCondition(subjectAsArray.Rank == expectation.Rank)\n .FailWith(\"Expected {context:array} to have {0} dimension(s), but it has {1}.\", expectation.Rank,\n subjectAsArray.Rank);\n\n return assertionChain.Succeeded;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/ReferenceEqualityEquivalencyStep.cs", "namespace AwesomeAssertions.Equivalency.Steps;\n\npublic class ReferenceEqualityEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n return ReferenceEquals(comparands.Subject, comparands.Expectation)\n ? EquivalencyResult.EquivalencyProven\n : EquivalencyResult.ContinueWithNext;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/RunAllUserStepsEquivalencyStep.cs", "namespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Represents a composite equivalency step that passes the execution to all user-supplied steps that can handle the\n/// current context.\n/// \npublic class RunAllUserStepsEquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n foreach (IEquivalencyStep step in context.Options.UserEquivalencySteps)\n {\n if (step.Handle(comparands, context, valueChildNodes) == EquivalencyResult.EquivalencyProven)\n {\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyStep.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Convenient implementation of that will only invoke\n/// \npublic abstract class EquivalencyStep : IEquivalencyStep\n{\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!typeof(T).IsAssignableFrom(comparands.GetExpectedType(context.Options)))\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n return OnHandle(comparands, context, valueChildNodes);\n }\n\n /// \n /// Implements , but only gets called when the expected type matches .\n /// \n protected abstract EquivalencyResult OnHandle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency nestedValidator);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/ExtensibilitySpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\n/// \n/// Test Class containing specs over the extensibility points of Should().BeEquivalentTo\n/// \npublic class ExtensibilitySpecs\n{\n #region Selection Rules\n\n [Fact]\n public void When_a_selection_rule_is_added_it_should_be_evaluated_after_all_existing_rules()\n {\n // Arrange\n var subject = new\n {\n NameId = \"123\",\n SomeValue = \"hello\"\n };\n\n var expected = new\n {\n SomeValue = \"hello\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new ExcludeForeignKeysSelectionRule()));\n }\n\n [Fact]\n public void When_a_selection_rule_is_added_it_should_appear_in_the_exception_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"123\",\n };\n\n var expected = new\n {\n SomeValue = \"hello\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new ExcludeForeignKeysSelectionRule()));\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*{nameof(ExcludeForeignKeysSelectionRule)}*\");\n }\n\n internal class ExcludeForeignKeysSelectionRule : IMemberSelectionRule\n {\n public bool OverridesStandardIncludeRules\n {\n get { return false; }\n }\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return selectedMembers.Where(pi => !pi.Subject.Name.EndsWith(\"Id\", StringComparison.Ordinal)).ToArray();\n }\n\n bool IMemberSelectionRule.IncludesMembers\n {\n get { return OverridesStandardIncludeRules; }\n }\n }\n\n #endregion\n\n #region Matching Rules\n\n [Fact]\n public void When_a_matching_rule_is_added_it_should_precede_all_existing_rules()\n {\n // Arrange\n var subject = new\n {\n Name = \"123\",\n SomeValue = \"hello\"\n };\n\n var expected = new\n {\n NameId = \"123\",\n SomeValue = \"hello\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new ForeignKeyMatchingRule()));\n }\n\n [Fact]\n public void When_a_matching_rule_is_added_it_should_appear_in_the_exception_message()\n {\n // Arrange\n var subject = new\n {\n NameId = \"123\",\n SomeValue = \"hello\"\n };\n\n var expected = new\n {\n Name = \"1234\",\n SomeValue = \"hello\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new ForeignKeyMatchingRule()));\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*{nameof(ForeignKeyMatchingRule)}*\");\n }\n\n internal class ForeignKeyMatchingRule : IMemberMatchingRule\n {\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options,\n AssertionChain assertionChain)\n {\n string name = expectedMember.Subject.Name;\n\n if (name.EndsWith(\"Id\", StringComparison.Ordinal))\n {\n name = name.Replace(\"Id\", \"\");\n }\n\n PropertyInfo runtimeProperty = subject.GetType().GetRuntimeProperty(name);\n return runtimeProperty is not null ? new Property(runtimeProperty, parent) : null;\n }\n }\n\n #endregion\n\n #region Ordering Rules\n\n [Fact]\n public void When_an_ordering_rule_is_added_it_should_be_evaluated_after_all_existing_rules()\n {\n // Arrange\n string[] subject = [\"First\", \"Second\"];\n string[] expected = [\"First\", \"Second\"];\n\n // Act / Assert\n subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new StrictOrderingRule()));\n }\n\n [Fact]\n public void When_an_ordering_rule_is_added_it_should_appear_in_the_exception_message()\n {\n // Arrange\n string[] subject = [\"First\", \"Second\"];\n string[] expected = [\"Second\", \"First\"];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new StrictOrderingRule()));\n\n act.Should().Throw()\n .WithMessage($\"*{nameof(StrictOrderingRule)}*\");\n }\n\n internal class StrictOrderingRule : IOrderingRule\n {\n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n return OrderStrictness.Strict;\n }\n }\n\n #endregion\n\n #region Assertion Rules\n\n [Fact]\n public void When_property_of_other_is_incompatible_with_generic_type_the_message_should_include_generic_type()\n {\n // Arrange\n var subject = new\n {\n Id = \"foo\",\n };\n\n var other = new\n {\n Id = 0.5d,\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Id*from expectation*string*double*\");\n }\n\n [Fact]\n public void Can_exclude_all_properties_of_the_parent_type()\n {\n // Arrange\n var subject = new\n {\n Id = \"foo\",\n };\n\n var expectation = new\n {\n Id = \"bar\",\n };\n\n // Act\n subject.Should().BeEquivalentTo(expectation,\n o => o\n .Using(c => c.Subject.Should().HaveLength(c.Expectation.Length))\n .When(si => si.ParentType == expectation.GetType() && si.Path.EndsWith(\"Id\", StringComparison.Ordinal)));\n }\n\n [Fact]\n public void When_property_of_subject_is_incompatible_with_generic_type_the_message_should_include_generic_type()\n {\n // Arrange\n var subject = new\n {\n Id = 0.5d,\n };\n\n var other = new\n {\n Id = \"foo\",\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Id*from subject*string*double*\");\n }\n\n [Fact]\n public void When_equally_named_properties_are_both_incompatible_with_generic_type_the_message_should_include_generic_type()\n {\n // Arrange\n var subject = new\n {\n Id = 0.5d,\n };\n\n var other = new\n {\n Id = 0.5d,\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Id*from subject*string*double*\");\n }\n\n [Fact]\n public void When_property_of_other_is_null_the_failure_message_should_not_complain_about_its_type()\n {\n // Arrange\n var subject = new\n {\n Id = \"foo\",\n };\n\n var other = new\n {\n Id = null as double?,\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should()\n .Contain(\"Expected property subject.Id to be , but found \\\"foo\\\"\")\n .And.NotContain(\"from expectation\");\n }\n\n [Fact]\n public void When_property_of_subject_is_null_the_failure_message_should_not_complain_about_its_type()\n {\n // Arrange\n var subject = new\n {\n Id = null as double?,\n };\n\n var expectation = new\n {\n Id = \"bar\",\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should()\n .Contain(\"Expected property subject.Id to be \\\"bar\\\", but found \")\n .And.NotContain(\"from subject\");\n }\n\n [Fact]\n public void When_equally_named_properties_are_both_null_it_should_succeed()\n {\n // Arrange\n var subject = new\n {\n Id = null as double?,\n };\n\n var other = new\n {\n Id = null as string,\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => c.Subject.Should().Be(c.Expectation))\n .When(si => si.Path == \"Id\"));\n }\n\n [Fact]\n public void When_equally_named_properties_are_type_incompatible_and_assertion_rule_exists_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Type = typeof(string),\n };\n\n var other = new\n {\n Type = typeof(string).AssemblyQualifiedName,\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other,\n o => o\n .Using(c => ((Type)c.Subject).AssemblyQualifiedName.Should().Be((string)c.Expectation))\n .When(si => si.Path == \"Type\"));\n }\n\n [Fact]\n public void When_an_assertion_is_overridden_for_a_predicate_it_should_use_the_provided_action()\n {\n // Arrange\n var subject = new\n {\n Date = 14.July(2012).At(12, 59, 59)\n };\n\n var expectation = new\n {\n Date = 14.July(2012).At(13, 0)\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .Using(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, 1.Seconds()))\n .When(info => info.Path.EndsWith(\"Date\", StringComparison.Ordinal)));\n }\n\n [Fact]\n public void When_an_assertion_is_overridden_for_all_types_it_should_use_the_provided_action_for_all_properties()\n {\n // Arrange\n var subject = new\n {\n Date = 21.July(2012).At(11, 8, 59),\n Nested = new\n {\n NestedDate = 14.July(2012).At(12, 59, 59)\n }\n };\n\n var expectation = new\n {\n Date = 21.July(2012).At(11, 9),\n Nested = new\n {\n NestedDate = 14.July(2012).At(13, 0)\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options =>\n options\n .Using(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, 1.Seconds()))\n .WhenTypeIs());\n }\n\n [InlineData(null, 0)]\n [InlineData(0, null)]\n [Theory]\n public void When_subject_or_expectation_is_null_it_should_not_match_a_non_nullable_type(int? subjectValue, int? expectedValue)\n {\n // Arrange\n var actual = new { Value = subjectValue };\n var expected = new { Value = expectedValue };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().NotBe(c.Expectation))\n .WhenTypeIs());\n\n // Assert\n act.Should().Throw();\n }\n\n [InlineData(null, 0)]\n [InlineData(0, null)]\n [Theory]\n public void When_subject_or_expectation_is_null_it_should_match_a_nullable_type(int? subjectValue, int? expectedValue)\n {\n // Arrange\n var actual = new { Value = subjectValue };\n var expected = new { Value = expectedValue };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().NotBe(c.Expectation))\n .WhenTypeIs());\n }\n\n [InlineData(null, null)]\n [InlineData(0, 0)]\n [Theory]\n public void When_types_are_nullable_it_should_match_a_nullable_type(int? subjectValue, int? expectedValue)\n {\n // Arrange\n var actual = new { Value = subjectValue };\n var expected = new { Value = expectedValue };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().NotBe(c.Expectation))\n .WhenTypeIs());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_overriding_with_custom_assertion_it_should_be_chainable()\n {\n // Arrange\n var actual = new { Nullable = (int?)1, NonNullable = 2 };\n var expected = new { Nullable = (int?)3, NonNullable = 3 };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().BeCloseTo(c.Expectation, 1))\n .WhenTypeIs()\n .Using(c => c.Subject.Should().NotBe(c.Expectation))\n .WhenTypeIs());\n }\n\n [Fact]\n public void When_a_nullable_property_is_overridden_with_a_custom_assertion_it_should_use_it()\n {\n // Arrange\n var actual = new SimpleWithNullable\n {\n NullableIntegerProperty = 1,\n StringProperty = \"I haz a string!\"\n };\n\n var expected = new SimpleWithNullable\n {\n StringProperty = \"I haz a string!\"\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, opt => opt\n .Using(c => c.Subject.Should().BeInRange(0, 10))\n .WhenTypeIs());\n }\n\n internal class SimpleWithNullable\n {\n public long? NullableIntegerProperty { get; set; }\n\n public string StringProperty { get; set; }\n }\n\n [Fact]\n public void When_an_assertion_rule_is_added_it_should_precede_all_existing_rules()\n {\n // Arrange\n var subject = new\n {\n Created = 8.July(2012).At(22, 9)\n };\n\n var expected = new\n {\n Created = 8.July(2012).At(22, 10)\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new RelaxingDateTimeEquivalencyStep()));\n }\n\n [Fact]\n public void When_an_assertion_rule_is_added_it_appear_in_the_exception_message()\n {\n // Arrange\n var subject = new\n {\n Property = 8.July(2012).At(22, 9)\n };\n\n var expected = new\n {\n Property = 8.July(2012).At(22, 11)\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(\n expected,\n options => options.Using(new RelaxingDateTimeEquivalencyStep()));\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*{nameof(RelaxingDateTimeEquivalencyStep)}*\");\n }\n\n [Fact]\n public void When_multiple_steps_are_added_they_should_be_evaluated_first_to_last()\n {\n // Arrange\n var subject = new\n {\n Created = 8.July(2012).At(22, 9)\n };\n\n var expected = new\n {\n Created = 8.July(2012).At(22, 10)\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opts => opts\n .Using(new RelaxingDateTimeEquivalencyStep())\n .Using(new AlwaysFailOnDateTimesEquivalencyStep()));\n\n // Assert\n act.Should().NotThrow(\n \"a different assertion rule should handle the comparison before the exception throwing assertion rule is hit\");\n }\n\n private class AlwaysFailOnDateTimesEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expectation is DateTime)\n {\n throw new Exception(\"Failed\");\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n }\n\n private class RelaxingDateTimeEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expectation is DateTime time)\n {\n ((DateTime)comparands.Subject).Should().BeCloseTo(time, 1.Minutes());\n\n return EquivalencyResult.EquivalencyProven;\n }\n\n return EquivalencyResult.ContinueWithNext;\n }\n }\n\n [Fact]\n public void When_multiple_assertion_rules_are_added_with_the_fluent_api_they_should_be_executed_from_right_to_left()\n {\n // Arrange\n var subject = new ClassWithOnlyAProperty();\n var expected = new ClassWithOnlyAProperty();\n\n // Act\n Action act =\n () =>\n subject.Should().BeEquivalentTo(expected,\n opts =>\n opts.Using(_ => throw new Exception())\n .When(_ => true)\n .Using(_ => { })\n .When(_ => true));\n\n // Assert\n act.Should().NotThrow(\n \"a different assertion rule should handle the comparison before the exception throwing assertion rule is hit\");\n }\n\n [Fact]\n public void When_using_a_nested_equivalency_api_in_a_custom_assertion_rule_it_should_honor_the_rule()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties\n {\n Property1 = \"value1\",\n Property2 = \"value2\"\n };\n\n var expectation = new ClassWithSomeFieldsAndProperties\n {\n Property1 = \"value1\",\n Property2 = \"value3\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .Using(ctx =>\n ctx.Subject.Should().BeEquivalentTo(ctx.Expectation, nestedOptions => nestedOptions.Excluding(x => x.Property2)))\n .WhenTypeIs());\n }\n\n [Fact]\n public void When_a_predicate_matches_after_auto_conversion_it_should_execute_the_assertion()\n {\n // Arrange\n var expectation = new\n {\n ThisIsMyDateTime = DateTime.Now\n };\n\n var actual = new\n {\n ThisIsMyDateTime = expectation.ThisIsMyDateTime.ToString(CultureInfo.InvariantCulture)\n };\n\n // Assert\n actual.Should().BeEquivalentTo(expectation,\n options => options\n .WithAutoConversion()\n .Using(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, 1.Seconds()))\n .WhenTypeIs());\n }\n\n #endregion\n\n #region Equivalency Steps\n\n [Fact]\n public void When_an_equivalency_step_handles_the_comparison_later_equivalency_steps_should_not_be_ran()\n {\n // Arrange\n var subject = new ClassWithOnlyAProperty();\n var expected = new ClassWithOnlyAProperty();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n opts =>\n opts.Using(new AlwaysHandleEquivalencyStep())\n .Using(new ThrowExceptionEquivalencyStep()));\n }\n\n [Fact]\n public void When_a_user_equivalency_step_is_registered_it_should_run_before_the_built_in_steps()\n {\n // Arrange\n var actual = new\n {\n Property = 123\n };\n\n var expected = new\n {\n Property = \"123\"\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options\n .Using(new EqualityEquivalencyStep()));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*123*123*\");\n }\n\n [Fact]\n public void When_an_equivalency_does_not_handle_the_comparison_later_equivalency_steps_should_still_be_ran()\n {\n // Arrange\n var subject = new ClassWithOnlyAProperty();\n var expected = new ClassWithOnlyAProperty();\n\n // Act\n Action act =\n () =>\n subject.Should().BeEquivalentTo(expected,\n opts =>\n opts.Using(new NeverHandleEquivalencyStep())\n .Using(new ThrowExceptionEquivalencyStep()));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_multiple_equivalency_steps_are_added_they_should_be_executed_in_registration_order()\n {\n // Arrange\n var subject = new ClassWithOnlyAProperty();\n var expected = new ClassWithOnlyAProperty();\n\n // Act\n Action act =\n () =>\n subject.Should().BeEquivalentTo(expected,\n opts =>\n opts.Using(new ThrowExceptionEquivalencyStep())\n .Using(new ThrowExceptionEquivalencyStep()));\n\n // Assert\n act.Should().Throw();\n }\n\n private class ThrowExceptionEquivalencyStep : IEquivalencyStep\n where TException : Exception, new()\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n throw new TException();\n }\n }\n\n private class AlwaysHandleEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n private class NeverHandleEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n }\n\n private class EqualityEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n internal class DoEquivalencyStep : IEquivalencyStep\n {\n private readonly Action doAction;\n\n public DoEquivalencyStep(Action doAction)\n {\n this.doAction = doAction;\n }\n\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n doAction();\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n [Fact]\n public void Can_compare_null_against_null_with_custom_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(new ClassWithNullableStructProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_null_against_not_null_with_custom_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty();\n var unexpected = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(unexpected, o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_null_with_custom_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new ClassWithNullableStructProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_not_null_with_custom_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n var expected = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_null_against_null_with_custom_nullable_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(new ClassWithNullableStructProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_null_against_not_null_with_custom_nullable_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty();\n var unexpected = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(unexpected, o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_null_with_custom_nullable_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new ClassWithNullableStructProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_not_null_with_custom_nullable_comparer_for_nullable_property()\n {\n // Arrange\n var subject = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n var expected = new ClassWithNullableStructProperty\n {\n Value = new StructWithProperties\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, o => o\n .Using()\n );\n }\n\n private class ClassWithNullableStructProperty\n {\n [UsedImplicitly]\n public StructWithProperties? Value { get; set; }\n }\n\n private struct StructWithProperties\n {\n // ReSharper disable once UnusedAutoPropertyAccessor.Local\n public int Value { get; set; }\n }\n\n private class StructWithPropertiesComparer : IEqualityComparer, IEqualityComparer\n {\n public bool Equals(StructWithProperties x, StructWithProperties y) => Equals(x.Value, y.Value);\n\n public int GetHashCode(StructWithProperties obj) => obj.Value;\n\n public bool Equals(StructWithProperties? x, StructWithProperties? y) => Equals(x?.Value, y?.Value);\n\n public int GetHashCode(StructWithProperties? obj) => obj?.Value ?? 0;\n }\n\n [Fact]\n public void Can_compare_null_against_null_with_custom_comparer_for_property()\n {\n // Arrange\n var subject = new ClassWithClassProperty();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(new ClassWithClassProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_null_against_not_null_with_custom_comparer_for_property()\n {\n // Arrange\n var subject = new ClassWithClassProperty();\n var unexpected = new ClassWithClassProperty\n {\n Value = new ClassProperty\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(unexpected, o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_null_with_custom_comparer_for_property()\n {\n // Arrange\n var subject = new ClassWithClassProperty\n {\n Value = new ClassProperty\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new ClassWithClassProperty(), o => o\n .Using()\n );\n }\n\n [Fact]\n public void Can_compare_not_null_against_not_null_with_custom_comparer_for_property()\n {\n // Arrange\n var subject = new ClassWithClassProperty\n {\n Value = new ClassProperty\n {\n Value = 42\n },\n };\n var expected = new ClassWithClassProperty\n {\n Value = new ClassProperty\n {\n Value = 42\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, o => o\n .Using()\n );\n }\n\n private class ClassWithClassProperty\n {\n // ReSharper disable once UnusedAutoPropertyAccessor.Local\n public ClassProperty Value { get; set; }\n }\n\n public class ClassProperty\n {\n public int Value { get; set; }\n }\n\n private class ClassPropertyComparer : IEqualityComparer\n {\n public bool Equals(ClassProperty x, ClassProperty y) => Equals(x?.Value, y?.Value);\n\n public int GetHashCode(ClassProperty obj) => obj.Value;\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IEquivalencyStep.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Defines a step in the process of comparing two object graphs for structural equivalency.\n/// \npublic interface IEquivalencyStep\n{\n /// \n /// Executes an operation such as an equivalency assertion on the provided .\n /// \n /// \n /// Should return if the subject matches the expectation or if no additional assertions\n /// have to be executed. Should return otherwise.\n /// \n /// \n /// May throw when preconditions are not met or if it detects mismatching data.\n /// \n EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/EquivalencyOptionsSpecs.cs", "using System;\nusing System.Collections;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Equivalency.Steps;\nusing AwesomeAssertions.Execution;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\npublic class EquivalencyOptionsSpecs\n{\n [Fact]\n public void When_injecting_a_null_configurer_it_should_throw()\n {\n // Arrange / Act\n var action = () => AssertionConfiguration.Current.Equivalency.Modify(configureOptions: null);\n\n // Assert\n action.Should().ThrowExactly()\n .WithParameterName(\"configureOptions\");\n }\n\n [Fact]\n public void When_concurrently_getting_equality_strategy_it_should_not_throw()\n {\n // Arrange / Act\n var action = () =>\n {\n#pragma warning disable CA1859 // https://github.com/dotnet/roslyn-analyzers/issues/6704\n IEquivalencyOptions equivalencyOptions = new EquivalencyOptions();\n#pragma warning restore CA1859\n\n return () => Parallel.For(0, 10_000, new ParallelOptions { MaxDegreeOfParallelism = 8 },\n _ => equivalencyOptions.GetEqualityStrategy(typeof(IEnumerable))\n );\n };\n\n // Assert\n action.Should().NotThrow();\n }\n\n [Collection(\"ConfigurationSpecs\")]\n public sealed class Given_temporary_global_assertion_options : IDisposable\n {\n [Fact]\n public void When_modifying_global_reference_type_settings_a_previous_assertion_should_not_have_any_effect_it_should_try_to_compare_the_classes_by_member_semantics_and_thus_throw()\n {\n // Arrange\n // Trigger a first equivalency check using the default global settings\n new MyValueType { Value = 1 }.Should().BeEquivalentTo(new MyValueType { Value = 2 });\n\n AssertionConfiguration.Current.Equivalency.Modify(o => o.ComparingByMembers());\n\n // Act\n Action act = () => new MyValueType { Value = 1 }.Should().BeEquivalentTo(new MyValueType { Value = 2 });\n\n // Assert\n act.Should().Throw();\n }\n\n internal class MyValueType\n {\n [UsedImplicitly]\n public int Value { get; set; }\n\n public override bool Equals(object obj) => true;\n\n public override int GetHashCode() => 0;\n }\n\n [Fact]\n public void When_modifying_global_value_type_settings_a_previous_assertion_should_not_have_any_effect_it_should_try_to_compare_the_classes_by_value_semantics_and_thus_throw()\n {\n // Arrange\n // Trigger a first equivalency check using the default global settings\n new MyClass { Value = 1 }.Should().BeEquivalentTo(new MyClass { Value = 1 });\n\n AssertionConfiguration.Current.Equivalency.Modify(o => o.ComparingByValue());\n\n // Act\n Action act = () => new MyClass() { Value = 1 }.Should().BeEquivalentTo(new MyClass { Value = 1 });\n\n // Assert\n act.Should().Throw();\n }\n\n internal class MyClass\n {\n [UsedImplicitly]\n public int Value { get; set; }\n }\n\n [Fact]\n public void When_modifying_record_settings_globally_it_should_use_the_global_settings_for_comparing_records()\n {\n // Arrange\n AssertionConfiguration.Current.Equivalency.Modify(o => o.ComparingByValue(typeof(Position)));\n\n // Act / Assert\n new Position(123).Should().BeEquivalentTo(new Position(123));\n }\n\n private record Position\n {\n [UsedImplicitly]\n private readonly int value;\n\n public Position(int value)\n {\n this.value = value;\n }\n }\n\n [Fact]\n public void When_assertion_doubles_should_always_allow_small_deviations_then_it_should_ignore_small_differences_without_the_need_of_local_options()\n {\n // Arrange\n AssertionConfiguration.Current.Equivalency.Modify(options => options\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.01))\n .WhenTypeIs());\n\n var actual = new\n {\n Value = 1D / 3D\n };\n\n var expected = new\n {\n Value = 0.33D\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_local_similar_options_are_used_then_they_should_override_the_global_options()\n {\n // Arrange\n AssertionConfiguration.Current.Equivalency.Modify(options => options\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.01))\n .WhenTypeIs());\n\n var actual = new\n {\n Value = 1D / 3D\n };\n\n var expected = new\n {\n Value = 0.33D\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options\n .Using(ctx => ctx.Subject.Should().Be(ctx.Expectation))\n .WhenTypeIs());\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*\");\n }\n\n [Fact]\n public void When_local_similar_options_are_used_then_they_should_not_affect_any_other_assertions()\n {\n // Arrange\n AssertionConfiguration.Current.Equivalency.Modify(options => options\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.01))\n .WhenTypeIs());\n\n var actual = new\n {\n Value = 1D / 3D\n };\n\n var expected = new\n {\n Value = 0.33D\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n public void Dispose() =>\n AssertionConfiguration.Current.Equivalency.Modify(_ => new EquivalencyOptions());\n }\n\n [Collection(\"ConfigurationSpecs\")]\n public sealed class Given_self_resetting_equivalency_plan : IDisposable\n {\n private static EquivalencyPlan Plan => AssertionConfiguration.Current.Equivalency.Plan;\n\n [Fact]\n public void When_inserting_a_step_then_it_should_precede_all_other_steps()\n {\n // Arrange / Act\n Plan.Insert();\n\n // Assert\n var addedStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n\n Plan.Should().StartWith(addedStep);\n }\n\n [Fact]\n public void When_inserting_a_step_before_another_then_it_should_precede_that_particular_step()\n {\n // Arrange / Act\n Plan.InsertBefore();\n\n // Assert\n var addedStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n var successor = Plan.LastOrDefault(s => s is DictionaryEquivalencyStep);\n\n Plan.Should().HaveElementPreceding(successor, addedStep);\n }\n\n [Fact]\n public void When_appending_a_step_then_it_should_precede_the_final_builtin_step()\n {\n // Arrange / Act\n Plan.Add();\n\n // Assert\n var equivalencyStep = Plan.LastOrDefault(s => s is SimpleEqualityEquivalencyStep);\n var subjectStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n\n Plan.Should().HaveElementPreceding(equivalencyStep, subjectStep);\n }\n\n [Fact]\n public void When_appending_a_step_after_another_then_it_should_precede_the_final_builtin_step()\n {\n // Arrange / Act\n Plan.AddAfter();\n\n // Assert\n var addedStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n var predecessor = Plan.LastOrDefault(s => s is DictionaryEquivalencyStep);\n\n Plan.Should().HaveElementSucceeding(predecessor, addedStep);\n }\n\n [Fact]\n public void When_appending_a_step_and_no_builtin_steps_are_there_then_it_should_precede_the_simple_equality_step()\n {\n // Arrange / Act\n Plan.Clear();\n Plan.Add();\n\n // Assert\n var subjectStep = Plan.LastOrDefault(s => s is MyEquivalencyStep);\n Plan.Should().EndWith(subjectStep);\n }\n\n [Fact]\n public void When_removing_a_specific_step_then_it_should_precede_the_simple_equality_step()\n {\n // Arrange / Act\n Plan.Remove();\n\n // Assert\n Plan.Should().NotContain(s => s is SimpleEqualityEquivalencyStep);\n }\n\n [Fact]\n public void When_removing_a_specific_step_that_doesnt_exist_Then_it_should_precede_the_simple_equality_step()\n {\n // Arrange / Act\n var action = () => Plan.Remove();\n\n // Assert\n action.Should().NotThrow();\n }\n\n private class MyEquivalencyStep : IEquivalencyStep\n {\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n AssertionChain.GetOrCreate().For(context).FailWith(GetType().FullName);\n\n return EquivalencyResult.EquivalencyProven;\n }\n }\n\n public void Dispose() => Plan.Reset();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EnumerableEquivalencyValidator.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Executes a single equivalency assertion on two collections, optionally recursive and with or without strict ordering.\n/// \ninternal class EnumerableEquivalencyValidator\n{\n private const int FailedItemsFastFailThreshold = 10;\n\n #region Private Definitions\n\n private readonly AssertionChain assertionChain;\n private readonly IValidateChildNodeEquivalency parent;\n private readonly IEquivalencyValidationContext context;\n\n #endregion\n\n public EnumerableEquivalencyValidator(AssertionChain assertionChain, IValidateChildNodeEquivalency parent,\n IEquivalencyValidationContext context)\n {\n this.assertionChain = assertionChain;\n this.parent = parent;\n this.context = context;\n Recursive = false;\n }\n\n public bool Recursive { get; init; }\n\n public OrderingRuleCollection OrderingRules { get; init; }\n\n public void Execute(object[] subject, T[] expectation)\n {\n if (AssertIsNotNull(expectation, subject) && AssertCollectionsHaveSameCount(subject, expectation))\n {\n if (Recursive)\n {\n using var _ = context.Tracer.WriteBlock(member =>\n Invariant($\"Structurally comparing {subject} and expectation {expectation} at {member.Expectation}\"));\n\n AssertElementGraphEquivalency(subject, expectation, context.CurrentNode);\n }\n else\n {\n using var _ = context.Tracer.WriteBlock(member =>\n Invariant(\n $\"Comparing subject {subject} and expectation {expectation} at {member.Expectation} using simple value equality\"));\n\n subject.Should().BeEquivalentTo(expectation);\n }\n }\n }\n\n private bool AssertIsNotNull(object expectation, object[] subject)\n {\n assertionChain\n .ForCondition(expectation is not null)\n .FailWith(\"Expected {context:subject} to be , but found {0}.\", [subject]);\n\n return assertionChain.Succeeded;\n }\n\n private bool AssertCollectionsHaveSameCount(ICollection subject, ICollection expectation)\n {\n assertionChain\n .AssertEitherCollectionIsNotEmpty(subject, expectation)\n .Then\n .AssertCollectionHasEnoughItems(subject, expectation)\n .Then\n .AssertCollectionHasNotTooManyItems(subject, expectation);\n\n return assertionChain.Succeeded;\n }\n\n private void AssertElementGraphEquivalency(object[] subjects, T[] expectations, INode currentNode)\n {\n unmatchedSubjectIndexes = Enumerable.Range(0, subjects.Length).ToList();\n\n if (OrderingRules.IsOrderingStrictFor(new ObjectInfo(new Comparands(subjects, expectations, typeof(T[])), currentNode)))\n {\n AssertElementGraphEquivalencyWithStrictOrdering(subjects, expectations);\n }\n else\n {\n AssertElementGraphEquivalencyWithLooseOrdering(subjects, expectations);\n }\n }\n\n private void AssertElementGraphEquivalencyWithStrictOrdering(object[] subjects, T[] expectations)\n {\n int failedCount = 0;\n\n foreach (int index in Enumerable.Range(0, expectations.Length))\n {\n T expectation = expectations[index];\n\n using var _ = context.Tracer.WriteBlock(member =>\n Invariant(\n $\"Strictly comparing expectation {expectation} at {member.Expectation} to item with index {index} in {subjects}\"));\n\n bool succeeded = StrictlyMatchAgainst(subjects, expectation, index);\n if (!succeeded)\n {\n failedCount++;\n if (failedCount >= FailedItemsFastFailThreshold)\n {\n context.Tracer.WriteLine(member =>\n $\"Aborting strict order comparison of collections after {FailedItemsFastFailThreshold} items failed at {member.Expectation}\");\n\n break;\n }\n }\n }\n }\n\n private void AssertElementGraphEquivalencyWithLooseOrdering(object[] subjects, T[] expectations)\n {\n int failedCount = 0;\n\n foreach (int index in Enumerable.Range(0, expectations.Length))\n {\n T expectation = expectations[index];\n\n using var _ = context.Tracer.WriteBlock(member =>\n Invariant(\n $\"Finding the best match of {expectation} within all items in {subjects} at {member.Expectation}[{index}]\"));\n\n bool succeeded = LooselyMatchAgainst(subjects, expectation, index);\n\n if (!succeeded)\n {\n failedCount++;\n\n if (failedCount >= FailedItemsFastFailThreshold)\n {\n context.Tracer.WriteLine(member =>\n $\"Fail failing loose order comparison of collection after {FailedItemsFastFailThreshold} items failed at {member.Expectation}\");\n\n break;\n }\n }\n }\n }\n\n private List unmatchedSubjectIndexes;\n\n private bool LooselyMatchAgainst(IList subjects, T expectation, int expectationIndex)\n {\n var results = new AssertionResultSet();\n int index = 0;\n\n GetTraceMessage getMessage = member =>\n $\"Comparing subject at {member.Subject}[{index}] with the expectation at {member.Expectation}[{expectationIndex}]\";\n\n int indexToBeRemoved = -1;\n\n for (var metaIndex = 0; metaIndex < unmatchedSubjectIndexes.Count; metaIndex++)\n {\n index = unmatchedSubjectIndexes[metaIndex];\n object subject = subjects[index];\n\n using var _ = context.Tracer.WriteBlock(getMessage);\n string[] failures = TryToMatch(subject, expectation, expectationIndex);\n\n results.AddSet(index, failures);\n\n if (results.ContainsSuccessfulSet())\n {\n context.Tracer.WriteLine(_ => \"It's a match\");\n indexToBeRemoved = metaIndex;\n break;\n }\n\n context.Tracer.WriteLine(_ => $\"Contained {failures.Length} failures\");\n }\n\n if (indexToBeRemoved != -1)\n {\n unmatchedSubjectIndexes.RemoveAt(indexToBeRemoved);\n }\n\n foreach (string failure in results.GetTheFailuresForTheSetWithTheFewestFailures(expectationIndex))\n {\n assertionChain.AddPreFormattedFailure(failure);\n }\n\n return indexToBeRemoved != -1;\n }\n\n private string[] TryToMatch(object subject, T expectation, int expectationIndex)\n {\n using var scope = new AssertionScope();\n\n parent.AssertEquivalencyOf(new Comparands(subject, expectation, typeof(T)), context.AsCollectionItem(expectationIndex));\n\n return scope.Discard();\n }\n\n private bool StrictlyMatchAgainst(object[] subjects, T expectation, int expectationIndex)\n {\n using var scope = new AssertionScope();\n object subject = subjects[expectationIndex];\n IEquivalencyValidationContext equivalencyValidationContext = context.AsCollectionItem(expectationIndex);\n\n parent.AssertEquivalencyOf(new Comparands(subject, expectation, typeof(T)), equivalencyValidationContext);\n\n bool failed = scope.HasFailures();\n return !failed;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/AssertionContext.cs", "using System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\ninternal sealed class AssertionContext : IAssertionContext\n{\n private AssertionContext(INode currentNode, TSubject subject, TSubject expectation,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n {\n SelectedNode = currentNode;\n Subject = subject;\n Expectation = expectation;\n Because = because;\n BecauseArgs = becauseArgs;\n }\n\n public INode SelectedNode { get; }\n\n public TSubject Subject { get; }\n\n public TSubject Expectation { get; }\n\n public string Because { get; set; }\n\n public object[] BecauseArgs { get; set; }\n\n internal static AssertionContext CreateFrom(Comparands comparands, IEquivalencyValidationContext context)\n {\n return new AssertionContext(\n context.CurrentNode,\n (TSubject)comparands.Subject,\n (TSubject)comparands.Expectation,\n context.Reason.FormattedMessage,\n context.Reason.Arguments);\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/UsersOfGetClosedGenericInterfaces.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Equivalency.Steps;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Engines;\nusing Bogus;\n\nnamespace Benchmarks;\n\n[SimpleJob(RunStrategy.Throughput, warmupCount: 3, iterationCount: 20)]\npublic class UsersOfGetClosedGenericInterfaces\n{\n private const int ValueCount = 100_000;\n\n private object[] values;\n\n private GenericDictionaryEquivalencyStep dictionaryStep;\n private GenericEnumerableEquivalencyStep enumerableStep;\n\n private IEquivalencyValidationContext context;\n\n private class Context : IEquivalencyValidationContext\n {\n public INode CurrentNode { get; }\n\n public Reason Reason { get; }\n\n public Tracer Tracer { get; }\n\n public IEquivalencyOptions Options { get; internal set; }\n\n public bool IsCyclicReference(object expectation) => throw new NotImplementedException();\n\n public IEquivalencyValidationContext AsNestedMember(IMember expectationMember) => throw new NotImplementedException();\n\n public IEquivalencyValidationContext AsCollectionItem(string index) => throw new NotImplementedException();\n\n public IEquivalencyValidationContext AsDictionaryItem(TKey key) =>\n throw new NotImplementedException();\n\n public IEquivalencyValidationContext Clone() => throw new NotImplementedException();\n }\n\n private class Config : IEquivalencyOptions\n {\n public IEnumerable SelectionRules => throw new NotImplementedException();\n\n public IEnumerable MatchingRules => throw new NotImplementedException();\n\n public bool IsRecursive => throw new NotImplementedException();\n\n public bool AllowInfiniteRecursion => throw new NotImplementedException();\n\n public CyclicReferenceHandling CyclicReferenceHandling => throw new NotImplementedException();\n\n public OrderingRuleCollection OrderingRules => throw new NotImplementedException();\n\n public ConversionSelector ConversionSelector => throw new NotImplementedException();\n\n public EnumEquivalencyHandling EnumEquivalencyHandling => throw new NotImplementedException();\n\n public IEnumerable UserEquivalencySteps => throw new NotImplementedException();\n\n public bool UseRuntimeTyping => false;\n\n public MemberVisibility IncludedProperties => throw new NotImplementedException();\n\n public MemberVisibility IncludedFields => throw new NotImplementedException();\n\n public bool IgnoreNonBrowsableOnSubject => throw new NotImplementedException();\n\n public bool ExcludeNonBrowsableOnExpectation => throw new NotImplementedException();\n\n public bool? CompareRecordsByValue => throw new NotImplementedException();\n\n public ITraceWriter TraceWriter => throw new NotImplementedException();\n\n public EqualityStrategy GetEqualityStrategy(Type type) => throw new NotImplementedException();\n\n public bool IgnoreLeadingWhitespace => throw new NotImplementedException();\n\n public bool IgnoreTrailingWhitespace => throw new NotImplementedException();\n\n public bool IgnoreCase => throw new NotImplementedException();\n\n public bool IgnoreNewlineStyle => throw new NotImplementedException();\n }\n\n [Params(typeof(DBNull), typeof(bool), typeof(char), typeof(sbyte), typeof(byte), typeof(short), typeof(ushort),\n typeof(int), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal), typeof(DateTime),\n typeof(string), typeof(TimeSpan), typeof(Guid), typeof(Dictionary), typeof(IEnumerable))]\n public Type DataType { get; set; }\n\n [GlobalSetup]\n [SuppressMessage(\"Style\", \"IDE0055:Fix formatting\", Justification = \"Big long list of one-liners\")]\n public void GlobalSetup()\n {\n dictionaryStep = new GenericDictionaryEquivalencyStep();\n enumerableStep = new GenericEnumerableEquivalencyStep();\n\n var faker = new Faker\n {\n Random = new Randomizer(localSeed: 1)\n };\n\n values = Enumerable.Range(0, ValueCount).Select(_ => CreateValue(faker)).ToArray();\n\n context = new Context\n {\n Options = new Config()\n };\n }\n\n private object CreateValue(Faker faker) => Type.GetTypeCode(DataType) switch\n {\n TypeCode.DBNull => DBNull.Value,\n TypeCode.Boolean => faker.Random.Bool(),\n TypeCode.Char => faker.Lorem.Letter().Single(),\n TypeCode.SByte => faker.Random.SByte(),\n TypeCode.Byte => faker.Random.Byte(),\n TypeCode.Int16 => faker.Random.Short(),\n TypeCode.UInt16 => faker.Random.UShort(),\n TypeCode.Int32 => faker.Random.Int(),\n TypeCode.UInt32 => faker.Random.UInt(),\n TypeCode.Int64 => faker.Random.Long(),\n TypeCode.UInt64 => faker.Random.ULong(),\n TypeCode.Single => faker.Random.Float(),\n TypeCode.Double => faker.Random.Double(),\n TypeCode.Decimal => faker.Random.Decimal(),\n TypeCode.DateTime => faker.Date.Between(DateTime.UtcNow.AddDays(-30), DateTime.UtcNow.AddDays(+30)),\n TypeCode.String => faker.Lorem.Lines(1),\n _ => CustomValue(faker),\n };\n\n private object CustomValue(Faker faker)\n {\n if (DataType == typeof(TimeSpan))\n {\n return faker.Date.Future() - faker.Date.Future();\n }\n else if (DataType == typeof(Guid))\n {\n return faker.Random.Guid();\n }\n else if (DataType == typeof(Dictionary))\n {\n return new Dictionary { { faker.Random.Int(), faker.Random.Int() } };\n }\n else if (DataType == typeof(IEnumerable))\n {\n return new[] { faker.Random.Int(), faker.Random.Int() };\n }\n\n throw new Exception(\"Unable to populate data of type \" + DataType);\n }\n\n [Benchmark]\n public void GenericDictionaryEquivalencyStep_CanHandle()\n {\n for (int i = 0; i < values.Length; i++)\n {\n dictionaryStep.Handle(new Comparands(values[i], values[0], typeof(object)), context, null);\n }\n }\n\n [Benchmark]\n public void GenericEnumerableEquivalencyStep_CanHandle()\n {\n for (int i = 0; i < values.Length; i++)\n {\n enumerableStep.Handle(new Comparands(values[i], values[0], typeof(object)), context, null);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IValidateChildNodeEquivalency.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic interface IValidateChildNodeEquivalency\n{\n /// \n /// Runs a deep recursive equivalency assertion on the provided .\n /// \n void AssertEquivalencyOf(Comparands comparands, IEquivalencyValidationContext context);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyValidationContext.cs", "using AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides information on a particular property during an assertion for structural equality of two object graphs.\n/// \npublic class EquivalencyValidationContext : IEquivalencyValidationContext\n{\n private Tracer tracer;\n\n public EquivalencyValidationContext(INode root, IEquivalencyOptions options)\n {\n Options = options;\n CurrentNode = root;\n CyclicReferenceDetector = new CyclicReferenceDetector();\n }\n\n public INode CurrentNode { get; }\n\n public Reason Reason { get; set; }\n\n public Tracer Tracer => tracer ??= new Tracer(CurrentNode, TraceWriter);\n\n public IEquivalencyOptions Options { get; }\n\n private CyclicReferenceDetector CyclicReferenceDetector { get; set; }\n\n public IEquivalencyValidationContext AsNestedMember(IMember expectationMember)\n {\n return new EquivalencyValidationContext(expectationMember, Options)\n {\n Reason = Reason,\n TraceWriter = TraceWriter,\n CyclicReferenceDetector = CyclicReferenceDetector\n };\n }\n\n public IEquivalencyValidationContext AsCollectionItem(string index)\n {\n return new EquivalencyValidationContext(Node.FromCollectionItem(index, CurrentNode), Options)\n {\n Reason = Reason,\n TraceWriter = TraceWriter,\n CyclicReferenceDetector = CyclicReferenceDetector\n };\n }\n\n public IEquivalencyValidationContext AsDictionaryItem(TKey key)\n {\n return new EquivalencyValidationContext(Node.FromDictionaryItem(key, CurrentNode), Options)\n {\n Reason = Reason,\n TraceWriter = TraceWriter,\n CyclicReferenceDetector = CyclicReferenceDetector\n };\n }\n\n public IEquivalencyValidationContext Clone()\n {\n return new EquivalencyValidationContext(CurrentNode, Options)\n {\n Reason = Reason,\n TraceWriter = TraceWriter,\n CyclicReferenceDetector = CyclicReferenceDetector\n };\n }\n\n public bool IsCyclicReference(object expectation)\n {\n bool compareByMembers = expectation is not null && Options.GetEqualityStrategy(expectation.GetType())\n is EqualityStrategy.Members or EqualityStrategy.ForceMembers;\n\n var reference = new ObjectReference(expectation, CurrentNode.Subject.PathAndName, compareByMembers);\n return CyclicReferenceDetector.IsCyclicReference(reference);\n }\n\n public ITraceWriter TraceWriter { get; set; }\n\n public override string ToString()\n {\n return Invariant($\"{{Path=\\\"{CurrentNode.Subject.PathAndName}\\\"}}\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/AssertionChainExtensions.cs", "using AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal static class AssertionChainExtensions\n{\n /// \n /// Updates the with the relevant information from the current , including the correct\n /// caller identification path.\n /// \n public static AssertionChain For(this AssertionChain chain, IEquivalencyValidationContext context)\n {\n chain.OverrideCallerIdentifier(() => context.CurrentNode.Subject.Description);\n\n return chain\n .WithReportable(\"configuration\", () => context.Options.ToString())\n .BecauseOf(context.Reason);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/SelfReferenceEquivalencyOptions.cs", "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.Linq.Expressions;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Matching;\nusing AwesomeAssertions.Equivalency.Ordering;\nusing AwesomeAssertions.Equivalency.Selection;\nusing AwesomeAssertions.Equivalency.Steps;\nusing AwesomeAssertions.Equivalency.Tracing;\n\nnamespace AwesomeAssertions.Equivalency;\n\n#pragma warning disable CA1033 //An unsealed externally visible type provides an explicit method implementation of a public interface and does not provide an alternative externally visible method that has the same name.\n\n/// \n/// Represents the run-time behavior of a structural equivalency assertion.\n/// \npublic abstract class SelfReferenceEquivalencyOptions : IEquivalencyOptions\n where TSelf : SelfReferenceEquivalencyOptions\n{\n #region Private Definitions\n\n private readonly EqualityStrategyProvider equalityStrategyProvider;\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private readonly List selectionRules = [];\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private readonly List matchingRules = [];\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private readonly List userEquivalencySteps = [];\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private CyclicReferenceHandling cyclicReferenceHandling = CyclicReferenceHandling.ThrowException;\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n protected OrderingRuleCollection OrderingRules { get; } = [];\n\n [DebuggerBrowsable(DebuggerBrowsableState.Never)]\n private bool isRecursive;\n\n private bool allowInfiniteRecursion;\n\n private EnumEquivalencyHandling enumEquivalencyHandling;\n\n private bool useRuntimeTyping;\n\n private MemberVisibility includedProperties;\n private MemberVisibility includedFields;\n private bool ignoreNonBrowsableOnSubject;\n private bool excludeNonBrowsableOnExpectation;\n\n private IEqualityComparer stringComparer;\n\n #endregion\n\n private protected SelfReferenceEquivalencyOptions()\n {\n equalityStrategyProvider = new EqualityStrategyProvider();\n\n AddMatchingRule(new MustMatchByNameRule());\n\n OrderingRules.Add(new ByteArrayOrderingRule());\n }\n\n /// \n /// Creates an instance of the equivalency assertions options based on defaults previously configured by the caller.\n /// \n protected SelfReferenceEquivalencyOptions(IEquivalencyOptions defaults)\n {\n equalityStrategyProvider = new EqualityStrategyProvider(defaults.GetEqualityStrategy)\n {\n CompareRecordsByValue = defaults.CompareRecordsByValue\n };\n\n isRecursive = defaults.IsRecursive;\n cyclicReferenceHandling = defaults.CyclicReferenceHandling;\n allowInfiniteRecursion = defaults.AllowInfiniteRecursion;\n enumEquivalencyHandling = defaults.EnumEquivalencyHandling;\n useRuntimeTyping = defaults.UseRuntimeTyping;\n includedProperties = defaults.IncludedProperties;\n includedFields = defaults.IncludedFields;\n ignoreNonBrowsableOnSubject = defaults.IgnoreNonBrowsableOnSubject;\n excludeNonBrowsableOnExpectation = defaults.ExcludeNonBrowsableOnExpectation;\n IgnoreLeadingWhitespace = defaults.IgnoreLeadingWhitespace;\n IgnoreTrailingWhitespace = defaults.IgnoreTrailingWhitespace;\n IgnoreCase = defaults.IgnoreCase;\n IgnoreNewlineStyle = defaults.IgnoreNewlineStyle;\n\n ConversionSelector = defaults.ConversionSelector.Clone();\n\n selectionRules.AddRange(defaults.SelectionRules);\n userEquivalencySteps.AddRange(defaults.UserEquivalencySteps);\n matchingRules.AddRange(defaults.MatchingRules);\n OrderingRules = new OrderingRuleCollection(defaults.OrderingRules);\n\n TraceWriter = defaults.TraceWriter;\n\n RemoveSelectionRule();\n RemoveSelectionRule();\n }\n\n /// \n /// Gets an ordered collection of selection rules that define what members are included.\n /// \n IEnumerable IEquivalencyOptions.SelectionRules\n {\n get\n {\n bool hasConflictingRules = selectionRules.Exists(rule => rule.IncludesMembers);\n\n if (includedProperties.HasFlag(MemberVisibility.Public) && !hasConflictingRules)\n {\n yield return new AllPropertiesSelectionRule();\n }\n\n if (includedFields.HasFlag(MemberVisibility.Public) && !hasConflictingRules)\n {\n yield return new AllFieldsSelectionRule();\n }\n\n if (excludeNonBrowsableOnExpectation)\n {\n yield return new ExcludeNonBrowsableMembersRule();\n }\n\n foreach (IMemberSelectionRule rule in selectionRules)\n {\n yield return rule;\n }\n }\n }\n\n /// \n /// Gets an ordered collection of matching rules that determine which subject members are matched with which\n /// expectation members.\n /// \n IEnumerable IEquivalencyOptions.MatchingRules => matchingRules;\n\n /// \n /// Gets an ordered collection of Equivalency steps how a subject is compared with the expectation.\n /// \n IEnumerable IEquivalencyOptions.UserEquivalencySteps => userEquivalencySteps;\n\n public ConversionSelector ConversionSelector { get; } = new();\n\n /// \n /// Gets an ordered collection of rules that determine whether or not the order of collections is important. By\n /// default,\n /// ordering is irrelevant.\n /// \n OrderingRuleCollection IEquivalencyOptions.OrderingRules => OrderingRules;\n\n /// \n /// Gets value indicating whether the equality check will include nested collections and complex types.\n /// \n bool IEquivalencyOptions.IsRecursive => isRecursive;\n\n bool IEquivalencyOptions.AllowInfiniteRecursion => allowInfiniteRecursion;\n\n /// \n /// Gets value indicating how cyclic references should be handled. By default, it will throw an exception.\n /// \n CyclicReferenceHandling IEquivalencyOptions.CyclicReferenceHandling => cyclicReferenceHandling;\n\n EnumEquivalencyHandling IEquivalencyOptions.EnumEquivalencyHandling => enumEquivalencyHandling;\n\n bool IEquivalencyOptions.UseRuntimeTyping => useRuntimeTyping;\n\n MemberVisibility IEquivalencyOptions.IncludedProperties => includedProperties;\n\n MemberVisibility IEquivalencyOptions.IncludedFields => includedFields;\n\n bool IEquivalencyOptions.IgnoreNonBrowsableOnSubject => ignoreNonBrowsableOnSubject;\n\n bool IEquivalencyOptions.ExcludeNonBrowsableOnExpectation => excludeNonBrowsableOnExpectation;\n\n public bool? CompareRecordsByValue => equalityStrategyProvider.CompareRecordsByValue;\n\n EqualityStrategy IEquivalencyOptions.GetEqualityStrategy(Type type)\n => equalityStrategyProvider.GetEqualityStrategy(type);\n\n public bool IgnoreLeadingWhitespace { get; private set; }\n\n public bool IgnoreTrailingWhitespace { get; private set; }\n\n public bool IgnoreCase { get; private set; }\n\n public bool IgnoreNewlineStyle { get; private set; }\n\n public ITraceWriter TraceWriter { get; private set; }\n\n /// \n /// Causes inclusion of only public properties of the subject as far as they are defined on the declared type.\n /// \n /// \n /// This clears all previously registered selection rules.\n /// \n public TSelf IncludingAllDeclaredProperties()\n {\n PreferringDeclaredMemberTypes();\n\n ExcludingFields();\n IncludingProperties();\n\n WithoutSelectionRules();\n\n return (TSelf)this;\n }\n\n /// \n /// Causes inclusion of only public properties of the subject based on its run-time type rather than its declared type.\n /// \n /// \n /// This clears all previously registered selection rules.\n /// \n public TSelf IncludingAllRuntimeProperties()\n {\n PreferringRuntimeMemberTypes();\n\n ExcludingFields();\n IncludingProperties();\n\n WithoutSelectionRules();\n\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to include public fields.\n /// \n /// \n /// This is part of the default behavior.\n /// \n public TSelf IncludingFields()\n {\n includedFields = MemberVisibility.Public;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to include public and internal fields.\n /// \n public TSelf IncludingInternalFields()\n {\n includedFields = MemberVisibility.Public | MemberVisibility.Internal;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to exclude fields.\n /// \n /// \n /// This does not preclude use of `Including`.\n /// \n public TSelf ExcludingFields()\n {\n includedFields = MemberVisibility.None;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to include public properties.\n /// \n /// \n /// This is part of the default behavior.\n /// \n public TSelf IncludingProperties()\n {\n includedProperties = MemberVisibility.Public | MemberVisibility.ExplicitlyImplemented |\n MemberVisibility.DefaultInterfaceProperties;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to include public and internal properties.\n /// \n public TSelf IncludingInternalProperties()\n {\n includedProperties = MemberVisibility.Public | MemberVisibility.Internal | MemberVisibility.ExplicitlyImplemented |\n MemberVisibility.DefaultInterfaceProperties;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to exclude properties.\n /// \n /// \n /// This does not preclude use of `Including`.\n /// \n public TSelf ExcludingProperties()\n {\n includedProperties = MemberVisibility.None;\n return (TSelf)this;\n }\n\n /// \n /// Excludes properties that are explicitly implemented from the equivalency comparison.\n /// \n public TSelf ExcludingExplicitlyImplementedProperties()\n {\n includedProperties &= ~MemberVisibility.ExplicitlyImplemented;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to exclude non-browsable members in the expectation (members set to\n /// ). It is not required that they be marked non-browsable in the subject. Use\n /// to ignore non-browsable members in the subject.\n /// \n public TSelf ExcludingNonBrowsableMembers()\n {\n excludeNonBrowsableOnExpectation = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to treat non-browsable members in the subject as though they do not exist. If you need to\n /// ignore non-browsable members in the expectation, use .\n /// \n public TSelf IgnoringNonBrowsableMembersOnSubject()\n {\n ignoreNonBrowsableOnSubject = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the structural equality comparison to use the run-time types\n /// of the members to drive the assertion.\n /// \n public TSelf PreferringRuntimeMemberTypes()\n {\n useRuntimeTyping = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the structural equality comparison to prefer the declared types\n /// of the members when executing assertions.\n /// \n /// \n /// In reality, the declared types of the members are only known for the members of the root object,\n /// or the objects in a root collection. Beyond that, AwesomeAssertions only knows the run-time types of the members.\n /// \n public TSelf PreferringDeclaredMemberTypes()\n {\n useRuntimeTyping = false;\n return (TSelf)this;\n }\n\n /// \n /// Excludes a (nested) property based on a predicate from the structural equality check.\n /// \n public TSelf Excluding(Expression> predicate)\n {\n AddSelectionRule(new ExcludeMemberByPredicateSelectionRule(predicate));\n return (TSelf)this;\n }\n\n /// \n /// Includes the specified member in the equality check.\n /// \n /// \n /// This overrides the default behavior of including all declared members.\n /// \n public TSelf Including(Expression> predicate)\n {\n AddSelectionRule(new IncludeMemberByPredicateSelectionRule(predicate));\n return (TSelf)this;\n }\n\n /// \n /// Tries to match the members of the expectation with equally named members on the subject. Ignores those\n /// members that don't exist on the subject and previously registered matching rules.\n /// \n public TSelf ExcludingMissingMembers()\n {\n matchingRules.RemoveAll(x => x is MustMatchByNameRule);\n matchingRules.Add(new TryMatchByNameRule());\n return (TSelf)this;\n }\n\n /// \n /// Requires the subject to have members which are equally named to members on the expectation.\n /// \n public TSelf ThrowingOnMissingMembers()\n {\n matchingRules.RemoveAll(x => x is TryMatchByNameRule);\n matchingRules.Add(new MustMatchByNameRule());\n return (TSelf)this;\n }\n\n /// \n /// Overrides the comparison of subject and expectation to use provided \n /// when the predicate is met.\n /// \n /// \n /// The assertion to execute when the predicate is met.\n /// \n public Restriction Using(Action> action)\n {\n return new Restriction((TSelf)this, action);\n }\n\n /// \n /// Causes the structural equality comparison to recursively traverse the object graph and compare the fields and\n /// properties of any nested objects and objects in collections.\n /// \n /// \n /// This is the default behavior. You can override this using .\n /// \n public TSelf IncludingNestedObjects()\n {\n isRecursive = true;\n return (TSelf)this;\n }\n\n /// \n /// Stops the structural equality check from recursively comparing the members of any nested objects.\n /// \n /// \n /// If a property or field points to a complex type or collection, a simple call will\n /// be done instead of recursively looking at the members of the nested object.\n /// \n public TSelf WithoutRecursing()\n {\n isRecursive = false;\n return (TSelf)this;\n }\n\n /// \n /// Causes the structural equality check to ignore any cyclic references.\n /// \n /// \n /// By default, cyclic references within the object graph will cause an exception to be thrown.\n /// \n public TSelf IgnoringCyclicReferences()\n {\n cyclicReferenceHandling = CyclicReferenceHandling.Ignore;\n return (TSelf)this;\n }\n\n /// \n /// Disables limitations on recursion depth when the structural equality check is configured to include nested objects\n /// \n public TSelf AllowingInfiniteRecursion()\n {\n allowInfiniteRecursion = true;\n return (TSelf)this;\n }\n\n /// \n /// Clears all selection rules, including those that were added by default.\n /// \n public TSelf WithoutSelectionRules()\n {\n selectionRules.Clear();\n return (TSelf)this;\n }\n\n /// \n /// Clears all matching rules, including those that were added by default.\n /// \n public TSelf WithoutMatchingRules()\n {\n matchingRules.Clear();\n return (TSelf)this;\n }\n\n /// \n /// Adds a selection rule to the ones already added by default, and which is evaluated after all existing rules.\n /// \n public TSelf Using(IMemberSelectionRule selectionRule)\n {\n return AddSelectionRule(selectionRule);\n }\n\n /// \n /// Adds a matching rule to the ones already added by default, and which is evaluated before all existing rules.\n /// \n public TSelf Using(IMemberMatchingRule matchingRule)\n {\n return AddMatchingRule(matchingRule);\n }\n\n /// \n /// Adds an ordering rule to the ones already added by default, and which is evaluated after all existing rules.\n /// \n public TSelf Using(IOrderingRule orderingRule)\n {\n return AddOrderingRule(orderingRule);\n }\n\n /// \n /// Adds an equivalency step rule to the ones already added by default, and which is evaluated before previous\n /// user-registered steps\n /// \n public TSelf Using(IEquivalencyStep equivalencyStep)\n {\n return AddEquivalencyStep(equivalencyStep);\n }\n\n /// \n /// Ensures the equivalency comparison will create and use an instance of \n /// that implements , any time\n /// when a property is of type .\n /// \n public TSelf Using()\n where TEqualityComparer : IEqualityComparer, new()\n {\n return Using(new TEqualityComparer());\n }\n\n /// \n /// Ensures the equivalency comparison will use the specified implementation of \n /// any time when a property is of type .\n /// \n public TSelf Using(IEqualityComparer comparer)\n {\n userEquivalencySteps.Insert(0, new EqualityComparerEquivalencyStep(comparer));\n\n return (TSelf)this;\n }\n\n /// \n /// Ensures the equivalency comparison will use the specified implementation of \n /// any time when a property is a .\n /// \n public TSelf Using(IEqualityComparer comparer)\n {\n userEquivalencySteps.Insert(0, new EqualityComparerEquivalencyStep(comparer));\n stringComparer = comparer;\n\n return (TSelf)this;\n }\n\n /// \n /// Causes all collections to be compared in the order in which the items appear in the expectation.\n /// \n public TSelf WithStrictOrdering()\n {\n OrderingRules.Clear();\n OrderingRules.Add(new MatchAllOrderingRule());\n return (TSelf)this;\n }\n\n /// \n /// Causes the collection identified by the provided to be compared in the order\n /// in which the items appear in the expectation.\n /// \n public TSelf WithStrictOrderingFor(Expression> predicate)\n {\n OrderingRules.Add(new PredicateBasedOrderingRule(predicate));\n return (TSelf)this;\n }\n\n /// \n /// Causes all collections - except bytes - to be compared ignoring the order in which the items appear in the expectation.\n /// \n public TSelf WithoutStrictOrdering()\n {\n OrderingRules.Clear();\n OrderingRules.Add(new ByteArrayOrderingRule());\n return (TSelf)this;\n }\n\n /// \n /// Causes the collection identified by the provided to be compared ignoring the order\n /// in which the items appear in the expectation.\n /// \n public TSelf WithoutStrictOrderingFor(Expression> predicate)\n {\n OrderingRules.Add(new PredicateBasedOrderingRule(predicate)\n {\n Invert = true\n });\n\n return (TSelf)this;\n }\n\n /// \n /// Causes to compare Enum properties using the result of their ToString method.\n /// \n /// \n /// By default, enums are compared by value.\n /// \n public TSelf ComparingEnumsByName()\n {\n enumEquivalencyHandling = EnumEquivalencyHandling.ByName;\n return (TSelf)this;\n }\n\n /// \n /// Causes to compare Enum members using their underlying value only.\n /// \n /// \n /// This is the default.\n /// \n public TSelf ComparingEnumsByValue()\n {\n enumEquivalencyHandling = EnumEquivalencyHandling.ByValue;\n return (TSelf)this;\n }\n\n /// \n /// Ensures records by default are compared by value instead of their members.\n /// \n public TSelf ComparingRecordsByValue()\n {\n equalityStrategyProvider.CompareRecordsByValue = true;\n return (TSelf)this;\n }\n\n /// \n /// Ensures records by default are compared by their members even though they override\n /// the method.\n /// \n /// \n /// This is the default.\n /// \n public TSelf ComparingRecordsByMembers()\n {\n equalityStrategyProvider.CompareRecordsByValue = false;\n return (TSelf)this;\n }\n\n /// \n /// Marks the as a type that should be compared by its members even though it may override\n /// the method.\n /// \n public TSelf ComparingByMembers() => ComparingByMembers(typeof(T));\n\n /// \n /// Marks as a type that should be compared by its members even though it may override\n /// the method.\n /// \n /// is .\n public TSelf ComparingByMembers(Type type)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n if (type.IsPrimitive)\n {\n throw new InvalidOperationException($\"Cannot compare a primitive type such as {type.ToFormattedString()} by its members\");\n }\n\n if (!equalityStrategyProvider.AddReferenceType(type))\n {\n throw new InvalidOperationException(\n $\"Can't compare {type.Name} by its members if it already setup to be compared by value\");\n }\n\n return (TSelf)this;\n }\n\n /// \n /// Marks the as a value type which must be compared using its\n /// method, regardless of it overriding it or not.\n /// \n public TSelf ComparingByValue() => ComparingByValue(typeof(T));\n\n /// \n /// Marks as a value type which must be compared using its\n /// method, regardless of it overriding it or not.\n /// \n /// is .\n public TSelf ComparingByValue(Type type)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n if (!equalityStrategyProvider.AddValueType(type))\n {\n throw new InvalidOperationException(\n $\"Can't compare {type.Name} by value if it already setup to be compared by its members\");\n }\n\n return (TSelf)this;\n }\n\n /// \n /// Enables tracing the steps the equivalency validation followed to compare two graphs.\n /// \n public TSelf WithTracing(ITraceWriter writer = null)\n {\n TraceWriter = writer ?? new StringBuilderTraceWriter();\n return (TSelf)this;\n }\n\n /// \n /// Instructs the equivalency comparison to try to convert the values of\n /// matching properties before running any of the other steps.\n /// \n public TSelf WithAutoConversion()\n {\n ConversionSelector.IncludeAll();\n return (TSelf)this;\n }\n\n /// \n /// Instructs the equivalency comparison to try to convert the value of\n /// a specific member on the expectation object before running any of the other steps.\n /// \n public TSelf WithAutoConversionFor(Expression> predicate)\n {\n ConversionSelector.Include(predicate);\n return (TSelf)this;\n }\n\n /// \n /// Instructs the equivalency comparison to prevent trying to convert the value of\n /// a specific member on the expectation object before running any of the other steps.\n /// \n public TSelf WithoutAutoConversionFor(Expression> predicate)\n {\n ConversionSelector.Exclude(predicate);\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to ignore leading whitespace when comparing s.\n /// \n /// \n /// Note: This affects the index of first mismatch, as the removed whitespace is also ignored for the index calculation!\n /// \n public TSelf IgnoringLeadingWhitespace()\n {\n IgnoreLeadingWhitespace = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to ignore trailing whitespace when comparing s.\n /// \n public TSelf IgnoringTrailingWhitespace()\n {\n IgnoreTrailingWhitespace = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to compare s case-insensitive.\n /// \n public TSelf IgnoringCase()\n {\n IgnoreCase = true;\n return (TSelf)this;\n }\n\n /// \n /// Instructs the comparison to ignore the newline style when comparing s.\n /// \n /// \n /// Enabling this option will replace all occurences of \\r\\n and \\r with \\n in the strings before comparing them.\n /// \n public TSelf IgnoringNewlineStyle()\n {\n IgnoreNewlineStyle = true;\n return (TSelf)this;\n }\n\n /// \n /// Returns the comparer for strings, which is either an explicitly specified comparer via or an ordinal comparer depending on .\n /// \n internal IEqualityComparer GetStringComparerOrDefault()\n {\n return stringComparer ?? (IgnoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);\n }\n\n /// \n /// Returns a string that represents the current object.\n /// \n /// \n /// A string that represents the current object.\n /// \n /// 2\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\")]\n public override string ToString()\n {\n var builder = new StringBuilder();\n\n builder.Append(\"- Prefer the \")\n .Append(useRuntimeTyping ? \"runtime\" : \"declared\")\n .AppendLine(\" type of the members\");\n\n if (ignoreNonBrowsableOnSubject)\n {\n builder.AppendLine(\"- Do not consider members marked non-browsable on the subject\");\n }\n\n if (isRecursive && allowInfiniteRecursion)\n {\n builder.AppendLine(\"- Recurse indefinitely\");\n }\n\n builder.AppendFormat(CultureInfo.InvariantCulture,\n \"- Compare enums by {0}\" + Environment.NewLine,\n enumEquivalencyHandling == EnumEquivalencyHandling.ByName ? \"name\" : \"value\");\n\n if (cyclicReferenceHandling == CyclicReferenceHandling.Ignore)\n {\n builder.AppendLine(\"- Ignoring cyclic references\");\n }\n\n builder\n .AppendLine(\"- Compare tuples by their properties\")\n .AppendLine(\"- Compare anonymous types by their properties\")\n .Append(equalityStrategyProvider);\n\n if (excludeNonBrowsableOnExpectation)\n {\n builder.AppendLine(\"- Exclude non-browsable members\");\n }\n else\n {\n builder.AppendLine(\"- Include non-browsable members\");\n }\n\n foreach (IMemberSelectionRule rule in selectionRules)\n {\n builder.Append(\"- \").AppendLine(rule.ToString());\n }\n\n foreach (IMemberMatchingRule rule in matchingRules)\n {\n builder.Append(\"- \").AppendLine(rule.ToString());\n }\n\n foreach (IEquivalencyStep step in userEquivalencySteps)\n {\n builder.Append(\"- \").AppendLine(step.ToString());\n }\n\n foreach (IOrderingRule rule in OrderingRules)\n {\n builder.Append(\"- \").AppendLine(rule.ToString());\n }\n\n builder.Append(\"- \").AppendLine(ConversionSelector.ToString());\n\n return builder.ToString();\n }\n\n /// \n /// Defines additional overrides when used with \n /// \n public class Restriction\n {\n private readonly Action> action;\n private readonly TSelf options;\n\n public Restriction(TSelf options, Action> action)\n {\n this.options = options;\n this.action = action;\n }\n\n /// \n /// Allows overriding the way structural equality is applied to (nested) objects of type\n /// \n /// \n public TSelf WhenTypeIs()\n where TMemberType : TMember\n {\n When(info => info.RuntimeType.IsSameOrInherits(typeof(TMemberType)));\n return options;\n }\n\n /// \n /// Allows overriding the way structural equality is applied to particular members.\n /// \n /// \n /// A predicate based on the of the subject that is used to identify the property for which\n /// the\n /// override applies.\n /// \n public TSelf When(Expression> predicate)\n {\n options.userEquivalencySteps.Insert(0,\n new AssertionRuleEquivalencyStep(predicate, action));\n\n return options;\n }\n }\n\n #region Non-fluent API\n\n private void RemoveSelectionRule()\n where T : IMemberSelectionRule\n {\n selectionRules.RemoveAll(selectionRule => selectionRule is T);\n }\n\n protected internal TSelf AddSelectionRule(IMemberSelectionRule selectionRule)\n {\n selectionRules.Add(selectionRule);\n return (TSelf)this;\n }\n\n protected TSelf AddMatchingRule(IMemberMatchingRule matchingRule)\n {\n matchingRules.Insert(0, matchingRule);\n return (TSelf)this;\n }\n\n private TSelf AddOrderingRule(IOrderingRule orderingRule)\n {\n OrderingRules.Add(orderingRule);\n return (TSelf)this;\n }\n\n private TSelf AddEquivalencyStep(IEquivalencyStep equivalencyStep)\n {\n userEquivalencySteps.Add(equivalencyStep);\n return (TSelf)this;\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/ConversionSelector.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Equivalency.Steps;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Collects the members that need to be converted by the .\n/// \npublic class ConversionSelector\n{\n private sealed class ConversionSelectorRule\n {\n public Func Predicate { get; }\n\n public string Description { get; }\n\n public ConversionSelectorRule(Func predicate, string description)\n {\n Predicate = predicate;\n Description = description;\n }\n }\n\n private readonly List inclusions;\n private readonly List exclusions;\n\n public ConversionSelector()\n : this([], [])\n {\n }\n\n private ConversionSelector(List inclusions, List exclusions)\n {\n this.inclusions = inclusions;\n this.exclusions = exclusions;\n }\n\n public void IncludeAll()\n {\n inclusions.Add(new ConversionSelectorRule(_ => true, \"Try conversion of all members. \"));\n }\n\n /// \n /// Instructs the equivalency comparison to try to convert the value of\n /// a specific member on the expectation object before running any of the other steps.\n /// \n /// is .\n public void Include(Expression> predicate)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n inclusions.Add(new ConversionSelectorRule(\n predicate.Compile(),\n $\"Try conversion of member {predicate.Body}. \"));\n }\n\n /// \n /// Instructs the equivalency comparison to prevent trying to convert the value of\n /// a specific member on the expectation object before running any of the other steps.\n /// \n /// is .\n public void Exclude(Expression> predicate)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n exclusions.Add(new ConversionSelectorRule(\n predicate.Compile(),\n $\"Do not convert member {predicate.Body}.\"));\n }\n\n public bool RequiresConversion(Comparands comparands, INode currentNode)\n {\n if (inclusions.Count == 0)\n {\n return false;\n }\n\n var objectInfo = new ObjectInfo(comparands, currentNode);\n\n return inclusions.Exists(p => p.Predicate(objectInfo)) && !exclusions.Exists(p => p.Predicate(objectInfo));\n }\n\n public override string ToString()\n {\n if (inclusions.Count == 0 && exclusions.Count == 0)\n {\n return \"Without automatic conversion.\";\n }\n\n var descriptionBuilder = new StringBuilder();\n\n foreach (ConversionSelectorRule inclusion in inclusions)\n {\n descriptionBuilder.Append(inclusion.Description);\n }\n\n foreach (ConversionSelectorRule exclusion in exclusions)\n {\n descriptionBuilder.Append(exclusion.Description);\n }\n\n return descriptionBuilder.ToString();\n }\n\n public ConversionSelector Clone()\n {\n return new ConversionSelector(new List(inclusions), new List(exclusions));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyPlan.cs", "#region\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency.Steps;\n\n#endregion\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a mutable collection of equivalency steps that can be reordered and/or amended with additional\n/// custom equivalency steps.\n/// \npublic class EquivalencyPlan : IEnumerable\n{\n private List steps = GetDefaultSteps();\n\n public IEnumerator GetEnumerator()\n {\n return steps.GetEnumerator();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n /// \n /// Adds a new after any of the built-in steps, with the exception of the final\n /// .\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Add()\n where TStep : IEquivalencyStep, new()\n {\n InsertBefore();\n }\n\n /// \n /// Adds a new right after the specified .\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void AddAfter()\n where TStep : IEquivalencyStep, new()\n {\n int insertIndex = Math.Max(steps.Count - 1, 0);\n\n IEquivalencyStep predecessor = steps.LastOrDefault(s => s is TPredecessor);\n\n if (predecessor is not null)\n {\n insertIndex = Math.Min(insertIndex, steps.LastIndexOf(predecessor) + 1);\n }\n\n steps.Insert(insertIndex, new TStep());\n }\n\n /// \n /// Inserts a new before any of the built-in steps.\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Insert()\n where TStep : IEquivalencyStep, new()\n {\n steps.Insert(0, new TStep());\n }\n\n /// \n /// Inserts a new just before the .\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void InsertBefore()\n where TStep : IEquivalencyStep, new()\n {\n int insertIndex = Math.Max(steps.Count - 1, 0);\n\n IEquivalencyStep equalityStep = steps.LastOrDefault(s => s is TSuccessor);\n\n if (equalityStep is not null)\n {\n insertIndex = steps.LastIndexOf(equalityStep);\n }\n\n steps.Insert(insertIndex, new TStep());\n }\n\n /// \n /// Removes all instances of the specified from the current step.\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Remove()\n where TStep : IEquivalencyStep\n {\n steps.RemoveAll(s => s is TStep);\n }\n\n /// \n /// Removes each and every built-in .\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Clear()\n {\n steps.Clear();\n }\n\n /// \n /// Removes all custom s.\n /// \n /// \n /// This method is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public void Reset()\n {\n steps = GetDefaultSteps();\n }\n\n private static List GetDefaultSteps()\n {\n return\n [\n new RunAllUserStepsEquivalencyStep(),\n new AutoConversionStep(),\n new ReferenceEqualityEquivalencyStep(),\n new GenericDictionaryEquivalencyStep(),\n new XDocumentEquivalencyStep(),\n new XElementEquivalencyStep(),\n new XAttributeEquivalencyStep(),\n new DictionaryEquivalencyStep(),\n new MultiDimensionalArrayEquivalencyStep(),\n new GenericEnumerableEquivalencyStep(),\n new EnumerableEquivalencyStep(),\n new StringEqualityEquivalencyStep(),\n new EnumEqualityStep(),\n new ValueTypeEquivalencyStep(),\n new StructuralEqualityEquivalencyStep(),\n new SimpleEqualityEquivalencyStep(),\n ];\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/StringCollectionAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Collections;\n\npublic class StringCollectionAssertions : StringCollectionAssertions>\n{\n /// \n /// Initializes a new instance of the class.\n /// \n public StringCollectionAssertions(IEnumerable actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n }\n}\n\npublic class StringCollectionAssertions\n : StringCollectionAssertions>\n where TCollection : IEnumerable\n{\n /// \n /// Initializes a new instance of the class.\n /// \n public StringCollectionAssertions(TCollection actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n }\n}\n\npublic class StringCollectionAssertions : GenericCollectionAssertions\n where TCollection : IEnumerable\n where TAssertions : StringCollectionAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public StringCollectionAssertions(TCollection actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Expects the current collection to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their . To ignore\n /// the element order, use instead.\n /// \n /// An with the expected elements.\n public new AndConstraint Equal(params string[] expected)\n {\n return base.Equal(expected.AsEnumerable());\n }\n\n /// \n /// Expects the current collection to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their . To ignore\n /// the element order, use instead.\n /// \n /// An with the expected elements.\n public AndConstraint Equal(IEnumerable expected)\n {\n return base.Equal(expected);\n }\n\n /// \n /// Asserts that a collection of string is equivalent to another collection of strings.\n /// \n /// \n /// The two collections are equivalent when they both contain the same strings in any order. To assert that the elements\n /// are in the same order, use instead.\n /// \n public AndConstraint BeEquivalentTo(params string[] expectation)\n {\n return BeEquivalentTo(expectation, config => config);\n }\n\n /// \n /// Asserts that a collection of objects is equivalent to another collection of objects.\n /// \n /// \n /// The two collections are equivalent when they both contain the same strings in any order. To assert that the elements\n /// are in the same order, use instead.\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(IEnumerable expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection of objects is equivalent to another collection of objects.\n /// \n /// \n /// The two collections are equivalent when they both contain the same strings in any order. To assert that the elements\n /// are in the same order, use instead.\n /// \n /// An with the expected elements.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults can be modified through\n /// .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(IEnumerable expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions>\n options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults()).AsCollection();\n\n var context =\n new EquivalencyValidationContext(Node.From>(() => CurrentAssertionChain.CallerIdentifier), options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(IEnumerable),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that all strings in a collection of strings are equal to the given string.\n /// \n /// An expected .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint AllBe(string expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return AllBe(expectation, options => options, because, becauseArgs);\n }\n\n /// \n /// Asserts that all strings in a collection of strings are equal to the given string.\n /// \n /// An expected .\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllBe(string expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n string[] repeatedExpectation = RepeatAsManyAs(expectation, Subject).ToArray();\n\n // Because we have just manually created the collection based on single element\n // we are sure that we can force strict ordering, because ordering does not matter in terms\n // of correctness. On the other hand we do not want to change ordering rules for nested objects\n // in case user needs to use them. Strict ordering improves algorithmic complexity\n // from O(n^2) to O(n). For bigger tables it is necessary in order to achieve acceptable\n // execution times.\n Func, EquivalencyOptions> forceStringOrderingConfig =\n x => config(x).WithStrictOrderingFor(s => string.IsNullOrEmpty(s.Path));\n\n return BeEquivalentTo(repeatedExpectation, forceStringOrderingConfig, because, becauseArgs);\n }\n\n /// \n /// Asserts that the collection contains at least one string that matches the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndWhichConstraint ContainMatch(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match strings in collection against . Provide a wildcard pattern or use the Contain method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match strings in collection against an empty string. Provide a wildcard pattern or use the Contain method.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain a match of {0}{reason}, but found .\", wildcardPattern);\n\n string[] matches = [];\n\n int? firstMatch = null;\n\n if (assertionChain.Succeeded)\n {\n (matches, firstMatch) = AllThatMatch(wildcardPattern);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(matches.Length > 0)\n .FailWith(\"Expected {context:collection} {0} to contain a match of {1}{reason}.\", Subject, wildcardPattern);\n }\n\n return new AndWhichConstraint((TAssertions)this, matches, assertionChain, \"[\" + firstMatch + \"]\");\n }\n\n private (string[] MatchingItems, int? FirstMatchingIndex) AllThatMatch(string wildcardPattern)\n {\n int? firstMatchingIndex = null;\n\n var matches = Subject.Where((item, index) =>\n {\n using var scope = new AssertionScope();\n\n item.Should().Match(wildcardPattern);\n\n if (scope.Discard().Length == 0)\n {\n firstMatchingIndex ??= index;\n return true;\n }\n\n return false;\n });\n\n return (matches.ToArray(), firstMatchingIndex);\n }\n\n /// \n /// Asserts that the collection does not contain any string that matches the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint NotContainMatch(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match strings in collection against . Provide a wildcard pattern or use the NotContain method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match strings in collection against an empty string. Provide a wildcard pattern or use the NotContain method.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Did not expect {context:collection} to contain a match of {0}{reason}, but found .\",\n wildcardPattern);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(NotContainsMatch(wildcardPattern))\n .FailWith(\"Did not expect {context:collection} {0} to contain a match of {1}{reason}.\", Subject, wildcardPattern);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n private bool NotContainsMatch(string wildcardPattern)\n {\n using var scope = new AssertionScope();\n\n return Subject.All(item =>\n {\n item.Should().NotMatch(wildcardPattern);\n return scope.Discard().Length == 0;\n });\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/ObjectAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \npublic class ObjectAssertions : ObjectAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public ObjectAssertions(object value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a value equals using the provided .\n /// \n /// The expected value\n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Be(TExpectation expected, IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is TExpectation subject && comparer.Equals(subject, expected))\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that a value does not equal using the provided .\n /// \n /// The unexpected value\n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBe(TExpectation unexpected, IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .ForCondition(Subject is not TExpectation subject || !comparer.Equals(subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Did not expect {context} to be equal to {0}{reason}.\", unexpected);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that a value is one of the specified using the provided .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndConstraint BeOneOf(IEnumerable validValues,\n IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(validValues);\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .ForCondition(Subject is TExpectation subject && validValues.Contains(subject, comparer))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint(this);\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class ObjectAssertions : ReferenceTypeAssertions\n where TAssertions : ObjectAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public ObjectAssertions(TSubject value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a value equals using its implementation.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TSubject expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(ObjectExtensions.GetComparer()(Subject, expected))\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value equals using the provided .\n /// \n /// The expected value\n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Be(TSubject expected, IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(comparer.Equals(Subject, expected))\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value does not equal using its method.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TSubject unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!ObjectExtensions.GetComparer()(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Did not expect {context} to be equal to {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value does not equal using the provided .\n /// \n /// The unexpected value\n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBe(TSubject unexpected, IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .ForCondition(!comparer.Equals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Did not expect {context} to be equal to {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object is equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that an object is equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(TExpectation expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var context = new EquivalencyValidationContext(Node.From(() =>\n CurrentAssertionChain.CallerIdentifier), options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object is not equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The unexpected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(\n TExpectation unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotBeEquivalentTo(unexpected, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that an object is not equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// \n /// The unexpected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeEquivalentTo(\n TExpectation unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n bool hasMismatches;\n\n using (var scope = new AssertionScope())\n {\n BeEquivalentTo(unexpected, config);\n hasMismatches = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(hasMismatches)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} not to be equivalent to {0}{reason}, but they are.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params TSubject[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// An equality comparer to compare values.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndConstraint BeOneOf(IEnumerable validValues,\n IEqualityComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(validValues);\n Guard.ThrowIfArgumentIsNull(comparer);\n\n assertionChain\n .ForCondition(validValues.Contains(Subject, comparer))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() or BeSameAs() instead?\");\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"object\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Execution/CollectionMemberOptionsDecorator.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency.Ordering;\nusing AwesomeAssertions.Equivalency.Selection;\nusing AwesomeAssertions.Equivalency.Tracing;\n\nnamespace AwesomeAssertions.Equivalency.Execution;\n\n/// \n/// Ensures that all the rules remove the collection index from the path before processing it further.\n/// \ninternal class CollectionMemberOptionsDecorator : IEquivalencyOptions\n{\n private readonly IEquivalencyOptions inner;\n\n public CollectionMemberOptionsDecorator(IEquivalencyOptions inner)\n {\n this.inner = inner;\n }\n\n public IEnumerable SelectionRules\n {\n get\n {\n return inner.SelectionRules.Select(rule => new CollectionMemberSelectionRuleDecorator(rule)).ToArray();\n }\n }\n\n public IEnumerable MatchingRules\n {\n get { return inner.MatchingRules.ToArray(); }\n }\n\n public OrderingRuleCollection OrderingRules\n {\n get\n {\n return new OrderingRuleCollection(inner.OrderingRules.Select(rule =>\n new CollectionMemberOrderingRuleDecorator(rule)));\n }\n }\n\n public ConversionSelector ConversionSelector => inner.ConversionSelector;\n\n public IEnumerable UserEquivalencySteps\n {\n get { return inner.UserEquivalencySteps; }\n }\n\n public bool IsRecursive => inner.IsRecursive;\n\n public bool AllowInfiniteRecursion => inner.AllowInfiniteRecursion;\n\n public CyclicReferenceHandling CyclicReferenceHandling => inner.CyclicReferenceHandling;\n\n public EnumEquivalencyHandling EnumEquivalencyHandling => inner.EnumEquivalencyHandling;\n\n public bool UseRuntimeTyping => inner.UseRuntimeTyping;\n\n public MemberVisibility IncludedProperties => inner.IncludedProperties;\n\n public MemberVisibility IncludedFields => inner.IncludedFields;\n\n public bool IgnoreNonBrowsableOnSubject => inner.IgnoreNonBrowsableOnSubject;\n\n public bool ExcludeNonBrowsableOnExpectation => inner.ExcludeNonBrowsableOnExpectation;\n\n public bool? CompareRecordsByValue => inner.CompareRecordsByValue;\n\n public EqualityStrategy GetEqualityStrategy(Type type)\n {\n return inner.GetEqualityStrategy(type);\n }\n\n public bool IgnoreLeadingWhitespace => inner.IgnoreLeadingWhitespace;\n\n public bool IgnoreTrailingWhitespace => inner.IgnoreTrailingWhitespace;\n\n public bool IgnoreCase => inner.IgnoreCase;\n\n public bool IgnoreNewlineStyle => inner.IgnoreNewlineStyle;\n\n public ITraceWriter TraceWriter => inner.TraceWriter;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/ComparableTypeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class ComparableTypeAssertions : ComparableTypeAssertions>\n{\n public ComparableTypeAssertions(IComparable value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class ComparableTypeAssertions : ReferenceTypeAssertions, TAssertions>\n where TAssertions : ComparableTypeAssertions\n{\n private const int Equal = 0;\n private readonly AssertionChain assertionChain;\n\n public ComparableTypeAssertions(IComparable value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that an object equals another object using its implementation.
\n /// Verification whether returns 0 is not done here, you should use\n /// to verify this.\n ///
\n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Equals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be equal to {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object is equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that an object is equivalent to another object.\n /// \n /// \n /// Objects are equivalent when both object graphs have equally named properties with the same value,\n /// irrespective of the type of those objects. Two properties are also equal if one type can be converted to another and the result is equal.\n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(TExpectation expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var context = new EquivalencyValidationContext(\n Node.From(() => CurrentAssertionChain.CallerIdentifier), options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object does not equal another object using its method.
\n /// Verification whether returns non-zero is not done here, you should use\n /// to verify this.\n ///
\n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(T unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Equals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:object} to be equal to {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is ranked equal to another object. I.e. the result of returns 0.\n /// To verify whether the objects are equal you must use .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeRankedEquallyTo(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) == Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be ranked as equal to {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is not ranked equal to another object. I.e. the result of returns non-zero.\n /// To verify whether the objects are not equal according to you must use .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeRankedEquallyTo(T unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(unexpected) != Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} not to be ranked as equal to {1}{reason}.\", Subject, unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is less than another object according to its implementation of .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThan(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) < Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be less than {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is less than or equal to another object according to its implementation of .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThanOrEqualTo(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) <= Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be less than or equal to {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is greater than another object according to its implementation of .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThan(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) > Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be greater than {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the subject is greater than or equal to another object according to its implementation of .\n /// \n /// \n /// The object to pass to the subject's method.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThanOrEqualTo(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(expected) >= Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} {0} to be greater than or equal to {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is within a range.\n /// \n /// \n /// Where the range is continuous or incremental depends on the actual type of the value.\n /// \n /// \n /// The minimum valid value of the range.\n /// \n /// \n /// The maximum valid value of the range.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeInRange(T minimumValue, T maximumValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.CompareTo(minimumValue) >= Equal && Subject.CompareTo(maximumValue) <= Equal)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be between {0} and {1}{reason}, but found {2}.\",\n minimumValue, maximumValue, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is not within a range.\n /// \n /// \n /// Where the range is continuous or incremental depends on the actual type of the value.\n /// \n /// \n /// The minimum valid value of the range.\n /// \n /// \n /// The maximum valid value of the range.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeInRange(T minimumValue, T maximumValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!(Subject.CompareTo(minimumValue) >= Equal && Subject.CompareTo(maximumValue) <= Equal))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to not be between {0} and {1}{reason}, but found {2}.\",\n minimumValue, maximumValue, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params T[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(validValues.Any(val => Equals(Subject, val)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:object} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"object\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IEquivalencyValidationContext.cs", "using AwesomeAssertions.Equivalency.Tracing;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides information on a particular property or field during an assertion for structural equality of two object graphs.\n/// \npublic interface IEquivalencyValidationContext\n{\n /// \n /// Gets the of the member that returned the current object, or if the current\n /// object represents the root object.\n /// \n INode CurrentNode { get; }\n\n /// \n /// A formatted phrase and the placeholder values explaining why the assertion is needed.\n /// \n public Reason Reason { get; }\n\n /// \n /// Gets an object that can be used by the equivalency algorithm to provide a trace when the\n /// option is used.\n /// \n Tracer Tracer { get; }\n\n IEquivalencyOptions Options { get; }\n\n /// \n /// Determines whether the specified object reference is a cyclic reference to the same object earlier in the\n /// equivalency validation.\n /// \n public bool IsCyclicReference(object expectation);\n\n /// \n /// Creates a context from the current object intended to assert the equivalency of a nested member.\n /// \n IEquivalencyValidationContext AsNestedMember(IMember expectationMember);\n\n /// \n /// Creates a context from the current object intended to assert the equivalency of a collection item identified by .\n /// \n IEquivalencyValidationContext AsCollectionItem(string index);\n\n /// \n /// Creates a context from the current object intended to assert the equivalency of a collection item identified by .\n /// \n IEquivalencyValidationContext AsDictionaryItem(TKey key);\n\n /// \n /// Creates a deep clone of the current context.\n /// \n IEquivalencyValidationContext Clone();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyOptions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Equivalency.Matching;\nusing AwesomeAssertions.Equivalency.Ordering;\nusing AwesomeAssertions.Equivalency.Selection;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents the run-time type-specific behavior of a structural equivalency assertion.\n/// \npublic class EquivalencyOptions\n : SelfReferenceEquivalencyOptions>\n{\n public EquivalencyOptions()\n {\n }\n\n public EquivalencyOptions(IEquivalencyOptions defaults)\n : base(defaults)\n {\n }\n\n /// \n /// Excludes the specified (nested) member from the structural equality check.\n /// \n public EquivalencyOptions Excluding(Expression> expression)\n {\n foreach (var memberPath in expression.GetMemberPaths())\n {\n AddSelectionRule(new ExcludeMemberByPathSelectionRule(memberPath));\n }\n\n return this;\n }\n\n /// \n /// Selects a collection to define exclusions at.\n /// Allows to navigate deeper by using .\n /// \n public NestedExclusionOptionBuilder For(\n Expression>> expression)\n {\n return new NestedExclusionOptionBuilder(\n this, new ExcludeMemberByPathSelectionRule(expression.GetMemberPath()));\n }\n\n /// \n /// Includes the specified member in the equality check.\n /// \n /// \n /// This overrides the default behavior of including all declared members.\n /// \n public EquivalencyOptions Including(Expression> expression)\n {\n foreach (var memberPath in expression.GetMemberPaths())\n {\n AddSelectionRule(new IncludeMemberByPathSelectionRule(memberPath));\n }\n\n return this;\n }\n\n /// \n /// Causes the collection identified by to be compared in the order\n /// in which the items appear in the expectation.\n /// \n public EquivalencyOptions WithStrictOrderingFor(\n Expression> expression)\n {\n string expressionMemberPath = expression.GetMemberPath().ToString();\n OrderingRules.Add(new PathBasedOrderingRule(expressionMemberPath));\n return this;\n }\n\n /// \n /// Causes the collection identified by to be compared ignoring the order\n /// in which the items appear in the expectation.\n /// \n public EquivalencyOptions WithoutStrictOrderingFor(\n Expression> expression)\n {\n string expressionMemberPath = expression.GetMemberPath().ToString();\n\n OrderingRules.Add(new PathBasedOrderingRule(expressionMemberPath)\n {\n Invert = true\n });\n\n return this;\n }\n\n /// \n /// Creates a new set of options based on the current instance which acts on a a collection of the .\n /// \n public EquivalencyOptions> AsCollection()\n {\n return new EquivalencyOptions>(\n new CollectionMemberOptionsDecorator(this));\n }\n\n /// \n /// Maps a (nested) property or field of type to\n /// a (nested) property or field of using lambda expressions.\n /// \n /// A field or property expression indicating the (nested) member to map from.\n /// A field or property expression indicating the (nested) member to map to.\n /// \n /// The members of the subject and the expectation must have the same parent. Also, indexes in collections are ignored.\n /// If the types of the members are different, the usual logic applies depending or not if conversion options were specified.\n /// Fields can be mapped to properties and vice-versa.\n /// \n public EquivalencyOptions WithMapping(\n Expression> expectationMemberPath,\n Expression> subjectMemberPath)\n {\n return WithMapping(\n expectationMemberPath.GetMemberPath().ToString().WithoutSpecificCollectionIndices(),\n subjectMemberPath.GetMemberPath().ToString().WithoutSpecificCollectionIndices());\n }\n\n /// \n /// Maps a (nested) property or field of the expectation to a (nested) property or field of the subject using a path string.\n /// \n /// \n /// A field or property path indicating the (nested) member to map from in the format Parent.Child.Collection[].Member.\n /// \n /// \n /// A field or property path indicating the (nested) member to map to in the format Parent.Child.Collection[].Member.\n /// \n /// \n /// The members of the subject and the expectation must have the same parent. Also, indexes in collections are not allowed\n /// and must be written as \"[]\". If the types of the members are different, the usual logic applies depending or not\n /// if conversion options were specified.\n /// Fields can be mapped to properties and vice-versa.\n /// \n public EquivalencyOptions WithMapping(\n string expectationMemberPath,\n string subjectMemberPath)\n {\n AddMatchingRule(new MappedPathMatchingRule(expectationMemberPath, subjectMemberPath));\n\n return this;\n }\n\n /// \n /// Maps a direct property or field of type to\n /// a direct property or field of using lambda expressions.\n /// \n /// A field or property expression indicating the member to map from.\n /// A field or property expression indicating the member to map to.\n /// \n /// Only direct members of and can be\n /// mapped to each other. Those types can appear anywhere in the object graphs that are being compared.\n /// If the types of the members are different, the usual logic applies depending or not if conversion options were specified.\n /// Fields can be mapped to properties and vice-versa.\n /// \n public EquivalencyOptions WithMapping(\n Expression> expectationMember,\n Expression> subjectMember)\n {\n return WithMapping(\n expectationMember.GetMemberPath().ToString(),\n subjectMember.GetMemberPath().ToString());\n }\n\n /// \n /// Maps a direct property or field of type to\n /// a direct property or field of using member names.\n /// \n /// A field or property name indicating the member to map from.\n /// A field or property name indicating the member to map to.\n /// \n /// Only direct members of and can be\n /// mapped to each other, so no . or [] are allowed.\n /// Those types can appear anywhere in the object graphs that are being compared.\n /// If the types of the members are different, the usual logic applies depending or not if conversion options were specified.\n /// Fields can be mapped to properties and vice-versa.\n /// \n public EquivalencyOptions WithMapping(\n string expectationMemberName,\n string subjectMemberName)\n {\n AddMatchingRule(new MappedMemberMatchingRule(\n expectationMemberName,\n subjectMemberName));\n\n return this;\n }\n}\n\n/// \n/// Represents the run-time type-agnostic behavior of a structural equivalency assertion.\n/// \npublic class EquivalencyOptions : SelfReferenceEquivalencyOptions\n{\n public EquivalencyOptions()\n {\n IncludingNestedObjects();\n\n IncludingFields();\n IncludingProperties();\n\n PreferringDeclaredMemberTypes();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EquivalencyValidationContextExtensions.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\ninternal static class EquivalencyValidationContextExtensions\n{\n public static IEquivalencyValidationContext AsCollectionItem(this IEquivalencyValidationContext context,\n int index) =>\n context.AsCollectionItem(index.ToString(CultureInfo.InvariantCulture));\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Matching/MustMatchByNameRule.cs", "using System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Matching;\n\n/// \n/// Requires the subject to have a member with the exact same name as the expectation has.\n/// \ninternal class MustMatchByNameRule : IMemberMatchingRule\n{\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain)\n {\n IMember subjectMember = null;\n\n if (options.IncludedProperties != MemberVisibility.None)\n {\n PropertyInfo propertyInfo = subject.GetType().FindProperty(\n expectedMember.Subject.Name,\n options.IncludedProperties | MemberVisibility.ExplicitlyImplemented | MemberVisibility.DefaultInterfaceProperties);\n\n subjectMember = propertyInfo is not null && !propertyInfo.IsIndexer() ? new Property(propertyInfo, parent) : null;\n }\n\n if (subjectMember is null && options.IncludedFields != MemberVisibility.None)\n {\n FieldInfo fieldInfo = subject.GetType().FindField(\n expectedMember.Subject.Name,\n options.IncludedFields);\n\n subjectMember = fieldInfo is not null ? new Field(fieldInfo, parent) : null;\n }\n\n if (subjectMember is null)\n {\n assertionChain.FailWith(\n $\"Expectation has {expectedMember.Expectation} that the other object does not have.\");\n }\n else if (options.IgnoreNonBrowsableOnSubject && !subjectMember.IsBrowsable)\n {\n assertionChain.FailWith(\n $\"Expectation has {expectedMember.Expectation} that is non-browsable in the other object, and non-browsable \" +\n \"members on the subject are ignored with the current configuration\");\n }\n else\n {\n // Everything is fine\n }\n\n return subjectMember;\n }\n\n /// \n /// 2\n public override string ToString()\n {\n return \"Match member by name (or throw)\";\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringComparisonSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Specs.CultureAwareTesting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n[Collection(nameof(StringComparisonSpecs))]\npublic class StringComparisonSpecs\n{\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_the_Turkish_letter_i_it_should_differ_by_dottedness(string subject, string expected)\n {\n // Act\n bool ordinal = string.Equals(subject, expected, StringComparison.OrdinalIgnoreCase);\n#pragma warning disable CA1309 // Verifies that test data behaves differently in current vs invariant culture\n bool currentCulture = string.Equals(subject, expected, StringComparison.CurrentCultureIgnoreCase);\n#pragma warning restore CA1309\n\n // Assert\n ordinal.Should().NotBe(currentCulture, \"Turkish distinguishes between a dotted and a non-dotted 'i'\");\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_the_same_digit_from_different_cultures_they_should_be_equal(string subject, string expected)\n {\n // Act\n bool ordinal = string.Equals(subject, expected, StringComparison.Ordinal);\n#pragma warning disable CA1309 // Verifies that test data behaves differently in current vs invariant culture\n bool currentCulture = string.Equals(subject, expected, StringComparison.CurrentCulture);\n#pragma warning restore CA1309\n\n // Assert\n ordinal.Should().NotBe(currentCulture,\n \"These two symbols happened to be culturewise identical on both ICU (net5.0, linux, macOS) and NLS (netfx and netcoreapp on windows)\");\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_equivalency_it_should_ignore_culture(string subject, string expected)\n {\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_equality_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_having_prefix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().StartWith(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_having_prefix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotStartWith(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_having_equivalent_prefix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().StartWithEquivalentOf(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_not_having_equivalent_prefix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotStartWithEquivalentOf(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_having_suffix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().EndWith(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_having_suffix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotEndWith(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_having_equivalent_suffix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().EndWithEquivalentOf(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_not_having_equivalent_suffix_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotEndWithEquivalentOf(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_containing_equivalent_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().ContainEquivalentOf(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_not_containing_equivalent_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotContainEquivalentOf(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_containing_equal_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().Contain(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_containing_all_equals_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().ContainAll(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_containing_any_equals_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().ContainAny(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_containing_one_equal_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().Contain(expected, Exactly.Once());\n\n // Assert\n act.Should().Throw();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void When_comparing_strings_for_containing_one_equivalent_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().ContainEquivalentOf(expected, Exactly.Once());\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_containing_equal_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotContain(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_containing_all_equals_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotContainAll(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EqualityData))]\n public void When_comparing_strings_for_not_containing_any_equals_it_should_ignore_culture(string subject, string expected)\n {\n // Act\n Action act = () => subject.Should().NotContainAny(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [CulturedFact(\"tr-TR\")]\n public void When_formatting_reason_arguments_it_should_ignore_culture()\n {\n // Act\n Action act = () => 1.Should().Be(2, \"{0}\", 1.234);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*1.234*\", \"it should always use . as decimal separator\");\n }\n\n [CulturedFact(\"tr-TR\")]\n public void When_stringifying_an_object_it_should_ignore_culture()\n {\n // Arrange\n var obj = new ObjectReference(1.234, string.Empty);\n\n // Act\n var str = obj.ToString();\n\n // Assert\n str.Should().Match(\"*1.234*\", \"it should always use . as decimal separator\");\n }\n\n [CulturedFact(\"tr-TR\")]\n public void When_stringifying_a_validation_context_it_should_ignore_culture()\n {\n // Arrange\n var comparands = new Comparands\n {\n Subject = 1.234,\n Expectation = 5.678\n };\n\n // Act\n var str = comparands.ToString();\n\n // Assert\n str.Should().Match(\"*1.234*5.678*\", \"it should always use . as decimal separator\");\n }\n\n [CulturedFact(\"tr-TR\")]\n public void When_formatting_the_context_it_should_ignore_culture()\n {\n // Arrange\n var context = new Dictionary\n {\n [\"FOO\"] = 1.234\n };\n\n var strategy = new CollectingAssertionStrategy();\n strategy.HandleFailure(string.Empty);\n\n // Act\n Action act = () => strategy.ThrowIfAny(context);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*1.234*\", \"it should always use . as decimal separator\");\n }\n\n [CulturedTheory(\"tr-TR\")]\n [MemberData(nameof(EquivalencyData))]\n public void Matching_strings_for_equivalence_ignores_the_culture(string subject, string expected)\n {\n // Assert\n subject.Should().MatchEquivalentOf(expected);\n }\n\n [CulturedFact(\"en-US\")]\n public void Culture_is_ignored_when_sorting_strings()\n {\n using var _ = new AssertionScope();\n\n new[] { \"A\", \"a\" }.Should().BeInAscendingOrder()\n .And.BeInAscendingOrder(e => e)\n .And.ThenBeInAscendingOrder(e => e)\n .And.NotBeInDescendingOrder()\n .And.NotBeInDescendingOrder(e => e);\n\n new[] { \"a\", \"A\" }.Should().BeInDescendingOrder()\n .And.BeInDescendingOrder(e => e)\n .And.ThenBeInDescendingOrder(e => e)\n .And.NotBeInAscendingOrder()\n .And.NotBeInAscendingOrder(e => e);\n }\n\n private const string LowerCaseI = \"i\";\n private const string UpperCaseI = \"I\";\n\n public static TheoryData EquivalencyData => new()\n {\n { LowerCaseI, UpperCaseI }\n };\n\n private const string SinhalaLithDigitEight = \"෮\";\n private const string MyanmarTaiLaingDigitEight = \"꧸\";\n\n public static TheoryData EqualityData => new()\n {\n { SinhalaLithDigitEight, MyanmarTaiLaingDigitEight }\n };\n}\n\n// Due to CulturedTheory changing CultureInfo\n[CollectionDefinition(nameof(StringComparisonSpecs), DisableParallelization = true)]\npublic class StringComparisonDefinition;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Matching/TryMatchByNameRule.cs", "using System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Matching;\n\n/// \n/// Finds a member of the expectation with the exact same name, but doesn't require it.\n/// \ninternal class TryMatchByNameRule : IMemberMatchingRule\n{\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain)\n {\n if (options.IncludedProperties != MemberVisibility.None)\n {\n PropertyInfo property = subject.GetType().FindProperty(expectedMember.Expectation.Name,\n options.IncludedProperties | MemberVisibility.ExplicitlyImplemented);\n\n if (property is not null && !property.IsIndexer())\n {\n return new Property(property, parent);\n }\n }\n\n FieldInfo field = subject.GetType()\n .FindField(expectedMember.Expectation.Name, options.IncludedFields);\n\n return field is not null ? new Field(field, parent) : null;\n }\n\n /// \n /// 2\n public override string ToString()\n {\n return \"Try to match member by name\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/NestedExclusionOptionBuilder.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Selection;\n\nnamespace AwesomeAssertions.Equivalency;\n\npublic class NestedExclusionOptionBuilder\n{\n /// \n /// The selected path starting at the first .\n /// \n private readonly ExcludeMemberByPathSelectionRule currentPathSelectionRule;\n\n private readonly EquivalencyOptions capturedOptions;\n\n internal NestedExclusionOptionBuilder(EquivalencyOptions capturedOptions,\n ExcludeMemberByPathSelectionRule currentPathSelectionRule)\n {\n this.capturedOptions = capturedOptions;\n this.currentPathSelectionRule = currentPathSelectionRule;\n }\n\n /// \n /// Selects a nested property to exclude. This ends the chain.\n /// \n public EquivalencyOptions Exclude(Expression> expression)\n {\n var currentSelectionPath = currentPathSelectionRule.CurrentPath;\n\n foreach (var path in expression.GetMemberPaths())\n {\n var newPath = currentSelectionPath.AsParentCollectionOf(path);\n capturedOptions.AddSelectionRule(new ExcludeMemberByPathSelectionRule(newPath));\n }\n\n return capturedOptions;\n }\n\n /// \n /// Adds the selected collection to the chain.\n /// \n public NestedExclusionOptionBuilder For(\n Expression>> expression)\n {\n var nextPath = expression.GetMemberPath();\n currentPathSelectionRule.AppendPath(nextPath);\n return new NestedExclusionOptionBuilder(capturedOptions, currentPathSelectionRule);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/ObjectAssertionsExtensions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.IO;\nusing System.Runtime.Serialization;\nusing System.Xml.Serialization;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions;\n\npublic static class ObjectAssertionsExtensions\n{\n /// \n /// Asserts that an object can be serialized and deserialized using the data contract serializer and that it stills retains\n /// the values of all members.\n /// \n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint BeDataContractSerializable(this ObjectAssertions assertions,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeDataContractSerializable(assertions, options => options, because, becauseArgs);\n }\n\n /// \n /// Asserts that an object can be serialized and deserialized using the data contract serializer and that it stills retains\n /// the values of all members.\n /// \n /// \n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public static AndConstraint BeDataContractSerializable(this ObjectAssertions assertions,\n Func, EquivalencyOptions> options,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(options);\n\n try\n {\n var deserializedObject = CreateCloneUsingDataContractSerializer(assertions.Subject);\n\n EquivalencyOptions defaultOptions = AssertionConfiguration.Current.Equivalency.CloneDefaults()\n .PreferringRuntimeMemberTypes().IncludingFields().IncludingProperties();\n\n ((T)deserializedObject).Should().BeEquivalentTo((T)assertions.Subject, _ => options(defaultOptions));\n }\n catch (Exception exc)\n {\n assertions.CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0} to be serializable{reason}, but serialization failed with:\"\n + Environment.NewLine + Environment.NewLine + \"{1}.\",\n assertions.Subject,\n exc.Message);\n }\n\n return new AndConstraint(assertions);\n }\n\n private static object CreateCloneUsingDataContractSerializer(object subject)\n {\n using var stream = new MemoryStream();\n var serializer = new DataContractSerializer(subject.GetType());\n serializer.WriteObject(stream, subject);\n stream.Position = 0;\n return serializer.ReadObject(stream);\n }\n\n /// \n /// Asserts that an object can be serialized and deserialized using the XML serializer and that it stills retains\n /// the values of all members.\n /// \n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint BeXmlSerializable(this ObjectAssertions assertions,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n try\n {\n object deserializedObject = CreateCloneUsingXmlSerializer(assertions.Subject);\n\n deserializedObject.Should().BeEquivalentTo(assertions.Subject,\n options => options.PreferringRuntimeMemberTypes().IncludingFields().IncludingProperties());\n }\n catch (Exception exc)\n {\n assertions.CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0} to be serializable{reason}, but serialization failed with:\"\n + Environment.NewLine + Environment.NewLine + \"{1}.\",\n assertions.Subject,\n exc.Message);\n }\n\n return new AndConstraint(assertions);\n }\n\n private static object CreateCloneUsingXmlSerializer(object subject)\n {\n using var stream = new MemoryStream();\n var serializer = new XmlSerializer(subject.GetType());\n serializer.Serialize(stream, subject);\n\n stream.Position = 0;\n return serializer.Deserialize(stream);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Execution/ObjectInfo.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency.Execution;\n\ninternal class ObjectInfo : IObjectInfo\n{\n public ObjectInfo(Comparands comparands, INode currentNode)\n {\n Type = currentNode.Type;\n ParentType = currentNode.ParentType;\n Path = currentNode.Expectation.PathAndName;\n CompileTimeType = comparands.CompileTimeType;\n RuntimeType = comparands.RuntimeType;\n }\n\n public Type Type { get; }\n\n public Type ParentType { get; }\n\n public string Path { get; set; }\n\n public Type CompileTimeType { get; }\n\n public Type RuntimeType { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.cs", "using System;\nusing AwesomeAssertions.Equivalency.Matching;\nusing AwesomeAssertions.Equivalency.Ordering;\nusing AwesomeAssertions.Equivalency.Selection;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n [Fact]\n public void Public_methods_follow_fluent_syntax()\n {\n // Arrange\n var subject = new Root();\n var expected = new RootDto();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .AllowingInfiniteRecursion()\n .ComparingByMembers(typeof(Root))\n .ComparingByMembers()\n .ComparingByValue(typeof(Customer))\n .ComparingByValue()\n .ComparingEnumsByName()\n .ComparingEnumsByValue()\n .ComparingRecordsByMembers()\n .ComparingRecordsByValue()\n .Excluding(r => r.Level)\n .ExcludingFields()\n .ExcludingMissingMembers()\n .WithoutRecursing()\n .ExcludingNonBrowsableMembers()\n .ExcludingProperties()\n .IgnoringCyclicReferences()\n .IgnoringNonBrowsableMembersOnSubject()\n .Including(r => r.Level)\n .IncludingAllDeclaredProperties()\n .IncludingAllRuntimeProperties()\n .IncludingFields()\n .IncludingInternalFields()\n .IncludingInternalProperties()\n .IncludingNestedObjects()\n .IncludingProperties()\n .PreferringDeclaredMemberTypes()\n .PreferringRuntimeMemberTypes()\n .ThrowingOnMissingMembers()\n .Using(new ExtensibilitySpecs.DoEquivalencyStep(() => { }))\n .Using(new MustMatchByNameRule())\n .Using(new AllFieldsSelectionRule())\n .Using(new ByteArrayOrderingRule())\n .Using(StringComparer.OrdinalIgnoreCase)\n .WithAutoConversion()\n .WithAutoConversionFor(_ => false)\n .WithoutAutoConversionFor(_ => true)\n .WithoutMatchingRules()\n .WithoutSelectionRules()\n .WithoutStrictOrdering()\n .WithoutStrictOrderingFor(r => r.Level)\n .WithStrictOrdering()\n .WithStrictOrderingFor(r => r.Level)\n .WithTracing()\n );\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Matching/MappedPathMatchingRule.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Matching;\n\n/// \n/// Allows mapping a member (property or field) of the expectation to a differently named member\n/// of the subject-under-test using a nested member path in the form of \"Parent.NestedCollection[].Member\"\n/// \ninternal class MappedPathMatchingRule : IMemberMatchingRule\n{\n private readonly MemberPath expectationPath;\n private readonly MemberPath subjectPath;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// is .\n /// is empty.\n /// is .\n /// is empty.\n public MappedPathMatchingRule(string expectationMemberPath, string subjectMemberPath)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(expectationMemberPath,\n nameof(expectationMemberPath), \"A member path cannot be null\");\n\n Guard.ThrowIfArgumentIsNullOrEmpty(subjectMemberPath,\n nameof(subjectMemberPath), \"A member path cannot be null\");\n\n expectationPath = new MemberPath(expectationMemberPath);\n subjectPath = new MemberPath(subjectMemberPath);\n\n if (expectationPath.GetContainsSpecificCollectionIndex() || subjectPath.GetContainsSpecificCollectionIndex())\n {\n throw new ArgumentException(\n \"Mapping properties containing a collection index must use the [] format without specific index.\");\n }\n\n if (!expectationPath.HasSameParentAs(subjectPath))\n {\n throw new ArgumentException(\"The member paths must have the same parent.\");\n }\n }\n\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain)\n {\n MemberPath path = expectationPath;\n\n if (expectedMember.RootIsCollection)\n {\n path = path.WithCollectionAsRoot();\n }\n\n if (path.IsEquivalentTo(expectedMember.Expectation.PathAndName))\n {\n var member = MemberFactory.Find(subject, subjectPath.MemberName, parent);\n\n if (member is null)\n {\n throw new MissingMemberException(\n $\"Subject of type {subject?.GetType().Name} does not have member {subjectPath.MemberName}\");\n }\n\n return member;\n }\n\n return null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EquivalencyResult.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic enum EquivalencyResult\n{\n ContinueWithNext,\n EquivalencyProven\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IEquivalencyOptions.cs", "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing AwesomeAssertions.Equivalency.Tracing;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides the run-time details of the class.\n/// \npublic interface IEquivalencyOptions\n{\n /// \n /// Gets an ordered collection of selection rules that define what members (e.g. properties or fields) are included.\n /// \n IEnumerable SelectionRules { get; }\n\n /// \n /// Gets an ordered collection of matching rules that determine which subject members are matched with which\n /// expectation properties.\n /// \n IEnumerable MatchingRules { get; }\n\n /// \n /// Gets a value indicating whether or not the assertion must perform a deep comparison.\n /// \n bool IsRecursive { get; }\n\n /// \n /// Gets a value indicating whether recursion is allowed to continue indefinitely.\n /// \n bool AllowInfiniteRecursion { get; }\n\n /// \n /// Gets value indicating how cyclic references should be handled. By default, it will throw an exception.\n /// \n CyclicReferenceHandling CyclicReferenceHandling { get; }\n\n /// \n /// Gets an ordered collection of rules that determine whether or not the order of collections is important. By default,\n /// ordering is irrelevant.\n /// \n OrderingRuleCollection OrderingRules { get; }\n\n /// \n /// Contains the rules for what properties to run an auto-conversion.\n /// \n ConversionSelector ConversionSelector { get; }\n\n /// \n /// Gets value indicating how the enums should be compared.\n /// \n EnumEquivalencyHandling EnumEquivalencyHandling { get; }\n\n /// \n /// Gets an ordered collection of Equivalency steps how a subject is compared with the expectation.\n /// \n IEnumerable UserEquivalencySteps { get; }\n\n /// \n /// Gets a value indicating whether the runtime type of the expectation should be used rather than the declared type.\n /// \n bool UseRuntimeTyping { get; }\n\n /// \n /// Gets a value indicating whether and which properties should be considered.\n /// \n MemberVisibility IncludedProperties { get; }\n\n /// \n /// Gets a value indicating whether and which fields should be considered.\n /// \n MemberVisibility IncludedFields { get; }\n\n /// \n /// Gets a value indicating whether members on the subject marked with []\n /// and should be treated as though they don't exist.\n /// \n bool IgnoreNonBrowsableOnSubject { get; }\n\n /// \n /// Gets a value indicating whether members on the expectation marked with []\n /// and should be excluded.\n /// \n bool ExcludeNonBrowsableOnExpectation { get; }\n\n /// \n /// Gets a value indicating whether records should be compared by value instead of their members\n /// \n bool? CompareRecordsByValue { get; }\n\n /// \n /// Gets the currently configured tracer, or if no tracing was configured.\n /// \n ITraceWriter TraceWriter { get; }\n\n /// \n /// Determines the right strategy for evaluating the equality of objects of this type.\n /// \n EqualityStrategy GetEqualityStrategy(Type type);\n\n /// \n /// Gets a value indicating whether leading whitespace is ignored when comparing s.\n /// \n bool IgnoreLeadingWhitespace { get; }\n\n /// \n /// Gets a value indicating whether trailing whitespace is ignored when comparing s.\n /// \n bool IgnoreTrailingWhitespace { get; }\n\n /// \n /// Gets a value indicating whether a case-insensitive comparer is used when comparing s.\n /// \n bool IgnoreCase { get; }\n\n /// \n /// Gets a value indicating whether the newline style is ignored when comparing s.\n /// \n /// \n /// Enabling this option will replace all occurrences of \\r\\n and \\r with \\n in the strings before comparing them.\n /// \n bool IgnoreNewlineStyle { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Matching/MappedMemberMatchingRule.cs", "using System;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Matching;\n\n/// \n/// Allows mapping a member (property or field) of the expectation to a differently named member\n/// of the subject-under-test using a member name and the target type.\n/// \ninternal class MappedMemberMatchingRule : IMemberMatchingRule\n{\n private readonly string expectationMemberName;\n private readonly string subjectMemberName;\n\n public MappedMemberMatchingRule(string expectationMemberName, string subjectMemberName)\n {\n if (Regex.IsMatch(expectationMemberName, @\"[\\.\\[\\]]\"))\n {\n throw new ArgumentException(\"The expectation's member name cannot be a nested path\", nameof(expectationMemberName));\n }\n\n if (Regex.IsMatch(subjectMemberName, @\"[\\.\\[\\]]\"))\n {\n throw new ArgumentException(\"The subject's member name cannot be a nested path\", nameof(subjectMemberName));\n }\n\n this.expectationMemberName = expectationMemberName;\n this.subjectMemberName = subjectMemberName;\n }\n\n public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain)\n {\n if (parent.Type.IsSameOrInherits(typeof(TExpectation)) && subject is TSubject &&\n expectedMember.Subject.Name == expectationMemberName)\n {\n var member = MemberFactory.Find(subject, subjectMemberName, parent);\n\n return member ?? throw new MissingMemberException(\n $\"Subject of type {typeof(TSubject).ToFormattedString()} does not have member {subjectMemberName}\");\n }\n\n return null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/EnumerableEquivalencyValidatorExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\ninternal static class EnumerableEquivalencyValidatorExtensions\n{\n public static Continuation AssertEitherCollectionIsNotEmpty(this AssertionChain assertionChain,\n ICollection subject,\n ICollection expectation)\n {\n return assertionChain\n .WithExpectation(\"Expected {context:subject} to be a collection with {0} item(s){reason}\", expectation.Count,\n chain => chain\n .ForCondition(subject.Count > 0 || expectation.Count == 0)\n .FailWith(\", but found an empty collection.\")\n .Then\n .ForCondition(subject.Count == 0 || expectation.Count > 0)\n .FailWith($\", but {{0}}{Environment.NewLine}contains {{1}} item(s).\",\n subject,\n subject.Count));\n }\n\n public static Continuation AssertCollectionHasEnoughItems(this AssertionChain assertionChain, ICollection subject,\n ICollection expectation)\n {\n return assertionChain\n .WithExpectation(\"Expected {context:subject} to be a collection with {0} item(s){reason}\", expectation.Count,\n chain => chain\n .ForCondition(subject.Count >= expectation.Count)\n .FailWith($\", but {{0}}{Environment.NewLine}contains {{1}} item(s) less than{Environment.NewLine}{{2}}.\",\n subject,\n expectation.Count - subject.Count,\n expectation));\n }\n\n public static Continuation AssertCollectionHasNotTooManyItems(this AssertionChain assertionChain,\n ICollection subject,\n ICollection expectation)\n {\n return assertionChain\n .WithExpectation(\"Expected {context:subject} to be a collection with {0} item(s){reason}\", expectation.Count,\n chain => chain\n .ForCondition(subject.Count <= expectation.Count)\n .FailWith($\", but {{0}}{Environment.NewLine}contains {{1}} item(s) more than{Environment.NewLine}{{2}}.\",\n subject,\n subject.Count - expectation.Count,\n expectation));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class StringAssertions : StringAssertions\n{\n /// \n /// Initializes a new instance of the class.\n /// \n public StringAssertions(string value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class StringAssertions : ReferenceTypeAssertions\n where TAssertions : StringAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public StringAssertions(string value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a string is exactly the same as another string, including the casing and any leading or trailing whitespace.\n /// \n /// The expected string.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var stringEqualityValidator = new StringValidator(assertionChain,\n new StringEqualityStrategy(StringComparer.Ordinal, \"be\"),\n because, becauseArgs);\n\n stringEqualityValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params string[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is exactly the same as another string, including any leading or trailing whitespace, with\n /// the exception of the casing.\n /// \n /// \n /// The string that the subject is expected to be equivalent to.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var expectation = new StringValidator(assertionChain,\n new StringEqualityStrategy(StringComparer.OrdinalIgnoreCase, \"be equivalent to\"),\n because, becauseArgs);\n\n expectation.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is exactly the same as another string, using the provided .\n /// \n /// \n /// The string that the subject is expected to be equivalent to.\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var expectation = new StringValidator(assertionChain,\n new StringEqualityStrategy(options.GetStringComparerOrDefault(), \"be equivalent to\"),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n expectation.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is not exactly the same as another string, including any leading or trailing whitespace, with\n /// the exception of the casing.\n /// \n /// \n /// The string that the subject is not expected to be equivalent to.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n BeEquivalentTo(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be equivalent to {0}{reason}, but they are.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is not exactly the same as another string, using the provided .\n /// \n /// \n /// The string that the subject is not expected to be equivalent to.\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(string unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().BeEquivalentTo(unexpected, config);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be equivalent to {0}{reason}, but they are.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n#if NET8_0_OR_GREATER\n\n /// \n /// Asserts that a string is parsable into something else, which is implementing .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The type to what the should parsed to.\n public AndWhichConstraint BeParsableInto(string because = \"\", params object[] becauseArgs)\n where T : IParsable\n {\n return BeParsableInto(null, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string is parsable into something else, which is implementing ,\n /// with additionally respecting an , e.g. a different .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The type to what the should parsed to.\n public AndWhichConstraint BeParsableInto(IFormatProvider formatProvider, string because = \"\",\n params object[] becauseArgs)\n where T : IParsable\n {\n T parsed = default;\n var canBeParsed = true;\n string exceptionMessage = null;\n\n try\n {\n parsed = T.Parse(Subject, formatProvider);\n }\n catch (Exception ex)\n {\n canBeParsed = false;\n exceptionMessage = ex.Message.FirstCharToLower();\n }\n\n CurrentAssertionChain\n .WithExpectation(\"Expected {context:the subject} with value {0} to be parsable into {1}{reason}, \",\n Subject, typeof(T),\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(canBeParsed)\n .FailWith($\"but it could not, because {exceptionMessage}\"));\n\n return new AndWhichConstraint((TAssertions)this, parsed);\n }\n\n /// \n /// Asserts that a string isn't parsable into something else, which is implementing .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The type to what the should parsed to.\n public AndConstraint NotBeParsableInto(string because = \"\", params object[] becauseArgs)\n where T : IParsable\n {\n return NotBeParsableInto(null, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string isn't parsable into something else, which is implementing ,\n /// with additionally respecting an , e.g. a different .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The type to what the should parsed to.\n public AndConstraint NotBeParsableInto(IFormatProvider formatProvider, string because = \"\",\n params object[] becauseArgs)\n where T : IParsable\n {\n CurrentAssertionChain\n .WithExpectation(\"Expected {context:the subject} with value {0} to be not parsable into {1}{reason}, \",\n Subject, typeof(T),\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!T.TryParse(Subject, formatProvider, out _))\n .FailWith(\"but it could.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n#endif\n\n /// \n /// Asserts that a string is not exactly the same as the specified ,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is not expected to be equivalent to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint Match(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the BeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.\");\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy(),\n because, becauseArgs);\n\n stringWildcardMatchingValidator.Validate(Subject, wildcardPattern);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not match the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination literal text and wildcard of\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint NotMatch(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.\");\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n Negate = true\n },\n because, becauseArgs);\n\n stringWildcardMatchingValidator.Validate(Subject, wildcardPattern);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint MatchEquivalentOf(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the BeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.\");\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n IgnoreCase = true,\n IgnoreAllNewlines = true\n },\n because, becauseArgs);\n\n stringWildcardMatchingValidator.Validate(Subject, wildcardPattern);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches the , using the provided .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint MatchEquivalentOf(string wildcardPattern,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the BeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.\");\n\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n IgnoreCase = options.IgnoreCase,\n IgnoreNewlineStyle = options.IgnoreNewlineStyle,\n },\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n wildcardPattern = ApplyStringSettings(wildcardPattern, options);\n\n stringWildcardMatchingValidator.Validate(subject, wildcardPattern);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not match the .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint NotMatchEquivalentOf(string wildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.\");\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n IgnoreCase = true,\n IgnoreAllNewlines = true,\n Negate = true\n },\n because, becauseArgs);\n\n stringWildcardMatchingValidator.Validate(Subject, wildcardPattern);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not match the , using the provided .\n /// \n /// \n /// The pattern to match against the subject. This parameter can contain a combination of literal text and wildcard\n /// (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n /// is .\n /// is empty.\n public AndConstraint NotMatchEquivalentOf(string wildcardPattern,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.\");\n\n Guard.ThrowIfArgumentIsEmpty(wildcardPattern, nameof(wildcardPattern),\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.\");\n\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringWildcardMatchingValidator = new StringValidator(assertionChain,\n new StringWildcardMatchingStrategy\n {\n IgnoreCase = options.IgnoreCase,\n IgnoreNewlineStyle = options.IgnoreNewlineStyle,\n Negate = true\n },\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n wildcardPattern = ApplyStringSettings(wildcardPattern, options);\n\n stringWildcardMatchingValidator.Validate(subject, wildcardPattern);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches a regular expression with expected occurrence\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A constraint specifying the expected amount of times a regex should match a string.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint MatchRegex([RegexPattern][StringSyntax(\"Regex\")] string regularExpression,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the BeNull method.\");\n\n Regex regex;\n\n try\n {\n regex = new Regex(regularExpression);\n }\n catch (ArgumentException)\n {\n assertionChain.FailWith(\"Cannot match {context:string} against {0} because it is not a valid regular expression.\",\n regularExpression);\n\n return new AndConstraint((TAssertions)this);\n }\n\n return MatchRegex(regex, occurrenceConstraint, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string matches a regular expression.\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint MatchRegex([RegexPattern][StringSyntax(\"Regex\")] string regularExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the BeNull method.\");\n\n Regex regex;\n\n try\n {\n regex = new Regex(regularExpression);\n }\n catch (ArgumentException)\n {\n assertionChain.FailWith(\"Cannot match {context:string} against {0} because it is not a valid regular expression.\",\n regularExpression);\n\n return new AndConstraint((TAssertions)this);\n }\n\n return MatchRegex(regex, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string matches a regular expression with expected occurrence\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A constraint specifying the expected amount of times a regex should match a string.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint MatchRegex(Regex regularExpression,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the BeNull method.\");\n\n var regexStr = regularExpression.ToString();\n\n Guard.ThrowIfArgumentIsEmpty(regexStr, nameof(regularExpression),\n \"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .UsingLineBreaks\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to match regex {0}{reason}, but it was .\", regexStr);\n\n if (assertionChain.Succeeded)\n {\n int actual = regularExpression.Matches(Subject!).Count;\n\n assertionChain\n .ForConstraint(occurrenceConstraint, actual)\n .UsingLineBreaks\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} {0} to match regex {1} {expectedOccurrence}{reason}, \" +\n $\"but found it {actual.Times()}.\",\n Subject, regexStr);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string matches a regular expression.\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint MatchRegex(Regex regularExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the BeNull method.\");\n\n var regexStr = regularExpression.ToString();\n\n Guard.ThrowIfArgumentIsEmpty(regexStr, nameof(regularExpression),\n \"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .UsingLineBreaks\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to match regex {0}{reason}, but it was .\", regexStr);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(regularExpression.IsMatch(Subject!))\n .BecauseOf(because, becauseArgs)\n .UsingLineBreaks\n .FailWith(\"Expected {context:string} to match regex {0}{reason}, but {1} does not match.\", regexStr, Subject);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not match a regular expression.\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotMatchRegex([RegexPattern][StringSyntax(\"Regex\")] string regularExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the NotBeNull method.\");\n\n Regex regex;\n\n try\n {\n regex = new Regex(regularExpression);\n }\n catch (ArgumentException)\n {\n assertionChain.FailWith(\"Cannot match {context:string} against {0} because it is not a valid regular expression.\",\n regularExpression);\n\n return new AndConstraint((TAssertions)this);\n }\n\n return NotMatchRegex(regex, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string does not match a regular expression.\n /// \n /// \n /// The regular expression with which the subject is matched.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotMatchRegex(Regex regularExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(regularExpression, nameof(regularExpression),\n \"Cannot match string against . Provide a regex pattern or use the NotBeNull method.\");\n\n var regexStr = regularExpression.ToString();\n\n Guard.ThrowIfArgumentIsEmpty(regexStr, nameof(regularExpression),\n \"Cannot match string against an empty regex pattern. Provide a regex pattern or use the NotBeEmpty method.\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .UsingLineBreaks\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to not match regex {0}{reason}, but it was .\", regexStr);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(!regularExpression.IsMatch(Subject!))\n .BecauseOf(because, becauseArgs)\n .UsingLineBreaks\n .FailWith(\"Did not expect {context:string} to match regex {0}{reason}, but {1} matches.\", regexStr, Subject);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string starts exactly with the specified value,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is expected to start with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWith(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare start of string with .\");\n\n var stringStartValidator = new StringValidator(assertionChain,\n new StringStartStrategy(StringComparer.Ordinal, \"start with\"),\n because, becauseArgs);\n\n stringStartValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not start with the specified value,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is not expected to start with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotStartWith(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare start of string with .\");\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().StartWith(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to start with {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string starts with the specified ,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is expected to start with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWithEquivalentOf(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string start equivalence with .\");\n\n var stringStartValidator = new StringValidator(assertionChain,\n new StringStartStrategy(StringComparer.OrdinalIgnoreCase, \"start with equivalent of\"),\n because, becauseArgs);\n\n stringStartValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string starts with the specified , using the provided .\n /// \n /// The string that the subject is expected to start with.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWithEquivalentOf(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string start equivalence with .\");\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringStartValidator = new StringValidator(assertionChain,\n new StringStartStrategy(options.GetStringComparerOrDefault(), \"start with equivalent of\"),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n stringStartValidator.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not start with the specified value,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is not expected to start with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotStartWithEquivalentOf(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare start of string with .\");\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().StartWithEquivalentOf(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to start with equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not start with the specified value, using the provided .\n /// \n /// The string that the subject is not expected to start with.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotStartWithEquivalentOf(string unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare start of string with .\");\n Guard.ThrowIfArgumentIsNull(config);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().StartWithEquivalentOf(unexpected, config);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to start with equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string ends exactly with the specified ,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is expected to end with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint EndWith(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string end with .\");\n\n var stringEndValidator = new StringValidator(assertionChain,\n new StringEndStrategy(StringComparer.Ordinal, \"end with\"),\n because, becauseArgs);\n\n stringEndValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not end exactly with the specified ,\n /// including the casing and any leading or trailing whitespace.\n /// \n /// The string that the subject is not expected to end with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEndWith(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare end of string with .\");\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().EndWith(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to end with {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string ends with the specified ,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is expected to end with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint EndWithEquivalentOf(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string end equivalence with .\");\n\n var stringEndValidator = new StringValidator(assertionChain,\n new StringEndStrategy(StringComparer.OrdinalIgnoreCase, \"end with equivalent of\"),\n because, becauseArgs);\n\n stringEndValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string ends with the specified , using the provided .\n /// \n /// The string that the subject is expected to end with.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint EndWithEquivalentOf(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare string end equivalence with .\");\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringEndValidator = new StringValidator(assertionChain,\n new StringEndStrategy(options.GetStringComparerOrDefault(), \"end with equivalent of\"),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n stringEndValidator.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not end with the specified ,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is not expected to end with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEndWithEquivalentOf(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare end of string with .\");\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().EndWithEquivalentOf(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to end with equivalent of {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not end with the specified , using the provided .\n /// \n /// The string that the subject is not expected to end with.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEndWithEquivalentOf(string unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare end of string with .\");\n Guard.ThrowIfArgumentIsNull(config);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().EndWithEquivalentOf(unexpected, config);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(Subject != null && notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to end with equivalent of {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains another (fragment of a) string.\n /// \n /// \n /// The (fragment of a) string that the current string should contain.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint Contain(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n\n assertionChain\n .ForCondition(Contains(Subject, expected, StringComparison.Ordinal))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} {0} to contain {1}{reason}.\", Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains another (fragment of a) string a set amount of times.\n /// \n /// \n /// The (fragment of a) string that the current string should contain.\n /// \n /// \n /// A constraint specifying the amount of times a substring should be present within the test subject.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint Contain(string expected, OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n\n int actual = Subject.CountSubstring(expected, StringComparer.Ordinal);\n\n assertionChain\n .ForConstraint(occurrenceConstraint, actual)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n $\"Expected {{context:string}} {{0}} to contain {{1}} {{expectedOccurrence}}{{reason}}, but found it {actual.Times()}.\",\n Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains the specified ,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is expected to contain.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainEquivalentOf(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n\n var stringContainValidator = new StringValidatorSupportingNull(assertionChain,\n new StringContainsStrategy(StringComparer.OrdinalIgnoreCase, AtLeast.Once()),\n because, becauseArgs);\n\n stringContainValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains the specified , using the provided .\n /// \n /// The string that the subject is expected to contain.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainEquivalentOf(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return ContainEquivalentOf(expected, AtLeast.Once(), config, because, becauseArgs);\n }\n\n /// \n /// Asserts that a string contains the specified , using the provided .\n /// \n /// The string that the subject is expected to contain.\n /// \n /// A constraint specifying the amount of times a substring should be present within the test subject.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainEquivalentOf(string expected,\n OccurrenceConstraint occurrenceConstraint,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n Guard.ThrowIfArgumentIsNull(occurrenceConstraint);\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var stringContainValidator = new StringValidatorSupportingNull(assertionChain,\n new StringContainsStrategy(options.GetStringComparerOrDefault(), occurrenceConstraint),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n stringContainValidator.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains the specified a set amount of times,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// \n /// The (fragment of a) string that the current string should contain.\n /// \n /// \n /// A constraint specifying the amount of times a substring should be present within the test subject.\n /// It can be created by invoking static methods Once, Twice, Thrice, or Times(int)\n /// on the classes , , , , and .\n /// For example, or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainEquivalentOf(string expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(expected, nameof(expected), \"Cannot assert string containment against an empty string.\");\n Guard.ThrowIfArgumentIsNull(occurrenceConstraint);\n\n var stringContainValidator = new StringValidatorSupportingNull(assertionChain,\n new StringContainsStrategy(StringComparer.OrdinalIgnoreCase, occurrenceConstraint),\n because, becauseArgs);\n\n stringContainValidator.Validate(Subject, expected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains all values present in .\n /// \n /// \n /// The values that should all be present in the string\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint ContainAll(IEnumerable values,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ThrowIfValuesNullOrEmpty(values);\n\n IEnumerable missing = values.Where(v => !Contains(Subject, v, StringComparison.Ordinal));\n\n assertionChain\n .ForCondition(values.All(v => Contains(Subject, v, StringComparison.Ordinal)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} {0} to contain the strings: {1}{reason}.\", Subject, missing);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains all values present in .\n /// \n /// \n /// The values that should all be present in the string\n /// \n public AndConstraint ContainAll(params string[] values)\n {\n return ContainAll(values, because: string.Empty);\n }\n\n /// \n /// Asserts that a string contains at least one value present in ,.\n /// \n /// \n /// The values that should will be tested against the string\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint ContainAny(IEnumerable values,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ThrowIfValuesNullOrEmpty(values);\n\n assertionChain\n .ForCondition(values.Any(v => Contains(Subject, v, StringComparison.Ordinal)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} {0} to contain at least one of the strings: {1}{reason}.\", Subject, values);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string contains at least one value present in ,.\n /// \n /// \n /// The values that should will be tested against the string\n /// \n public AndConstraint ContainAny(params string[] values)\n {\n return ContainAny(values, because: string.Empty);\n }\n\n /// \n /// Asserts that a string does not contain another (fragment of a) string.\n /// \n /// \n /// The (fragment of a) string that the current string should not contain.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotContain(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot assert string containment against .\");\n Guard.ThrowIfArgumentIsEmpty(unexpected, nameof(unexpected), \"Cannot assert string containment against an empty string.\");\n\n assertionChain\n .ForCondition(!Contains(Subject, unexpected, StringComparison.Ordinal))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} {0} to contain {1}{reason}.\", Subject, unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not contain all of the strings provided in . The string\n /// may contain some subset of the provided values.\n /// \n /// \n /// The values that should not be present in the string\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainAll(IEnumerable values,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ThrowIfValuesNullOrEmpty(values);\n\n var matches = values.Count(v => Contains(Subject, v, StringComparison.Ordinal));\n\n assertionChain\n .ForCondition(matches != values.Count())\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} {0} to contain all of the strings: {1}{reason}.\", Subject, values);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not contain all of the strings provided in . The string\n /// may contain some subset of the provided values.\n /// \n /// \n /// The values that should not be present in the string\n /// \n public AndConstraint NotContainAll(params string[] values)\n {\n return NotContainAll(values, because: string.Empty);\n }\n\n /// \n /// Asserts that a string does not contain any of the strings provided in .\n /// \n /// \n /// The values that should not be present in the string\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainAny(IEnumerable values,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ThrowIfValuesNullOrEmpty(values);\n\n IEnumerable matches = values.Where(v => Contains(Subject, v, StringComparison.Ordinal));\n\n assertionChain\n .ForCondition(!matches.Any())\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} {0} to contain any of the strings: {1}{reason}.\", Subject, matches);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not contain any of the strings provided in .\n /// \n /// \n /// The values that should not be present in the string\n /// \n public AndConstraint NotContainAny(params string[] values)\n {\n return NotContainAny(values, because: string.Empty);\n }\n\n /// \n /// Asserts that a string does not contain the specified string,\n /// including any leading or trailing whitespace, with the exception of the casing.\n /// \n /// The string that the subject is not expected to contain.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainEquivalentOf(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!string.IsNullOrEmpty(unexpected) && Subject != null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to contain the equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().ContainEquivalentOf(unexpected);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to contain the equivalent of {0}{reason} but found {1}.\", unexpected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string does not contain the specified string, using the provided .\n /// \n /// The string that the subject is not expected to contain.\n /// \n /// The equivalency options.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainEquivalentOf(string unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n assertionChain\n .ForCondition(!string.IsNullOrEmpty(unexpected) && Subject != null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to contain the equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n bool notEquivalent;\n\n using (var scope = new AssertionScope())\n {\n Subject.Should().ContainEquivalentOf(unexpected, config);\n notEquivalent = scope.Discard().Length > 0;\n }\n\n assertionChain\n .ForCondition(notEquivalent)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to contain the equivalent of {0}{reason}, but found {1}.\", unexpected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject?.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to be empty{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is null || Subject.Length > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:string} to be empty{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string has the specified length.\n /// \n /// The expected length of the string\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveLength(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:string} with length {0}{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.Length == expected)\n .FailWith(\"Expected {context:string} with length {0}{reason}, but found string {1} with length {2}.\",\n expected, Subject, Subject.Length);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is neither nor .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNullOrEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!string.IsNullOrEmpty(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be or empty{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is either or .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNullOrEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(string.IsNullOrEmpty(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to be or empty{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is neither nor nor white space\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNullOrWhiteSpace([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!string.IsNullOrWhiteSpace(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} not to be or whitespace{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a string is either or or white space\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNullOrWhiteSpace([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(string.IsNullOrWhiteSpace(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:string} to be or whitespace{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that all cased characters in a string are upper-case. That is, that the string could be the result of a call to\n /// .\n /// \n /// \n /// Numbers, special characters, and many Asian characters don't have casing, so \n /// will ignore these and will fail only in the presence of lower-case characters.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeUpperCased([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null && !Subject.Any(char.IsLower))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected all alphabetic characters in {context:string} to be upper-case{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that of all the cased characters in a string, some are not upper-case. That is, the string could not be\n /// the result of a call to .\n /// \n /// \n /// Numbers, special characters, and many Asian characters don't have casing, so \n /// will ignore these and will fail only if the string contains cased characters and they are all upper-case.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeUpperCased([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is null || HasMixedOrNoCase(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected some characters in {context:string} to be lower-case{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that all cased characters in a string are lower-case. That is, that the string could be the result of a call to\n /// ,\n /// \n /// \n /// Numbers, special characters, and many Asian characters don't have casing, so \n /// will ignore these and will fail only in the presence of upper-case characters.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLowerCased([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null && !Subject.Any(char.IsUpper))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected all alphabetic characters in {context:string} to be lower cased{reason}, but found {0}.\",\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that of all the cased characters in a string, some are not lower-case. That is, the string could not be\n /// the result of a call to .\n /// \n /// \n /// Numbers, special characters, and many Asian characters don't have casing, so \n /// will ignore these and will fail only if the string contains cased characters and they are all lower-case.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeLowerCased([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is null || HasMixedOrNoCase(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected some characters in {context:string} to be upper-case{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n private static bool HasMixedOrNoCase(string value)\n {\n var hasUpperCase = false;\n var hasLowerCase = false;\n\n foreach (var ch in value)\n {\n hasUpperCase |= char.IsUpper(ch);\n hasLowerCase |= char.IsLower(ch);\n\n if (hasUpperCase && hasLowerCase)\n {\n return true;\n }\n }\n\n return !hasUpperCase && !hasLowerCase;\n }\n\n internal AndConstraint Be(string expected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var expectation = new StringValidator(assertionChain,\n new StringEqualityStrategy(options.GetStringComparerOrDefault(), \"be\"),\n because, becauseArgs);\n\n var subject = ApplyStringSettings(Subject, options);\n expected = ApplyStringSettings(expected, options);\n\n expectation.Validate(subject, expected);\n return new AndConstraint((TAssertions)this);\n }\n\n private static bool Contains(string actual, string expected, StringComparison comparison)\n {\n return (actual ?? string.Empty).Contains(expected ?? string.Empty, comparison);\n }\n\n private static void ThrowIfValuesNullOrEmpty(IEnumerable values)\n {\n Guard.ThrowIfArgumentIsNull(values, nameof(values), \"Cannot assert string containment of values in null collection\");\n\n if (!values.Any())\n {\n throw new ArgumentException(\"Cannot assert string containment of values in empty collection\", nameof(values));\n }\n }\n\n /// \n /// Applies the string-specific to the .\n /// \n /// \n /// When is set, whitespace is removed from the start of the .
\n /// When is set, whitespace is removed from the end of the .
\n /// When is set, all newlines (\\r\\n and \\r) are replaced with \\n in the .
\n ///
\n private static string ApplyStringSettings(string value, IEquivalencyOptions options)\n {\n if (options.IgnoreLeadingWhitespace)\n {\n value = value.TrimStart();\n }\n\n if (options.IgnoreTrailingWhitespace)\n {\n value = value.TrimEnd();\n }\n\n if (options.IgnoreNewlineStyle)\n {\n value = value.RemoveNewlineStyle();\n }\n\n return value;\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"string\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/IncludeMemberByPathSelectionRule.cs", "using System.Collections.Generic;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that includes a particular property in the structural comparison.\n/// \ninternal class IncludeMemberByPathSelectionRule : SelectMemberByPathSelectionRule\n{\n private readonly MemberPath memberToInclude;\n\n public IncludeMemberByPathSelectionRule(MemberPath pathToInclude)\n {\n memberToInclude = pathToInclude;\n }\n\n public override bool IncludesMembers => true;\n\n protected override void AddOrRemoveMembersFrom(List selectedMembers, INode parent, string parentPath,\n MemberSelectionContext context)\n {\n foreach (MemberInfo memberInfo in context.Type.GetMembers(MemberKind.Public | MemberKind.Internal))\n {\n var memberPath = new MemberPath(context.Type, memberInfo.DeclaringType, parentPath.Combine(memberInfo.Name));\n\n if (memberToInclude.IsSameAs(memberPath) || memberToInclude.IsParentOrChildOf(memberPath))\n {\n selectedMembers.Add(MemberFactory.Create(memberInfo, parent));\n }\n }\n }\n\n public override string ToString()\n {\n return \"Include member root.\" + memberToInclude;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/GenericCollectionAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Collections.MaximumMatching;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Collections;\n\n[DebuggerNonUserCode]\npublic class GenericCollectionAssertions : GenericCollectionAssertions, T, GenericCollectionAssertions>\n{\n public GenericCollectionAssertions(IEnumerable actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n }\n}\n\n[DebuggerNonUserCode]\npublic class GenericCollectionAssertions\n : GenericCollectionAssertions>\n where TCollection : IEnumerable\n{\n public GenericCollectionAssertions(TCollection actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n\n[DebuggerNonUserCode]\npublic class GenericCollectionAssertions : ReferenceTypeAssertions\n where TCollection : IEnumerable\n where TAssertions : GenericCollectionAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public GenericCollectionAssertions(TCollection actualValue, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"collection\";\n\n /// \n /// Asserts that all items in the collection are of the specified type \n /// \n /// The expected type of the objects\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint> AllBeAssignableTo(\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be {0}{reason}, but found {context:the collection} is .\",\n typeof(TExpectation));\n\n IEnumerable matches = [];\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type to be {0}{reason}, \", typeof(TExpectation), chain => chain\n .ForCondition(Subject!.All(x => x is not null))\n .FailWith(\"but found a null element.\")\n .Then\n .ForCondition(Subject.All(x => typeof(TExpectation).IsAssignableFrom(GetType(x))))\n .FailWith(\"but found {0}.\", Subject.Select(GetType)));\n\n matches = Subject!.OfType();\n }\n\n return new AndWhichConstraint>((TAssertions)this, matches);\n }\n\n /// \n /// Asserts that all items in the collection are of the specified type \n /// \n /// The expected type of the objects\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllBeAssignableTo(Type expectedType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type to be {0}{reason}, \", expectedType, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found {context:collection} is .\")\n .Then\n .ForCondition(subject => subject.All(x => x is not null))\n .FailWith(\"but found a null element.\")\n .Then\n .ForCondition(subject => subject.All(x => expectedType.IsAssignableFrom(GetType(x))))\n .FailWith(\"but found {0}.\", subject => subject.Select(GetType)));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that all elements in a collection of objects are equivalent to a given object.\n /// \n /// \n /// Objects within the collection are equivalent to given object when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint AllBeEquivalentTo(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return AllBeEquivalentTo(expectation, options => options, because, becauseArgs);\n }\n\n /// \n /// Asserts that all elements in a collection of objects are equivalent to a given object.\n /// \n /// \n /// Objects within the collection are equivalent to given object when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllBeEquivalentTo(TExpectation expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n TExpectation[] repeatedExpectation = RepeatAsManyAs(expectation, Subject).ToArray();\n\n // Because we have just manually created the collection based on single element\n // we are sure that we can force strict ordering, because ordering does not matter in terms\n // of correctness. On the other hand we do not want to change ordering rules for nested objects\n // in case user needs to use them. Strict ordering improves algorithmic complexity\n // from O(n^2) to O(n). For bigger tables it is necessary in order to achieve acceptable\n // execution times.\n Func, EquivalencyOptions> forceStrictOrderingConfig =\n x => config(x).WithStrictOrderingFor(s => string.IsNullOrEmpty(s.Path));\n\n return BeEquivalentTo(repeatedExpectation, forceStrictOrderingConfig, because, becauseArgs);\n }\n\n /// \n /// Asserts that all items in the collection are of the exact specified type \n /// \n /// The expected type of the objects\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint> AllBeOfType(\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be {0}{reason}, but found {context:collection} is .\",\n typeof(TExpectation));\n\n IEnumerable matches = [];\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type to be {0}{reason}, \", typeof(TExpectation), chain => chain\n .ForCondition(Subject!.All(x => x is not null))\n .FailWith(\"but found a null element.\")\n .Then\n .ForCondition(Subject.All(x => typeof(TExpectation) == GetType(x)))\n .FailWith(\"but found {0}.\", () => Subject.Select(GetType)));\n\n matches = Subject!.OfType();\n }\n\n return new AndWhichConstraint>((TAssertions)this, matches);\n }\n\n /// \n /// Asserts that all items in the collection are of the exact specified type \n /// \n /// The expected type of the objects\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllBeOfType(Type expectedType, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type to be {0}{reason}, \", expectedType, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found {context:collection} is .\")\n .Then\n .ForCondition(subject => subject.All(x => x is not null))\n .FailWith(\"but found a null element.\")\n .Then\n .ForCondition(subject => subject.All(x => expectedType == GetType(x)))\n .FailWith(\"but found {0}.\", subject => subject.Select(GetType)));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any items.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var singleItemArray = Subject?.Take(1).ToArray();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to be empty{reason}, \", chain => chain\n .Given(() => singleItemArray)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(subject => subject.Length == 0)\n .FailWith(\"but found at least one item {0}.\", singleItemArray));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection of objects is equivalent to another collection of objects.\n /// \n /// \n /// Objects within the collections are equivalent when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(IEnumerable expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection of objects is equivalent to another collection of objects.\n /// \n /// \n /// Objects within the collections are equivalent when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of a collection property is ignored as long as the collection implements and all\n /// items in the collection are structurally equal.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// An with the expected elements.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(IEnumerable expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions> options =\n config(AssertionConfiguration.Current.Equivalency.CloneDefaults()).AsCollection();\n\n var context =\n new EquivalencyValidationContext(\n Node.From>(() => CallerIdentifier.DetermineCallerIdentity()),\n options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter,\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(IEnumerable),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection is ordered in ascending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInAscendingOrder(\n Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeInAscendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in ascending order according to the value of the specified\n /// implementation.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> BeInAscendingOrder(\n IComparer comparer, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return BeInOrder(comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in ascending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> BeInAscendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return BeOrderedBy(propertyExpression, comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to have all elements in ascending order. Elements are compared\n /// using their implementation.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInAscendingOrder(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeInAscendingOrder(GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to have all elements in ascending order. Elements are compared\n /// using the given lambda expression.\n /// \n /// \n /// A lambda expression that should be used to determine the expected ordering between two objects.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInAscendingOrder(Func comparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return BeInOrder(Comparer.Create((x, y) => comparison(x, y)), SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in descending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInDescendingOrder(\n Expression> propertyExpression, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return BeInDescendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in descending order according to the value of the specified\n /// implementation.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> BeInDescendingOrder(\n IComparer comparer, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return BeInOrder(comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is ordered in descending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> BeInDescendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return BeOrderedBy(propertyExpression, comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to have all elements in descending order. Elements are compared\n /// using their implementation.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInDescendingOrder(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeInDescendingOrder(GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to have all elements in descending order. Elements are compared\n /// using the given lambda expression.\n /// \n /// \n /// A lambda expression that should be used to determine the expected ordering between two objects.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> BeInDescendingOrder(Func comparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeInOrder(Comparer.Create((x, y) => comparison(x, y)), SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts that the collection is null or does not contain any items.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNullOrEmpty(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var singleItemArray = Subject?.Take(1).ToArray();\n var nullOrEmpty = singleItemArray is null || singleItemArray.Length == 0;\n\n assertionChain.ForCondition(nullOrEmpty)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to be null or empty{reason}, but found at least one item {0}.\",\n singleItemArray);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection is a subset of the .\n /// \n /// An with the expected superset.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeSubsetOf(IEnumerable expectedSuperset,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedSuperset, nameof(expectedSuperset),\n \"Cannot verify a subset against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to be a subset of {0}{reason}, \", expectedSuperset, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Except(expectedSuperset))\n .ForCondition(excessItems => !excessItems.Any())\n .FailWith(\"but items {0} are not part of the superset.\", excessItems => excessItems));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection contains the specified item.\n /// \n /// The expectation item.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint Contain(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0}{reason}, but found .\", expected);\n\n IEnumerable matches = [];\n\n if (assertionChain.Succeeded)\n {\n ICollection collection = Subject.ConvertOrCastToCollection();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(collection.Contains(expected))\n .FailWith(\"Expected {context:collection} {0} to contain {1}{reason}.\", collection, expected);\n\n matches = collection.Where(item => EqualityComparer.Default.Equals(item, expected));\n }\n\n return new AndWhichConstraint((TAssertions)this, matches);\n }\n\n /// \n /// Asserts that the collection contains at least one item that matches the predicate.\n /// \n /// A predicate to match the items in the collection against.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint Contain(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0}{reason}, but found .\", predicate.Body);\n\n IEnumerable matches = [];\n\n int? firstMatchingIndex = null;\n if (assertionChain.Succeeded)\n {\n Func func = predicate.Compile();\n\n foreach (var (item, index) in Subject!.Select((item, index) => (item, index)))\n {\n if (func(item))\n {\n firstMatchingIndex = index;\n break;\n }\n }\n\n assertionChain\n .ForCondition(firstMatchingIndex.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to have an item matching {1}{reason}.\", Subject, predicate.Body);\n\n matches = Subject.Where(func);\n }\n\n assertionChain.WithCallerPostfix($\"[{firstMatchingIndex}]\").ReuseOnce();\n\n return new AndWhichConstraint((TAssertions)this, matches);\n }\n\n /// \n /// Expects the current collection to contain the specified elements in any order. Elements are compared\n /// using their implementation.\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint Contain(IEnumerable expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify containment against a collection\");\n\n ICollection expectedObjects = expected.ConvertOrCastToCollection();\n Guard.ThrowIfArgumentIsEmpty(expectedObjects, nameof(expected), \"Cannot verify containment against an empty collection\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0}{reason}, but found .\", expectedObjects);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable missingItems = expectedObjects.Except(Subject!);\n\n if (missingItems.Any())\n {\n if (expectedObjects.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to contain {1}{reason}, but could not find {2}.\",\n Subject, expectedObjects, missingItems);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to contain {1}{reason}.\",\n Subject, expectedObjects.Single());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that at least one element in the collection is equivalent to .\n /// \n /// \n /// \n /// Important: You cannot use this method to assert whether a subset of the collection is equivalent to the .\n /// This usually means that the expectation is meant to be a single item.\n /// \n /// \n /// By default, objects within the collection are seen as equivalent to the expected object when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint ContainEquivalentOf(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return ContainEquivalentOf(expectation, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that at least one element in the collection is equivalent to .\n /// \n /// \n /// \n /// Important: You cannot use this method to assert whether a subset of the collection is equivalent to the .\n /// This usually means that the expectation is meant to be a single item.\n /// \n /// \n /// By default, objects within the collection are seen as equivalent to the expected object when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint ContainEquivalentOf(TExpectation expectation,\n Func,\n EquivalencyOptions> config, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain equivalent of {0}{reason}, but found .\", expectation);\n\n if (assertionChain.Succeeded)\n {\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n using var scope = new AssertionScope();\n assertionChain.AddReportable(\"configuration\", () => options.ToString());\n\n foreach ((T actualItem, int index) in Subject!.Select((item, index) => (item, index)))\n {\n var context =\n new EquivalencyValidationContext(Node.From(() => CurrentAssertionChain.CallerIdentifier),\n options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = actualItem,\n Expectation = expectation,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n string[] failures = scope.Discard();\n\n if (failures.Length == 0)\n {\n return new AndWhichConstraint((TAssertions)this, actualItem, assertionChain, $\"[{index}]\");\n }\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to contain equivalent of {1}{reason}.\", Subject, expectation);\n }\n\n return new AndWhichConstraint((TAssertions)this, default(T));\n }\n\n /// \n /// Expects the current collection to contain the specified elements in the exact same order, not necessarily consecutive.\n /// using their implementation.\n /// \n /// An with the expected elements.\n public AndConstraint ContainInOrder(params T[] expected)\n {\n return ContainInOrder(expected, string.Empty);\n }\n\n /// \n /// Expects the current collection to contain the specified elements in the exact same order, not necessarily consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint ContainInOrder(IEnumerable expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify ordered containment against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0} in order{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n IList expectedItems = expected.ConvertOrCastToList();\n IList actualItems = Subject.ConvertOrCastToList();\n\n int subjectIndex = 0;\n\n for (int index = 0; index < expectedItems.Count; index++)\n {\n T expectedItem = expectedItems[index];\n subjectIndex = IndexOf(actualItems, expectedItem, startIndex: subjectIndex);\n\n if (subjectIndex == -1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} to contain items {1} in order{reason}\" +\n \", but {2} (index {3}) did not appear (in the right order).\",\n Subject, expected, expectedItem, index);\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection to contain the specified elements in the exact same order, and to be consecutive.\n /// using their implementation.\n /// \n /// An with the expected elements.\n public AndConstraint ContainInConsecutiveOrder(params T[] expected)\n {\n return ContainInConsecutiveOrder(expected, string.Empty);\n }\n\n /// \n /// Expects the current collection to contain the specified elements in the exact same order, and to be consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint ContainInConsecutiveOrder(IEnumerable expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify ordered containment against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0} in order{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n IList expectedItems = expected.ConvertOrCastToList();\n\n if (expectedItems.Count == 0)\n {\n return new AndConstraint((TAssertions)this);\n }\n\n IList actualItems = Subject.ConvertOrCastToList();\n\n int subjectIndex = 0;\n int highestIndex = 0;\n\n while (subjectIndex != -1)\n {\n subjectIndex = IndexOf(actualItems, expectedItems[0], startIndex: subjectIndex);\n\n if (subjectIndex != -1)\n {\n int consecutiveItems = ConsecutiveItemCount(actualItems, expectedItems, startIndex: subjectIndex);\n\n if (consecutiveItems == expectedItems.Count)\n {\n return new AndConstraint((TAssertions)this);\n }\n\n highestIndex = Math.Max(highestIndex, consecutiveItems);\n subjectIndex++;\n }\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} to contain items {1} in order{reason}\" +\n \", but {2} (index {3}) did not appear (in the right consecutive order).\",\n Subject, expected, expectedItems[highestIndex], highestIndex);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection contains at least one element that is assignable to the type .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint ContainItemsAssignableTo(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain at least one element assignable to type {0}{reason}, \",\n typeof(TExpectation), chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(() => Subject.ConvertOrCastToCollection())\n .ForCondition(subject => subject.Any(x => typeof(TExpectation).IsAssignableFrom(GetType(x))))\n .FailWith(\"but found {0}.\", subject => subject.Select(x => GetType(x))));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection does not contain any elements that are assignable to the type .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint\n NotContainItemsAssignableTo(string because = \"\", params object[] becauseArgs) =>\n NotContainItemsAssignableTo(typeof(TExpectation), because, becauseArgs);\n\n /// \n /// Asserts that the current collection does not contain any elements that are assignable to the given type.\n /// \n /// \n /// Object type that should not be in collection\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainItemsAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to not contain any elements assignable to type {0}{reason}, \",\n type, chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(() => Subject.ConvertOrCastToCollection())\n .ForCondition(subject => subject.All(x => !type.IsAssignableFrom(GetType(x))))\n .FailWith(\"but found {0}.\", subject => subject.Select(x => GetType(x))));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection to contain only a single item.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint ContainSingle(string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain a single item{reason}, but found .\");\n\n T match = default;\n\n if (assertionChain.Succeeded)\n {\n ICollection actualItems = Subject.ConvertOrCastToCollection();\n\n switch (actualItems.Count)\n {\n case 0: // Fail, Collection is empty\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to contain a single item{reason}, but the collection is empty.\");\n\n break;\n case 1: // Success Condition\n match = actualItems.Single();\n break;\n default: // Fail, Collection contains more than a single item\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to contain a single item{reason}, but found {0}.\", Subject);\n\n break;\n }\n }\n\n return new AndWhichConstraint((TAssertions)this, match, assertionChain, \"[0]\");\n }\n\n /// \n /// Expects the current collection to contain only a single item matching the specified .\n /// \n /// The predicate that will be used to find the matching items.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint ContainSingle(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n const string expectationPrefix =\n \"Expected {context:collection} to contain a single item matching {0}{reason}, \";\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(expectationPrefix + \"but found .\", predicate);\n\n T[] matches = [];\n\n if (assertionChain.Succeeded)\n {\n ICollection actualItems = Subject.ConvertOrCastToCollection();\n\n assertionChain\n .ForCondition(actualItems.Count > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(expectationPrefix + \"but the collection is empty.\", predicate);\n\n matches = actualItems.Where(predicate.Compile()).ToArray();\n int count = matches.Length;\n\n if (count == 0)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(expectationPrefix + \"but no such item was found.\", predicate);\n }\n else if (count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n expectationPrefix + \"but \" + count.ToString(CultureInfo.InvariantCulture) + \" such items were found.\",\n predicate);\n }\n else\n {\n // Can never happen\n }\n }\n\n return new AndWhichConstraint((TAssertions)this, matches, assertionChain, \"[0]\");\n }\n\n /// \n /// Asserts that the current collection ends with same elements in the same order as the collection identified by\n /// . Elements are compared using their .\n /// \n /// \n /// A collection of expected elements.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint EndWith(IEnumerable expectation, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return EndWith(expectation, (a, b) => EqualityComparer.Default.Equals(a, b), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current collection ends with same elements in the same order as the collection identified by\n /// . Elements are compared using .\n /// \n /// \n /// A collection of expected elements.\n /// \n /// \n /// A equality comparison the is used to determine whether two objects should be treated as equal.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint EndWith(\n IEnumerable expectation, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectation, nameof(expectation), \"Cannot compare collection with .\");\n\n AssertCollectionEndsWith(Subject, expectation.ConvertOrCastToCollection(), equalityComparison, because, becauseArgs);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection ends with the specified .\n /// \n /// \n /// The element that is expected to appear at the end of the collection. The object's \n /// is used to compare the element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint EndWith(T element, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return EndWith([element], ObjectExtensions.GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Expects the current collection to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their method.\n /// \n /// A params array with the expected elements.\n public AndConstraint Equal(params T[] elements)\n {\n AssertSubjectEquality(elements, ObjectExtensions.GetComparer(), string.Empty);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that two collections contain the same items in the same order, where equality is determined using a\n /// .\n /// \n /// \n /// The collection to compare the subject with.\n /// \n /// \n /// A equality comparison the is used to determine whether two objects should be treated as equal.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Equal(\n IEnumerable expectation, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n AssertSubjectEquality(expectation, equalityComparison, because, becauseArgs);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their .\n /// \n /// An with the expected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Equal(IEnumerable expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n AssertSubjectEquality(expected, ObjectExtensions.GetComparer(), because, becauseArgs);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection matches the supplied amount.\n /// \n /// The expected number of items in the collection.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCount(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0} item(s){reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n int actualCount = Subject!.Count();\n\n assertionChain\n .ForCondition(actualCount == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to contain {0} item(s){reason}, but found {1}: {2}.\",\n expected, actualCount, Subject);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection matches a condition stated by the .\n /// \n /// A predicate that yields the number of items that is expected to be in the collection.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint HaveCount(Expression> countPredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(countPredicate, nameof(countPredicate),\n \"Cannot compare collection count against a predicate.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to contain {0} items{reason}, but found .\", countPredicate.Body);\n\n if (assertionChain.Succeeded)\n {\n Func compiledPredicate = countPredicate.Compile();\n\n int actualCount = Subject!.Count();\n\n if (!compiledPredicate(actualCount))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to have a count {0}{reason}, but count is {1}: {2}.\",\n countPredicate.Body, actualCount, Subject);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection is greater than or equal to the supplied amount.\n /// \n /// The number to which the actual number items in the collection will be compared.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCountGreaterThanOrEqualTo(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain at least {0} item(s){reason}, \", expected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount >= expected)\n .FailWith(\"but found {0}: {1}.\", actualCount => actualCount, _ => Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection is greater than the supplied amount.\n /// \n /// The number to which the actual number items in the collection will be compared.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCountGreaterThan(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain more than {0} item(s){reason}, \", expected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount > expected)\n .FailWith(\"but found {0}: {1}.\", actualCount => actualCount, _ => Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection is less than or equal to the supplied amount.\n /// \n /// The number to which the actual number items in the collection will be compared.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCountLessThanOrEqualTo(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain at most {0} item(s){reason}, \", expected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount <= expected)\n .FailWith(\"but found {0}: {1}.\", actualCount => actualCount, _ => Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection is less than the supplied amount.\n /// \n /// The number to which the actual number items in the collection will be compared.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveCountLessThan(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain fewer than {0} item(s){reason}, \", expected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount < expected)\n .FailWith(\"but found {0}: {1}.\", actualCount => actualCount, _ => Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection has the supplied at the\n /// supplied .\n /// \n /// The index where the element is expected\n /// The expected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementAt(int index, T element,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to have element at index {0}{reason}, but found .\", index);\n\n T actual = default;\n\n if (assertionChain.Succeeded)\n {\n if (index < Subject!.Count())\n {\n actual = Subject.ElementAt(index);\n\n assertionChain\n .ForCondition(ObjectExtensions.GetComparer()(actual, element))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0} at index {1}{reason}, but found {2}.\", element, index, actual);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0} at index {1}{reason}, but found no element.\", element, index);\n }\n }\n\n return new AndWhichConstraint((TAssertions)this, actual, assertionChain, $\"[{index}]\");\n }\n\n /// \n /// Asserts that the element directly precedes the .\n /// \n /// The element that should succeed .\n /// The expected element that should precede .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveElementPreceding(T successor, T expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to have {0} precede {1}{reason}, \", expectation, successor, chain =>\n chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but the collection is .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\"but the collection is empty.\")\n .Then\n .ForCondition(subject => HasPredecessor(successor, subject))\n .FailWith(\"but found nothing.\")\n .Then\n .Given(subject => PredecessorOf(successor, subject))\n .ForCondition(predecessor => ObjectExtensions.GetComparer()(predecessor, expectation))\n .FailWith(\"but found {0}.\", predecessor => predecessor));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the element directly succeeds the .\n /// \n /// The element that should precede .\n /// The element that should succeed .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveElementSucceeding(T predecessor, T expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to have {0} succeed {1}{reason}, \", expectation, predecessor,\n chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but the collection is .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\"but the collection is empty.\")\n .Then\n .ForCondition(subject => HasSuccessor(predecessor, subject))\n .FailWith(\"but found nothing.\")\n .Then\n .Given(subject => SuccessorOf(predecessor, subject))\n .ForCondition(successor => ObjectExtensions.GetComparer()(successor, expectation))\n .FailWith(\"but found {0}.\", successor => successor));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Assert that the current collection has the same number of elements as .\n /// \n /// The other collection with the same expected number of elements\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint HaveSameCount(IEnumerable otherCollection,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(otherCollection, nameof(otherCollection), \"Cannot verify count against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to have \", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"the same count as {0}{reason}, but found .\", otherCollection)\n .Then\n .Given(subject => (actual: subject.Count(), expected: otherCollection.Count()))\n .ForCondition(count => count.actual == count.expected)\n .FailWith(\"{0} item(s){reason}, but found {1}.\", count => count.expected, count => count.actual));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection shares one or more items with the specified .\n /// \n /// The with the expected shared items.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint IntersectWith(IEnumerable otherCollection,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(otherCollection, nameof(otherCollection),\n \"Cannot verify intersection against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to intersect with {0}{reason}, but found .\", otherCollection);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable sharedItems = Subject!.Intersect(otherCollection);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(sharedItems.Any())\n .FailWith(\n \"Expected {context:collection} to intersect with {0}{reason}, but {1} does not contain any shared items.\",\n otherCollection, Subject);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection contains at least 1 item.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEmpty(string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} not to be empty{reason}\", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\".\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection not to contain all elements of the collection identified by ,\n /// regardless of the order. Elements are compared using their .\n /// \n /// An with the unexpected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeEquivalentTo(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot verify inequivalence against a collection.\");\n\n if (Subject is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} not to be equivalent{reason}, but found .\");\n }\n\n if (ReferenceEquals(Subject, unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} not to be equivalent with collection {1}{reason}, but they both reference the same object.\",\n Subject,\n unexpected);\n }\n\n return NotBeEquivalentTo(unexpected.ConvertOrCastToList(), config => config, because, becauseArgs);\n }\n\n /// \n /// Expects the current collection not to contain all elements of the collection identified by ,\n /// regardless of the order. Elements are compared using their .\n /// \n /// An with the unexpected elements.\n /// /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(IEnumerable unexpected,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot verify inequivalence against a collection.\");\n\n if (Subject is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} not to be equivalent{reason}, but found .\");\n }\n\n string[] failures;\n\n using (var scope = new AssertionScope())\n {\n BeEquivalentTo(unexpected, config);\n\n failures = scope.Discard();\n }\n\n assertionChain\n .ForCondition(failures.Length > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} not to be equivalent to collection {1}{reason}.\", Subject,\n unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection is not ordered in ascending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInAscendingOrder(\n Expression> propertyExpression, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeInAscendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in ascending order according to the value of the specified\n /// implementation.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint NotBeInAscendingOrder(\n IComparer comparer, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return NotBeInOrder(comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in ascending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint NotBeInAscendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return NotBeOrderedBy(propertyExpression, comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts the current collection does not have all elements in ascending order. Elements are compared\n /// using their implementation.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInAscendingOrder(string because = \"\", params object[] becauseArgs)\n {\n return NotBeInAscendingOrder(GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in ascending order according to the provided lambda expression.\n /// \n /// \n /// A lambda expression that should be used to determine the expected ordering between two objects.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInAscendingOrder(Func comparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeInOrder(Comparer.Create((x, y) => comparison(x, y)), SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in descending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInDescendingOrder(\n Expression> propertyExpression, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeInDescendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in descending order according to the value of the specified\n /// implementation.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint NotBeInDescendingOrder(\n IComparer comparer, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return NotBeInOrder(comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection not is ordered in descending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint NotBeInDescendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return NotBeOrderedBy(propertyExpression, comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts the current collection does not have all elements in descending order. Elements are compared\n /// using their implementation.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInDescendingOrder(string because = \"\", params object[] becauseArgs)\n {\n return NotBeInDescendingOrder(GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a collection is not ordered in descending order according to the provided lambda expression.\n /// \n /// \n /// A lambda expression that should be used to determine the expected ordering between two objects.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint NotBeInDescendingOrder(Func comparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeInOrder(Comparer.Create((x, y) => comparison(x, y)), SortOrder.Descending, because, becauseArgs);\n }\n\n /// \n /// Asserts that the collection is not null and contains at least 1 item.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNullOrEmpty(string because = \"\", params object[] becauseArgs)\n {\n return NotBeNull(because, becauseArgs)\n .And.NotBeEmpty(because, becauseArgs);\n }\n\n /// \n /// Asserts that the collection is not a subset of the .\n /// \n /// An with the unexpected superset.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSubsetOf(IEnumerable unexpectedSuperset,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Cannot assert a collection against a subset.\");\n\n if (assertionChain.Succeeded)\n {\n if (ReferenceEquals(Subject, unexpectedSuperset))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:collection} {0} to be a subset of {1}{reason}, but they both reference the same object.\",\n Subject,\n unexpectedSuperset);\n }\n\n ICollection actualItems = Subject.ConvertOrCastToCollection();\n\n if (actualItems.Intersect(unexpectedSuperset).Count() == actualItems.Count)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:collection} {0} to be a subset of {1}{reason}.\", actualItems,\n unexpectedSuperset);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection does not contain the supplied item.\n /// \n /// The element that is not expected to be in the collection\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContain(T unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to not contain {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded)\n {\n ICollection collection = Subject.ConvertOrCastToCollection();\n\n if (collection.Contains(unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to not contain {1}{reason}.\", collection, unexpected);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any items that match the predicate.\n /// \n /// A predicate to match the items in the collection against.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotContain(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} not to contain {0}{reason}, but found .\", predicate.Body);\n\n if (assertionChain.Succeeded)\n {\n Func compiledPredicate = predicate.Compile();\n IEnumerable unexpectedItems = Subject!.Where(item => compiledPredicate(item));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!unexpectedItems.Any())\n .FailWith(\"Expected {context:collection} {0} to not have any items matching {1}{reason}, but found {2}.\",\n Subject, predicate, unexpectedItems);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection does not contain the supplied items. Elements are compared\n /// using their implementation.\n /// \n /// An with the unexpected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotContain(IEnumerable unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot verify non-containment against a collection\");\n\n ICollection unexpectedObjects = unexpected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(unexpectedObjects, nameof(unexpected),\n \"Cannot verify non-containment against an empty collection\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to not contain {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable foundItems = unexpectedObjects.Intersect(Subject!);\n\n if (foundItems.Any())\n {\n if (unexpectedObjects.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to not contain {1}{reason}, but found {2}.\", Subject,\n unexpected, foundItems);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to not contain {1}{reason}.\",\n Subject, unexpectedObjects.First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that no element in the collection is equivalent to .\n /// \n /// \n /// \n /// Important: You cannot use this method to assert whether a subset of the collection is not equivalent to the .\n /// This usually means that the expectation is meant to be a single item.\n /// \n /// \n /// By default, objects within the collection are seen as not equivalent to the expected object when both object graphs have unequally named properties with the same\n /// value, irrespective of the type of those objects.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// \n /// The unexpected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainEquivalentOf(TExpectation unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotContainEquivalentOf(unexpected, config => config, because, becauseArgs);\n }\n\n /// \n /// Asserts that no element in the collection is equivalent to .\n /// \n /// \n /// \n /// Important: You cannot use this method to assert whether a subset of the collection is not equivalent to the .\n /// This usually means that the expectation is meant to be a single item.\n /// \n /// \n /// By default, objects within the collection are seen as not equivalent to the expected object when both object graphs have unequally named properties with the same\n /// value, irrespective of the type of those objects.\n /// Notice that actual behavior is determined by the global defaults managed by .\n /// \n /// \n /// The unexpected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\", Justification = \"Needs refactoring\")]\n public AndConstraint NotContainEquivalentOf(TExpectation unexpected,\n Func,\n EquivalencyOptions> config, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} not to contain equivalent of {0}{reason}, but collection is .\",\n unexpected);\n\n if (assertionChain.Succeeded)\n {\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var foundIndices = new List();\n\n using (var scope = new AssertionScope())\n {\n int index = 0;\n\n foreach (T actualItem in Subject!)\n {\n var context =\n new EquivalencyValidationContext(Node.From(() => CurrentAssertionChain.CallerIdentifier),\n options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = actualItem,\n Expectation = unexpected,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n string[] failures = scope.Discard();\n\n if (failures.Length == 0)\n {\n foundIndices.Add(index);\n }\n\n index++;\n }\n }\n\n if (foundIndices.Count > 0)\n {\n using (new AssertionScope())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithReportable(\"configuration\", () => options.ToString())\n .WithExpectation(\"Expected {context:collection} {0} not to contain equivalent of {1}{reason}, \", Subject,\n unexpected, chain =>\n {\n if (foundIndices.Count == 1)\n {\n chain.FailWith(\"but found one at index {0}.\", foundIndices[0]);\n }\n else\n {\n chain.FailWith(\"but found several at indices {0}.\", foundIndices);\n }\n });\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts the current collection does not contain the specified elements in the exact same order, not necessarily consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// A with the unexpected elements.\n /// is .\n public AndConstraint NotContainInOrder(params T[] unexpected)\n {\n return NotContainInOrder(unexpected, string.Empty);\n }\n\n /// \n /// Asserts the current collection does not contain the specified elements in the exact same order, not necessarily consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// An with the unexpected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotContainInOrder(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected),\n \"Cannot verify absence of ordered containment against a collection.\");\n\n if (Subject is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Cannot verify absence of ordered containment in a collection.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n IList unexpectedItems = unexpected.ConvertOrCastToList();\n\n if (unexpectedItems.Any())\n {\n IList actualItems = Subject.ConvertOrCastToList();\n int subjectIndex = 0;\n\n foreach (var unexpectedItem in unexpectedItems)\n {\n subjectIndex = IndexOf(actualItems, unexpectedItem, startIndex: subjectIndex);\n\n if (subjectIndex == -1)\n {\n return new AndConstraint((TAssertions)this);\n }\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} to not contain items {1} in order{reason}, \" +\n \"but items appeared in order ending at index {2}.\",\n Subject, unexpected, subjectIndex - 1);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts the current collection does not contain the specified elements in the exact same order and are consecutive.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// A with the unexpected elements.\n /// is .\n public AndConstraint NotContainInConsecutiveOrder(params T[] unexpected)\n {\n return NotContainInConsecutiveOrder(unexpected, string.Empty);\n }\n\n /// \n /// Asserts the current collection does not contain the specified elements in the exact same order and consecutively.\n /// \n /// \n /// Elements are compared using their implementation.\n /// \n /// An with the unexpected elements.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotContainInConsecutiveOrder(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected),\n \"Cannot verify absence of ordered containment against a collection.\");\n\n if (Subject is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Cannot verify absence of ordered containment in a collection.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n IList unexpectedItems = unexpected.ConvertOrCastToList();\n\n if (unexpectedItems.Any())\n {\n IList actualItems = Subject.ConvertOrCastToList();\n\n if (unexpectedItems.Count > actualItems.Count)\n {\n return new AndConstraint((TAssertions)this);\n }\n\n int subjectIndex = 0;\n\n while (subjectIndex != -1)\n {\n subjectIndex = IndexOf(actualItems, unexpectedItems[0], startIndex: subjectIndex);\n\n if (subjectIndex != -1)\n {\n int consecutiveItems = ConsecutiveItemCount(actualItems, unexpectedItems, startIndex: subjectIndex);\n\n if (consecutiveItems == unexpectedItems.Count)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} {0} to not contain items {1} in consecutive order{reason}, \" +\n \"but items appeared in order ending at index {2}.\",\n Subject, unexpectedItems, (subjectIndex + consecutiveItems) - 2);\n }\n\n subjectIndex++;\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any items.\n /// \n /// The predicate when evaluated should not be null.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotContainNulls(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TKey : class\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} not to contain s{reason}, but collection is .\");\n\n if (assertionChain.Succeeded)\n {\n Func compiledPredicate = predicate.Compile();\n\n T[] values = Subject!\n .Where(e => compiledPredicate(e) is null)\n .ToArray();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(values.Length == 0)\n .FailWith(\"Expected {context:collection} not to contain s on {0}{reason}, but found {1}.\",\n predicate.Body, values);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any items.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainNulls(string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} not to contain s{reason}, but collection is .\");\n\n if (assertionChain.Succeeded)\n {\n int[] indices = Subject!\n .Select((item, index) => (Item: item, Index: index))\n .Where(e => e.Item is null)\n .Select(e => e.Index)\n .ToArray();\n\n if (indices.Length > 0)\n {\n if (indices.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} not to contain s{reason}, but found several at indices {0}.\",\n indices);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} not to contain s{reason}, but found one at index {0}.\",\n indices[0]);\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection not to contain all the same elements in the same order as the collection identified by\n /// . Elements are compared using their .\n /// \n /// An with the elements that are not expected.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEqual(IEnumerable unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare collection with .\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected collections not to be equal{reason}, \", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(subject => !ReferenceEquals(subject, unexpected))\n .FailWith(\"but they both reference the same object.\"))\n .Then\n .Given(() => Subject.ConvertOrCastToCollection())\n .ForCondition(actualItems => !actualItems.SequenceEqual(unexpected))\n .FailWith(\"Did not expect collections {0} and {1} to be equal{reason}.\", _ => unexpected,\n actualItems => actualItems);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the number of items in the collection does not match the supplied amount.\n /// \n /// The unexpected number of items in the collection.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveCount(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to not contain {0} item(s){reason}, \", unexpected, chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but found .\")\n .Then\n .Given(subject => subject.Count())\n .ForCondition(actualCount => actualCount != unexpected)\n .FailWith(\"but found {0}.\", actualCount => actualCount));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Assert that the current collection does not have the same number of elements as .\n /// \n /// The other collection with the unexpected number of elements\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotHaveSameCount(IEnumerable otherCollection,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(otherCollection, nameof(otherCollection), \"Cannot verify count against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\n \"Expected {context:collection} to not have the same count as {0}{reason}, but found .\",\n otherCollection)\n .Then\n .ForCondition(subject => !ReferenceEquals(subject, otherCollection))\n .FailWith(\n \"Expected {context:collection} {0} to not have the same count as {1}{reason}, but they both reference the same object.\",\n subject => subject, _ => otherCollection)\n .Then\n .Given(subject => (actual: subject.Count(), expected: otherCollection.Count()))\n .ForCondition(count => count.actual != count.expected)\n .FailWith(\n \"Expected {context:collection} to not have {0} item(s){reason}, but found {1}.\",\n count => count.expected, count => count.actual);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not share any items with the specified .\n /// \n /// The to compare to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotIntersectWith(IEnumerable otherCollection,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(otherCollection, nameof(otherCollection),\n \"Cannot verify intersection against a collection.\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\n \"Did not expect {context:collection} to intersect with {0}{reason}, but found .\",\n otherCollection)\n .Then\n .ForCondition(subject => !ReferenceEquals(subject, otherCollection))\n .FailWith(\n \"Did not expect {context:collection} {0} to intersect with {1}{reason}, but they both reference the same object.\",\n subject => subject, _ => otherCollection)\n .Then\n .Given(subject => subject.Intersect(otherCollection))\n .ForCondition(sharedItems => !sharedItems.Any())\n .FailWith(\n \"Did not expect {context:collection} to intersect with {0}{reason}, but found the following shared items {1}.\",\n _ => otherCollection, sharedItems => sharedItems);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection only contains items that match a predicate.\n /// \n /// A predicate to match the items in the collection against.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint OnlyContain(\n Expression> predicate, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n Func compiledPredicate = predicate.Compile();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain only items matching {0}{reason}, \", predicate.Body,\n chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but the collection is .\")\n .Then\n .Given(subject => subject.ConvertOrCastToCollection().Where(item => !compiledPredicate(item)))\n .ForCondition(mismatchingItems => !mismatchingItems.Any())\n .FailWith(\"but {0} do(es) not match.\", mismatchingItems => mismatchingItems));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any duplicate items.\n /// \n /// The predicate to group the items by.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint OnlyHaveUniqueItems(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to only have unique items{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n Func compiledPredicate = predicate.Compile();\n\n IGrouping[] groupWithMultipleItems = Subject!\n .GroupBy(compiledPredicate)\n .Where(g => g.Count() > 1)\n .ToArray();\n\n if (groupWithMultipleItems.Length > 0)\n {\n if (groupWithMultipleItems.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to only have unique items on {0}{reason}, but items {1} are not unique.\",\n predicate.Body,\n groupWithMultipleItems.SelectMany(g => g));\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to only have unique items on {0}{reason}, but item {1} is not unique.\",\n predicate.Body,\n groupWithMultipleItems[0].First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection does not contain any duplicate items.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint OnlyHaveUniqueItems(string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to only have unique items{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n T[] groupWithMultipleItems = Subject!\n .GroupBy(o => o)\n .Where(g => g.Count() > 1)\n .Select(g => g.Key)\n .ToArray();\n\n if (groupWithMultipleItems.Length > 0)\n {\n if (groupWithMultipleItems.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:collection} to only have unique items{reason}, but items {0} are not unique.\",\n groupWithMultipleItems);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to only have unique items{reason}, but item {0} is not unique.\",\n groupWithMultipleItems[0]);\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection contains only items which meet\n /// the criteria provided by the inspector.\n /// \n /// \n /// The element inspector, which inspects each element in turn.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint AllSatisfy(Action expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify against a inspector\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain only items satisfying the inspector{reason}, \",\n chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but collection is .\"));\n\n if (assertionChain.Succeeded)\n {\n string[] failuresFromInspectors;\n\n using (CallerIdentifier.OverrideStackSearchUsingCurrentScope())\n {\n var elementInspectors = Subject.Select(_ => expected);\n failuresFromInspectors = CollectFailuresFromInspectors(elementInspectors);\n }\n\n if (failuresFromInspectors.Length > 0)\n {\n string failureMessage = Environment.NewLine\n + string.Join(Environment.NewLine, failuresFromInspectors.Select(x => x.IndentLines()));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to contain only items satisfying the inspector{reason}:\",\n chain => chain\n .FailWithPreFormatted(failureMessage));\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection contains exactly a given number of elements, which meet\n /// the criteria provided by the element inspectors.\n /// \n /// \n /// The element inspectors, which inspect each element in turn. The\n /// total number of element inspectors must exactly match the number of elements in the collection.\n /// \n /// is .\n /// is empty.\n public AndConstraint SatisfyRespectively(params Action[] elementInspectors)\n {\n return SatisfyRespectively(elementInspectors, string.Empty);\n }\n\n /// \n /// Asserts that a collection contains exactly a given number of elements, which meet\n /// the criteria provided by the element inspectors.\n /// \n /// \n /// The element inspectors, which inspect each element in turn. The\n /// total number of element inspectors must exactly match the number of elements in the collection.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint SatisfyRespectively(IEnumerable> expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot verify against a collection of inspectors\");\n\n ICollection> elementInspectors = expected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(elementInspectors, nameof(expected),\n \"Cannot verify against an empty collection of inspectors\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to satisfy all inspectors{reason}, \", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"but collection is .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\"but collection is empty.\"))\n .Then\n .Given(() => (elements: Subject.Count(), inspectors: elementInspectors.Count))\n .ForCondition(count => count.elements == count.inspectors)\n .FailWith(\n \"Expected {context:collection} to contain exactly {0} items{reason}, but it contains {1} items\",\n count => count.inspectors, count => count.elements);\n\n if (assertionChain.Succeeded)\n {\n string[] failuresFromInspectors;\n\n using (CallerIdentifier.OverrideStackSearchUsingCurrentScope())\n {\n failuresFromInspectors = CollectFailuresFromInspectors(elementInspectors);\n }\n\n if (failuresFromInspectors.Length > 0)\n {\n string failureMessage = Environment.NewLine\n + string.Join(Environment.NewLine, failuresFromInspectors.Select(x => x.IndentLines()));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\n \"Expected {context:collection} to satisfy all inspectors{reason}, but some inspectors are not satisfied:\",\n chain => chain\n .FailWithPreFormatted(failureMessage));\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a collection contains exactly a given number of elements which meet\n /// the criteria provided by the element predicates. Assertion fails if it is not possible\n /// to find a one-to-one mapping between the elements of the collection and the predicates.\n /// The order of the predicates does not need to match the order of the elements.\n /// \n /// \n /// The predicates that the elements of the collection must match.\n /// The total number of predicates must exactly match the number of elements in the collection.\n /// \n /// is .\n /// is empty.\n public AndConstraint Satisfy(params Expression>[] predicates)\n {\n return Satisfy(predicates, because: string.Empty);\n }\n\n /// \n /// Asserts that a collection contains exactly a given number of elements which meet\n /// the criteria provided by the element predicates. Assertion fails if it is not possible\n /// to find a one-to-one mapping between the elements of the collection and the predicates.\n /// \n /// \n /// The predicates that the elements of the collection must match.\n /// The total number of predicates must exactly match the number of elements in the collection.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint Satisfy(IEnumerable>> predicates,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicates, nameof(predicates), \"Cannot verify against a collection of predicates\");\n\n IList>> predicatesList = predicates.ConvertOrCastToList();\n\n Guard.ThrowIfArgumentIsEmpty(predicatesList, nameof(predicates),\n \"Cannot verify against an empty collection of predicates\");\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject)\n .ForCondition(subject => subject is not null)\n .FailWith(\"Expected {context:collection} to satisfy all predicates{reason}, but collection is .\")\n .Then\n .ForCondition(subject => subject.Any())\n .FailWith(\"Expected {context:collection} to satisfy all predicates{reason}, but collection is empty.\");\n\n if (assertionChain.Succeeded)\n {\n MaximumMatchingSolution maximumMatchingSolution = new MaximumMatchingProblem(predicatesList, Subject).Solve();\n\n if (maximumMatchingSolution.UnmatchedPredicatesExist || maximumMatchingSolution.UnmatchedElementsExist)\n {\n string message = string.Empty;\n var doubleNewLine = Environment.NewLine + Environment.NewLine;\n\n List> unmatchedPredicates = maximumMatchingSolution.GetUnmatchedPredicates();\n\n if (unmatchedPredicates.Count > 0)\n {\n message += doubleNewLine + \"The following predicates did not have matching elements:\";\n\n message += doubleNewLine +\n string.Join(Environment.NewLine,\n unmatchedPredicates.Select(predicate => Formatter.ToString(predicate.Expression)));\n }\n\n List> unmatchedElements = maximumMatchingSolution.GetUnmatchedElements();\n\n if (unmatchedElements.Count > 0)\n {\n message += doubleNewLine + \"The following elements did not match any predicate:\";\n\n IEnumerable elementDescriptions = unmatchedElements\n .Select(element => $\"Index: {element.Index}, Element: {Formatter.ToString(element.Value)}\");\n\n message += doubleNewLine + string.Join(doubleNewLine, elementDescriptions);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to satisfy all predicates{reason}, but:\", chain => chain\n .FailWithPreFormatted(message));\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current collection starts with same elements in the same order as the collection identified by\n /// . Elements are compared using their .\n /// \n /// \n /// A collection of expected elements.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWith(IEnumerable expectation, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return StartWith(expectation, (a, b) => EqualityComparer.Default.Equals(a, b), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current collection starts with same elements in the same order as the collection identified by\n /// . Elements are compared using .\n /// \n /// \n /// A collection of expected elements.\n /// \n /// \n /// A equality comparison the is used to determine whether two objects should be treated as equal.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint StartWith(\n IEnumerable expectation, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectation, nameof(expectation), \"Cannot compare collection with .\");\n\n AssertCollectionStartsWith(Subject, expectation.ConvertOrCastToCollection(), equalityComparison, because, becauseArgs);\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the collection starts with the specified .\n /// \n /// \n /// The element that is expected to appear at the start of the collection. The object's \n /// is used to compare the element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint StartWith(T element, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return StartWith([element], ObjectExtensions.GetComparer(), because, becauseArgs);\n }\n\n internal AndConstraint> BeOrderedBy(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n string because,\n object[] becauseArgs)\n {\n if (IsValidProperty(propertyExpression, because, becauseArgs))\n {\n ICollection unordered = Subject.ConvertOrCastToCollection();\n\n IOrderedEnumerable expectation = GetOrderedEnumerable(\n propertyExpression,\n comparer,\n direction,\n unordered);\n\n assertionChain\n .ForCondition(unordered.SequenceEqual(expectation))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to be ordered {1}{reason} and result in {2}.\",\n () => Subject, () => GetExpressionOrderString(propertyExpression), () => expectation);\n\n return new AndConstraint>(\n new SubsequentOrderingAssertions(Subject, expectation, assertionChain));\n }\n\n return new AndConstraint>(\n new SubsequentOrderingAssertions(Subject, EmptyOrderedEnumerable, assertionChain));\n }\n\n internal virtual IOrderedEnumerable GetOrderedEnumerable(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n ICollection unordered)\n {\n Func keySelector = propertyExpression.Compile();\n\n IOrderedEnumerable expectation = direction == SortOrder.Ascending\n ? unordered.OrderBy(keySelector, comparer)\n : unordered.OrderByDescending(keySelector, comparer);\n\n return expectation;\n }\n\n protected static IEnumerable RepeatAsManyAs(TExpectation value, IEnumerable enumerable)\n {\n if (enumerable is null)\n {\n return [];\n }\n\n return RepeatAsManyAsIterator(value, enumerable);\n }\n\n protected void AssertCollectionEndsWith(IEnumerable actual,\n ICollection expected, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(equalityComparison);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to end with {0}{reason}, \", expected, chain => chain\n .Given(() => actual)\n .AssertCollectionIsNotNull()\n .Then\n .AssertCollectionHasEnoughItems(expected.Count)\n .Then\n .AssertCollectionsHaveSameItems(expected, (a, e) =>\n {\n int firstIndexToCompare = a.Count - e.Count;\n int index = a.Skip(firstIndexToCompare).IndexOfFirstDifferenceWith(e, equalityComparison);\n return index >= 0 ? index + firstIndexToCompare : index;\n }));\n }\n\n protected void AssertCollectionStartsWith(IEnumerable actualItems,\n ICollection expected, Func equalityComparison,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(equalityComparison);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:collection} to start with {0}{reason}, \", expected, chain => chain\n .Given(() => actualItems)\n .AssertCollectionIsNotNull()\n .Then\n .AssertCollectionHasEnoughItems(expected.Count)\n .Then\n .AssertCollectionsHaveSameItems(expected,\n (a, e) => a.Take(e.Count).IndexOfFirstDifferenceWith(e, equalityComparison)));\n }\n\n protected void AssertSubjectEquality(IEnumerable expectation,\n Func equalityComparison, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(equalityComparison);\n\n bool subjectIsNull = Subject is null;\n bool expectationIsNull = expectation is null;\n\n if (subjectIsNull && expectationIsNull)\n {\n return;\n }\n\n Guard.ThrowIfArgumentIsNull(expectation, nameof(expectation), \"Cannot compare collection with .\");\n\n ICollection expectedItems = expectation.ConvertOrCastToCollection();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!subjectIsNull)\n .FailWith(\"Expected {context:collection} to be equal to {0}{reason}, but found .\", expectedItems)\n .Then\n .WithExpectation(\"Expected {context:collection} to be equal to {0}{reason}, \", expectedItems, chain => chain\n .Given(() => Subject.ConvertOrCastToCollection())\n .AssertCollectionsHaveSameCount(expectedItems.Count)\n .Then\n .AssertCollectionsHaveSameItems(expectedItems, (a, e) => a.IndexOfFirstDifferenceWith(e, equalityComparison)));\n }\n\n private static string GetExpressionOrderString(Expression> propertyExpression)\n {\n string orderString = propertyExpression.GetMemberPath().ToString();\n\n return orderString is \"\\\"\\\"\" ? string.Empty : \"by \" + orderString;\n }\n\n private static Type GetType(TType o)\n {\n return o is Type t ? t : o.GetType();\n }\n\n private static bool HasPredecessor(T successor, TCollection subject)\n {\n return !ReferenceEquals(subject.First(), successor);\n }\n\n private static bool HasSuccessor(T predecessor, TCollection subject)\n {\n return !ReferenceEquals(subject.Last(), predecessor);\n }\n\n private static T PredecessorOf(T successor, TCollection subject)\n {\n IList collection = subject.ConvertOrCastToList();\n int index = collection.IndexOf(successor);\n return index > 0 ? collection[index - 1] : default;\n }\n\n private static IEnumerable RepeatAsManyAsIterator(TExpectation value, IEnumerable enumerable)\n {\n using IEnumerator enumerator = enumerable.GetEnumerator();\n\n while (enumerator.MoveNext())\n {\n yield return value;\n }\n }\n\n private static T SuccessorOf(T predecessor, TCollection subject)\n {\n IList collection = subject.ConvertOrCastToList();\n int index = collection.IndexOf(predecessor);\n return index < (collection.Count - 1) ? collection[index + 1] : default;\n }\n\n private string[] CollectFailuresFromInspectors(IEnumerable> elementInspectors)\n {\n string[] collectionFailures;\n\n using (var collectionScope = new AssertionScope())\n {\n int index = 0;\n\n foreach ((T element, Action inspector) in Subject.Zip(elementInspectors,\n (element, inspector) => (element, inspector)))\n {\n string[] inspectorFailures;\n\n using (var itemScope = new AssertionScope())\n {\n inspector(element);\n inspectorFailures = itemScope.Discard();\n }\n\n if (inspectorFailures.Length > 0)\n {\n // Adding one tab and removing trailing dot to allow nested SatisfyRespectively\n string failures = string.Join(Environment.NewLine,\n inspectorFailures.Select(x => x.IndentLines().TrimEnd('.')));\n\n collectionScope.AddPreFormattedFailure($\"At index {index}:{Environment.NewLine}{failures}\");\n }\n\n index++;\n }\n\n collectionFailures = collectionScope.Discard();\n }\n\n return collectionFailures;\n }\n\n private bool IsValidProperty(Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because,\n object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(propertyExpression, nameof(propertyExpression),\n \"Cannot assert collection ordering without specifying a property.\");\n\n propertyExpression.ValidateMemberPath();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:collection} to be ordered by {0}{reason} but found .\",\n () => propertyExpression.GetMemberPath());\n\n return assertionChain.Succeeded;\n }\n\n private AndConstraint NotBeOrderedBy(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n string because,\n object[] becauseArgs)\n {\n if (IsValidProperty(propertyExpression, because, becauseArgs))\n {\n ICollection unordered = Subject.ConvertOrCastToCollection();\n\n IOrderedEnumerable expectation = GetOrderedEnumerable(\n propertyExpression,\n comparer,\n direction,\n unordered);\n\n assertionChain\n .ForCondition(!unordered.SequenceEqual(expectation))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} {0} to not be ordered {1}{reason} and not result in {2}.\",\n () => Subject, () => GetExpressionOrderString(propertyExpression), () => expectation);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Expects the current collection to have all elements in the specified .\n /// Elements are compared using their implementation.\n /// \n private AndConstraint> BeInOrder(\n IComparer comparer, SortOrder expectedOrder, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n string sortOrder = expectedOrder == SortOrder.Ascending ? \"ascending\" : \"descending\";\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:collection}} to be in {sortOrder} order{{reason}}, but found .\");\n\n IOrderedEnumerable ordering = EmptyOrderedEnumerable;\n\n if (assertionChain.Succeeded)\n {\n IList actualItems = Subject.ConvertOrCastToList();\n\n ordering = expectedOrder == SortOrder.Ascending\n ? actualItems.OrderBy(item => item, comparer)\n : actualItems.OrderByDescending(item => item, comparer);\n\n T[] orderedItems = ordering.ToArray();\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n for (int index = 0; index < orderedItems.Length; index++)\n {\n if (!areSameOrEqual(actualItems[index], orderedItems[index]))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:collection} to be in \" + sortOrder +\n \" order{reason}, but found {0} where item at index {1} is in wrong order.\",\n actualItems, index);\n\n return new AndConstraint>(\n new SubsequentOrderingAssertions(Subject, EmptyOrderedEnumerable, assertionChain));\n }\n }\n }\n\n return new AndConstraint>(\n new SubsequentOrderingAssertions(Subject, ordering, assertionChain));\n }\n\n /// \n /// Asserts the current collection does not have all elements in ascending order. Elements are compared\n /// using their implementation.\n /// \n private AndConstraint NotBeInOrder(IComparer comparer, SortOrder order,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n string sortOrder = order == SortOrder.Ascending ? \"ascending\" : \"descending\";\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Did not expect {{context:collection}} to be in {sortOrder} order{{reason}}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n IList actualItems = Subject.ConvertOrCastToList();\n\n T[] orderedItems = order == SortOrder.Ascending\n ? actualItems.OrderBy(item => item, comparer).ToArray()\n : actualItems.OrderByDescending(item => item, comparer).ToArray();\n\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n bool itemsAreUnordered = actualItems\n .Where((actualItem, index) => !areSameOrEqual(actualItem, orderedItems[index]))\n .Any();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(itemsAreUnordered)\n .FailWith(\n \"Did not expect {context:collection} to be in \" + sortOrder + \" order{reason}, but found {0}.\",\n actualItems);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\n \"Equals is not part of Awesome Assertions. Did you mean BeSameAs(), Equal(), or BeEquivalentTo() instead?\");\n\n private static int IndexOf(IList items, T item, int startIndex)\n {\n Func comparer = ObjectExtensions.GetComparer();\n\n for (; startIndex < items.Count; startIndex++)\n {\n if (comparer(items[startIndex], item))\n {\n startIndex++;\n return startIndex;\n }\n }\n\n return -1;\n }\n\n private static int ConsecutiveItemCount(IList actualItems, IList expectedItems, int startIndex)\n {\n for (var index = 1; index < expectedItems.Count; index++)\n {\n T unexpectedItem = expectedItems[index];\n\n int previousSubjectIndex = startIndex;\n startIndex = IndexOf(actualItems, unexpectedItem, startIndex: startIndex);\n\n if (startIndex == -1 || !previousSubjectIndex.IsConsecutiveTo(startIndex))\n {\n return index;\n }\n }\n\n return expectedItems.Count;\n }\n\n private protected static IComparer GetComparer() =>\n typeof(TItem) == typeof(string) ? (IComparer)StringComparer.Ordinal : Comparer.Default;\n\n private static IOrderedEnumerable EmptyOrderedEnumerable =>\n#if NET8_0_OR_GREATER\n Enumerable.Empty().Order();\n#else\n Enumerable.Empty().OrderBy(x => x);\n#endif\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/GenericDictionaryAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Collections;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class GenericDictionaryAssertions\n : GenericDictionaryAssertions>\n where TCollection : IEnumerable>\n{\n public GenericDictionaryAssertions(TCollection keyValuePairs, AssertionChain assertionChain)\n : base(keyValuePairs, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class GenericDictionaryAssertions\n : GenericCollectionAssertions, TAssertions>\n where TCollection : IEnumerable>\n where TAssertions : GenericDictionaryAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public GenericDictionaryAssertions(TCollection keyValuePairs, AssertionChain assertionChain)\n : base(keyValuePairs, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n #region Equal\n\n /// \n /// Asserts that the current dictionary contains all the same key-value pairs as the\n /// specified dictionary. Keys and values are compared using\n /// their implementation.\n /// \n /// The expected dictionary\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Equal(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : IEnumerable>\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare dictionary with .\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to be equal to {0}{reason}, but found {1}.\", expected, Subject);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable subjectKeys = GetKeys(Subject);\n IEnumerable expectedKeys = GetKeys(expected);\n IEnumerable missingKeys = expectedKeys.Except(subjectKeys);\n IEnumerable additionalKeys = subjectKeys.Except(expectedKeys);\n\n if (missingKeys.Any())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to be equal to {0}{reason}, but could not find keys {1}.\", expected,\n missingKeys);\n }\n\n if (additionalKeys.Any())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to be equal to {0}{reason}, but found additional keys {1}.\",\n expected,\n additionalKeys);\n }\n\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n foreach (var key in expectedKeys)\n {\n assertionChain\n .ForCondition(areSameOrEqual(GetValue(Subject, key), GetValue(expected, key)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to be equal to {0}{reason}, but {1} differs at key {2}.\",\n expected, Subject, key);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts the current dictionary not to contain all the same key-value pairs as the\n /// specified dictionary. Keys and values are compared using\n /// their implementation.\n /// \n /// The unexpected dictionary\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotEqual(T unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : IEnumerable>\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), \"Cannot compare dictionary with .\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected dictionaries not to be equal{reason}, but found {0}.\", Subject);\n\n if (assertionChain.Succeeded)\n {\n if (ReferenceEquals(Subject, unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected dictionaries not to be equal{reason}, but they both reference the same object.\");\n }\n\n IEnumerable subjectKeys = GetKeys(Subject);\n IEnumerable unexpectedKeys = GetKeys(unexpected);\n IEnumerable missingKeys = unexpectedKeys.Except(subjectKeys);\n IEnumerable additionalKeys = subjectKeys.Except(unexpectedKeys);\n\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n bool foundDifference = missingKeys.Any()\n || additionalKeys.Any()\n || subjectKeys.Any(key => !areSameOrEqual(GetValue(Subject, key), GetValue(unexpected, key)));\n\n if (!foundDifference)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect dictionaries {0} and {1} to be equal{reason}.\", unexpected, Subject);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n /// \n /// Asserts that two dictionaries are equivalent.\n /// \n /// \n /// The values within the dictionaries are equivalent when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of the values in the dictionaries are ignored as long as both dictionaries contain the same keys and\n /// the values for each key are structurally equivalent. Notice that actual behavior is determined by the global\n /// defaults managed by the class.\n /// \n /// The expected element.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(TExpectation expectation,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeEquivalentTo(expectation, options => options, because, becauseArgs);\n }\n\n /// \n /// Asserts that two dictionaries are equivalent.\n /// \n /// \n /// The values within the dictionaries are equivalent when both object graphs have equally named properties with the same\n /// value, irrespective of the type of those objects. Two properties are also equal if one type can be converted to another\n /// and the result is equal.\n /// The type of the values in the dictionaries are ignored as long as both dictionaries contain the same keys and\n /// the values for each key are structurally equivalent. Notice that actual behavior is determined by the global\n /// defaults managed by the class.\n /// \n /// The expected element.\n /// \n /// A reference to the configuration object that can be used\n /// to influence the way the object graphs are compared. You can also provide an alternative instance of the\n /// class. The global defaults are determined by the\n /// class.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeEquivalentTo(TExpectation expectation,\n Func, EquivalencyOptions> config,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(config);\n\n EquivalencyOptions options = config(AssertionConfiguration.Current.Equivalency.CloneDefaults());\n\n var context =\n new EquivalencyValidationContext(Node.From(() => CurrentAssertionChain.CallerIdentifier), options)\n {\n Reason = new Reason(because, becauseArgs),\n TraceWriter = options.TraceWriter\n };\n\n var comparands = new Comparands\n {\n Subject = Subject,\n Expectation = expectation,\n CompileTimeType = typeof(TExpectation),\n };\n\n new EquivalencyValidator().AssertEquality(comparands, context);\n\n return new AndConstraint((TAssertions)this);\n }\n\n #region ContainKey\n\n /// \n /// Asserts that the dictionary contains the specified key.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The expected key\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public WhoseValueConstraint ContainKey(TKey expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n AndConstraint andConstraint = ContainKeys([expected], because, becauseArgs);\n\n _ = TryGetValue(Subject, expected, out TValue value);\n\n return new WhoseValueConstraint(andConstraint.And, value);\n }\n\n /// \n /// Asserts that the dictionary contains all of the specified keys.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The expected keys\n public AndConstraint ContainKeys(params TKey[] expected)\n {\n return ContainKeys(expected, string.Empty);\n }\n\n /// \n /// Asserts that the dictionary contains all of the specified keys.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The expected keys\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint ContainKeys(IEnumerable expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot verify key containment against a collection of keys\");\n\n ICollection expectedKeys = expected.ConvertOrCastToCollection();\n Guard.ThrowIfArgumentIsEmpty(expectedKeys, nameof(expected), \"Cannot verify key containment against an empty sequence\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain keys {0}{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable missingKeys = expectedKeys.Where(key => !ContainsKey(Subject, key));\n\n if (missingKeys.Any())\n {\n if (expectedKeys.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to contain keys {1}{reason}, but could not find {2}.\",\n Subject,\n expected, missingKeys);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to contain key {1}{reason}.\", Subject,\n expected.First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region NotContainKey\n\n /// \n /// Asserts that the current dictionary does not contain the specified key.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The unexpected key\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainKey(TKey unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} not to contain key {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded && ContainsKey(Subject, unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} not to contain key {1}{reason}, but found it anyhow.\", Subject,\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the dictionary does not contain any of the specified keys.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The unexpected keys\n public AndConstraint NotContainKeys(params TKey[] unexpected)\n {\n return NotContainKeys(unexpected, string.Empty);\n }\n\n /// \n /// Asserts that the dictionary does not contain any of the specified keys.\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// \n /// The unexpected keys\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotContainKeys(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected),\n \"Cannot verify key containment against a collection of keys\");\n\n ICollection unexpectedKeys = unexpected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(unexpectedKeys, nameof(unexpected),\n \"Cannot verify key containment against an empty sequence\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to not contain keys {0}{reason}, but found .\", unexpectedKeys);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable foundKeys = unexpectedKeys.Where(key => ContainsKey(Subject, key));\n\n if (foundKeys.Any())\n {\n if (unexpectedKeys.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to not contain keys {1}{reason}, but found {2}.\", Subject,\n unexpectedKeys, foundKeys);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to not contain key {1}{reason}.\", Subject,\n unexpectedKeys.First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region ContainValue\n\n /// \n /// Asserts that the dictionary contains the specified value. Values are compared using\n /// their implementation.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint ContainValue(TValue expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n AndWhichConstraint> result =\n ContainValues([expected], because, becauseArgs);\n\n return new AndWhichConstraint(result.And, result.Subject);\n }\n\n /// \n /// Asserts that the dictionary contains all of the specified values. Values are compared using\n /// their implementation.\n /// \n /// The expected values\n public AndWhichConstraint> ContainValues(params TValue[] expected)\n {\n return ContainValues(expected, string.Empty);\n }\n\n /// \n /// Asserts that the dictionary contains all the specified values. Values are compared using\n /// their implementation.\n /// \n /// The expected values\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint> ContainValues(IEnumerable expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot verify value containment against a collection of values\");\n\n ICollection expectedValues = expected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(expectedValues, nameof(expected),\n \"Cannot verify value containment against an empty sequence\");\n\n var missingValues = new List(expectedValues);\n\n Dictionary matches = new();\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain values {0}{reason}, but found .\", expected);\n\n if (assertionChain.Succeeded)\n {\n foreach (var pair in Subject!)\n {\n if (missingValues.Contains(pair.Value))\n {\n matches.Add(pair.Key, pair.Value);\n missingValues.Remove(pair.Value);\n }\n }\n\n if (missingValues.Count > 0)\n {\n if (expectedValues.Count == 1)\n {\n assertionChain.FailWith(\n \"Expected {context:dictionary} {0} to contain value {1}{reason}.\",\n Subject, expectedValues.Single());\n }\n else\n {\n assertionChain.FailWith(\n \"Expected {context:dictionary} {0} to contain values {1}{reason}, but could not find {2}.\",\n Subject, expectedValues, missingValues.Count == 1 ? missingValues.Single() : missingValues);\n }\n }\n }\n\n string postfix = matches.Count > 0 ? \"[\" + string.Join(\" and \", matches.Keys) + \"]\" : \"\";\n\n return new AndWhichConstraint>((TAssertions)this, matches.Values, assertionChain, postfix);\n }\n\n #endregion\n\n #region NotContainValue\n\n /// \n /// Asserts that the current dictionary does not contain the specified value.\n /// Values are compared using their implementation.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContainValue(TValue unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} not to contain value {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded && GetValues(Subject).Contains(unexpected))\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} not to contain value {1}{reason}, but found it anyhow.\", Subject,\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the dictionary does not contain any of the specified values. Values are compared using\n /// their implementation.\n /// \n /// The unexpected values\n public AndConstraint NotContainValues(params TValue[] unexpected)\n {\n return NotContainValues(unexpected, string.Empty);\n }\n\n /// \n /// Asserts that the dictionary does not contain any of the specified values. Values are compared using\n /// their implementation.\n /// \n /// The unexpected values\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotContainValues(IEnumerable unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpected, nameof(unexpected),\n \"Cannot verify value containment against a collection of values\");\n\n ICollection unexpectedValues = unexpected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(unexpectedValues, nameof(unexpected),\n \"Cannot verify value containment with an empty sequence\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to not contain values {0}{reason}, but found .\", unexpected);\n\n if (assertionChain.Succeeded)\n {\n IEnumerable foundValues = unexpectedValues.Intersect(GetValues(Subject));\n\n if (foundValues.Any())\n {\n if (unexpectedValues.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to not contain value {1}{reason}, but found {2}.\",\n Subject,\n unexpected, foundValues);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to not contain value {1}{reason}.\", Subject,\n unexpected.First());\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region Contain\n\n /// \n /// Asserts that the current dictionary contains the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The expected key/value pairs.\n public AndConstraint Contain(params KeyValuePair[] expected)\n {\n return Contain(expected, string.Empty);\n }\n\n /// \n /// Asserts that the current dictionary contains the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The expected key/value pairs.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\", Justification = \"Needs refactoring\")]\n public new AndConstraint Contain(IEnumerable> expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected), \"Cannot compare dictionary with .\");\n\n ICollection> expectedKeyValuePairs = expected.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(expectedKeyValuePairs, nameof(expected),\n \"Cannot verify key containment against an empty collection of key/value pairs\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain key/value pairs {0}{reason}, but dictionary is .\",\n expected);\n\n if (assertionChain.Succeeded)\n {\n TKey[] expectedKeys = expectedKeyValuePairs.Select(keyValuePair => keyValuePair.Key).ToArray();\n IEnumerable missingKeys = expectedKeys.Where(key => !ContainsKey(Subject, key));\n\n if (missingKeys.Any())\n {\n if (expectedKeyValuePairs.Count > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to contain key(s) {1}{reason}, but could not find keys {2}.\",\n Subject,\n expectedKeys, missingKeys);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} {0} to contain key {1}{reason}.\", Subject,\n expectedKeys[0]);\n }\n }\n\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n KeyValuePair[] keyValuePairsNotSameOrEqualInSubject = expectedKeyValuePairs\n .Where(keyValuePair => !areSameOrEqual(GetValue(Subject, keyValuePair.Key), keyValuePair.Value)).ToArray();\n\n if (keyValuePairsNotSameOrEqualInSubject.Length > 0)\n {\n if (keyValuePairsNotSameOrEqualInSubject.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:dictionary} to contain {0}{reason}, but {context:dictionary} differs at keys {1}.\",\n expectedKeyValuePairs, keyValuePairsNotSameOrEqualInSubject.Select(keyValuePair => keyValuePair.Key));\n }\n else\n {\n KeyValuePair expectedKeyValuePair = keyValuePairsNotSameOrEqualInSubject[0];\n TValue actual = GetValue(Subject, expectedKeyValuePair.Key);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain value {0} at key {1}{reason}, but found {2}.\",\n expectedKeyValuePair.Value, expectedKeyValuePair.Key, actual);\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current dictionary contains the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The expected \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public new AndConstraint Contain(KeyValuePair expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return Contain(expected.Key, expected.Value, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current dictionary contains the specified for the supplied\n /// .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The key for which to validate the value\n /// The value to validate\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Contain(TKey key, TValue value,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain value {0} at key {1}{reason}, but dictionary is .\",\n value, key);\n\n if (assertionChain.Succeeded)\n {\n if (TryGetValue(Subject, key, out TValue actual))\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n assertionChain\n .ForCondition(areSameOrEqual(actual, value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain value {0} at key {1}{reason}, but found {2}.\", value, key,\n actual);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to contain value {0} at key {1}{reason}, but the key was not found.\",\n value,\n key);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region NotContain\n\n /// \n /// Asserts that the current dictionary does not contain the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The unexpected key/value pairs\n public AndConstraint NotContain(params KeyValuePair[] items)\n {\n return NotContain(items, string.Empty);\n }\n\n /// \n /// Asserts that the current dictionary does not contain the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The unexpected key/value pairs\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public new AndConstraint NotContain(IEnumerable> items,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(items, nameof(items), \"Cannot compare dictionary with .\");\n\n ICollection> keyValuePairs = items.ConvertOrCastToCollection();\n\n Guard.ThrowIfArgumentIsEmpty(keyValuePairs, nameof(items),\n \"Cannot verify key containment against an empty collection of key/value pairs\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} to not contain key/value pairs {0}{reason}, but dictionary is .\",\n items);\n\n if (assertionChain.Succeeded)\n {\n KeyValuePair[] keyValuePairsFound =\n keyValuePairs.Where(keyValuePair => ContainsKey(Subject, keyValuePair.Key)).ToArray();\n\n if (keyValuePairsFound.Length > 0)\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n KeyValuePair[] keyValuePairsSameOrEqualInSubject = keyValuePairsFound\n .Where(keyValuePair => areSameOrEqual(GetValue(Subject, keyValuePair.Key), keyValuePair.Value)).ToArray();\n\n if (keyValuePairsSameOrEqualInSubject.Length > 0)\n {\n if (keyValuePairsSameOrEqualInSubject.Length > 1)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:dictionary} to not contain key/value pairs {0}{reason}, but found them anyhow.\",\n keyValuePairs);\n }\n else\n {\n KeyValuePair keyValuePair = keyValuePairsSameOrEqualInSubject[0];\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:dictionary} to not contain value {0} at key {1}{reason}, but found it anyhow.\",\n keyValuePair.Value, keyValuePair.Key);\n }\n }\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current dictionary does not contain the specified .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The unexpected \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public new AndConstraint NotContain(KeyValuePair item,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotContain(item.Key, item.Value, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current dictionary does not contain the specified for the\n /// supplied .\n /// Key comparison will honor the equality comparer of the dictionary when applicable.\n /// Values are compared using their implementation.\n /// \n /// The key for which to validate the value\n /// The value to validate\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotContain(TKey key, TValue value,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} not to contain value {0} at key {1}{reason}, but dictionary is .\",\n value, key);\n\n if (assertionChain.Succeeded && TryGetValue(Subject, key, out TValue actual))\n {\n assertionChain\n .ForCondition(!ObjectExtensions.GetComparer()(actual, value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:dictionary} not to contain value {0} at key {1}{reason}, but found it anyhow.\",\n value, key);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"dictionary\";\n\n private static IEnumerable GetKeys(TCollection collection) =>\n collection.GetKeys();\n\n private static IEnumerable GetKeys(T collection)\n where T : IEnumerable> =>\n collection.GetKeys();\n\n private static IEnumerable GetValues(TCollection collection) =>\n collection.GetValues();\n\n private static bool ContainsKey(TCollection collection, TKey key) =>\n collection.ContainsKey(key);\n\n private static bool TryGetValue(TCollection collection, TKey key, out TValue value) =>\n collection.TryGetValue(key, out value);\n\n private static TValue GetValue(TCollection collection, TKey key) =>\n collection.GetValue(key);\n\n private static TValue GetValue(T collection, TKey key)\n where T : IEnumerable> =>\n collection.GetValue(key);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Comparands.cs", "using System;\nusing AwesomeAssertions.Common;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency;\n\npublic class Comparands\n{\n private Type compileTimeType;\n\n public Comparands()\n {\n }\n\n public Comparands(object subject, object expectation, Type compileTimeType)\n {\n this.compileTimeType = compileTimeType;\n Subject = subject;\n Expectation = expectation;\n }\n\n /// \n /// Gets the value of the subject object graph.\n /// \n public object Subject { get; set; }\n\n /// \n /// Gets the value of the expected object graph.\n /// \n public object Expectation { get; set; }\n\n public Type CompileTimeType\n {\n get\n {\n return compileTimeType != typeof(object) || Expectation is null ? compileTimeType : RuntimeType;\n }\n\n // SMELL: Do we really need this? Can we replace it by making Comparands generic or take a constructor parameter?\n set => compileTimeType = value;\n }\n\n /// \n /// Gets the run-time type of the current expectation object.\n /// \n public Type RuntimeType\n {\n get\n {\n if (Expectation is not null)\n {\n return Expectation.GetType();\n }\n\n return CompileTimeType;\n }\n }\n\n /// \n /// Returns either the run-time or compile-time type of the expectation based on the options provided by the caller.\n /// \n /// \n /// If the expectation is a nullable type, it should return the type of the wrapped object.\n /// \n public Type GetExpectedType(IEquivalencyOptions options)\n {\n Type type = options.UseRuntimeTyping ? RuntimeType : CompileTimeType;\n\n return type.NullableOrActualType();\n }\n\n public override string ToString()\n {\n return Invariant($\"{{Subject={Subject}, Expectation={Expectation}}}\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/CyclicReferencesSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class CyclicReferencesSpecs\n{\n [Fact]\n public void Graphs_up_to_the_maximum_depth_are_supported()\n {\n // Arrange\n var actual = new ClassWithFiniteRecursiveProperty(recursiveDepth: 10);\n var expectation = new ClassWithFiniteRecursiveProperty(recursiveDepth: 10);\n\n // Act/Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Graphs_deeper_than_the_maximum_depth_are_not_supported()\n {\n // Arrange\n var actual = new ClassWithFiniteRecursiveProperty(recursiveDepth: 11);\n var expectation = new ClassWithFiniteRecursiveProperty(recursiveDepth: 11);\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\"*maximum*depth*10*\");\n }\n\n [Fact]\n public void By_default_cyclic_references_are_not_valid()\n {\n // Arrange\n var cyclicRoot = new CyclicRoot\n {\n Text = \"Root\"\n };\n\n cyclicRoot.Level = new CyclicLevel1\n {\n Text = \"Level1\",\n Root = cyclicRoot\n };\n\n var cyclicRootDto = new CyclicRootDto\n {\n Text = \"Root\"\n };\n\n cyclicRootDto.Level = new CyclicLevel1Dto\n {\n Text = \"Level1\",\n Root = cyclicRootDto\n };\n\n // Act\n Action act = () => cyclicRoot.Should().BeEquivalentTo(cyclicRootDto);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected property cyclicRoot.Level.Root to be*but it contains a cyclic reference*\");\n }\n\n [Fact]\n public void The_cyclic_reference_itself_will_be_compared_using_simple_equality()\n {\n // Arrange\n var expectedChild = new Child\n {\n Stuff = 1\n };\n\n var expectedParent = new Parent\n {\n Child1 = expectedChild\n };\n\n expectedChild.Parent = expectedParent;\n\n var actualChild = new Child\n {\n Stuff = 1\n };\n\n var actualParent = new Parent\n {\n Child1 = actualChild\n };\n\n // Act\n var act = () => actualParent.Should().BeEquivalentTo(expectedParent, options => options.IgnoringCyclicReferences());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property actualParent.Child1.Parent to refer to*but found*null*\");\n }\n\n [Fact]\n public void The_cyclic_reference_can_be_ignored_if_the_comparands_point_to_the_same_object()\n {\n // Arrange\n var expectedChild = new Child\n {\n Stuff = 1\n };\n\n var expectedParent = new Parent\n {\n Child1 = expectedChild\n };\n\n expectedChild.Parent = expectedParent;\n\n var actualChild = new Child\n {\n Stuff = 1\n };\n\n var actualParent = new Parent\n {\n Child1 = actualChild\n };\n\n // Connect this child to the same parent as the expectation child\n actualChild.Parent = expectedParent;\n\n // Act\n actualParent.Should().BeEquivalentTo(expectedParent, options => options.IgnoringCyclicReferences());\n }\n\n [Fact]\n public void Two_graphs_with_ignored_cyclic_references_can_be_compared()\n {\n // Arrange\n var actual = new Parent();\n actual.Child1 = new Child(actual, 1);\n actual.Child2 = new Child(actual);\n\n var expected = new Parent();\n expected.Child1 = new Child(expected);\n expected.Child2 = new Child(expected);\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, x => x\n .Excluding(y => y.Child1)\n .IgnoringCyclicReferences());\n }\n\n private class Parent\n {\n public Child Child1 { get; set; }\n\n [UsedImplicitly]\n public Child Child2 { get; set; }\n }\n\n private class Child\n {\n public Child(Parent parent = null, int stuff = 0)\n {\n Parent = parent;\n Stuff = stuff;\n }\n\n [UsedImplicitly]\n public Parent Parent { get; set; }\n\n [UsedImplicitly]\n public int Stuff { get; set; }\n }\n\n [Fact]\n public void Nested_properties_that_are_null_are_not_treated_as_cyclic_references()\n {\n // Arrange\n var actual = new CyclicRoot\n {\n Text = null,\n Level = new CyclicLevel1\n {\n Text = null,\n Root = null\n }\n };\n\n var expectation = new CyclicRootDto\n {\n Text = null,\n Level = new CyclicLevel1Dto\n {\n Text = null,\n Root = null\n }\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Equivalent_value_objects_are_not_treated_as_cyclic_references()\n {\n // Arrange\n var actual = new CyclicRootWithValueObject\n {\n Value = new ValueObject(\"MyValue\"),\n Level = new CyclicLevelWithValueObject\n {\n Value = new ValueObject(\"MyValue\"),\n Root = null\n }\n };\n\n var expectation = new CyclicRootWithValueObject\n {\n Value = new ValueObject(\"MyValue\"),\n Level = new CyclicLevelWithValueObject\n {\n Value = new ValueObject(\"MyValue\"),\n Root = null\n }\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Cyclic_references_do_not_trigger_stack_overflows()\n {\n // Arrange\n var recursiveClass1 = new ClassWithInfinitelyRecursiveProperty();\n var recursiveClass2 = new ClassWithInfinitelyRecursiveProperty();\n\n // Act\n Action act =\n () => recursiveClass1.Should().BeEquivalentTo(recursiveClass2);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Cyclic_references_can_be_ignored_in_equivalency_assertions()\n {\n // Arrange\n var recursiveClass1 = new ClassWithFiniteRecursiveProperty(15);\n var recursiveClass2 = new ClassWithFiniteRecursiveProperty(15);\n\n // Act / Assert\n recursiveClass1.Should().BeEquivalentTo(recursiveClass2, options => options.AllowingInfiniteRecursion());\n }\n\n [Fact]\n public void Allowing_infinite_recursion_is_reported_in_the_failure_message()\n {\n // Arrange\n var recursiveClass1 = new ClassWithFiniteRecursiveProperty(1);\n var recursiveClass2 = new ClassWithFiniteRecursiveProperty(2);\n\n // Act\n Action act = () => recursiveClass1.Should().BeEquivalentTo(recursiveClass2,\n options => options.AllowingInfiniteRecursion());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Recurse indefinitely*\");\n }\n\n [Fact]\n public void Can_ignore_cyclic_references_for_inequivalency_assertions()\n {\n // Arrange\n var recursiveClass1 = new ClassWithFiniteRecursiveProperty(15);\n var recursiveClass2 = new ClassWithFiniteRecursiveProperty(16);\n\n // Act / Assert\n recursiveClass1.Should().NotBeEquivalentTo(recursiveClass2,\n options => options.AllowingInfiniteRecursion());\n }\n\n [Fact]\n public void Can_detect_cyclic_references_in_enumerables()\n {\n // Act\n var instance1 = new SelfReturningEnumerable();\n var instance2 = new SelfReturningEnumerable();\n\n var actual = new List\n {\n instance1,\n instance2\n };\n\n // Assert\n Action act = () => actual.Should().BeEquivalentTo(\n [new SelfReturningEnumerable(), new SelfReturningEnumerable()],\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*we want to test the failure message*cyclic reference*\");\n }\n\n public class SelfReturningEnumerable : IEnumerable\n {\n public IEnumerator GetEnumerator()\n {\n yield return this;\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n }\n\n [Fact]\n public void Can_detect_cyclic_references_in_nested_objects_referring_to_the_root()\n {\n // Arrange\n var company1 = new MyCompany\n {\n Name = \"Company\"\n };\n\n var user1 = new MyUser\n {\n Name = \"User\",\n Company = company1\n };\n\n var logo1 = new MyCompanyLogo\n {\n Url = \"blank\",\n Company = company1,\n CreatedBy = user1\n };\n\n company1.Logo = logo1;\n\n var company2 = new MyCompany\n {\n Name = \"Company\"\n };\n\n var user2 = new MyUser\n {\n Name = \"User\",\n Company = company2\n };\n\n var logo2 = new MyCompanyLogo\n {\n Url = \"blank\",\n Company = company2,\n CreatedBy = user2\n };\n\n company2.Logo = logo2;\n\n // Act / Assert\n company1.Should().BeEquivalentTo(company2, o => o.IgnoringCyclicReferences());\n }\n\n [Fact]\n public void Allow_ignoring_cyclic_references_in_value_types_compared_by_members()\n {\n // Arrange\n var expectation = new ValueTypeCircularDependency\n {\n Title = \"First\"\n };\n\n var second = new ValueTypeCircularDependency\n {\n Title = \"Second\",\n Previous = expectation\n };\n\n expectation.Next = second;\n\n var subject = new ValueTypeCircularDependency\n {\n Title = \"First\"\n };\n\n var secondCopy = new ValueTypeCircularDependency\n {\n Title = \"SecondDifferent\",\n Previous = subject\n };\n\n subject.Next = secondCopy;\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .ComparingByMembers()\n .IgnoringCyclicReferences());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*subject.Next.Title*SecondDifferent*Second*\")\n .Which.Message.Should().NotContain(\"maximum recursion depth was reached\");\n }\n\n private class ValueTypeCircularDependency\n {\n public string Title { get; set; }\n\n public ValueTypeCircularDependency Previous { get; set; }\n\n public ValueTypeCircularDependency Next { get; set; }\n\n public override bool Equals(object obj)\n {\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n return obj is ValueTypeCircularDependency baseObj && baseObj.Title == Title;\n }\n\n public override int GetHashCode()\n {\n return Title.GetHashCode();\n }\n }\n\n private class ClassWithInfinitelyRecursiveProperty\n {\n public ClassWithInfinitelyRecursiveProperty Self\n {\n get { return new ClassWithInfinitelyRecursiveProperty(); }\n }\n }\n\n private class ClassWithFiniteRecursiveProperty\n {\n private readonly int depth;\n\n public ClassWithFiniteRecursiveProperty(int recursiveDepth)\n {\n depth = recursiveDepth;\n }\n\n public ClassWithFiniteRecursiveProperty Self\n {\n get\n {\n return depth > 0\n ? new ClassWithFiniteRecursiveProperty(depth - 1)\n : null;\n }\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/SelectMemberByPathSelectionRule.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\ninternal abstract class SelectMemberByPathSelectionRule : IMemberSelectionRule\n{\n public virtual bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n var currentPath = RemoveRootIndexQualifier(currentNode.Expectation.PathAndName);\n var members = selectedMembers.ToList();\n AddOrRemoveMembersFrom(members, currentNode, currentPath, context);\n\n return members;\n }\n\n protected abstract void AddOrRemoveMembersFrom(List selectedMembers,\n INode parent, string parentPath,\n MemberSelectionContext context);\n\n private static string RemoveRootIndexQualifier(string path)\n {\n Match match = new Regex(@\"^\\[[0-9]+]\").Match(path);\n\n if (match.Success)\n {\n path = path.Substring(match.Length);\n }\n\n return path;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/XmlReaderValidator.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Xml;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Xml.Equivalency;\n\ninternal class XmlReaderValidator\n{\n private readonly AssertionChain assertionChain;\n private readonly XmlReader subjectReader;\n private readonly XmlReader expectationReader;\n private XmlIterator subjectIterator;\n private XmlIterator expectationIterator;\n private Node currentNode = Node.CreateRoot();\n\n public XmlReaderValidator(AssertionChain assertionChain, XmlReader subjectReader, XmlReader expectationReader, string because, object[] becauseArgs)\n {\n this.assertionChain = assertionChain;\n assertionChain.BecauseOf(because, becauseArgs);\n\n this.subjectReader = subjectReader;\n this.expectationReader = expectationReader;\n }\n\n public void Validate(bool shouldBeEquivalent)\n {\n Failure failure = Validate();\n\n if (shouldBeEquivalent && failure is not null)\n {\n assertionChain.FailWith(failure.FormatString, failure.FormatParams);\n }\n\n if (!shouldBeEquivalent && failure is null)\n {\n assertionChain.FailWith(\"Did not expect {context:subject} to be equivalent{reason}, but it is.\");\n }\n }\n\n#pragma warning disable MA0051\n private Failure Validate()\n#pragma warning restore MA0051\n {\n if (subjectReader is null && expectationReader is null)\n {\n return null;\n }\n\n Failure failure = ValidateAgainstNulls();\n\n if (failure is not null)\n {\n return failure;\n }\n\n subjectIterator = new XmlIterator(subjectReader);\n expectationIterator = new XmlIterator(expectationReader);\n\n while (!subjectIterator.IsEndOfDocument && !expectationIterator.IsEndOfDocument)\n {\n if (subjectIterator.NodeType != expectationIterator.NodeType)\n {\n var expectation = expectationIterator.NodeType == XmlNodeType.Text\n ? $\"content \\\"{expectationIterator.Value}\\\"\"\n : $\"{expectationIterator.NodeType} \\\"{expectationIterator.LocalName}\\\"\";\n\n var subject = subjectIterator.NodeType == XmlNodeType.Text\n ? $\"content \\\"{subjectIterator.Value}\\\"\"\n : $\"{subjectIterator.NodeType} \\\"{subjectIterator.LocalName}\\\"\";\n\n return new Failure(\n $\"Expected {expectation} in {{context:subject}} at {{0}}{{reason}}, but found {subject}.\",\n currentNode.GetXPath());\n }\n\n#pragma warning disable IDE0010 // The default case handles the many missing cases\n switch (expectationIterator.NodeType)\n#pragma warning restore IDE0010\n {\n case XmlNodeType.Element:\n failure = ValidateStartElement();\n\n if (failure is not null)\n {\n return failure;\n }\n\n // starting new element, add local name to location stack\n // to build XPath info\n currentNode = currentNode.Push(expectationIterator.LocalName);\n\n failure = ValidateAttributes();\n\n if (expectationIterator.IsEmptyElement)\n {\n // The element is already complete. (We will NOT get an EndElement node.)\n // Update node information.\n currentNode = currentNode.Parent;\n }\n\n // check whether empty element and self-closing element needs to be synchronized\n if (subjectIterator.IsEmptyElement && !expectationIterator.IsEmptyElement)\n {\n expectationIterator.MoveToEndElement();\n }\n else if (expectationIterator.IsEmptyElement && !subjectIterator.IsEmptyElement)\n {\n subjectIterator.MoveToEndElement();\n }\n\n break;\n\n case XmlNodeType.EndElement:\n // No need to verify end element, if it doesn't match\n // the start element it isn't valid XML, so the parser\n // would handle that.\n currentNode.Pop();\n currentNode = currentNode.Parent;\n break;\n\n case XmlNodeType.Text:\n failure = ValidateText();\n break;\n\n default:\n throw new NotSupportedException(\n $\"{expectationIterator.NodeType} found at {currentNode.GetXPath()} is not supported for equivalency comparison.\");\n }\n\n if (failure is not null)\n {\n return failure;\n }\n\n subjectIterator.Read();\n expectationIterator.Read();\n }\n\n if (!expectationIterator.IsEndOfDocument)\n {\n return new Failure(\n \"Expected {0} in {context:subject}{reason}, but found end of document.\",\n expectationIterator.LocalName);\n }\n\n if (!subjectIterator.IsEndOfDocument)\n {\n return new Failure(\n \"Expected end of document in {context:subject}{reason}, but found {0}.\",\n subjectIterator.LocalName);\n }\n\n return null;\n }\n\n private Failure ValidateAttributes()\n {\n IList expectedAttributes = expectationIterator.GetAttributes();\n IList subjectAttributes = subjectIterator.GetAttributes();\n\n foreach (AttributeData subjectAttribute in subjectAttributes)\n {\n AttributeData expectedAttribute = expectedAttributes.SingleOrDefault(\n ea => ea.NamespaceUri == subjectAttribute.NamespaceUri\n && ea.LocalName == subjectAttribute.LocalName);\n\n if (expectedAttribute is null)\n {\n return new Failure(\n \"Did not expect to find attribute {0} in {context:subject} at {1}{reason}.\",\n subjectAttribute.QualifiedName, currentNode.GetXPath());\n }\n\n if (subjectAttribute.Value != expectedAttribute.Value)\n {\n return new Failure(\n \"Expected attribute {0} in {context:subject} at {1} to have value {2}{reason}, but found {3}.\",\n subjectAttribute.LocalName, currentNode.GetXPath(), expectedAttribute.Value, subjectAttribute.Value);\n }\n }\n\n if (subjectAttributes.Count != expectedAttributes.Count)\n {\n AttributeData missingAttribute = expectedAttributes.First(ea =>\n !subjectAttributes.Any(sa =>\n ea.NamespaceUri == sa.NamespaceUri\n && sa.LocalName == ea.LocalName));\n\n return new Failure(\n \"Expected attribute {0} in {context:subject} at {1}{reason}, but found none.\",\n missingAttribute.LocalName, currentNode.GetXPath());\n }\n\n return null;\n }\n\n private Failure ValidateStartElement()\n {\n if (subjectIterator.LocalName != expectationIterator.LocalName)\n {\n return new Failure(\n \"Expected local name of element in {context:subject} at {0} to be {1}{reason}, but found {2}.\",\n currentNode.GetXPath(), expectationIterator.LocalName, subjectIterator.LocalName);\n }\n\n if (subjectIterator.NamespaceUri != expectationIterator.NamespaceUri)\n {\n return new Failure(\n \"Expected namespace of element {0} in {context:subject} at {1} to be {2}{reason}, but found {3}.\",\n subjectIterator.LocalName, currentNode.GetXPath(), expectationIterator.NamespaceUri,\n subjectIterator.NamespaceUri);\n }\n\n return null;\n }\n\n private Failure ValidateText()\n {\n string subject = subjectIterator.Value;\n string expected = expectationIterator.Value;\n\n if (subject != expected)\n {\n return new Failure(\n \"Expected content to be {0} in {context:subject} at {1}{reason}, but found {2}.\",\n expected, currentNode.GetXPath(), subject);\n }\n\n return null;\n }\n\n private Failure ValidateAgainstNulls()\n {\n if (expectationReader is null != subjectReader is null)\n {\n return new Failure(\n \"Expected {context:subject} to be equivalent to {0}{reason}, but found {1}.\",\n subjectReader, expectationReader);\n }\n\n return null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Configuration/GlobalEquivalencyOptions.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Configuration;\n\npublic class GlobalEquivalencyOptions\n{\n private EquivalencyOptions defaults = new();\n\n /// \n /// Represents a mutable plan consisting of steps that are executed while asserting a (collection of) object(s)\n /// is structurally equivalent to another (collection of) object(s).\n /// \n /// \n /// Members on this property are not thread-safe and should not be invoked from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public EquivalencyPlan Plan { get; } = new();\n\n /// \n /// Allows configuring the defaults used during a structural equivalency assertion.\n /// \n /// \n /// This method is not thread-safe and should not be invoked from within a unit test.\n /// See the docs on how to safely use it.\n /// \n /// \n /// An action that is used to configure the defaults.\n /// \n /// is .\n public void Modify(Func configureOptions)\n {\n Guard.ThrowIfArgumentIsNull(configureOptions);\n\n defaults = configureOptions(defaults);\n }\n\n /// \n /// Creates a clone of the default options and allows the caller to modify them.\n /// \n /// \n /// Can be used by external packages like AwesomeAssertions.DataSets to create a copy of the default equivalency options.\n /// \n [PublicAPI]\n public EquivalencyOptions CloneDefaults()\n {\n return new EquivalencyOptions(defaults);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Node.cs", "using System;\nusing System.Collections;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal class Node : INode\n{\n private static readonly Regex MatchFirstIndex = new(@\"^\\[[0-9]+\\]$\");\n\n private GetSubjectId subjectIdProvider;\n\n private string cachedSubjectId;\n private Pathway subject;\n\n public GetSubjectId GetSubjectId\n {\n get => () => cachedSubjectId ??= subjectIdProvider();\n protected init => subjectIdProvider = value;\n }\n\n public Type Type { get; protected set; }\n\n public Type ParentType { get; protected set; }\n\n public Pathway Subject\n {\n get => subject;\n set\n {\n subject = value;\n\n if (Expectation is null)\n {\n Expectation = value;\n }\n }\n }\n\n public Pathway Expectation { get; protected set; }\n\n public bool IsRoot\n {\n get\n {\n // If the root is a collection, we need treat the objects in that collection as the root of the graph because all options\n // refer to the type of the collection items.\n return Subject.PathAndName.Length == 0 || (RootIsCollection && IsFirstIndex);\n }\n }\n\n private bool IsFirstIndex => MatchFirstIndex.IsMatch(Subject.PathAndName);\n\n public bool RootIsCollection { get; protected set; }\n\n public void AdjustForRemappedSubject(IMember subjectMember)\n {\n if (subject.Name != subjectMember.Subject.Name)\n {\n subject.Name = subjectMember.Subject.Name;\n }\n }\n\n public int Depth\n {\n get\n {\n const char memberSeparator = '.';\n return Subject.PathAndName.Count(chr => chr == memberSeparator);\n }\n }\n\n private static bool IsCollection(Type type)\n {\n return !typeof(string).IsAssignableFrom(type) && typeof(IEnumerable).IsAssignableFrom(type);\n }\n\n public static INode From(GetSubjectId getSubjectId)\n {\n return new Node\n {\n subjectIdProvider = () => getSubjectId() ?? \"root\",\n Subject = new Pathway(string.Empty, string.Empty, _ => getSubjectId()),\n Type = typeof(T),\n ParentType = null,\n RootIsCollection = IsCollection(typeof(T))\n };\n }\n\n public static INode FromCollectionItem(string index, INode parent)\n {\n Pathway.GetDescription getDescription = pathAndName => parent.GetSubjectId().Combine(pathAndName);\n\n string itemName = \"[\" + index + \"]\";\n\n return new Node\n {\n Type = typeof(T),\n ParentType = parent.Type,\n Subject = new Pathway(parent.Subject, itemName, getDescription),\n Expectation = new Pathway(parent.Expectation, itemName, getDescription),\n GetSubjectId = parent.GetSubjectId,\n RootIsCollection = parent.RootIsCollection\n };\n }\n\n public static INode FromDictionaryItem(object key, INode parent)\n {\n Pathway.GetDescription getDescription = pathAndName => parent.GetSubjectId().Combine(pathAndName);\n\n string itemName = \"[\" + key + \"]\";\n\n return new Node\n {\n Type = typeof(T),\n ParentType = parent.Type,\n Subject = new Pathway(parent.Subject, itemName, getDescription),\n Expectation = new Pathway(parent.Expectation, itemName, getDescription),\n GetSubjectId = parent.GetSubjectId,\n RootIsCollection = parent.RootIsCollection\n };\n }\n\n public override bool Equals(object obj)\n {\n if (obj is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n if (obj.GetType() != GetType())\n {\n return false;\n }\n\n return Equals((Node)obj);\n }\n\n private bool Equals(Node other) => (Type, Subject.Name, Subject.Path) == (other.Type, other.Subject.Name, other.Subject.Path);\n\n public override int GetHashCode()\n {\n unchecked\n {\n#pragma warning disable CA1307\n int hashCode = Type.GetHashCode();\n hashCode = (hashCode * 397) + Subject.Path.GetHashCode();\n hashCode = (hashCode * 397) + Subject.Name.GetHashCode();\n return hashCode;\n }\n }\n\n public override string ToString() => Subject.Description;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Tracing/Tracer.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency.Tracing;\n\n/// \n/// Exposes tracing capabilities that can be used by the implementation of the equivalency algorithm\n/// when an is provided.\n/// \npublic class Tracer\n{\n private readonly INode currentNode;\n private readonly ITraceWriter traceWriter;\n\n internal Tracer(INode currentNode, ITraceWriter traceWriter)\n {\n this.currentNode = currentNode;\n this.traceWriter = traceWriter;\n }\n\n /// \n /// Writes a single line to the currently configured .\n /// \n /// \n /// If no tracer has been configured, the call will be ignored.\n /// \n public void WriteLine(GetTraceMessage getTraceMessage)\n {\n traceWriter?.AddSingle(getTraceMessage(currentNode));\n }\n\n /// \n /// Starts a block that scopes an operation that will be written to the currently configured \n /// after the returned disposable is disposed.\n /// \n /// \n /// If no tracer has been configured for the , the call will be ignored.\n /// \n public IDisposable WriteBlock(GetTraceMessage getTraceMessage)\n {\n if (traceWriter is not null)\n {\n return traceWriter.AddBlock(getTraceMessage(currentNode));\n }\n\n return new Disposable(() => { });\n }\n\n public override string ToString() => traceWriter is not null ? traceWriter.ToString() : string.Empty;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/IncludeMemberByPredicateSelectionRule.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that includes a particular member in the structural comparison.\n/// \ninternal class IncludeMemberByPredicateSelectionRule : IMemberSelectionRule\n{\n private readonly Func predicate;\n private readonly string description;\n\n public IncludeMemberByPredicateSelectionRule(Expression> predicate)\n {\n description = predicate.Body.ToString();\n this.predicate = predicate.Compile();\n }\n\n public bool IncludesMembers => true;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n var members = new List(selectedMembers);\n\n foreach (MemberInfo memberInfo in currentNode.Type.GetMembers(MemberKind.Public |\n MemberKind.Internal))\n {\n IMember member = MemberFactory.Create(memberInfo, currentNode);\n\n if (predicate(new MemberToMemberInfoAdapter(member)) && !members.Exists(p => p.IsEquivalentTo(member)))\n {\n members.Add(member);\n }\n }\n\n return members;\n }\n\n /// \n /// 2\n public override string ToString()\n {\n return \"Include member when \" + description;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/ObjectReferenceSpecs.cs", "using AwesomeAssertions.Equivalency.Execution;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class ObjectReferenceSpecs\n{\n [Theory]\n [InlineData(\"\", \"\", false)]\n [InlineData(\"[a]\", \"\", true)]\n [InlineData(\"[a]\", \"[b]\", false)]\n [InlineData(\"[a]\", \"[a][b]\", true)]\n [InlineData(\"[a][a]\", \"[b][a]\", false)]\n [InlineData(\"[a][b][c][d][e][a]\", \"[a]\", true)]\n [InlineData(\"[a][b][c][d][e][a]\", \"[a][b][c]\", true)]\n public void Equals_should_be_symmetrical(string xPath, string yPath, bool expectedResult)\n {\n /*\n From the .NET documentation:\n\n The following statements must be true for all implementations of the Equals(Object) method.\n [..]\n\n x.Equals(y) returns the same value as y.Equals(x).\n\n Earlier implementations of ObjectReference.Equals were not symmetrical.\n */\n\n // Arrange\n var obj = new object();\n\n var x = new ObjectReference(obj, xPath);\n var y = new ObjectReference(obj, yPath);\n\n // Act\n var forwardResult = x.Equals(y);\n var backwardResult = y.Equals(x);\n\n // Assert\n forwardResult.Should().Be(backwardResult, \"because the contract for Equals specifies symmetry\");\n forwardResult.Should().Be(expectedResult, \"because of the semantics of ObjectReference.Equals (sanity check)\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/Formatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Execution;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Xml;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Provides services for formatting an object being used in an assertion in a human-readable format.\n/// \npublic static class Formatter\n{\n #region Private Definitions\n\n private static readonly List CustomFormatters = [];\n\n private static readonly List DefaultFormatters =\n [\n new XmlReaderValueFormatter(),\n new XmlNodeFormatter(),\n new AttributeBasedFormatter(),\n new AggregateExceptionValueFormatter(),\n new XDocumentValueFormatter(),\n new XElementValueFormatter(),\n new XAttributeValueFormatter(),\n new PropertyInfoFormatter(),\n new MethodInfoFormatter(),\n new NullValueFormatter(),\n new GuidValueFormatter(),\n new DateTimeOffsetValueFormatter(),\n#if NET6_0_OR_GREATER\n new DateOnlyValueFormatter(),\n new TimeOnlyValueFormatter(),\n#endif\n new TimeSpanValueFormatter(),\n new Int32ValueFormatter(),\n new Int64ValueFormatter(),\n new DoubleValueFormatter(),\n new SingleValueFormatter(),\n new DecimalValueFormatter(),\n new ByteValueFormatter(),\n new UInt32ValueFormatter(),\n new UInt64ValueFormatter(),\n new Int16ValueFormatter(),\n new UInt16ValueFormatter(),\n new SByteValueFormatter(),\n new StringValueFormatter(),\n new TaskFormatter(),\n new PredicateLambdaExpressionValueFormatter(),\n new ExpressionValueFormatter(),\n new ExceptionValueFormatter(),\n new MultidimensionalArrayFormatter(),\n new DictionaryValueFormatter(),\n new EnumerableValueFormatter(),\n new EnumValueFormatter(),\n new TypeValueFormatter(),\n new DefaultValueFormatter(),\n ];\n\n /// \n /// Is used to detect recursive calls by implementations.\n /// \n [ThreadStatic]\n private static bool isReentry;\n\n #endregion\n\n /// \n /// A list of objects responsible for formatting the objects represented by placeholders.\n /// \n public static IEnumerable Formatters =>\n AssertionScope.Current.FormattingOptions.ScopedFormatters\n .Concat(CustomFormatters)\n .Concat(DefaultFormatters);\n\n /// \n /// Returns a human-readable representation of a particular object.\n /// \n /// The value for which to create a .\n /// \n /// Indicates whether the formatter should use line breaks when the specific supports it.\n /// \n /// \n /// A that represents this instance.\n /// \n public static string ToString(object value, FormattingOptions options = null)\n {\n options ??= new FormattingOptions();\n\n try\n {\n if (isReentry)\n {\n throw new InvalidOperationException(\n $\"Use the {nameof(FormatChild)} delegate inside a {nameof(IValueFormatter)} to recursively format children\");\n }\n\n isReentry = true;\n\n var graph = new ObjectGraph(value);\n\n var context = new FormattingContext\n {\n UseLineBreaks = options.UseLineBreaks\n };\n\n FormattedObjectGraph output = new(options.MaxLines);\n\n try\n {\n Format(value, output, context,\n (path, childValue, childOutput)\n => FormatChild(path, childValue, childOutput, context, options, graph));\n }\n catch (MaxLinesExceededException)\n {\n }\n\n return output.ToString();\n }\n finally\n {\n isReentry = false;\n }\n }\n\n private static void FormatChild(string path, object value, FormattedObjectGraph output, FormattingContext context,\n FormattingOptions options, ObjectGraph graph)\n {\n try\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(path, nameof(path), \"Formatting a child value requires a path\");\n\n if (!graph.TryPush(path, value))\n {\n output.AddFragment(\"{Cyclic reference to type \");\n TypeValueFormatter.FormatType(value.GetType(), output.AddFragment);\n output.AddFragment(\" detected}\");\n }\n else if (graph.Depth > options.MaxDepth)\n {\n output.AddLine($\"Maximum recursion depth of {options.MaxDepth} was reached. \" +\n $\" Increase {nameof(FormattingOptions.MaxDepth)} on {nameof(AssertionScope)} or {nameof(AssertionConfiguration)} to get more details.\");\n }\n else\n {\n using (output.WithIndentation())\n {\n Format(value, output, context, (childPath, childValue, nestedOutput) =>\n FormatChild(childPath, childValue, nestedOutput, context, options, graph));\n }\n }\n }\n finally\n {\n graph.Pop();\n }\n }\n\n private static void Format(object value, FormattedObjectGraph output, FormattingContext context, FormatChild formatChild)\n {\n IValueFormatter firstFormatterThatCanHandleValue = Formatters.First(f => f.CanHandle(value));\n firstFormatterThatCanHandleValue.Format(value, output, context, formatChild);\n }\n\n /// \n /// Removes a custom formatter that was previously added through .\n /// \n /// \n /// This method is not thread-safe and should not be invoked from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public static void RemoveFormatter(IValueFormatter formatter)\n {\n CustomFormatters.Remove(formatter);\n }\n\n /// \n /// Ensures a custom formatter is included in the chain, just before the default formatter is executed.\n /// \n /// \n /// This method is not thread-safe and should not be invoked from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public static void AddFormatter(IValueFormatter formatter)\n {\n if (!CustomFormatters.Contains(formatter))\n {\n CustomFormatters.Insert(0, formatter);\n }\n }\n\n /// \n /// Tracks the objects that were formatted as well as the path in the object graph of\n /// that object.\n /// \n /// \n /// Is used to detect the maximum recursion depth as well as cyclic references in the graph.\n /// \n private sealed class ObjectGraph\n {\n private readonly CyclicReferenceDetector tracker;\n private readonly Stack pathStack;\n\n public ObjectGraph(object rootObject)\n {\n tracker = new CyclicReferenceDetector();\n pathStack = new Stack();\n TryPush(\"root\", rootObject);\n }\n\n public bool TryPush(string path, object value)\n {\n pathStack.Push(path);\n\n string fullPath = GetFullPath();\n var reference = new ObjectReference(value, fullPath);\n return !tracker.IsCyclicReference(reference);\n }\n\n private string GetFullPath() => string.Join(\".\", pathStack.Reverse());\n\n public void Pop()\n {\n pathStack.Pop();\n }\n\n public int Depth => pathStack.Count - 1;\n\n public override string ToString()\n {\n return string.Join(\".\", pathStack.Reverse());\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MemberSelectionContext.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides contextual information to an .\n/// \npublic class MemberSelectionContext\n{\n private readonly Type compileTimeType;\n private readonly Type runtimeType;\n private readonly IEquivalencyOptions options;\n\n public MemberSelectionContext(Type compileTimeType, Type runtimeType, IEquivalencyOptions options)\n {\n this.runtimeType = runtimeType;\n this.compileTimeType = compileTimeType;\n this.options = options;\n }\n\n /// \n /// Gets a value indicating whether and which properties should be considered.\n /// \n public MemberVisibility IncludedProperties => options.IncludedProperties;\n\n /// \n /// Gets a value indicating whether and which fields should be considered.\n /// \n public MemberVisibility IncludedFields => options.IncludedFields;\n\n /// \n /// Gets either the compile-time or run-time type depending on the options provided by the caller.\n /// \n public Type Type\n {\n get\n {\n Type type = options.UseRuntimeTyping ? runtimeType : compileTimeType;\n\n return type.NullableOrActualType();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/ExcludeMemberByPathSelectionRule.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that removes a particular property from the structural comparison.\n/// \ninternal class ExcludeMemberByPathSelectionRule : SelectMemberByPathSelectionRule\n{\n private MemberPath memberToExclude;\n\n public ExcludeMemberByPathSelectionRule(MemberPath pathToExclude)\n {\n memberToExclude = pathToExclude;\n }\n\n protected override void AddOrRemoveMembersFrom(List selectedMembers, INode parent, string parentPath,\n MemberSelectionContext context)\n {\n selectedMembers.RemoveAll(member =>\n memberToExclude.IsSameAs(new MemberPath(member, parentPath)));\n }\n\n public void AppendPath(MemberPath nextPath)\n {\n memberToExclude = memberToExclude.AsParentCollectionOf(nextPath);\n }\n\n public MemberPath CurrentPath => memberToExclude;\n\n public override string ToString()\n {\n return \"Exclude member \" + memberToExclude;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/AssertionResultSet.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Represents a collection of assertion results obtained through a .\n/// \ninternal class AssertionResultSet\n{\n private readonly Dictionary set = [];\n\n /// \n /// Adds the failures (if any) resulting from executing an assertion within a\n /// identified by a key.\n /// \n public void AddSet(object key, string[] failures)\n {\n set[key] = failures;\n }\n\n /// \n /// Returns the closest match compared to the set identified by the provided or\n /// an empty array if one of the results represents a successful assertion.\n /// \n /// \n /// The closest match is the set that contains the least amount of failures, or no failures at all, and preferably\n /// the set that is identified by the .\n /// \n public string[] GetTheFailuresForTheSetWithTheFewestFailures(object key = null)\n {\n if (ContainsSuccessfulSet())\n {\n return [];\n }\n\n KeyValuePair[] bestResultSets = GetBestResultSets();\n\n KeyValuePair bestMatch = Array.Find(bestResultSets, r => r.Key.Equals(key));\n\n if ((bestMatch.Key, bestMatch.Value) == default)\n {\n return bestResultSets[0].Value;\n }\n\n return bestMatch.Value;\n }\n\n private KeyValuePair[] GetBestResultSets()\n {\n int fewestFailures = set.Values.Min(r => r.Length);\n return set.Where(r => r.Value.Length == fewestFailures).ToArray();\n }\n\n /// \n /// Gets a value indicating whether this collection contains a set without any failures at all.\n /// \n public bool ContainsSuccessfulSet() => set.Values.Any(v => v.Length == 0);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MemberFactory.cs", "using System;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\npublic static class MemberFactory\n{\n public static IMember Create(MemberInfo memberInfo, INode parent)\n {\n return memberInfo.MemberType switch\n {\n MemberTypes.Field => new Field((FieldInfo)memberInfo, parent),\n MemberTypes.Property => new Property((PropertyInfo)memberInfo, parent),\n _ => throw new NotSupportedException($\"Don't know how to deal with a {memberInfo.MemberType}\")\n };\n }\n\n internal static IMember Find(object target, string memberName, INode parent)\n {\n PropertyInfo property = target.GetType().FindProperty(memberName, MemberVisibility.Public | MemberVisibility.ExplicitlyImplemented);\n\n if (property is not null && !property.IsIndexer())\n {\n return new Property(property, parent);\n }\n\n FieldInfo field = target.GetType().FindField(memberName, MemberVisibility.Public);\n return field is not null ? new Field(field, parent) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/AllPropertiesSelectionRule.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that adds all public properties of the expectation.\n/// \ninternal class AllPropertiesSelectionRule : IMemberSelectionRule\n{\n public bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n MemberVisibility visibility = context.IncludedProperties;\n\n IEnumerable selectedProperties = context.Type\n .GetProperties(visibility.ToMemberKind())\n .Where(property => property.GetMethod?.IsPrivate == false)\n .Select(info => new Property(context.Type, info, currentNode));\n\n return selectedMembers.Union(selectedProperties).ToList();\n }\n\n /// \n /// Returns a string that represents the current object.\n /// \n /// \n /// A string that represents the current object.\n /// \n /// 2\n public override string ToString()\n {\n return \"Include all non-private properties\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Property.cs", "using System;\nusing System.ComponentModel;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// A specialized type of that represents a property of an object in a structural equivalency assertion.\n/// \n#pragma warning disable CA1716\ninternal class Property : Node, IMember\n{\n private readonly PropertyInfo propertyInfo;\n private bool? isBrowsable;\n\n public Property(PropertyInfo propertyInfo, INode parent)\n : this(propertyInfo.ReflectedType, propertyInfo, parent)\n {\n }\n\n public Property(Type reflectedType, PropertyInfo propertyInfo, INode parent)\n {\n ReflectedType = reflectedType;\n this.propertyInfo = propertyInfo;\n DeclaringType = propertyInfo.DeclaringType;\n Subject = new Pathway(parent.Subject.PathAndName, propertyInfo.Name, pathAndName => $\"property {parent.GetSubjectId().Combine(pathAndName)}\");\n Expectation = new Pathway(parent.Expectation.PathAndName, propertyInfo.Name, pathAndName => $\"property {pathAndName}\");\n Type = propertyInfo.PropertyType;\n ParentType = propertyInfo.DeclaringType;\n GetSubjectId = parent.GetSubjectId;\n RootIsCollection = parent.RootIsCollection;\n }\n\n public object GetValue(object obj)\n {\n return propertyInfo.GetValue(obj);\n }\n\n public Type DeclaringType { get; }\n\n public Type ReflectedType { get; }\n\n public CSharpAccessModifier GetterAccessibility => propertyInfo.GetGetMethod(nonPublic: true).GetCSharpAccessModifier();\n\n public CSharpAccessModifier SetterAccessibility => propertyInfo.GetSetMethod(nonPublic: true).GetCSharpAccessModifier();\n\n public bool IsBrowsable\n {\n get\n {\n isBrowsable ??=\n propertyInfo.GetCustomAttribute() is not { State: EditorBrowsableState.Never };\n\n return isBrowsable.Value;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/CollectionMemberSelectionRuleDecorator.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\ninternal class CollectionMemberSelectionRuleDecorator : IMemberSelectionRule\n{\n private readonly IMemberSelectionRule selectionRule;\n\n public CollectionMemberSelectionRuleDecorator(IMemberSelectionRule selectionRule)\n {\n this.selectionRule = selectionRule;\n }\n\n public bool IncludesMembers => selectionRule.IncludesMembers;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return selectionRule.SelectMembers(currentNode, selectedMembers, context);\n }\n\n public override string ToString()\n {\n return selectionRule.ToString();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/Node.cs", "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\n\nnamespace AwesomeAssertions.Xml.Equivalency;\n\ninternal sealed class Node\n{\n private readonly List children = [];\n private readonly string name;\n private int count;\n\n public static Node CreateRoot() => new(null, null);\n\n private Node(Node parent, string name)\n {\n Parent = parent;\n this.name = name;\n }\n\n public string GetXPath()\n {\n var resultBuilder = new StringBuilder();\n\n foreach (Node location in GetPath().Reverse())\n {\n if (location.count > 1)\n {\n resultBuilder.AppendFormat(CultureInfo.InvariantCulture, \"/{0}[{1}]\", location.name, location.count);\n }\n else\n {\n resultBuilder.AppendFormat(CultureInfo.InvariantCulture, \"/{0}\", location.name);\n }\n }\n\n if (resultBuilder.Length == 0)\n {\n return \"/\";\n }\n\n return resultBuilder.ToString();\n }\n\n private IEnumerable GetPath()\n {\n Node current = this;\n\n while (current.Parent is not null)\n {\n yield return current;\n current = current.Parent;\n }\n }\n\n public Node Parent { get; }\n\n public Node Push(string localName)\n {\n Node node = children.Find(e => e.name == localName)\n ?? AddChildNode(localName);\n\n node.count++;\n\n return node;\n }\n\n public void Pop()\n {\n children.Clear();\n }\n\n private Node AddChildNode(string name)\n {\n var node = new Node(this, name);\n children.Add(node);\n return node;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IMemberMatchingRule.cs", "using AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a rule that defines how to map the selected members of the expectation object to the properties\n/// of the subject.\n/// \npublic interface IMemberMatchingRule\n{\n /// \n /// Attempts to find a member on the subject that should be compared with the\n /// during a structural equality.\n /// \n /// \n /// Whether or not a match is required or optional is up to the specific rule. If no match is found and this is not an issue,\n /// simply return .\n /// \n /// \n /// The of the subject's member for which a match must be found. Can never\n /// be .\n /// \n /// \n /// The subject object for which a matching member must be returned. Can never be .\n /// \n /// \n /// \n /// \n /// \n /// Returns the of the property with which to compare the subject with, or \n /// if no match was found.\n /// \n IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/ExcludeNonBrowsableMembersRule.cs", "using System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\ninternal class ExcludeNonBrowsableMembersRule : IMemberSelectionRule\n{\n public bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return selectedMembers.Where(member => member.IsBrowsable).ToList();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/AllFieldsSelectionRule.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that adds all public fields of the expectation\n/// \ninternal class AllFieldsSelectionRule : IMemberSelectionRule\n{\n public bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n IEnumerable selectedFields = context.Type\n .GetFields(context.IncludedFields.ToMemberKind())\n .Select(info => new Field(info, currentNode));\n\n return selectedMembers.Union(selectedFields).ToList();\n }\n\n /// \n /// Returns a string that represents the current object.\n /// \n /// \n /// A string that represents the current object.\n /// \n /// 2\n public override string ToString()\n {\n return \"Include all non-private fields\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EqualityStrategyProvider.cs", "using System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal sealed class EqualityStrategyProvider\n{\n private readonly List referenceTypes = [];\n private readonly List valueTypes = [];\n private readonly ConcurrentDictionary typeCache = new();\n\n [CanBeNull]\n private readonly Func defaultStrategy;\n\n private bool? compareRecordsByValue;\n\n public EqualityStrategyProvider()\n {\n }\n\n public EqualityStrategyProvider(Func defaultStrategy)\n {\n this.defaultStrategy = defaultStrategy;\n }\n\n public bool? CompareRecordsByValue\n {\n get => compareRecordsByValue;\n set\n {\n compareRecordsByValue = value;\n typeCache.Clear();\n }\n }\n\n public EqualityStrategy GetEqualityStrategy(Type type)\n {\n // As the valueFactory parameter captures instance members,\n // be aware if the cache must be cleared on mutating the members.\n return typeCache.GetOrAdd(type, typeKey =>\n {\n if (!typeKey.IsPrimitive && referenceTypes.Count > 0 && referenceTypes.Exists(t => typeKey.IsSameOrInherits(t)))\n {\n return EqualityStrategy.ForceMembers;\n }\n else if (valueTypes.Count > 0 && valueTypes.Exists(t => typeKey.IsSameOrInherits(t)))\n {\n return EqualityStrategy.ForceEquals;\n }\n else if (!typeKey.IsPrimitive && referenceTypes.Count > 0 &&\n referenceTypes.Exists(t => typeKey.IsAssignableToOpenGeneric(t)))\n {\n return EqualityStrategy.ForceMembers;\n }\n else if (valueTypes.Count > 0 && valueTypes.Exists(t => typeKey.IsAssignableToOpenGeneric(t)))\n {\n return EqualityStrategy.ForceEquals;\n }\n else if ((compareRecordsByValue.HasValue || defaultStrategy is null) && typeKey.IsRecord())\n {\n return compareRecordsByValue is true ? EqualityStrategy.ForceEquals : EqualityStrategy.ForceMembers;\n }\n else if (defaultStrategy is not null)\n {\n return defaultStrategy(typeKey);\n }\n\n return typeKey.HasValueSemantics() ? EqualityStrategy.Equals : EqualityStrategy.Members;\n });\n }\n\n public bool AddReferenceType(Type type)\n {\n if (valueTypes.Exists(t => type.IsSameOrInherits(t)))\n {\n return false;\n }\n\n referenceTypes.Add(type);\n typeCache.Clear();\n return true;\n }\n\n public bool AddValueType(Type type)\n {\n if (referenceTypes.Exists(t => type.IsSameOrInherits(t)))\n {\n return false;\n }\n\n valueTypes.Add(type);\n typeCache.Clear();\n return true;\n }\n\n public override string ToString()\n {\n var builder = new StringBuilder();\n\n if (compareRecordsByValue is true)\n {\n builder.AppendLine(\"- Compare records by value\");\n }\n else\n {\n builder.AppendLine(\"- Compare records by their members\");\n }\n\n foreach (Type valueType in valueTypes)\n {\n builder.AppendLine(CultureInfo.InvariantCulture, $\"- Compare {valueType} by value\");\n }\n\n foreach (Type type in referenceTypes)\n {\n builder.AppendLine(CultureInfo.InvariantCulture, $\"- Compare {type} by its members\");\n }\n\n return builder.ToString();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Field.cs", "using System;\nusing System.ComponentModel;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// A specialized type of that represents a field of an object in a structural equivalency assertion.\n/// \ninternal class Field : Node, IMember\n{\n private readonly FieldInfo fieldInfo;\n private bool? isBrowsable;\n\n public Field(FieldInfo fieldInfo, INode parent)\n {\n this.fieldInfo = fieldInfo;\n DeclaringType = fieldInfo.DeclaringType;\n ReflectedType = fieldInfo.ReflectedType;\n Subject = new Pathway(parent.Subject.PathAndName, fieldInfo.Name, pathAndName => $\"field {parent.GetSubjectId().Combine(pathAndName)}\");\n Expectation = new Pathway(parent.Expectation.PathAndName, fieldInfo.Name, pathAndName => $\"field {pathAndName}\");\n GetSubjectId = parent.GetSubjectId;\n Type = fieldInfo.FieldType;\n ParentType = fieldInfo.DeclaringType;\n RootIsCollection = parent.RootIsCollection;\n }\n\n public Type ReflectedType { get; }\n\n public object GetValue(object obj)\n {\n return fieldInfo.GetValue(obj);\n }\n\n public Type DeclaringType { get; set; }\n\n public CSharpAccessModifier GetterAccessibility => fieldInfo.GetCSharpAccessModifier();\n\n public CSharpAccessModifier SetterAccessibility => fieldInfo.GetCSharpAccessModifier();\n\n public bool IsBrowsable =>\n isBrowsable ??= fieldInfo.GetCustomAttribute() is not { State: EditorBrowsableState.Never };\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/DictionarySpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.Collections.Specialized;\nusing System.Globalization;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency.Tracing;\nusing Newtonsoft.Json;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class DictionarySpecs\n{\n private class NonGenericDictionary : IDictionary\n {\n private readonly IDictionary dictionary = new Dictionary();\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public void CopyTo(Array array, int index)\n {\n dictionary.CopyTo(array, index);\n }\n\n public int Count => dictionary.Count;\n\n public bool IsSynchronized => dictionary.IsSynchronized;\n\n public object SyncRoot => dictionary.SyncRoot;\n\n public void Add(object key, object value)\n {\n dictionary.Add(key, value);\n }\n\n public void Clear()\n {\n dictionary.Clear();\n }\n\n public bool Contains(object key)\n {\n return dictionary.Contains(key);\n }\n\n public IDictionaryEnumerator GetEnumerator()\n {\n return dictionary.GetEnumerator();\n }\n\n public void Remove(object key)\n {\n dictionary.Remove(key);\n }\n\n public bool IsFixedSize => dictionary.IsFixedSize;\n\n public bool IsReadOnly => dictionary.IsReadOnly;\n\n public object this[object key]\n {\n get => dictionary[key];\n set => dictionary[key] = value;\n }\n\n public ICollection Keys => dictionary.Keys;\n\n public ICollection Values => dictionary.Values;\n }\n\n private class GenericDictionaryNotImplementingIDictionary : IDictionary\n {\n private readonly Dictionary dictionary = [];\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public IEnumerator> GetEnumerator()\n {\n return dictionary.GetEnumerator();\n }\n\n void ICollection>.Add(KeyValuePair item)\n {\n ((ICollection>)dictionary).Add(item);\n }\n\n public void Clear()\n {\n dictionary.Clear();\n }\n\n bool ICollection>.Contains(KeyValuePair item)\n {\n return ((ICollection>)dictionary).Contains(item);\n }\n\n void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex)\n {\n ((ICollection>)dictionary).CopyTo(array, arrayIndex);\n }\n\n bool ICollection>.Remove(KeyValuePair item)\n {\n return ((ICollection>)dictionary).Remove(item);\n }\n\n public int Count => dictionary.Count;\n\n public bool IsReadOnly => ((ICollection>)dictionary).IsReadOnly;\n\n public bool ContainsKey(TKey key)\n {\n return dictionary.ContainsKey(key);\n }\n\n public void Add(TKey key, TValue value)\n {\n dictionary.Add(key, value);\n }\n\n public bool Remove(TKey key)\n {\n return dictionary.Remove(key);\n }\n\n public bool TryGetValue(TKey key, out TValue value)\n {\n return dictionary.TryGetValue(key, out value);\n }\n\n public TValue this[TKey key]\n {\n get => dictionary[key];\n set => dictionary[key] = value;\n }\n\n public ICollection Keys => dictionary.Keys;\n\n public ICollection Values => dictionary.Values;\n }\n\n /// \n /// FakeItEasy can probably handle this in a couple lines, but then it would not be portable.\n /// \n private class ClassWithTwoDictionaryImplementations : Dictionary, IDictionary\n {\n IEnumerator> IEnumerable>.GetEnumerator()\n {\n return\n ((ICollection>)this).Select(\n item =>\n new KeyValuePair(\n item.Key.ToString(CultureInfo.InvariantCulture),\n item.Value)).GetEnumerator();\n }\n\n public void Add(KeyValuePair item)\n {\n ((ICollection>)this).Add(new KeyValuePair(Parse(item.Key), item.Value));\n }\n\n public bool Contains(KeyValuePair item)\n {\n return\n ((ICollection>)this).Contains(\n new KeyValuePair(Parse(item.Key), item.Value));\n }\n\n public void CopyTo(KeyValuePair[] array, int arrayIndex)\n {\n ((ICollection>)this).Select(\n item =>\n new KeyValuePair(item.Key.ToString(CultureInfo.InvariantCulture), item.Value))\n .ToArray()\n .CopyTo(array, arrayIndex);\n }\n\n public bool Remove(KeyValuePair item)\n {\n return\n ((ICollection>)this).Remove(\n new KeyValuePair(Parse(item.Key), item.Value));\n }\n\n bool ICollection>.IsReadOnly =>\n ((ICollection>)this).IsReadOnly;\n\n public bool ContainsKey(string key)\n {\n return ContainsKey(Parse(key));\n }\n\n public void Add(string key, object value)\n {\n Add(Parse(key), value);\n }\n\n public bool Remove(string key)\n {\n return Remove(Parse(key));\n }\n\n public bool TryGetValue(string key, out object value)\n {\n return TryGetValue(Parse(key), out value);\n }\n\n public object this[string key]\n {\n get => this[Parse(key)];\n set => this[Parse(key)] = value;\n }\n\n ICollection IDictionary.Keys =>\n Keys.Select(key => key.ToString(CultureInfo.InvariantCulture)).ToList();\n\n ICollection IDictionary.Values => Values;\n\n private int Parse(string key)\n {\n return int.Parse(key, CultureInfo.InvariantCulture);\n }\n }\n\n public class UserRolesLookupElement\n {\n private readonly Dictionary> innerRoles = [];\n\n public virtual Dictionary> Roles =>\n innerRoles.ToDictionary(x => x.Key, y => y.Value.Select(z => z));\n\n public void Add(Guid userId, params string[] roles)\n {\n innerRoles[userId] = roles.ToList();\n }\n }\n\n public class ClassWithMemberDictionary\n {\n public Dictionary Dictionary { get; set; }\n }\n\n public class SomeBaseKeyClass : IEquatable\n {\n public SomeBaseKeyClass(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n\n public override int GetHashCode()\n {\n return Id;\n }\n\n public bool Equals(SomeBaseKeyClass other)\n {\n if (other is null)\n {\n return false;\n }\n\n return Id == other.Id;\n }\n\n public override bool Equals(object obj)\n {\n return Equals(obj as SomeBaseKeyClass);\n }\n\n public override string ToString()\n {\n return $\"BaseKey {Id}\";\n }\n }\n\n public class SomeDerivedKeyClass : SomeBaseKeyClass\n {\n public SomeDerivedKeyClass(int id)\n : base(id)\n {\n }\n }\n\n [Fact]\n public void When_a_dictionary_does_not_implement_the_dictionary_interface_it_should_still_be_treated_as_a_dictionary()\n {\n // Arrange\n IDictionary dictionary = new GenericDictionaryNotImplementingIDictionary\n {\n [\"hi\"] = 1\n };\n\n ICollection> collection =\n new List> { new(\"hi\", 1) };\n\n // Act / Assert\n dictionary.Should().BeEquivalentTo(collection);\n }\n\n [Fact]\n public void When_a_read_only_dictionary_matches_the_expectation_it_should_succeed()\n {\n // Arrange\n IReadOnlyDictionary> dictionary =\n new ReadOnlyDictionary>(\n new Dictionary>\n {\n [\"Key2\"] = [\"Value2\"],\n [\"Key1\"] = [\"Value1\"]\n });\n\n // Act / Assert\n dictionary.Should().BeEquivalentTo(new Dictionary>\n {\n [\"Key1\"] = [\"Value1\"],\n [\"Key2\"] = [\"Value2\"]\n });\n }\n\n [Fact]\n public void When_a_read_only_dictionary_does_not_match_the_expectation_it_should_throw()\n {\n // Arrange\n IReadOnlyDictionary> dictionary =\n new ReadOnlyDictionary>(\n new Dictionary>\n {\n [\"Key2\"] = [\"Value2\"],\n [\"Key1\"] = [\"Value1\"]\n });\n\n // Act\n Action act = () => dictionary.Should().BeEquivalentTo(new Dictionary>\n {\n [\"Key2\"] = [\"Value3\"],\n [\"Key1\"] = [\"Value1\"]\n });\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected dictionary[Key2][0]*Value2*Value3*\");\n }\n\n [Fact]\n public void When_a_dictionary_is_compared_to_null_it_should_not_throw_a_NullReferenceException()\n {\n // Arrange\n Dictionary subject = null;\n Dictionary expectation = [];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, \"because we do expect a valid dictionary\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*not to be*null*valid dictionary*\");\n }\n\n [Fact]\n public void When_a_null_dictionary_is_compared_to_null_it_should_not_throw()\n {\n // Arrange\n Dictionary subject = null;\n Dictionary expectation = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_a_dictionary_is_compared_to_a_dictionary_it_should_allow_chaining()\n {\n // Arrange\n Dictionary subject = new() { [42] = 1337 };\n\n Dictionary expectation = new() { [42] = 1337 };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation)\n .And.ContainKey(42);\n }\n\n [Fact]\n public void When_a_dictionary_is_compared_to_a_dictionary_with_a_config_it_should_allow_chaining()\n {\n // Arrange\n Dictionary subject = new() { [42] = 1337 };\n\n Dictionary expectation = new() { [42] = 1337 };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opt => opt)\n .And.ContainKey(42);\n }\n\n [Fact]\n public void When_a_dictionary_property_is_detected_it_should_ignore_the_order_of_the_pairs()\n {\n // Arrange\n var expected = new\n {\n Customers = new Dictionary\n {\n [\"Key2\"] = \"Value2\",\n [\"Key1\"] = \"Value1\"\n }\n };\n\n var subject = new\n {\n Customers = new Dictionary\n {\n [\"Key1\"] = \"Value1\",\n [\"Key2\"] = \"Value2\"\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_collection_of_key_value_pairs_is_equivalent_to_the_dictionary_it_should_succeed()\n {\n // Arrange\n var collection = new List> { new(\"hi\", 1) };\n\n // Act / Assert\n Action act = () => collection.Should().BeEquivalentTo(new Dictionary\n {\n { \"hi\", 2 }\n });\n\n act.Should().Throw().WithMessage(\"Expected collection[hi]*to be 2, but found 1.*\");\n }\n\n [Fact]\n public void\n When_a_generic_dictionary_is_typed_as_object_and_runtime_typing_has_is_specified_it_should_use_the_runtime_type()\n {\n // Arrange\n object object1 = new Dictionary { [\"greeting\"] = \"hello\" };\n object object2 = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().NotThrow(\"the runtime type is a dictionary and the dictionaries are equivalent\");\n }\n\n [Fact]\n public void When_a_generic_dictionary_is_typed_as_object_it_should_respect_the_runtime_typed()\n {\n // Arrange\n object object1 = new Dictionary { [\"greeting\"] = \"hello\" };\n object object2 = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act / Assert\n object1.Should().BeEquivalentTo(object2);\n }\n\n [Fact]\n public void\n When_a_non_generic_dictionary_is_typed_as_object_and_runtime_typing_is_specified_the_runtime_type_should_be_respected()\n {\n // Arrange\n object object1 = new NonGenericDictionary { [\"greeting\"] = \"hello\" };\n object object2 = new NonGenericDictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().NotThrow(\"the runtime type is a dictionary and the dictionaries are equivalent\");\n }\n\n [Fact]\n public void\n When_a_non_generic_dictionary_is_decided_to_be_equivalent_to_expected_trace_is_still_written()\n {\n // Arrange\n object object1 = new NonGenericDictionary { [\"greeting\"] = \"hello\" };\n object object2 = new NonGenericDictionary { [\"greeting\"] = \"hello\" };\n var traceWriter = new StringBuilderTraceWriter();\n\n // Act\n object1.Should().BeEquivalentTo(object2, opts => opts.PreferringRuntimeMemberTypes().WithTracing(traceWriter));\n\n // Assert\n string trace = traceWriter.ToString();\n trace.Should().Contain(\"Recursing into dictionary item greeting at object1\");\n }\n\n [Fact]\n public void When_a_non_generic_dictionary_is_typed_as_object_it_should_respect_the_runtime_type()\n {\n // Arrange\n object object1 = new NonGenericDictionary();\n object object2 = new NonGenericDictionary();\n\n // Act / Assert\n object1.Should().BeEquivalentTo(object2);\n }\n\n [Fact]\n public void When_an_object_implements_two_IDictionary_interfaces_it_should_fail_descriptively()\n {\n // Arrange\n var object1 = (object)new ClassWithTwoDictionaryImplementations();\n var object2 = (object)new ClassWithTwoDictionaryImplementations();\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*expectation*implements multiple dictionary types*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_dictionaries_and_configured_to_respect_runtime_type_it_should_respect_the_runtime_type()\n {\n // Arrange\n IDictionary dictionary1 = new NonGenericDictionary { [2001] = new Car() };\n IDictionary dictionary2 = new NonGenericDictionary { [2001] = new Customer() };\n\n // Act\n Action act =\n () =>\n dictionary1.Should().BeEquivalentTo(dictionary2,\n opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw(\"the types have different properties\");\n }\n\n [Fact]\n public void Can_compare_non_generic_dictionaries_without_recursing()\n {\n // Arrange\n var expected = new NonGenericDictionary\n {\n [\"Key2\"] = \"Value2\",\n [\"Key1\"] = \"Value1\"\n };\n\n var subject = new NonGenericDictionary\n {\n [\"Key1\"] = \"Value1\",\n [\"Key3\"] = \"Value2\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, options => options.WithoutRecursing());\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected subject[\\\"Key2\\\"] to be \\\"Value2\\\", but found *\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_dictionaries_it_should_respect_the_declared_type()\n {\n // Arrange\n var actual = new Dictionary { [0] = new(\"123\") };\n var expectation = new Dictionary { [0] = new DerivedCustomerType(\"123\") };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().NotThrow(\"because it should ignore the properties of the derived type\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_it_should_throw()\n {\n // Arrange\n var actual = new Dictionary();\n var expectation = new Dictionary();\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_generic_dictionaries_and_configured_to_use_runtime_properties_it_should_respect_the_runtime_type()\n {\n // Arrange\n var actual = new Dictionary { [0] = new(\"123\") };\n var expectation = new Dictionary { [0] = new DerivedCustomerType(\"123\") };\n\n // Act\n Action act =\n () =>\n actual.Should().BeEquivalentTo(expectation, opts => opts\n .PreferringRuntimeMemberTypes()\n .ComparingByMembers()\n );\n\n // Assert\n act.Should().Throw(\"the runtime types have different properties\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_generic_dictionaries_and_the_expectation_key_type_is_assignable_from_the_subjects_it_should_fail_if_incompatible()\n {\n // Arrange\n var actual = new Dictionary { [new object()] = \"hello\" };\n var expected = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual*to contain key \\\"greeting\\\"*\");\n }\n\n [Fact]\n public void When_the_subjects_key_type_is_compatible_with_the_expected_key_type_it_should_match()\n {\n // Arrange\n var dictionary1 = new Dictionary { [\"greeting\"] = \"hello\" };\n var dictionary2 = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n act.Should().NotThrow(\"the keys are still strings\");\n }\n\n [Fact]\n public void When_the_subjects_key_type_is_not_compatible_with_the_expected_key_type_it_should_throw()\n {\n // Arrange\n var actual = new Dictionary { [1234] = \"hello\" };\n var expectation = new Dictionary { [\"greeting\"] = \"hello\" };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected actual to be a dictionary or collection of key-value pairs that is keyed to type string*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_generic_dictionaries_the_type_information_should_be_preserved_for_other_equivalency_steps()\n {\n // Arrange\n var userId = Guid.NewGuid();\n\n var dictionary1 = new Dictionary> { [userId] = new List { \"Admin\", \"Special\" } };\n var dictionary2 = new Dictionary> { [userId] = new List { \"Admin\", \"Other\" } };\n\n // Act\n Action act = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_non_generic_dictionaries_the_lack_of_type_information_should_be_preserved_for_other_equivalency_steps()\n {\n // Arrange\n var userId = Guid.NewGuid();\n\n var dictionary1 = new NonGenericDictionary { [userId] = new List { \"Admin\", \"Special\" } };\n var dictionary2 = new NonGenericDictionary { [userId] = new List { \"Admin\", \"Other\" } };\n\n // Act\n Action act = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Special*Other*\");\n }\n\n [Fact]\n public void When_asserting_the_equivalence_of_generic_dictionaries_it_should_respect_the_declared_type()\n {\n // Arrange\n var actual = new Dictionary\n {\n [0] = new DerivedCustomerType(\"123\")\n };\n\n var expectation = new Dictionary { [0] = new(\"123\") };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().NotThrow(\"the objects are equivalent according to the members on the declared type\");\n }\n\n [Fact]\n public void When_the_both_properties_are_null_it_should_not_throw()\n {\n // Arrange\n var expected = new ClassWithMemberDictionary\n {\n Dictionary = null\n };\n\n var subject = new ClassWithMemberDictionary\n {\n Dictionary = null\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void\n When_the_dictionary_values_are_handled_by_the_enumerable_equivalency_step_the_type_information_should_be_preserved()\n {\n // Arrange\n var userId = Guid.NewGuid();\n\n var actual = new UserRolesLookupElement();\n actual.Add(userId, \"Admin\", \"Special\");\n\n var expected = new UserRolesLookupElement();\n expected.Add(userId, \"Admin\", \"Other\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*Roles[*][1]*Special*Other*\");\n }\n\n [Fact]\n public void When_the_other_dictionary_does_not_contain_enough_items_it_should_throw()\n {\n // Arrange\n var expected = new\n {\n Customers = new Dictionary\n {\n [\"Key1\"] = \"Value1\",\n [\"Key2\"] = \"Value2\"\n }\n };\n\n var subject = new\n {\n Customers = new Dictionary\n {\n [\"Key1\"] = \"Value1\"\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, \"because we are expecting two keys\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Customers*dictionary*2 item(s)*expecting two keys*but*misses*\");\n }\n\n [Fact]\n public void When_the_other_property_is_not_a_dictionary_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n Customers = \"I am a string\"\n };\n\n var expected = new\n {\n Customers = new Dictionary\n {\n [\"Key2\"] = \"Value2\",\n [\"Key1\"] = \"Value1\"\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property subject.Customers to be a dictionary or collection of key-value pairs that is keyed to type string*\");\n }\n\n [Fact]\n public void When_the_other_property_is_null_it_should_throw()\n {\n // Arrange\n var subject = new ClassWithMemberDictionary\n {\n Dictionary = new Dictionary\n {\n [\"Key2\"] = \"Value2\",\n [\"Key1\"] = \"Value1\"\n }\n };\n\n var expected = new ClassWithMemberDictionary\n {\n Dictionary = null\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, \"because we are not expecting anything\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*property*Dictionary*to be because we are not expecting anything, but found *{*}*\");\n }\n\n [Fact]\n public void When_subject_dictionary_asserted_to_be_equivalent_have_less_elements_fails_describing_missing_keys()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [\"greeting\"] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [\"greeting\"] = \"hello\",\n [\"farewell\"] = \"goodbye\"\n };\n\n // Act\n Action action = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected dictionary1*to be a dictionary with 2 item(s), but it misses key(s) {\\\"farewell\\\"}*\");\n }\n\n [Fact]\n public void\n When_subject_dictionary_with_class_keys_asserted_to_be_equivalent_have_less_elements_other_dictionary_derived_class_keys_fails_describing_missing_keys()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [new SomeDerivedKeyClass(1)] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [new SomeDerivedKeyClass(1)] = \"hello\",\n [new SomeDerivedKeyClass(2)] = \"hello\"\n };\n\n // Act\n Action action = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*to be a dictionary with 2 item(s), but*misses key(s) {BaseKey 2}*\");\n }\n\n [Fact]\n public void When_subject_dictionary_asserted_to_be_equivalent_have_more_elements_fails_describing_additional_keys()\n {\n // Arrange\n var expectation = new Dictionary\n {\n [\"greeting\"] = \"hello\"\n };\n\n var subject = new Dictionary\n {\n [\"greeting\"] = \"hello\",\n [\"farewell\"] = \"goodbye\"\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, \"because we expect one pair\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject*to be a dictionary with 1 item(s) because we expect one pair, but*additional key(s) {\\\"farewell\\\"}*\");\n }\n\n [Fact]\n public void\n When_subject_dictionary_with_class_keys_asserted_to_be_equivalent_and_other_dictionary_derived_class_keys_fails_because_of_types_incompatibility()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [new SomeDerivedKeyClass(1)] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [new SomeDerivedKeyClass(1)] = \"hello\",\n [new SomeDerivedKeyClass(2)] = \"hello\"\n };\n\n // Act\n Action action = () => dictionary2.Should().BeEquivalentTo(dictionary1);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary2 to be a dictionary or collection of key-value pairs that is keyed to type AwesomeAssertions.Equivalency.Specs.DictionarySpecs+SomeBaseKeyClass.*\");\n }\n\n [Fact]\n public void\n When_subject_dictionary_asserted_to_be_equivalent_have_less_elements_but_some_missing_and_some_additional_elements_fails_describing_missing_and_additional_keys()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [\"GREETING\"] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [\"greeting\"] = \"hello\",\n [\"farewell\"] = \"goodbye\"\n };\n\n // Act\n Action action = () => dictionary1.Should().BeEquivalentTo(dictionary2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected*to be a dictionary with 2 item(s), but*misses key(s)*{\\\"greeting\\\", \\\"farewell\\\"}*additional key(s) {\\\"GREETING\\\"}*\");\n }\n\n [Fact]\n public void\n When_subject_dictionary_asserted_to_be_equivalent_have_more_elements_but_some_missing_and_some_additional_elements_fails_describing_missing_and_additional_keys()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [\"GREETING\"] = \"hello\"\n };\n\n var dictionary2 = new Dictionary\n {\n [\"greeting\"] = \"hello\",\n [\"farewell\"] = \"goodbye\"\n };\n\n // Act\n Action action = () => dictionary2.Should().BeEquivalentTo(dictionary1);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected*to be a dictionary with 1 item(s), but*misses key(s) {\\\"GREETING\\\"}*additional key(s) {\\\"greeting\\\", \\\"farewell\\\"}*\");\n }\n\n [Fact]\n public void When_two_equivalent_dictionaries_are_compared_directly_as_if_it_is_a_collection_it_should_succeed()\n {\n // Arrange\n var result = new Dictionary\n {\n [\"C\"] = null,\n [\"B\"] = 0,\n [\"A\"] = 0\n };\n\n // Act / Assert\n result.Should().BeEquivalentTo(new Dictionary\n {\n [\"A\"] = 0,\n [\"B\"] = 0,\n [\"C\"] = null\n });\n }\n\n [Fact]\n public void When_two_equivalent_dictionaries_are_compared_directly_it_should_succeed()\n {\n // Arrange\n var result = new Dictionary\n {\n [\"C\"] = 0,\n [\"B\"] = 0,\n [\"A\"] = 0\n };\n\n // Act / Assert\n result.Should().BeEquivalentTo(new Dictionary\n {\n [\"A\"] = 0,\n [\"B\"] = 0,\n [\"C\"] = 0\n });\n }\n\n [Fact]\n public void When_two_nested_dictionaries_contain_null_values_it_should_not_crash()\n {\n // Arrange\n var projection = new\n {\n ReferencedEquipment = new Dictionary\n {\n [1] = null\n }\n };\n\n var persistedProjection = new\n {\n ReferencedEquipment = new Dictionary\n {\n [1] = null\n }\n };\n\n // Act / Assert\n persistedProjection.Should().BeEquivalentTo(projection);\n }\n\n [Fact]\n public void When_two_nested_dictionaries_do_not_match_it_should_throw()\n {\n // Arrange\n var projection = new\n {\n ReferencedEquipment = new Dictionary\n {\n [1] = \"Bla1\"\n }\n };\n\n var persistedProjection = new\n {\n ReferencedEquipment = new Dictionary\n {\n [1] = \"Bla2\"\n }\n };\n\n // Act\n Action act = () => persistedProjection.Should().BeEquivalentTo(projection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*ReferencedEquipment[1]*Bla2*Bla1*\");\n }\n\n [Fact]\n public void When_a_dictionary_is_missing_a_key_it_should_report_the_specific_key()\n {\n // Arrange\n var actual = new Dictionary\n {\n { \"a\", \"x\" },\n { \"b\", \"x\" },\n };\n\n var expected = new Dictionary\n {\n { \"a\", \"x\" },\n { \"c\", \"x\" }, // key mismatch\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, \"because we're expecting {0}\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual*key*c*because we're expecting c*\");\n }\n\n [Fact]\n public void When_a_nested_dictionary_value_doesnt_match_it_should_throw()\n {\n // Arrange\n const string json =\n \"\"\"\n {\n \"NestedDictionary\": {\n \"StringProperty\": \"string\",\n \"IntProperty\": 123\n }\n }\n \"\"\";\n\n var expectedResult = new Dictionary\n {\n [\"NestedDictionary\"] = new Dictionary\n {\n [\"StringProperty\"] = \"string\",\n [\"IntProperty\"] = 123\n }\n };\n\n // Act\n var result = JsonConvert.DeserializeObject>(json);\n Action act = () => result.Should().BeEquivalentTo(expectedResult);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*String*JValue*\");\n }\n\n [Fact]\n public void When_a_custom_rule_is_applied_on_a_dictionary_it_should_apply_it_on_the_values()\n {\n // Arrange\n var dictOne = new Dictionary\n {\n { \"a\", 1.2345 },\n { \"b\", 2.4567 },\n { \"c\", 5.6789 },\n { \"s\", 3.333 }\n };\n\n var dictTwo = new Dictionary\n {\n { \"a\", 1.2348 },\n { \"b\", 2.4561 },\n { \"c\", 5.679 },\n { \"s\", 3.333 }\n };\n\n // Act / Assert\n dictOne.Should().BeEquivalentTo(dictTwo, options => options\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.1))\n .WhenTypeIs()\n );\n }\n\n [Fact]\n public void Passing_the_reason_to_the_inner_equivalency_assertion_works()\n {\n var subject = new Dictionary\n {\n [\"a\"] = new List()\n };\n\n var expected = new Dictionary\n {\n [\"a\"] = new List { 42 }\n };\n\n Action act = () => subject.Should().BeEquivalentTo(expected, \"FOO {0}\", \"BAR\");\n\n act.Should().Throw().WithMessage(\"*FOO BAR*\");\n }\n\n [Fact]\n public void A_non_generic_subject_can_be_compared_with_a_generic_expectation()\n {\n var subject = new ListDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n var expected = new Dictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void A_non_generic_subject_which_is_null_can_be_compared_with_a_generic_expectation()\n {\n var subject = (ListDictionary)null;\n\n var expected = new Dictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n act.Should().Throw().WithMessage(\"**\");\n }\n\n [Fact]\n public void Excluding_nested_objects_when_dictionary_is_equivalent()\n {\n var subject = new Dictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n var expected = new Dictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n subject.Should().BeEquivalentTo(expected, opt => opt.WithoutRecursing());\n }\n\n [Fact]\n public void Custom_types_which_implementing_dictionaries_pass()\n {\n var subject = new NonGenericChildDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n var expected = new Specs.NonGenericDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void Custom_types_which_implementing_dictionaries_pass_with_swapped_subject_expectation()\n {\n var subject = new Specs.NonGenericDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n var expected = new NonGenericChildDictionary\n {\n [\"id\"] = 22,\n [\"CustomerId\"] = 33\n };\n\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void A_subject_string_key_with_curly_braces_is_formatted_correctly_in_failure_message()\n {\n // Arrange\n var actual = new Dictionary { [\"{}\"] = \"\" };\n var expected = new Dictionary { [\"{}\"] = null };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected actual[{}] to be *, but found *.\");\n }\n\n [Fact]\n public void A_subject_key_with_braces_in_string_representation_is_formatted_correctly_in_failure_message()\n {\n // Arrange\n var actual = new Dictionary { [new()] = \"\" };\n var expected = new Dictionary { [new()] = null };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected actual[RecordStruct { }] to be *, but found *.\");\n }\n\n private record struct RecordStruct();\n}\n\ninternal class NonGenericChildDictionary : Dictionary\n{\n public new void Add(string key, int value)\n {\n base.Add(key, value);\n }\n}\n\ninternal class NonGenericDictionary : IDictionary\n{\n private readonly Dictionary innerDictionary = [];\n\n public int this[string key]\n {\n get => innerDictionary[key];\n set => innerDictionary[key] = value;\n }\n\n public ICollection Keys => innerDictionary.Keys;\n\n public ICollection Values => innerDictionary.Values;\n\n public int Count => innerDictionary.Count;\n\n public bool IsReadOnly => false;\n\n public void Add(string key, int value) => innerDictionary.Add(key, value);\n\n public void Add(KeyValuePair item) => innerDictionary.Add(item.Key, item.Value);\n\n public void Clear() => innerDictionary.Clear();\n\n public bool Contains(KeyValuePair item) => innerDictionary.Contains(item);\n\n public bool ContainsKey(string key) => innerDictionary.ContainsKey(key);\n\n public void CopyTo(KeyValuePair[] array, int arrayIndex) =>\n ((ICollection>)innerDictionary).CopyTo(array, arrayIndex);\n\n public IEnumerator> GetEnumerator() => innerDictionary.GetEnumerator();\n\n public bool Remove(string key) => innerDictionary.Remove(key);\n\n public bool Remove(KeyValuePair item) => innerDictionary.Remove(item.Key);\n\n public bool TryGetValue(string key, out int value) => innerDictionary.TryGetValue(key, out value);\n\n IEnumerator IEnumerable.GetEnumerator() => innerDictionary.GetEnumerator();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/OrderingRuleCollection.cs", "using System.Collections;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Equivalency.Ordering;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Collection of s.\n/// \npublic class OrderingRuleCollection : IEnumerable\n{\n private readonly List rules = [];\n\n /// \n /// Initializes a new collection of ordering rules.\n /// \n public OrderingRuleCollection()\n {\n }\n\n /// \n /// Initializes a new collection of ordering rules based on an existing collection of ordering rules.\n /// \n public OrderingRuleCollection(IEnumerable orderingRules)\n {\n rules.AddRange(orderingRules);\n }\n\n /// \n /// Returns an enumerator that iterates through the collection.\n /// \n /// \n /// A that can be used to iterate through the collection.\n /// \n /// 1\n public IEnumerator GetEnumerator()\n {\n return rules.GetEnumerator();\n }\n\n /// \n /// Returns an enumerator that iterates through a collection.\n /// \n /// \n /// An object that can be used to iterate through the collection.\n /// \n /// 2\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public void Add(IOrderingRule rule)\n {\n rules.Add(rule);\n }\n\n internal void Clear()\n {\n rules.Clear();\n }\n\n /// \n /// Determines whether the rules in this collection dictate strict ordering during the equivalency assertion on\n /// the collection pointed to by .\n /// \n public bool IsOrderingStrictFor(IObjectInfo objectInfo)\n {\n List results = rules.ConvertAll(r => r.Evaluate(objectInfo));\n return results.Contains(OrderStrictness.Strict) && !results.Contains(OrderStrictness.NotStrict);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/CollectionMemberObjectInfo.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency.Ordering;\n\ninternal class CollectionMemberObjectInfo : IObjectInfo\n{\n public CollectionMemberObjectInfo(IObjectInfo context)\n {\n Path = GetAdjustedPropertyPath(context.Path);\n\n#pragma warning disable CS0618\n Type = context.Type;\n#pragma warning restore CS0618\n\n ParentType = context.ParentType;\n RuntimeType = context.RuntimeType;\n CompileTimeType = context.CompileTimeType;\n }\n\n private static string GetAdjustedPropertyPath(string propertyPath)\n {\n return propertyPath.Substring(propertyPath.IndexOf('.', StringComparison.Ordinal) + 1);\n }\n\n public Type Type { get; }\n\n public Type ParentType { get; }\n\n public string Path { get; set; }\n\n public Type CompileTimeType { get; }\n\n public Type RuntimeType { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/ExcludeMemberByPredicateSelectionRule.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Selection rule that removes a particular member from the structural comparison based on a predicate.\n/// \ninternal class ExcludeMemberByPredicateSelectionRule : IMemberSelectionRule\n{\n private readonly Func predicate;\n private readonly string description;\n\n public ExcludeMemberByPredicateSelectionRule(Expression> predicate)\n {\n description = predicate.Body.ToString();\n this.predicate = predicate.Compile();\n }\n\n public bool IncludesMembers => false;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return selectedMembers.Where(p => !predicate(new MemberToMemberInfoAdapter(p))).ToArray();\n }\n\n /// \n /// 2\n public override string ToString()\n {\n return \"Exclude member when \" + description;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IMemberSelectionRule.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a rule that defines which members of the expectation to include while comparing\n/// two objects for structural equality.\n/// \npublic interface IMemberSelectionRule\n{\n /// \n /// Gets a value indicating whether this rule should override the default selection rules that include all members.\n /// \n bool IncludesMembers { get; }\n\n /// \n /// Adds or removes properties or fields to/from the collection of members that must be included while\n /// comparing two objects for structural equality.\n /// \n /// \n /// The node within the graph from which to select members.\n /// \n /// \n /// A collection of members that was pre-populated by other selection rules. Can be empty.\n /// Provides auxiliary information such as the configuration and such.\n /// \n /// The collection of members after applying this rule. Can contain less or more than was passed in.\n /// \n IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/NonEquivalencySpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class NonEquivalencySpecs\n{\n [Fact]\n public void When_asserting_inequivalence_of_equal_ints_as_object_it_should_fail()\n {\n // Arrange\n object i1 = 1;\n object i2 = 1;\n\n // Act\n Action act = () => i1.Should().NotBeEquivalentTo(i2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_unequal_ints_as_object_it_should_succeed()\n {\n // Arrange\n object i1 = 1;\n object i2 = 2;\n\n // Act / Assert\n i1.Should().NotBeEquivalentTo(i2);\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_equal_strings_as_object_it_should_fail()\n {\n // Arrange\n object s1 = \"A\";\n object s2 = \"A\";\n\n // Act\n Action act = () => s1.Should().NotBeEquivalentTo(s2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_unequal_strings_as_object_it_should_succeed()\n {\n // Arrange\n object s1 = \"A\";\n object s2 = \"B\";\n\n // Act / Assert\n s1.Should().NotBeEquivalentTo(s2);\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_equal_classes_it_should_fail()\n {\n // Arrange\n var o1 = new { Name = \"A\" };\n var o2 = new { Name = \"A\" };\n\n // Act\n Action act = () => o1.Should().NotBeEquivalentTo(o2, \"some {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*some reason*\");\n }\n\n [Fact]\n public void When_asserting_inequivalence_of_unequal_classes_it_should_succeed()\n {\n // Arrange\n var o1 = new { Name = \"A\" };\n var o2 = new { Name = \"B\" };\n\n // Act / Assert\n o1.Should().NotBeEquivalentTo(o2);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/BasicSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Net;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class BasicSpecs\n{\n [Fact]\n public void A_null_configuration_is_invalid()\n {\n // Arrange\n var actual = new { };\n var expectation = new { };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void A_null_as_the_configuration_is_not_valid_for_inequivalency_assertions()\n {\n // Arrange\n var actual = new { };\n var expectation = new { };\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expectation, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_expectation_is_null_it_should_throw()\n {\n // Arrange\n var subject = new { };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be , but found { }*\");\n }\n\n [Fact]\n public void When_comparing_nested_collection_with_a_null_value_it_should_fail_with_the_correct_message()\n {\n // Arrange\n MyClass[] subject = [new MyClass { Items = [\"a\"] }];\n\n MyClass[] expectation = [new MyClass()];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*subject[0].Items*null*, but found*\\\"a\\\"*\");\n }\n\n public class MyClass\n {\n public IEnumerable Items { get; set; }\n }\n\n [Fact]\n public void When_subject_is_null_it_should_throw()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(new { });\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject*to be*, but found *\");\n }\n\n [Fact]\n public void When_subject_and_expectation_are_null_it_should_not_throw()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(null);\n }\n\n [Fact]\n public void When_subject_and_expectation_are_compared_for_equivalence_it_should_allow_chaining()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(null)\n .And.BeNull();\n }\n\n [Fact]\n public void When_subject_and_expectation_are_compared_for_equivalence_with_config_it_should_allow_chaining()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(null, opt => opt)\n .And.BeNull();\n }\n\n [Fact]\n public void When_subject_and_expectation_are_compared_for_non_equivalence_it_should_allow_chaining()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new { })\n .And.BeNull();\n }\n\n [Fact]\n public void When_subject_and_expectation_are_compared_for_non_equivalence_with_config_it_should_allow_chaining()\n {\n // Arrange\n SomeDto subject = null;\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(new { }, opt => opt)\n .And.BeNull();\n }\n\n [Fact]\n public void When_asserting_equivalence_on_a_value_type_from_system_it_should_not_do_a_structural_comparision()\n {\n // Arrange\n\n // DateTime is used as an example because the current implementation\n // would hit the recursion-depth limit if structural equivalence were attempted.\n var date1 = new { Property = 1.January(2011) };\n\n var date2 = new { Property = 1.January(2011) };\n\n // Act / Assert\n date1.Should().BeEquivalentTo(date2);\n }\n\n [Fact]\n public void When_an_object_hides_object_equals_it_should_be_compared_using_its_members()\n {\n // Arrange\n var actual = new VirtualClassOverride { Property = \"Value\", OtherProperty = \"Actual\" };\n\n var expected = new VirtualClassOverride { Property = \"Value\", OtherProperty = \"Expected\" };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw(\"*OtherProperty*Expected*Actual*\");\n }\n\n public class VirtualClass\n {\n public string Property { get; set; }\n\n public new virtual bool Equals(object obj)\n {\n return obj is VirtualClass other && other.Property == Property;\n }\n }\n\n public class VirtualClassOverride : VirtualClass\n {\n public string OtherProperty { get; set; }\n }\n\n [Fact]\n public void When_treating_a_value_type_in_a_collection_as_a_complex_type_it_should_compare_them_by_members()\n {\n // Arrange\n ClassWithValueSemanticsOnSingleProperty[] subject = [new() { Key = \"SameKey\", NestedProperty = \"SomeValue\" }];\n ClassWithValueSemanticsOnSingleProperty[] expected = [new() { Key = \"SameKey\", NestedProperty = \"OtherValue\" }];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected,\n options => options.ComparingByMembers());\n\n // Assert\n act.Should().Throw().WithMessage(\"*NestedProperty*SomeValue*OtherValue*\");\n }\n\n [Fact]\n public void When_treating_a_value_type_as_a_complex_type_it_should_compare_them_by_members()\n {\n // Arrange\n var subject = new ClassWithValueSemanticsOnSingleProperty { Key = \"SameKey\", NestedProperty = \"SomeValue\" };\n\n var expected = new ClassWithValueSemanticsOnSingleProperty { Key = \"SameKey\", NestedProperty = \"OtherValue\" };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected,\n options => options.ComparingByMembers());\n\n // Assert\n act.Should().Throw().WithMessage(\"*NestedProperty*SomeValue*OtherValue*\");\n }\n\n [Fact]\n public void When_treating_a_type_as_value_type_but_it_was_already_marked_as_reference_type_it_should_throw()\n {\n // Arrange\n var subject = new ClassWithValueSemanticsOnSingleProperty { Key = \"Don't care\" };\n\n var expected = new ClassWithValueSemanticsOnSingleProperty { Key = \"Don't care\" };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, options => options\n .ComparingByMembers()\n .ComparingByValue());\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"*compare {nameof(ClassWithValueSemanticsOnSingleProperty)}*value*already*members*\");\n }\n\n [Fact]\n public void When_treating_a_type_as_reference_type_but_it_was_already_marked_as_value_type_it_should_throw()\n {\n // Arrange\n var subject = new ClassWithValueSemanticsOnSingleProperty { Key = \"Don't care\" };\n\n var expected = new ClassWithValueSemanticsOnSingleProperty { Key = \"Don't care\" };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, options => options\n .ComparingByValue()\n .ComparingByMembers());\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"*compare {nameof(ClassWithValueSemanticsOnSingleProperty)}*members*already*value*\");\n }\n\n [Fact]\n public void When_treating_a_complex_type_in_a_collection_as_a_value_type_it_should_compare_them_by_value()\n {\n // Arrange\n var subject = new[] { new { Address = IPAddress.Parse(\"1.2.3.4\"), Word = \"a\" } };\n\n var expected = new[] { new { Address = IPAddress.Parse(\"1.2.3.4\"), Word = \"a\" } };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.ComparingByValue());\n }\n\n [Fact]\n public void When_treating_a_complex_type_as_a_value_type_it_should_compare_them_by_value()\n {\n // Arrange\n var subject = new { Address = IPAddress.Parse(\"1.2.3.4\"), Word = \"a\" };\n\n var expected = new { Address = IPAddress.Parse(\"1.2.3.4\"), Word = \"a\" };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.ComparingByValue());\n }\n\n [Fact]\n public void When_treating_a_null_type_as_value_type_it_should_throw()\n {\n // Arrange\n var subject = new object();\n var expected = new object();\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByValue(null));\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"type\");\n }\n\n [Fact]\n public void When_treating_a_null_type_as_reference_type_it_should_throw()\n {\n // Arrange\n var subject = new object();\n var expected = new object();\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers(null));\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"type\");\n }\n\n [Fact]\n public void When_comparing_an_open_type_by_members_it_should_succeed()\n {\n // Arrange\n var subject = new Option([1, 3, 2]);\n var expected = new Option([1, 2, 3]);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers(typeof(Option<>)));\n }\n\n [Fact]\n public void When_treating_open_type_as_reference_type_and_a_closed_type_as_value_type_it_should_compare_by_value()\n {\n // Arrange\n var subject = new Option([1, 3, 2]);\n var expected = new Option([1, 2, 3]);\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers(typeof(Option<>))\n .ComparingByValue>());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_treating_open_type_as_value_type_and_a_closed_type_as_reference_type_it_should_compare_by_members()\n {\n // Arrange\n var subject = new Option([1, 3, 2]);\n var expected = new Option([1, 2, 3]);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByValue(typeof(Option<>))\n .ComparingByMembers>());\n }\n\n private readonly struct Option : IEquatable>\n where T : class\n {\n public T Value { get; }\n\n public Option(T value)\n {\n Value = value;\n }\n\n public bool Equals(Option other) =>\n EqualityComparer.Default.Equals(Value, other.Value);\n\n public override bool Equals(object obj) =>\n obj is Option other && Equals(other);\n\n public override int GetHashCode() => Value?.GetHashCode() ?? 0;\n }\n\n [Fact]\n public void When_treating_any_type_as_reference_type_it_should_exclude_primitive_types()\n {\n // Arrange\n var subject = new { Value = 1 };\n var expected = new { Value = 2 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be 2*found 1*\");\n }\n\n [Fact]\n public void When_treating_an_open_type_as_reference_type_it_should_exclude_primitive_types()\n {\n // Arrange\n var subject = new { Value = 1 };\n var expected = new { Value = 2 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers(typeof(IEquatable<>)));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be 2*found 1*\");\n }\n\n [Fact]\n public void When_treating_a_primitive_type_as_a_reference_type_it_should_throw()\n {\n // Arrange\n var subject = new { Value = 1 };\n var expected = new { Value = 2 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .ComparingByMembers());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Cannot compare a primitive type* int *\");\n }\n\n [Fact]\n public void When_a_type_originates_from_the_System_namespace_it_should_be_treated_as_a_value_type()\n {\n // Arrange\n var subject = new { UriBuilder = new UriBuilder(\"http://localhost:9001/api\"), };\n\n var expected = new { UriBuilder = new UriBuilder(\"https://localhost:9002/bapi\"), };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*UriBuilder* to be https://localhost:9002/bapi, but found http://localhost:9001/api*\");\n }\n\n [Fact]\n public void When_asserting_equivalence_on_a_string_it_should_use_string_specific_failure_messages()\n {\n // Arrange\n string s1 = \"hello\";\n string s2 = \"good-bye\";\n\n // Act\n Action act = () => s1.Should().BeEquivalentTo(s2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\"\"*be equivalent to *differ at index 0:*(actual)*\"hello\"*\"good-bye\"*(expected).\"\"\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_strings_typed_as_objects_it_should_compare_them_as_strings()\n {\n // Arrange\n\n // The convoluted construction is so the compiler does not optimize the two objects to be the same.\n object s1 = new string('h', 2);\n object s2 = \"hh\";\n\n // Act / Assert\n s1.Should().BeEquivalentTo(s2);\n }\n\n [Fact]\n public void When_asserting_equivalence_of_ints_typed_as_objects_it_should_use_the_runtime_type()\n {\n // Arrange\n object s1 = 1;\n object s2 = 1;\n\n // Act\n s1.Should().BeEquivalentTo(s2);\n }\n\n [Fact]\n public void When_all_field_of_the_object_are_equal_equivalency_should_pass()\n {\n // Arrange\n var object1 = new ClassWithOnlyAField { Value = 1 };\n var object2 = new ClassWithOnlyAField { Value = 1 };\n\n // Act / Assert\n object1.Should().BeEquivalentTo(object2);\n }\n\n [Fact]\n public void When_number_values_are_convertible_it_should_treat_them_as_equivalent()\n {\n // Arrange\n var actual = new Dictionary { [\"001\"] = 1L, [\"002\"] = 2L };\n\n var expected = new Dictionary { [\"001\"] = 1, [\"002\"] = 2 };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_all_field_of_the_object_are_not_equal_equivalency_should_fail()\n {\n // Arrange\n var object1 = new ClassWithOnlyAField { Value = 1 };\n var object2 = new ClassWithOnlyAField { Value = 101 };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_field_on_the_subject_matches_a_property_the_members_should_match_for_equivalence()\n {\n // Arrange\n var onlyAField = new ClassWithOnlyAField { Value = 1 };\n var onlyAProperty = new ClassWithOnlyAProperty { Value = 101 };\n\n // Act\n Action act = () => onlyAField.Should().BeEquivalentTo(onlyAProperty);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property onlyAField.Value*to be 101, but found 1.*\");\n }\n\n [Fact]\n public void When_asserting_equivalence_including_only_fields_it_should_not_match_properties()\n {\n // Arrange\n var onlyAField = new ClassWithOnlyAField { Value = 1 };\n object onlyAProperty = new ClassWithOnlyAProperty { Value = 101 };\n\n // Act\n Action act = () => onlyAProperty.Should().BeEquivalentTo(onlyAField, opts => opts.ExcludingProperties());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectation has field Value that the other object does not have.*\");\n }\n\n [Fact]\n public void When_asserting_equivalence_including_only_properties_it_should_not_match_fields()\n {\n // Arrange\n var onlyAField = new ClassWithOnlyAField { Value = 1 };\n var onlyAProperty = new ClassWithOnlyAProperty { Value = 101 };\n\n // Act\n Action act = () => onlyAField.Should().BeEquivalentTo(onlyAProperty, opts => opts.IncludingAllDeclaredProperties());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectation has property Value that the other object does not have*\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_objects_including_enumerables_it_should_print_the_failure_message_only_once()\n {\n // Arrange\n var record = new { Member1 = \"\", Member2 = new[] { \"\", \"\" } };\n\n var record2 = new { Member1 = \"different\", Member2 = new[] { \"\", \"\" } };\n\n // Act\n Action act = () => record.Should().BeEquivalentTo(record2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"\"\"Expected property record.Member1 to be the same string* differ at index 0:*(actual)*\"\"*\"different\"*(expected).*\"\"\");\n }\n\n [Fact]\n public void When_asserting_object_equivalence_against_a_null_value_it_should_properly_throw()\n {\n // Act\n Action act = () => ((object)null).Should().BeEquivalentTo(\"foo\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*foo*null*\");\n }\n\n [Fact]\n public void When_the_graph_contains_guids_it_should_properly_format_them()\n {\n // Arrange\n var actual =\n new[] { new { Id = Guid.NewGuid(), Name = \"Name\" } };\n\n var expected =\n new[] { new { Id = Guid.NewGuid(), Name = \"Name\" } };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property actual[0].Id*to be *-*, but found *-*\");\n }\n\n [Fact]\n public void Empty_array_segments_can_be_compared_for_equivalency()\n {\n // Arrange\n var actual = new ClassWithArraySegment();\n var expected = new ClassWithArraySegment();\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n private class ClassWithArraySegment\n {\n public ArraySegment Segment { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Execution/ObjectReference.cs", "using System;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing AwesomeAssertions.Common;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Equivalency.Execution;\n\n/// \n/// Represents an object tracked by the including it's location within an object graph.\n/// \ninternal class ObjectReference\n{\n private readonly object @object;\n private readonly string path;\n private readonly bool? compareByMembers;\n private string[] pathElements;\n\n public ObjectReference(object @object, string path, bool? compareByMembers = null)\n {\n this.@object = @object;\n this.path = path;\n this.compareByMembers = compareByMembers;\n }\n\n /// \n /// Determines whether the specified is equal to the current .\n /// \n /// \n /// true if the specified is equal to the current ; otherwise, false.\n /// \n /// The to compare with the current . \n /// 2\n public override bool Equals(object obj)\n {\n return obj is ObjectReference other\n && ReferenceEquals(@object, other.@object) && IsParentOrChildOf(other);\n }\n\n private string[] GetPathElements() => pathElements\n ??= path.ToUpperInvariant().Replace(\"][\", \"].[\", StringComparison.Ordinal)\n .Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);\n\n private bool IsParentOrChildOf(ObjectReference other)\n {\n string[] elements = GetPathElements();\n string[] otherPath = other.GetPathElements();\n\n int commonElements = Math.Min(elements.Length, otherPath.Length);\n int longerPathAdditionalElements = Math.Max(elements.Length, otherPath.Length) - commonElements;\n\n return longerPathAdditionalElements > 0 && otherPath.Take(commonElements).SequenceEqual(elements.Take(commonElements));\n }\n\n /// \n /// Serves as a hash function for a particular type.\n /// \n /// \n /// A hash code for the current .\n /// \n /// 2\n public override int GetHashCode()\n {\n return RuntimeHelpers.GetHashCode(@object);\n }\n\n public override string ToString()\n {\n return Invariant($\"{{\\\"{path}\\\", {@object}}}\");\n }\n\n public bool CompareByMembers => compareByMembers ?? @object?.GetType().OverridesEquals() == false;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/XmlIterator.cs", "using System.Collections.Generic;\nusing System.Xml;\n\nnamespace AwesomeAssertions.Xml.Equivalency;\n\ninternal class XmlIterator\n{\n private readonly XmlReader reader;\n private bool skipOnce;\n\n public XmlIterator(XmlReader reader)\n {\n this.reader = reader;\n\n this.reader.MoveToContent();\n }\n\n public XmlNodeType NodeType => reader.NodeType;\n\n public string LocalName => reader.LocalName;\n\n public string NamespaceUri => reader.NamespaceURI;\n\n public string Value => reader.Value;\n\n public bool IsEmptyElement => reader.IsEmptyElement;\n\n public bool IsEndOfDocument => reader.EOF;\n\n public void Read()\n {\n if (skipOnce)\n {\n skipOnce = false;\n return;\n }\n\n if (reader.Read())\n {\n reader.MoveToContent();\n }\n }\n\n public void MoveToEndElement()\n {\n reader.Read();\n\n if (reader.NodeType != XmlNodeType.EndElement)\n {\n // advancing failed\n // skip reading on next attempt to \"simulate\" rewind reader\n skipOnce = true;\n }\n\n reader.MoveToContent();\n }\n\n public IList GetAttributes()\n {\n var attributes = new List();\n\n if (reader.MoveToFirstAttribute())\n {\n do\n {\n if (reader.NamespaceURI != \"http://www.w3.org/2000/xmlns/\")\n {\n attributes.Add(new AttributeData(reader.NamespaceURI, reader.LocalName, reader.Value, reader.Prefix));\n }\n }\n while (reader.MoveToNextAttribute());\n\n reader.MoveToElement();\n }\n\n return attributes;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/MemberPath.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Equivalency;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Encapsulates a dotted candidate to a (nested) member of a type as well as the\n/// declaring type of the deepest member.\n/// \ninternal class MemberPath\n{\n private readonly string dottedPath;\n private readonly Type reflectedType;\n private readonly Type declaringType;\n\n private string[] segments;\n\n private static readonly MemberPathSegmentEqualityComparer MemberPathSegmentEqualityComparer = new();\n\n public MemberPath(IMember member, string parentPath)\n : this(member.ReflectedType, member.DeclaringType, parentPath.Combine(member.Expectation.Name))\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// is .\n public MemberPath(Type reflectedType, Type declaringType, string dottedPath)\n : this(dottedPath)\n {\n this.reflectedType = reflectedType;\n this.declaringType = declaringType;\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// is .\n public MemberPath(string dottedPath)\n {\n Guard.ThrowIfArgumentIsNull(\n dottedPath, nameof(dottedPath),\n \"A member path cannot be null\");\n\n this.dottedPath = dottedPath;\n }\n\n /// \n /// Gets a value indicating whether the current object represents a child member of the \n /// or that it is the parent of that candidate.\n /// \n public bool IsParentOrChildOf(MemberPath candidate)\n {\n return IsParentOf(candidate) || IsChildOf(candidate);\n }\n\n public bool IsSameAs(MemberPath candidate)\n {\n if (declaringType == candidate.declaringType || declaringType?.IsAssignableFrom(candidate.reflectedType) == true)\n {\n string[] candidateSegments = candidate.Segments;\n\n return candidateSegments.SequenceEqual(Segments, MemberPathSegmentEqualityComparer);\n }\n\n return false;\n }\n\n private bool IsParentOf(MemberPath candidate)\n {\n string[] candidateSegments = candidate.Segments;\n\n return candidateSegments.Length > Segments.Length &&\n candidateSegments.Take(Segments.Length).SequenceEqual(Segments, MemberPathSegmentEqualityComparer);\n }\n\n private bool IsChildOf(MemberPath candidate)\n {\n string[] candidateSegments = candidate.Segments;\n\n return candidateSegments.Length < Segments.Length\n && candidateSegments.SequenceEqual(Segments.Take(candidateSegments.Length),\n MemberPathSegmentEqualityComparer);\n }\n\n public MemberPath AsParentCollectionOf(MemberPath nextPath)\n {\n var extendedDottedPath = dottedPath.Combine(nextPath.dottedPath, \"[]\");\n return new MemberPath(nextPath.reflectedType, nextPath.declaringType, extendedDottedPath);\n }\n\n /// \n /// Determines whether the current path is the same as when ignoring any specific indexes.\n /// \n public bool IsEquivalentTo(string path)\n {\n return path.WithoutSpecificCollectionIndices() == dottedPath.WithoutSpecificCollectionIndices();\n }\n\n public bool HasSameParentAs(MemberPath path)\n {\n return Segments.Length == path.Segments.Length\n && GetParentSegments().SequenceEqual(path.GetParentSegments(), MemberPathSegmentEqualityComparer);\n }\n\n private IEnumerable GetParentSegments() => Segments.Take(Segments.Length - 1);\n\n /// \n /// Gets a value indicating whether the current path contains an indexer like `[1]` instead of `[]`.\n /// \n public bool GetContainsSpecificCollectionIndex() => dottedPath.ContainsSpecificCollectionIndex();\n\n private string[] Segments =>\n segments ??= dottedPath\n .Replace(\"[]\", \"[*]\", StringComparison.Ordinal)\n .Split(new[] { '.', '[', ']' }, StringSplitOptions.RemoveEmptyEntries);\n\n /// \n /// Returns a copy of the current object as if it represented an un-indexed item in a collection.\n /// \n public MemberPath WithCollectionAsRoot()\n {\n return new MemberPath(reflectedType, declaringType, \"[].\" + dottedPath);\n }\n\n /// \n /// Returns the name of the member the current path points to without its parent path.\n /// \n public string MemberName => Segments[^1];\n\n public override string ToString()\n {\n return dottedPath;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Configuration/GlobalConfiguration.cs", "namespace AwesomeAssertions.Configuration;\n\npublic class GlobalConfiguration\n{\n private TestFramework? testFramework;\n\n /// \n /// Provides access to the formatting defaults for all assertions.\n /// \n public GlobalFormattingOptions Formatting { get; set; } = new();\n\n /// \n /// Provides access to the defaults used by the structural equivalency assertions.\n /// \n public GlobalEquivalencyOptions Equivalency { get; set; } = new();\n\n /// \n /// Sets a specific test framework to be used by AwesomeAssertions when throwing assertion exceptions.\n /// \n /// \n /// If set to , the test framework will be automatically detected by scanning the appdomain.\n /// \n public TestFramework? TestFramework\n {\n get => testFramework;\n set\n {\n testFramework = value;\n AssertionEngine.TestFramework = null;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EnumEquivalencyHandling.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic enum EnumEquivalencyHandling\n{\n ByValue,\n ByName\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Execution/CyclicReferenceDetector.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Equivalency.Execution;\n\n/// \n/// Keeps track of objects and their location within an object graph so that cyclic references can be detected\n/// and handled upon.\n/// \ninternal class CyclicReferenceDetector : ICloneable2\n{\n #region Private Definitions\n\n private HashSet observedReferences = [];\n\n #endregion\n\n /// \n /// Determines whether the specified object reference is a cyclic reference to the same object earlier in the\n /// equivalency validation.\n /// \n public bool IsCyclicReference(ObjectReference reference)\n {\n bool isCyclic = false;\n\n if (reference.CompareByMembers)\n {\n isCyclic = !observedReferences.Add(reference);\n }\n\n return isCyclic;\n }\n\n /// \n /// Creates a new object that is a copy of the current instance.\n /// \n /// \n /// A new object that is a copy of this instance.\n /// \n public object Clone()\n {\n return new CyclicReferenceDetector\n {\n observedReferences = new HashSet(observedReferences)\n };\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Steps/DictionaryInterfaceInfo.cs", "using System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency.Steps;\n\n/// \n/// Provides Reflection-backed meta-data information about a type implementing the interface.\n/// \ninternal sealed class DictionaryInterfaceInfo\n{\n // ReSharper disable once PossibleNullReferenceException\n private static readonly MethodInfo ConvertToDictionaryMethod =\n new Func>, Dictionary>(ConvertToDictionaryInternal)\n .GetMethodInfo().GetGenericMethodDefinition();\n\n private static readonly ConcurrentDictionary Cache = new();\n\n private DictionaryInterfaceInfo(Type key, Type value)\n {\n Key = key;\n Value = value;\n }\n\n public Type Value { get; }\n\n public Type Key { get; }\n\n /// \n /// Tries to reflect on the provided and returns an instance of the \n /// representing the single dictionary interface. Will throw if the target implements more than one dictionary interface.\n /// \n /// >\n /// The is used to describe the in failure messages.\n /// \n public static DictionaryInterfaceInfo FindFrom(Type target, string role)\n {\n var interfaces = GetDictionaryInterfacesFrom(target);\n\n if (interfaces.Length > 1)\n {\n throw new ArgumentException(\n $\"The {role} implements multiple dictionary types. It is not known which type should be \" +\n $\"use for equivalence.{Environment.NewLine}The following IDictionary interfaces are implemented: \" +\n $\"{string.Join(\", \", (IEnumerable)interfaces)}\", nameof(role));\n }\n\n if (interfaces.Length == 0)\n {\n return null;\n }\n\n return interfaces[0];\n }\n\n /// \n /// Tries to reflect on the provided and returns an instance of the \n /// representing the single dictionary interface keyed to .\n /// Will throw if the target implements more than one dictionary interface.\n /// \n /// >\n /// The is used to describe the in failure messages.\n /// \n public static DictionaryInterfaceInfo FindFromWithKey(Type target, string role, Type key)\n {\n var suitableDictionaryInterfaces = GetDictionaryInterfacesFrom(target)\n .Where(info => info.Key.IsAssignableFrom(key))\n .ToArray();\n\n if (suitableDictionaryInterfaces.Length > 1)\n {\n throw new InvalidOperationException(\n $\"The {role} implements multiple IDictionary interfaces taking a key of {key}. \");\n }\n\n if (suitableDictionaryInterfaces.Length == 0)\n {\n return null;\n }\n\n return suitableDictionaryInterfaces[0];\n }\n\n private static DictionaryInterfaceInfo[] GetDictionaryInterfacesFrom(Type target)\n {\n return Cache.GetOrAdd(target, static key =>\n {\n if (Type.GetTypeCode(key) != TypeCode.Object)\n {\n return [];\n }\n\n return key\n .GetClosedGenericInterfaces(typeof(IDictionary<,>))\n .Select(@interface => @interface.GetGenericArguments())\n .Select(arguments => new DictionaryInterfaceInfo(arguments[0], arguments[1]))\n .ToArray();\n });\n }\n\n /// \n /// Tries to convert an object into a dictionary typed to the and of the current .\n /// \n /// \n /// if the conversion succeeded or otherwise.\n /// \n public object ConvertFrom(object convertable)\n {\n Type[] enumerables = convertable.GetType().GetClosedGenericInterfaces(typeof(IEnumerable<>));\n\n var suitableKeyValuePairCollection = enumerables\n .Select(enumerable => enumerable.GenericTypeArguments[0])\n .Where(itemType => itemType.IsGenericType && itemType.GetGenericTypeDefinition() == typeof(KeyValuePair<,>))\n .SingleOrDefault(itemType => itemType.GenericTypeArguments[0] == Key);\n\n if (suitableKeyValuePairCollection != null)\n {\n Type pairValueType = suitableKeyValuePairCollection.GenericTypeArguments[^1];\n\n var methodInfo = ConvertToDictionaryMethod.MakeGenericMethod(Key, pairValueType);\n return methodInfo.Invoke(null, [convertable]);\n }\n\n return null;\n }\n\n private static Dictionary ConvertToDictionaryInternal(\n IEnumerable> collection)\n {\n return collection.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);\n }\n\n public override string ToString() => $\"IDictionary<{Key}, {Value}>\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/ByteArrayOrderingRule.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency.Ordering;\n\n/// \n/// Ordering rule that ensures that byte arrays are always compared in strict ordering since it would cause a\n/// severe performance impact otherwise.\n/// \ninternal class ByteArrayOrderingRule : IOrderingRule\n{\n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n return objectInfo.CompileTimeType.IsSameOrInherits(typeof(IEnumerable))\n ? OrderStrictness.Strict\n : OrderStrictness.Irrelevant;\n }\n\n public override string ToString()\n {\n return \"Be strict about the order of items in byte arrays\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Selection/MemberToMemberInfoAdapter.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency.Selection;\n\n/// \n/// Represents a selection context of a nested property\n/// \ninternal class MemberToMemberInfoAdapter : IMemberInfo\n{\n private readonly IMember member;\n\n public MemberToMemberInfoAdapter(IMember member)\n {\n this.member = member;\n DeclaringType = member.DeclaringType;\n Name = member.Expectation.Name;\n Type = member.Type;\n Path = member.Expectation.PathAndName;\n }\n\n public string Name { get; }\n\n public Type Type { get; }\n\n public Type DeclaringType { get; }\n\n public string Path { get; set; }\n\n public CSharpAccessModifier GetterAccessibility => member.GetterAccessibility;\n\n public CSharpAccessModifier SetterAccessibility => member.SetterAccessibility;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/PathBasedOrderingRule.cs", "using System;\nusing System.Text.RegularExpressions;\n\nnamespace AwesomeAssertions.Equivalency.Ordering;\n\n/// \n/// Represents a rule for determining whether or not a certain collection within the object graph should be compared using\n/// strict ordering.\n/// \ninternal class PathBasedOrderingRule : IOrderingRule\n{\n private readonly string path;\n\n public PathBasedOrderingRule(string path)\n {\n this.path = path;\n }\n\n public bool Invert { get; init; }\n\n /// \n /// Determines if ordering of the member referred to by the current is relevant.\n /// \n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n string currentPropertyPath = objectInfo.Path;\n\n if (!ContainsIndexingQualifiers(path))\n {\n currentPropertyPath = RemoveInitialIndexQualifier(currentPropertyPath);\n }\n\n if (currentPropertyPath.Equals(path, StringComparison.OrdinalIgnoreCase))\n {\n return Invert ? OrderStrictness.NotStrict : OrderStrictness.Strict;\n }\n\n return OrderStrictness.Irrelevant;\n }\n\n private static bool ContainsIndexingQualifiers(string path)\n {\n return path.Contains('[', StringComparison.Ordinal) && path.Contains(']', StringComparison.Ordinal);\n }\n\n private string RemoveInitialIndexQualifier(string sourcePath)\n {\n var indexQualifierRegex = new Regex(@\"^\\[[0-9]+]\\.\");\n\n if (!indexQualifierRegex.IsMatch(path))\n {\n Match match = indexQualifierRegex.Match(sourcePath);\n\n if (match.Success)\n {\n sourcePath = sourcePath.Substring(match.Length);\n }\n }\n\n return sourcePath;\n }\n\n public override string ToString()\n {\n return $\"Be {(Invert ? \"not strict\" : \"strict\")} about the order of collection items when path is \" + path;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Digit.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal class Digit\n{\n private readonly int length;\n private readonly Digit nextDigit;\n private int index;\n\n public Digit(int length, Digit nextDigit)\n {\n this.length = length;\n this.nextDigit = nextDigit;\n }\n\n public int[] GetIndices()\n {\n var indices = new List();\n\n Digit digit = this;\n\n while (digit is not null)\n {\n indices.Add(digit.index);\n digit = digit.nextDigit;\n }\n\n return indices.ToArray();\n }\n\n public bool Increment()\n {\n bool success = nextDigit?.Increment() == true;\n\n if (!success)\n {\n if (index < (length - 1))\n {\n index++;\n success = true;\n }\n else\n {\n index = 0;\n }\n }\n\n return success;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/INode.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a node in the object graph that is being compared as part of a structural equivalency check.\n/// This can be the root object, a collection item, a dictionary element, a property or a field.\n/// \npublic interface INode\n{\n /// \n /// The name of the variable on which a structural equivalency assertion is executed or\n /// the default if reflection failed.\n /// \n GetSubjectId GetSubjectId { get; }\n\n /// \n /// Gets the type of this node, e.g. the type of the field or property, or the type of the collection item.\n /// \n Type Type { get; }\n\n /// \n /// Gets the type of the parent node, e.g. the type that declares a property or field.\n /// \n /// \n /// Is for the root object.\n /// \n Type ParentType { get; }\n\n /// \n /// Gets the path from the root of the subject upto and including the current node.\n /// \n Pathway Subject { get; internal set; }\n\n /// \n /// Gets the path from the root of the expectation upto and including the current node.\n /// \n Pathway Expectation { get; }\n\n /// \n /// Gets a zero-based number representing the depth within the object graph\n /// \n /// \n /// The root object has a depth of 0, the next nested object a depth of 1, etc.\n /// See also this article\n /// \n int Depth { get; }\n\n /// \n /// Gets a value indicating whether the current node is the root.\n /// \n bool IsRoot { get; }\n\n /// \n /// Gets a value indicating if the root of this graph is a collection.\n /// \n bool RootIsCollection { get; }\n\n /// \n /// Adjusts the current node to reflect a remapped subject member during a structural equivalency check.\n /// Ensures that assertion failures report the correct subject member name when the matching process selects\n /// a different member in the subject compared to the expectation.\n /// \n /// \n /// The specific member in the subject that the current node should be remapped to.\n /// \n void AdjustForRemappedSubject(IMember subjectMember);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MemberVisibilityExtensions.cs", "using System;\nusing System.Collections.Concurrent;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Equivalency;\n\ninternal static class MemberVisibilityExtensions\n{\n private static readonly ConcurrentDictionary Cache = new();\n\n public static MemberKind ToMemberKind(this MemberVisibility visibility)\n {\n return Cache.GetOrAdd(visibility, static v =>\n {\n MemberKind result = MemberKind.None;\n\n#if NET6_0_OR_GREATER\n var flags = Enum.GetValues();\n#else\n var flags = (MemberVisibility[])Enum.GetValues(typeof(MemberVisibility));\n#endif\n foreach (MemberVisibility flag in flags)\n {\n if (v.HasFlag(flag))\n {\n var convertedFlag = flag switch\n {\n MemberVisibility.None => MemberKind.None,\n MemberVisibility.Internal => MemberKind.Internal,\n MemberVisibility.Public => MemberKind.Public,\n MemberVisibility.ExplicitlyImplemented => MemberKind.ExplicitlyImplemented,\n MemberVisibility.DefaultInterfaceProperties => MemberKind.DefaultInterfaceProperties,\n _ => throw new ArgumentOutOfRangeException(nameof(v), v, null)\n };\n\n result |= convertedFlag;\n }\n }\n\n return result;\n });\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XmlNodeAssertions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Xml;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Xml.Equivalency;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XmlNodeAssertions : XmlNodeAssertions\n{\n public XmlNodeAssertions(XmlNode xmlNode, AssertionChain assertionChain)\n : base(xmlNode, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XmlNodeAssertions : ReferenceTypeAssertions\n where TSubject : XmlNode\n where TAssertions : XmlNodeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public XmlNodeAssertions(TSubject xmlNode, AssertionChain assertionChain)\n : base(xmlNode, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current is equivalent to the node.\n /// \n /// The expected node\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(XmlNode expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (var subjectReader = new XmlNodeReader(Subject))\n using (var expectedReader = new XmlNodeReader(expected))\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, expectedReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: true);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not equivalent to\n /// the node.\n /// \n /// The unexpected node\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(XmlNode unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (var subjectReader = new XmlNodeReader(Subject))\n using (var unexpectedReader = new XmlNodeReader(unexpected))\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, unexpectedReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: false);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"XML node\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/PredicateBasedOrderingRule.cs", "using System;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Equivalency.Ordering;\n\ninternal class PredicateBasedOrderingRule : IOrderingRule\n{\n private readonly Func predicate;\n private readonly string description;\n\n public PredicateBasedOrderingRule(Expression> predicate)\n {\n description = predicate.Body.ToString();\n this.predicate = predicate.Compile();\n }\n\n public bool Invert { get; init; }\n\n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n if (predicate(objectInfo))\n {\n return Invert ? OrderStrictness.NotStrict : OrderStrictness.Strict;\n }\n\n return OrderStrictness.Irrelevant;\n }\n\n public override string ToString()\n {\n return $\"Be {(Invert ? \"not strict\" : \"strict\")} about the order of collections when {description}\";\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/ExceptionAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Equivalency.Steps;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an is in the correct state.\n/// \n[DebuggerNonUserCode]\npublic class ExceptionAssertions : ReferenceTypeAssertions, ExceptionAssertions>\n where TException : Exception\n{\n private readonly AssertionChain assertionChain;\n\n public ExceptionAssertions(IEnumerable exceptions, AssertionChain assertionChain)\n : base(exceptions, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Gets the exception object of the exception thrown.\n /// \n public TException And => SingleSubject;\n\n /// \n /// Gets the exception object of the exception thrown.\n /// \n public TException Which => And;\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"exception\";\n\n /// \n /// Asserts that the thrown exception has a message that matches .\n /// \n /// \n /// The pattern to match against the exception message. This parameter can contain a combination of literal text and\n /// wildcard (* and ?) characters, but it doesn't support regular expressions.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// can be a combination of literal and wildcard characters,\n /// but it doesn't support regular expressions. The following wildcard specifiers are permitted in\n /// .\n /// \n /// \n /// Wildcard character\n /// Description\n /// \n /// \n /// * (asterisk)\n /// Zero or more characters in that position.\n /// \n /// \n /// ? (question mark)\n /// Exactly one character in that position.\n /// \n /// \n /// \n public virtual ExceptionAssertions WithMessage(string expectedWildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .UsingLineBreaks\n .ForCondition(Subject.Any())\n .FailWith(\"Expected exception with message {0}{reason}, but no exception was thrown.\", expectedWildcardPattern);\n\n AssertExceptionMessage(Subject.Select(exc => exc.Message), expectedWildcardPattern, because,\n becauseArgs);\n\n return this;\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of type .\n /// \n /// The expected type of the inner exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public virtual ExceptionAssertions WithInnerException(string because = \"\",\n params object[] becauseArgs)\n where TInnerException : Exception\n {\n var expectedInnerExceptions = AssertInnerExceptions(typeof(TInnerException), because, becauseArgs);\n return new ExceptionAssertions(expectedInnerExceptions.Cast(), assertionChain);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of type .\n /// \n /// The expected type of the inner exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public ExceptionAssertions WithInnerException(Type innerException,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(innerException);\n\n return new ExceptionAssertions(AssertInnerExceptions(innerException, because, becauseArgs), assertionChain);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of the exact type (and not a derived exception type).\n /// \n /// The expected type of the inner exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public virtual ExceptionAssertions WithInnerExceptionExactly(string because = \"\",\n params object[] becauseArgs)\n where TInnerException : Exception\n {\n var exceptionExpression = AssertInnerExceptionExactly(typeof(TInnerException), because, becauseArgs);\n return new ExceptionAssertions(exceptionExpression.Cast(), assertionChain);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of the exact type (and not a derived exception type).\n /// \n /// The expected type of the inner exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public ExceptionAssertions WithInnerExceptionExactly(Type innerException,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(innerException);\n\n return new ExceptionAssertions(AssertInnerExceptionExactly(innerException, because, becauseArgs), assertionChain);\n }\n\n /// \n /// Asserts that the exception matches a particular condition.\n /// \n /// \n /// The condition that the exception must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public ExceptionAssertions Where(Expression> exceptionExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(exceptionExpression);\n\n Func condition = exceptionExpression.Compile();\n\n assertionChain\n .ForCondition(condition(SingleSubject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected exception where {0}{reason}, but the condition was not met by:\"\n + Environment.NewLine + Environment.NewLine + \"{1}.\",\n exceptionExpression, Subject);\n\n return this;\n }\n\n private IEnumerable AssertInnerExceptionExactly(Type innerException, string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.Any(e => e.InnerException is not null))\n .FailWith(\"Expected inner {0}{reason}, but the thrown exception has no inner exception.\", innerException);\n\n Exception[] expectedExceptions = Subject\n .Select(e => e.InnerException)\n .Where(e => e?.GetType() == innerException).ToArray();\n\n assertionChain\n .ForCondition(expectedExceptions.Length > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected inner {0}{reason}, but found {1}.\", innerException, SingleSubject.InnerException);\n\n return expectedExceptions;\n }\n\n private IEnumerable AssertInnerExceptions(Type innerException, string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.Any(e => e.InnerException is not null))\n .FailWith(\"Expected inner {0}{reason}, but the thrown exception has no inner exception.\", innerException);\n\n Exception[] expectedInnerExceptions = Subject\n .Select(e => e.InnerException)\n .Where(e => e != null && e.GetType().IsSameOrInherits(innerException))\n .ToArray();\n\n assertionChain\n .ForCondition(expectedInnerExceptions.Length > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected inner {0}{reason}, but found {1}.\", innerException, SingleSubject.InnerException);\n\n return expectedInnerExceptions;\n }\n\n private TException SingleSubject\n {\n get\n {\n if (Subject.Count() > 1)\n {\n string thrownExceptions = BuildExceptionsString(Subject);\n\n AssertionEngine.TestFramework.Throw(\n $\"More than one exception was thrown. AwesomeAssertions cannot determine which Exception was meant.{Environment.NewLine}{thrownExceptions}\");\n }\n\n return Subject.Single();\n }\n }\n\n private static string BuildExceptionsString(IEnumerable exceptions)\n {\n return string.Join(Environment.NewLine,\n exceptions.Select(\n exception =>\n \"\\t\" + Formatter.ToString(exception)));\n }\n\n private void AssertExceptionMessage(IEnumerable messages, string expectation, string because, params object[] becauseArgs)\n {\n var results = new AssertionResultSet();\n\n foreach (string message in messages)\n {\n using (var scope = new AssertionScope())\n {\n var chain = AssertionChain.GetOrCreate();\n chain.OverrideCallerIdentifier(() => \"exception message\");\n chain.ReuseOnce();\n\n message.Should().MatchEquivalentOf(expectation, because, becauseArgs);\n\n results.AddSet(message, scope.Discard());\n }\n\n if (results.ContainsSuccessfulSet())\n {\n break;\n }\n }\n\n foreach (string failure in results.GetTheFailuresForTheSetWithTheFewestFailures())\n {\n string replacedCurlyBraces =\n failure.EscapePlaceholders();\n\n assertionChain.FailWith(replacedCurlyBraces);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IAssertionContext.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Provides the required information for executing an equality assertion between a subject and an expectation.\n/// \n/// The type of the subject.\npublic interface IAssertionContext\n{\n /// \n /// Gets the of the member that returned the current object, or if the current\n /// object represents the root object.\n /// \n INode SelectedNode { get; }\n\n /// \n /// Gets the value of the \n /// \n TSubject Subject { get; }\n\n /// \n /// Gets the value of the expectation object that was matched with the subject using a .\n /// \n TSubject Expectation { get; }\n\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n string Because { get; set; }\n\n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n object[] BecauseArgs { get; set; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/TypeExtensions.cs", "using System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing AwesomeAssertions.Equivalency;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class TypeExtensions\n{\n private const BindingFlags PublicInstanceMembersFlag =\n BindingFlags.Public | BindingFlags.Instance;\n\n private const BindingFlags AllStaticAndInstanceMembersFlag =\n PublicInstanceMembersFlag | BindingFlags.NonPublic | BindingFlags.Static;\n\n private static readonly ConcurrentDictionary HasValueSemanticsCache = new();\n private static readonly ConcurrentDictionary TypeIsRecordCache = new();\n\n public static bool IsDecoratedWith(this Type type)\n where TAttribute : Attribute\n {\n return type.IsDefined(typeof(TAttribute), inherit: false);\n }\n\n public static bool IsDecoratedWith(this MemberInfo type)\n where TAttribute : Attribute\n {\n // Do not use MemberInfo.IsDefined\n // There is an issue with PropertyInfo and EventInfo preventing the inherit option to work.\n // https://github.com/dotnet/runtime/issues/30219\n return Attribute.IsDefined(type, typeof(TAttribute), inherit: false);\n }\n\n public static bool IsDecoratedWithOrInherit(this Type type)\n where TAttribute : Attribute\n {\n return type.IsDefined(typeof(TAttribute), inherit: true);\n }\n\n public static bool IsDecoratedWithOrInherit(this MemberInfo type)\n where TAttribute : Attribute\n {\n // Do not use MemberInfo.IsDefined\n // There is an issue with PropertyInfo and EventInfo preventing the inherit option to work.\n // https://github.com/dotnet/runtime/issues/30219\n return Attribute.IsDefined(type, typeof(TAttribute), inherit: true);\n }\n\n public static bool IsDecoratedWith(this Type type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate).Any();\n }\n\n public static bool IsDecoratedWith(this MemberInfo type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate).Any();\n }\n\n public static bool IsDecoratedWithOrInherit(this Type type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate, inherit: true).Any();\n }\n\n public static IEnumerable GetMatchingAttributes(this Type type)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type);\n }\n\n public static IEnumerable GetMatchingAttributes(this Type type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate);\n }\n\n public static IEnumerable GetMatchingOrInheritedAttributes(this Type type)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, inherit: true);\n }\n\n public static IEnumerable GetMatchingOrInheritedAttributes(this Type type,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n return GetCustomAttributes(type, isMatchingAttributePredicate, inherit: true);\n }\n\n public static IEnumerable GetCustomAttributes(this MemberInfo type, bool inherit = false)\n where TAttribute : Attribute\n {\n // Do not use MemberInfo.GetCustomAttributes.\n // There is an issue with PropertyInfo and EventInfo preventing the inherit option to work.\n // https://github.com/dotnet/runtime/issues/30219\n return CustomAttributeExtensions.GetCustomAttributes(type, inherit);\n }\n\n private static IEnumerable GetCustomAttributes(MemberInfo type,\n Expression> isMatchingAttributePredicate, bool inherit = false)\n where TAttribute : Attribute\n {\n Func isMatchingAttribute = isMatchingAttributePredicate.Compile();\n return GetCustomAttributes(type, inherit).Where(isMatchingAttribute);\n }\n\n private static TAttribute[] GetCustomAttributes(this Type type, bool inherit = false)\n where TAttribute : Attribute\n {\n return (TAttribute[])type.GetCustomAttributes(typeof(TAttribute), inherit);\n }\n\n private static IEnumerable GetCustomAttributes(Type type,\n Expression> isMatchingAttributePredicate, bool inherit = false)\n where TAttribute : Attribute\n {\n Func isMatchingAttribute = isMatchingAttributePredicate.Compile();\n return GetCustomAttributes(type, inherit).Where(isMatchingAttribute);\n }\n\n /// \n /// Determines whether two objects refer to the same\n /// member.\n /// \n public static bool IsEquivalentTo(this IMember property, IMember otherProperty)\n {\n return (property.DeclaringType.IsSameOrInherits(otherProperty.DeclaringType) ||\n otherProperty.DeclaringType.IsSameOrInherits(property.DeclaringType)) &&\n property.Expectation.Name == otherProperty.Expectation.Name;\n }\n\n /// \n /// Returns the interfaces that the implements that are concrete\n /// versions of the .\n /// \n public static Type[] GetClosedGenericInterfaces(this Type type, Type openGenericType)\n {\n if (type.IsGenericType && type.GetGenericTypeDefinition() == openGenericType)\n {\n return [type];\n }\n\n Type[] interfaces = type.GetInterfaces();\n\n return\n interfaces\n .Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == openGenericType)\n .ToArray();\n }\n\n public static bool OverridesEquals(this Type type)\n {\n MethodInfo method = type\n .GetMethod(\"Equals\", [typeof(object)]);\n\n return method is not null\n && method.GetBaseDefinition().DeclaringType != method.DeclaringType;\n }\n\n /// \n /// Finds the property by a case-sensitive name and with a certain visibility.\n /// \n /// \n /// If both a normal property and one that was implemented through an explicit interface implementation with the same name exist,\n /// then the normal property will be returned.\n /// \n /// \n /// Returns if no such property exists.\n /// \n public static PropertyInfo FindProperty(this Type type, string propertyName, MemberVisibility memberVisibility)\n {\n var properties = type.GetProperties(memberVisibility.ToMemberKind());\n\n return Array.Find(properties, p =>\n p.Name == propertyName || p.Name.EndsWith(\".\" + propertyName, StringComparison.Ordinal));\n }\n\n /// \n /// Finds the field by a case-sensitive name.\n /// \n /// \n /// Returns if no such field exists.\n /// \n public static FieldInfo FindField(this Type type, string fieldName, MemberVisibility memberVisibility)\n {\n var fields = type.GetFields(memberVisibility.ToMemberKind());\n\n return Array.Find(fields, p => p.Name == fieldName);\n }\n\n /// \n /// Check if the type is declared as abstract.\n /// \n /// Type to be checked\n public static bool IsCSharpAbstract(this Type type)\n {\n return type.IsAbstract && !type.IsSealed;\n }\n\n /// \n /// Check if the type is declared as sealed.\n /// \n /// Type to be checked\n public static bool IsCSharpSealed(this Type type)\n {\n return type.IsSealed && !type.IsAbstract;\n }\n\n /// \n /// Check if the type is declared as static.\n /// \n /// Type to be checked\n public static bool IsCSharpStatic(this Type type)\n {\n return type.IsSealed && type.IsAbstract;\n }\n\n public static MethodInfo GetMethod(this Type type, string methodName, IEnumerable parameterTypes)\n {\n return type.GetMethods(AllStaticAndInstanceMembersFlag)\n .SingleOrDefault(m =>\n m.Name == methodName && m.GetParameters().Select(p => p.ParameterType).SequenceEqual(parameterTypes));\n }\n\n public static bool HasMethod(this Type type, string methodName, IEnumerable parameterTypes)\n {\n return type.GetMethod(methodName, parameterTypes) is not null;\n }\n\n public static MethodInfo GetParameterlessMethod(this Type type, string methodName)\n {\n return type.GetMethod(methodName, Enumerable.Empty());\n }\n\n public static PropertyInfo FindPropertyByName(this Type type, string propertyName)\n {\n return type.GetProperty(propertyName, AllStaticAndInstanceMembersFlag);\n }\n\n public static bool HasExplicitlyImplementedProperty(this Type type, Type interfaceType, string propertyName)\n {\n bool hasGetter = type.HasParameterlessMethod($\"{interfaceType.FullName}.get_{propertyName}\");\n\n bool hasSetter = type.GetMethods(AllStaticAndInstanceMembersFlag)\n .SingleOrDefault(m =>\n m.Name == $\"{interfaceType.FullName}.set_{propertyName}\" &&\n m.GetParameters().Length == 1) is not null;\n\n return hasGetter || hasSetter;\n }\n\n private static bool HasParameterlessMethod(this Type type, string methodName)\n {\n return type.GetParameterlessMethod(methodName) is not null;\n }\n\n public static PropertyInfo GetIndexerByParameterTypes(this Type type, IEnumerable parameterTypes)\n {\n return type.GetProperties(AllStaticAndInstanceMembersFlag)\n .SingleOrDefault(p =>\n p.IsIndexer() && p.GetIndexParameters().Select(i => i.ParameterType).SequenceEqual(parameterTypes));\n }\n\n public static bool IsIndexer(this PropertyInfo member)\n {\n return member.GetIndexParameters().Length != 0;\n }\n\n public static ConstructorInfo GetConstructor(this Type type, IEnumerable parameterTypes)\n {\n const BindingFlags allInstanceMembersFlag =\n BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;\n\n return type\n .GetConstructors(allInstanceMembersFlag)\n .SingleOrDefault(m => m.GetParameters().Select(p => p.ParameterType).SequenceEqual(parameterTypes));\n }\n\n private static IEnumerable GetConversionOperators(this Type type, Type sourceType, Type targetType,\n Func predicate)\n {\n return type\n .GetMethods()\n .Where(m =>\n m.IsPublic\n && m.IsStatic\n && m.IsSpecialName\n && m.ReturnType == targetType\n && predicate(m.Name)\n && m.GetParameters() is { Length: 1 } parameters\n && parameters[0].ParameterType == sourceType);\n }\n\n public static bool IsAssignableToOpenGeneric(this Type type, Type definition)\n {\n // The CLR type system does not consider anything to be assignable to an open generic type.\n // For the purposes of test assertions, the user probably means that the subject type is\n // assignable to any generic type based on the given generic type definition.\n if (definition.IsInterface)\n {\n return type.IsImplementationOfOpenGeneric(definition);\n }\n\n return type == definition || type.IsDerivedFromOpenGeneric(definition);\n }\n\n private static bool IsImplementationOfOpenGeneric(this Type type, Type definition)\n {\n // check subject against definition\n if (type.IsInterface && type.IsGenericType &&\n type.GetGenericTypeDefinition() == definition)\n {\n return true;\n }\n\n // check subject's interfaces against definition\n return type.GetInterfaces()\n .Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == definition);\n }\n\n public static bool IsDerivedFromOpenGeneric(this Type type, Type definition)\n {\n if (type == definition)\n {\n // do not consider a type to be derived from itself\n return false;\n }\n\n // check subject and its base types against definition\n for (Type baseType = type;\n baseType is not null;\n baseType = baseType.BaseType)\n {\n if (baseType.IsGenericType && baseType.GetGenericTypeDefinition() == definition)\n {\n return true;\n }\n }\n\n return false;\n }\n\n public static bool IsUnderNamespace(this Type type, string @namespace)\n {\n return IsGlobalNamespace()\n || IsExactNamespace()\n || IsParentNamespace();\n\n bool IsGlobalNamespace() => @namespace is null;\n bool IsExactNamespace() => IsNamespacePrefix() && type.Namespace.Length == @namespace.Length;\n bool IsParentNamespace() => IsNamespacePrefix() && type.Namespace[@namespace.Length] is '.';\n bool IsNamespacePrefix() => type.Namespace?.StartsWith(@namespace, StringComparison.Ordinal) == true;\n }\n\n public static bool IsSameOrInherits(this Type actualType, Type expectedType)\n {\n return actualType == expectedType ||\n expectedType.IsAssignableFrom(actualType);\n }\n\n public static MethodInfo GetExplicitConversionOperator(this Type type, Type sourceType, Type targetType)\n {\n return type\n .GetConversionOperators(sourceType, targetType, name => name is \"op_Explicit\")\n .SingleOrDefault();\n }\n\n public static MethodInfo GetImplicitConversionOperator(this Type type, Type sourceType, Type targetType)\n {\n return type\n .GetConversionOperators(sourceType, targetType, name => name is \"op_Implicit\")\n .SingleOrDefault();\n }\n\n public static bool HasValueSemantics(this Type type)\n {\n return HasValueSemanticsCache.GetOrAdd(type, static t =>\n t.OverridesEquals() &&\n !t.IsAnonymous() &&\n !t.IsTuple() &&\n !IsKeyValuePair(t));\n }\n\n private static bool IsTuple(this Type type)\n {\n if (!type.IsGenericType)\n {\n return false;\n }\n\n#if !(NET47 || NETSTANDARD2_0)\n return typeof(ITuple).IsAssignableFrom(type);\n#else\n Type openType = type.GetGenericTypeDefinition();\n\n return openType == typeof(ValueTuple<>)\n || openType == typeof(ValueTuple<,>)\n || openType == typeof(ValueTuple<,,>)\n || openType == typeof(ValueTuple<,,,>)\n || openType == typeof(ValueTuple<,,,,>)\n || openType == typeof(ValueTuple<,,,,,>)\n || openType == typeof(ValueTuple<,,,,,,>)\n || (openType == typeof(ValueTuple<,,,,,,,>) && IsTuple(type.GetGenericArguments()[7]))\n || openType == typeof(Tuple<>)\n || openType == typeof(Tuple<,>)\n || openType == typeof(Tuple<,,>)\n || openType == typeof(Tuple<,,,>)\n || openType == typeof(Tuple<,,,,>)\n || openType == typeof(Tuple<,,,,,>)\n || openType == typeof(Tuple<,,,,,,>)\n || (openType == typeof(Tuple<,,,,,,,>) && IsTuple(type.GetGenericArguments()[7]));\n#endif\n }\n\n private static bool IsAnonymous(this Type type)\n {\n bool nameContainsAnonymousType = type.FullName.Contains(\"AnonymousType\", StringComparison.Ordinal);\n\n if (!nameContainsAnonymousType)\n {\n return false;\n }\n\n bool hasCompilerGeneratedAttribute =\n type.IsDecoratedWith();\n\n return hasCompilerGeneratedAttribute;\n }\n\n public static bool IsRecord(this Type type)\n {\n return TypeIsRecordCache.GetOrAdd(type, static t => t.IsRecordClass() || t.IsRecordStruct());\n }\n\n private static bool IsRecordClass(this Type type)\n {\n return type.GetMethod(\"$\", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) is { } &&\n type.GetProperty(\"EqualityContract\", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)?\n .GetMethod?.IsDecoratedWith() == true;\n }\n\n private static bool IsRecordStruct(this Type type)\n {\n // As noted here: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/record-structs#open-questions\n // recognizing record structs from metadata is an open point. The following check is based on common sense\n // and heuristic testing, apparently giving good results but not supported by official documentation.\n return type.BaseType == typeof(ValueType) &&\n type.GetMethod(\"PrintMembers\", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly, null,\n [typeof(StringBuilder)], null) is { } &&\n type.GetMethod(\"op_Equality\", BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly, null,\n [type, type], null)?\n .IsDecoratedWith() == true;\n }\n\n private static bool IsKeyValuePair(Type type)\n {\n return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(KeyValuePair<,>);\n }\n\n /// \n /// If the type provided is a nullable type, gets the underlying type. Returns the type itself otherwise.\n /// \n public static Type NullableOrActualType(this Type type)\n {\n if (type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))\n {\n type = type.GetGenericArguments()[0];\n }\n\n return type;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Tracing/StringBuilderTraceWriter.cs", "using System;\nusing System.Text;\n\nnamespace AwesomeAssertions.Equivalency.Tracing;\n\npublic class StringBuilderTraceWriter : ITraceWriter\n{\n private readonly StringBuilder builder = new();\n private int depth = 1;\n\n public void AddSingle(string trace)\n {\n WriteLine(trace);\n }\n\n public IDisposable AddBlock(string trace)\n {\n WriteLine(trace);\n WriteLine(\"{\");\n depth++;\n\n return new Disposable(() =>\n {\n depth--;\n WriteLine(\"}\");\n });\n }\n\n private void WriteLine(string trace)\n {\n foreach (string traceLine in trace.Split([Environment.NewLine], StringSplitOptions.RemoveEmptyEntries))\n {\n builder.Append(new string(' ', depth * 2)).AppendLine(traceLine);\n }\n }\n\n public override string ToString()\n {\n return builder.ToString();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/AttributeData.cs", "namespace AwesomeAssertions.Xml.Equivalency;\n\ninternal class AttributeData\n{\n public AttributeData(string namespaceUri, string localName, string value, string prefix)\n {\n NamespaceUri = namespaceUri;\n LocalName = localName;\n Value = value;\n Prefix = prefix;\n }\n\n public string NamespaceUri { get; }\n\n public string LocalName { get; }\n\n public string Value { get; }\n\n private string Prefix { get; }\n\n public string QualifiedName\n {\n get\n {\n if (string.IsNullOrEmpty(Prefix))\n {\n return LocalName;\n }\n\n return Prefix + \":\" + LocalName;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/CollectionMemberOrderingRuleDecorator.cs", "namespace AwesomeAssertions.Equivalency.Ordering;\n\ninternal class CollectionMemberOrderingRuleDecorator : IOrderingRule\n{\n private readonly IOrderingRule orderingRule;\n\n public CollectionMemberOrderingRuleDecorator(IOrderingRule orderingRule)\n {\n this.orderingRule = orderingRule;\n }\n\n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n return orderingRule.Evaluate(new CollectionMemberObjectInfo(objectInfo));\n }\n\n public override string ToString()\n {\n return orderingRule.ToString();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Ordering/MatchAllOrderingRule.cs", "namespace AwesomeAssertions.Equivalency.Ordering;\n\n/// \n/// An ordering rule that basically states that the order of items in all collections is important.\n/// \ninternal class MatchAllOrderingRule : IOrderingRule\n{\n /// \n /// Determines if ordering of the member referred to by the current is relevant.\n /// \n public OrderStrictness Evaluate(IObjectInfo objectInfo)\n {\n return OrderStrictness.Strict;\n }\n\n public override string ToString()\n {\n return \"Always be strict about the collection order\";\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Covariance.cs", "#if NET5_0_OR_GREATER\n\nusing System;\nusing JetBrains.Annotations;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Covariance\n {\n [Fact]\n public void Excluding_a_covariant_property_should_work()\n {\n // Arrange\n var actual = new DerivedWithCovariantOverride(new DerivedWithProperty\n {\n DerivedProperty = \"a\",\n BaseProperty = \"a_base\"\n })\n {\n OtherProp = \"other\"\n };\n\n var expectation = new DerivedWithCovariantOverride(new DerivedWithProperty\n {\n DerivedProperty = \"b\",\n BaseProperty =\n \"b_base\"\n })\n {\n OtherProp = \"other\"\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(d => d.Property));\n }\n\n [Fact]\n public void Excluding_a_covariant_property_through_the_base_class_excludes_the_base_class_property()\n {\n // Arrange\n var actual = new DerivedWithCovariantOverride(new DerivedWithProperty\n {\n DerivedProperty = \"a\",\n BaseProperty = \"a_base\"\n })\n {\n OtherProp = \"other\"\n };\n\n BaseWithAbstractProperty expectation = new DerivedWithCovariantOverride(new DerivedWithProperty\n {\n DerivedProperty =\n \"b\",\n BaseProperty = \"b_base\"\n })\n {\n OtherProp = \"other\"\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(d => d.Property));\n\n // Assert\n act.Should().Throw().WithMessage(\"No members*\");\n }\n\n private class BaseWithProperty\n {\n [UsedImplicitly]\n public string BaseProperty { get; set; }\n }\n\n private class DerivedWithProperty : BaseWithProperty\n {\n [UsedImplicitly]\n public string DerivedProperty { get; set; }\n }\n\n private abstract class BaseWithAbstractProperty\n {\n public abstract BaseWithProperty Property { get; }\n }\n\n private sealed class DerivedWithCovariantOverride : BaseWithAbstractProperty\n {\n public override DerivedWithProperty Property { get; }\n\n [UsedImplicitly]\n public string OtherProp { get; set; }\n\n public DerivedWithCovariantOverride(DerivedWithProperty prop)\n {\n Property = prop;\n }\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DefaultValueFormatter.cs", "using System;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Reflectify;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DefaultValueFormatter : IValueFormatter\n{\n /// \n /// Determines whether this instance can handle the specified value.\n /// \n /// The value.\n /// \n /// if this instance can handle the specified value; otherwise, .\n /// \n public virtual bool CanHandle(object value)\n {\n return true;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n if (value.GetType() == typeof(object))\n {\n formattedGraph.AddFragment($\"System.Object (HashCode={value.GetHashCode()})\");\n return;\n }\n\n if (HasCompilerGeneratedToStringImplementation(value))\n {\n WriteTypeAndMemberValues(value, formattedGraph, formatChild);\n }\n else if (context.UseLineBreaks)\n {\n formattedGraph.AddFragmentOnNewLine(value.ToString());\n }\n else\n {\n formattedGraph.AddFragment(value.ToString());\n }\n }\n\n /// \n /// Selects which members of to format.\n /// \n /// The of the object being formatted.\n /// The members of that will be included when formatting this object.\n /// The default is all non-private members.\n protected virtual MemberInfo[] GetMembers(Type type)\n {\n return type.GetMembers(MemberKind.Public);\n }\n\n private static bool HasCompilerGeneratedToStringImplementation(object value)\n {\n Type type = value.GetType();\n\n return HasDefaultToStringImplementation(value) || type.IsCompilerGenerated();\n }\n\n private static bool HasDefaultToStringImplementation(object value)\n {\n string str = value.ToString();\n\n return str is null || str == value.GetType().ToString();\n }\n\n private void WriteTypeAndMemberValues(object obj, FormattedObjectGraph formattedGraph, FormatChild formatChild)\n {\n Type type = obj.GetType();\n WriteTypeName(formattedGraph, type);\n WriteTypeValue(obj, formattedGraph, formatChild, type);\n }\n\n private void WriteTypeName(FormattedObjectGraph formattedGraph, Type type)\n {\n var typeName = type.HasFriendlyName() ? TypeDisplayName(type) : string.Empty;\n formattedGraph.AddFragment(typeName);\n }\n\n private void WriteTypeValue(object obj, FormattedObjectGraph formattedGraph, FormatChild formatChild, Type type)\n {\n MemberInfo[] members = GetMembers(type);\n if (members.Length == 0)\n {\n formattedGraph.AddFragment(\"{ }\");\n }\n else\n {\n formattedGraph.EnsureInitialNewLine();\n formattedGraph.AddLine(\"{\");\n WriteMemberValues(obj, members, formattedGraph, formatChild);\n formattedGraph.AddFragmentOnNewLine(\"}\");\n }\n }\n\n private static void WriteMemberValues(object obj, MemberInfo[] members, FormattedObjectGraph formattedGraph, FormatChild formatChild)\n {\n using var iterator = new Iterator(members.OrderBy(mi => mi.Name, StringComparer.Ordinal));\n\n while (iterator.MoveNext())\n {\n WriteMemberValueTextFor(obj, iterator.Current, formattedGraph, formatChild);\n\n if (!iterator.IsLast)\n {\n formattedGraph.AddFragment(\", \");\n }\n }\n }\n\n /// \n /// Selects the name to display for .\n /// \n /// The of the object being formatted.\n /// The name to be displayed for .\n /// The default is .\n protected virtual string TypeDisplayName(Type type) => TypeValueFormatter.Format(type);\n\n private static void WriteMemberValueTextFor(object value, MemberInfo member, FormattedObjectGraph formattedGraph,\n FormatChild formatChild)\n {\n object memberValue;\n\n try\n {\n memberValue = member switch\n {\n FieldInfo fi => fi.GetValue(value),\n PropertyInfo pi => pi.GetValue(value),\n _ => throw new InvalidOperationException()\n };\n }\n catch (Exception ex)\n {\n ex = (ex as TargetInvocationException)?.InnerException ?? ex;\n memberValue = $\"[Member '{member.Name}' threw an exception: '{ex.Message}']\";\n }\n\n formattedGraph.AddFragmentOnNewLine($\"{new string(' ', FormattedObjectGraph.SpacesPerIndentation)}{member.Name} = \");\n formatChild(member.Name, memberValue, formattedGraph);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AssertionExtensionsSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Numeric;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Specialized;\nusing AwesomeAssertions.Types;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class AssertionExtensionsSpecs\n{\n [Fact]\n public void Assertions_classes_override_equals()\n {\n // Arrange / Act\n var equalsOverloads = AllTypes.From(typeof(AwesomeAssertions.AssertionExtensions).Assembly)\n .ThatAreClasses()\n .Where(t => t.IsPublic && t.Name.TrimEnd('`', '1', '2', '3').EndsWith(\"Assertions\", StringComparison.Ordinal))\n .Select(e => GetMostParentType(e))\n .Distinct()\n .Select(t => (type: t, overridesEquals: OverridesEquals(t)))\n .ToList();\n\n // Assert\n equalsOverloads.Should().OnlyContain(e => e.overridesEquals);\n }\n\n private static bool OverridesEquals(Type t)\n {\n MethodInfo equals = t.GetMethod(\"Equals\", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public,\n null, [typeof(object)], null);\n\n return equals is not null;\n }\n\n public static TheoryData ClassesWithGuardEquals =>\n [\n new ObjectAssertions(default, AssertionChain.GetOrCreate()),\n new BooleanAssertions(default, AssertionChain.GetOrCreate()),\n new DateTimeAssertions(default, AssertionChain.GetOrCreate()),\n new DateTimeRangeAssertions(default, AssertionChain.GetOrCreate(), default, default, default),\n new DateTimeOffsetAssertions(default, AssertionChain.GetOrCreate()),\n new DateTimeOffsetRangeAssertions(default, AssertionChain.GetOrCreate(), default, default, default),\n new ExecutionTimeAssertions(new ExecutionTime(() => { }, () => new StopwatchTimer()), AssertionChain.GetOrCreate()),\n new GuidAssertions(default, AssertionChain.GetOrCreate()),\n new MethodInfoSelectorAssertions(AssertionChain.GetOrCreate()),\n new NumericAssertions>(default, AssertionChain.GetOrCreate()),\n new PropertyInfoSelectorAssertions(AssertionChain.GetOrCreate()),\n new SimpleTimeSpanAssertions(default, AssertionChain.GetOrCreate()),\n new TaskCompletionSourceAssertions(default, AssertionChain.GetOrCreate()),\n new TypeSelectorAssertions(AssertionChain.GetOrCreate()),\n new EnumAssertions>(default, AssertionChain.GetOrCreate()),\n#if NET6_0_OR_GREATER\n new DateOnlyAssertions(default, AssertionChain.GetOrCreate()),\n new TimeOnlyAssertions(default, AssertionChain.GetOrCreate()),\n#endif\n ];\n\n [Theory]\n [MemberData(nameof(ClassesWithGuardEquals))]\n public void Guarding_equals_throws(object obj)\n {\n // Act\n Action act = () => obj.Equals(null);\n\n // Assert\n act.Should().ThrowExactly();\n }\n\n [Theory]\n [InlineData(typeof(ReferenceTypeAssertions))]\n [InlineData(typeof(BooleanAssertions))]\n [InlineData(typeof(DateTimeAssertions))]\n [InlineData(typeof(DateTimeRangeAssertions))]\n [InlineData(typeof(DateTimeOffsetAssertions))]\n [InlineData(typeof(DateTimeOffsetRangeAssertions))]\n [InlineData(typeof(ExecutionTimeAssertions))]\n [InlineData(typeof(GuidAssertions))]\n [InlineData(typeof(MethodInfoSelectorAssertions))]\n [InlineData(typeof(PropertyInfoSelectorAssertions))]\n [InlineData(typeof(SimpleTimeSpanAssertions))]\n [InlineData(typeof(TaskCompletionSourceAssertionsBase))]\n [InlineData(typeof(TypeSelectorAssertions))]\n [InlineData(typeof(EnumAssertions>))]\n#if NET6_0_OR_GREATER\n [InlineData(typeof(DateOnlyAssertions))]\n [InlineData(typeof(TimeOnlyAssertions))]\n#endif\n public void Fake_should_method_throws(Type type)\n {\n // Arrange\n MethodInfo fakeOverload = AllTypes.From(typeof(AwesomeAssertions.AssertionExtensions).Assembly)\n .ThatAreClasses()\n .ThatAreStatic()\n .Where(t => t.IsPublic)\n .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public))\n .Single(m => m.Name == \"Should\" && IsGuardOverload(m)\n && m.GetParameters().Single().ParameterType.Name == type.Name);\n\n if (type.IsConstructedGenericType)\n {\n fakeOverload = fakeOverload.MakeGenericMethod(type.GenericTypeArguments);\n }\n\n // Act\n Action act = () => fakeOverload.Invoke(null, [null]);\n\n // Assert\n act.Should()\n .ThrowExactly()\n .WithInnerExceptionExactly()\n .WithMessage(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'.\");\n }\n\n [Fact]\n public void Should_methods_have_a_matching_overload_to_guard_against_chaining_and_constraints()\n {\n // Arrange / Act\n List shouldOverloads = AllTypes.From(typeof(AwesomeAssertions.AssertionExtensions).Assembly)\n .ThatAreClasses()\n .ThatAreStatic()\n .Where(t => t.IsPublic)\n .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public))\n .Where(m => m.Name == \"Should\")\n .ToList();\n\n List realOverloads =\n [\n ..shouldOverloads\n .Where(m => !IsGuardOverload(m))\n .Select(t => GetMostParentType(t.ReturnType))\n .Distinct(),\n\n // @jnyrup: DateTimeRangeAssertions and DateTimeOffsetRangeAssertions are manually added here,\n // because they expose AndConstraints,\n // and hence should have a guarding Should(DateTimeRangeAssertions _) overloads,\n // but they do not have a regular Should() overload,\n // as they are always constructed through the fluent API.\n typeof(DateTimeRangeAssertions<>),\n typeof(DateTimeOffsetRangeAssertions<>)\n ];\n\n List fakeOverloads = shouldOverloads\n .Where(m => IsGuardOverload(m))\n .Select(e => e.GetParameters()[0].ParameterType)\n .ToList();\n\n // Assert\n fakeOverloads.Should().BeEquivalentTo(realOverloads, opt => opt\n .Using(ctx => ctx.Subject.Name.Should().Be(ctx.Expectation.Name))\n .WhenTypeIs(),\n \"AssertionExtensions.cs should have a guard overload of Should calling InvalidShouldCall()\");\n }\n\n [Theory]\n [MemberData(nameof(GetShouldMethods), true)]\n public void Should_methods_returning_reference_type_assertions_are_annotated_with_not_null_attribute(MethodInfo method)\n {\n var notNullAttribute = method.GetParameters().Single().GetCustomAttribute();\n notNullAttribute.Should().NotBeNull();\n }\n\n [Theory]\n [MemberData(nameof(GetShouldMethods), false)]\n public void Should_methods_not_returning_reference_type_assertions_are_not_annotated_with_not_null_attribute(MethodInfo method)\n {\n var notNullAttribute = method.GetParameters().Single().GetCustomAttribute();\n notNullAttribute.Should().BeNull();\n }\n\n public static TheoryData GetShouldMethods(bool referenceTypes)\n {\n return new(AllTypes.From(typeof(AwesomeAssertions.AssertionExtensions).Assembly)\n .ThatAreClasses()\n .ThatAreStatic()\n .Where(t => t.IsPublic)\n .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public))\n .Where(m => m.Name == \"Should\"\n && !IsGuardOverload(m)\n && m.GetParameters().Length == 1\n && (referenceTypes ? ReturnsReferenceTypeAssertions(m) : !ReturnsReferenceTypeAssertions(m))));\n }\n\n private static bool ReturnsReferenceTypeAssertions(MethodInfo m) =>\n m.ReturnType.IsAssignableToOpenGeneric(typeof(ReferenceTypeAssertions<,>));\n\n private static bool IsGuardOverload(MethodInfo m) =>\n m.ReturnType == typeof(void) && m.IsDefined(typeof(ObsoleteAttribute));\n\n private static Type GetMostParentType(Type type)\n {\n while (type.BaseType != typeof(object))\n {\n type = type.BaseType;\n }\n\n if (type.IsGenericType)\n {\n type = type.GetGenericTypeDefinition();\n }\n\n return type;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IMember.cs", "using System;\nusing System.ComponentModel;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Exposes information about an object's member\n/// \npublic interface IMember : INode\n{\n /// \n /// Gets the type that declares the current member.\n /// \n Type DeclaringType { get; }\n\n /// \n /// Gets the type that was used to determine this member.\n /// \n Type ReflectedType { get; }\n\n /// \n /// Gets the value of the member from the provided \n /// \n object GetValue(object obj);\n\n /// \n /// Gets the access modifier for the getter of this member.\n /// \n CSharpAccessModifier GetterAccessibility { get; }\n\n /// \n /// Gets the access modifier for the setter of this member.\n /// \n CSharpAccessModifier SetterAccessibility { get; }\n\n /// \n /// Gets a value indicating whether the member is browsable in the source code editor. This is controlled with\n /// .\n /// \n bool IsBrowsable { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/RecordSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class RecordSpecs\n{\n [Fact]\n public void When_the_subject_is_a_record_it_should_compare_it_by_its_members()\n {\n var actual = new MyRecord { StringField = \"foo\", CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { StringField = \"foo\", CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_the_subject_is_a_record_struct_it_should_compare_it_by_its_members()\n {\n var actual = new MyRecordStruct(\"foo\", [\"bar\", \"zip\", \"foo\"]);\n\n var expected = new MyRecordStruct(\"foo\", [\"bar\", \"zip\", \"foo\"]);\n\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_the_subject_is_a_record_it_should_mention_that_in_the_configuration_output()\n {\n var actual = new MyRecord { StringField = \"foo\", };\n\n var expected = new MyRecord { StringField = \"bar\", };\n\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n act.Should().Throw()\n .WithMessage(\"*Compare records by their members*\");\n }\n\n [Fact]\n public void When_a_record_should_be_treated_as_a_value_type_it_should_use_its_equality_for_comparing()\n {\n var actual = new MyRecord { StringField = \"foo\", CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { StringField = \"foo\", CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n Action act = () => actual.Should().BeEquivalentTo(expected, o => o\n .ComparingByValue());\n\n act.Should().Throw()\n .WithMessage(\"*Expected*MyRecord*but found*MyRecord*\")\n .WithMessage(\"*Compare*MyRecord by value*\");\n }\n\n [Fact]\n public void When_all_records_should_be_treated_as_value_types_it_should_use_equality_for_comparing()\n {\n var actual = new MyRecord { StringField = \"foo\", CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { StringField = \"foo\", CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n Action act = () => actual.Should().BeEquivalentTo(expected, o => o\n .ComparingRecordsByValue());\n\n act.Should().Throw()\n .WithMessage(\"*Expected*MyRecord*but found*MyRecord*\")\n .WithMessage(\"*Compare records by value*\");\n }\n\n [Fact]\n public void\n When_all_records_except_a_specific_type_should_be_treated_as_value_types_it_should_compare_that_specific_type_by_its_members()\n {\n var actual = new MyRecord { StringField = \"foo\", CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { StringField = \"foo\", CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n actual.Should().BeEquivalentTo(expected, o => o\n .ComparingRecordsByValue()\n .ComparingByMembers());\n }\n\n [Fact]\n public void When_global_record_comparing_options_are_chained_it_should_ensure_the_last_one_wins()\n {\n var actual = new MyRecord { CollectionProperty = [\"bar\", \"zip\", \"foo\"] };\n\n var expected = new MyRecord { CollectionProperty = [\"foo\", \"bar\", \"zip\"] };\n\n actual.Should().BeEquivalentTo(expected, o => o\n .ComparingRecordsByValue()\n .ComparingRecordsByMembers());\n }\n\n private record MyRecord\n {\n public string StringField;\n\n public string[] CollectionProperty { get; init; }\n }\n\n private record struct MyRecordStruct(string StringField, string[] CollectionProperty)\n {\n public string StringField = StringField;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/AssertionChain.cs", "using System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Threading;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Provides a fluent API to build simple or composite assertions, and which can flow from one assertion to another.\n/// \n/// \n/// This is the core engine of many of the assertion APIs in this library. When combined with ,\n/// you can run multiple assertions which failure messages will be collected until the scope is disposed.\n/// \npublic sealed class AssertionChain\n{\n private readonly Func getCurrentScope;\n private readonly ContextDataDictionary contextData = new();\n private string fallbackIdentifier = \"object\";\n private Func getCallerIdentifier;\n private Func reason;\n private bool? succeeded;\n\n // We need to keep track of this because we don't want the second successful assertion hide the first unsuccessful assertion\n private Func expectation;\n private string callerPostfix = string.Empty;\n\n private static readonly AsyncLocal Instance = new();\n\n /// \n /// Ensures that the next call to will reuse the current instance.\n /// \n public void ReuseOnce()\n {\n Instance.Value = this;\n }\n\n /// \n /// Indicates whether the previous assertion in the chain was successful.\n /// \n /// \n /// This property is used internally to determine if subsequent assertions\n /// should be evaluated based on the result of the previous assertion.\n /// \n internal bool PreviousAssertionSucceeded { get; private set; } = true;\n\n /// \n /// Indicates whether the caller identifier has been manually overridden.\n /// \n /// \n /// This property is used to track if the caller identifier has been customized using the\n /// method or similar methods that modify the identifier.\n /// \n public bool HasOverriddenCallerIdentifier { get; private set; }\n\n /// \n /// Either starts a new assertion chain, or, when was called, for once, will return\n /// an existing instance.\n /// \n public static AssertionChain GetOrCreate()\n {\n if (Instance.Value != null)\n {\n AssertionChain assertionChain = Instance.Value;\n Instance.Value = null;\n return assertionChain;\n }\n\n return new AssertionChain(() => AssertionScope.Current,\n () => AwesomeAssertions.CallerIdentifier.DetermineCallerIdentity());\n }\n\n private AssertionChain(Func getCurrentScope, Func getCallerIdentifier)\n {\n this.getCurrentScope = getCurrentScope;\n\n this.getCallerIdentifier = () =>\n {\n var scopeName = getCurrentScope().Name();\n var callerIdentifier = getCallerIdentifier();\n\n if (scopeName is null)\n {\n return callerIdentifier;\n }\n else if (callerIdentifier is null)\n {\n return scopeName;\n }\n else\n {\n return $\"{scopeName}/{callerIdentifier}\";\n }\n };\n }\n\n /// \n /// The effective caller identifier including any prefixes and postfixes configured through\n /// .\n /// \n /// \n /// Can be overridden with .\n /// \n public string CallerIdentifier => getCallerIdentifier() + callerPostfix;\n\n /// \n /// Adds an explanation of why the assertion is supposed to succeed to the scope.\n /// \n /// \n /// An object containing a formatted phrase as is supported by explaining why the assertion\n /// is needed, as well as zero or more objects to format the placeholders.\n /// If the phrase does not start with the word because, it is prepended automatically.explaining why the assertion is needed.\n /// \n public AssertionChain BecauseOf(Reason reason)\n {\n return BecauseOf(reason.FormattedMessage, reason.Arguments);\n }\n\n /// \n /// Adds an explanation of why the assertion is supposed to succeed to the scope.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AssertionChain BecauseOf(string because, params object[] becauseArgs)\n {\n reason = () =>\n {\n try\n {\n string becauseOrEmpty = because ?? string.Empty;\n\n return becauseArgs?.Length > 0\n ? string.Format(CultureInfo.InvariantCulture, becauseOrEmpty, becauseArgs)\n : becauseOrEmpty;\n }\n catch (FormatException formatException)\n {\n return\n $\"**WARNING** because message '{because}' could not be formatted with string.Format{Environment.NewLine}{formatException.StackTrace}\";\n }\n };\n\n return this;\n }\n\n public AssertionChain ForCondition(bool condition)\n {\n if (PreviousAssertionSucceeded)\n {\n succeeded = condition;\n }\n\n return this;\n }\n\n public AssertionChain ForConstraint(OccurrenceConstraint constraint, int actualOccurrences)\n {\n if (PreviousAssertionSucceeded)\n {\n constraint.RegisterContextData((key, value) => contextData.Add(\n new ContextDataDictionary.DataItem(key, value, reportable: false, requiresFormatting: false)));\n\n succeeded = constraint.Assert(actualOccurrences);\n }\n\n return this;\n }\n\n public Continuation WithExpectation(string message, object arg1, Action chain)\n {\n return WithExpectation(message, chain, arg1);\n }\n\n public Continuation WithExpectation(string message, object arg1, object arg2, Action chain)\n {\n return WithExpectation(message, chain, arg1, arg2);\n }\n\n public Continuation WithExpectation(string message, Action chain)\n {\n return WithExpectation(message, chain, []);\n }\n\n private Continuation WithExpectation(string message, Action chain, params object[] args)\n {\n if (PreviousAssertionSucceeded)\n {\n expectation = () =>\n {\n var formatter = new FailureMessageFormatter(getCurrentScope().FormattingOptions)\n .WithReason(reason?.Invoke() ?? string.Empty)\n .WithContext(contextData)\n .WithIdentifier(CallerIdentifier)\n .WithFallbackIdentifier(fallbackIdentifier);\n\n return formatter.Format(message, args);\n };\n\n chain(this);\n\n expectation = null;\n }\n\n return new Continuation(this);\n }\n\n public AssertionChain WithDefaultIdentifier(string identifier)\n {\n fallbackIdentifier = identifier;\n return this;\n }\n\n public GivenSelector Given(Func selector)\n {\n return new GivenSelector(selector, this);\n }\n\n internal Continuation FailWithPreFormatted(string formattedFailReason)\n {\n return FailWith(() => formattedFailReason);\n }\n\n public Continuation FailWith(string message)\n {\n return FailWith(() => new FailReason(message));\n }\n\n public Continuation FailWith(string message, params object[] args)\n {\n return FailWith(() => new FailReason(message, args));\n }\n\n public Continuation FailWith(string message, params Func[] argProviders)\n {\n return FailWith(\n () => new FailReason(\n message,\n argProviders.Select(a => a()).ToArray()));\n }\n\n public Continuation FailWith(Func getFailureReason)\n {\n return FailWith(() =>\n {\n var formatter = new FailureMessageFormatter(getCurrentScope().FormattingOptions)\n .WithReason(reason?.Invoke() ?? string.Empty)\n .WithContext(contextData)\n .WithIdentifier(CallerIdentifier)\n .WithFallbackIdentifier(fallbackIdentifier);\n\n FailReason failReason = getFailureReason();\n\n return formatter.Format(failReason.Message, failReason.Args);\n });\n }\n\n private Continuation FailWith(Func getFailureReason)\n {\n if (PreviousAssertionSucceeded)\n {\n PreviousAssertionSucceeded = succeeded is true;\n\n if (succeeded is not true)\n {\n string failure = getFailureReason();\n\n if (expectation is not null)\n {\n failure = expectation() + failure;\n }\n\n getCurrentScope().AddPreFormattedFailure(failure.Capitalize().RemoveTrailingWhitespaceFromLines());\n }\n }\n\n // Reset the state for successive assertions on this object\n succeeded = null;\n\n return new Continuation(this);\n }\n\n /// \n /// Allows overriding the caller identifier for the next call to one of the `FailWith` overloads instead\n /// of relying on the automatic behavior that extracts the variable names from the C# code.\n /// \n public void OverrideCallerIdentifier(Func getCallerIdentifier)\n {\n this.getCallerIdentifier = getCallerIdentifier;\n HasOverriddenCallerIdentifier = true;\n }\n\n /// \n /// Adds a postfix such as [0] to the caller identifier detected by the library.\n /// \n /// \n /// Can be used by an assertion that uses to return an object or\n /// collection on which another assertion is executed, and which wants to amend the automatically detected caller\n /// identifier with a postfix.\n /// \n public AssertionChain WithCallerPostfix(string postfix)\n {\n callerPostfix = postfix;\n HasOverriddenCallerIdentifier = true;\n\n return this;\n }\n\n /// \n /// Adds some information to the assertion that will be included in the message\n /// that is emitted if an assertion fails.\n /// \n public void AddReportable(string key, string value)\n {\n getCurrentScope().AddReportable(key, value);\n }\n\n /// \n /// Adds some information to the assertion that will be included in the message\n /// that is emitted if an assertion fails. The value is only calculated on failure.\n /// \n public void AddReportable(string key, Func getValue)\n {\n getCurrentScope().AddReportable(key, getValue);\n }\n\n /// \n /// Fluent alternative for \n /// \n public AssertionChain WithReportable(string name, Func content)\n {\n getCurrentScope().AddReportable(name, content);\n return this;\n }\n\n /// \n /// Registers a failure in the chain that doesn't need any parsing or formatting anymore.\n /// \n internal void AddPreFormattedFailure(string failure)\n {\n getCurrentScope().AddPreFormattedFailure(failure);\n }\n\n /// \n /// Gets a value indicating whether all assertions in the have succeeded.\n /// \n public bool Succeeded => PreviousAssertionSucceeded && succeeded is null or true;\n\n public AssertionChain UsingLineBreaks\n {\n get\n {\n getCurrentScope().FormattingOptions.UseLineBreaks = true;\n return this;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Tracing/GetTraceMessage.cs", "namespace AwesomeAssertions.Equivalency.Tracing;\n\n/// \n/// Defines a function that takes the full path from the root object until the current object\n/// in the equivalency operation separated by dots, and returns the trace message to log.\n/// \npublic delegate string GetTraceMessage(INode node);\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/MemberVisibility.cs", "using System;\n\n#pragma warning disable CA1714\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Determines which members are included in the equivalency assertion\n/// \n[Flags]\npublic enum MemberVisibility\n{\n None = 0,\n Internal = 1,\n Public = 2,\n ExplicitlyImplemented = 4,\n DefaultInterfaceProperties = 8\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/AssertionScopeSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution\n{\n /// \n /// Type specs.\n /// \n public partial class AssertionScopeSpecs\n {\n [Fact]\n public void When_disposed_it_should_throw_any_failures()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure1\");\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().StartWith(\"Failure1\");\n }\n }\n\n [Fact]\n public void When_disposed_it_should_throw_any_failures_and_properly_format_using_args()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure{0}\", 1);\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().StartWith(\"Failure1\");\n }\n }\n\n [Fact]\n public void When_lazy_version_is_not_disposed_it_should_not_execute_fail_reason_function()\n {\n // Arrange\n var scope = new AssertionScope();\n bool failReasonCalled = false;\n\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(() =>\n {\n failReasonCalled = true;\n return new FailReason(\"Failure\");\n });\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n act();\n failReasonCalled.Should().BeFalse(\" fail reason function cannot be called for scope that successful\");\n }\n\n [Fact]\n public void When_lazy_version_is_disposed_it_should_throw_any_failures_and_properly_format_using_args()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain\n .GetOrCreate()\n .FailWith(() => new FailReason(\"Failure{0}\", 1));\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().StartWith(\"Failure1\");\n }\n }\n\n [Fact]\n public void When_multiple_scopes_are_nested_it_should_throw_all_failures_from_the_outer_scope()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure1\");\n\n using (new AssertionScope())\n {\n AssertionChain.GetOrCreate().FailWith(\"Failure2\");\n\n using var deeplyNestedScope = new AssertionScope();\n AssertionChain.GetOrCreate().FailWith(\"Failure3\");\n }\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().ContainAll(\"Failure1\", \"Failure2\", \"Failure3\");\n }\n }\n\n [Fact]\n public void When_multiple_nested_scopes_each_have_multiple_failures_it_should_throw_all_failures_from_the_outer_scope()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure1.1\");\n AssertionChain.GetOrCreate().FailWith(\"Failure1.2\");\n\n using (new AssertionScope())\n {\n AssertionChain.GetOrCreate().FailWith(\"Failure2.1\");\n AssertionChain.GetOrCreate().FailWith(\"Failure2.2\");\n\n using var deeplyNestedScope = new AssertionScope();\n AssertionChain.GetOrCreate().FailWith(\"Failure3.1\");\n AssertionChain.GetOrCreate().FailWith(\"Failure3.2\");\n }\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().ContainAll(\n \"Failure1.1\", \"Failure1.2\", \"Failure2.1\", \"Failure2.2\", \"Failure3.1\", \"Failure3.2\");\n }\n }\n\n [Fact]\n public void When_a_nested_scope_is_discarded_its_failures_should_also_be_discarded()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure1\");\n\n using (new AssertionScope())\n {\n AssertionChain.GetOrCreate().FailWith(\"Failure2\");\n\n using var deeplyNestedScope = new AssertionScope();\n AssertionChain.GetOrCreate().FailWith(\"Failure3\");\n deeplyNestedScope.Discard();\n }\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n try\n {\n act();\n }\n catch (Exception exception)\n {\n exception.Message.Should().ContainAll(\"Failure1\", \"Failure2\")\n .And.NotContain(\"Failure3\");\n }\n }\n\n [Fact]\n public async Task When_using_a_scope_across_thread_boundaries_it_should_work()\n {\n using var semaphore = new SemaphoreSlim(0, 1);\n await Task.WhenAll(SemaphoreYieldAndWait(semaphore), SemaphoreYieldAndRelease(semaphore));\n }\n\n private static async Task SemaphoreYieldAndWait(SemaphoreSlim semaphore)\n {\n await Task.Yield();\n var scope = new AssertionScope();\n await semaphore.WaitAsync();\n scope.Should().BeSameAs(AssertionScope.Current);\n }\n\n private static async Task SemaphoreYieldAndRelease(SemaphoreSlim semaphore)\n {\n await Task.Yield();\n var scope = new AssertionScope();\n semaphore.Release();\n scope.Should().BeSameAs(AssertionScope.Current);\n }\n\n [Fact]\n public void When_custom_strategy_used_respect_its_behavior()\n {\n // Arrange\n using var _ = new AssertionScope(new FailWithStupidMessageAssertionStrategy());\n\n // Act\n Action act = () => AssertionChain.GetOrCreate().FailWith(\"Failure 1\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Good luck with understanding what's going on!\");\n }\n\n [Fact]\n public void When_custom_strategy_is_null_it_should_throw()\n {\n // Arrange\n IAssertionStrategy strategy = null;\n\n // Arrange / Act\n Func act = () => new AssertionScope(strategy);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"assertionStrategy\");\n }\n\n [Fact]\n public void When_using_a_custom_strategy_it_should_include_failure_messages_of_all_failing_assertions()\n {\n // Arrange\n var scope = new AssertionScope(new CustomAssertionStrategy());\n false.Should().BeTrue();\n true.Should().BeFalse();\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"*but found false*but found true*\");\n }\n\n [Fact]\n public void When_nested_scope_is_disposed_it_passes_reports_to_parent_scope()\n {\n // Arrange/Act\n var outerScope = new AssertionScope();\n outerScope.AddReportable(\"outerReportable\", \"foo\");\n\n using (var innerScope = new AssertionScope())\n {\n innerScope.AddReportable(\"innerReportable\", \"bar\");\n }\n\n AssertionChain.GetOrCreate().FailWith(\"whatever reason\");\n\n Action act = () => outerScope.Dispose();\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"Whatever reason*outerReportable*foo*innerReportable*bar*\");\n }\n\n [Fact]\n public void Formatting_options_passed_to_inner_assertion_scopes()\n {\n // Arrange\n var subject = new[]\n {\n new\n {\n Value = 42\n }\n };\n\n var expected = new[]\n {\n new\n {\n Value = 42\n },\n new\n {\n Value = 42\n }\n };\n\n // Act\n using var scope = new AssertionScope();\n scope.FormattingOptions.MaxDepth = 1;\n subject.Should().BeEquivalentTo(expected);\n\n // Assert\n scope.Discard().Should().ContainSingle()\n .Which.Should().Contain(\"Maximum recursion depth of 1 was reached\");\n }\n\n [Fact]\n public void Multiple_named_scopes_will_prefix_the_caller_identifier()\n {\n // Arrange\n List nonEmptyList = [1, 2];\n\n // Act\n Action act = () =>\n {\n using var scope1 = new AssertionScope(\"Test1\");\n using var scope2 = new AssertionScope(\"Test2\");\n nonEmptyList.Should().BeEmpty();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected Test1/Test2/nonEmptyList to be empty*\");\n }\n\n [Fact]\n public void A_scope_with_multiple_failures_after_a_successful_assertion_should_show_all_errors()\n {\n Action act = () =>\n {\n // any call to AssertionScope.Current (like in AssertionChain.GetOrCreate())\n _ = AssertionScope.Current.HasFailures();\n\n using (new AssertionScope())\n {\n 42.Should().Be(27);\n 42.Should().Be(23);\n }\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected value to be 27, but found 42*{Environment.NewLine}\" +\n \"*Expected value to be 23, but found 42*\");\n }\n\n public class CustomAssertionStrategy : IAssertionStrategy\n {\n private readonly List failureMessages = [];\n\n public IEnumerable FailureMessages => failureMessages;\n\n public IEnumerable DiscardFailures()\n {\n var discardedFailures = failureMessages.ToArray();\n failureMessages.Clear();\n return discardedFailures;\n }\n\n public void ThrowIfAny(IDictionary context)\n {\n if (failureMessages.Count > 0)\n {\n var builder = new StringBuilder();\n builder.AppendJoin(Environment.NewLine, failureMessages).AppendLine();\n\n if (context.Any())\n {\n foreach (KeyValuePair pair in context)\n {\n builder.AppendFormat(CultureInfo.InvariantCulture,\n $\"{Environment.NewLine}With {pair.Key}:{Environment.NewLine}{{0}}\", pair.Value);\n }\n }\n\n AssertionEngine.TestFramework.Throw(builder.ToString());\n }\n }\n\n public void HandleFailure(string message)\n {\n failureMessages.Add(message);\n }\n }\n\n internal class FailWithStupidMessageAssertionStrategy : IAssertionStrategy\n {\n public IEnumerable FailureMessages => [];\n\n public void HandleFailure(string message) =>\n AssertionEngine.TestFramework.Throw(\"Good luck with understanding what's going on!\");\n\n public IEnumerable DiscardFailures() => [];\n\n public void ThrowIfAny(IDictionary context)\n {\n // do nothing\n }\n }\n }\n}\n\n#pragma warning disable RCS1110, CA1050, S3903 // Declare type inside namespace.\npublic class AssertionScopeSpecsWithoutNamespace\n#pragma warning restore RCS1110, CA1050, S3903 // Declare type inside namespace.\n{\n [Fact]\n public void This_class_should_not_be_inside_a_namespace()\n {\n // Arrange\n Type type = typeof(AssertionScopeSpecsWithoutNamespace);\n\n // Act / Assert\n type.Assembly.Should().DefineType(null, type.Name, \"this class should not be inside a namespace\");\n }\n\n [Fact]\n public void When_the_test_method_is_not_inside_a_namespace_it_should_not_throw_a_NullReferenceException()\n {\n // Act\n Action act = () => 1.Should().Be(2, \"we don't want a NullReferenceException\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"*we don't want a NullReferenceException*\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/Equivalency/Failure.cs", "namespace AwesomeAssertions.Xml.Equivalency;\n\ninternal class Failure\n{\n public Failure(string formatString, params object[] formatParams)\n {\n FormatString = formatString;\n FormatParams = formatParams;\n }\n\n public string FormatString { get; }\n\n public object[] FormatParams { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Tracing/ITraceWriter.cs", "using System;\n\nnamespace AwesomeAssertions.Equivalency.Tracing;\n\n/// \n/// Represents an object that is used by the class to receive tracing statements on what is\n/// happening during a structural equivalency comparison.\n/// \npublic interface ITraceWriter\n{\n /// \n /// Writes a single line to the trace.\n /// \n void AddSingle(string trace);\n\n /// \n /// Starts a block that scopes an operation that should be written to the trace after the returned \n /// is disposed.\n /// \n IDisposable AddBlock(string trace);\n\n /// \n /// Returns a copy of the trace.\n /// \n string ToString();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/TupleSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class TupleSpecs\n{\n [Fact]\n public void When_a_nested_member_is_a_tuple_it_should_compare_its_property_for_equivalence()\n {\n // Arrange\n var actual = new { Tuple = (new[] { \"string1\" }, new[] { \"string2\" }) };\n\n var expected = new { Tuple = (new[] { \"string1\" }, new[] { \"string2\" }) };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_tuple_is_compared_it_should_compare_its_components()\n {\n // Arrange\n var actual = Tuple.Create(\"Hello\", true, new[] { 3, 2, 1 });\n var expected = Tuple.Create(\"Hello\", true, new[] { 1, 2, 3 });\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/NestedPropertiesSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class NestedPropertiesSpecs\n{\n [Fact]\n public void When_all_the_properties_of_the_nested_objects_are_equal_it_should_succeed()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1 { Text = \"Level1\", Level = new Level2 { Text = \"Level2\" } }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto { Text = \"Level1\", Level = new Level2Dto { Text = \"Level2\" } }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_the_expectation_contains_a_nested_null_it_should_properly_report_the_difference()\n {\n // Arrange\n var subject = new Root { Text = \"Root\", Level = new Level1 { Text = \"Level1\", Level = new Level2() } };\n\n var expected = new RootDto { Text = \"Root\", Level = new Level1Dto { Text = \"Level1\", Level = null } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Expected*Level.Level*to be , but found*Level2*Without automatic conversion*\");\n }\n\n [Fact]\n public void\n When_not_all_the_properties_of_the_nested_objects_are_equal_but_nested_objects_are_excluded_it_should_succeed()\n {\n // Arrange\n var subject = new\n {\n Property = new ClassWithValueSemanticsOnSingleProperty\n {\n Key = \"123\",\n NestedProperty = \"Should be ignored\"\n }\n };\n\n var expected = new\n {\n Property = new ClassWithValueSemanticsOnSingleProperty\n {\n Key = \"123\",\n NestedProperty = \"Should be ignored as well\"\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.WithoutRecursing());\n }\n\n [Fact]\n public void When_nested_objects_should_be_excluded_it_should_do_a_simple_equality_check_instead()\n {\n // Arrange\n var item = new Item { Child = new Item() };\n\n // Act\n Action act = () => item.Should().BeEquivalentTo(new Item(), options => options.WithoutRecursing());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*Item*null*\");\n }\n\n public class Item\n {\n public Item Child { get; set; }\n }\n\n [Fact]\n public void When_not_all_the_properties_of_the_nested_objects_are_equal_it_should_throw()\n {\n // Arrange\n var subject = new Root { Text = \"Root\", Level = new Level1 { Text = \"Level1\" } };\n\n var expected = new RootDto { Text = \"Root\", Level = new Level1Dto { Text = \"Level2\" } };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().Which.Message\n\n // Checking exception message exactly is against general guidelines\n // but in that case it was done on purpose, so that we have at least have a single\n // test confirming that whole mechanism of gathering description from\n // equivalency steps works.\n .Should().Be(\"\"\"\n Expected property subject.Level.Text to be the same string, but they differ at index 5:\n ↓ (actual)\n \"Level1\"\n \"Level2\"\n ↑ (expected).\n\n With configuration:\n - Prefer the declared type of the members\n - Compare enums by value\n - Compare tuples by their properties\n - Compare anonymous types by their properties\n - Compare records by their members\n - Include non-browsable members\n - Match member by name (or throw)\n - Be strict about the order of items in byte arrays\n - Without automatic conversion.\n\n \"\"\");\n }\n\n [Fact]\n public void When_the_actual_nested_object_is_null_it_should_throw()\n {\n // Arrange\n var subject = new Root { Text = \"Root\", Level = new Level1 { Text = \"Level2\" } };\n\n var expected = new RootDto { Text = \"Root\", Level = null };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*Level*to be *, but found*Level1*Level2*\");\n }\n\n public class StringSubContainer\n {\n public string SubValue { get; set; }\n }\n\n public class StringContainer\n {\n public StringContainer(string mainValue, string subValue = null)\n {\n MainValue = mainValue;\n SubValues = [new StringSubContainer { SubValue = subValue }];\n }\n\n public string MainValue { get; set; }\n\n public IList SubValues { get; set; }\n }\n\n public class MyClass2\n {\n public StringContainer One { get; set; }\n\n public StringContainer Two { get; set; }\n }\n\n [Fact]\n public void When_deeply_nested_strings_dont_match_it_should_properly_report_the_mismatches()\n {\n // Arrange\n MyClass2[] expected =\n [\n new MyClass2 { One = new StringContainer(\"EXPECTED\", \"EXPECTED\"), Two = new StringContainer(\"CORRECT\") },\n new MyClass2()\n ];\n\n MyClass2[] actual =\n [\n new MyClass2\n {\n One = new StringContainer(\"INCORRECT\", \"INCORRECT\"), Two = new StringContainer(\"CORRECT\")\n },\n new MyClass2()\n ];\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*EXPECTED*INCORRECT*EXPECTED*INCORRECT*\");\n }\n\n [Fact]\n public void When_the_nested_object_property_is_null_it_should_throw()\n {\n // Arrange\n var subject = new Root { Text = \"Root\", Level = null };\n\n var expected = new RootDto { Text = \"Root\", Level = new Level1Dto { Text = \"Level2\" } };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected property subject.Level*to be*Level1Dto*Level2*, but found *\");\n }\n\n [Fact]\n public void When_not_all_the_properties_of_the_nested_object_exist_on_the_expected_object_it_should_throw()\n {\n // Arrange\n var subject = new { Level = new { Text = \"Level1\", } };\n\n var expected = new { Level = new { Text = \"Level1\", OtherProperty = \"OtherProperty\" } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expectation has property Level.OtherProperty that the other object does not have*\");\n }\n\n [Fact]\n public void When_all_the_shared_properties_of_the_nested_objects_are_equal_it_should_succeed()\n {\n // Arrange\n var subject = new { Level = new { Text = \"Level1\", Property = \"Property\" } };\n\n var expected = new { Level = new { Text = \"Level1\", OtherProperty = \"OtherProperty\" } };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, options => options.ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_deeply_nested_properties_do_not_have_all_equal_values_it_should_throw()\n {\n // Arrange\n var root = new Root\n {\n Text = \"Root\",\n Level = new Level1 { Text = \"Level1\", Level = new Level2 { Text = \"Level2\" } }\n };\n\n var rootDto = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto { Text = \"Level1\", Level = new Level2Dto { Text = \"A wrong text value\" } }\n };\n\n // Act\n Action act = () => root.Should().BeEquivalentTo(rootDto);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected*Level.Level.Text*to be *\\\"Level2\\\"*A wrong text value*\");\n }\n\n [Fact]\n public void When_two_objects_have_the_same_nested_objects_it_should_not_throw()\n {\n // Arrange\n var c1 = new ClassOne();\n var c2 = new ClassOne();\n\n // Act / Assert\n c1.Should().BeEquivalentTo(c2);\n }\n\n [Fact]\n public void When_a_property_of_a_nested_object_doesnt_match_it_should_clearly_indicate_the_path()\n {\n // Arrange\n var c1 = new ClassOne();\n var c2 = new ClassOne();\n c2.RefOne.ValTwo = 2;\n\n // Act\n Action act = () => c1.Should().BeEquivalentTo(c2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property c1.RefOne.ValTwo to be 2, but found 3*\");\n }\n\n [Fact]\n public void Should_support_nested_collections_containing_empty_objects()\n {\n // Arrange\n OuterWithObject[] orig = [new OuterWithObject { MyProperty = [new Inner()] }];\n\n OuterWithObject[] expectation = [new OuterWithObject { MyProperty = [new Inner()] }];\n\n // Act / Assert\n orig.Should().BeEquivalentTo(expectation);\n }\n\n public class Inner;\n\n public class OuterWithObject\n {\n public Inner[] MyProperty { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/AttributeBasedFormatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Configuration;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Specialized value formatter that looks for static methods in the caller's assembly marked with the\n/// .\n/// \npublic class AttributeBasedFormatter : IValueFormatter\n{\n private Dictionary formatters;\n private ValueFormatterDetectionMode detectionMode;\n\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return IsScanningEnabled && value is not null && GetFormatter(value) is not null;\n }\n\n private static bool IsScanningEnabled => AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode == ValueFormatterDetectionMode.Scan;\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n MethodInfo method = GetFormatter(value);\n\n object[] parameters = [value, formattedGraph];\n\n method.Invoke(null, parameters);\n }\n\n private MethodInfo GetFormatter(object value)\n {\n Type valueType = value.GetType();\n\n do\n {\n if (Formatters.TryGetValue(valueType, out var formatter))\n {\n return formatter;\n }\n\n valueType = valueType.BaseType;\n }\n while (valueType is not null);\n\n return null;\n }\n\n private Dictionary Formatters\n {\n get\n {\n HandleValueFormatterDetectionModeChanges();\n\n return formatters ??= FindCustomFormatters();\n }\n }\n\n private void HandleValueFormatterDetectionModeChanges()\n {\n ValueFormatterDetectionMode configuredDetectionMode =\n AssertionEngine.Configuration.Formatting.ValueFormatterDetectionMode;\n\n if (detectionMode != configuredDetectionMode)\n {\n detectionMode = configuredDetectionMode;\n formatters = null;\n }\n }\n\n private static Dictionary FindCustomFormatters()\n {\n var query =\n from type in TypeReflector.GetAllTypesFromAppDomain(Applicable)\n where type is not null\n from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public)\n where method.IsStatic\n where method.ReturnType == typeof(void)\n where method.IsDecoratedWithOrInherit()\n let methodParameters = method.GetParameters()\n where methodParameters.Length == 2\n select new { Type = methodParameters[0].ParameterType, Method = method }\n into formatter\n group formatter by formatter.Type\n into formatterGroup\n select formatterGroup.First();\n\n return query.ToDictionary(f => f.Type, f => f.Method);\n }\n\n private static bool Applicable(Assembly assembly)\n {\n GlobalFormattingOptions options = AssertionEngine.Configuration.Formatting;\n ValueFormatterDetectionMode mode = options.ValueFormatterDetectionMode;\n\n return mode == ValueFormatterDetectionMode.Scan || (\n mode == ValueFormatterDetectionMode.Specific &&\n assembly.FullName.Split(',')[0].Equals(options.ValueFormatterAssembly, StringComparison.OrdinalIgnoreCase));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XDocumentAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Xml;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Xml.Equivalency;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XDocumentAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public XDocumentAssertions(XDocument document, AssertionChain assertionChain)\n : base(document, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current equals the document,\n /// using its implementation.\n /// \n /// The expected document\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(XDocument expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Equals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:subject} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not equal the document,\n /// using its implementation.\n /// \n /// The unexpected document\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(XDocument unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Equals(Subject, unexpected))\n .FailWith(\"Did not expect {context:subject} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is equivalent to the document,\n /// using its implementation.\n /// \n /// The expected document\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(XDocument expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (XmlReader subjectReader = Subject?.CreateReader())\n using (XmlReader otherReader = expected?.CreateReader())\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, otherReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: true);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not equivalent to the document,\n /// using its implementation.\n /// \n /// The unexpected document\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(XDocument unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (XmlReader subjectReader = Subject?.CreateReader())\n using (XmlReader otherReader = unexpected?.CreateReader())\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, otherReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: false);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a root element with the specified\n /// name.\n /// \n /// The name of the expected root element of the current document.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveRoot(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has a root element if the expected name is .\");\n\n return HaveRoot(XNamespace.None + expected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has a root element with the specified\n /// name.\n /// \n /// The full name of the expected root element of the current document.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveRoot(XName expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (Subject is null)\n {\n throw new InvalidOperationException(\n \"Cannot assert the document has a root element if the document itself is .\");\n }\n\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has a root element if the expected name is .\");\n\n XElement root = Subject.Root;\n\n assertionChain\n .ForCondition(root is not null && root.Name == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have root element {0}{reason}, but found {1}.\",\n expected.ToString(), Subject);\n\n return new AndWhichConstraint(this, root, assertionChain, $\"/{expected}\");\n }\n\n /// \n /// Asserts that the element of the current has a direct\n /// child element with the specified name.\n /// \n /// \n /// The name of the expected child element of the current document's element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveElement(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has an element if the expected name is .\");\n\n return HaveElement(XNamespace.None + expected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the element of the current has the specified occurrence of\n /// child elements with the specified name.\n /// \n /// \n /// The name of the expected child element of the current document's element.\n /// \n /// \n /// A constraint specifying the number of times the specified elements should appear.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint> HaveElement(string expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has an element if the expected name is .\");\n\n return HaveElement(XNamespace.None + expected, occurrenceConstraint, because, becauseArgs);\n }\n\n /// \n /// Asserts that the element of the current has a direct\n /// child element with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current document's element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveElement(XName expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (Subject is null)\n {\n throw new InvalidOperationException(\"Cannot assert the document has an element if the document itself is .\");\n }\n\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has an element if the expected name is .\");\n\n assertionChain\n .ForCondition(Subject.Root is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have root element with child {0}{reason}, but it has no root element.\",\n expected.ToString());\n\n XElement xElement = null;\n\n if (assertionChain.Succeeded)\n {\n xElement = Subject.Root!.Element(expected);\n\n assertionChain\n .ForCondition(xElement is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have root element with child {0}{reason}, but no such child element was found.\",\n expected.ToString());\n }\n\n return new AndWhichConstraint(this, xElement, assertionChain, \"/\" + expected);\n }\n\n /// \n /// Asserts that the element of the current has the specified occurrence of\n /// child elements with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current document's element.\n /// \n /// \n /// A constraint specifying the number of times the specified elements should appear.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint> HaveElement(XName expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the document has an element count if the element name is .\");\n\n IEnumerable xElements = [];\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Cannot assert the count if the document itself is .\")\n .Then\n .WithExpectation(\"Expected {context:subject} to have a root element containing a child {0}\",\n expected.ToString(), chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject.Root)\n .ForCondition(root => root is not null)\n .FailWith(\"{reason}, but it has no root element.\", expected.ToString())\n .Then\n .Given(root =>\n {\n xElements = root.Elements(expected);\n return xElements.Count();\n })\n .ForConstraint(occurrenceConstraint, actual => actual)\n .FailWith(actual => $\"{{expectedOccurrence}}{{reason}}, but found it {actual.Times()}.\"));\n\n return new AndWhichConstraint>(this, xElements, assertionChain,\n \"/\" + expected);\n }\n\n /// \n /// Asserts that the of the current doesn't have the specified child element.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElement(string unexpectedElement,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n\n return NotHaveElement(XNamespace.None + unexpectedElement, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current doesn't have the specified child element.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElement(XName unexpectedElement,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:subject} to have an element {0}{reason}, \", unexpectedElement, chain =>\n chain\n .ForCondition(Subject is not null)\n .FailWith(\"but the element itself is .\")\n .Then\n .ForCondition(!Subject!.Root!.Elements(unexpectedElement).Any())\n .FailWith(\" but the element {0} was found.\", unexpectedElement));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the of the current has the specified child element\n /// with the specified name.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// The expected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithValue(string expectedElement,\n string expectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedElement, nameof(expectedElement));\n Guard.ThrowIfArgumentIsNull(expectedValue, nameof(expectedValue));\n\n return HaveElementWithValue(XNamespace.None + expectedElement, expectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current has the specified child element\n /// with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// The expected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithValue(XName expectedElement,\n string expectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedElement, nameof(expectedElement));\n Guard.ThrowIfArgumentIsNull(expectedValue, nameof(expectedValue));\n\n IEnumerable xElements = [];\n\n assertionChain\n .WithExpectation(\"Expected {context:subject} to have an element {0} with value {1}{reason}, \",\n expectedElement.ToString(), expectedValue, chain => chain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"but the element itself is .\",\n expectedElement.ToString(), expectedValue)\n .Then\n .Given(() =>\n {\n xElements = Subject!.Root!.Elements(expectedElement).ToList();\n\n return xElements;\n })\n .ForCondition(collection => collection.Any())\n .FailWith(\"but the element {0} isn't found.\", expectedElement)\n .Then\n .ForCondition(collection => collection.Any(e => e.Value == expectedValue))\n .FailWith(\"but the element {0} does not have such a value.\", expectedElement));\n\n return new AndWhichConstraint(this, xElements.FirstOrDefault());\n }\n\n /// \n /// Asserts that the of the current either doesn't have the\n /// specified child element or doesn't have the specified .\n /// \n /// \n /// The name of the unexpected child element of the current element's .\n /// \n /// \n /// The unexpected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElementWithValue(string unexpectedElement,\n string unexpectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n return NotHaveElementWithValue(XNamespace.None + unexpectedElement, unexpectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current either doesn't have the\n /// specified child element or doesn't have the specified .\n /// \n /// \n /// he full name of the unexpected child element of the current element's .\n /// \n /// \n /// The unexpected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElementWithValue(XName unexpectedElement,\n string unexpectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:subject} to have an element {0} with value {1}{reason}, \",\n unexpectedElement, unexpectedValue, chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but the element itself is .\")\n .Then\n .ForCondition(!Subject!.Root!.Elements(unexpectedElement)\n .Any(e => e.Value == unexpectedValue))\n .FailWith(\"but the element {0} does have this value.\", unexpectedElement));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"XML document\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XElementAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Xml;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Xml.Equivalency;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XElementAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public XElementAssertions(XElement xElement, AssertionChain assertionChain)\n : base(xElement, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current equals the\n /// element, by using\n /// \n /// \n /// The expected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(XElement expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(XNode.DeepEquals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:subject} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not equal the\n /// element, using\n /// .\n /// \n /// The unexpected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(XElement unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition((Subject is null && unexpected is not null) || !XNode.DeepEquals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:subject} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is equivalent to the\n /// element, using a semantic equivalency\n /// comparison.\n /// \n /// The expected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEquivalentTo(XElement expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (XmlReader subjectReader = Subject?.CreateReader())\n using (XmlReader expectedReader = expected?.CreateReader())\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, expectedReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: true);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not equivalent to\n /// the element, using a semantic\n /// equivalency comparison.\n /// \n /// The unexpected element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEquivalentTo(XElement unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n using (XmlReader subjectReader = Subject?.CreateReader())\n using (XmlReader otherReader = unexpected?.CreateReader())\n {\n var xmlReaderValidator = new XmlReaderValidator(assertionChain, subjectReader, otherReader, because, becauseArgs);\n xmlReaderValidator.Validate(shouldBeEquivalent: false);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the element to have value {0}{reason}, but {context:member} is .\", expected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(Subject!.Value == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} '{0}' to have value {1}{reason}, but found {2}.\",\n Subject.Name, expected, Subject.Value);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an attribute with the specified .\n /// \n /// The name of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint HaveAttribute(string expectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(expectedName);\n\n return HaveAttribute(XNamespace.None + expectedName, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an attribute with the specified .\n /// \n /// The name of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint HaveAttribute(XName expectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedName);\n\n string expectedText = expectedName.ToString();\n\n assertionChain\n .WithExpectation(\"Expected attribute {0} in element to exist {reason}, \", expectedText,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n \"but {context:member} is .\"))\n .Then\n .WithExpectation(\"Expected {context:subject} to have attribute {0}{reason}, \", expectedText,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attribute(expectedName))\n .ForCondition(attribute => attribute is not null)\n .FailWith(\"but found no such attribute in {0}.\", Subject));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current doesn't have an attribute with the specified .\n /// \n /// The name of the unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotHaveAttribute(string unexpectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(unexpectedName);\n\n return NotHaveAttribute(XNamespace.None + unexpectedName, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current doesn't have an attribute with the specified .\n /// \n /// The name of the unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotHaveAttribute(XName unexpectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedName);\n\n string unexpectedText = unexpectedName.ToString();\n\n assertionChain\n .WithExpectation(\"Did not expect attribute {0} in element to exist{reason}, \", unexpectedText,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n \"but {context:member} is .\",\n unexpectedText))\n .Then\n .WithExpectation(\"Did not expect {context:subject} to have attribute {0}{reason}, \", unexpectedText,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attribute(unexpectedName))\n .ForCondition(attribute => attribute is null)\n .FailWith(\"but found such attribute in {0}.\", Subject));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an attribute with the specified \n /// and .\n /// \n /// The name of the expected attribute\n /// The value of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint HaveAttributeWithValue(string expectedName, string expectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(expectedName);\n\n return HaveAttributeWithValue(XNamespace.None + expectedName, expectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an attribute with the specified \n /// and .\n /// \n /// The name of the expected attribute\n /// The value of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint HaveAttributeWithValue(XName expectedName, string expectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedName);\n\n string expectedText = expectedName.ToString();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected attribute {0} in element to have value {1}{reason}, \",\n expectedText, expectedValue,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but {context:member} is .\"))\n .Then\n .WithExpectation(\"Expected {context:subject} to have attribute {0} with value {1}{reason}, \",\n expectedText, expectedValue,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attribute(expectedName))\n .ForCondition(attr => attr is not null)\n .FailWith(\"but found no such attribute in {0}\", Subject))\n .Then\n .WithExpectation(\"Expected attribute {0} in {context:subject} to have value {1}{reason}, \",\n expectedText, expectedValue,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attribute(expectedName))\n .ForCondition(attr => attr!.Value == expectedValue)\n .FailWith(\"but found {0}.\", attr => attr.Value));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current doesn't have an attribute with the specified \n /// and/or .\n /// \n /// The name of the unexpected attribute\n /// The value of the unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotHaveAttributeWithValue(string unexpectedName, string unexpectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(unexpectedName, nameof(unexpectedName));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n return NotHaveAttributeWithValue(XNamespace.None + unexpectedName, unexpectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current doesn't have an attribute with the specified \n /// and/or .\n /// \n /// The name of the unexpected attribute\n /// The value of the unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotHaveAttributeWithValue(XName unexpectedName, string unexpectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedName, nameof(unexpectedName));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n string unexpectedText = unexpectedName.ToString();\n\n assertionChain\n .WithExpectation(\"Did not expect attribute {0} in element to have value {1}{reason}, \",\n unexpectedText, unexpectedValue,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"but {context:member} is .\"))\n .Then\n .WithExpectation(\"Did not expect {context:subject} to have attribute {0} with value {1}{reason}, \",\n unexpectedText, unexpectedValue,\n chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() => Subject!.Attributes()\n .FirstOrDefault(a => a.Name == unexpectedName && a.Value == unexpectedValue))\n .ForCondition(attribute => attribute is null)\n .FailWith(\"but found such attribute in {0}.\", Subject));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a direct child element with the specified\n /// name.\n /// \n /// The name of the expected child element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint HaveElement(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(expected);\n\n return HaveElement(XNamespace.None + expected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has a direct child element with the specified\n /// name.\n /// \n /// The name of the expected child element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveElement(XName expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n \"Expected the element to have child element {0}{reason}, but {context:member} is .\",\n expected.ToString().EscapePlaceholders());\n\n XElement xElement = null;\n\n if (assertionChain.Succeeded)\n {\n xElement = Subject!.Element(expected);\n\n assertionChain\n .ForCondition(xElement is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have child element {0}{reason}, but no such child element was found.\",\n expected.ToString().EscapePlaceholders());\n }\n\n return new AndWhichConstraint(this, xElement, assertionChain, \"/\" + expected);\n }\n\n /// \n /// Asserts that the of the current has the specified occurrence of\n /// child elements with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// A constraint specifying the number of times the specified elements should appear.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint> HaveElement(XName expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the element has an element count if the element name is .\");\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have an element with count of {0}{reason}, but the element itself is .\",\n expected.ToString());\n\n IEnumerable xElements = [];\n\n if (assertionChain.Succeeded)\n {\n xElements = Subject!.Elements(expected);\n int actual = xElements.Count();\n\n assertionChain\n .ForConstraint(occurrenceConstraint, actual)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have an element {0} {expectedOccurrence}\" +\n $\"{{reason}}, but found it {actual.Times()}.\",\n expected.ToString());\n }\n\n return new AndWhichConstraint>(this, xElements, assertionChain, \"/\" + expected);\n }\n\n /// \n /// Asserts that the of the current has the specified occurrence of\n /// child elements with the specified name.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// A constraint specifying the number of times the specified elements should appear.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint> HaveElement(string expected,\n OccurrenceConstraint occurrenceConstraint,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expected, nameof(expected),\n \"Cannot assert the element has an element if the expected name is .\");\n\n return HaveElement(XNamespace.None + expected, occurrenceConstraint, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current doesn't have the specified child element.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElement(string unexpectedElement,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n\n return NotHaveElement(XNamespace.None + unexpectedElement, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current doesn't have the specified child element.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElement(XName unexpectedElement,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:subject} to have an element {0}{reason}, but the element itself is .\",\n unexpectedElement.ToString());\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.Elements(unexpectedElement).Any())\n .FailWith(\"Did not expect {context:subject} to have an element {0}{reason}, \" +\n \"but the element {0} was found.\", unexpectedElement);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the of the current has the specified child element\n /// with the specified name.\n /// \n /// \n /// The name of the expected child element of the current element's .\n /// \n /// \n /// The expected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithValue(string expectedElement,\n string expectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedElement, nameof(expectedElement));\n Guard.ThrowIfArgumentIsNull(expectedValue, nameof(expectedValue));\n\n return HaveElementWithValue(XNamespace.None + expectedElement, expectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current has the specified child element\n /// with the specified name.\n /// \n /// \n /// The full name of the expected child element of the current element's .\n /// \n /// \n /// The expected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithValue(XName expectedElement,\n string expectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedElement, nameof(expectedElement));\n Guard.ThrowIfArgumentIsNull(expectedValue, nameof(expectedValue));\n\n IEnumerable xElements = [];\n\n assertionChain\n .WithExpectation(\"Expected {context:subject} to have an element {0} with value {1}{reason}, \",\n expectedElement.ToString(), expectedValue,\n chain => chain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"but the element itself is .\"))\n .Then\n .WithExpectation(\"Expected {context:subject} to have an element {0} with value {1}{reason}, \",\n expectedElement, expectedValue, chain => chain\n .BecauseOf(because, becauseArgs)\n .Given(() =>\n {\n xElements = Subject!.Elements(expectedElement);\n\n return xElements;\n })\n .ForCondition(elements => elements.Any())\n .FailWith(\"but the element {0} isn't found.\", expectedElement)\n .Then\n .ForCondition(elements => elements.Any(e => e.Value == expectedValue))\n .FailWith(\"but the element {0} does not have such a value.\", expectedElement));\n\n return new AndWhichConstraint(this, xElements.FirstOrDefault());\n }\n\n /// \n /// Asserts that the of the current either doesn't have the\n /// specified child element or doesn't have the specified .\n /// \n /// \n /// The name of the unexpected child element of the current element's .\n /// \n /// \n /// The unexpected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElementWithValue(string unexpectedElement,\n string unexpectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n return NotHaveElementWithValue(XNamespace.None + unexpectedElement, unexpectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the of the current either doesn't have the\n /// specified child element or doesn't have the specified .\n /// \n /// \n /// he full name of the unexpected child element of the current element's .\n /// \n /// \n /// The unexpected value of this particular element.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveElementWithValue(XName unexpectedElement,\n string unexpectedValue, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedElement, nameof(unexpectedElement));\n Guard.ThrowIfArgumentIsNull(unexpectedValue, nameof(unexpectedValue));\n\n assertionChain\n .WithExpectation(\"Did not expect {context:subject} to have an element {0} with value {1}{reason}, \",\n unexpectedElement.ToString(), unexpectedValue,\n chain => chain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"but the element itself is .\")\n .Then\n .ForCondition(!Subject!.Elements(unexpectedElement)\n .Any(e => e.Value == unexpectedValue))\n .FailWith(\"but the element {0} does have this value.\", unexpectedElement));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"XML element\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IOrderingRule.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Defines a rule that is used to determine whether the order of items in collections is relevant or not.\n/// \npublic interface IOrderingRule\n{\n /// \n /// Determines if ordering of the member referred to by the current is relevant.\n /// \n OrderStrictness Evaluate(IObjectInfo objectInfo);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/OrderStrictness.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic enum OrderStrictness\n{\n Strict,\n NotStrict,\n Irrelevant\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/MemberLessObjectsSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class MemberLessObjectsSpecs\n{\n [Fact]\n public void When_asserting_instances_of_an_anonymous_type_having_no_members_are_equivalent_it_should_fail()\n {\n // Arrange / Act\n Action act = () => new { }.Should().BeEquivalentTo(new { });\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_instances_of_a_class_having_no_members_are_equivalent_it_should_fail()\n {\n // Arrange / Act\n Action act = () => new ClassWithNoMembers().Should().BeEquivalentTo(new ClassWithNoMembers());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_instances_of_Object_are_equivalent_it_should_fail()\n {\n // Arrange / Act\n Action act = () => new object().Should().BeEquivalentTo(new object());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_instance_of_object_is_equivalent_to_null_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n object actual = new();\n object expected = null;\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Expected*to be *we want to test the failure message*, but found System.Object*\");\n }\n\n [Fact]\n public void When_asserting_null_is_equivalent_to_instance_of_object_it_should_fail()\n {\n // Arrange\n object actual = null;\n object expected = new();\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Expected*to be System.Object*but found *\");\n }\n\n [Fact]\n public void When_an_type_only_exposes_fields_but_fields_are_ignored_in_the_equivalence_comparision_it_should_fail()\n {\n // Arrange\n var object1 = new ClassWithOnlyAField { Value = 1 };\n var object2 = new ClassWithOnlyAField { Value = 101 };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2, opts => opts.IncludingAllDeclaredProperties());\n\n // Assert\n act.Should().Throw(\"the objects have no members to compare.\");\n }\n\n [Fact]\n public void\n When_an_type_only_exposes_properties_but_properties_are_ignored_in_the_equivalence_comparision_it_should_fail()\n {\n // Arrange\n var object1 = new ClassWithOnlyAProperty { Value = 1 };\n var object2 = new ClassWithOnlyAProperty { Value = 101 };\n\n // Act\n Action act = () => object1.Should().BeEquivalentTo(object2, opts => opts.ExcludingProperties());\n\n // Assert\n act.Should().Throw(\"the objects have no members to compare.\");\n }\n\n [Fact]\n public void When_asserting_instances_of_arrays_of_types_in_System_are_equivalent_it_should_respect_the_runtime_type()\n {\n // Arrange\n object actual = new int[0];\n object expectation = new int[0];\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_throwing_on_missing_members_and_there_are_no_missing_members_should_not_throw()\n {\n // Arrange\n var subject = new { Version = 2, Age = 36, };\n\n var expectation = new { Version = 2, Age = 36 };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n options => options.ThrowingOnMissingMembers());\n }\n\n [Fact]\n public void When_throwing_on_missing_members_and_there_is_a_missing_member_should_throw()\n {\n // Arrange\n var subject = new { Version = 2 };\n\n var expectation = new { Version = 2, Age = 36 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.ThrowingOnMissingMembers());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectation has property Age that the other object does not have*\");\n }\n\n [Fact]\n public void When_throwing_on_missing_members_and_there_is_an_additional_property_on_subject_should_not_throw()\n {\n // Arrange\n var subject = new { Version = 2, Age = 36, Additional = 13 };\n\n var expectation = new { Version = 2, Age = 36 };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n options => options.ThrowingOnMissingMembers());\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Common/TypeExtensionsSpecs.cs", "using System;\nusing System.Collections.Immutable;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing JetBrains.Annotations;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Common;\n\npublic class TypeExtensionsSpecs\n{\n [Fact]\n public void When_comparing_types_and_types_are_same_it_should_return_true()\n {\n // Arrange\n var type1 = typeof(InheritedType);\n var type2 = typeof(InheritedType);\n\n // Act\n bool result = type1.IsSameOrInherits(type2);\n\n // Assert\n result.Should().BeTrue();\n }\n\n [Fact]\n public void When_comparing_types_and_first_type_inherits_second_it_should_return_true()\n {\n // Arrange\n var type1 = typeof(InheritingType);\n var type2 = typeof(InheritedType);\n\n // Act\n bool result = type1.IsSameOrInherits(type2);\n\n // Assert\n result.Should().BeTrue();\n }\n\n [Fact]\n public void When_comparing_types_and_second_type_inherits_first_it_should_return_false()\n {\n // Arrange\n var type1 = typeof(InheritedType);\n var type2 = typeof(InheritingType);\n\n // Act\n bool result = type1.IsSameOrInherits(type2);\n\n // Assert\n result.Should().BeFalse();\n }\n\n [Fact]\n public void When_comparing_types_and_types_are_different_it_should_return_false()\n {\n // Arrange\n var type1 = typeof(string);\n var type2 = typeof(InheritedType);\n\n // Act\n bool result = type1.IsSameOrInherits(type2);\n\n // Assert\n result.Should().BeFalse();\n }\n\n [Fact]\n public void When_getting_explicit_conversion_operator_from_a_type_with_fake_conversion_operators_it_should_not_return_any()\n {\n // Arrange\n var type1 = typeof(TypeWithFakeConversionOperators);\n var type2 = typeof(byte);\n\n // Act\n MethodInfo result = type1.GetExplicitConversionOperator(type1, type2);\n\n // Assert\n result.Should().BeNull();\n }\n\n [Fact]\n public void When_getting_implicit_conversion_operator_from_a_type_with_fake_conversion_operators_it_should_not_return_any()\n {\n // Arrange\n var type1 = typeof(TypeWithFakeConversionOperators);\n var type2 = typeof(int);\n\n // Act\n MethodInfo result = type1.GetImplicitConversionOperator(type1, type2);\n\n // Assert\n result.Should().BeNull();\n }\n\n [Fact]\n public void When_getting_fake_explicit_conversion_operator_from_a_type_with_fake_conversion_operators_it_should_return_one()\n {\n // Arrange\n var type = typeof(TypeWithFakeConversionOperators);\n string name = \"op_Explicit\";\n var bindingAttr = BindingFlags.Public | BindingFlags.Static;\n var returnType = typeof(byte);\n\n // Act\n MethodInfo result = GetFakeConversionOperator(type, name, bindingAttr, returnType);\n\n // Assert\n result.Should().NotBeNull();\n }\n\n [Fact]\n public void When_getting_fake_implicit_conversion_operator_from_a_type_with_fake_conversion_operators_it_should_return_one()\n {\n // Arrange\n var type = typeof(TypeWithFakeConversionOperators);\n string name = \"op_Implicit\";\n var bindingAttr = BindingFlags.Public | BindingFlags.Static;\n var returnType = typeof(int);\n\n // Act\n MethodInfo result = GetFakeConversionOperator(type, name, bindingAttr, returnType);\n\n // Assert\n result.Should().NotBeNull();\n }\n\n [Theory]\n [InlineData(typeof(MyRecord), true)]\n [InlineData(typeof(MyRecordStruct), true)]\n [InlineData(typeof(MyRecordStructWithCustomPrintMembers), true)]\n [InlineData(typeof(MyRecordStructWithOverriddenEquality), true)]\n [InlineData(typeof(MyReadonlyRecordStruct), true)]\n [InlineData(typeof(MyStruct), false)]\n [InlineData(typeof(MyStructWithFakeCompilerGeneratedEquality), false)]\n [InlineData(typeof(MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers), true)] // false positive!\n [InlineData(typeof(MyStructWithOverriddenEquality), false)]\n [InlineData(typeof(MyClass), false)]\n [InlineData(typeof(int), false)]\n [InlineData(typeof(string), false)]\n public void IsRecord_should_detect_records_correctly(Type type, bool expected)\n {\n type.IsRecord().Should().Be(expected);\n }\n\n [Fact]\n public void When_checking_if_anonymous_type_is_record_it_should_return_false()\n {\n new { Value = 42 }.GetType().IsRecord().Should().BeFalse();\n }\n\n [Fact]\n public void When_checking_if_value_tuple_is_record_it_should_return_false()\n {\n (42, \"the answer\").GetType().IsRecord().Should().BeFalse();\n }\n\n [Fact]\n public void When_checking_if_class_with_multiple_equality_methods_is_record_it_should_return_false()\n {\n typeof(ImmutableArray).IsRecord().Should().BeFalse();\n }\n\n private static MethodInfo GetFakeConversionOperator(Type type, string name, BindingFlags bindingAttr, Type returnType)\n {\n MethodInfo[] methods = type.GetMethods(bindingAttr);\n\n return methods.SingleOrDefault(m =>\n m.Name == name\n && m.ReturnType == returnType\n && m.GetParameters().Select(p => p.ParameterType).SequenceEqual([type])\n );\n }\n\n private class InheritedType;\n\n private class InheritingType : InheritedType;\n\n private readonly struct TypeWithFakeConversionOperators\n {\n private readonly int value;\n\n [UsedImplicitly]\n private TypeWithFakeConversionOperators(int value)\n {\n this.value = value;\n }\n\n#pragma warning disable IDE1006, SA1300 // These two functions mimic the compiler generated conversion operators\n [UsedImplicitly]\n public static int op_Implicit(TypeWithFakeConversionOperators typeWithFakeConversionOperators) =>\n typeWithFakeConversionOperators.value;\n\n [UsedImplicitly]\n public static byte op_Explicit(TypeWithFakeConversionOperators typeWithFakeConversionOperators) =>\n (byte)typeWithFakeConversionOperators.value;\n#pragma warning restore SA1300, IDE1006\n }\n\n [UsedImplicitly]\n private record MyRecord(int Value);\n\n [UsedImplicitly]\n private record struct MyRecordStruct(int Value);\n\n [UsedImplicitly]\n private record struct MyRecordStructWithCustomPrintMembers(int Value)\n {\n // ReSharper disable once RedundantNameQualifier\n private bool PrintMembers(System.Text.StringBuilder builder)\n {\n builder.Append(Value);\n return true;\n }\n }\n\n private record struct MyRecordStructWithOverriddenEquality(int Value)\n {\n public bool Equals(MyRecordStructWithOverriddenEquality other) => Value == other.Value;\n\n public override int GetHashCode() => Value;\n }\n\n [UsedImplicitly]\n private readonly record struct MyReadonlyRecordStruct(int Value);\n\n private struct MyStruct\n {\n [UsedImplicitly]\n public int Value { get; set; }\n }\n\n private struct MyStructWithFakeCompilerGeneratedEquality : IEquatable\n {\n [UsedImplicitly]\n public int Value { get; set; }\n\n public bool Equals(MyStructWithFakeCompilerGeneratedEquality other) => Value == other.Value;\n\n public override bool Equals(object obj) => obj is MyStructWithFakeCompilerGeneratedEquality other && Equals(other);\n\n public override int GetHashCode() => Value;\n\n [CompilerGenerated]\n public static bool operator ==(MyStructWithFakeCompilerGeneratedEquality left,\n MyStructWithFakeCompilerGeneratedEquality right) => left.Equals(right);\n\n public static bool operator !=(MyStructWithFakeCompilerGeneratedEquality left,\n MyStructWithFakeCompilerGeneratedEquality right) => !left.Equals(right);\n }\n\n // Note that this struct is mistakenly detected as a record struct by the current version of TypeExtensions.IsRecord.\n // This cannot be avoided at present, unless something is changed at language level,\n // or a smarter way to check for record structs is found.\n private struct MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers\n : IEquatable\n {\n [UsedImplicitly]\n public int Value { get; set; }\n\n public bool Equals(MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers other) => Value == other.Value;\n\n public override bool Equals(object obj) =>\n obj is MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers other && Equals(other);\n\n public override int GetHashCode() => Value;\n\n [CompilerGenerated]\n public static bool operator ==(MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers left,\n MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers right) => left.Equals(right);\n\n public static bool operator !=(MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers left,\n MyStructWithFakeCompilerGeneratedEqualityAndPrintMembers right) => !left.Equals(right);\n\n [UsedImplicitly]\n private bool PrintMembers(StringBuilder builder)\n {\n builder.Append(Value);\n return true;\n }\n }\n\n private struct MyStructWithOverriddenEquality : IEquatable\n {\n [UsedImplicitly]\n public int Value { get; set; }\n\n public bool Equals(MyStructWithOverriddenEquality other) => Value == other.Value;\n\n public override bool Equals(object obj) => obj is MyStructWithOverriddenEquality other && Equals(other);\n\n public override int GetHashCode() => Value;\n\n public static bool operator ==(MyStructWithOverriddenEquality left, MyStructWithOverriddenEquality right) =>\n left.Equals(right);\n\n public static bool operator !=(MyStructWithOverriddenEquality left, MyStructWithOverriddenEquality right) =>\n !left.Equals(right);\n }\n\n private class MyClass\n {\n [UsedImplicitly]\n public int Value { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/MemberConversionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class MemberConversionSpecs\n{\n [Fact]\n public void When_two_objects_have_the_same_properties_with_convertable_values_it_should_succeed()\n {\n // Arrange\n var subject = new { Age = \"37\", Birthdate = \"1973-09-20\" };\n\n var other = new { Age = 37, Birthdate = new DateTime(1973, 9, 20) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other, o => o.WithAutoConversion());\n }\n\n [Fact]\n public void When_a_string_is_declared_equivalent_to_an_int_representing_the_numerals_it_should_pass()\n {\n // Arrange\n var actual = new { Property = \"32\" };\n\n var expectation = new { Property = 32 };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation,\n options => options.WithAutoConversion());\n }\n\n [Fact]\n public void When_an_int_is_compared_equivalent_to_a_string_representing_the_number_it_should_pass()\n {\n // Arrange\n var subject = new { Property = 32 };\n var expectation = new { Property = \"32\" };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n }\n\n [Fact]\n public void Numbers_can_be_converted_to_enums()\n {\n // Arrange\n var expectation = new { Property = EnumFour.Three };\n var subject = new { Property = 3UL };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n }\n\n [Fact]\n public void Enums_are_not_converted_to_enums_of_different_type()\n {\n // Arrange\n var expectation = new { Property = EnumTwo.Two };\n var subject = new { Property = EnumThree.Two };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n }\n\n [Fact]\n public void Strings_are_not_converted_to_enums()\n {\n // Arrange\n var expectation = new { Property = EnumTwo.Two };\n var subject = new { Property = \"Two\" };\n\n // Act / Assert\n var act = () => subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n\n act.Should().Throw();\n }\n\n [Fact]\n public void Numbers_that_are_out_of_range_cannot_be_converted_to_enums()\n {\n // Arrange\n var expectation = new { Property = EnumFour.Three };\n var subject = new { Property = 4 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, options => options.WithAutoConversion());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*subject*Property*EnumFour*\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_WithAutoConversionFor_it_should_throw()\n {\n // Arrange\n var subject = new object();\n\n var expectation = new object();\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.WithAutoConversionFor(predicate: null));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_only_a_single_property_is_and_can_be_converted_but_the_other_one_doesnt_match_it_should_throw()\n {\n // Arrange\n var subject = new { Age = 32, Birthdate = \"1973-09-20\" };\n\n var expectation = new { Age = \"32\", Birthdate = new DateTime(1973, 9, 20) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.WithAutoConversionFor(x => x.Path.Contains(\"Birthdate\")));\n\n // Assert\n act.Should().Throw().WithMessage(\"*Age*String*int*\");\n }\n\n [Fact]\n public void When_only_a_single_property_is_converted_and_the_other_matches_it_should_succeed()\n {\n // Arrange\n var subject = new { Age = 32, Birthdate = \"1973-09-20\" };\n\n var expectation = new { Age = 32, Birthdate = new DateTime(1973, 9, 20) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .WithAutoConversionFor(x => x.Path.Contains(\"Birthdate\")));\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_WithoutAutoConversionFor_it_should_throw()\n {\n // Arrange\n var subject = new object();\n\n var expectation = new object();\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.WithoutAutoConversionFor(predicate: null));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_a_specific_mismatching_property_is_excluded_from_conversion_it_should_throw()\n {\n // Arrange\n var subject = new { Age = 32, Birthdate = \"1973-09-20\" };\n\n var expectation = new { Age = 32, Birthdate = new DateTime(1973, 9, 20) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, options => options\n .WithAutoConversion()\n .WithoutAutoConversionFor(x => x.Path.Contains(\"Birthdate\")));\n\n // Assert\n act.Should().Throw().Which.Message\n .Should().Match(\"Expected*<1973-09-20>*\\\"1973-09-20\\\"*\", \"{0} field is of mismatched type\",\n nameof(expectation.Birthdate))\n .And.Subject.Should().Match(\"*Try conversion of all members*\", \"conversion description should be present\")\n .And.Subject.Should().NotMatch(\"*Try conversion of all members*Try conversion of all members*\",\n \"conversion description should not be duplicated\");\n }\n\n [Fact]\n public void When_declaring_equivalent_a_convertable_object_that_is_equivalent_once_converted_it_should_pass()\n {\n // Arrange\n string str = \"This is a test\";\n CustomConvertible obj = new(str);\n\n // Act / Assert\n obj.Should().BeEquivalentTo(str, options => options.WithAutoConversion());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/GetSubjectId.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Allows deferred fetching of the subject ID.\n/// \npublic delegate string GetSubjectId();\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/ComparableSpecs.cs", "using System;\nusing System.Globalization;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic class ComparableSpecs\n{\n public class Be\n {\n [Fact]\n public void When_two_instances_are_equal_it_should_succeed()\n {\n // Arrange\n var subject = new EquatableOfInt(1);\n var other = new EquatableOfInt(1);\n\n // Act / Assert\n subject.Should().Be(other);\n }\n\n [Fact]\n public void When_two_instances_are_the_same_reference_but_are_not_considered_equal_it_should_succeed()\n {\n // Arrange\n var subject = new SameInstanceIsNotEqualClass();\n var other = subject;\n\n // Act\n Action act = () => subject.Should().Be(other);\n\n // Assert\n act.Should().NotThrow(\n \"This is inconsistent with the behavior ObjectAssertions.Be but is how ComparableTypeAssertions.Be has always worked.\");\n }\n\n [Fact]\n public void When_two_instances_are_not_equal_it_should_throw()\n {\n // Arrange\n var subject = new EquatableOfInt(1);\n var other = new EquatableOfInt(2);\n\n // Act\n Action act = () => subject.Should().Be(other, \"they have the same property values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected*2*because they have the same property values, but found*1*.\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_two_references_to_the_same_instance_are_not_equal_it_should_throw()\n {\n // Arrange\n var subject = new SameInstanceIsNotEqualClass();\n var other = subject;\n\n // Act\n Action act = () => subject.Should().NotBe(other);\n\n // Assert\n act.Should().Throw(\n \"This is inconsistent with the behavior ObjectAssertions.Be but is how ComparableTypeAssertions.Be has always worked.\");\n }\n\n [Fact]\n public void When_two_equal_objects_should_not_be_equal_it_should_throw()\n {\n // Arrange\n var subject = new EquatableOfInt(1);\n var other = new EquatableOfInt(1);\n\n // Act\n Action act = () => subject.Should().NotBe(other, \"they represent different things\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*Did not expect subject to be equal to*1*because they represent different things.*\");\n }\n\n [Fact]\n public void When_two_unequal_objects_should_not_be_equal_it_should_not_throw()\n {\n // Arrange\n var subject = new EquatableOfInt(1);\n var other = new EquatableOfInt(2);\n\n // Act / Assert\n subject.Should().NotBe(other);\n }\n }\n\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_equal_to_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n var value = new EquatableOfInt(3);\n\n // Act\n Action act = () => value.Should().BeOneOf(new[] { new EquatableOfInt(4), new EquatableOfInt(5) },\n \"because those are the valid {0}\", \"values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be one of {4, 5} because those are the valid values, but found 3.\");\n }\n\n [Fact]\n public void When_two_instances_are_the_same_reference_but_are_not_considered_equal_it_should_succeed()\n {\n // Arrange\n var subject = new SameInstanceIsNotEqualClass();\n var other = subject;\n\n // Act\n Action act = () => subject.Should().BeOneOf(other);\n\n // Assert\n act.Should().NotThrow(\n \"This is inconsistent with the behavior ObjectAssertions.Be but is how ComparableTypeAssertions.Be has always worked.\");\n }\n\n [Fact]\n public void When_a_value_is_equal_to_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n var value = new EquatableOfInt(4);\n\n // Act / Assert\n value.Should().BeOneOf(new EquatableOfInt(4), new EquatableOfInt(5));\n }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void When_two_instances_are_equivalent_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n var expected = new CustomerDto(42);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_two_instances_are_compared_it_should_allow_chaining()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n var expected = new CustomerDto(42);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected)\n .And.NotBeNull();\n }\n\n [Fact]\n public void When_two_instances_are_compared_with_config_it_should_allow_chaining()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n var expected = new CustomerDto(42);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt)\n .And.NotBeNull();\n }\n\n [Fact]\n public void When_two_instances_are_equivalent_due_to_exclusion_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n\n var expected = new AnotherCustomerDto(42)\n {\n SomeOtherProperty = 1337\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.Excluding(x => x.SomeOtherProperty),\n \"they have the same property values\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_it_should_throw()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n var expected = new AnotherCustomerDto(42);\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_two_instances_are_not_equivalent_it_should_throw()\n {\n // Arrange\n var subject = new ComparableCustomer(42);\n\n var expected = new AnotherCustomerDto(42)\n {\n SomeOtherProperty = 1337\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected, \"they have the same property values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expectation has property SomeOtherProperty*that the other object does not have*\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_assertion_an_instance_to_be_null_and_it_is_null_it_should_succeed()\n {\n // Arrange\n ComparableOfString subject = null;\n\n // Act / Assert\n subject.Should().BeNull();\n }\n\n [Fact]\n public void When_assertion_an_instance_to_be_null_and_it_is_not_null_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"\");\n\n // Act\n Action action = () =>\n subject.Should().BeNull();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject to be , but found*\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_assertion_an_instance_not_to_be_null_and_it_is_not_null_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableOfString(\"\");\n\n // Act / Assert\n subject.Should().NotBeNull();\n }\n\n [Fact]\n public void When_assertion_an_instance_not_to_be_null_and_it_is_null_it_should_throw()\n {\n // Arrange\n ComparableOfString subject = null;\n\n // Act\n Action action = () =>\n subject.Should().NotBeNull();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject not to be .\");\n }\n }\n\n public class BeInRange\n {\n [Fact]\n public void When_assertion_an_instance_to_be_in_a_certain_range_and_it_is_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableOfInt(1);\n\n // Act / Assert\n subject.Should().BeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n }\n\n [Fact]\n public void When_asserting_an_instance_to_be_in_a_certain_range_and_it_is_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableOfInt(2);\n\n // Act / Assert\n subject.Should().BeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n }\n\n [Fact]\n public void When_assertion_an_instance_to_be_in_a_certain_range_but_it_is_not_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfInt(3);\n\n // Act\n Action action = () =>\n subject.Should().BeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject to be between*and*, but found *.\");\n }\n }\n\n public class NotBeInRange\n {\n [Fact]\n public void When_assertion_an_instance_to_not_be_in_a_certain_range_and_it_is_not_it_should_succeed()\n {\n // Arrange\n var subject = new ComparableOfInt(3);\n\n // Act / Assert\n subject.Should().NotBeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n }\n\n [Fact]\n public void When_assertion_an_instance_to_not_be_in_a_certain_range_but_it_is_not_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfInt(2);\n\n // Act\n Action action = () =>\n subject.Should().NotBeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject to not be between*and*, but found *.\");\n }\n\n [Fact]\n public void When_asserting_an_instance_to_not_be_in_a_certain_range_but_it_is_not_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfInt(1);\n\n // Act\n Action action = () =>\n subject.Should().NotBeInRange(new ComparableOfInt(1), new ComparableOfInt(2));\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class BeRankedEquallyTo\n {\n [Fact]\n public void When_subect_is_ranked_equal_to_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"Hello\");\n var other = new ComparableOfString(\"Hello\");\n\n // Act / Assert\n subject.Should().BeRankedEquallyTo(other);\n }\n\n [Fact]\n public void When_subject_is_not_ranked_equal_to_another_subject_but_that_is_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"42\");\n var other = new ComparableOfString(\"Forty two\");\n\n // Act\n Action act = () => subject.Should().BeRankedEquallyTo(other, \"they represent the same number\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected subject*42*to be ranked as equal to*Forty two*because they represent the same number.\");\n }\n }\n\n public class NotBeRankedEquallyTo\n {\n [Fact]\n public void When_subect_is_not_ranked_equal_to_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"Hello\");\n var other = new ComparableOfString(\"Hi\");\n\n // Act / Assert\n subject.Should().NotBeRankedEquallyTo(other);\n }\n\n [Fact]\n public void When_subject_is_ranked_equal_to_another_subject_but_that_is_not_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"Lead\");\n var other = new ComparableOfString(\"Lead\");\n\n // Act\n Action act = () => subject.Should().NotBeRankedEquallyTo(other, \"they represent different concepts\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected subject*Lead*not to be ranked as equal to*Lead*because they represent different concepts.\");\n }\n }\n\n public class BeLessThan\n {\n [Fact]\n public void When_subject_is_less_than_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"City\");\n var other = new ComparableOfString(\"World\");\n\n // Act / Assert\n subject.Should().BeLessThan(other);\n }\n\n [Fact]\n public void When_subject_is_not_less_than_another_subject_but_that_is_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"World\");\n var other = new ComparableOfString(\"City\");\n\n // Act\n Action act = () => subject.Should().BeLessThan(other, \"a city is smaller than the world\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected subject*World*to be less than*City*because a city is smaller than the world.\");\n }\n\n [Fact]\n public void When_subject_is_equal_to_another_subject_and_expected_to_be_less_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"City\");\n var other = new ComparableOfString(\"City\");\n\n // Act\n Action act = () => subject.Should().BeLessThan(other);\n\n // Assert\n act.Should().Throw();\n }\n }\n\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void When_subject_is_greater_than_another_subject_and_that_is_not_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"World\");\n var other = new ComparableOfString(\"City\");\n\n // Act\n Action act = () => subject.Should().BeLessThanOrEqualTo(other, \"we want to order them\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected subject*World*to be less than or equal to*City*because we want to order them.\");\n }\n\n [Fact]\n public void When_subject_is_equal_to_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"World\");\n var other = new ComparableOfString(\"World\");\n\n // Act / Assert\n subject.Should().BeLessThanOrEqualTo(other);\n }\n\n [Fact]\n public void When_subject_is_less_than_another_subject_and_less_than_or_equal_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"City\");\n var other = new ComparableOfString(\"World\");\n\n // Act / Assert\n subject.Should().BeLessThanOrEqualTo(other);\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var subject = new ComparableOfString(\"World\");\n var other = new ComparableOfString(\"World\");\n\n // Act / Assert\n subject.Should().BeLessThanOrEqualTo(other).And.NotBeNull();\n }\n }\n\n public class BeGreaterThan\n {\n [Fact]\n public void When_subject_is_greater_than_another_subject_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"efg\");\n var other = new ComparableOfString(\"abc\");\n\n // Act / Assert\n subject.Should().BeGreaterThan(other);\n }\n\n [Fact]\n public void When_subject_is_equal_to_another_subject_and_expected_to_be_greater_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"efg\");\n var other = new ComparableOfString(\"efg\");\n\n // Act\n Action act = () => subject.Should().BeGreaterThan(other);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_is_not_greater_than_another_subject_but_that_is_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"abc\");\n var other = new ComparableOfString(\"def\");\n\n // Act\n Action act = () => subject.Should().BeGreaterThan(other, \"'a' is smaller then 'e'\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected subject*abc*to be greater than*def*because 'a' is smaller then 'e'.\");\n }\n }\n\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void When_subject_is_less_than_another_subject_and_that_is_not_expected_it_should_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"abc\");\n var other = new ComparableOfString(\"def\");\n\n // Act\n Action act = () => subject.Should().BeGreaterThanOrEqualTo(other, \"'d' is bigger then 'a'\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected subject*abc*to be greater than or equal to*def*because 'd' is bigger then 'a'.\");\n }\n\n [Fact]\n public void When_subject_is_equal_to_another_subject_and_that_is_equal_or_greater_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"def\");\n var other = new ComparableOfString(\"def\");\n\n // Act / Assert\n subject.Should().BeGreaterThanOrEqualTo(other);\n }\n\n [Fact]\n public void When_subject_is_greater_than_another_subject_and_greater_than_or_equal_is_expected_it_should_not_throw()\n {\n // Arrange\n var subject = new ComparableOfString(\"xyz\");\n var other = new ComparableOfString(\"abc\");\n\n // Act / Assert\n subject.Should().BeGreaterThanOrEqualTo(other);\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var subject = new ComparableOfString(\"def\");\n var other = new ComparableOfString(\"def\");\n\n // Act / Assert\n subject.Should().BeGreaterThanOrEqualTo(other).And.NotBeNull();\n }\n }\n}\n\npublic class ComparableOfString : IComparable\n{\n public string Value { get; set; }\n\n public ComparableOfString(string value)\n {\n Value = value;\n }\n\n public int CompareTo(ComparableOfString other)\n {\n return string.CompareOrdinal(Value, other.Value);\n }\n\n public override string ToString()\n {\n return Value;\n }\n}\n\npublic class SameInstanceIsNotEqualClass : IComparable\n{\n public override bool Equals(object obj)\n {\n return false;\n }\n\n public override int GetHashCode()\n {\n return 1;\n }\n\n int IComparable.CompareTo(SameInstanceIsNotEqualClass other) =>\n throw new NotSupportedException(\"This type is meant for assertions using Equals()\");\n}\n\npublic class EquatableOfInt : IComparable\n{\n public int Value { get; set; }\n\n public EquatableOfInt(int value)\n {\n Value = value;\n }\n\n public override bool Equals(object obj)\n {\n return Value == ((EquatableOfInt)obj).Value;\n }\n\n public override int GetHashCode()\n {\n return Value.GetHashCode();\n }\n\n public override string ToString()\n {\n return Value.ToString(CultureInfo.InvariantCulture);\n }\n\n int IComparable.CompareTo(EquatableOfInt other) =>\n throw new NotSupportedException(\"This type is meant for assertions using Equals()\");\n}\n\npublic class ComparableOfInt : IComparable\n{\n public int Value { get; set; }\n\n public ComparableOfInt(int value)\n {\n Value = value;\n }\n\n public int CompareTo(ComparableOfInt other)\n {\n return Value.CompareTo(other.Value);\n }\n\n public override string ToString()\n {\n return Value.ToString(CultureInfo.InvariantCulture);\n }\n}\n\npublic class ComparableCustomer : IComparable\n{\n public ComparableCustomer(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n\n public int CompareTo(ComparableCustomer other)\n {\n return Id.CompareTo(other.Id);\n }\n}\n\npublic class CustomerDto\n{\n public CustomerDto(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n}\n\npublic class AnotherCustomerDto\n{\n public AnotherCustomerDto(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n\n public int SomeOtherProperty { get; set; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/GenericAsyncFunctionAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an asynchronous method yields the expected result.\n/// \n/// The type returned in the .\npublic class GenericAsyncFunctionAssertions\n : AsyncFunctionAssertions, GenericAsyncFunctionAssertions>\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public GenericAsyncFunctionAssertions(Func> subject, IExtractExceptions extractor, AssertionChain assertionChain)\n : this(subject, extractor, assertionChain, new Clock())\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Initializes a new instance of the class with custom .\n /// \n public GenericAsyncFunctionAssertions(Func> subject, IExtractExceptions extractor, AssertionChain assertionChain,\n IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current will complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task, TResult>> CompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n (Task task, TimeSpan remainingTime) = InvokeWithTimer(timeSpan);\n\n assertionChain\n .ForCondition(remainingTime >= TimeSpan.Zero)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(task, remainingTime, _ => Task.CompletedTask);\n\n assertionChain\n .ForCondition(completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n\n#pragma warning disable CA1849 // Call async methods when in an async method\n TResult result = assertionChain.Succeeded ? task.Result : default;\n#pragma warning restore CA1849 // Call async methods when in an async method\n return new AndWhichConstraint, TResult>(this, result, assertionChain, \".Result\");\n }\n\n return new AndWhichConstraint, TResult>(this, default(TResult));\n }\n\n /// \n /// Asserts that the current does not throw any exception.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task, TResult>> NotThrowAsync(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n try\n {\n TResult result = await Subject!.Invoke();\n return new AndWhichConstraint, TResult>(this, result, assertionChain, \".Result\");\n }\n catch (Exception exception)\n {\n _ = NotThrowInternal(exception, because, becauseArgs);\n }\n }\n\n return new AndWhichConstraint, TResult>(this, default(TResult));\n }\n\n /// \n /// Asserts that the current stops throwing any exception\n /// after a specified amount of time.\n /// \n /// \n /// The is invoked. If it raises an exception,\n /// the invocation is repeated until it either stops raising any exceptions\n /// or the specified wait time is exceeded.\n /// \n /// \n /// The time after which the should have stopped throwing any exception.\n /// \n /// \n /// The time between subsequent invocations of the .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// or are negative.\n public Task, TResult>> NotThrowAfterAsync(\n TimeSpan waitTime, TimeSpan pollInterval, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(waitTime);\n Guard.ThrowIfArgumentIsNegative(pollInterval);\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw any exceptions after {0}{reason}, but found .\", waitTime);\n\n if (assertionChain.Succeeded)\n {\n return AssertionTaskAsync();\n\n async Task, TResult>> AssertionTaskAsync()\n {\n TimeSpan? invocationEndTime = null;\n Exception exception = null;\n Common.ITimer timer = Clock.StartTimer();\n\n while (invocationEndTime is null || invocationEndTime < waitTime)\n {\n try\n {\n TResult result = await Subject.Invoke();\n return new AndWhichConstraint, TResult>(this, result, assertionChain, \".Result\");\n }\n catch (Exception ex)\n {\n exception = ex;\n await Clock.DelayAsync(pollInterval, CancellationToken.None);\n invocationEndTime = timer.Elapsed;\n }\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exceptions after {0}{reason}, but found {1}.\", waitTime, exception);\n\n return new AndWhichConstraint, TResult>(this, default(TResult));\n }\n }\n\n return Task.FromResult(new AndWhichConstraint, TResult>(this, default(TResult)));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DictionaryValueFormatter.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DictionaryValueFormatter : IValueFormatter\n{\n /// \n /// The number of items to include when formatting this object.\n /// \n /// The default value is 32.\n protected virtual int MaxItems => 32;\n\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public virtual bool CanHandle(object value)\n {\n return value is IDictionary;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n int startCount = formattedGraph.LineCount;\n IEnumerable> collection = AsEnumerable((IDictionary)value);\n\n using var iterator = new Iterator>(collection, MaxItems);\n\n while (iterator.MoveNext())\n {\n if (iterator.IsFirst)\n {\n formattedGraph.AddFragment(\"{\");\n }\n\n if (!iterator.HasReachedMaxItems)\n {\n var index = iterator.Index.ToString(CultureInfo.InvariantCulture);\n formattedGraph.AddFragment(\"[\");\n formatChild(index + \".Key\", iterator.Current.Key, formattedGraph);\n formattedGraph.AddFragment(\"] = \");\n formatChild(index + \".Value\", iterator.Current.Value, formattedGraph);\n }\n else\n {\n using IDisposable _ = formattedGraph.WithIndentation();\n string moreItemsMessage = $\"…{collection.Count() - MaxItems} more…\";\n AddLineOrFragment(formattedGraph, startCount, moreItemsMessage);\n }\n\n if (iterator.IsLast)\n {\n AddLineOrFragment(formattedGraph, startCount, \"}\");\n }\n else\n {\n formattedGraph.AddFragment(\", \");\n }\n }\n\n if (iterator.IsEmpty)\n {\n formattedGraph.AddFragment(\"{empty}\");\n }\n }\n\n private static void AddLineOrFragment(FormattedObjectGraph formattedGraph, int startCount, string fragment)\n {\n if (formattedGraph.LineCount > (startCount + 1))\n {\n formattedGraph.AddLine(fragment);\n }\n else\n {\n formattedGraph.AddFragment(fragment);\n }\n }\n\n private static IEnumerable> AsEnumerable(IDictionary dictionary)\n {\n IDictionaryEnumerator iterator = dictionary.GetEnumerator();\n\n using (iterator as IDisposable)\n {\n while (iterator.MoveNext())\n {\n yield return new KeyValuePair(iterator.Key, iterator.Value);\n }\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/Pathway.cs", "using AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents the path of a field or property in an object graph.\n/// \npublic record Pathway\n{\n public delegate string GetDescription(string pathAndName);\n\n private readonly string path = string.Empty;\n private string name = string.Empty;\n private string pathAndName;\n\n private readonly GetDescription getDescription;\n\n public Pathway(string path, string name, GetDescription getDescription)\n {\n Path = path;\n Name = name;\n this.getDescription = getDescription;\n }\n\n /// \n /// Creates an instance of with the specified parent and name and a factory\n /// to provide a description for the path and name.\n /// \n public Pathway(Pathway parent, string name, GetDescription getDescription)\n {\n Path = parent.PathAndName;\n Name = name;\n this.getDescription = getDescription;\n }\n\n /// \n /// Gets the path of the field or property without the name.\n /// \n public string Path\n {\n get => path;\n private init\n {\n path = value;\n pathAndName = null;\n }\n }\n\n /// \n /// Gets the name of the field or property without the path.\n /// \n public string Name\n {\n get => name;\n internal set\n {\n name = value;\n pathAndName = null;\n }\n }\n\n /// \n /// Gets the path and name of the field or property separated by dots.\n /// \n public string PathAndName => pathAndName ??= path.Combine(name);\n\n /// \n /// Gets the display representation of this path.\n /// \n public string Description => getDescription(PathAndName);\n\n public override string ToString() => Description;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/EqualityStrategy.cs", "namespace AwesomeAssertions.Equivalency;\n\npublic enum EqualityStrategy\n{\n /// \n /// The object overrides , so use that.\n /// \n Equals,\n\n /// \n /// The object does not seem to override , so compare by members\n /// \n Members,\n\n /// \n /// Compare using , whether or not the object overrides it.\n /// \n ForceEquals,\n\n /// \n /// Compare the members, regardless of an override exists or not.\n /// \n ForceMembers,\n}\n"], ["/AwesomeAssertions/Build/Build.cs", "using System;\nusing System.Linq;\nusing LibGit2Sharp;\nusing Nuke.Common;\nusing Nuke.Common.CI.GitHubActions;\nusing Nuke.Common.Execution;\nusing Nuke.Common.Git;\nusing Nuke.Common.IO;\nusing Nuke.Common.ProjectModel;\nusing Nuke.Common.Tooling;\nusing Nuke.Common.Tools.DotNet;\nusing Nuke.Common.Tools.GitVersion;\nusing Nuke.Common.Tools.ReportGenerator;\nusing Nuke.Common.Tools.Xunit;\nusing Nuke.Common.Utilities;\nusing Nuke.Common.Utilities.Collections;\nusing static Nuke.Common.Tools.DotNet.DotNetTasks;\nusing static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;\nusing static Nuke.Common.Tools.Xunit.XunitTasks;\nusing static Serilog.Log;\nusing static CustomNpmTasks;\n\n[UnsetVisualStudioEnvironmentVariables]\n[DotNetVerbosityMapping]\nclass Build : NukeBuild\n{\n /* Support plugins are available for:\n - JetBrains ReSharper https://nuke.build/resharper\n - JetBrains Rider https://nuke.build/rider\n - Microsoft VisualStudio https://nuke.build/visualstudio\n - Microsoft VSCode https://nuke.build/vscode\n */\n\n public static int Main() => Execute(x => x.SpellCheck, x => x.Push);\n\n GitHubActions GitHubActions => GitHubActions.Instance;\n\n string BranchSpec => GitHubActions?.Ref;\n\n string BuildNumber => GitHubActions?.RunNumber.ToString();\n\n string PullRequestBase => GitHubActions?.BaseRef;\n\n [Parameter(\"The solution configuration to build. Default is 'Debug' (local) or 'CI' (server).\")]\n readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.CI;\n\n [Parameter(\"Use this parameter if you encounter build problems in any way, \" +\n \"to generate a .binlog file which holds some useful information.\")]\n readonly bool? GenerateBinLog;\n\n [Parameter(\"The key to push to Nuget\")]\n [Secret]\n readonly string NuGetApiKey;\n\n [Solution(GenerateProjects = true)]\n readonly Solution Solution;\n\n [Required]\n [GitVersion(Framework = \"net8.0\", NoCache = true, NoFetch = true)]\n readonly GitVersion GitVersion;\n\n [Required]\n [GitRepository]\n readonly GitRepository GitRepository;\n AbsolutePath ArtifactsDirectory => RootDirectory / \"Artifacts\";\n\n AbsolutePath TestResultsDirectory => RootDirectory / \"TestResults\";\n\n string SemVer;\n\n Target Clean => _ => _\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n ArtifactsDirectory.CreateOrCleanDirectory();\n TestResultsDirectory.CreateOrCleanDirectory();\n });\n\n Target CalculateNugetVersion => _ => _\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n SemVer = GitVersion.SemVer;\n\n if (IsPullRequest)\n {\n Information(\n \"Branch spec {branchspec} is a pull request. Adding build number {buildnumber}\",\n BranchSpec, BuildNumber);\n\n SemVer = string.Join('.', GitVersion.SemVer.Split('.').Take(3).Union([BuildNumber]));\n }\n\n Information(\"SemVer = {semver}\", SemVer);\n });\n\n bool IsPullRequest => GitHubActions?.IsPullRequest ?? false;\n\n Target Restore => _ => _\n .DependsOn(Clean)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n DotNetRestore(s => s\n .SetProjectFile(Solution)\n .EnableNoCache()\n .SetConfigFile(RootDirectory / \"nuget.config\"));\n });\n\n Target Compile => _ => _\n .DependsOn(Restore)\n .DependsOn(CalculateNugetVersion)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n ReportSummary(s => s\n .WhenNotNull(SemVer, (summary, semVer) => summary\n .AddPair(\"Version\", semVer)));\n\n DotNetBuild(s => s\n .SetProjectFile(Solution)\n .SetConfiguration(Configuration)\n .When(_ => GenerateBinLog is true, c => c\n .SetBinaryLog(ArtifactsDirectory / $\"{Solution.Core.AwesomeAssertions.Name}.binlog\")\n )\n .EnableNoLogo()\n .EnableNoRestore()\n .SetVersion(SemVer)\n .SetAssemblyVersion(GitVersion.AssemblySemVer)\n .SetFileVersion(GitVersion.AssemblySemFileVer)\n .SetInformationalVersion(GitVersion.InformationalVersion));\n });\n\n Target ApiChecks => _ => _\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n Project project = Solution.Specs.Approval_Tests;\n\n DotNetTest(s => s\n .SetConfiguration(Configuration == Configuration.Debug ? \"Debug\" : \"Release\")\n .SetProcessEnvironmentVariable(\"DOTNET_CLI_UI_LANGUAGE\", \"en-US\")\n .EnableNoBuild()\n .SetResultsDirectory(TestResultsDirectory)\n .CombineWith(cc => cc\n .SetProjectFile(project)\n .AddLoggers($\"trx;LogFileName={project.Name}.trx\")), completeOnFailure: true);\n });\n\n Project[] Projects =>\n [\n Solution.Specs.AwesomeAssertions_Specs,\n Solution.Specs.AwesomeAssertions_Equivalency_Specs,\n Solution.Specs.AwesomeAssertions_Extensibility_Specs,\n Solution.Specs.FSharp_Specs,\n Solution.Specs.VB_Specs\n ];\n\n Target UnitTestsNet47 => _ => _\n .Unlisted()\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => EnvironmentInfo.IsWin && (RunAllTargets || HasSourceChanges))\n .Executes(() =>\n {\n string[] testAssemblies = Projects\n .SelectMany(project => project.Directory.GlobFiles(\"bin/Debug/net47/*.Specs.dll\"))\n .Select(p => p.ToString())\n .ToArray();\n\n Assert.NotEmpty(testAssemblies.ToList());\n\n Xunit2(s => s\n .SetFramework(\"net47\")\n .AddTargetAssemblies(testAssemblies)\n );\n });\n\n Target UnitTestsNet6OrGreater => _ => _\n .Unlisted()\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n const string net47 = \"net47\";\n\n DotNetTest(s => s\n .SetConfiguration(Configuration.Debug)\n .SetProcessEnvironmentVariable(\"DOTNET_CLI_UI_LANGUAGE\", \"en-US\")\n .EnableNoBuild()\n .SetDataCollector(\"XPlat Code Coverage\")\n .SetResultsDirectory(TestResultsDirectory)\n .AddRunSetting(\n \"DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DoesNotReturnAttribute\",\n \"DoesNotReturnAttribute\")\n .CombineWith(\n Projects,\n (settings, project) => settings\n .SetProjectFile(project)\n .CombineWith(\n project.GetTargetFrameworks().Except([net47]),\n (frameworkSettings, framework) => frameworkSettings\n .SetFramework(framework)\n .AddLoggers($\"trx;LogFileName={project.Name}_{framework}.trx\")\n )\n ), completeOnFailure: true\n );\n });\n\n Target UnitTests => _ => _\n .DependsOn(UnitTestsNet47)\n .DependsOn(UnitTestsNet6OrGreater);\n\n Target CodeCoverage => _ => _\n .DependsOn(TestFrameworks)\n .DependsOn(UnitTests)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n ReportGenerator(s => s\n .SetProcessToolPath(NuGetToolPathResolver.GetPackageExecutable(\"ReportGenerator\", \"ReportGenerator.dll\",\n framework: \"net8.0\"))\n .SetTargetDirectory(TestResultsDirectory / \"reports\")\n .AddReports(TestResultsDirectory / \"**/coverage.cobertura.xml\")\n .AddReportTypes(\n ReportTypes.lcov,\n ReportTypes.HtmlInline_AzurePipelines_Dark)\n .AddFileFilters(\"-*.g.cs\")\n .AddFileFilters(\"-*.nuget*\")\n .SetAssemblyFilters(\"+AwesomeAssertions\"));\n\n string link = TestResultsDirectory / \"reports\" / \"index.html\";\n Information($\"Code coverage report: \\x1b]8;;file://{link.Replace('\\\\', '/')}\\x1b\\\\{link}\\x1b]8;;\\x1b\\\\\");\n });\n\n Target VSTestFrameworks => _ => _\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n Project[] projects =\n [\n Solution.TestFrameworks.MSpec_Specs,\n Solution.TestFrameworks.MSTestV2_Specs,\n Solution.TestFrameworks.NUnit3_Specs,\n Solution.TestFrameworks.NUnit4_Specs,\n Solution.TestFrameworks.XUnit2_Specs,\n Solution.TestFrameworks.XUnit3_Specs,\n Solution.TestFrameworks.XUnit3Core_Specs,\n ];\n\n var testCombinations =\n from project in projects\n let frameworks = project.GetTargetFrameworks()\n let supportedFrameworks = EnvironmentInfo.IsWin ? frameworks : frameworks.Except([\"net47\"])\n from framework in supportedFrameworks\n select new { project, framework };\n\n DotNetTest(s => s\n .SetConfiguration(Configuration.Debug)\n .SetProcessEnvironmentVariable(\"DOTNET_CLI_UI_LANGUAGE\", \"en-US\")\n .EnableNoBuild()\n .SetDataCollector(\"XPlat Code Coverage\")\n .SetResultsDirectory(TestResultsDirectory)\n .AddRunSetting(\n \"DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DoesNotReturnAttribute\",\n \"DoesNotReturnAttribute\")\n .CombineWith(\n testCombinations,\n (settings, v) => settings\n .SetProjectFile(v.project)\n .SetFramework(v.framework)\n .AddLoggers($\"trx;LogFileName={v.project.Name}_{v.framework}.trx\")), completeOnFailure: true);\n });\n\n Target TestingPlatformFrameworks => _ => _\n .DependsOn(Compile)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n Project[] projects =\n [\n Solution.TestFrameworks.TUnit_Specs\n ];\n\n var testCombinations =\n from project in projects\n let frameworks = project.GetTargetFrameworks()\n from framework in frameworks\n select new { project, framework };\n\n DotNetTest(s => s\n .SetConfiguration(Configuration.Debug)\n .SetProcessEnvironmentVariable(\"DOTNET_CLI_UI_LANGUAGE\", \"en-US\")\n .EnableNoBuild()\n .CombineWith(\n testCombinations,\n (settings, v) => settings\n .SetProjectFile(v.project)\n .SetFramework(v.framework)\n .SetProcessAdditionalArguments(\n \"--\",\n \"--coverage\",\n \"--report-trx\",\n $\"--report-trx-filename {v.project.Name}_{v.framework}.trx\",\n $\"--results-directory {TestResultsDirectory}\"\n )\n )\n );\n });\n\n Target TestFrameworks => _ => _\n .DependsOn(VSTestFrameworks)\n .DependsOn(TestingPlatformFrameworks);\n\n Target Pack => _ => _\n .DependsOn(ApiChecks)\n .DependsOn(TestFrameworks)\n .DependsOn(UnitTests)\n .DependsOn(CodeCoverage)\n .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)\n .Executes(() =>\n {\n ReportSummary(s => s\n .WhenNotNull(SemVer, (c, semVer) => c\n .AddPair(\"Packed version\", semVer)));\n\n DotNetPack(s => s\n .SetProject(Solution.Core.AwesomeAssertions)\n .SetOutputDirectory(ArtifactsDirectory)\n .SetConfiguration(Configuration == Configuration.Debug ? \"Debug\" : \"Release\")\n .EnableNoLogo()\n .EnableNoRestore()\n .EnableContinuousIntegrationBuild() // Necessary for deterministic builds\n .SetVersion(SemVer));\n });\n\n Target Push => _ => _\n .DependsOn(Pack)\n .OnlyWhenDynamic(() => IsTag)\n .ProceedAfterFailure()\n .Executes(() =>\n {\n var packages = ArtifactsDirectory.GlobFiles(\"*.nupkg\");\n\n Assert.NotEmpty(packages);\n\n DotNetNuGetPush(s => s\n .SetApiKey(NuGetApiKey)\n .EnableSkipDuplicate()\n .SetSource(\"https://api.nuget.org/v3/index.json\")\n .EnableNoSymbols()\n .CombineWith(packages,\n (v, path) => v.SetTargetPath(path)));\n });\n\n Target SpellCheck => _ => _\n .OnlyWhenDynamic(() => RunAllTargets || HasDocumentationChanges)\n .DependsOn(InstallNode)\n .ProceedAfterFailure()\n .Executes(() =>\n {\n NpmInstall(silent: true, workingDirectory: RootDirectory);\n NpmRun(\"cspell\", silent: true);\n });\n\n Target InstallNode => _ => _\n .OnlyWhenDynamic(() => RunAllTargets || HasDocumentationChanges)\n .ProceedAfterFailure()\n .Executes(() =>\n {\n Initialize(RootDirectory);\n\n NpmFetchRuntime();\n\n ReportSummary(conf =>\n {\n if (HasCachedNodeModules)\n {\n conf.AddPair(\"Skipped\", \"Downloading and extracting\");\n }\n\n return conf;\n });\n });\n\n bool HasDocumentationChanges => Changes.Any(x => IsDocumentation(x));\n\n bool HasSourceChanges => Changes.Any(x => !IsDocumentation(x));\n\n static bool IsDocumentation(string x) =>\n x.StartsWith(\"docs\") ||\n x.StartsWith(\"CONTRIBUTING.md\") ||\n x.StartsWith(\"cSpell.json\") ||\n x.StartsWith(\"LICENSE\") ||\n x.StartsWith(\"package.json\") ||\n x.StartsWith(\"package-lock.json\") ||\n x.StartsWith(\"NodeVersion\") ||\n x.StartsWith(\"README.md\");\n\n string[] Changes =>\n Repository.Diff\n .Compare(TargetBranch, SourceBranch)\n .Where(x => x.Exists)\n .Select(x => x.Path)\n .ToArray();\n\n Repository Repository => new(GitRepository.LocalDirectory);\n\n Tree TargetBranch => Repository.Branches[PullRequestBase].Tip.Tree;\n\n Tree SourceBranch => Repository.Branches[Repository.Head.FriendlyName].Tip.Tree;\n\n bool RunAllTargets => string.IsNullOrWhiteSpace(PullRequestBase) || Changes.Any(x => x.StartsWith(\"Build\"));\n\n bool IsTag => BranchSpec != null && BranchSpec.Contains(\"refs/tags\", StringComparison.OrdinalIgnoreCase);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/CyclicReferenceHandling.cs", "namespace AwesomeAssertions.Equivalency;\n\n/// \n/// Indication of how cyclic references should be handled when validating equality of nested properties.\n/// \npublic enum CyclicReferenceHandling\n{\n /// \n /// Cyclic references will be ignored.\n /// \n Ignore,\n\n /// \n /// Cyclic references will result in an exception.\n /// \n ThrowException\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/XmlSpecs.cs", "using System;\nusing System.Xml.Linq;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class XmlSpecs\n{\n [Fact]\n public void\n When_asserting_a_xml_selfclosing_document_is_equivalent_to_a_different_xml_document_with_same_structure_it_should_succeed()\n {\n // Arrange\n var subject = new\n {\n Document = XDocument.Parse(\"\")\n };\n\n var expectation = new\n {\n Document = XDocument.Parse(\"\")\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equivalent_to_a_xml_document_with_elements_missing_it_should_fail()\n {\n var subject = new\n {\n Document = XDocument.Parse(\"\")\n };\n\n var expectation = new\n {\n Document = XDocument.Parse(\"\")\n };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in property subject.Document at \\\"/parent\\\", but found Element \\\"child2\\\".*\");\n }\n\n [Fact]\n public void When_xml_elements_are_equivalent_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Element = XElement.Parse(\"\")\n };\n\n var expectation = new\n {\n Element = XElement.Parse(\"\")\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_an_xml_element_property_is_equivalent_to_an_xml_element_with_elements_missing_it_should_fail()\n {\n // Arrange\n var subject = new\n {\n Element = XElement.Parse(\"\")\n };\n\n var expectation = new\n {\n Element = XElement.Parse(\"\")\n };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in property subject.Element at \\\"/parent\\\", but found Element \\\"child2\\\"*\");\n }\n\n [Fact]\n public void When_asserting_an_xml_attribute_is_equal_to_the_same_xml_attribute_it_should_succeed()\n {\n var subject = new\n {\n Attribute = new XAttribute(\"name\", \"value\")\n };\n\n var expectation = new\n {\n Attribute = new XAttribute(\"name\", \"value\")\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_asserting_an_xml_attribute_is_equal_to_a_different_xml_attribute_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var subject = new\n {\n Attribute = new XAttribute(\"name\", \"value\")\n };\n\n var expectation = new\n {\n Attribute = new XAttribute(\"name2\", \"value\")\n };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expectation, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected property subject.Attribute to be name2=\\\"value\\\" because we want to test the failure message, but found name=\\\"value\\\"*\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/SubjectInfoExtensions.cs", "using AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\npublic static class SubjectInfoExtensions\n{\n /// \n /// Checks if the subject info setter has the given access modifier.\n /// \n /// The subject info being checked.\n /// The access modifier that the subject info setter should have.\n /// True if the subject info setter has the given access modifier, false otherwise.\n public static bool WhichSetterHas(this IMemberInfo memberInfo, CSharpAccessModifier accessModifier)\n {\n return memberInfo.SetterAccessibility == accessModifier;\n }\n\n /// \n /// Checks if the subject info setter does not have the given access modifier.\n /// \n /// The subject info being checked.\n /// The access modifier that the subject info setter should not have.\n /// True if the subject info setter does not have the given access modifier, false otherwise.\n public static bool WhichSetterDoesNotHave(this IMemberInfo memberInfo, CSharpAccessModifier accessModifier)\n {\n return memberInfo.SetterAccessibility != accessModifier;\n }\n\n /// \n /// Checks if the subject info getter has the given access modifier.\n /// \n /// The subject info being checked.\n /// The access modifier that the subject info getter should have.\n /// True if the subject info getter has the given access modifier, false otherwise.\n public static bool WhichGetterHas(this IMemberInfo memberInfo, CSharpAccessModifier accessModifier)\n {\n return memberInfo.GetterAccessibility == accessModifier;\n }\n\n /// \n /// Checks if the subject info getter does not have the given access modifier.\n /// \n /// The subject info being checked.\n /// The access modifier that the subject info getter should not have.\n /// True if the subject info getter does not have the given access modifier, false otherwise.\n public static bool WhichGetterDoesNotHave(this IMemberInfo memberInfo, CSharpAccessModifier accessModifier)\n {\n return memberInfo.GetterAccessibility != accessModifier;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Accessibility.cs", "using System;\nusing System.Collections.Generic;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Accessibility\n {\n [Fact]\n public void When_a_property_is_write_only_it_should_be_ignored()\n {\n // Arrange\n var expected = new ClassWithWriteOnlyProperty\n {\n WriteOnlyProperty = 123,\n SomeOtherProperty = \"whatever\"\n };\n\n var subject = new\n {\n SomeOtherProperty = \"whatever\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_property_is_private_it_should_be_ignored()\n {\n // Arrange\n var subject = new Customer(\"MyPassword\")\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var other = new Customer(\"SomeOtherPassword\")\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_a_field_is_private_it_should_be_ignored()\n {\n // Arrange\n var subject = new ClassWithAPrivateField(1234)\n {\n Value = 1\n };\n\n var other = new ClassWithAPrivateField(54321)\n {\n Value = 1\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_a_property_is_protected_it_should_be_ignored()\n {\n // Arrange\n var subject = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n subject.SetProtected(\"ActualValue\");\n\n var expected = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n expected.SetProtected(\"ExpectedValue\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_property_is_internal_and_it_should_be_included_it_should_fail_the_assertion()\n {\n // Arrange\n var actual = new ClassWithInternalProperty\n {\n PublicProperty = \"public\",\n InternalProperty = \"internal\",\n ProtectedInternalProperty = \"internal\"\n };\n\n var expected = new ClassWithInternalProperty\n {\n PublicProperty = \"public\",\n InternalProperty = \"also internal\",\n ProtectedInternalProperty = \"also internal\"\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.IncludingInternalProperties());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*InternalProperty*internal*also internal*ProtectedInternalProperty*\");\n }\n\n private class ClassWithInternalProperty\n {\n [UsedImplicitly]\n public string PublicProperty { get; set; }\n\n [UsedImplicitly]\n internal string InternalProperty { get; set; }\n\n [UsedImplicitly]\n protected internal string ProtectedInternalProperty { get; set; }\n }\n\n [Fact]\n public void When_a_field_is_internal_it_should_be_excluded_from_the_comparison()\n {\n // Arrange\n var actual = new ClassWithInternalField\n {\n PublicField = \"public\",\n InternalField = \"internal\",\n ProtectedInternalField = \"internal\"\n };\n\n var expected = new ClassWithInternalField\n {\n PublicField = \"public\",\n InternalField = \"also internal\",\n ProtectedInternalField = \"also internal\"\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_field_is_internal_and_it_should_be_included_it_should_fail_the_assertion()\n {\n // Arrange\n var actual = new ClassWithInternalField\n {\n PublicField = \"public\",\n InternalField = \"internal\",\n ProtectedInternalField = \"internal\"\n };\n\n var expected = new ClassWithInternalField\n {\n PublicField = \"public\",\n InternalField = \"also internal\",\n ProtectedInternalField = \"also internal\"\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.IncludingInternalFields());\n\n // Assert\n act.Should().Throw().WithMessage(\"*InternalField*internal*also internal*ProtectedInternalField*\");\n }\n\n private class ClassWithInternalField\n {\n [UsedImplicitly]\n public string PublicField;\n\n [UsedImplicitly]\n internal string InternalField;\n\n [UsedImplicitly]\n protected internal string ProtectedInternalField;\n }\n\n [Fact]\n public void When_a_property_is_internal_it_should_be_excluded_from_the_comparison()\n {\n // Arrange\n var actual = new ClassWithInternalProperty\n {\n PublicProperty = \"public\",\n InternalProperty = \"internal\",\n ProtectedInternalProperty = \"internal\"\n };\n\n var expected = new ClassWithInternalProperty\n {\n PublicProperty = \"public\",\n InternalProperty = \"also internal\",\n ProtectedInternalProperty = \"also internal\"\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void Private_protected_properties_are_ignored()\n {\n // Arrange\n var subject = new ClassWithPrivateProtectedProperty(\"Name\", 13);\n var other = new ClassWithPrivateProtectedProperty(\"Name\", 37);\n\n // Act/Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n private class ClassWithPrivateProtectedProperty\n {\n public ClassWithPrivateProtectedProperty(string name, int value)\n {\n Name = name;\n Value = value;\n }\n\n [UsedImplicitly]\n public string Name { get; }\n\n [UsedImplicitly]\n private protected int Value { get; }\n }\n\n [Fact]\n public void Private_protected_fields_are_ignored()\n {\n // Arrange\n var subject = new ClassWithPrivateProtectedField(\"Name\", 13);\n var other = new ClassWithPrivateProtectedField(\"Name\", 37);\n\n // Act/Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n private class ClassWithPrivateProtectedField\n {\n public ClassWithPrivateProtectedField(string name, int value)\n {\n Name = name;\n this.value = value;\n }\n\n [UsedImplicitly]\n public string Name;\n\n [UsedImplicitly]\n private protected int value;\n }\n\n [Fact]\n public void Normal_properties_have_priority_over_explicitly_implemented_properties()\n {\n // Arrange\n var instance = new MyClass\n {\n Message = \"instance string message\",\n };\n ((IMyInterface)instance).Message = 42;\n instance.Items.AddRange([1, 2, 3]);\n\n var other = new MyClass\n {\n Message = \"other string message\",\n };\n ((IMyInterface)other).Message = 42;\n other.Items.AddRange([1, 2, 27]);\n\n // Act\n Action act = () => instance.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*Expected property *.Message to be the same string*\" +\n \"*Expected *.Items[2] to be 27, but found 3*\"\n );\n }\n\n private class MyParentClass\n {\n public List Items { get; } = [];\n }\n\n private class MyClass : MyParentClass, IMyInterface\n {\n public string Message { get; set; }\n\n int IMyInterface.Message { get; set; }\n\n IReadOnlyCollection IMyInterface.Items => Items;\n }\n\n private interface IMyInterface\n {\n int Message { get; set; }\n\n IReadOnlyCollection Items { get; }\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/AssertionChainSpecs.MessageFormating.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\n/// \n/// The message formatting specs.\n/// \npublic partial class AssertionChainSpecs\n{\n public class MessageFormatting\n {\n [Fact]\n public void Multiple_assertions_in_an_assertion_scope_are_all_reported()\n {\n // Arrange\n var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate().FailWith(\"Failure\");\n AssertionChain.GetOrCreate().FailWith(\"Failure\");\n\n using (new AssertionScope())\n {\n AssertionChain.GetOrCreate().FailWith(\"Failure\");\n AssertionChain.GetOrCreate().FailWith(\"Failure\");\n }\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Contain(\"Failure\", Exactly.Times(4));\n }\n\n [InlineData(\"foo\")]\n [InlineData(\"{}\")]\n [Theory]\n public void The_failure_message_uses_the_name_of_the_scope_as_context(string context)\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope(context);\n new[] { 1, 2, 3 }.Should().Equal(3, 2, 1);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected {context} to be equal to*\");\n }\n\n [Fact]\n public void The_failure_message_uses_the_lazy_name_of_the_scope_as_context()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope(() => \"lazy foo\");\n new[] { 1, 2, 3 }.Should().Equal(3, 2, 1);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected lazy foo to be equal to*\");\n }\n\n [Fact]\n public void The_failure_message_includes_all_failures()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var values = new Dictionary();\n values.Should().ContainKey(0);\n values.Should().ContainKey(1);\n };\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"\"\"\n Expected * to contain key 0.\n Expected * to contain key 1.\n\n \"\"\");\n }\n\n [Fact]\n public void The_failure_message_includes_all_failures_as_well()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var values = new List();\n values.Should().ContainSingle();\n values.Should().ContainSingle();\n };\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"\"\"\n Expected * to contain a single item, but the collection is empty.\n Expected * to contain a single item, but the collection is empty.\n\n \"\"\");\n }\n\n [Fact]\n public void The_reason_can_contain_parentheses()\n {\n // Act\n Action act = () => 1.Should().Be(2, \"can't use these in becauseArgs: {0} {1}\", \"{\", \"}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because can't use these in becauseArgs: { }*\");\n }\n\n [Fact]\n public void Because_reason_should_ignore_undefined_arguments()\n {\n // Act\n object[] becauseArgs = null;\n Action act = () => 1.Should().Be(2, \"it should still work\", becauseArgs);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because it should still work*\");\n }\n\n [Fact]\n public void Because_reason_should_threat_parentheses_as_literals_if_no_arguments_are_defined()\n {\n // Act\n#pragma warning disable CA2241\n // ReSharper disable once FormatStringProblem\n Action act = () => 1.Should().Be(2, \"use of {} is okay if there are no because arguments\");\n#pragma warning restore CA2241\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because use of {} is okay if there are no because arguments*\");\n }\n\n [Fact]\n public void Because_reason_should_inform_about_invalid_parentheses_with_a_default_message()\n {\n // Act\n#pragma warning disable CA2241\n // ReSharper disable once FormatStringProblem\n Action act = () => 1.Should().Be(2, \"use of {} is considered invalid in because parameter with becauseArgs\",\n \"additional becauseArgs argument\");\n#pragma warning restore CA2241\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*because message 'use of {} is considered invalid in because parameter with becauseArgs' could not be formatted with string.Format*\");\n }\n\n [Fact]\n public void Message_should_keep_parentheses_in_literal_values()\n {\n // Act\n Action act = () => \"{foo}\".Should().Be(\"{bar}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string to be the same string*\\\"{foo}\\\"*\\\"{bar}\\\"*\");\n }\n\n [Fact]\n public void Message_should_contain_literal_value_if_marked_with_double_parentheses()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate().FailWith(\"{{empty}}\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"{empty}*\");\n }\n\n [InlineData(\"\\r\")]\n [InlineData(\"\\\\r\")]\n [InlineData(\"\\\\\\r\")]\n [InlineData(\"\\\\\\\\r\")]\n [InlineData(\"\\\\\\\\\\r\")]\n [InlineData(\"\\n\")]\n [InlineData(\"\\\\n\")]\n [InlineData(\"\\\\\\n\")]\n [InlineData(\"\\\\\\\\n\")]\n [InlineData(\"\\\\\\\\\\n\")]\n [Theory]\n public void Message_should_not_have_modified_carriage_return_or_line_feed_control_characters(string str)\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate().FailWith(str);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(str);\n }\n\n [InlineData(\"\\r\")]\n [InlineData(\"\\\\r\")]\n [InlineData(\"\\\\\\r\")]\n [InlineData(@\"\\\\r\")]\n [InlineData(\"\\\\\\\\\\r\")]\n [InlineData(\"\\n\")]\n [InlineData(\"\\\\n\")]\n [InlineData(\"\\\\\\n\")]\n [InlineData(@\"\\\\n\")]\n [InlineData(\"\\\\\\\\\\n\")]\n [Theory]\n public void Message_should_not_have_modified_carriage_return_or_line_feed_control_characters_in_supplied_arguments(\n string str)\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate().FailWith(@\"\\{0}\\A\", str);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"\\\\\\\"\" + str + \"\\\"\\\\A*\");\n }\n\n [Fact]\n public void Message_should_not_have_trailing_backslashes_removed_from_subject()\n {\n // Arrange / Act\n Action act = () => \"A\\\\\".Should().Be(\"A\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\"\"*\"A\\\"*\"A\"*\"\"\");\n }\n\n [Fact]\n public void Message_should_not_have_trailing_backslashes_removed_from_expectation()\n {\n // Arrange / Act\n Action act = () => \"A\".Should().Be(\"A\\\\\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\"\"*\"A\"*\"A\\\"*\"\"\");\n }\n\n [Fact]\n public void Message_should_have_scope_reportable_values_appended_at_the_end()\n {\n // Arrange\n var scope = new AssertionScope();\n scope.AddReportable(\"SomeKey\", \"SomeValue\");\n scope.AddReportable(\"AnotherKey\", \"AnotherValue\");\n\n AssertionChain.GetOrCreate().FailWith(\"{SomeKey}{AnotherKey}\");\n\n // Act\n Action act = scope.Dispose;\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"\"\"\n *With SomeKey:\n SomeValue\n With AnotherKey:\n AnotherValue\n\n \"\"\");\n }\n\n [Fact]\n public void Message_should_not_contain_reportable_values_added_to_chain_without_surrounding_scope()\n {\n // Arrange\n var chain = AssertionChain.GetOrCreate();\n chain.AddReportable(\"SomeKey\", \"SomeValue\");\n chain.AddReportable(\"AnotherKey\", \"AnotherValue\");\n\n // Act\n Action act = () => chain.FailWith(\"{SomeKey}{AnotherKey}\");\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().BeEmpty();\n }\n\n [Fact]\n public void Deferred_reportable_values_should_not_be_calculated_in_absence_of_failures()\n {\n // Arrange\n var scope = new AssertionScope();\n var deferredValueInvoked = false;\n\n scope.AddReportable(\"MyKey\", () =>\n {\n deferredValueInvoked = true;\n\n return \"MyValue\";\n });\n\n // Act\n scope.Dispose();\n\n // Assert\n deferredValueInvoked.Should().BeFalse();\n }\n\n [Fact]\n public void Message_should_start_with_the_defined_expectation()\n {\n // Act\n Action act = () =>\n {\n var assertion = AssertionChain.GetOrCreate();\n\n assertion\n .WithExpectation(\"Expectations are the root \", chain => chain\n .ForCondition(false)\n .FailWith(\"of disappointment\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectations are the root of disappointment\");\n }\n\n [Fact]\n public void Message_should_start_with_the_defined_expectation_and_arguments()\n {\n // Act\n Action act = () =>\n {\n var assertion = AssertionChain.GetOrCreate();\n\n assertion\n .WithExpectation(\"Expectations are the {0} \", \"root\", chain => chain.ForCondition(false)\n .FailWith(\"of disappointment\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectations are the \\\"root\\\" of disappointment\");\n }\n\n [Fact]\n public void Message_should_contain_object_as_context_if_identifier_can_not_be_resolved()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"Expected {context}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected object\");\n }\n\n [Fact]\n public void Message_should_contain_the_fallback_value_as_context_if_identifier_can_not_be_resolved()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"Expected {context:fallback}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected fallback\");\n }\n\n [Fact]\n public void Message_should_contain_the_default_identifier_as_context_if_identifier_can_not_be_resolved()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .WithDefaultIdentifier(\"identifier\")\n .ForCondition(false)\n .FailWith(\"Expected {context}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected identifier\");\n }\n\n [Fact]\n public void Message_should_contain_the_reason_as_defined()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .BecauseOf(\"because reasons\")\n .FailWith(\"Expected{reason}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because reasons\");\n }\n\n [Fact]\n public void Message_should_contain_the_reason_as_defined_with_arguments()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .BecauseOf(\"because {0}\", \"reasons\")\n .FailWith(\"Expected{reason}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because reasons\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/EnumerableValueFormatter.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class EnumerableValueFormatter : IValueFormatter\n{\n /// \n /// The number of items to include when formatting this object.\n /// \n /// The default value is 32.\n protected virtual int MaxItems => 32;\n\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public virtual bool CanHandle(object value)\n {\n return value is IEnumerable;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n IEnumerable collection = ((IEnumerable)value).Cast();\n\n using var iterator = new Iterator(collection, MaxItems);\n\n var iteratorGraph = formattedGraph.KeepOnSingleLineAsLongAsPossible();\n FormattedObjectGraph.PossibleMultilineFragment separatingCommaGraph = null;\n\n while (iterator.MoveNext())\n {\n if (!iterator.HasReachedMaxItems)\n {\n formatChild(iterator.Index.ToString(CultureInfo.InvariantCulture), iterator.Current, formattedGraph);\n }\n else\n {\n using IDisposable _ = formattedGraph.WithIndentation();\n string moreItemsMessage = value is ICollection c ? $\"…{c.Count - MaxItems} more…\" : \"…more…\";\n iteratorGraph.AddLineOrFragment(moreItemsMessage);\n }\n\n separatingCommaGraph?.InsertLineOrFragment(\", \");\n separatingCommaGraph = formattedGraph.KeepOnSingleLineAsLongAsPossible();\n\n // We cannot know whether or not the enumerable will take up more than one line of\n // output until we have formatted the first item. So we format the first item, then\n // go back and insert the enumerable's opening brace in the correct place depending\n // on whether that first item was all on one line or not.\n if (iterator.IsLast)\n {\n iteratorGraph.AddStartingLineOrFragment(\"{\");\n iteratorGraph.AddLineOrFragment(\"}\");\n }\n }\n\n if (iterator.IsEmpty)\n {\n iteratorGraph.AddFragment(\"{empty}\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/AssertionRuleSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class AssertionRuleSpecs\n{\n [Fact]\n public void When_two_objects_have_the_same_property_values_it_should_succeed()\n {\n // Arrange\n var subject = new { Age = 36, Birthdate = new DateTime(1973, 9, 20), Name = \"Dennis\" };\n\n var other = new { Age = 36, Birthdate = new DateTime(1973, 9, 20), Name = \"Dennis\" };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_two_objects_have_the_same_nullable_property_values_it_should_succeed()\n {\n // Arrange\n var subject = new { Age = 36, Birthdate = (DateTime?)new DateTime(1973, 9, 20), Name = \"Dennis\" };\n\n var other = new { Age = 36, Birthdate = (DateTime?)new DateTime(1973, 9, 20), Name = \"Dennis\" };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_two_objects_have_the_same_properties_but_a_different_value_it_should_throw()\n {\n // Arrange\n var subject = new { Age = 36 };\n\n var expectation = new { Age = 37 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, \"because {0} are the same\", \"they\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Age*to be 37 because they are the same, but found 36*\");\n }\n\n [Fact]\n public void\n When_subject_has_a_valid_property_that_is_compared_with_a_null_property_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var subject = new { Name = \"Dennis\" };\n\n var other = new { Name = (string)null };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected property subject.Name to be *we want to test the failure message*, but found \\\"Dennis\\\"*\");\n }\n\n [Fact]\n public void When_two_collection_properties_dont_match_it_should_throw_and_specify_the_difference()\n {\n // Arrange\n var subject = new { Values = new[] { 1, 2, 3 } };\n\n var other = new { Values = new[] { 1, 4, 3 } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Values[1]*to be 4, but found 2*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_two_string_properties_do_not_match_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject = new { Name = \"Dennes\" };\n\n var other = new { Name = \"Dennis\" };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other, options => options.Including(d => d.Name));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Name to be*index 4*\\\"Dennes\\\"*\\\"Dennis\\\"*\");\n }\n\n [Fact]\n public void When_two_properties_are_of_derived_types_but_are_equal_it_should_succeed()\n {\n // Arrange\n var subject = new { Type = new DerivedCustomerType(\"123\") };\n\n var other = new { Type = new CustomerType(\"123\") };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void\n When_two_properties_have_the_same_declared_type_but_different_runtime_types_and_are_equivalent_according_to_the_declared_type_it_should_succeed()\n {\n // Arrange\n var subject = new { Type = (CustomerType)new DerivedCustomerType(\"123\") };\n\n var other = new { Type = new CustomerType(\"123\") };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_a_nested_property_is_equal_based_on_equality_comparer_it_should_not_throw()\n {\n // Arrange\n var subject = new { Timestamp = 22.March(2020).At(19, 30) };\n\n var expectation = new { Timestamp = 1.January(2020).At(7, 31) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using());\n }\n\n [Fact]\n public void When_a_nested_property_is_unequal_based_on_equality_comparer_it_should_throw()\n {\n // Arrange\n var subject = new { Timestamp = 22.March(2020) };\n\n var expectation = new { Timestamp = 1.January(2021) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(new DateTimeByYearComparer()));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*equal*2021*DateTimeByYearComparer*2020*\");\n }\n\n [Fact]\n public void When_the_subjects_property_type_is_different_from_the_equality_comparer_it_should_throw()\n {\n // Arrange\n var subject = new { Timestamp = 1L };\n\n var expectation = new { Timestamp = 1.January(2021) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(new DateTimeByYearComparer()));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*Timestamp*1L*\");\n }\n\n private class DateTimeByYearComparer : IEqualityComparer\n {\n public bool Equals(DateTime x, DateTime y)\n {\n return x.Year == y.Year;\n }\n\n public int GetHashCode(DateTime obj) => obj.GetHashCode();\n }\n\n [Fact]\n public void When_an_invalid_equality_comparer_is_provided_it_should_throw()\n {\n // Arrange\n var subject = new { Timestamp = 22.March(2020) };\n\n var expectation = new { Timestamp = 1.January(2021) };\n\n IEqualityComparer equalityComparer = null;\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(equalityComparer));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*comparer*\");\n }\n\n [Fact]\n public void When_the_compile_time_type_does_not_match_the_equality_comparer_type_it_should_use_the_default_mechanics()\n {\n // Arrange\n var subject = new { Property = (IInterface)new ConcreteClass(\"SomeString\") };\n\n var expectation = new { Property = (IInterface)new ConcreteClass(\"SomeOtherString\") };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opt =>\n opt.Using());\n }\n\n [Fact]\n public void When_the_runtime_type_does_match_the_equality_comparer_type_it_should_use_the_default_mechanics()\n {\n // Arrange\n var subject = new { Property = (IInterface)new ConcreteClass(\"SomeString\") };\n\n var expectation = new { Property = (IInterface)new ConcreteClass(\"SomeOtherString\") };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opt => opt\n .PreferringRuntimeMemberTypes()\n .Using());\n\n // Assert\n act.Should().Throw().WithMessage(\"*ConcreteClassEqualityComparer*\");\n }\n\n [Fact]\n public void When_several_properties_do_not_match_they_are_all_reported_after_an_other_successful_assertion()\n {\n // Arrange\n var test = new Test\n {\n Id = 42,\n Text = \"some-text\",\n };\n var actualTest = new Test\n {\n Id = 32,\n Text = \"some-other-text\",\n };\n\n // Act\n Action act = () =>\n {\n actualTest.Text.Should().Be(\"some-other-text\");\n actualTest.Should().BeEquivalentTo(test);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected property actualTest.Id to be*{Environment.NewLine}\" +\n \"*Expected property actualTest.Text to be*\"\n );\n }\n\n private sealed class Test\n {\n public int Id { get; set; }\n\n public string Text { get; set; }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void An_equality_comparer_of_non_nullable_type_is_not_invoked_on_nullable_member()\n {\n // Arrange\n var subject = new { Timestamp = (DateTime?)22.March(2020) };\n\n var expectation = new { Timestamp = (DateTime?)1.January(2020) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(new DateTimeByYearComparer()));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Timestamp*2020*\");\n }\n\n [Fact]\n public void An_equality_comparer_of_nullable_type_is_not_invoked_on_non_nullable_member()\n {\n // Arrange\n var subject = new { Timestamp = 22.March(2020) };\n\n var expectation = new { Timestamp = 1.January(2020) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opt => opt.Using(new NullableDateTimeByYearComparer()));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Timestamp*2020*\");\n }\n\n [Fact]\n public void An_equality_comparer_of_non_nullable_type_is_invoked_on_non_nullable_data()\n {\n // Arrange\n var subject = new { Timestamp = (DateTime?)22.March(2020) };\n\n var expectation = new { Timestamp = (DateTime?)1.January(2020) };\n\n // Act\n subject.Should().BeEquivalentTo(expectation, opt => opt\n .PreferringRuntimeMemberTypes()\n .Using(new DateTimeByYearComparer()));\n }\n\n [Fact]\n public void An_equality_comparer_of_nullable_type_is_not_invoked_on_non_nullable_data()\n {\n // Arrange\n var subject = new { Timestamp = (DateTime?)22.March(2020) };\n\n var expectation = new { Timestamp = (DateTime?)1.January(2020) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opt => opt\n .PreferringRuntimeMemberTypes()\n .Using(new NullableDateTimeByYearComparer()));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Timestamp*2020*\");\n }\n }\n\n private interface IInterface;\n\n private class ConcreteClass : IInterface\n {\n private readonly string property;\n\n public ConcreteClass(string propertyValue)\n {\n property = propertyValue;\n }\n\n public string GetProperty() => property;\n }\n\n private class ConcreteClassEqualityComparer : IEqualityComparer\n {\n public bool Equals(ConcreteClass x, ConcreteClass y)\n {\n return x.GetProperty() == y.GetProperty();\n }\n\n public int GetHashCode(ConcreteClass obj) => obj.GetProperty().GetHashCode();\n }\n\n private class NullableDateTimeByYearComparer : IEqualityComparer\n {\n public bool Equals(DateTime? x, DateTime? y)\n {\n return x?.Year == y?.Year;\n }\n\n public int GetHashCode(DateTime? obj) => obj?.GetHashCode() ?? 0;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DoubleValueFormatter.cs", "using System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DoubleValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is double;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(Format(value));\n }\n\n private static string Format(object value)\n {\n double doubleValue = (double)value;\n\n if (double.IsPositiveInfinity(doubleValue))\n {\n return nameof(Double) + \".\" + nameof(double.PositiveInfinity);\n }\n\n if (double.IsNegativeInfinity(doubleValue))\n {\n return nameof(Double) + \".\" + nameof(double.NegativeInfinity);\n }\n\n if (double.IsNaN(doubleValue))\n {\n return doubleValue.ToString(CultureInfo.InvariantCulture);\n }\n\n string formattedValue = doubleValue.ToString(\"R\", CultureInfo.InvariantCulture);\n\n return !formattedValue.Contains('.', StringComparison.Ordinal) && !formattedValue.Contains('E', StringComparison.Ordinal)\n ? formattedValue + \".0\"\n : formattedValue;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/NumericAssertionsExtensions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Numeric;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Contains a number of extension methods for floating point .\n/// \npublic static class NumericAssertionsExtensions\n{\n #region BeCloseTo\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n sbyte nearbyValue, byte delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n sbyte actualValue = parent.Subject;\n sbyte minValue = (sbyte)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = sbyte.MinValue;\n }\n\n sbyte maxValue = (sbyte)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = sbyte.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue, because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n byte nearbyValue, byte delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n byte actualValue = parent.Subject;\n byte minValue = (byte)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = byte.MinValue;\n }\n\n byte maxValue = (byte)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = byte.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue, nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n short nearbyValue, ushort delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n short actualValue = parent.Subject;\n short minValue = (short)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = short.MinValue;\n }\n\n short maxValue = (short)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = short.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n ushort nearbyValue, ushort delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ushort actualValue = parent.Subject;\n ushort minValue = (ushort)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = ushort.MinValue;\n }\n\n ushort maxValue = (ushort)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = ushort.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n int nearbyValue, uint delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n int actualValue = parent.Subject;\n int minValue = (int)(nearbyValue - delta);\n\n if (minValue > nearbyValue)\n {\n minValue = int.MinValue;\n }\n\n int maxValue = (int)(nearbyValue + delta);\n\n if (maxValue < nearbyValue)\n {\n maxValue = int.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because,\n becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n uint nearbyValue, uint delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n uint actualValue = parent.Subject;\n uint minValue = nearbyValue - delta;\n\n if (minValue > nearbyValue)\n {\n minValue = uint.MinValue;\n }\n\n uint maxValue = nearbyValue + delta;\n\n if (maxValue < nearbyValue)\n {\n maxValue = uint.MaxValue;\n }\n\n FailIfValueOutsideBounds(\n parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n long nearbyValue, ulong delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n long actualValue = parent.Subject;\n long minValue = GetMinValue(nearbyValue, delta);\n long maxValue = GetMaxValue(nearbyValue, delta);\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is close to another value within a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeCloseTo(this NumericAssertions parent,\n ulong nearbyValue, ulong delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ulong actualValue = parent.Subject;\n ulong minValue = nearbyValue - delta;\n\n if (minValue > nearbyValue)\n {\n minValue = ulong.MinValue;\n }\n\n ulong maxValue = nearbyValue + delta;\n\n if (maxValue < nearbyValue)\n {\n maxValue = ulong.MaxValue;\n }\n\n FailIfValueOutsideBounds(parent.CurrentAssertionChain,\n minValue <= actualValue && actualValue <= maxValue,\n nearbyValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n private static void FailIfValueOutsideBounds(AssertionChain assertionChain, bool valueWithinBounds,\n TValue nearbyValue, TDelta delta, TValue actualValue,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n {\n assertionChain\n .ForCondition(valueWithinBounds)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be within {0} from {1}{reason}, but found {2}.\",\n delta, nearbyValue, actualValue);\n }\n\n #endregion\n\n #region NotBeCloseTo\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n sbyte distantValue, byte delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n sbyte actualValue = parent.Subject;\n sbyte minValue = (sbyte)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = sbyte.MinValue;\n }\n\n sbyte maxValue = (sbyte)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = sbyte.MaxValue;\n }\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n byte distantValue, byte delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n byte actualValue = parent.Subject;\n byte minValue = (byte)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = byte.MinValue;\n }\n\n byte maxValue = (byte)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = byte.MaxValue;\n }\n\n FailIfValueInsideBounds(\n parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n short distantValue, ushort delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n short actualValue = parent.Subject;\n short minValue = (short)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = short.MinValue;\n }\n\n short maxValue = (short)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = short.MaxValue;\n }\n\n FailIfValueInsideBounds(\n parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n ushort distantValue, ushort delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ushort actualValue = parent.Subject;\n ushort minValue = (ushort)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = ushort.MinValue;\n }\n\n ushort maxValue = (ushort)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = ushort.MaxValue;\n }\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n int distantValue, uint delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n int actualValue = parent.Subject;\n int minValue = (int)(distantValue - delta);\n\n if (minValue > distantValue)\n {\n minValue = int.MinValue;\n }\n\n int maxValue = (int)(distantValue + delta);\n\n if (maxValue < distantValue)\n {\n maxValue = int.MaxValue;\n }\n\n FailIfValueInsideBounds(\n parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n uint distantValue, uint delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n uint actualValue = parent.Subject;\n uint minValue = distantValue - delta;\n\n if (minValue > distantValue)\n {\n minValue = uint.MinValue;\n }\n\n uint maxValue = distantValue + delta;\n\n if (maxValue < distantValue)\n {\n maxValue = uint.MaxValue;\n }\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n long distantValue, ulong delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n long actualValue = parent.Subject;\n long minValue = GetMinValue(distantValue, delta);\n long maxValue = GetMaxValue(distantValue, delta);\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue),\n distantValue, delta, actualValue,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts an integral value is not within another value by a specified value.\n /// \n /// The object that is being extended.\n /// \n /// The nearby value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeCloseTo(this NumericAssertions parent,\n ulong distantValue, ulong delta,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n ulong actualValue = parent.Subject;\n ulong minValue = distantValue - delta;\n\n if (minValue > distantValue)\n {\n minValue = ulong.MinValue;\n }\n\n ulong maxValue = distantValue + delta;\n\n if (maxValue < distantValue)\n {\n maxValue = ulong.MaxValue;\n }\n\n FailIfValueInsideBounds(parent.CurrentAssertionChain,\n !(minValue <= actualValue && actualValue <= maxValue), distantValue,\n delta,\n actualValue,\n because,\n becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n private static void FailIfValueInsideBounds(\n AssertionChain assertionChain,\n bool valueOutsideBounds,\n TValue distantValue, TDelta delta, TValue actualValue,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n {\n assertionChain\n .ForCondition(valueOutsideBounds)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be within {0} from {1}{reason}, but found {2}.\",\n delta, distantValue, actualValue);\n }\n\n #endregion\n\n #region BeApproximately\n\n /// \n /// Asserts a floating point value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NullableNumericAssertions parent,\n float expectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .\", expectedValue,\n precision);\n\n if (assertion.Succeeded)\n {\n var nonNullableAssertions = new SingleAssertions(parent.Subject.Value, assertion);\n nonNullableAssertions.BeApproximately(expectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a floating point value approximates another value as close as possible.\n /// Does not throw if null subject value approximates null value.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NullableNumericAssertions parent,\n float? expectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null && expectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(expectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was {2}.\", expectedValue, precision,\n parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.BeApproximately(expectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a floating point value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NumericAssertions parent,\n float expectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (float.IsNaN(expectedValue))\n {\n throw new ArgumentException(\"Cannot determine approximation of a float to NaN\", nameof(expectedValue));\n }\n\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (float.IsPositiveInfinity(expectedValue))\n {\n FailIfDifferenceOutsidePrecision(float.IsPositiveInfinity(parent.Subject), parent, expectedValue, precision,\n float.NaN, because, becauseArgs);\n }\n else if (float.IsNegativeInfinity(expectedValue))\n {\n FailIfDifferenceOutsidePrecision(float.IsNegativeInfinity(parent.Subject), parent, expectedValue, precision,\n float.NaN, because, becauseArgs);\n }\n else\n {\n float actualDifference = Math.Abs(expectedValue - parent.Subject);\n\n FailIfDifferenceOutsidePrecision(actualDifference <= precision, parent, expectedValue, precision, actualDifference,\n because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NullableNumericAssertions parent,\n double expectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .\", expectedValue,\n precision);\n\n if (assertion.Succeeded)\n {\n var nonNullableAssertions = new DoubleAssertions(parent.Subject.Value, assertion);\n BeApproximately(nonNullableAssertions, expectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value approximates another value as close as possible.\n /// Does not throw if null subject value approximates null value.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NullableNumericAssertions parent,\n double? expectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null && expectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(expectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was {2}.\", expectedValue, precision,\n parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.BeApproximately(expectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NumericAssertions parent,\n double expectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (double.IsNaN(expectedValue))\n {\n throw new ArgumentException(\"Cannot determine approximation of a double to NaN\", nameof(expectedValue));\n }\n\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (double.IsPositiveInfinity(expectedValue))\n {\n FailIfDifferenceOutsidePrecision(double.IsPositiveInfinity(parent.Subject), parent, expectedValue, precision,\n double.NaN, because, becauseArgs);\n }\n else if (double.IsNegativeInfinity(expectedValue))\n {\n FailIfDifferenceOutsidePrecision(double.IsNegativeInfinity(parent.Subject), parent, expectedValue, precision,\n double.NaN, because, becauseArgs);\n }\n else\n {\n double actualDifference = Math.Abs(expectedValue - parent.Subject);\n\n FailIfDifferenceOutsidePrecision(actualDifference <= precision, parent, expectedValue, precision, actualDifference,\n because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(\n this NullableNumericAssertions parent,\n decimal expectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .\", expectedValue,\n precision);\n\n if (assertion.Succeeded)\n {\n var nonNullableAssertions = new DecimalAssertions(parent.Subject.Value, assertion);\n BeApproximately(nonNullableAssertions, expectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value approximates another value as close as possible.\n /// Does not throw if null subject value approximates null value.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(\n this NullableNumericAssertions parent,\n decimal? expectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null && expectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(expectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {0} +/- {1}{reason}, but it was {2}.\", expectedValue, precision,\n parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.BeApproximately(expectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value approximates another value as close as possible.\n /// \n /// The object that is being extended.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// \n /// The maximum amount of which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> BeApproximately(this NumericAssertions parent,\n decimal expectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n decimal actualDifference = Math.Abs(expectedValue - parent.Subject);\n\n FailIfDifferenceOutsidePrecision(actualDifference <= precision, parent, expectedValue, precision, actualDifference,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n private static void FailIfDifferenceOutsidePrecision(\n bool differenceWithinPrecision,\n NumericAssertions parent, T expectedValue, T precision, T actualDifference,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where T : struct, IComparable\n {\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(differenceWithinPrecision)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to approximate {1} +/- {2}{reason}, but {0} differed by {3}.\",\n parent.Subject, expectedValue, precision, actualDifference);\n }\n\n #endregion\n\n #region NotBeApproximately\n\n /// \n /// Asserts a floating point value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NullableNumericAssertions parent,\n float unexpectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is not null)\n {\n var nonNullableAssertions = new SingleAssertions(parent.Subject.Value, parent.CurrentAssertionChain);\n nonNullableAssertions.NotBeApproximately(unexpectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a floating point value does not approximate another value by a given amount.\n /// Throws if both subject and are null.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NullableNumericAssertions parent,\n float? unexpectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null != unexpectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null && unexpectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not approximate {0} +/- {1}{reason}, but it was {2}.\", unexpectedValue,\n precision, parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.NotBeApproximately(unexpectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a floating point value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NumericAssertions parent,\n float unexpectedValue, float precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (float.IsNaN(unexpectedValue))\n {\n throw new ArgumentException(\"Cannot determine approximation of a float to NaN\", nameof(unexpectedValue));\n }\n\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (float.IsPositiveInfinity(unexpectedValue))\n {\n FailIfDifferenceWithinPrecision(parent, !float.IsPositiveInfinity(parent.Subject), unexpectedValue, precision,\n float.NaN, because, becauseArgs);\n }\n else if (float.IsNegativeInfinity(unexpectedValue))\n {\n FailIfDifferenceWithinPrecision(parent, !float.IsNegativeInfinity(parent.Subject), unexpectedValue, precision,\n float.NaN, because, becauseArgs);\n }\n else\n {\n float actualDifference = Math.Abs(unexpectedValue - parent.Subject);\n\n FailIfDifferenceWithinPrecision(parent, actualDifference > precision, unexpectedValue, precision, actualDifference,\n because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(\n this NullableNumericAssertions parent,\n double unexpectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is not null)\n {\n var nonNullableAssertions = new DoubleAssertions(parent.Subject.Value, parent.CurrentAssertionChain);\n nonNullableAssertions.NotBeApproximately(unexpectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value does not approximate another value by a given amount.\n /// Throws if both subject and are null.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(\n this NullableNumericAssertions parent,\n double? unexpectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null != unexpectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n AssertionChain assertionChain = parent.CurrentAssertionChain;\n\n assertionChain\n .ForCondition(parent.Subject is not null && unexpectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not approximate {0} +/- {1}{reason}, but it was {2}.\", unexpectedValue,\n precision, parent.Subject);\n\n if (assertionChain.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.NotBeApproximately(unexpectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a double value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NumericAssertions parent,\n double unexpectedValue, double precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (double.IsNaN(unexpectedValue))\n {\n throw new ArgumentException(\"Cannot determine approximation of a double to NaN\", nameof(unexpectedValue));\n }\n\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (double.IsPositiveInfinity(unexpectedValue))\n {\n FailIfDifferenceWithinPrecision(parent, !double.IsPositiveInfinity(parent.Subject), unexpectedValue, precision,\n double.NaN, because, becauseArgs);\n }\n else if (double.IsNegativeInfinity(unexpectedValue))\n {\n FailIfDifferenceWithinPrecision(parent, !double.IsNegativeInfinity(parent.Subject), unexpectedValue, precision,\n double.NaN, because, becauseArgs);\n }\n else\n {\n double actualDifference = Math.Abs(unexpectedValue - parent.Subject);\n\n FailIfDifferenceWithinPrecision(parent, actualDifference > precision, unexpectedValue, precision, actualDifference,\n because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(\n this NullableNumericAssertions parent,\n decimal unexpectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is not null)\n {\n var nonNullableAssertions = new DecimalAssertions(parent.Subject.Value, parent.CurrentAssertionChain);\n NotBeApproximately(nonNullableAssertions, unexpectedValue, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value does not approximate another value by a given amount.\n /// Throws if both subject and are null.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(\n this NullableNumericAssertions parent,\n decimal? unexpectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n if (parent.Subject is null != unexpectedValue is null)\n {\n return new AndConstraint>(parent);\n }\n\n var assertion = parent.CurrentAssertionChain;\n\n assertion\n .ForCondition(parent.Subject is not null && unexpectedValue is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not approximate {0} +/- {1}{reason}, but it was {2}.\", unexpectedValue,\n precision, parent.Subject);\n\n if (assertion.Succeeded)\n {\n // ReSharper disable once PossibleInvalidOperationException\n parent.NotBeApproximately(unexpectedValue.Value, precision, because, becauseArgs);\n }\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts a decimal value does not approximate another value by a given amount.\n /// \n /// The object that is being extended.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// \n /// The minimum exclusive amount of which the two values should differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public static AndConstraint> NotBeApproximately(this NumericAssertions parent,\n decimal unexpectedValue, decimal precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n decimal actualDifference = Math.Abs(unexpectedValue - parent.Subject);\n\n FailIfDifferenceWithinPrecision(parent, actualDifference > precision, unexpectedValue, precision, actualDifference,\n because, becauseArgs);\n\n return new AndConstraint>(parent);\n }\n\n private static void FailIfDifferenceWithinPrecision(\n NumericAssertions parent, bool differenceOutsidePrecision,\n T unexpectedValue, T precision, T actualDifference,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where T : struct, IComparable\n {\n parent.CurrentAssertionChain\n .ForCondition(differenceOutsidePrecision)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not approximate {1} +/- {2}{reason}, but {0} only differed by {3}.\",\n parent.Subject, unexpectedValue, precision, actualDifference);\n }\n\n #endregion\n\n #region BeNaN\n\n /// \n /// Asserts that the number is seen as not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeNaN(this NumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n float actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(float.IsNaN(actualValue))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be NaN{reason}, but found {0}.\", actualValue);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is seen as not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeNaN(this NumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n double actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(double.IsNaN(actualValue))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be NaN{reason}, but found {0}.\", actualValue);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is seen as not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeNaN(this NullableNumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n float? actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(actualValue is { } value && float.IsNaN(value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be NaN{reason}, but found {0}.\", actualValue);\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is seen as not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> BeNaN(this NullableNumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n double? actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(actualValue is { } value && double.IsNaN(value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be NaN{reason}, but found {0}.\", actualValue);\n\n return new AndConstraint>(parent);\n }\n\n #endregion\n\n #region NotBeNaN\n\n /// \n /// Asserts that the number is not seen as the special value not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeNaN(this NumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n float actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(!float.IsNaN(actualValue))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be NaN{reason}.\");\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is not seen as the special value not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeNaN(this NumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n double actualValue = parent.Subject;\n\n parent.CurrentAssertionChain\n .ForCondition(!double.IsNaN(actualValue))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be NaN{reason}.\");\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is not seen as the special value not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeNaN(this NullableNumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n float? actualValue = parent.Subject;\n bool actualValueIsNaN = actualValue is { } value && float.IsNaN(value);\n\n parent.CurrentAssertionChain\n .ForCondition(!actualValueIsNaN)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be NaN{reason}.\");\n\n return new AndConstraint>(parent);\n }\n\n /// \n /// Asserts that the number is not seen as the special value not a number (NaN).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static AndConstraint> NotBeNaN(this NullableNumericAssertions parent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n double? actualValue = parent.Subject;\n bool actualValueIsNaN = actualValue is { } value && double.IsNaN(value);\n\n parent.CurrentAssertionChain\n .ForCondition(!actualValueIsNaN)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be NaN{reason}.\");\n\n return new AndConstraint>(parent);\n }\n\n #endregion\n\n private static long GetMinValue(long value, ulong delta)\n {\n long minValue;\n\n if (delta <= (ulong.MaxValue / 2))\n {\n minValue = value - (long)delta;\n }\n else if (value < 0)\n {\n minValue = long.MinValue;\n }\n else\n {\n minValue = -(long)(delta - (ulong)value);\n }\n\n if (minValue > value)\n {\n minValue = long.MinValue;\n }\n\n return minValue;\n }\n\n private static long GetMaxValue(long value, ulong delta)\n {\n long maxValue;\n\n if (delta <= (ulong.MaxValue / 2))\n {\n maxValue = value + (long)delta;\n }\n else if (value >= 0)\n {\n maxValue = long.MaxValue;\n }\n else\n {\n maxValue = (long)((ulong)value + delta);\n }\n\n if (maxValue < value)\n {\n maxValue = long.MaxValue;\n }\n\n return maxValue;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Basic.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Basic\n {\n [Fact]\n public void Property_names_are_case_sensitive()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\"\n };\n\n var other = new\n {\n name = \"John\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expectation*name**other*not have*\");\n }\n\n [Fact]\n public void Field_names_are_case_sensitive()\n {\n // Arrange\n var subject = new ClassWithFieldInUpperCase\n {\n Name = \"John\"\n };\n\n var other = new ClassWithFieldInLowerCase\n {\n name = \"John\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expectation*name**other*not have*\");\n }\n\n private class ClassWithFieldInLowerCase\n {\n [UsedImplicitly]\n#pragma warning disable SA1307\n public string name;\n#pragma warning restore SA1307\n }\n\n private class ClassWithFieldInUpperCase\n {\n [UsedImplicitly]\n public string Name;\n }\n\n [Fact]\n public void When_a_property_is_an_indexer_it_should_be_ignored()\n {\n // Arrange\n var expected = new ClassWithIndexer\n {\n Foo = \"test\"\n };\n\n var result = new ClassWithIndexer\n {\n Foo = \"test\"\n };\n\n // Act / Assert\n result.Should().BeEquivalentTo(expected);\n }\n\n public class ClassWithIndexer\n {\n [UsedImplicitly]\n public object Foo { get; set; }\n\n public string this[int n] =>\n n.ToString(\n CultureInfo.InvariantCulture);\n }\n\n [Fact]\n public void When_the_expected_object_has_a_property_not_available_on_the_subject_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n };\n\n var other = new\n {\n // ReSharper disable once StringLiteralTypo\n City = \"Rijswijk\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expectation has property City that the other object does not have*\");\n }\n\n [Fact]\n public void When_equally_named_properties_are_type_incompatible_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n Type = \"A\"\n };\n\n var other = new\n {\n Type = 36\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected property subject.Type to be 36, but found*\\\"A\\\"*\");\n }\n\n [Fact]\n public void When_multiple_properties_mismatch_it_should_report_all_of_them()\n {\n // Arrange\n var subject = new\n {\n Property1 = \"A\",\n Property2 = \"B\",\n SubType1 = new\n {\n SubProperty1 = \"C\",\n SubProperty2 = \"D\"\n }\n };\n\n var other = new\n {\n Property1 = \"1\",\n Property2 = \"2\",\n SubType1 = new\n {\n SubProperty1 = \"3\",\n SubProperty2 = \"D\"\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"\"\"\n *property subject.Property1*to be *\"A\" *\"1\"\n *property subject.Property2*to be *\"B\" *\"2\"\n *property subject.SubType1.SubProperty1*to be *\"C\" * \"3\"*\n \"\"\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void Including_all_declared_properties_excludes_all_fields()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"foo\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n // Act / Assert\n class1.Should().BeEquivalentTo(class2, opts => opts.IncludingAllDeclaredProperties());\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void Including_all_runtime_properties_excludes_all_fields()\n {\n // Arrange\n object class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n object class2 = new ClassWithSomeFieldsAndProperties\n {\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n // Act / Assert\n class1.Should().BeEquivalentTo(class2, opts => opts.IncludingAllRuntimeProperties());\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void Respecting_the_runtime_type_includes_both_properties_and_fields_included()\n {\n // Arrange\n object class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Property1 = \"sit\"\n };\n\n object class2 = new ClassWithSomeFieldsAndProperties();\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw().Which.Message.Should().Contain(\"Field1\").And.Contain(\"Property1\");\n }\n\n [Fact]\n public void A_nested_class_without_properties_inside_a_collection_is_fine()\n {\n // Arrange\n var sut = new List\n {\n new()\n {\n Name = \"theName\"\n }\n };\n\n // Act / Assert\n sut.Should().BeEquivalentTo(\n [\n new BaseClassPointingToClassWithoutProperties\n {\n Name = \"theName\"\n }\n ]);\n }\n\n#if NETCOREAPP3_0_OR_GREATER\n [Fact]\n public void Will_include_default_interface_properties_in_the_comparison()\n {\n var lista = new List\n {\n new Test { Name = \"Test\" }\n };\n\n List listb = new()\n {\n new Test { Name = \"Test\" }\n };\n\n lista.Should().BeEquivalentTo(listb);\n }\n\n private class Test : ITest\n {\n public string Name { get; set; }\n }\n\n private interface ITest\n {\n string Name { get; }\n\n int NameLength => Name.Length;\n }\n#endif\n\n internal class BaseClassPointingToClassWithoutProperties\n {\n [UsedImplicitly]\n public string Name { get; set; }\n\n [UsedImplicitly]\n public ClassWithoutProperty ClassWithoutProperty { get; } = new();\n }\n\n internal class ClassWithoutProperty;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IObjectInfo.cs", "using System;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents an object, dictionary key pair, collection item or member in an object graph.\n/// \npublic interface IObjectInfo\n{\n /// \n /// Gets the type of the object\n /// \n [Obsolete(\"Use CompileTimeType or RuntimeType instead\")]\n Type Type { get; }\n\n /// \n /// Gets the type of the parent, e.g. the type that declares a property or field.\n /// \n /// \n /// Is for the root object.\n /// \n [CanBeNull]\n Type ParentType { get; }\n\n /// \n /// Gets the full path from the root object until the current node separated by dots.\n /// \n string Path { get; set; }\n\n /// \n /// Gets the compile-time type of the current object. If the current object is not the root object and the type is not ,\n /// then it returns the same as the property does.\n /// \n Type CompileTimeType { get; }\n\n /// \n /// Gets the run-time type of the current object.\n /// \n Type RuntimeType { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Including.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Including\n {\n [Fact]\n public void When_specific_properties_have_been_specified_it_should_ignore_the_other_properties()\n {\n // Arrange\n var subject = new\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"Dennis\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(customer, options => options\n .Including(d => d.Age)\n .Including(d => d.Birthdate));\n }\n\n [Fact]\n public void A_member_included_by_path_is_described_in_the_failure_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\"\n };\n\n var customer = new\n {\n Name = \"Jack\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(customer, options => options\n .Including(d => d.Name));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Include*Name*\");\n }\n\n [Fact]\n public void A_member_included_by_predicate_is_described_in_the_failure_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\"\n };\n\n var customer = new\n {\n Name = \"Jack\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(customer, options => options\n .Including(ctx => ctx.Path == \"Name\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Include member when*Name*\");\n }\n\n [Fact]\n public void When_a_predicate_for_properties_to_include_has_been_specified_it_should_ignore_the_other_properties()\n {\n // Arrange\n var subject = new\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"Dennis\"\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(customer, options => options\n .Including(info => info.Path.EndsWith(\"Age\", StringComparison.Ordinal))\n .Including(info => info.Path.EndsWith(\"Birthdate\", StringComparison.Ordinal)));\n }\n\n [Fact]\n public void When_a_non_property_expression_is_provided_it_should_throw()\n {\n // Arrange\n var dto = new CustomerDto();\n\n // Act\n Action act = () => dto.Should().BeEquivalentTo(dto, options => options.Including(d => d.GetType()));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expression cannot be used to select a member.*\")\n .WithParameterName(\"expression\");\n }\n\n [Fact]\n public void When_including_a_property_it_should_exactly_match_the_property()\n {\n // Arrange\n var actual = new\n {\n DeclaredType = LocalOtherType.NonDefault,\n Type = LocalType.NonDefault\n };\n\n var expectation = new\n {\n DeclaredType = LocalOtherType.NonDefault\n };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation,\n config => config.Including(o => o.DeclaredType));\n }\n\n private enum LocalOtherType : byte\n {\n Default,\n NonDefault\n }\n\n private enum LocalType : byte\n {\n Default,\n NonDefault\n }\n\n public class CustomType\n {\n [UsedImplicitly]\n public string Name { get; set; }\n }\n\n [Fact]\n public void When_including_a_property_using_an_expression_it_should_evaluate_it_from_the_root()\n {\n // Arrange\n var list1 = new List\n {\n new()\n {\n Name = \"A\"\n },\n new()\n {\n Name = \"B\"\n }\n };\n\n var list2 = new List\n {\n new()\n {\n Name = \"C\"\n },\n new()\n {\n Name = \"D\"\n }\n };\n\n var objectA = new ClassA\n {\n ListOfCustomTypes = list1\n };\n\n var objectB = new ClassA\n {\n ListOfCustomTypes = list2\n };\n\n // Act\n Action act = () => objectA.Should().BeEquivalentTo(objectB, options => options.Including(x => x.ListOfCustomTypes));\n\n // Assert\n act.Should().Throw().WithMessage(\"*C*but*A*D*but*B*\");\n }\n\n private class ClassA\n {\n public List ListOfCustomTypes { get; set; }\n }\n\n [Fact]\n public void When_null_is_provided_as_property_expression_it_should_throw()\n {\n // Arrange\n var dto = new CustomerDto();\n\n // Act\n Action act =\n () => dto.Should().BeEquivalentTo(dto, options => options.Including(null));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected an expression, but found .*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_including_fields_it_should_succeed_if_just_the_included_field_match()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act =\n () =>\n class1.Should().BeEquivalentTo(class2, opts => opts.Including(o => o.Field1).Including(o => o.Field2));\n\n // Assert\n act.Should().NotThrow(\"the only selected fields have the same value\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_including_fields_it_should_fail_if_any_included_field_do_not_match()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act =\n () =>\n class1.Should().BeEquivalentTo(class2,\n opts => opts.Including(o => o.Field1).Including(o => o.Field2).Including(o => o.Field3));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected field class1.Field3*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_both_field_and_properties_are_configured_for_inclusion_both_should_be_included()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Property1 = \"sit\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties();\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.IncludingFields().IncludingProperties());\n\n // Assert\n act.Should().Throw().Which.Message.Should().Contain(\"Field1\").And.Contain(\"Property1\");\n }\n\n [Fact]\n public void Including_nested_objects_restores_the_default_behavior()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1\n {\n Text = \"Level1\",\n Level = new Level2\n {\n Text = \"Mismatch\"\n }\n }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto\n {\n Text = \"Level1\",\n Level = new Level2Dto\n {\n Text = \"Level2\"\n }\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected,\n options => options.WithoutRecursing().IncludingNestedObjects());\n\n // Assert\n act.Should().Throw().WithMessage(\"*Level.Level.Text*Mismatch*Level2*\");\n }\n\n#if NETCOREAPP3_0_OR_GREATER\n [Fact]\n public void Can_include_a_default_interface_property_using_an_expression()\n {\n // Arrange\n IHaveDefaultProperty subject = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Value\"\n };\n\n IHaveDefaultProperty expectation = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Another Value\"\n };\n\n // Act\n var act = () => subject.Should().BeEquivalentTo(expectation, x => x.Including(p => p.DefaultProperty));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property subject.DefaultProperty to be 13, but found 5.*\");\n }\n\n [Fact]\n public void Can_include_a_default_interface_property_using_a_name()\n {\n // Arrange\n IHaveDefaultProperty subject = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Value\"\n };\n\n IHaveDefaultProperty expectation = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Another Value\"\n };\n\n // Act\n var act = () => subject.Should().BeEquivalentTo(expectation,\n x => x.Including(p => p.Name.Contains(\"DefaultProperty\")));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property subject.DefaultProperty to be 13, but found 5.*\");\n }\n\n private class ClassReceivedDefaultInterfaceProperty : IHaveDefaultProperty\n {\n public string NormalProperty { get; set; }\n }\n\n private interface IHaveDefaultProperty\n {\n string NormalProperty { get; set; }\n\n int DefaultProperty => NormalProperty.Length;\n }\n#endif\n\n [Fact]\n public void An_anonymous_object_selects_correctly()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var expectation = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opts => opts.Including(o => new { o.Field1, o.Field2, o.Field3 }));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected field subject.Field3*\");\n }\n\n [Fact]\n public void An_anonymous_object_selects_nested_fields_correctly()\n {\n // Arrange\n var subject = new\n {\n Field = \"Lorem\",\n NestedField = new\n {\n FieldB = \"ipsum\"\n }\n };\n\n var expectation = new\n {\n FieldA = \"Lorem\",\n NestedField = new\n {\n FieldB = \"no ipsum\"\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation,\n opts => opts.Including(o => new { o.NestedField.FieldB }));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*subject.NestedField.FieldB*\");\n }\n\n [Fact]\n public void An_anonymous_object_in_combination_with_exclude_selects_nested_fields_correctly()\n {\n // Arrange\n var subject = new\n {\n FieldA = \"Lorem\",\n NestedField = new\n {\n FieldB = \"ipsum\",\n FieldC = \"ipsum2\",\n FieldD = \"ipsum3\",\n FieldE = \"ipsum4\",\n }\n };\n\n var expectation = new\n {\n FieldA = \"Lorem\",\n NestedField = new\n {\n FieldB = \"no ipsum\",\n FieldC = \"no ipsum2\",\n FieldD = \"no ipsum3\",\n FieldE = \"no ipsum4\",\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(o => new { o.NestedField })\n .Including(o => new { o.NestedField.FieldB }));\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should()\n .Match(\"*Expected*subject.NestedField.FieldB*\").And\n .NotMatch(\"*Expected*FieldC*FieldD*FieldE*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Interfaces.cs", "using System;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Interfaces\n {\n [Fact]\n public void When_an_interface_hierarchy_is_used_it_should_include_all_inherited_properties()\n {\n // Arrange\n ICar subject = new Car\n {\n VehicleId = 1,\n Wheels = 4\n };\n\n ICar expected = new Car\n {\n VehicleId = 99999,\n Wheels = 4\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Expected*VehicleId*99999*but*1*\");\n }\n\n [Fact]\n public void When_a_reference_to_an_interface_is_provided_it_should_only_include_those_properties()\n {\n // Arrange\n IVehicle expected = new Car\n {\n VehicleId = 1,\n Wheels = 4\n };\n\n IVehicle subject = new Car\n {\n VehicleId = 1,\n Wheels = 99999\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_reference_to_an_explicit_interface_impl_is_provided_it_should_only_include_those_properties()\n {\n // Arrange\n IVehicle expected = new ExplicitCar\n {\n Wheels = 4\n };\n\n IVehicle subject = new ExplicitCar\n {\n Wheels = 99999\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void Explicitly_implemented_subject_properties_are_ignored_if_a_normal_property_exists_with_the_same_name()\n {\n // Arrange\n IVehicle expected = new Vehicle\n {\n VehicleId = 1\n };\n\n IVehicle subject = new ExplicitVehicle\n {\n VehicleId = 2 // normal property\n };\n\n subject.VehicleId = 1; // explicitly implemented property\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Explicitly_implemented_read_only_subject_properties_are_ignored_if_a_normal_property_exists_with_the_same_name()\n {\n // Arrange\n IReadOnlyVehicle subject = new ExplicitReadOnlyVehicle(explicitValue: 1)\n {\n VehicleId = 2 // normal property\n };\n\n var expected = new Vehicle\n {\n VehicleId = 1\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Explicitly_implemented_subject_properties_are_ignored_if_only_fields_are_included()\n {\n // Arrange\n var expected = new VehicleWithField\n {\n VehicleId = 1 // A field named like a property\n };\n\n var subject = new ExplicitVehicle\n {\n VehicleId = 2 // A real property\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected, opt => opt\n .IncludingFields()\n .ExcludingProperties());\n\n // Assert\n action.Should().Throw().WithMessage(\"*field*VehicleId*other*\");\n }\n\n [Fact]\n public void Explicitly_implemented_subject_properties_are_ignored_if_only_fields_are_included_and_they_may_be_missing()\n {\n // Arrange\n var expected = new VehicleWithField\n {\n VehicleId = 1 // A field named like a property\n };\n\n var subject = new ExplicitVehicle\n {\n VehicleId = 2 // A real property\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt\n .IncludingFields()\n .ExcludingProperties()\n .ExcludingMissingMembers());\n }\n\n [Fact]\n public void Excluding_missing_members_does_not_affect_how_explicitly_implemented_subject_properties_are_dealt_with()\n {\n // Arrange\n IVehicle expected = new Vehicle\n {\n VehicleId = 1\n };\n\n IVehicle subject = new ExplicitVehicle\n {\n VehicleId = 2 // instance member\n };\n\n subject.VehicleId = 1; // interface member\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingMissingMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_respecting_declared_types_explicit_interface_member_on_interfaced_expectation_should_be_used()\n {\n // Arrange\n IVehicle expected = new ExplicitVehicle\n {\n VehicleId = 2 // instance member\n };\n\n expected.VehicleId = 1; // interface member\n\n IVehicle subject = new Vehicle\n {\n VehicleId = 1\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.PreferringDeclaredMemberTypes());\n }\n\n [Fact]\n public void When_respecting_runtime_types_explicit_interface_member_on_interfaced_subject_should_not_be_used()\n {\n // Arrange\n IVehicle expected = new Vehicle\n {\n VehicleId = 1\n };\n\n IVehicle subject = new ExplicitVehicle\n {\n VehicleId = 2 // instance member\n };\n\n subject.VehicleId = 1; // interface member\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected, opt => opt.PreferringRuntimeMemberTypes());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_respecting_runtime_types_explicit_interface_member_on_interfaced_expectation_should_not_be_used()\n {\n // Arrange\n IVehicle expected = new ExplicitVehicle\n {\n VehicleId = 2 // instance member\n };\n\n expected.VehicleId = 1; // interface member\n\n IVehicle subject = new Vehicle\n {\n VehicleId = 1\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected, opt => opt.PreferringRuntimeMemberTypes());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_respecting_declared_types_explicit_interface_member_on_expectation_should_not_be_used()\n {\n // Arrange\n var expected = new ExplicitVehicle\n {\n VehicleId = 2\n };\n\n ((IVehicle)expected).VehicleId = 1;\n\n var subject = new Vehicle\n {\n VehicleId = 1\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Can_find_explicitly_implemented_property_on_the_subject()\n {\n // Arrange\n IPerson person = new Person();\n person.Name = \"Bob\";\n\n // Act / Assert\n person.Should().BeEquivalentTo(new { Name = \"Bob\" });\n }\n\n [Fact]\n public void Can_exclude_explicitly_implemented_properties()\n {\n // Arrange\n var subject = new Person\n {\n NormalProperty = \"Normal\",\n };\n\n ((IPerson)subject).Name = \"Bob\";\n\n var expectation = new Person\n {\n NormalProperty = \"Normal\",\n };\n\n ((IPerson)expectation).Name = \"Jim\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.ExcludingExplicitlyImplementedProperties());\n }\n\n private interface IPerson\n {\n string Name { get; set; }\n }\n\n private class Person : IPerson\n {\n [UsedImplicitly]\n public string NormalProperty { get; set; }\n\n string IPerson.Name { get; set; }\n }\n\n [Fact]\n public void Excluding_an_interface_property_through_inheritance_should_work()\n {\n // Arrange\n IInterfaceWithTwoProperties[] actual =\n [\n new DerivedClassImplementingInterface\n {\n Value1 = 1,\n Value2 = 2\n }\n ];\n\n IInterfaceWithTwoProperties[] expected =\n [\n new DerivedClassImplementingInterface\n {\n Value1 = 999,\n Value2 = 2\n }\n ];\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, options => options\n .Excluding(a => a.Value1)\n .PreferringRuntimeMemberTypes());\n }\n\n [Fact]\n public void Including_an_interface_property_through_inheritance_should_work()\n {\n // Arrange\n IInterfaceWithTwoProperties[] actual =\n [\n new DerivedClassImplementingInterface\n {\n Value1 = 1,\n Value2 = 2\n }\n ];\n\n IInterfaceWithTwoProperties[] expected =\n [\n new DerivedClassImplementingInterface\n {\n Value1 = 999,\n Value2 = 2\n }\n ];\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, options => options\n .Including(a => a.Value2)\n .PreferringRuntimeMemberTypes());\n }\n\n public interface IInterfaceWithTwoProperties\n {\n int Value1 { get; set; }\n\n int Value2 { get; set; }\n }\n\n public class BaseProvidingSamePropertiesAsInterface\n {\n public int Value1 { get; set; }\n\n public int Value2 { get; set; }\n }\n\n public class DerivedClassImplementingInterface : BaseProvidingSamePropertiesAsInterface, IInterfaceWithTwoProperties;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Equivalency/IMemberInfo.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Equivalency;\n\n/// \n/// Represents a field or property in an object graph.\n/// \npublic interface IMemberInfo\n{\n /// \n /// Gets the name of the current member.\n /// \n string Name { get; }\n\n /// \n /// Gets the type of this member.\n /// \n Type Type { get; }\n\n /// \n /// Gets the type that declares the current member.\n /// \n Type DeclaringType { get; }\n\n /// \n /// Gets the full path from the root object until and including the current node separated by dots.\n /// \n string Path { get; set; }\n\n /// \n /// Gets the access modifier for the getter of this member.\n /// \n CSharpAccessModifier GetterAccessibility { get; }\n\n /// \n /// Gets the access modifier for the setter of this member.\n /// \n CSharpAccessModifier SetterAccessibility { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/TestTypes.cs", "using System;\nusing System.Collections.Generic;\n\n// ReSharper disable NotAccessedField.Global\n// ReSharper disable NotAccessedField.Local\n// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global\n// ReSharper disable UnusedMember.Global\n// ReSharper disable AutoPropertyCanBeMadeGetOnly.Local\n#pragma warning disable SA1649\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic enum EnumULong : ulong\n{\n Int64Max = long.MaxValue,\n UInt64LessOne = ulong.MaxValue - 1,\n UInt64Max = ulong.MaxValue\n}\n\npublic enum EnumLong : long\n{\n Int64Max = long.MaxValue,\n Int64LessOne = long.MaxValue - 1\n}\n\n#region Test Classes\n\npublic class ClassOne\n{\n public ClassTwo RefOne { get; set; } = new();\n\n public int ValOne { get; set; } = 1;\n}\n\npublic class ClassTwo\n{\n public int ValTwo { get; set; } = 3;\n}\n\npublic class ClassWithWriteOnlyProperty : IHaveWriteOnlyProperty\n{\n private int writeOnlyPropertyValue;\n\n public int WriteOnlyProperty\n {\n set => writeOnlyPropertyValue = value;\n }\n\n public string SomeOtherProperty { get; set; }\n}\n\npublic interface IHaveWriteOnlyProperty\n{\n int WriteOnlyProperty { set; }\n}\n\ninternal enum EnumOne\n{\n One = 0,\n Two = 3\n}\n\ninternal enum EnumCharOne\n{\n A = 'A',\n B = 'B'\n}\n\ninternal enum EnumCharTwo\n{\n A = 'Z',\n ValueB = 'B'\n}\n\ninternal enum EnumTwo\n{\n One = 0,\n Two = 3\n}\n\ninternal enum EnumThree\n{\n ValueZero = 0,\n Two = 3\n}\n\ninternal enum EnumFour\n{\n Three = 3\n}\n\ninternal class ClassWithEnumCharOne\n{\n public EnumCharOne Enum { get; set; }\n}\n\ninternal class ClassWithEnumCharTwo\n{\n public EnumCharTwo Enum { get; set; }\n}\n\ninternal class ClassWithEnumOne\n{\n public EnumOne Enum { get; set; }\n}\n\ninternal class ClassWithEnumTwo\n{\n public EnumTwo Enum { get; set; }\n}\n\ninternal class ClassWithEnumThree\n{\n public EnumThree Enum { get; set; }\n}\n\ninternal class ClassWithEnumFour\n{\n public EnumFour Enum { get; set; }\n}\n\ninternal class ClassWithNoMembers;\n\ninternal class ClassWithOnlyAField\n{\n public int Value;\n}\n\ninternal class ClassWithAPrivateField : ClassWithOnlyAField\n{\n private readonly int value;\n\n public ClassWithAPrivateField(int value)\n {\n this.value = value;\n }\n}\n\ninternal class ClassWithOnlyAProperty\n{\n public int Value { get; set; }\n}\n\ninternal struct StructWithNoMembers;\n\ninternal class ClassWithSomeFieldsAndProperties\n{\n public string Field1;\n\n public string Field2;\n\n public string Field3;\n\n public string Property1 { get; set; }\n\n public string Property2 { get; set; }\n\n public string Property3 { get; set; }\n}\n\ninternal class ClassWithCctor\n{\n // ReSharper disable once EmptyConstructor\n static ClassWithCctor()\n {\n }\n}\n\ninternal class ClassWithCctorAndNonDefaultConstructor\n{\n // ReSharper disable once EmptyConstructor\n static ClassWithCctorAndNonDefaultConstructor() { }\n\n public ClassWithCctorAndNonDefaultConstructor(int _) { }\n}\n\ninternal class MyCompanyLogo\n{\n public string Url { get; set; }\n\n public MyCompany Company { get; set; }\n\n public MyUser CreatedBy { get; set; }\n}\n\ninternal class MyUser\n{\n public string Name { get; set; }\n\n public MyCompany Company { get; set; }\n}\n\ninternal class MyCompany\n{\n public string Name { get; set; }\n\n public MyCompanyLogo Logo { get; set; }\n\n public List Users { get; set; }\n}\n\npublic class Customer : Entity\n{\n private string PrivateProperty { get; set; }\n\n protected string ProtectedProperty { get; set; }\n\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n\n public long Id { get; set; }\n\n public void SetProtected(string value)\n {\n ProtectedProperty = value;\n }\n\n public Customer()\n {\n }\n\n public Customer(string privateProperty)\n {\n PrivateProperty = privateProperty;\n }\n}\n\npublic class Entity\n{\n internal long Version { get; set; }\n}\n\npublic class CustomerDto\n{\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n}\n\npublic class CustomerType\n{\n public CustomerType(string code)\n {\n Code = code;\n }\n\n public string Code { get; }\n\n public override bool Equals(object obj)\n {\n return obj is CustomerType other && Code == other.Code;\n }\n\n public override int GetHashCode()\n {\n return Code?.GetHashCode() ?? 0;\n }\n\n public static bool operator ==(CustomerType a, CustomerType b)\n {\n if (ReferenceEquals(a, b))\n {\n return true;\n }\n\n if (a is null || b is null)\n {\n return false;\n }\n\n return a.Code == b.Code;\n }\n\n public static bool operator !=(CustomerType a, CustomerType b)\n {\n return !(a == b);\n }\n}\n\npublic class DerivedCustomerType : CustomerType\n{\n public string DerivedInfo { get; set; }\n\n public DerivedCustomerType(string code)\n : base(code)\n {\n }\n}\n\npublic class CustomConvertible : IConvertible\n{\n private readonly string convertedStringValue;\n\n public CustomConvertible(string convertedStringValue)\n {\n this.convertedStringValue = convertedStringValue;\n }\n\n public TypeCode GetTypeCode()\n {\n throw new InvalidCastException();\n }\n\n public bool ToBoolean(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public char ToChar(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public sbyte ToSByte(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public byte ToByte(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public short ToInt16(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public ushort ToUInt16(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public int ToInt32(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public uint ToUInt32(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public long ToInt64(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public ulong ToUInt64(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public float ToSingle(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public double ToDouble(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public decimal ToDecimal(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public DateTime ToDateTime(IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n\n public string ToString(IFormatProvider provider)\n {\n return convertedStringValue;\n }\n\n public object ToType(Type conversionType, IFormatProvider provider)\n {\n throw new InvalidCastException();\n }\n}\n\npublic abstract class Base\n{\n public abstract string AbstractProperty { get; }\n\n public virtual string VirtualProperty => \"Foo\";\n\n public virtual string NonExcludedBaseProperty => \"Foo\";\n}\n\npublic class Derived : Base\n{\n public string DerivedProperty1 { get; set; }\n\n public string DerivedProperty2 { get; set; }\n\n public override string AbstractProperty => $\"{DerivedProperty1} {DerivedProperty2}\";\n\n public override string VirtualProperty => \"Bar\";\n\n public override string NonExcludedBaseProperty => \"Bar\";\n\n public virtual string NonExcludedDerivedProperty => \"Foo\";\n}\n\n#endregion\n\n#region Nested classes for comparison\n\npublic class ClassWithAllAccessModifiersForMembers\n{\n public string PublicField;\n protected string protectedField;\n internal string InternalField;\n protected internal string ProtectedInternalField;\n private readonly string privateField;\n private protected string privateProtectedField;\n\n public string PublicProperty { get; set; }\n\n public string ReadOnlyProperty { get; private set; }\n\n public string WriteOnlyProperty { private get; set; }\n\n protected string ProtectedProperty { get; set; }\n\n internal string InternalProperty { get; set; }\n\n protected internal string ProtectedInternalProperty { get; set; }\n\n private string PrivateProperty { get; set; }\n\n private protected string PrivateProtectedProperty { get; set; }\n\n public ClassWithAllAccessModifiersForMembers(string publicValue, string protectedValue, string internalValue,\n string protectedInternalValue, string privateValue, string privateProtectedValue)\n {\n PublicField = publicValue;\n protectedField = protectedValue;\n InternalField = internalValue;\n ProtectedInternalField = protectedInternalValue;\n privateField = privateValue;\n privateProtectedField = privateProtectedValue;\n\n PublicProperty = publicValue;\n ReadOnlyProperty = privateValue;\n WriteOnlyProperty = privateValue;\n ProtectedProperty = protectedValue;\n InternalProperty = internalValue;\n ProtectedInternalProperty = protectedInternalValue;\n PrivateProperty = privateValue;\n PrivateProtectedProperty = privateProtectedValue;\n }\n}\n\npublic class ClassWithValueSemanticsOnSingleProperty\n{\n public string Key { get; set; }\n\n public string NestedProperty { get; set; }\n\n protected bool Equals(ClassWithValueSemanticsOnSingleProperty other)\n {\n return Key == other.Key;\n }\n\n public override bool Equals(object obj)\n {\n if (obj is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n if (obj.GetType() != GetType())\n {\n return false;\n }\n\n return Equals((ClassWithValueSemanticsOnSingleProperty)obj);\n }\n\n public override int GetHashCode()\n {\n return Key.GetHashCode();\n }\n}\n\npublic class Root\n{\n public string Text { get; set; }\n\n public Level1 Level { get; set; }\n}\n\npublic class Level1\n{\n public string Text { get; set; }\n\n public Level2 Level { get; set; }\n}\n\npublic class Level2\n{\n public string Text { get; set; }\n}\n\npublic class RootDto\n{\n public string Text { get; set; }\n\n public Level1Dto Level { get; set; }\n}\n\npublic class Level1Dto\n{\n public string Text { get; set; }\n\n public Level2Dto Level { get; set; }\n}\n\npublic class Level2Dto\n{\n public string Text { get; set; }\n}\n\npublic class CyclicRoot\n{\n public string Text { get; set; }\n\n public CyclicLevel1 Level { get; set; }\n}\n\npublic class CyclicRootWithValueObject\n{\n public ValueObject Value { get; set; }\n\n public CyclicLevelWithValueObject Level { get; set; }\n}\n\npublic class ValueObject\n{\n public ValueObject(string value)\n {\n Value = value;\n }\n\n public string Value { get; }\n\n public override bool Equals(object obj)\n {\n return ((ValueObject)obj).Value == Value;\n }\n\n public override int GetHashCode()\n {\n return Value.GetHashCode();\n }\n}\n\npublic class CyclicLevel1\n{\n public string Text { get; set; }\n\n public CyclicRoot Root { get; set; }\n}\n\npublic class CyclicLevelWithValueObject\n{\n public ValueObject Value { get; set; }\n\n public CyclicRootWithValueObject Root { get; set; }\n}\n\npublic class CyclicRootDto\n{\n public string Text { get; set; }\n\n public CyclicLevel1Dto Level { get; set; }\n}\n\npublic class CyclicLevel1Dto\n{\n public string Text { get; set; }\n\n public CyclicRootDto Root { get; set; }\n}\n\n#endregion\n\n#region Interfaces for verifying inheritance of properties\n\npublic class Car : Vehicle, ICar\n{\n public int Wheels { get; set; }\n}\n\npublic class ExplicitCar : ExplicitVehicle, ICar\n{\n public int Wheels { get; set; }\n}\n\npublic class Vehicle : IVehicle\n{\n public int VehicleId { get; set; }\n}\n\npublic class VehicleWithField\n{\n public int VehicleId;\n}\n\npublic class ExplicitVehicle : IVehicle\n{\n int IVehicle.VehicleId { get; set; }\n\n public int VehicleId { get; set; }\n}\n\npublic interface IReadOnlyVehicle\n{\n int VehicleId { get; }\n}\n\npublic class ExplicitReadOnlyVehicle : IReadOnlyVehicle\n{\n private readonly int explicitValue;\n\n public ExplicitReadOnlyVehicle(int explicitValue)\n {\n this.explicitValue = explicitValue;\n }\n\n int IReadOnlyVehicle.VehicleId => explicitValue;\n\n public int VehicleId { get; set; }\n}\n\npublic interface ICar : IVehicle\n{\n int Wheels { get; set; }\n}\n\npublic interface IVehicle\n{\n int VehicleId { get; set; }\n}\n\npublic class SomeDto\n{\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n}\n\n#endregion\n\n#pragma warning restore SA1649\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/AssertionScopeSpecs.ScopedFormatters.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\npublic partial class AssertionScopeSpecs\n{\n [Fact]\n public void A_scoped_formatter_will_be_used()\n {\n // Arrange\n Action act = () =>\n {\n // Act\n using var outerScope = new AssertionScope();\n\n var outerFormatter = new OuterFormatter();\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n 1.Should().Be(2);\n };\n\n // Assert\n act.Should().Throw().WithMessage($\"*{nameof(OuterFormatter)}*\");\n }\n\n [Fact]\n public void A_scoped_formatter_is_not_available_after_disposal()\n {\n // Arrange\n Action act = () =>\n {\n // Act\n using var outerScope = new AssertionScope();\n\n var outerFormatter = new OuterFormatter();\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n\n // ReSharper disable once DisposeOnUsingVariable\n outerScope.Dispose();\n\n 1.Should().Be(2);\n };\n\n // Assert\n act.Should().Throw().Which.Message.Should().NotMatch($\"*{nameof(OuterFormatter)}*\");\n }\n\n [Fact]\n public void Removing_a_formatter_from_scope_works()\n {\n // Arrange\n using var outerScope = new AssertionScope();\n var outerFormatter = new OuterFormatter();\n\n // Act 1\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n 1.Should().Be(2);\n\n // Assert 1\n outerScope.Discard().Should().ContainSingle().Which.Should().Match($\"*{nameof(OuterFormatter)}*\");\n\n // Act 2\n outerScope.FormattingOptions.RemoveFormatter(outerFormatter);\n 1.Should().Be(2);\n\n // Assert2\n outerScope.Discard().Should().ContainSingle().Which.Should().NotMatch($\"*{nameof(OuterFormatter)}*\");\n outerScope.FormattingOptions.ScopedFormatters.Should().BeEmpty();\n }\n\n [Fact]\n public void Add_a_formatter_to_nested_scope_adds_and_removes_correctly_on_dispose()\n {\n // Arrange\n using var outerScope = new AssertionScope(\"outside\");\n\n var outerFormatter = new OuterFormatter();\n var innerFormatter = new InnerFormatter();\n\n // Act 1\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n 1.Should().Be(2);\n\n // Assert 1 / Test if outer scope contains OuterFormatter\n outerScope.Discard().Should().ContainSingle().Which.Should().Match($\"*{nameof(OuterFormatter)}*\");\n\n using (var innerScope = new AssertionScope(\"inside\"))\n {\n // Act 2\n innerScope.FormattingOptions.AddFormatter(innerFormatter);\n MyEnum.Value1.Should().Be(MyEnum.Value2); // InnerFormatter\n 1.Should().Be(2); // OuterFormatter\n\n // Assert 2\n innerScope.Discard().Should()\n .SatisfyRespectively(\n failure1 => failure1.Should().Match($\"*{nameof(InnerFormatter)}*\"),\n failure2 => failure2.Should().Match($\"*{nameof(OuterFormatter)}*\"));\n }\n\n // Act 3\n 1.Should().Be(2);\n\n // Assert 3\n outerScope.Discard().Should().ContainSingle().Which.Should().Match($\"*{nameof(OuterFormatter)}*\");\n }\n\n [Fact]\n public void Removing_a_formatter_from_outer_scope_inside_nested_scope_leaves_outer_scope_untouched()\n {\n // Arrange\n using var outerScope = new AssertionScope();\n var outerFormatter = new OuterFormatter();\n var innerFormatter = new InnerFormatter();\n\n // Act\n outerScope.FormattingOptions.AddFormatter(outerFormatter);\n\n using var innerScope = new AssertionScope();\n innerScope.FormattingOptions.AddFormatter(innerFormatter);\n innerScope.FormattingOptions.RemoveFormatter(outerFormatter);\n 1.Should().Be(2);\n MyEnum.Value1.Should().Be(MyEnum.Value2);\n\n // Assert\n innerScope.Discard().Should().SatisfyRespectively(\n failure1 => failure1.Should().Match(\"*2, but found 1*\"),\n failure2 => failure2.Should().NotMatch($\"*{nameof(OuterFormatter)}*\")\n .And.Match($\"*{nameof(InnerFormatter)}*\"));\n\n outerScope.FormattingOptions.ScopedFormatters.Should().ContainSingle()\n .Which.Should().Be(outerFormatter);\n }\n\n private class OuterFormatter : IValueFormatter\n {\n public bool CanHandle(object value) => value is int;\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(nameof(OuterFormatter));\n }\n }\n\n private class InnerFormatter : IValueFormatter\n {\n public bool CanHandle(object value) => value is MyEnum;\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(nameof(InnerFormatter));\n }\n }\n\n private enum MyEnum\n {\n Value1,\n Value2,\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/DateTimePropertiesSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class DateTimePropertiesSpecs\n{\n [Fact]\n public void When_two_properties_are_datetime_and_both_are_nullable_and_both_are_null_it_should_succeed()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)null };\n\n var other =\n new { Time = (DateTime?)null };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void When_two_properties_are_datetime_and_both_are_nullable_and_are_equal_it_should_succeed()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void\n When_two_properties_are_datetime_and_both_are_nullable_and_expectation_is_null_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = (DateTime?)null };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Time to be , but found <2013-12-09 15:58:00>.*\");\n }\n\n [Fact]\n public void\n When_two_properties_are_datetime_and_both_are_nullable_and_subject_is_null_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)null };\n\n var other =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Time*to be <2013-12-09 15:58:00>, but found .*\");\n }\n\n [Fact]\n public void When_two_properties_are_datetime_and_expectation_is_nullable_and_are_equal_it_should_succeed()\n {\n // Arrange\n var subject =\n new { Time = new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void\n When_two_properties_are_datetime_and_expectation_is_nullable_and_expectation_is_null_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject =\n new { Time = new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = (DateTime?)null };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Time*to be , but found <2013-12-09 15:58:00>.*\");\n }\n\n [Fact]\n public void When_two_properties_are_datetime_and_subject_is_nullable_and_are_equal_it_should_succeed()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)new DateTime(2013, 12, 9, 15, 58, 0) };\n\n var other =\n new { Time = new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(other);\n }\n\n [Fact]\n public void\n When_two_properties_are_datetime_and_subject_is_nullable_and_subject_is_null_it_should_throw_and_state_the_difference()\n {\n // Arrange\n var subject =\n new { Time = (DateTime?)null };\n\n var other =\n new { Time = new DateTime(2013, 12, 9, 15, 58, 0) };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Time*to be <2013-12-09 15:58:00>, but found .*\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/MethodInfoFormatter.cs", "using System.Reflection;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class MethodInfoFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is MethodInfo;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var method = (MethodInfo)value;\n if (method.IsSpecialName && method.Name == \"op_Implicit\")\n {\n FormatOperator(method, \"implicit\", formattedGraph, formatChild);\n }\n else if (method.IsSpecialName && method.Name == \"op_Explicit\")\n {\n FormatOperator(method, \"explicit\", formattedGraph, formatChild);\n }\n else\n {\n formatChild(\"type\", method!.DeclaringType.AsFormattableShortType(), formattedGraph);\n formattedGraph.AddFragment($\".{method.Name}\");\n }\n }\n\n private static void FormatOperator(MethodInfo method, string operatorType, FormattedObjectGraph formattedGraph, FormatChild formatChild)\n {\n formattedGraph.AddFragment($\"{operatorType} operator \");\n formatChild(\"type\", method.ReturnType.AsFormattableShortType(), formattedGraph);\n formattedGraph.AddFragment(\"(\");\n formatChild(\"type\", method.GetParameters()[0].ParameterType.AsFormattableShortType(), formattedGraph);\n formattedGraph.AddFragment(\")\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/MultidimensionalArrayFormatter.cs", "using System;\nusing System.Collections;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class MultidimensionalArrayFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is Array { Rank: >= 2 };\n }\n\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\", Justification = \"Required refactoring\")]\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var arr = (Array)value;\n\n if (arr.Length == 0)\n {\n formattedGraph.AddFragment(\"{empty}\");\n return;\n }\n\n int[] dimensionIndices = Enumerable.Range(0, arr.Rank).Select(dimension => arr.GetLowerBound(dimension)).ToArray();\n\n int currentLoopIndex = 0;\n\n // ReSharper disable once NotDisposedResource (false positive)\n // See https://youtrack.jetbrains.com/issue/QD-8114/It-is-not-a-problem-Local-variable-enumerator-is-never-disposed\n IEnumerator enumerator = arr.GetEnumerator();\n\n // Emulate n-ary loop\n while (currentLoopIndex >= 0)\n {\n int currentDimensionIndex = dimensionIndices[currentLoopIndex];\n\n if (IsFirstIteration(arr, currentDimensionIndex, currentLoopIndex))\n {\n formattedGraph.AddFragment(\"{\");\n }\n\n if (IsInnerMostLoop(arr, currentLoopIndex))\n {\n enumerator.MoveNext();\n formatChild(string.Join(\"-\", dimensionIndices), enumerator.Current, formattedGraph);\n\n if (!IsLastIteration(arr, currentDimensionIndex, currentLoopIndex))\n {\n formattedGraph.AddFragment(\", \");\n }\n\n ++dimensionIndices[currentLoopIndex];\n }\n else\n {\n ++currentLoopIndex;\n continue;\n }\n\n while (IsLastIteration(arr, currentDimensionIndex, currentLoopIndex))\n {\n formattedGraph.AddFragment(\"}\");\n\n // Reset current loop's variable to start value ...and move to outer loop\n dimensionIndices[currentLoopIndex] = arr.GetLowerBound(currentLoopIndex);\n --currentLoopIndex;\n\n if (currentLoopIndex < 0)\n {\n break;\n }\n\n currentDimensionIndex = dimensionIndices[currentLoopIndex];\n\n if (!IsLastIteration(arr, currentDimensionIndex, currentLoopIndex))\n {\n formattedGraph.AddFragment(\", \");\n }\n\n ++dimensionIndices[currentLoopIndex];\n }\n }\n }\n\n private static bool IsFirstIteration(Array arr, int index, int dimension)\n {\n return index == arr.GetLowerBound(dimension);\n }\n\n private static bool IsInnerMostLoop(Array arr, int index)\n {\n return index == (arr.Rank - 1);\n }\n\n private static bool IsLastIteration(Array arr, int index, int dimension)\n {\n return index >= arr.GetUpperBound(dimension);\n }\n}\n"], ["/AwesomeAssertions/Build/CustomNpmTasks.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Nuke.Common;\nusing Nuke.Common.IO;\nusing Nuke.Common.Tooling;\nusing Nuke.Common.Utilities;\nusing Nuke.Common.Utilities.Collections;\nusing static Serilog.Log;\n\npublic static class CustomNpmTasks\n{\n static AbsolutePath RootDirectory;\n static AbsolutePath TempDir;\n static AbsolutePath NodeDir;\n static AbsolutePath NodeDirPerOs;\n static AbsolutePath WorkingDirectory;\n\n static IReadOnlyDictionary NpmEnvironmentVariables;\n\n static Tool Npm;\n\n static string Version;\n\n static Func GetCachedNodeModules;\n\n public static bool HasCachedNodeModules;\n\n public static void Initialize(AbsolutePath root)\n {\n RootDirectory = root;\n NodeDir = RootDirectory / \".nuke\" / \"temp\";\n\n Version = (RootDirectory / \"NodeVersion\").ReadAllText().Trim();\n GetCachedNodeModules = os => NodeDir.GlobFiles($\"node*{Version}-{os}*/**/node*\", $\"node*{Version}-{os}*/**/npm*\").Count != 0;\n }\n\n public static void NpmFetchRuntime()\n {\n DownloadNodeArchive().ExtractNodeArchive();\n\n LinkTools();\n }\n\n static AbsolutePath DownloadNodeArchive()\n {\n AbsolutePath archive = NodeDir;\n string os = null;\n string archiveType = null;\n\n if (EnvironmentInfo.IsWin)\n {\n os = \"win\";\n archiveType = \".zip\";\n }\n else if (EnvironmentInfo.IsOsx)\n {\n os = \"darwin\";\n archiveType = \".tar.gz\";\n }\n else if (EnvironmentInfo.IsLinux)\n {\n os = \"linux\";\n archiveType = \".tar.xz\";\n }\n\n os.NotNull();\n archiveType.NotNull();\n\n string architecture =\n EnvironmentInfo.IsArm64 ? \"arm64\" :\n EnvironmentInfo.Is64Bit ? \"x64\" : \"x86\";\n\n os = $\"{os}-{architecture}\";\n\n HasCachedNodeModules = GetCachedNodeModules(os);\n\n if (!HasCachedNodeModules)\n {\n Information($\"Fetching node.js ({Version}) for {os}\");\n\n string downloadUrl = $\"https://nodejs.org/dist/v{Version}/node-v{Version}-{os}{archiveType}\";\n archive = NodeDir / $\"node{archiveType}\";\n\n HttpTasks.HttpDownloadFile(downloadUrl, archive, clientConfigurator: c =>\n {\n c.Timeout = TimeSpan.FromSeconds(50);\n\n return c;\n });\n }\n else\n {\n Information(\"Skipping archive download due to cache\");\n }\n\n NodeDirPerOs = NodeDir / $\"node-v{Version}-{os}\";\n WorkingDirectory = NodeDirPerOs;\n\n return archive;\n }\n\n static void ExtractNodeArchive(this AbsolutePath archive)\n {\n if (HasCachedNodeModules)\n {\n Information(\"Skipping archive extraction due to cache\");\n\n return;\n }\n\n Information($\"Extracting node.js binary archive ({archive}) to {NodeDir}\");\n\n if (EnvironmentInfo.IsWin)\n {\n archive.UnZipTo(NodeDir);\n }\n else if (EnvironmentInfo.IsOsx)\n {\n archive.UnTarGZipTo(NodeDir);\n }\n else if (EnvironmentInfo.IsLinux)\n {\n archive.UnTarXzTo(NodeDir);\n }\n }\n\n static void LinkTools()\n {\n AbsolutePath npmExecutable;\n\n if (EnvironmentInfo.IsWin)\n {\n npmExecutable = NodeDirPerOs / \"npm.cmd\";\n }\n else\n {\n WorkingDirectory /= \"bin\";\n\n var nodeExecutable = WorkingDirectory / \"node\";\n var npmNodeModules = NodeDirPerOs / \"lib\" / \"node_modules\";\n npmExecutable = npmNodeModules / \"npm\" / \"bin\" / \"npm\";\n\n Information($\"Set execution permissions for {nodeExecutable}...\");\n nodeExecutable.SetExecutable();\n\n Information($\"Set execution permissions for {npmExecutable}...\");\n npmExecutable.SetExecutable();\n\n Information(\"Linking binaries...\");\n npmExecutable.AddUnixSymlink(WorkingDirectory / \"npm\", force: true);\n npmNodeModules.AddUnixSymlink(WorkingDirectory / \"node_modules\", force: true);\n\n npmExecutable = WorkingDirectory / \"npm\";\n }\n\n Information(\"Resolve tool npm...\");\n npmExecutable.NotNull();\n Npm = ToolResolver.GetTool(npmExecutable);\n\n NpmConfig(\"set update-notifier false\");\n NpmVersion();\n\n SetEnvVars();\n }\n\n static void SetEnvVars()\n {\n NpmEnvironmentVariables = EnvironmentInfo.Variables\n .ToDictionary(x => x.Key, x => x.Value)\n .SetKeyValue(\"path\", WorkingDirectory)\n .AsReadOnly();\n }\n\n public static void NpmInstall(bool silent = false, string workingDirectory = null)\n {\n Npm($\"install {(silent ? \"--silent\" : \"\")}\",\n workingDirectory,\n logger: NpmLogger);\n }\n\n public static void NpmRun(string args, bool silent = false)\n {\n Npm($\"run {(silent ? \"--silent\" : \"\")} {args}\".TrimMatchingDoubleQuotes(),\n environmentVariables: NpmEnvironmentVariables,\n logger: NpmLogger);\n }\n\n static void NpmVersion()\n {\n Npm(\"--version\",\n workingDirectory: WorkingDirectory,\n logInvocation: false,\n logger: NpmLogger,\n environmentVariables: NpmEnvironmentVariables);\n }\n\n static void NpmConfig(string args)\n {\n Npm($\"config {args}\".TrimMatchingDoubleQuotes(),\n workingDirectory: WorkingDirectory,\n logInvocation: false,\n logOutput: false,\n logger: NpmLogger,\n environmentVariables: NpmEnvironmentVariables);\n }\n\n static readonly Action NpmLogger = (outputType, msg) =>\n {\n if (EnvironmentInfo.IsWsl && msg.Contains(\"wslpath\"))\n return;\n\n if (outputType == OutputType.Err)\n {\n Error(msg);\n\n return;\n }\n\n Information(msg);\n };\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/FunctionAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that a synchronous function yields the expected result.\n/// \n[DebuggerNonUserCode]\npublic class FunctionAssertions : DelegateAssertions, FunctionAssertions>\n{\n private readonly AssertionChain assertionChain;\n\n public FunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain)\n : base(subject, extractor, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n public FunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain, IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n protected override void InvokeSubject()\n {\n Subject();\n }\n\n protected override string Identifier => \"function\";\n\n /// \n /// Asserts that the current does not throw any exception.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint, T> NotThrow([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n T result = default;\n\n if (assertionChain.Succeeded)\n {\n try\n {\n result = Subject!();\n }\n catch (Exception exception)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exception{reason}, but found {0}.\", exception);\n\n result = default;\n }\n }\n\n return new AndWhichConstraint, T>(this, result, assertionChain, \".Result\");\n }\n\n /// \n /// Asserts that the current stops throwing any exception\n /// after a specified amount of time.\n /// \n /// \n /// The is invoked. If it raises an exception,\n /// the invocation is repeated until it either stops raising any exceptions\n /// or the specified wait time is exceeded.\n /// \n /// \n /// The time after which the should have stopped throwing any exception.\n /// \n /// \n /// The time between subsequent invocations of the .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// or are negative.\n public AndWhichConstraint, T> NotThrowAfter(TimeSpan waitTime, TimeSpan pollInterval,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw any exceptions after {0}{reason}, but found .\", waitTime);\n\n T result = default;\n\n if (assertionChain.Succeeded)\n {\n result = NotThrowAfter(Subject, Clock, waitTime, pollInterval, because, becauseArgs);\n }\n\n return new AndWhichConstraint, T>(this, result, assertionChain, \".Result\");\n }\n\n internal TResult NotThrowAfter(Func subject, IClock clock, TimeSpan waitTime, TimeSpan pollInterval,\n string because, object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(waitTime);\n Guard.ThrowIfArgumentIsNegative(pollInterval);\n\n TimeSpan? invocationEndTime = null;\n Exception exception = null;\n ITimer timer = clock.StartTimer();\n\n while (invocationEndTime is null || invocationEndTime < waitTime)\n {\n try\n {\n return subject();\n }\n catch (Exception ex)\n {\n exception = ex;\n }\n\n clock.Delay(pollInterval);\n invocationEndTime = timer.Elapsed;\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exceptions after {0}{reason}, but found {1}.\", waitTime, exception);\n\n return default;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/ReferenceTypeAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a reference type object is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic abstract class ReferenceTypeAssertions\n where TAssertions : ReferenceTypeAssertions\n{\n protected ReferenceTypeAssertions(TSubject subject, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = subject;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public TSubject Subject { get; }\n\n /// \n /// Asserts that the current object has not been initialized yet.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be {reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current object has been initialized.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} not to be {reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object reference refers to the exact same object as another object reference.\n /// \n /// The expected object\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSameAs(TSubject expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(ReferenceEquals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to refer to {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an object reference refers to a different object than another object reference refers to.\n /// \n /// The unexpected object\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSameAs(TSubject unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(!ReferenceEquals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Did not expect {context} to refer to {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is of the specified type .\n /// \n /// The expected type of the object.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint BeOfType([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n BeOfType(typeof(T), because, becauseArgs);\n\n T typedSubject = Subject is T type\n ? type\n : default;\n\n return new AndWhichConstraint((TAssertions)this, typedSubject);\n }\n\n /// \n /// Asserts that the object is of the .\n /// \n /// \n /// The type that the subject is supposed to be.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeOfType(Type expectedType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedType);\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} to be {0}{reason}, but found .\", expectedType);\n\n if (CurrentAssertionChain.Succeeded)\n {\n Type subjectType = Subject.GetType();\n\n if (expectedType.IsGenericTypeDefinition && subjectType.IsGenericType)\n {\n subjectType.GetGenericTypeDefinition().Should().Be(expectedType, because, becauseArgs);\n }\n else\n {\n subjectType.Should().Be(expectedType, because, becauseArgs);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is not of the specified type .\n /// \n /// The type that the subject is not supposed to be.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOfType([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n NotBeOfType(typeof(T), because, becauseArgs);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is not the .\n /// \n /// \n /// The type that the subject is not supposed to be.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeOfType(Type unexpectedType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedType);\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} not to be {0}{reason}, but found .\", unexpectedType);\n\n if (CurrentAssertionChain.Succeeded)\n {\n Type subjectType = Subject.GetType();\n\n if (unexpectedType.IsGenericTypeDefinition && subjectType.IsGenericType)\n {\n subjectType.GetGenericTypeDefinition().Should().NotBe(unexpectedType, because, becauseArgs);\n }\n else\n {\n subjectType.Should().NotBe(unexpectedType, because, becauseArgs);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is assignable to a variable of type .\n /// \n /// The type to which the object should be assignable to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public AndWhichConstraint BeAssignableTo([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} to be assignable to {0}{reason}, but found .\", typeof(T));\n\n if (CurrentAssertionChain.Succeeded)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be assignable to {0}{reason}, but {1} is not.\", typeof(T), Subject.GetType());\n }\n\n T typedSubject = Subject is T type\n ? type\n : default;\n\n return new AndWhichConstraint((TAssertions)this, typedSubject);\n }\n\n /// \n /// Asserts that the object is assignable to a variable of given .\n /// \n /// The type to which the object should be assignable to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint BeAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} to be assignable to {0}{reason}, but found .\", type);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool isAssignable = type.IsGenericTypeDefinition\n ? Subject.GetType().IsAssignableToOpenGeneric(type)\n : type.IsAssignableFrom(Subject.GetType());\n\n CurrentAssertionChain\n .ForCondition(isAssignable)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to be assignable to {0}{reason}, but {1} is not.\",\n type,\n Subject.GetType());\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is not assignable to a variable of type .\n /// \n /// The type to which the object should not be assignable to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public AndConstraint NotBeAssignableTo([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeAssignableTo(typeof(T), because, becauseArgs);\n }\n\n /// \n /// Asserts that the object is not assignable to a variable of given .\n /// \n /// The type to which the object should not be assignable to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint NotBeAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(\"type\")\n .FailWith(\"Expected {context} to not be assignable to {0}{reason}, but found .\", type);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool isAssignable = type.IsGenericTypeDefinition\n ? Subject.GetType().IsAssignableToOpenGeneric(type)\n : type.IsAssignableFrom(Subject.GetType());\n\n CurrentAssertionChain\n .ForCondition(!isAssignable)\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context} to not be assignable to {0}{reason}, but {1} is.\", type, Subject.GetType());\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is satisfied.\n /// \n /// The predicate which must be satisfied by the .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return Match(predicate, because, becauseArgs);\n }\n\n /// \n /// Asserts that the is satisfied.\n /// \n /// The predicate which must be satisfied by the .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : TSubject\n {\n Guard.ThrowIfArgumentIsNull(predicate, nameof(predicate), \"Cannot match an object against a predicate.\");\n\n CurrentAssertionChain\n .ForCondition(predicate.Compile()((T)Subject))\n .BecauseOf(because, becauseArgs)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context:object} to match {1}{reason}, but found {0}.\", Subject, predicate);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Allows combining one or more assertions using the other assertion methods that this library offers on an instance of .\n /// \n /// \n /// If multiple assertions executed by the fail, they will be raised as a single failure.\n /// \n /// The element inspector which must be satisfied by the .\n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint Satisfy(Action assertion)\n where T : TSubject\n {\n Guard.ThrowIfArgumentIsNull(assertion, nameof(assertion), \"Cannot verify an object against a inspector.\");\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context:object} to be assignable to {0}{reason}, but found .\", typeof(T))\n .Then\n .ForCondition(Subject is T)\n .WithDefaultIdentifier(Identifier)\n .FailWith(\"Expected {context:object} to be assignable to {0}{reason}, but {1} is not.\", typeof(T),\n Subject?.GetType());\n\n if (CurrentAssertionChain.Succeeded)\n {\n string[] failuresFromInspector;\n\n using (var assertionScope = new AssertionScope())\n {\n assertion((T)Subject);\n failuresFromInspector = assertionScope.Discard();\n }\n\n if (failuresFromInspector.Length > 0)\n {\n string failureMessage = Environment.NewLine\n + string.Join(Environment.NewLine, failuresFromInspector.Select(x => x.IndentLines()));\n\n CurrentAssertionChain\n .WithDefaultIdentifier(Identifier)\n .WithExpectation(\"Expected {context:object} to match inspector, but the inspector was not satisfied:\",\n Subject,\n chain => chain.FailWithPreFormatted(failureMessage));\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// It should be a user-friendly name as it is included in the failure message.\n /// \n protected abstract string Identifier { get; }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean BeSameAs() instead?\");\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.MemberHiding.cs", "using System;\nusing JetBrains.Annotations;\nusing Xunit;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class MemberHiding\n {\n [Fact]\n public void Ignores_properties_hidden_by_the_derived_class()\n {\n // Arrange\n var subject = new SubclassAHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithProperty)subject).Property = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((AnotherBaseWithProperty)expectation).Property = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Ignores_properties_of_the_same_runtime_types_hidden_by_the_derived_class()\n {\n // Arrange\n var subject = new SubclassHidingStringProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithStringProperty)subject).Property = \"ActualBaseValue\";\n\n var expectation = new SubclassHidingStringProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithStringProperty)expectation).Property = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Includes_hidden_property_of_the_base_when_using_a_reference_to_the_base()\n {\n // Arrange\n BaseWithProperty subject = new SubclassAHidingProperty\n {\n Property = \"ActualDerivedValue\"\n };\n\n // AA doesn't know the compile-time type of the subject, so even though we pass a reference to the base-class,\n // at run-time, it'll start finding the property on the subject starting from the run-time type, and thus ignore the\n // hidden base-class field\n ((SubclassAHidingProperty)subject).Property = \"BaseValue\";\n\n AnotherBaseWithProperty expectation = new SubclassBHidingProperty\n {\n Property = \"ExpectedDerivedValue\"\n };\n\n expectation.Property = \"BaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Run_type_typing_ignores_hidden_properties_even_when_using_a_reference_to_the_base_class()\n {\n // Arrange\n var subject = new SubclassAHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithProperty)subject).Property = \"ActualBaseValue\";\n\n AnotherBaseWithProperty expectation = new SubclassBHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n expectation.Property = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o.PreferringRuntimeMemberTypes());\n }\n\n [Fact]\n public void Including_the_derived_property_excludes_the_hidden_property()\n {\n // Arrange\n var subject = new SubclassAHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((BaseWithProperty)subject).Property = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingProperty\n {\n Property = \"DerivedValue\"\n };\n\n ((AnotherBaseWithProperty)expectation).Property = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opt => opt\n .Including(o => o.Property));\n }\n\n [Fact]\n public void Excluding_the_property_hiding_the_base_class_one_does_not_reveal_the_latter()\n {\n // Arrange\n var subject = new SubclassAHidingProperty();\n\n ((BaseWithProperty)subject).Property = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingProperty();\n\n ((AnotherBaseWithProperty)expectation).Property = \"ExpectedBaseValue\";\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, o => o\n .Excluding(b => b.Property));\n\n // Assert\n act.Should().Throw().WithMessage(\"*No members were found *\");\n }\n\n private class BaseWithProperty\n {\n [UsedImplicitly]\n public object Property { get; set; }\n }\n\n private class SubclassAHidingProperty : BaseWithProperty\n {\n [UsedImplicitly]\n public new T Property { get; set; }\n }\n\n private class BaseWithStringProperty\n {\n [UsedImplicitly]\n public string Property { get; set; }\n }\n\n private class SubclassHidingStringProperty : BaseWithStringProperty\n {\n [UsedImplicitly]\n public new string Property { get; set; }\n }\n\n private class AnotherBaseWithProperty\n {\n [UsedImplicitly]\n public object Property { get; set; }\n }\n\n private class SubclassBHidingProperty : AnotherBaseWithProperty\n {\n public new T Property\n {\n get;\n set;\n }\n }\n\n [Fact]\n public void Ignores_fields_hidden_by_the_derived_class()\n {\n // Arrange\n var subject = new SubclassAHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((BaseWithField)subject).Field = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((AnotherBaseWithField)expectation).Field = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.IncludingFields());\n }\n\n [Fact]\n public void Includes_hidden_field_of_the_base_when_using_a_reference_to_the_base()\n {\n // Arrange\n BaseWithField subject = new SubclassAHidingField\n {\n Field = \"BaseValueFromSubject\"\n };\n\n // AA doesn't know the compile-time type of the subject, so even though we pass a reference to the base-class,\n // at run-time, it'll start finding the field on the subject starting from the run-time type, and thus ignore the\n // hidden base-class field\n ((SubclassAHidingField)subject).Field = \"BaseValueFromExpectation\";\n\n AnotherBaseWithField expectation = new SubclassBHidingField\n {\n Field = \"ExpectedDerivedValue\"\n };\n\n expectation.Field = \"BaseValueFromExpectation\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.IncludingFields());\n }\n\n [Fact]\n public void Run_type_typing_ignores_hidden_fields_even_when_using_a_reference_to_the_base_class()\n {\n // Arrange\n var subject = new SubclassAHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((BaseWithField)subject).Field = \"ActualBaseValue\";\n\n AnotherBaseWithField expectation = new SubclassBHidingField\n {\n Field = \"DerivedValue\"\n };\n\n expectation.Field = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options.IncludingFields().PreferringRuntimeMemberTypes());\n }\n\n [Fact]\n public void Including_the_derived_field_excludes_the_hidden_field()\n {\n // Arrange\n var subject = new SubclassAHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((BaseWithField)subject).Field = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingField\n {\n Field = \"DerivedValue\"\n };\n\n ((AnotherBaseWithField)expectation).Field = \"ExpectedBaseValue\";\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .IncludingFields()\n .Including(o => o.Field));\n }\n\n [Fact]\n public void Excluding_the_field_hiding_the_base_class_one_does_not_reveal_the_latter()\n {\n // Arrange\n var subject = new SubclassAHidingField();\n\n ((BaseWithField)subject).Field = \"ActualBaseValue\";\n\n var expectation = new SubclassBHidingField();\n\n ((AnotherBaseWithField)expectation).Field = \"ExpectedBaseValue\";\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, options => options\n .IncludingFields()\n .Excluding(b => b.Field));\n\n // Assert\n act.Should().Throw().WithMessage(\"*No members were found *\");\n }\n\n private class BaseWithField\n {\n [UsedImplicitly]\n public string Field;\n }\n\n private class SubclassAHidingField : BaseWithField\n {\n [UsedImplicitly]\n public new string Field;\n }\n\n private class AnotherBaseWithField\n {\n [UsedImplicitly]\n public string Field;\n }\n\n private class SubclassBHidingField : AnotherBaseWithField\n {\n [UsedImplicitly]\n public new string Field;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/CallerIdentificationSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Equivalency;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\n#pragma warning disable RCS1192, RCS1214, S4144 // verbatim string literals and interpolated strings\n// ReSharper disable RedundantStringInterpolation\nnamespace AwesomeAssertions.Specs.Execution\n{\n public class CallerIdentificationSpecs\n {\n [Fact]\n public void Types_in_the_system_namespace_are_excluded_from_identification()\n {\n // Act\n Action act = () => SystemNamespaceClass.AssertAgainstFailure();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected object*\",\n \"because a subject in a system namespace should not be ignored by caller identification\");\n }\n\n [Fact]\n public void Types_in_a_namespace_nested_under_system_are_excluded_from_identification()\n {\n // Act\n Action act = () => System.Data.NestedSystemNamespaceClass.AssertAgainstFailure();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected object*\");\n }\n\n [Fact]\n public void Types_in_a_namespace_prefixed_with_system_are_excluded_from_identification()\n {\n // Act\n Action act = () => SystemPrefixed.SystemPrefixedNamespaceClass.AssertAgainstFailure();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected actualCaller*\");\n }\n\n [Fact]\n public void When_variable_name_contains_Should_it_should_identify_the_entire_variable_name_as_the_caller()\n {\n // Arrange\n string fooShould = \"bar\";\n\n // Act\n Action act = () => fooShould.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected fooShould to be *\");\n }\n\n [Fact]\n public async Task When_should_is_passed_argument_context_should_still_be_found()\n {\n // Arrange\n var bob = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => bob.Should(timer).NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n bob.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect bob to complete within 1s because test testArg.\");\n }\n\n [Fact]\n public void When_variable_is_captured_it_should_use_the_variable_name()\n {\n // Arrange\n string foo = \"bar\";\n\n // Act\n Action act = () => foo.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo to be *\");\n }\n\n [Fact]\n public void When_field_is_the_subject_it_should_use_the_field_name()\n {\n // Arrange & Act\n Action act = () =>\n {\n var foo = new Foo();\n foo.Field.Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.Field to be *\");\n }\n\n [Fact]\n public void When_property_is_the_subject_it_should_use_the_property_name()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.Bar.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.Bar to be *\");\n }\n\n [Fact]\n public void When_method_name_is_the_subject_it_should_use_the_method_name()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod().Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod() to be *\");\n }\n\n [Fact]\n public void When_method_contains_arguments_it_should_add_them_to_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"test\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"test\\\") to be *\");\n }\n\n [Fact]\n public void When_the_caller_contains_multiple_members_it_should_include_them_all()\n {\n // Arrange\n string test1 = \"test1\";\n var foo = new Foo\n {\n Field = \"test3\"\n };\n\n // Act\n Action act = () => foo.GetFoo(test1).GetFooStatic(\"test\" + 2).GetFoo(foo.Field).Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(test1).GetFooStatic(\\\"test\\\" + 2).GetFoo(foo.Field) to be *\");\n }\n\n [Fact]\n public void When_the_caller_contains_multiple_members_across_multiple_lines_it_should_include_them_all()\n {\n // Arrange\n string test1 = \"test1\";\n var foo = new Foo\n {\n Field = \"test3\"\n };\n\n // Act\n Action act = () => foo\n .GetFoo(test1)\n .GetFooStatic(\"test\" + 2)\n .GetFoo(foo.Field)\n .Should()\n .BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(test1).GetFooStatic(\\\"test\\\" + 2).GetFoo(foo.Field) to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_Should_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\".Should()\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\".Should()\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_semicolon_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"test;\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"test;\\\") to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Code should not contain multiple statements on one line\", \"SA1107\")]\n [SuppressMessage(\"Code should not contain multiple statements on one line\", \"IDE0055\")]\n public void When_there_are_several_statements_on_the_line_it_should_use_the_correct_statement()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n#pragma warning disable format\n Action act = () =>\n {\n var foo2 = foo; foo2.Should().BeNull();\n };\n#pragma warning restore format\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo2 to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_escaped_quote_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"test\\\";\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"test\\\\\\\";\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_verbatim_string_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(@\"test\", argument2: $@\"test2\", argument3: @$\"test3\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(@\\\"test\\\", argument2: $@\\\"test2\\\", argument3: @$\\\"test3\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_multi_line_verbatim_string_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(@\"\n bob dole\n \"\n )\n .Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(@\\\" bob dole \\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_verbatim_string_interpolation_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(@$\"test\"\";\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(@$\\\"test\\\"\\\";\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_concatenations_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"1\" + 2).Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"1\\\" + 2) to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_multi_line_concatenations_it_should_include_that_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"abc\"\n + \"def\"\n )\n .Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"abc\\\"+ \\\"def\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_string_with_comment_like_contents_inside_it_should_include_them_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(\"test//test2/*test3*/\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(\\\"test//test2/*test3*/\\\") to be *\");\n }\n\n [Fact]\n public void When_arguments_contain_verbatim_string_with_verbatim_like_string_inside_it_should_include_them_to_the_caller()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.BarMethod(@\"test @\"\" @$\"\" bob\").Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.BarMethod(@\\\"test @\\\"\\\" @$\\\"\\\" bob\\\") to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"SA1515\")]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"IDE0055\")]\n public void When_the_caller_contains_single_line_comment_it_should_ignore_that()\n {\n // Arrange\n string foo = \"bar\";\n\n // Act\n Action act = () =>\n {\n foo\n // some important comment\n .Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"SA1515\")]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"IDE0055\")]\n public void When_the_caller_contains_multi_line_comment_it_should_ignore_that()\n {\n // Arrange\n string foo = \"bar\";\n\n // Act\n Action act = () =>\n {\n foo\n /*\n * some important comment\n */\n .Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"SA1515\")]\n [SuppressMessage(\"Single - line comment should be preceded by blank line\", \"IDE0055\")]\n public void When_the_caller_contains_several_comments_it_should_ignore_them()\n {\n // Arrange\n string foo = \"bar\";\n\n // Act\n Action act = () =>\n {\n foo\n // some important comment\n /* another one */.Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo to be *\");\n }\n\n [Fact]\n [SuppressMessage(\"Code should not contain multiple statements on one line\", \"IDE0055\")]\n [SuppressMessage(\"Single-line comment should be preceded by blank line\", \"SA1515\")]\n public void When_the_caller_with_methods_has_comments_between_it_should_ignore_them()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () =>\n {\n foo\n // some important comment\n .GetFoo(\"bob\")\n /* another one */\n .BarMethod()\n .Should().BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(\\\"bob\\\").BarMethod() to be *\");\n }\n\n [Fact]\n public void When_the_method_has_Should_prefix_it_should_read_whole_method()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.ShouldReturnSomeBool().Should().BeFalse();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.ShouldReturnSomeBool() to be false*\");\n }\n\n [Collection(\"UIFacts\")]\n public class UIFacts\n {\n [UIFact]\n public async Task Caller_identification_should_also_work_for_statements_following_async_code()\n {\n // Arrange\n const string someText = \"Hello\";\n Func task = async () => await Task.Yield();\n\n // Act\n await task.Should().NotThrowAsync();\n Action act = () => someText.Should().Be(\"Hi\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*someText*\", \"it should capture the variable name\");\n }\n }\n\n [Fact]\n public void A_method_taking_an_array_initializer_is_an_identifier()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.GetFoo(new[] { 1, 2, 3 }.Sum() + \"\")\n .Should()\n .BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(new[] { 1, 2, 3 }.Sum() + \\\"\\\") to be *\");\n }\n\n [Fact]\n public void A_method_taking_a_target_typed_new_expression_is_an_identifier()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.GetFoo(new('a', 10))\n .Should()\n .BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(new('a', 10)) to be *\");\n }\n\n [Fact]\n public void A_method_taking_a_list_is_an_identifier()\n {\n // Arrange\n var foo = new Foo();\n\n // Act\n Action act = () => foo.GetFoo(new List { 1, 2, 3 }.Sum() + \"\")\n .Should()\n .BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected foo.GetFoo(new List { 1, 2, 3 }*\");\n }\n\n [Fact]\n public void An_array_initializer_preceding_an_assertion_is_not_an_identifier()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().BeEmpty();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to be empty*\");\n }\n\n [Fact]\n public void An_object_initializer_preceding_an_assertion_is_not_an_identifier()\n {\n // Act\n Action act = () => new { Property = \"blah\" }.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected object to be*\");\n }\n\n [Fact]\n public void All_core_code_anywhere_in_the_stack_trace_is_ignored()\n {\n /*\n We want to test this specific scenario.\n\n 1. CallerIdentifier.DetermineCallerIdentity\n 2. AwesomeAssertions code\n 3. Custom extension <--- pointed to by lastUserStackFrameBeforeAwesomeAssertionsCodeIndex\n 4. AwesomeAssertions code <--- this is where DetermineCallerIdentity tried to get the variable name from before the fix\n 5. Test\n */\n\n var node = Node.From(GetSubjectId);\n\n // Assert\n node.Subject.Description.Should().StartWith(\"node.Subject.Description\");\n }\n\n [CustomAssertion]\n private string GetSubjectId() => AssertionChain.GetOrCreate().CallerIdentifier;\n }\n\n#pragma warning disable IDE0060, RCS1163 // Remove unused parameter\n [SuppressMessage(\"The name of a C# element does not begin with an upper-case letter\", \"SA1300\")]\n [SuppressMessage(\"Parameter is never used\", \"CA1801\")]\n public class Foo\n {\n public string Field = \"bar\";\n\n public string Bar => \"bar\";\n\n public string BarMethod() => Bar;\n\n public string BarMethod(string argument) => Bar;\n\n public string BarMethod(string argument, string argument2, string argument3) => Bar;\n\n public bool ShouldReturnSomeBool() => true;\n\n public Foo GetFoo(string argument) => this;\n }\n\n [SuppressMessage(\"Parameter is never used\", \"CA1801\")]\n public static class Extensions\n {\n public static Foo GetFooStatic(this Foo foo, string prm) => foo;\n }\n#pragma warning restore IDE0060, RCS1163 // Remove unused parameter\n}\n\nnamespace System\n{\n public static class SystemNamespaceClass\n {\n public static void AssertAgainstFailure()\n {\n object actualCaller = null;\n actualCaller.Should().NotBeNull(\"because we want this to fail and not return the name of the subject\");\n }\n }\n}\n\nnamespace SystemPrefixed\n{\n public static class SystemPrefixedNamespaceClass\n {\n public static void AssertAgainstFailure()\n {\n object actualCaller = null;\n actualCaller.Should().NotBeNull(\"because we want this to fail and return the name of the subject\");\n }\n }\n}\n\nnamespace System.Data\n{\n public static class NestedSystemNamespaceClass\n {\n public static void AssertAgainstFailure()\n {\n object actualCaller = null;\n actualCaller.Should().NotBeNull(\"because we want this to fail and not return the name of the subject\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/TaskCompletionSourceAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n\n#if NET6_0_OR_GREATER\npublic class TaskCompletionSourceAssertions : TaskCompletionSourceAssertionsBase\n{\n private readonly TaskCompletionSource subject;\n\n public TaskCompletionSourceAssertions(TaskCompletionSource tcs, AssertionChain assertionChain)\n : this(tcs, assertionChain, new Clock())\n {\n CurrentAssertionChain = assertionChain;\n }\n\n public TaskCompletionSourceAssertions(TaskCompletionSource tcs, AssertionChain assertionChain, IClock clock)\n : base(clock)\n {\n subject = tcs;\n CurrentAssertionChain = assertionChain;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the of the current will complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> CompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(subject!.Task, timeSpan);\n CurrentAssertionChain\n .ForCondition(completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the of the current will not complete within the specified time.\n /// \n /// The time span to wait for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> NotCompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to not complete within {0}{reason}, but found .\", timeSpan);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(subject!.Task, timeSpan);\n CurrentAssertionChain\n .ForCondition(!completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to not complete within {0}{reason}.\", timeSpan);\n }\n\n return new AndConstraint(this);\n }\n}\n#endif\n\npublic class TaskCompletionSourceAssertions : TaskCompletionSourceAssertionsBase\n{\n private readonly TaskCompletionSource subject;\n\n public TaskCompletionSourceAssertions(TaskCompletionSource tcs, AssertionChain assertionChain)\n : this(tcs, assertionChain, new Clock())\n {\n CurrentAssertionChain = assertionChain;\n }\n\n public TaskCompletionSourceAssertions(TaskCompletionSource tcs, AssertionChain assertionChain, IClock clock)\n : base(clock)\n {\n subject = tcs;\n CurrentAssertionChain = assertionChain;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the of the current will complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task, T>> CompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(subject!.Task, timeSpan);\n\n CurrentAssertionChain\n .ForCondition(completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n\n#pragma warning disable CA1849 // Call async methods when in an async method\n T result = subject.Task.IsCompleted ? subject.Task.Result : default;\n#pragma warning restore CA1849 // Call async methods when in an async method\n return new AndWhichConstraint, T>(this, result, CurrentAssertionChain, \".Result\");\n }\n\n return new AndWhichConstraint, T>(this, default(T));\n }\n\n /// \n /// Asserts that the of the current will not complete within the specified time.\n /// \n /// The time span to wait for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task>> NotCompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (CurrentAssertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(subject!.Task, timeSpan);\n\n CurrentAssertionChain\n .ForCondition(!completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n\n return new AndConstraint>(this);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/PropertyInfoAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class PropertyInfoAssertions : MemberInfoAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public PropertyInfoAssertions(PropertyInfo propertyInfo, AssertionChain assertionChain)\n : base(propertyInfo, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the selected property is virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeVirtual(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property to be virtual{reason}, but {context:property} is .\")\n .Then\n .ForCondition(Subject.IsVirtual())\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subjectDescription} to be virtual{{reason}}, but it is not.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property is not virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property not to be virtual{reason}, but {context:property} is .\")\n .Then\n .ForCondition(!Subject.IsVirtual())\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected property {subjectDescription} not to be virtual{{reason}}, but it is.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property has a setter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeWritable(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property to have a setter{reason}, but {context:property} is .\")\n .Then\n .ForCondition(Subject!.CanWrite)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subjectDescription} to have a setter{{reason}}.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property has a setter with the specified C# access modifier.\n /// \n /// The expected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint BeWritable(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:project}} to be {accessModifier}{{reason}}, but it is .\")\n .Then\n .ForCondition(Subject!.CanWrite)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subjectDescription} to have a setter{{reason}}.\");\n });\n\n if (assertionChain.Succeeded)\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n assertionChain.OverrideCallerIdentifier(() => $\"setter of {subjectDescription}\");\n assertionChain.ReuseOnce();\n\n Subject!.GetSetMethod(nonPublic: true).Should().HaveAccessModifier(accessModifier, because, becauseArgs);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property does not have a setter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeWritable(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:property} not to have a setter{reason}, but it is .\")\n .Then\n .ForCondition(!Subject!.CanWrite)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Did not expect {subjectDescription} to have a setter{{reason}}.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property has a getter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeReadable([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property to have a getter{reason}, but {context:property} is .\")\n .Then\n .ForCondition(Subject!.CanRead)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected property {subjectDescription} to have a getter{{reason}}, but it does not.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property has a getter with the specified C# access modifier.\n /// \n /// The expected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint BeReadable(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:property}} to be {accessModifier}{{reason}}, but it is .\")\n .Then\n .ForCondition(Subject!.CanRead)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subjectDescription} to have a getter{{reason}}, but it does not.\");\n });\n\n if (assertionChain.Succeeded)\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n assertionChain.OverrideCallerIdentifier(() => $\"getter of {subjectDescription}\");\n assertionChain.ReuseOnce();\n\n Subject!.GetGetMethod(nonPublic: true).Should().HaveAccessModifier(accessModifier, because, becauseArgs);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property does not have a getter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeReadable(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected property not to have a getter{reason}, but {context:property} is .\")\n .Then\n .ForCondition(!Subject!.CanRead)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subjectDescription = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Did not expect {subjectDescription} to have a getter{{reason}}.\");\n });\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property returns a specified type.\n /// \n /// The expected type of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Return(Type propertyType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(propertyType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type of property to be {0}{reason}, but {context:property} is .\", propertyType)\n .Then.ForCondition(Subject!.PropertyType == propertyType)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected type of property {2} to be {0}{reason}, but it is {1}.\",\n propertyType, Subject.PropertyType, Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property returns .\n /// \n /// The expected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Return([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return Return(typeof(TReturn), because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected property does not return a specified type.\n /// \n /// The unexpected type of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotReturn(Type propertyType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(propertyType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type of property not to be {0}{reason}, but {context:property} is .\", propertyType)\n .Then\n .ForCondition(Subject!.PropertyType != propertyType)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected type of property {0} not to be {1}{reason}, but it is.\", Subject, propertyType);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected property does not return .\n /// \n /// The unexpected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotReturn([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotReturn(typeof(TReturn), because, becauseArgs);\n }\n\n private string GetSubjectDescription(AssertionChain assertionChain) =>\n assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : $\"{Identifier} {Subject.ToFormattedString()}\";\n\n private protected override string SubjectDescription => Subject.ToFormattedString();\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"property\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DateTimeOffsetValueFormatter.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DateTimeOffsetValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is DateTime or DateTimeOffset;\n }\n\n [SuppressMessage(\"Design\", \"MA0051:Method is too long\", Justification = \"Needs to be refactored\")]\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n DateTimeOffset dateTimeOffset;\n bool significantOffset = false;\n\n if (value is DateTime dateTime)\n {\n dateTimeOffset = dateTime.ToDateTimeOffset();\n }\n else\n {\n dateTimeOffset = (DateTimeOffset)value;\n significantOffset = true;\n }\n\n formattedGraph.AddFragment(\"<\");\n\n bool hasDate = HasDate(dateTimeOffset);\n\n if (hasDate)\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"yyyy-MM-dd\", CultureInfo.InvariantCulture));\n }\n\n bool hasTime = HasTime(dateTimeOffset);\n\n if (hasTime)\n {\n if (hasDate)\n {\n formattedGraph.AddFragment(\" \");\n }\n\n if (HasNanoSeconds(dateTimeOffset))\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"HH:mm:ss.fffffff\", CultureInfo.InvariantCulture));\n }\n else if (HasMicroSeconds(dateTimeOffset))\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"HH:mm:ss.ffffff\", CultureInfo.InvariantCulture));\n }\n else if (HasMilliSeconds(dateTimeOffset))\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"HH:mm:ss.fff\", CultureInfo.InvariantCulture));\n }\n else\n {\n formattedGraph.AddFragment(dateTimeOffset.ToString(\"HH:mm:ss\", CultureInfo.InvariantCulture));\n }\n }\n\n if (dateTimeOffset.Offset > TimeSpan.Zero)\n {\n formattedGraph.AddFragment(\" +\");\n formatChild(\"offset\", dateTimeOffset.Offset, formattedGraph);\n }\n else if (dateTimeOffset.Offset < TimeSpan.Zero)\n {\n formattedGraph.AddFragment(\" \");\n formatChild(\"offset\", dateTimeOffset.Offset, formattedGraph);\n }\n else if (significantOffset && (hasDate || hasTime))\n {\n formattedGraph.AddFragment(\" +0h\");\n }\n else\n {\n // No offset added, since it was deemed unnecessary\n }\n\n if (!hasDate && !hasTime)\n {\n formattedGraph.AddFragment(\"0001-01-01 00:00:00.000\");\n }\n\n formattedGraph.AddFragment(\">\");\n }\n\n private static bool HasTime(DateTimeOffset dateTime)\n {\n return dateTime.Hour != 0\n || dateTime.Minute != 0\n || dateTime.Second != 0\n || HasMilliSeconds(dateTime)\n || HasMicroSeconds(dateTime)\n || HasNanoSeconds(dateTime);\n }\n\n private static bool HasDate(DateTimeOffset dateTime)\n {\n return dateTime.Day != 1 || dateTime.Month != 1 || dateTime.Year != 1;\n }\n\n private static bool HasMilliSeconds(DateTimeOffset dateTime)\n {\n return dateTime.Millisecond > 0;\n }\n\n private static bool HasMicroSeconds(DateTimeOffset dateTime)\n {\n return (dateTime.Ticks % TimeSpan.FromMilliseconds(1).Ticks) > 0;\n }\n\n private static bool HasNanoSeconds(DateTimeOffset dateTime)\n {\n return (dateTime.Ticks % (TimeSpan.FromMilliseconds(1).Ticks / 1000)) > 0;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NumericAssertionsBase.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\npublic abstract class NumericAssertionsBase\n where T : struct, IComparable\n where TAssertions : NumericAssertionsBase\n{\n public abstract TSubject Subject { get; }\n\n protected NumericAssertionsBase(AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the integral number value is exactly the same as the value.\n /// \n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T subject && subject.CompareTo(expected) == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be {0}{reason}, but found {1}\" + GenerateDifferenceMessage(expected), expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the integral number value is exactly the same as the value.\n /// \n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(T? expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(expected is { } value ? Subject is T subject && subject.CompareTo(value) == 0 : Subject is not T)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be {0}{reason}, but found {1}\" + GenerateDifferenceMessage(expected), expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the integral number value is not the same as the value.\n /// \n /// The unexpected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(T unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is not T subject || subject.CompareTo(unexpected) != 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the integral number value is not the same as the value.\n /// \n /// The unexpected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(T? unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(unexpected is { } value ? Subject is not T subject || subject.CompareTo(value) != 0 : Subject is T)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:value} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is greater than zero.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BePositive([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T subject && subject.CompareTo(default) > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be positive{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is less than zero.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNegative([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T value && !IsNaN(value) && value.CompareTo(default) < 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be negative{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is less than the specified value.\n /// \n /// The value to compare the current numeric value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThan(T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(expected))\n {\n throw new ArgumentException(\"A value can never be less than NaN\", nameof(expected));\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T value && !IsNaN(value) && value.CompareTo(expected) < 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be less than {0}{reason}, but found {1}\" + GenerateDifferenceMessage(expected),\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is less than or equal to the specified value.\n /// \n /// The value to compare the current numeric value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThanOrEqualTo(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(expected))\n {\n throw new ArgumentException(\"A value can never be less than or equal to NaN\", nameof(expected));\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T value && !IsNaN(value) && value.CompareTo(expected) <= 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:value} to be less than or equal to {0}{reason}, but found {1}\" +\n GenerateDifferenceMessage(expected), expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is greater than the specified value.\n /// \n /// The value to compare the current numeric value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThan(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(expected))\n {\n throw new ArgumentException(\"A value can never be greater than NaN\", nameof(expected));\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T subject && subject.CompareTo(expected) > 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:value} to be greater than {0}{reason}, but found {1}\" + GenerateDifferenceMessage(expected),\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the numeric value is greater than or equal to the specified value.\n /// \n /// The value to compare the current numeric value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThanOrEqualTo(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(expected))\n {\n throw new ArgumentException(\"A value can never be greater than or equal to a NaN\", nameof(expected));\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T subject && subject.CompareTo(expected) >= 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:value} to be greater than or equal to {0}{reason}, but found {1}\" +\n GenerateDifferenceMessage(expected), expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is within a range.\n /// \n /// \n /// Where the range is continuous or incremental depends on the actual type of the value.\n /// \n /// \n /// The minimum valid value of the range (inclusive).\n /// \n /// \n /// The maximum valid value of the range (inclusive).\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeInRange(T minimumValue, T maximumValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(minimumValue) || IsNaN(maximumValue))\n {\n throw new ArgumentException(\"A range cannot begin or end with NaN\");\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T value && value.CompareTo(minimumValue) >= 0 && value.CompareTo(maximumValue) <= 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be between {0} and {1}{reason}, but found {2}.\",\n minimumValue, maximumValue, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is not within a range.\n /// \n /// \n /// Where the range is continuous or incremental depends on the actual type of the value.\n /// \n /// \n /// The minimum valid value of the range.\n /// \n /// \n /// The maximum valid value of the range.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeInRange(T minimumValue, T maximumValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (IsNaN(minimumValue) || IsNaN(maximumValue))\n {\n throw new ArgumentException(\"A range cannot begin or end with NaN\");\n }\n\n CurrentAssertionChain\n .ForCondition(Subject is T value && !(value.CompareTo(minimumValue) >= 0 && value.CompareTo(maximumValue) <= 0))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to not be between {0} and {1}{reason}, but found {2}.\",\n minimumValue, maximumValue, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params T[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that a value is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is T value && validValues.Contains(value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is of the specified type .\n /// \n /// \n /// The type that the subject is supposed to be of.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeOfType(Type expectedType, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(expectedType);\n\n Type subjectType = Subject?.GetType();\n\n if (expectedType.IsGenericTypeDefinition && subjectType?.IsGenericType == true)\n {\n subjectType.GetGenericTypeDefinition().Should().Be(expectedType, because, becauseArgs);\n }\n else\n {\n subjectType.Should().Be(expectedType, because, becauseArgs);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the object is not of the specified type .\n /// \n /// \n /// The type that the subject is not supposed to be of.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeOfType(Type unexpectedType, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(unexpectedType);\n\n CurrentAssertionChain\n .ForCondition(Subject is T)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected type not to be {0}{reason}, but found .\", unexpectedType);\n\n if (CurrentAssertionChain.Succeeded)\n {\n Subject.GetType().Should().NotBe(unexpectedType, because, becauseArgs);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is satisfied.\n /// \n /// \n /// The predicate which must be satisfied\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n CurrentAssertionChain\n .ForCondition(Subject is T expression && predicate.Compile()(expression))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:value} to match {0}{reason}, but found {1}.\", predicate.Body, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n\n private protected virtual bool IsNaN(T value) => false;\n\n /// \n /// A method to generate additional information upon comparison failures.\n /// \n /// The current numeric value verified to be non-null.\n /// The value to compare the current numeric value with.\n /// \n /// Returns the difference between a number value and the value.\n /// Returns `null` if the compared numbers are small enough that a difference message is irrelevant.\n /// \n private protected virtual string CalculateDifferenceForFailureMessage(T subject, T expected) => null;\n\n private string GenerateDifferenceMessage(T? expected)\n {\n const string noDifferenceMessage = \".\";\n\n if (Subject is not T subject || expected is not { } expectedValue)\n {\n return noDifferenceMessage;\n }\n\n var difference = CalculateDifferenceForFailureMessage(subject, expectedValue);\n return difference is null ? noDifferenceMessage : $\" (difference of {difference}).\";\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringEqualityStrategy.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringEqualityStrategy : IStringComparisonStrategy\n{\n private const string Indentation = \" \";\n private const string Prefix = Indentation + \"\\\"\";\n private const string Suffix = \"\\\"\";\n private const char ArrowDown = '\\u2193';\n private const char ArrowUp = '\\u2191';\n private const char Ellipsis = '\\u2026';\n\n private readonly IEqualityComparer comparer;\n private readonly string predicateDescription;\n\n public StringEqualityStrategy(IEqualityComparer comparer, string predicateDescription)\n {\n this.comparer = comparer;\n this.predicateDescription = predicateDescription;\n }\n\n public string ExpectationDescription => $\"Expected {{context:string}} to {predicateDescription} \";\n\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n if (ValidateAgainstSuperfluousWhitespace(assertionChain, subject, expected))\n {\n return;\n }\n\n int indexOfMismatch = GetIndexOfFirstMismatch(subject, expected);\n\n assertionChain\n .ForCondition(indexOfMismatch == -1)\n .FailWith(() => new FailReason(CreateFailureMessage(subject, expected, indexOfMismatch)));\n }\n\n private string CreateFailureMessage(string subject, string expected, int indexOfMismatch)\n {\n string locationDescription = $\"at index {indexOfMismatch}\";\n var matchingString = subject[..indexOfMismatch];\n int lineNumber = matchingString.Count(c => c == '\\n');\n\n if (lineNumber > 0)\n {\n var indexOfLastNewlineBeforeMismatch = matchingString.LastIndexOf('\\n');\n var column = matchingString.Length - indexOfLastNewlineBeforeMismatch;\n locationDescription = $\"on line {lineNumber + 1} and column {column} (index {indexOfMismatch})\";\n }\n\n string mismatchSegment = GetMismatchSegment(subject, expected, indexOfMismatch).EscapePlaceholders();\n\n return $$\"\"\"\n {{ExpectationDescription}}the same string{reason}, but they differ {{locationDescription}}:\n {{mismatchSegment}}.\n \"\"\";\n }\n\n private bool ValidateAgainstSuperfluousWhitespace(AssertionChain assertion, string subject, string expected)\n {\n assertion\n .ForCondition(!(expected.Length > subject.Length && comparer.Equals(expected.TrimEnd(), subject)))\n .FailWith($\"{ExpectationDescription}{{0}}{{reason}}, but it misses some extra whitespace at the end.\", expected)\n .Then\n .ForCondition(!(subject.Length > expected.Length && comparer.Equals(subject.TrimEnd(), expected)))\n .FailWith($\"{ExpectationDescription}{{0}}{{reason}}, but it has unexpected whitespace at the end.\", expected);\n\n return !assertion.Succeeded;\n }\n\n /// \n /// Get the mismatch segment between and ,\n /// when they differ at index .\n /// \n private static string GetMismatchSegment(string subject, string expected, int firstIndexOfMismatch)\n {\n int trimStart = GetStartIndexOfPhraseToShowBeforeTheMismatchingIndex(subject, firstIndexOfMismatch);\n\n int whiteSpaceCountBeforeArrow = (firstIndexOfMismatch - trimStart) + Prefix.Length;\n\n if (trimStart > 0)\n {\n whiteSpaceCountBeforeArrow++;\n }\n\n var visibleText = subject[trimStart..firstIndexOfMismatch];\n whiteSpaceCountBeforeArrow += visibleText.Count(c => c is '\\r' or '\\n');\n\n var sb = new StringBuilder();\n\n sb.Append(' ', whiteSpaceCountBeforeArrow).Append(ArrowDown).AppendLine(\" (actual)\");\n AppendPrefixAndEscapedPhraseToShowWithEllipsisAndSuffix(sb, subject, trimStart);\n AppendPrefixAndEscapedPhraseToShowWithEllipsisAndSuffix(sb, expected, trimStart);\n sb.Append(' ', whiteSpaceCountBeforeArrow).Append(ArrowUp).Append(\" (expected)\");\n\n return sb.ToString();\n }\n\n /// \n /// Appends the prefix, the escaped visible phrase decorated with ellipsis and the suffix to the .\n /// \n /// When text phrase starts at and with a calculated length omits text on start or end, an ellipsis is added.\n private static void AppendPrefixAndEscapedPhraseToShowWithEllipsisAndSuffix(StringBuilder stringBuilder,\n string text, int indexOfStartingPhrase)\n {\n var subjectLength = GetLengthOfPhraseToShowOrDefaultLength(text[indexOfStartingPhrase..]);\n\n stringBuilder.Append(Prefix);\n\n if (indexOfStartingPhrase > 0)\n {\n stringBuilder.Append(Ellipsis);\n }\n\n stringBuilder.Append(text\n .Substring(indexOfStartingPhrase, subjectLength)\n .Replace(\"\\r\", \"\\\\r\", StringComparison.OrdinalIgnoreCase)\n .Replace(\"\\n\", \"\\\\n\", StringComparison.OrdinalIgnoreCase));\n\n if (text.Length > (indexOfStartingPhrase + subjectLength))\n {\n stringBuilder.Append(Ellipsis);\n }\n\n stringBuilder.AppendLine(Suffix);\n }\n\n /// \n /// Calculates the start index of the visible segment from when highlighting the difference at .\n /// \n /// \n /// Either keep the last 10 characters before or a word begin (separated by whitespace) between 15 and 5 characters before .\n /// \n private static int GetStartIndexOfPhraseToShowBeforeTheMismatchingIndex(string value, int indexOfFirstMismatch)\n {\n const int defaultCharactersToKeep = 10;\n const int minCharactersToKeep = 5;\n const int maxCharactersToKeep = 15;\n const int lengthOfWhitespace = 1;\n const int phraseLengthToCheckForWordBoundary = (maxCharactersToKeep - minCharactersToKeep) + lengthOfWhitespace;\n\n if (indexOfFirstMismatch <= defaultCharactersToKeep)\n {\n return 0;\n }\n\n var indexToStartSearchingForWordBoundary = Math.Max(indexOfFirstMismatch - (maxCharactersToKeep + lengthOfWhitespace), 0);\n\n var indexOfWordBoundary = value\n .IndexOf(' ', indexToStartSearchingForWordBoundary, phraseLengthToCheckForWordBoundary) -\n indexToStartSearchingForWordBoundary;\n\n if (indexOfWordBoundary >= 0)\n {\n return indexToStartSearchingForWordBoundary + indexOfWordBoundary + lengthOfWhitespace;\n }\n\n return indexOfFirstMismatch - defaultCharactersToKeep;\n }\n\n /// \n /// Calculates how many characters to keep in .\n /// \n /// \n /// If a word end is found between 45 and 60 characters, use this word end, otherwise keep 50 characters.\n /// \n private static int GetLengthOfPhraseToShowOrDefaultLength(string value)\n {\n var defaultLength = AssertionConfiguration.Current.Formatting.StringPrintLength;\n int minLength = defaultLength - 5;\n int maxLength = defaultLength + 10;\n const int lengthOfWhitespace = 1;\n\n var indexOfWordBoundary = value\n .LastIndexOf(' ', Math.Min(maxLength + lengthOfWhitespace, value.Length) - 1);\n\n if (indexOfWordBoundary >= minLength)\n {\n return indexOfWordBoundary;\n }\n\n return Math.Min(defaultLength, value.Length);\n }\n\n /// \n /// Get index of the first mismatch between and . \n /// \n /// \n /// \n /// Returns the index of the first mismatch, or -1 if the strings are equal.\n private int GetIndexOfFirstMismatch(string subject, string expected)\n {\n int indexOfMismatch = subject.IndexOfFirstMismatch(expected, comparer);\n\n if (indexOfMismatch != -1)\n {\n return indexOfMismatch;\n }\n\n // If no mismatch is found, we can assume the strings are equal when they also have the same length.\n if (subject.Length == expected.Length)\n {\n return -1;\n }\n\n // the mismatch is the first character of the longer string.\n return Math.Min(subject.Length, expected.Length);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/PredicateLambdaExpressionValueFormatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// The is responsible for formatting\n/// boolean lambda expressions.\n/// \npublic class PredicateLambdaExpressionValueFormatter : IValueFormatter\n{\n public bool CanHandle(object value) => value is LambdaExpression;\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var lambdaExpression = (LambdaExpression)value;\n\n var reducedExpression = ReduceConstantSubExpressions(lambdaExpression.Body);\n\n if (reducedExpression is BinaryExpression { NodeType: ExpressionType.AndAlso } binaryExpression)\n {\n var subExpressions = ExtractChainOfExpressionsJoinedWithAndOperator(binaryExpression);\n formattedGraph.AddFragment(string.Join(\" AndAlso \", subExpressions.Select(e => e.ToString())));\n }\n else\n {\n formattedGraph.AddFragment(reducedExpression.ToString());\n }\n }\n\n /// \n /// This step simplifies the lambda expression by replacing parts of it which do not depend on the lambda parameters\n /// with the actual values of these sub-expressions. The simplified expression is much easier to read.\n /// E.g. \"(_.Text == \"two\") AndAlso (_.Number == 3)\"\n /// Instead of \"(_.Text == value(AwesomeAssertions.Specs.Collections.GenericCollectionAssertionsSpecs+c__DisplayClass122_0).twoText) AndAlso (_.Number == 3)\".\n /// \n private static Expression ReduceConstantSubExpressions(Expression expression)\n {\n try\n {\n return new ConstantSubExpressionReductionVisitor().Visit(expression);\n }\n catch (InvalidOperationException)\n {\n // Fallback if we make an invalid rewrite of the expression.\n return expression;\n }\n }\n\n /// \n /// This step simplifies the lambda expression by removing unnecessary parentheses for root level chain of AND operators.\n /// E.g. (_.Text == \"two\") AndAlso (_.Number == 3) AndAlso (_.OtherText == \"foo\")\n /// Instead of ((_.Text == \"two\") AndAlso (_.Number == 3)) AndAlso (_.OtherText == \"foo\")\n /// This simplification is only implemented for the chain of AND operators because this is the most common predicate scenario.\n /// Similar logic can be implemented in the future for other operators.\n /// \n private static List ExtractChainOfExpressionsJoinedWithAndOperator(BinaryExpression binaryExpression)\n {\n var visitor = new AndOperatorChainExtractor();\n visitor.Visit(binaryExpression);\n return visitor.AndChain;\n }\n\n /// \n /// Expression visitor which can detect whether the expression depends on parameters.\n /// \n private sealed class ParameterDetector : ExpressionVisitor\n {\n public bool HasParameters { get; private set; }\n\n public override Expression Visit(Expression node)\n {\n // As soon as at least one parameter was found in the expression tree we should stop iterating (this is achieved by not calling base.Visit).\n return HasParameters ? node : base.Visit(node);\n }\n\n protected override Expression VisitParameter(ParameterExpression node)\n {\n HasParameters = true;\n return node;\n }\n }\n\n /// \n /// Expression visitor which can replace constant sub-expressions with constant values.\n /// \n private sealed class ConstantSubExpressionReductionVisitor : ExpressionVisitor\n {\n public override Expression Visit(Expression node)\n {\n if (node is null)\n {\n return null;\n }\n\n if (node is ConstantExpression)\n {\n return node;\n }\n\n if (!HasLiftedOperator(node) && ExpressionIsConstant(node))\n {\n return Expression.Constant(Expression.Lambda(node).Compile().DynamicInvoke());\n }\n\n return base.Visit(node);\n }\n\n private static bool HasLiftedOperator(Expression expression) =>\n expression is BinaryExpression { IsLifted: true } or UnaryExpression { IsLifted: true };\n\n private static bool ExpressionIsConstant(Expression expression)\n {\n if (expression is NewExpression or MemberInitExpression)\n {\n return false;\n }\n\n var visitor = new ParameterDetector();\n visitor.Visit(expression);\n return !visitor.HasParameters;\n }\n }\n\n /// \n /// Expression visitor which can extract sub-expressions from an expression which has the following form:\n /// (SubExpression1) AND (SubExpression2) ... AND (SubExpressionN)\n /// \n private sealed class AndOperatorChainExtractor : ExpressionVisitor\n {\n public List AndChain { get; } = [];\n\n public override Expression Visit(Expression node)\n {\n if (node!.NodeType == ExpressionType.AndAlso)\n {\n var binaryExpression = (BinaryExpression)node;\n Visit(binaryExpression.Left);\n Visit(binaryExpression.Right);\n }\n else\n {\n AndChain.Add(node);\n }\n\n return null;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/AsyncFunctionAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an asynchronous method yields the expected result.\n/// \n/// The type of to be handled.\n/// The type of assertion to be returned.\n[DebuggerNonUserCode]\npublic class AsyncFunctionAssertions : DelegateAssertionsBase, TAssertions>\n where TTask : Task\n where TAssertions : AsyncFunctionAssertions\n{\n private readonly AssertionChain assertionChain;\n\n protected AsyncFunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain,\n IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n protected override string Identifier => \"async function\";\n\n /// \n /// Asserts that the current will not complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> NotCompleteWithinAsync(TimeSpan timeSpan,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:task} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n (Task task, TimeSpan remainingTime) = InvokeWithTimer(timeSpan);\n\n if (remainingTime >= TimeSpan.Zero)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(task, remainingTime, _ => Task.CompletedTask);\n\n assertionChain\n .ForCondition(!completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current throws an exception of the exact type (and not a derived exception type).\n /// \n /// The type of exception expected to be thrown.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Returns an object that allows asserting additional members of the thrown exception.\n /// \n public async Task> ThrowExactlyAsync(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n Type expectedType = typeof(TException);\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw exactly {0}{reason}, but found .\", expectedType);\n\n if (assertionChain.Succeeded)\n {\n Exception exception = await InvokeWithInterceptionAsync(Subject);\n\n assertionChain\n .ForCondition(exception is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0}{reason}, but no exception was thrown.\", expectedType);\n\n if (assertionChain.Succeeded)\n {\n exception.Should().BeOfType(expectedType, because, becauseArgs);\n }\n\n return new ExceptionAssertions([exception as TException], assertionChain);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n /// \n /// Asserts that the current throws an exception of type .\n /// \n /// The type of exception expected to be thrown.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> ThrowAsync(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw {0}{reason}, but found .\", typeof(TException));\n\n if (assertionChain.Succeeded)\n {\n Exception exception = await InvokeWithInterceptionAsync(Subject);\n return ThrowInternal(exception, because, becauseArgs);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n /// \n /// Asserts that the current throws an exception of type \n /// within a specific timeout.\n /// \n /// The type of exception expected to be thrown.\n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> ThrowWithinAsync(TimeSpan timeSpan,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw {0} within {1}{reason}, but found .\",\n typeof(TException), timeSpan);\n\n if (assertionChain.Succeeded)\n {\n Exception caughtException = await InvokeWithInterceptionAsync(timeSpan);\n return AssertThrows(caughtException, timeSpan, because, becauseArgs);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n private ExceptionAssertions AssertThrows(\n Exception exception, TimeSpan timeSpan,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where TException : Exception\n {\n TException[] expectedExceptions = Extractor.OfType(exception).ToArray();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected a <{0}> to be thrown within {1}{reason}, \", typeof(TException), timeSpan, chain => chain\n .ForCondition(exception is not null)\n .FailWith(\"but no exception was thrown.\")\n .Then\n .ForCondition(expectedExceptions.Length > 0)\n .FailWith(\"but found <{0}>:\" + Environment.NewLine + \"{1}.\",\n exception?.GetType(),\n exception));\n\n return new ExceptionAssertions(expectedExceptions, assertionChain);\n }\n\n private async Task InvokeWithInterceptionAsync(TimeSpan timeout)\n {\n try\n {\n // For the duration of this nested invocation, configure CallerIdentifier\n // to match the contents of the subject rather than our own call site.\n //\n // Func action = async () => await subject.Should().BeSomething();\n // await action.Should().ThrowAsync();\n //\n // If an assertion failure occurs, we want the message to talk about \"subject\"\n // not \"await action\".\n using (CallerIdentifier.OnlyOneAssertionScopeOnCallStack()\n ? CallerIdentifier.OverrideStackSearchUsingCurrentScope()\n : default)\n {\n (TTask task, TimeSpan remainingTime) = InvokeWithTimer(timeout);\n\n if (remainingTime < TimeSpan.Zero)\n {\n // timeout reached without exception\n return null;\n }\n\n if (task.IsFaulted)\n {\n // exception in synchronous portion\n return task.Exception!.GetBaseException();\n }\n\n // Start monitoring the task regarding timeout.\n // Here we do not need to know whether the task completes (successfully) in timeout\n // or does not complete. We are only interested in the exception which is thrown, not returned.\n // So, we can ignore the result.\n _ = await CompletesWithinTimeoutAsync(task, remainingTime, cancelledTask => cancelledTask);\n }\n\n return null;\n }\n catch (Exception exception)\n {\n return exception;\n }\n }\n\n /// \n /// Asserts that the current does not throw an exception of type .\n /// \n /// The type of exception expected to not be thrown.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> NotThrowAsync([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n try\n {\n await Subject!.Invoke();\n }\n catch (Exception exception)\n {\n return NotThrowInternal(exception, because, becauseArgs);\n }\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Invokes the subject and measures the sync execution time.\n /// \n private protected (TTask result, TimeSpan remainingTime) InvokeWithTimer(TimeSpan timeSpan)\n {\n Common.ITimer timer = Clock.StartTimer();\n TTask result = Subject.Invoke();\n TimeSpan remainingTime = timeSpan - timer.Elapsed;\n\n return (result, remainingTime);\n }\n\n /// \n /// Monitors the specified task whether it completes withing the remaining time span.\n /// \n private protected async Task CompletesWithinTimeoutAsync(Task target, TimeSpan remainingTime, Func onTaskCanceled)\n {\n using var delayCancellationTokenSource = new CancellationTokenSource();\n\n Task delayTask = Clock.DelayAsync(remainingTime, delayCancellationTokenSource.Token);\n Task completedTask = await Task.WhenAny(target, delayTask);\n\n if (completedTask.IsFaulted)\n {\n // Throw the inner exception.\n await completedTask;\n }\n\n if (completedTask != target)\n {\n // The monitored task did not complete.\n return false;\n }\n\n if (target.IsCanceled)\n {\n await onTaskCanceled(target);\n }\n\n // The monitored task is completed, we shall cancel the clock.\n#pragma warning disable CA1849 // Call async methods when in an async method: Is not a drop-in replacement in this case, but may cause problems.\n delayCancellationTokenSource.Cancel();\n#pragma warning restore CA1849 // Call async methods when in an async method\n return true;\n }\n\n private protected static async Task InvokeWithInterceptionAsync(Func action)\n {\n try\n {\n // For the duration of this nested invocation, configure CallerIdentifier\n // to match the contents of the subject rather than our own call site.\n //\n // Func action = async () => await subject.Should().BeSomething();\n // await action.Should().ThrowAsync();\n //\n // If an assertion failure occurs, we want the message to talk about \"subject\"\n // not \"await action\".\n using (CallerIdentifier.OnlyOneAssertionScopeOnCallStack()\n ? CallerIdentifier.OverrideStackSearchUsingCurrentScope()\n : default)\n {\n await action();\n }\n\n return null;\n }\n catch (Exception exception)\n {\n return exception;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/FailureMessageFormatter.cs", "using System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Encapsulates expanding the various placeholders supported in a failure message.\n/// \ninternal class FailureMessageFormatter(FormattingOptions formattingOptions)\n{\n private static readonly char[] Blanks = ['\\r', '\\n', ' ', '\\t'];\n private string reason;\n private ContextDataDictionary contextData;\n private string identifier;\n private string fallbackIdentifier;\n\n public FailureMessageFormatter WithReason(string reason)\n {\n this.reason = SanitizeReason(reason ?? string.Empty);\n return this;\n }\n\n private static string SanitizeReason(string reason)\n {\n if (!string.IsNullOrEmpty(reason))\n {\n reason = EnsurePrefix(\"because\", reason);\n reason = reason.EscapePlaceholders();\n\n return StartsWithBlank(reason) ? reason : \" \" + reason;\n }\n\n return string.Empty;\n }\n\n // SMELL: looks way too complex just to retain the leading whitespace\n private static string EnsurePrefix(string prefix, string text)\n {\n string leadingBlanks = ExtractLeadingBlanksFrom(text);\n string textWithoutLeadingBlanks = text.Substring(leadingBlanks.Length);\n\n return !textWithoutLeadingBlanks.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)\n ? leadingBlanks + prefix + \" \" + textWithoutLeadingBlanks\n : text;\n }\n\n private static string ExtractLeadingBlanksFrom(string text)\n {\n string trimmedText = text.TrimStart(Blanks);\n int leadingBlanksCount = text.Length - trimmedText.Length;\n\n return text.Substring(0, leadingBlanksCount);\n }\n\n private static bool StartsWithBlank(string text)\n {\n return text.Length > 0 && Blanks.Contains(text[0]);\n }\n\n public FailureMessageFormatter WithContext(ContextDataDictionary contextData)\n {\n this.contextData = contextData;\n return this;\n }\n\n public FailureMessageFormatter WithIdentifier(string identifier)\n {\n this.identifier = identifier;\n return this;\n }\n\n public FailureMessageFormatter WithFallbackIdentifier(string fallbackIdentifier)\n {\n this.fallbackIdentifier = fallbackIdentifier;\n return this;\n }\n\n public string Format(string message, object[] messageArgs)\n {\n message = message.Replace(\"{reason}\", reason, StringComparison.Ordinal);\n\n message = SubstituteIdentifier(message, identifier?.EscapePlaceholders(), fallbackIdentifier);\n\n message = SubstituteContextualTags(message, contextData);\n\n message = FormatArgumentPlaceholders(message, messageArgs);\n\n return message;\n }\n\n private static string SubstituteIdentifier(string message, string identifier, string fallbackIdentifier)\n {\n const string pattern = @\"(?:\\s|^)\\{context(?:\\:(?[a-zA-Z\\s]+))?\\}\";\n\n message = Regex.Replace(message, pattern, match =>\n {\n const string result = \" \";\n\n if (!string.IsNullOrEmpty(identifier))\n {\n return result + identifier;\n }\n\n string defaultIdentifier = match.Groups[\"default\"].Value;\n\n if (!string.IsNullOrEmpty(defaultIdentifier))\n {\n return result + defaultIdentifier;\n }\n\n if (!string.IsNullOrEmpty(fallbackIdentifier))\n {\n return result + fallbackIdentifier;\n }\n\n return \" object\";\n });\n\n return message.TrimStart();\n }\n\n private static string SubstituteContextualTags(string message, ContextDataDictionary contextData)\n {\n const string pattern = @\"(?[a-zA-Z]+)(?:\\:(?[a-zA-Z\\s]+))?\\}(?!\\})\";\n\n return Regex.Replace(message, pattern, match =>\n {\n string key = match.Groups[\"key\"].Value;\n string contextualTags = contextData.AsStringOrDefault(key);\n string contextualTagsSubstituted = contextualTags?.EscapePlaceholders();\n\n return contextualTagsSubstituted ?? match.Groups[\"default\"].Value;\n });\n }\n\n private string FormatArgumentPlaceholders(string failureMessage, object[] failureArgs)\n {\n object[] values = failureArgs.Select(object (a) => Formatter.ToString(a, formattingOptions)).ToArray();\n\n try\n {\n return string.Format(CultureInfo.InvariantCulture, failureMessage, values);\n }\n catch (FormatException formatException)\n {\n return\n $\"**WARNING** failure message '{failureMessage}' could not be formatted with string.Format{Environment.NewLine}{formatException.StackTrace}\";\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventMonitor.cs", "#if !NETSTANDARD2_0\n\nusing System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Tracks the events an object raises.\n/// \ninternal sealed class EventMonitor : IMonitor\n{\n private readonly WeakReference subject;\n\n private readonly ConcurrentDictionary recorderMap = new();\n\n public EventMonitor(object eventSource, EventMonitorOptions options)\n {\n Guard.ThrowIfArgumentIsNull(eventSource, nameof(eventSource), \"Cannot monitor the events of a object.\");\n Guard.ThrowIfArgumentIsNull(options, nameof(options), \"Event monitor needs configuration.\");\n\n this.options = options;\n\n subject = new WeakReference(eventSource);\n\n Attach(typeof(T), this.options.TimestampProvider);\n }\n\n public T Subject => (T)subject.Target;\n\n private readonly ThreadSafeSequenceGenerator threadSafeSequenceGenerator = new();\n private readonly EventMonitorOptions options;\n\n public EventMetadata[] MonitoredEvents =>\n recorderMap\n .Values\n .Select(recorder => new EventMetadata(recorder.EventName, recorder.EventHandlerType))\n .ToArray();\n\n public OccurredEvent[] OccurredEvents\n {\n get\n {\n IEnumerable query =\n from eventName in recorderMap.Keys\n let recording = GetRecordingFor(eventName)\n from @event in recording\n orderby @event.Sequence\n select @event;\n\n return query.ToArray();\n }\n }\n\n public void Clear()\n {\n foreach (EventRecorder recorder in recorderMap.Values)\n {\n recorder.Reset();\n }\n }\n\n public EventAssertions Should()\n {\n return new EventAssertions(this, AssertionChain.GetOrCreate());\n }\n\n public IEventRecording GetRecordingFor(string eventName)\n {\n if (!recorderMap.TryGetValue(eventName, out EventRecorder recorder))\n {\n throw new InvalidOperationException($\"Not monitoring any events named \\\"{eventName}\\\".\");\n }\n\n return recorder;\n }\n\n private void Attach(Type typeDefiningEventsToMonitor, Func utcNow)\n {\n if (subject.Target is null)\n {\n throw new InvalidOperationException(\"Cannot monitor events on garbage-collected object\");\n }\n\n EventInfo[] events = GetPublicEvents(typeDefiningEventsToMonitor);\n\n if (events.Length == 0)\n {\n throw new InvalidOperationException($\"Type {typeDefiningEventsToMonitor.Name} does not expose any events.\");\n }\n\n foreach (EventInfo eventInfo in events)\n {\n AttachEventHandler(eventInfo, utcNow);\n }\n }\n\n private static EventInfo[] GetPublicEvents(Type type)\n {\n if (!type.IsInterface)\n {\n return type.GetEvents();\n }\n\n return new[] { type }\n .Concat(type.GetInterfaces())\n .SelectMany(i => i.GetEvents())\n .ToArray();\n }\n\n public void Dispose()\n {\n foreach (EventRecorder recorder in recorderMap.Values)\n {\n DisposeSafeIfRequested(recorder);\n }\n\n recorderMap.Clear();\n }\n\n private void DisposeSafeIfRequested(IDisposable recorder)\n {\n try\n {\n recorder.Dispose();\n }\n catch when (options.ShouldIgnoreEventAccessorExceptions)\n {\n // ignore\n }\n }\n\n private void AttachEventHandler(EventInfo eventInfo, Func utcNow)\n {\n if (!recorderMap.TryGetValue(eventInfo.Name, out _))\n {\n var recorder = new EventRecorder(subject.Target, eventInfo.Name, utcNow, threadSafeSequenceGenerator);\n\n if (recorderMap.TryAdd(eventInfo.Name, recorder))\n {\n AttachEventHandler(eventInfo, recorder);\n }\n }\n }\n\n private void AttachEventHandler(EventInfo eventInfo, EventRecorder recorder)\n {\n try\n {\n recorder.Attach(subject, eventInfo);\n }\n catch when (options.ShouldIgnoreEventAccessorExceptions)\n {\n if (!options.ShouldRecordEventsWithBrokenAccessor)\n {\n recorderMap.TryRemove(eventInfo.Name, out _);\n }\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringValidator.cs", "using AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringValidator\n{\n private readonly IStringComparisonStrategy comparisonStrategy;\n private AssertionChain assertionChain;\n\n public StringValidator(AssertionChain assertionChain, IStringComparisonStrategy comparisonStrategy, string because,\n object[] becauseArgs)\n {\n this.comparisonStrategy = comparisonStrategy;\n this.assertionChain = assertionChain.BecauseOf(because, becauseArgs);\n }\n\n public void Validate(string subject, string expected)\n {\n if (expected is null && subject is null)\n {\n return;\n }\n\n if (!ValidateAgainstNulls(subject, expected))\n {\n return;\n }\n\n if (expected.IsLongOrMultiline() || subject.IsLongOrMultiline())\n {\n assertionChain = assertionChain.UsingLineBreaks;\n }\n\n comparisonStrategy.ValidateAgainstMismatch(assertionChain, subject, expected);\n }\n\n private bool ValidateAgainstNulls(string subject, string expected)\n {\n if (expected is null == subject is null)\n {\n return true;\n }\n\n assertionChain.FailWith($\"{comparisonStrategy.ExpectationDescription}{{0}}{{reason}}, but found {{1}}.\", expected, subject);\n return false;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AssertionEngine.cs", "using System;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Configuration;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensibility;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Represents the run-time configuration of the assertion library.\n/// \npublic static class AssertionEngine\n{\n private static readonly object Lockable = new();\n private static ITestFramework testFramework;\n private static bool isInitialized;\n\n static AssertionEngine()\n {\n EnsureInitialized();\n }\n\n /// \n /// Gets or sets the run-time test framework used for throwing assertion exceptions.\n /// \n public static ITestFramework TestFramework\n {\n get\n {\n if (testFramework is not null)\n {\n return testFramework;\n }\n\n lock (Lockable)\n {\n#pragma warning disable CA1508\n if (testFramework is null)\n#pragma warning restore CA1508\n {\n testFramework = TestFrameworkFactory.GetFramework(Configuration.TestFramework);\n }\n }\n\n return testFramework;\n }\n set => testFramework = value;\n }\n\n /// \n /// Provides access to the global configuration and options to customize the behavior of AwesomeAssertions.\n /// \n public static GlobalConfiguration Configuration { get; private set; } = new();\n\n /// \n /// Resets the configuration to its default state and forces the engine to reinitialize the next time it is used.\n /// \n [PublicAPI]\n public static void ResetToDefaults()\n {\n isInitialized = false;\n Configuration = new();\n testFramework = null;\n EnsureInitialized();\n }\n\n internal static void EnsureInitialized()\n {\n if (isInitialized)\n {\n return;\n }\n\n lock (Lockable)\n {\n if (!isInitialized)\n {\n ExecuteCustomInitializers();\n\n isInitialized = true;\n }\n }\n }\n\n private static void ExecuteCustomInitializers()\n {\n var currentAssembly = Assembly.GetExecutingAssembly();\n var currentAssemblyName = currentAssembly.GetName();\n\n AssertionEngineInitializerAttribute[] attributes = [];\n\n try\n {\n attributes = AppDomain.CurrentDomain\n .GetAssemblies()\n .Where(assembly => assembly != currentAssembly && !assembly.IsDynamic && !IsFramework(assembly))\n .Where(a => a.GetReferencedAssemblies().Any(r => r.FullName == currentAssemblyName.FullName))\n .SelectMany(a => a.GetCustomAttributes())\n .ToArray();\n }\n catch\n {\n // Just ignore any exceptions that might happen while trying to find the attributes\n }\n\n foreach (var attribute in attributes)\n {\n try\n {\n attribute.Initialize();\n }\n catch\n {\n // Just ignore any exceptions that might happen while trying to find the attributes\n }\n }\n }\n\n private static bool IsFramework(Assembly assembly)\n {\n#if NET6_0_OR_GREATER\n return assembly!.FullName?.StartsWith(\"Microsoft.\", StringComparison.OrdinalIgnoreCase) == true ||\n assembly.FullName?.StartsWith(\"System.\", StringComparison.OrdinalIgnoreCase) == true;\n#else\n return assembly.FullName.StartsWith(\"Microsoft.\", StringComparison.OrdinalIgnoreCase) ||\n assembly.FullName.StartsWith(\"System.\", StringComparison.OrdinalIgnoreCase);\n#endif\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/CollectionSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Immutable;\nusing System.Collections.ObjectModel;\nusing System.Linq;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class CollectionSpecs\n{\n public interface IInterface\n {\n int InterfaceProperty { get; set; }\n }\n\n public class MyClass : IInterface\n {\n public int InterfaceProperty { get; set; }\n\n public int ClassProperty { get; set; }\n }\n\n public class SubDummy\n {\n public SubDummy(int id)\n {\n Id = id;\n }\n\n public int Id { get; }\n\n public override bool Equals(object obj)\n {\n return obj is SubDummy subDummy\n && Id == subDummy.Id;\n }\n\n public override int GetHashCode()\n {\n return Id.GetHashCode();\n }\n }\n\n public class TestDummy\n {\n public TestDummy(SubDummy sd)\n {\n Sd = sd;\n }\n\n public SubDummy Sd { get; }\n }\n\n private class NonGenericCollection : ICollection\n {\n private readonly IList inner;\n\n public NonGenericCollection(IList inner)\n {\n this.inner = inner;\n }\n\n public IEnumerator GetEnumerator()\n {\n foreach (var @object in inner)\n {\n yield return @object;\n }\n }\n\n public void CopyTo(Array array, int index)\n {\n ((ICollection)inner).CopyTo(array, index);\n }\n\n public int Count => inner.Count;\n\n public object SyncRoot => ((ICollection)inner).SyncRoot;\n\n public bool IsSynchronized => ((ICollection)inner).IsSynchronized;\n }\n\n private class EnumerableOfStringAndObject : IEnumerable, IEnumerable\n {\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public IEnumerator GetEnumerator()\n {\n yield return string.Empty;\n }\n }\n\n public class MyObject\n {\n public string MyString { get; set; }\n\n public ClassIdentifiedById Child { get; set; }\n }\n\n public class ClassIdentifiedById\n {\n public int Id { get; set; }\n\n public string MyChildString { get; set; }\n\n public override bool Equals(object obj)\n {\n return obj is ClassIdentifiedById other && other.Id == Id;\n }\n\n public override int GetHashCode()\n {\n return Id.GetHashCode();\n }\n }\n\n private class SelectPropertiesSelectionRule : IMemberSelectionRule\n {\n public bool OverridesStandardIncludeRules => throw new NotImplementedException();\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return context.Type.GetProperties().Select(pi => new Property(pi, currentNode));\n }\n\n bool IMemberSelectionRule.IncludesMembers => OverridesStandardIncludeRules;\n }\n\n private class SelectNoMembersSelectionRule : IMemberSelectionRule\n {\n public bool OverridesStandardIncludeRules => true;\n\n public IEnumerable SelectMembers(INode currentNode, IEnumerable selectedMembers,\n MemberSelectionContext context)\n {\n return [];\n }\n\n bool IMemberSelectionRule.IncludesMembers => OverridesStandardIncludeRules;\n }\n\n public class UserRolesLookupElement\n {\n private readonly Dictionary> innerRoles = [];\n\n public virtual Dictionary> Roles\n => innerRoles.ToDictionary(x => x.Key, y => y.Value.Select(z => z));\n\n public void Add(Guid userId, params string[] roles)\n {\n innerRoles[userId] = roles.ToList();\n }\n }\n\n public class ExceptionThrowingClass\n {\n#pragma warning disable CA1065 // this is for testing purposes.\n public object ExceptionThrowingProperty => throw new NotImplementedException();\n#pragma warning restore CA1065\n }\n\n [Fact]\n public void When_the_expectation_is_an_array_of_interface_type_it_should_respect_declared_types()\n {\n // Arrange\n var actual = new IInterface[]\n {\n new MyClass { InterfaceProperty = 1, ClassProperty = 42 }\n };\n\n var expected = new IInterface[]\n {\n new MyClass { InterfaceProperty = 1, ClassProperty = 1337 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().NotThrow(\"it should respect the declared types on IInterface\");\n }\n\n [Fact]\n public void When_the_expectation_has_fewer_dimensions_than_a_multi_dimensional_subject_it_should_fail()\n {\n // Arrange\n object objectA = new();\n object objectB = new();\n\n object[][] actual = [[objectA, objectB]];\n var expected = actual[0];\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be a collection with 2 item(s)*contains 1 item(s) less than*\",\n \"adding a `params object[]` overload cannot distinguish 'an array of objects' from 'an element which is an array of objects'\");\n }\n\n [Fact]\n public void When_the_expectation_is_an_array_of_anonymous_types_it_should_respect_runtime_types()\n {\n // Arrange\n var actual = new[] { new { A = 1, B = 2 }, new { A = 1, B = 2 } };\n var expected = new object[] { new { A = 1 }, new { B = 2 } };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_byte_array_does_not_match_strictly_it_should_throw()\n {\n // Arrange\n var subject = new byte[] { 1, 2, 3, 4, 5, 6 };\n\n var expectation = new byte[] { 6, 5, 4, 3, 2, 1 };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*subject[0]*6*1*\");\n }\n\n [Fact]\n public void When_a_byte_array_does_not_match_strictly_and_order_is_not_strict_it_should_throw()\n {\n // Arrange\n var subject = new byte[] { 1, 2, 3, 4, 5, 6 };\n\n var expectation = new byte[] { 6, 5, 4, 3, 2, 1 };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options.WithoutStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*subject[0]*6*1*\");\n }\n\n [Fact]\n public void\n When_a_collection_property_is_a_byte_array_which_does_not_match_strictly_and_order_is_not_strict_it_should_throw()\n {\n // Arrange\n var subject = new { bytes = new byte[] { 1, 2, 3, 4, 5, 6 } };\n\n var expectation = new { bytes = new byte[] { 6, 5, 4, 3, 2, 1 } };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options.WithoutStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected *bytes[0]*6*1*\");\n }\n\n [Fact]\n public void When_a_collection_does_not_match_it_should_include_items_in_message()\n {\n // Arrange\n int[] subject = [1, 2];\n\n int[] expectation = [3, 2, 1];\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*but*{1, 2}*1 item(s) less than*{3, 2, 1}*\");\n }\n\n [Fact]\n public void When_collection_of_same_count_does_not_match_it_should_include_at_most_10_items_in_message()\n {\n // Arrange\n // Subjects contains different values, because we want to distinguish them in the assertion message\n var subject = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\n var expectation = Enumerable.Repeat(20, subject.Length).ToArray();\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw().Which\n .Message.Should().Contain(\"[9]\").And.NotContain(\"[10]\");\n }\n\n [Fact]\n public void When_a_nullable_collection_does_not_match_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n Values = (ImmutableArray?)ImmutableArray.Create(1, 2, 3)\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(new\n {\n Values = (ImmutableArray?)ImmutableArray.Create(1, 2, 4)\n });\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Values[2]*to be 4, but found 3*\");\n }\n\n [Fact]\n public void\n When_a_collection_contains_a_reference_to_an_object_that_is_also_in_its_parent_it_should_not_be_treated_as_a_cyclic_reference()\n {\n // Arrange\n var logbook = new LogbookCode(\"SomeKey\");\n\n var logbookEntry = new LogbookEntryProjection\n {\n Logbook = logbook,\n LogbookRelations = [new LogbookRelation { Logbook = logbook }]\n };\n\n var equivalentLogbookEntry = new LogbookEntryProjection\n {\n Logbook = logbook,\n LogbookRelations = [new LogbookRelation { Logbook = logbook }]\n };\n\n // Act / Assert\n logbookEntry.Should().BeEquivalentTo(equivalentLogbookEntry);\n }\n\n [Fact]\n public void When_a_collection_contains_less_items_than_expected_it_should_throw()\n {\n // Arrange\n var expected = new\n {\n Customers = new[]\n {\n new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" },\n new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"Jane\" }\n }\n };\n\n var subject = new\n {\n Customers = new[] { new CustomerDto { Age = 24, Birthdate = 21.September(1973), Name = \"John\" } }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*Customers*to be a collection with 2 item(s), but*contains 1 item(s) less than*\");\n }\n\n [Fact]\n public void When_a_collection_contains_more_items_than_expected_it_should_throw()\n {\n // Arrange\n var expected = new { Customers = new[] { new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" } } };\n\n var subject = new\n {\n Customers = new[]\n {\n new CustomerDto { Age = 38, Birthdate = 20.September(1973), Name = \"Jane\" },\n new CustomerDto { Age = 24, Birthdate = 21.September(1973), Name = \"John\" }\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*Customers*to be a collection with 1 item(s), but*contains 1 item(s) more than*\");\n }\n\n [Fact]\n public void When_a_collection_property_contains_objects_with_matching_properties_in_any_order_it_should_not_throw()\n {\n // Arrange\n var expected = new\n {\n Customers = new[]\n {\n new Customer { Age = 32, Birthdate = 31.July(1978), Name = \"Jane\" },\n new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" }\n }\n };\n\n var subject = new\n {\n Customers = new[]\n {\n new CustomerDto { Age = 38, Birthdate = 20.September(1973), Name = \"John\" },\n new CustomerDto { Age = 32, Birthdate = 31.July(1978), Name = \"Jane\" }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, o => o.ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_two_deeply_nested_collections_are_equivalent_while_ignoring_the_order_it_should_not_throw()\n {\n // Arrange\n int[][] subject = [[], [42]];\n int[][] expectation = [[42], []];\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_a_collection_property_contains_objects_with_mismatching_properties_it_should_throw()\n {\n // Arrange\n var expected = new { Customers = new[] { new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" } } };\n\n var subject = new\n {\n Customers = new[] { new CustomerDto { Age = 38, Birthdate = 20.September(1973), Name = \"Jane\" } }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Customers[0].Name*Jane*John*\");\n }\n\n [Fact]\n public void When_the_subject_is_a_non_generic_collection_it_should_still_work()\n {\n // Arrange\n object item = new();\n object[] array = [item];\n IList readOnlyList = ArrayList.ReadOnly(array);\n\n // Act / Assert\n readOnlyList.Should().BeEquivalentTo(array);\n }\n\n [Fact]\n public void When_a_collection_property_was_expected_but_the_property_is_not_a_collection_it_should_throw()\n {\n // Arrange\n var subject = new { Customers = \"Jane, John\" };\n\n var expected = new { Customers = new[] { new Customer { Age = 38, Birthdate = 20.September(1973), Name = \"John\" } } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected*Customers*collection*String*\");\n }\n\n [Fact]\n public void When_a_complex_object_graph_with_collections_matches_expectations_it_should_not_throw()\n {\n // Arrange\n var subject = new { Bytes = new byte[] { 1, 2, 3, 4 }, Object = new { A = 1, B = 2 } };\n\n var expected = new { Bytes = new byte[] { 1, 2, 3, 4 }, Object = new { A = 1, B = 2 } };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_a_deeply_nested_property_of_a_collection_with_an_invalid_value_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Text = \"Root\",\n Level = new\n {\n Text = \"Level1\",\n Level = new { Text = \"Level2\" },\n Collection = new[] { new { Number = 1, Text = \"Text\" }, new { Number = 2, Text = \"Actual\" } }\n }\n };\n\n var expected = new\n {\n Text = \"Root\",\n Level = new\n {\n Text = \"Level1\",\n Level = new { Text = \"Level2\" },\n Collection = new[] { new { Number = 1, Text = \"Text\" }, new { Number = 2, Text = \"Expected\" } }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.Excluding(x => x.Level.Collection[1].Number).Excluding(x => x.Level.Collection[1].Text));\n }\n\n public class For\n {\n [Fact]\n public void When_property_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 3,\n Text = \"Actual\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection)\n .Exclude(x => x.Number));\n }\n\n [Fact]\n public void When_property_in_collection_is_excluded_it_should_not_throw_if_root_is_a_collection()\n {\n // Arrange\n var subject = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 3,\n Text = \"Actual\"\n }\n }\n }\n };\n\n // Act / Assert\n new[] { subject }.Should().BeEquivalentTo([expected],\n options => options\n .For(x => x.Level.Collection)\n .Exclude(x => x.Number));\n }\n\n [Fact]\n public void When_collection_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n NextCollection = new[]\n {\n new\n {\n Text = \"Text\"\n }\n }\n },\n new\n {\n Number = 2,\n NextCollection = new[]\n {\n new\n {\n Text = \"Actual\"\n }\n }\n }\n }\n }\n };\n\n var expected = new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n NextCollection = new[]\n {\n new\n {\n Text = \"Text\"\n }\n }\n },\n new\n {\n Number = 2,\n NextCollection = new[]\n {\n new\n {\n Text = \"Expected\"\n }\n }\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection)\n .Exclude(x => x.NextCollection));\n }\n\n [Fact]\n public void When_property_in_collection_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Text = \"Text\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n NextCollection = new[]\n {\n new\n {\n Text = \"Text\"\n }\n }\n },\n new\n {\n Number = 2,\n NextCollection = new[]\n {\n new\n {\n Text = \"Actual\"\n }\n }\n }\n }\n }\n };\n\n var expected = new\n {\n Text = \"Text\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n NextCollection = new[]\n {\n new\n {\n Text = \"Text\"\n }\n }\n },\n new\n {\n Number = 2,\n NextCollection = new[]\n {\n new\n {\n Text = \"Expected\"\n }\n }\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection)\n .For(x => x.NextCollection)\n .Exclude(x => x.Text)\n );\n }\n\n [Fact]\n public void When_property_in_object_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Text = \"Expected\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Collection)\n .Exclude(x => x.Level.Text)\n );\n }\n\n [Fact]\n public void When_property_in_object_in_collection_in_object_in_collection_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Text = \"Actual\"\n }\n }\n }\n }\n }\n }\n };\n\n var expected = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Level = new\n {\n Text = \"Expected\"\n }\n }\n }\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Collection)\n .For(x => x.Level.Collection)\n .Exclude(x => x.Level)\n );\n }\n\n [Fact]\n public void A_nested_exclusion_can_be_followed_by_a_root_level_exclusion()\n {\n // Arrange\n var subject = new\n {\n Text = \"Actual\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Text = \"Expected\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Expected\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection).Exclude(x => x.Text)\n .Excluding(x => x.Text));\n }\n\n [Fact]\n public void A_nested_exclusion_can_be_preceded_by_a_root_level_exclusion()\n {\n // Arrange\n var subject = new\n {\n Text = \"Actual\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Text = \"Expected\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Expected\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .Excluding(x => x.Text)\n .For(x => x.Level.Collection).Exclude(x => x.Text));\n }\n\n [Fact]\n public void A_nested_exclusion_can_be_followed_by_a_nested_exclusion()\n {\n // Arrange\n var subject = new\n {\n Text = \"Actual\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 2,\n Text = \"Actual\"\n }\n }\n }\n };\n\n var expected = new\n {\n Text = \"Actual\",\n Level = new\n {\n Collection = new[]\n {\n new\n {\n Number = 1,\n Text = \"Text\"\n },\n new\n {\n Number = 3,\n Text = \"Expected\"\n }\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .For(x => x.Level.Collection).Exclude(x => x.Text)\n .For(x => x.Level.Collection).Exclude(x => x.Number));\n }\n }\n\n [Fact]\n public void When_a_dictionary_property_is_detected_it_should_ignore_the_order_of_the_pairs()\n {\n // Arrange\n var expected = new { Customers = new Dictionary { [\"Key2\"] = \"Value2\", [\"Key1\"] = \"Value1\" } };\n\n var subject = new { Customers = new Dictionary { [\"Key1\"] = \"Value1\", [\"Key2\"] = \"Value2\" } };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_injecting_a_null_config_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = new EnumerableOfStringAndObject();\n IEnumerable collection2 = new EnumerableOfStringAndObject();\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void\n When_a_object_implements_multiple_IEnumerable_interfaces_but_the_declared_type_is_assignable_to_only_one_and_runtime_checking_is_configured_it_should_fail()\n {\n // Arrange\n IEnumerable collection1 = new EnumerableOfStringAndObject();\n IEnumerable collection2 = new EnumerableOfStringAndObject();\n\n // Act\n Action act =\n () => collection1.Should().BeEquivalentTo(collection2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw(\"the runtime type is assignable to two IEnumerable interfaces\")\n .WithMessage(\"*cannot determine which one*\");\n }\n\n [Fact]\n public void When_a_specific_property_is_included_it_should_ignore_the_rest_of_the_properties()\n {\n // Arrange\n var result = new[] { new { A = \"aaa\", B = \"bbb\" } };\n\n var expected = new { A = \"aaa\", B = \"ccc\" };\n\n // Act / Assert\n result.Should().BeEquivalentTo([expected], options => options.Including(x => x.A));\n }\n\n [Fact]\n public void\n When_a_strongly_typed_collection_is_declared_as_an_untyped_collection_and_runtime_checking_is_configured_is_should_use_the_runtime_type()\n {\n // Arrange\n ICollection collection1 = new List { new() };\n ICollection collection2 = new List { new() };\n\n // Act\n Action act =\n () => collection1.Should().BeEquivalentTo(collection2, opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw(\"the items have different runtime types\");\n }\n\n [Fact]\n public void When_all_strings_in_the_collection_are_equal_to_the_expected_string_it_should_succeed()\n {\n // Arrange\n var subject = new List { \"one\", \"one\", \"one\" };\n\n // Act / Assert\n subject.Should().AllBe(\"one\");\n }\n\n [Fact]\n public void When_all_strings_in_the_collection_are_equal_to_the_expected_string_it_should_allow_chaining()\n {\n // Arrange\n var subject = new List { \"one\", \"one\", \"one\" };\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\").And.HaveCount(3);\n }\n\n [Fact]\n public void When_some_string_in_the_collection_is_not_equal_to_the_expected_string_it_should_throw()\n {\n // Arrange\n string[] subject = [\"one\", \"two\", \"six\"];\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\");\n\n // Assert\n action.Should().Throw().WithMessage(\"\"\"\n Expected subject[1]*to be *\"two\"*\"one\"*\n Expected subject[2]*to be *\"six\"*\"one\"*\n \"\"\");\n }\n\n [Fact]\n public void When_some_string_in_the_collection_is_in_different_case_than_expected_string_it_should_throw()\n {\n // Arrange\n string[] subject = [\"one\", \"One\", \"ONE\"];\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\");\n\n // Assert\n action.Should().Throw().WithMessage(\"\"\"\n Expected subject[1]*to be *\"One\"*\"one\"*\n Expected subject[2]*to be *\"ONE\"*\"one\"*\n \"\"\");\n }\n\n [Fact]\n public void When_more_than_10_strings_in_the_collection_are_not_equal_to_expected_string_only_10_are_reported()\n {\n // Arrange\n var subject = Enumerable.Repeat(\"two\", 11);\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\");\n\n // Assert\n action.Should().Throw().Which\n .Message.Should().Contain(\"\"\"\n subject[9] to be the same string, but they differ at index 0:\n ↓ (actual)\n \"two\"\n \"one\"\n ↑ (expected).\n \"\"\")\n .And.NotContain(\"subject[10]\");\n }\n\n [Fact]\n public void\n When_some_strings_in_the_collection_are_not_equal_to_expected_string_for_huge_table_execution_time_should_still_be_short()\n {\n // Arrange\n const int N = 100000;\n var subject = new List(N) { \"one\" };\n\n for (int i = 1; i < N; i++)\n {\n subject.Add(\"two\");\n }\n\n // Act\n Action action = () =>\n {\n try\n {\n subject.Should().AllBe(\"one\");\n }\n catch\n {\n // ignored, we only care about execution time\n }\n };\n\n // Assert\n action.ExecutionTime().Should().BeLessThan(1.Seconds());\n }\n\n [Fact]\n public void When_all_subject_items_are_equivalent_to_expectation_object_it_should_succeed()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"someDto\", Age = 1 },\n new() { Name = \"someDto\", Age = 1 },\n new() { Name = \"someDto\", Age = 1 }\n };\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo(new\n {\n Name = \"someDto\",\n Age = 1,\n Birthdate = default(DateTime)\n });\n }\n\n [Fact]\n public void When_all_subject_items_are_equivalent_to_expectation_object_it_should_allow_chaining()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"someDto\", Age = 1 },\n new() { Name = \"someDto\", Age = 1 },\n new() { Name = \"someDto\", Age = 1 }\n };\n var expectation = new\n {\n Name = \"someDto\",\n Age = 1,\n Birthdate = default(DateTime)\n };\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo(expectation).And.HaveCount(3);\n }\n\n [Fact]\n public void When_some_subject_items_are_not_equivalent_to_expectation_object_it_should_throw()\n {\n // Arrange\n int[] subject = [1, 2, 3];\n\n // Act\n Action action = () => subject.Should().AllBeEquivalentTo(1);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected subject[1]*to be 1, but found 2.*Expected subject[2]*to be 1, but found 3*\");\n }\n\n [Fact]\n public void When_more_than_10_subjects_items_are_not_equivalent_to_expectation_only_10_are_reported()\n {\n // Arrange\n var subject = Enumerable.Repeat(2, 11);\n\n // Act\n Action action = () => subject.Should().AllBeEquivalentTo(1);\n\n // Assert\n action.Should().Throw().Which\n .Message.Should().Contain(\"subject[9] to be 1, but found 2\")\n .And.NotContain(\"item[10]\");\n }\n\n [Fact]\n public void\n When_some_subject_items_are_not_equivalent_to_expectation_for_huge_table_execution_time_should_still_be_short()\n {\n // Arrange\n const int N = 100000;\n var subject = new List(N) { 1 };\n\n for (int i = 1; i < N; i++)\n {\n subject.Add(2);\n }\n\n // Act\n Action action = () =>\n {\n try\n {\n subject.Should().AllBeEquivalentTo(1);\n }\n catch\n {\n // ignored, we only care about execution time\n }\n };\n\n // Assert\n action.ExecutionTime().Should().BeLessThan(1.Seconds());\n }\n\n [Fact]\n public void\n When_an_object_implements_multiple_IEnumerable_interfaces_but_the_declared_type_is_assignable_to_only_one_it_should_respect_the_declared_type()\n {\n // Arrange\n IEnumerable collection1 = new EnumerableOfStringAndObject();\n IEnumerable collection2 = new EnumerableOfStringAndObject();\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().NotThrow(\"the declared type is assignable to only one IEnumerable interface\");\n }\n\n [Fact]\n public void When_an_unordered_collection_must_be_strict_using_a_predicate_it_should_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options =>\n options.WithStrictOrderingFor(s => s.Path.Contains(\"UnorderedCollection\")));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*Expected*[0].UnorderedCollection*5 item(s)*empty collection*\");\n }\n\n [Fact]\n public void\n When_an_unordered_collection_must_be_strict_using_a_predicate_and_order_was_reset_to_not_strict_it_should_not_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options =>\n options\n .WithStrictOrderingFor(s => s.Path.Contains(\"UnorderedCollection\"))\n .WithoutStrictOrdering());\n }\n\n [Fact]\n public void When_an_unordered_collection_must_be_strict_using_an_expression_it_should_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act\n Action action =\n () =>\n subject.Should().BeEquivalentTo(expectation,\n options => options\n .WithStrictOrderingFor(\n s => s.UnorderedCollection));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"*Expected*[0].UnorderedCollection*5 item(s)*empty collection*\");\n }\n\n [Fact]\n public void Can_force_strict_ordering_based_on_the_parent_type_of_an_unordered_collection()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrderingFor(oi => oi.ParentType == expectation[0].GetType()));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*Expected*[0].UnorderedCollection*5 item(s)*empty collection*\");\n }\n\n [Fact]\n public void\n When_an_unordered_collection_must_be_strict_using_an_expression_and_order_is_reset_to_not_strict_it_should_not_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n options => options\n .WithStrictOrderingFor(s => s.UnorderedCollection)\n .WithoutStrictOrdering());\n }\n\n [Fact]\n public void When_an_unordered_collection_must_not_be_strict_using_a_predicate_it_should_not_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrdering()\n .WithoutStrictOrderingFor(s => s.Path.Contains(\"UnorderedCollection\")));\n }\n\n [Fact]\n public void When_an_unordered_collection_must_not_be_strict_using_an_expression_it_should_not_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrdering()\n .WithoutStrictOrderingFor(x => x.UnorderedCollection));\n }\n\n [Fact]\n public void\n When_an_unordered_collection_must_not_be_strict_using_a_predicate_and_order_was_reset_to_strict_it_should_throw()\n {\n // Arrange\n var subject = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 1, 2 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n var expectation = new[]\n {\n new { Name = \"John\", UnorderedCollection = new[] { 2, 1 } },\n new { Name = \"Jane\", UnorderedCollection = new int[0] }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrdering()\n .WithoutStrictOrderingFor(s => s.Path.Contains(\"UnorderedCollection\"))\n .WithStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"*Expected*subject[0].UnorderedCollection[0]*to be 2, but found 1.*Expected subject[0].UnorderedCollection[1]*to be 1, but found 2*\");\n }\n\n [Fact]\n public void When_an_unordered_collection_must_not_be_strict_using_an_expression_and_collection_is_not_equal_it_should_throw()\n {\n // Arrange\n var subject = new\n {\n UnorderedCollection = new[] { 1 }\n };\n\n var expectation = new\n {\n UnorderedCollection = new[] { 2 }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options\n .WithStrictOrdering()\n .WithoutStrictOrderingFor(x => x.UnorderedCollection));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*not strict*\");\n }\n\n [Fact]\n public void Can_request_strict_ordering_using_an_expression_that_points_to_the_collection_items()\n {\n // Arrange\n var subject = new List { \"first\", \"second\" };\n\n var expectation = new List { \"second\", \"first\" };\n\n var act = () => subject.Should().BeEquivalentTo(expectation,\n options => options.WithStrictOrderingFor(v => v));\n\n act.Should().Throw().WithMessage(\"Expected*second*but*first*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_collections_and_configured_to_use_runtime_properties_it_should_respect_the_runtime_type()\n {\n // Arrange\n ICollection collection1 = new NonGenericCollection([new Customer()]);\n ICollection collection2 = new NonGenericCollection([new Car()]);\n\n // Act\n Action act =\n () =>\n collection1.Should().BeEquivalentTo(collection2,\n opts => opts.PreferringRuntimeMemberTypes());\n\n // Assert\n act.Should().Throw(\"the types have different properties\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_generic_collections_it_should_respect_the_declared_type()\n {\n // Arrange\n var collection1 = new Collection { new DerivedCustomerType(\"123\") };\n var collection2 = new Collection { new(\"123\") };\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().NotThrow(\"the objects are equivalent according to the members on the declared type\");\n }\n\n [Fact]\n public void When_asserting_equivalence_of_non_generic_collections_it_should_respect_the_runtime_type()\n {\n // Arrange\n ICollection subject = new NonGenericCollection([new Customer()]);\n ICollection expectation = new NonGenericCollection([new Car()]);\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Wheels*not have*VehicleId*not have*\");\n }\n\n [Fact]\n public void When_custom_assertion_rules_are_utilized_the_rules_should_be_respected()\n {\n // Arrange\n var subject = new[]\n {\n new { Value = new Customer { Name = \"John\", Age = 31, Id = 1 } },\n new { Value = new Customer { Name = \"Jane\", Age = 24, Id = 2 } }\n };\n\n var expectation = new[]\n {\n new { Value = new CustomerDto { Name = \"John\", Age = 30 } },\n new { Value = new CustomerDto { Name = \"Jane\", Age = 24 } }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opts => opts\n .Using(ctx => ctx.Subject.Should().BeInRange(ctx.Expectation - 1, ctx.Expectation + 1))\n .WhenTypeIs()\n );\n }\n\n [Fact]\n public void When_expectation_is_null_enumerable_it_should_throw()\n {\n // Arrange\n IEnumerable subject = [];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo((IEnumerable)null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject*to be , but found*\");\n }\n\n [Fact]\n public void When_nested_objects_are_excluded_from_collections_it_should_use_simple_equality_semantics()\n {\n // Arrange\n var actual = new MyObject\n {\n MyString = \"identical string\",\n Child = new ClassIdentifiedById { Id = 1, MyChildString = \"identical string\" }\n };\n\n var expectation = new MyObject\n {\n MyString = \"identical string\",\n Child = new ClassIdentifiedById { Id = 1, MyChildString = \"DIFFERENT STRING\" }\n };\n\n IList actualList = new List { actual };\n IList expectationList = new List { expectation };\n\n // Act / Assert\n actualList.Should().BeEquivalentTo(expectationList, opt => opt.WithoutRecursing());\n }\n\n [Fact]\n public void When_no_collection_item_matches_it_should_report_the_closest_match()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 30, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"Jane\", Age = 30, Id = 2 },\n new() { Name = \"John\", Age = 28, Id = 1 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*[1].Age*28*27*\");\n }\n\n [Fact]\n public void When_only_a_deeply_nested_property_is_included_it_should_exclude_the_other_properties()\n {\n // Arrange\n var actualObjects = new[]\n {\n new { SubObject = new { Property1 = \"John\", Property2 = \"John\" } },\n new { SubObject = new { Property1 = \"John\", Property2 = \"John\" } }\n };\n\n var expectedObjects = new[]\n {\n new { SubObject = new { Property1 = \"John\", Property2 = \"John\" } },\n new { SubObject = new { Property1 = \"John\", Property2 = \"Jane\" } }\n };\n\n // Act / Assert\n actualObjects.Should().BeEquivalentTo(expectedObjects, options =>\n options.Including(order => order.SubObject.Property1));\n }\n\n [Fact]\n public void When_selection_rules_are_configured_they_should_be_evaluated_from_last_to_first()\n {\n // Arrange\n var list1 = new[] { new { Value = 3 } };\n var list2 = new[] { new { Value = 2 } };\n\n // Act\n Action act = () => list1.Should().BeEquivalentTo(list2, config =>\n {\n config.WithoutSelectionRules();\n config.Using(new SelectNoMembersSelectionRule());\n config.Using(new SelectPropertiesSelectionRule());\n return config;\n });\n\n // Assert\n act.Should().Throw().WithMessage(\"*to be 2, but found 3*\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_generic_overload_it_should_throw()\n {\n // Arrange\n var list1 = new[] { new { Value = 3 } };\n var list2 = new[] { new { Value = 2 } };\n\n // Act\n Action act = () => list1.Should().BeEquivalentTo(list2, config: null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_subject_and_expectation_are_null_enumerable_it_should_succeed()\n {\n // Arrange\n IEnumerable subject = null;\n\n // Act / Assert\n subject.Should().BeEquivalentTo((IEnumerable)null);\n }\n\n [Fact]\n public void When_string_collection_subject_is_empty_and_expectation_is_object_succeed()\n {\n // Arrange\n var subject = new List();\n\n // Act / Assert\n subject.Should().AllBe(\"one\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_AllBe_for_string_collection_it_should_throw()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\", config: null);\n\n // Assert\n action.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_all_string_subject_items_are_equal_to_expectation_object_with_a_config_it_should_succeed()\n {\n // Arrange\n var subject = new List { \"one\", \"one\" };\n\n // Act / Assert\n subject.Should().AllBe(\"one\", opt => opt);\n }\n\n [Fact]\n public void When_not_all_string_subject_items_are_equal_to_expectation_object_with_a_config_it_should_fail()\n {\n // Arrange\n var subject = new List { \"one\", \"two\" };\n\n // Act\n Action action = () => subject.Should().AllBe(\"one\", opt => opt, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*we want to test the failure message*\");\n }\n\n [Fact]\n public void When_all_string_subject_items_are_equal_to_expectation_object_with_a_config_it_should_allow_chaining()\n {\n // Arrange\n var subject = new List { \"one\", \"one\" };\n\n // Act / Assert\n subject.Should().AllBe(\"one\", opt => opt)\n .And.HaveCount(2);\n }\n\n [Fact]\n public void When_subject_is_empty_and_expectation_is_object_succeed()\n {\n // Arrange\n var subject = new List();\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo('g');\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_AllBeEquivalentTo_it_should_throw()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action action = () => subject.Should().AllBeEquivalentTo('g', config: null);\n\n // Assert\n action.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_all_subject_items_are_equivalent_to_expectation_object_with_a_config_it_should_succeed()\n {\n // Arrange\n var subject = new List { 'g', 'g' };\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo('g', opt => opt);\n }\n\n [Fact]\n public void When_not_all_subject_items_are_equivalent_to_expectation_object_with_a_config_it_should_fail()\n {\n // Arrange\n var subject = new List { 'g', 'a' };\n\n // Act\n Action action = () =>\n subject.Should().AllBeEquivalentTo('g', opt => opt, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*we want to test the failure message*\");\n }\n\n [Fact]\n public void When_all_subject_items_are_equivalent_to_expectation_object_with_a_config_it_should_allow_chaining()\n {\n // Arrange\n var subject = new List { 'g', 'g' };\n\n // Act / Assert\n subject.Should().AllBeEquivalentTo('g', opt => opt)\n .And.HaveCount(2);\n }\n\n [Fact]\n public void When_subject_is_null_and_expectation_is_enumerable_it_should_throw()\n {\n // Arrange\n IEnumerable subject = null;\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(Enumerable.Empty());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject*not to be *\");\n }\n\n [Fact]\n public void When_the_expectation_is_null_it_should_throw()\n {\n // Arrange\n int[,] actual =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual*to be *{{1, 2, 3}, {4, 5, 6}}*\");\n }\n\n [Fact]\n public void When_a_multi_dimensional_array_is_compared_to_null_it_should_throw()\n {\n // Arrange\n Array actual = null;\n\n int[,] expectation =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare a multi-dimensional array to *\");\n }\n\n [Fact]\n public void When_a_multi_dimensional_array_is_compared_to_a_non_array_it_should_throw()\n {\n // Arrange\n var actual = new object();\n\n int[,] expectation =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare a multi-dimensional array to something else*\");\n }\n\n [Fact]\n public void When_the_length_of_the_2nd_dimension_differs_between_the_arrays_it_should_throw()\n {\n // Arrange\n int[,] actual =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n int[,] expectation = { { 1, 2, 3 } };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dimension 0 to contain 1 item(s), but found 2*\");\n }\n\n [Fact]\n public void When_the_length_of_the_first_dimension_differs_between_the_arrays_it_should_throw()\n {\n // Arrange\n int[,] actual =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n int[,] expectation =\n {\n { 1, 2 },\n { 4, 5 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dimension 1 to contain 2 item(s), but found 3*\");\n }\n\n [Fact]\n public void When_the_number_of_dimensions_of_the_arrays_are_not_the_same_it_should_throw()\n {\n // Arrange\n#pragma warning disable format // VS and Rider disagree on how to format a multidimensional array initializer\n int[,,] actual =\n {\n {\n { 1 },\n { 2 },\n { 3 }\n },\n {\n { 4 },\n { 5 },\n { 6 }\n }\n };\n#pragma warning restore format\n\n int[,] expectation =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual*2 dimension(s)*but it has 3*\");\n }\n\n [Fact]\n public void When_the_other_dictionary_does_not_contain_enough_items_it_should_throw()\n {\n // Arrange\n var expected = new { Customers = new Dictionary { [\"Key1\"] = \"Value1\", [\"Key2\"] = \"Value2\" } };\n\n var subject = new { Customers = new Dictionary { [\"Key1\"] = \"Value1\" } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*Customers*dictionary*2 item(s)*but*misses*Key2*\");\n }\n\n [Fact]\n public void When_the_other_property_is_not_a_dictionary_it_should_throw()\n {\n // Arrange\n var expected = new { Customers = \"I am a string\" };\n\n var subject = new { Customers = new Dictionary { [\"Key2\"] = \"Value2\", [\"Key1\"] = \"Value1\" } };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*property*Customers*String*found*Dictionary*\");\n }\n\n [Fact]\n public void\n When_the_root_object_is_referenced_from_an_object_in_a_nested_collection_it_should_treat_it_as_a_cyclic_reference()\n {\n // Arrange\n var company1 = new MyCompany { Name = \"Company\" };\n var user1 = new MyUser { Name = \"User\", Company = company1 };\n company1.Users = [user1];\n company1.Logo = new MyCompanyLogo { Url = \"blank\", Company = company1, CreatedBy = user1 };\n\n var company2 = new MyCompany { Name = \"Company\" };\n var user2 = new MyUser { Name = \"User\", Company = company2 };\n company2.Users = [user2];\n company2.Logo = new MyCompanyLogo { Url = \"blank\", Company = company2, CreatedBy = user2 };\n\n // Act / Assert\n company1.Should().BeEquivalentTo(company2, o => o.IgnoringCyclicReferences());\n }\n\n [Fact]\n public void When_the_subject_contains_less_items_than_expected_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"*subject*to be a collection with 2 item(s), but*contains 1 item(s) less than*\");\n }\n\n [Fact]\n public void When_the_subject_contains_more_items_than_expected_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject*to be a collection with 1 item(s), but*contains 1 item(s) more than*\");\n }\n\n [Fact]\n public void When_the_subject_contains_same_number_of_items_and_both_contain_duplicates_it_should_succeed()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_the_subject_contains_same_number_of_items_but_expectation_contains_duplicates_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"John\", Age = 27, Id = 1 },\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected property subject[1].Name*to be *actual*\\\"Jane\\\" *\\\"John\\\"*expected*\");\n }\n\n [Fact]\n public void When_the_subject_contains_same_number_of_items_but_subject_contains_duplicates_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected property subject[1].Name*to be *actual*\\\"John\\\" *\\\"Jane\\\"*expected*\");\n }\n\n [Fact]\n public void\n When_two_collections_have_nested_members_of_the_contained_equivalent_but_not_equal_it_should_not_throw()\n {\n // Arrange\n var list1 = new[] { new { Nested = new ClassWithOnlyAProperty { Value = 1 } } };\n\n var list2 = new[] { new { Nested = new { Value = 1 } } };\n\n // Act / Assert\n list1.Should().BeEquivalentTo(list2, opts => opts);\n }\n\n [Fact]\n public void\n When_two_collections_have_properties_of_the_contained_items_excluded_but_still_differ_it_should_throw()\n {\n // Arrange\n KeyValuePair[] list1 = [new(1, 123)];\n KeyValuePair[] list2 = [new(2, 321)];\n\n // Act\n Action act = () => list1.Should().BeEquivalentTo(list2, config => config\n .Excluding(ctx => ctx.Key)\n .ComparingByMembers>());\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected property list1[0].Value*to be 321, but found 123.*\");\n }\n\n [Fact]\n public void\n When_two_equivalent_dictionaries_are_compared_directly_as_if_it_is_a_collection_it_should_succeed()\n {\n // Arrange\n var result = new Dictionary { [\"C\"] = null, [\"B\"] = 0, [\"A\"] = 0 };\n\n // Act / Assert\n result.Should().BeEquivalentTo(new Dictionary\n {\n [\"A\"] = 0,\n [\"B\"] = 0,\n [\"C\"] = null\n });\n }\n\n [Fact]\n public void When_two_equivalent_dictionaries_are_compared_directly_it_should_succeed()\n {\n // Arrange\n var result = new Dictionary { [\"C\"] = 0, [\"B\"] = 0, [\"A\"] = 0 };\n\n // Act / Assert\n result.Should().BeEquivalentTo(new Dictionary { [\"A\"] = 0, [\"B\"] = 0, [\"C\"] = 0 });\n }\n\n [Fact]\n public void When_two_lists_dont_contain_the_same_structural_equal_objects_it_should_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 30, Id = 2 }\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*subject[1].Age*30*24*\");\n }\n\n [Fact]\n public void When_two_lists_only_differ_in_excluded_properties_it_should_not_throw()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27 },\n new() { Name = \"Jane\", Age = 30 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation,\n options => options\n .ExcludingMissingMembers()\n .Excluding(c => c.Age));\n }\n\n [Fact]\n public void When_two_multi_dimensional_arrays_are_equivalent_it_should_not_throw()\n {\n // Arrange\n int[,] subject =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n int[,] expectation =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_multi_dimensional_arrays_are_not_equivalent_it_should_throw()\n {\n // Arrange\n int[,] actual =\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n };\n\n int[,] expectation =\n {\n { 1, 2, 4 },\n { 4, -5, 6 }\n };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*actual[0,2]*4*3*actual[1,1]*-5*5*\");\n }\n\n [Fact]\n public void When_two_multi_dimensional_arrays_have_empty_dimensions_they_should_be_equivalent()\n {\n // Arrange\n Array actual = new long[,] { { } };\n\n Array expectation = new long[,] { { } };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_multi_dimensional_arrays_are_empty_they_should_be_equivalent()\n {\n // Arrange\n Array actual = new long[0, 1] { };\n\n Array expectation = new long[0, 1] { };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_nested_dictionaries_contain_null_values_it_should_not_crash()\n {\n // Arrange\n var projection = new { ReferencedEquipment = new Dictionary { [1] = null } };\n\n var persistedProjection = new { ReferencedEquipment = new Dictionary { [1] = null } };\n\n // Act / Assert\n persistedProjection.Should().BeEquivalentTo(projection);\n }\n\n [Fact]\n public void When_two_nested_dictionaries_contain_null_values_it_should_not_crash2()\n {\n // Arrange\n var userId = Guid.NewGuid();\n\n var actual = new UserRolesLookupElement();\n actual.Add(userId, \"Admin\", \"Special\");\n\n var expected = new UserRolesLookupElement();\n expected.Add(userId, \"Admin\", \"Other\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*Roles[*][1]*Special*Other*\");\n }\n\n [Fact]\n public void When_two_nested_dictionaries_do_not_match_it_should_throw()\n {\n // Arrange\n var projection = new { ReferencedEquipment = new Dictionary { [1] = \"Bla1\" } };\n\n var persistedProjection = new { ReferencedEquipment = new Dictionary { [1] = \"Bla2\" } };\n\n // Act\n Action act = () => persistedProjection.Should().BeEquivalentTo(projection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*ReferencedEquipment[1]*Bla2*Bla1*\");\n }\n\n [Fact]\n public void When_two_ordered_lists_are_structurally_equivalent_it_should_succeed()\n {\n // Arrange\n var subject = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n var expectation = new List\n {\n new() { Name = \"John\", Age = 27, Id = 1 },\n new() { Name = \"Jane\", Age = 24, Id = 2 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_unordered_lists_are_structurally_equivalent_and_order_is_strict_it_should_fail()\n {\n // Arrange\n Customer[] subject =\n [\n new()\n { Name = \"John\", Age = 27, Id = 1 },\n new()\n { Name = \"Jane\", Age = 24, Id = 2 }\n ];\n\n var expectation = new Collection\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, options => options.WithStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected property subject[0].Name*John*Jane*subject[1].Name*Jane*John*\");\n }\n\n [Fact]\n public void When_two_unordered_lists_are_structurally_equivalent_and_order_was_reset_to_strict_it_should_fail()\n {\n // Arrange\n Customer[] subject =\n [\n new()\n { Name = \"John\", Age = 27, Id = 1 },\n new()\n { Name = \"Jane\", Age = 24, Id = 2 }\n ];\n\n var expectation = new Collection\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(\n expectation,\n options => options\n .WithStrictOrdering()\n .WithoutStrictOrdering()\n .WithStrictOrdering());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected property subject[0].Name*John*Jane*subject[1].Name*Jane*John*\");\n }\n\n [Fact]\n public void When_two_unordered_lists_are_structurally_equivalent_and_order_was_reset_to_not_strict_it_should_succeed()\n {\n // Arrange\n Customer[] subject =\n [\n new()\n { Name = \"John\", Age = 27, Id = 1 },\n new()\n { Name = \"Jane\", Age = 24, Id = 2 }\n ];\n\n var expectation = new Collection\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, x => x.WithStrictOrdering().WithoutStrictOrdering());\n }\n\n [Fact]\n public void When_two_unordered_lists_are_structurally_equivalent_it_should_succeed()\n {\n // Arrange\n Customer[] subject =\n [\n new()\n { Name = \"John\", Age = 27, Id = 1 },\n new()\n { Name = \"Jane\", Age = 24, Id = 2 }\n ];\n\n var expectation = new Collection\n {\n new() { Name = \"Jane\", Age = 24, Id = 2 },\n new() { Name = \"John\", Age = 27, Id = 1 }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_two_unordered_lists_contain_empty_different_objects_it_should_throw()\n {\n // Arrange\n var actual = new object[] { new() };\n var expected = new object[] { new() };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_two_unordered_lists_contain_null_in_subject_it_should_throw()\n {\n // Arrange\n var actual = new object[] { null };\n var expected = new object[] { new() };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_two_unordered_lists_contain_null_in_expectation_it_should_throw()\n {\n // Arrange\n var actual = new object[] { new() };\n var expected = new object[] { null };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Theory]\n [MemberData(nameof(ArrayTestData))]\n public void When_two_unordered_lists_contain_empty_objects_they_should_still_be_structurally_equivalent(TActual[] actual, TExpected[] expected)\n#pragma warning restore xUnit1039\n {\n // Act / Assert\n actual.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void When_an_exception_is_thrown_during_data_access_the_stack_trace_contains_the_original_site()\n {\n // Arrange\n var genericCollectionA = new List { new() };\n\n var genericCollectionB = new List { new() };\n\n var expectedTargetSite = typeof(ExceptionThrowingClass)\n .GetProperty(nameof(ExceptionThrowingClass.ExceptionThrowingProperty))!.GetMethod;\n\n // Act\n Action act = () => genericCollectionA.Should().BeEquivalentTo(genericCollectionB);\n\n // Assert\n act.Should().Throw().And.TargetSite.Should().Be(expectedTargetSite);\n }\n\n public static TheoryData ArrayTestData()\n {\n var arrays = new object[]\n {\n new int?[] { null, 1 }, new int?[] { 1, null }, new object[] { null, 1 }, new object[] { 1, null }\n };\n\n var pairs =\n from x in arrays\n from y in arrays\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n [Fact]\n public void Comparing_lots_of_complex_objects_should_still_be_fast()\n {\n // Arrange\n ClassWithLotsOfProperties GetObject(int i)\n {\n return new ClassWithLotsOfProperties\n {\n#pragma warning disable CA1305\n Id = i.ToString(),\n Value1 = i.ToString(),\n Value2 = i.ToString(),\n Value3 = i.ToString(),\n Value4 = i.ToString(),\n Value5 = i.ToString(),\n Value6 = i.ToString(),\n Value7 = i.ToString(),\n Value8 = i.ToString(),\n Value9 = i.ToString(),\n Value10 = i.ToString(),\n Value11 = i.ToString(),\n Value12 = i.ToString(),\n#pragma warning restore CA1305\n };\n }\n\n var actual = new List();\n var expectation = new List();\n\n var maxAmount = 100;\n\n for (var i = 0; i < maxAmount; i++)\n {\n actual.Add(GetObject(i));\n expectation.Add(GetObject(maxAmount - 1 - i));\n }\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.ExecutionTime().Should().BeLessThan(20.Seconds());\n }\n\n private class ClassWithLotsOfProperties\n {\n public string Id { get; set; }\n\n public string Value1 { get; set; }\n\n public string Value2 { get; set; }\n\n public string Value3 { get; set; }\n\n public string Value4 { get; set; }\n\n public string Value5 { get; set; }\n\n public string Value6 { get; set; }\n\n public string Value7 { get; set; }\n\n public string Value8 { get; set; }\n\n public string Value9 { get; set; }\n\n public string Value10 { get; set; }\n\n public string Value11 { get; set; }\n\n public string Value12 { get; set; }\n }\n\n private class LogbookEntryProjection\n {\n public virtual LogbookCode Logbook { get; set; }\n\n public virtual ICollection LogbookRelations { get; set; }\n }\n\n private class LogbookRelation\n {\n public virtual LogbookCode Logbook { get; set; }\n }\n\n private class LogbookCode\n {\n public LogbookCode(string key)\n {\n Key = key;\n }\n\n public string Key { get; }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/AssertionChainSpecs.Chaining.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\n/// \n/// The chaining API specs.\n/// \npublic partial class AssertionChainSpecs\n{\n public class Chaining\n {\n [Fact]\n public void A_successful_assertion_does_not_affect_the_chained_failing_assertion()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(condition: true)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second assertion\");\n\n // Arrange\n act.Should().Throw().WithMessage(\"*Second assertion*\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_next_one_with_arguments()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second {0}\", \"assertion\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second \\\"assertion\\\"\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_next_one_with_argument_providers()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second {0}\", () => \"assertion\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second \\\"assertion\\\"\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_next_one_with_a_fail_reason_function()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(() => new FailReason(\"Second {0}\", \"assertion\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second \\\"assertion\\\"\");\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_the_reason_should_be_part_of_consecutive_failures()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .BecauseOf(\"because reasons\")\n .FailWith(\"Expected{reason}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because reasons\");\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_the_reason_with_arguments_should_be_part_of_consecutive_failures()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .BecauseOf(\"because {0}\", \"reasons\")\n .FailWith(\"Expected{reason}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because reasons\");\n }\n\n [Fact]\n public void Passing_a_null_value_as_reason_does_not_fail()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .BecauseOf(null, \"only because for method disambiguity\")\n .ForCondition(false)\n .FailWith(\"First assertion\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void When_a_given_is_used_before_an_assertion_then_the_result_should_be_available_for_evaluation()\n {\n // Act / Assert\n AssertionChain.GetOrCreate()\n .Given(() => new[] { \"a\", \"b\" })\n .ForCondition(collection => collection.Length > 0)\n .FailWith(\"First assertion\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_evaluate_the_succeeding_given_statement()\n {\n // Arrange\n using var _ = new AssertionScope(new IgnoringFailuresAssertionStrategy());\n\n // Act / Assert\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .Given(() => throw new InvalidOperationException());\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_evaluate_the_succeeding_condition()\n {\n // Arrange\n bool secondConditionEvaluated = false;\n\n try\n {\n using var _ = new AssertionScope();\n\n // Act\n AssertionChain.GetOrCreate()\n .Given(() => (string)null)\n .ForCondition(s => s is not null)\n .FailWith(\"but is was null\")\n .Then\n .ForCondition(_ => secondConditionEvaluated = true)\n .FailWith(\"it should be 42\");\n }\n catch\n {\n // Ignore\n }\n\n // Assert\n secondConditionEvaluated.Should().BeFalse(\"because the 2nd condition should not be invoked\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_failure()\n {\n // Arrange\n var scope = new AssertionScope();\n\n // Act\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .ForCondition(false)\n .FailWith(\"Second assertion\");\n\n string[] failures = scope.Discard();\n scope.Dispose();\n\n Assert.Single(failures);\n Assert.Contains(\"First assertion\", failures);\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_failure_with_arguments()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second {0}\", \"assertion\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_failure_with_argument_providers()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(\"Second {0}\", () => \"assertion\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_failure_with_a_fail_reason_function()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .FailWith(() => new FailReason(\"Second {0}\", \"assertion\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_expectation()\n {\n // Act\n Action act = () =>\n {\n using var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectations are the root \", c => c\n .ForCondition(false)\n .FailWith(\"of disappointment\")\n .Then\n .WithExpectation(\"Assumptions are the root \", c2 => c2\n .FailWith(\"of all evil\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectations are the root of disappointment\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_expectation_with_arguments()\n {\n // Act\n Action act = () =>\n {\n using var scope = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectations are the {0} \", \"root\", c => c\n .ForCondition(false)\n .FailWith(\"of disappointment\")\n .Then\n .WithExpectation(\"Assumptions are the {0} \", \"root\", c2 => c2\n .FailWith(\"of all evil\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectations are the \\\"root\\\" of disappointment\");\n }\n\n [Fact]\n public void When_the_previous_assertion_failed_it_should_not_execute_the_succeeding_default_identifier()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .WithDefaultIdentifier(\"identifier\")\n .ForCondition(false)\n .FailWith(\"Expected {context}\")\n .Then\n .WithDefaultIdentifier(\"other\")\n .FailWith(\"Expected {context}\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected identifier\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_reasons_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .BecauseOf(\"because {0}\", \"whatever\")\n .ForCondition(false)\n .FailWith(\"Expected{reason}\")\n .Then\n .BecauseOf(\"because reasons\")\n .FailWith(\"Expected{reason}\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because whatever\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_reasons_with_arguments_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .BecauseOf(\"because {0}\", \"whatever\")\n .ForCondition(false)\n .FailWith(\"Expected{reason}\")\n .Then\n .BecauseOf(\"because {0}\", \"reasons\")\n .FailWith(\"Expected{reason}\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected because whatever\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_evaluate_the_succeeding_given_statement()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .Given(() => throw new InvalidOperationException());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_succeeding_expectation()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectations are the root \", chain => chain\n .ForCondition(true)\n .FailWith(\"of disappointment\")\n .Then\n .WithExpectation(\"Assumptions are the root \", innerChain => innerChain\n .FailWith(\"of all evil\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Assumptions are the root of all evil\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_succeeding_expectation_with_arguments()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectations are the {0} \", \"root\", c => c\n .ForCondition(true)\n .FailWith(\"of disappointment\")\n .Then\n .WithExpectation(\"Assumptions are the {0} \", \"root\", c2 => c2\n .FailWith(\"of all evil\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Assumptions are the \\\"root\\\" of all evil\");\n }\n\n [Fact]\n public void When_the_previous_assertion_succeeded_it_should_not_affect_the_succeeding_default_identifier()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithDefaultIdentifier(\"identifier\")\n .ForCondition(true)\n .FailWith(\"Expected {context}\")\n .Then\n .WithDefaultIdentifier(\"other\")\n .FailWith(\"Expected {context}\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected other\");\n }\n\n [Fact]\n public void Continuing_an_assertion_with_occurrence()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .WithExpectation(\"{expectedOccurrence} \", c => c\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"Second {0}\", \"assertion\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Exactly 1 time Second \\\"assertion\\\"*\");\n }\n\n [Fact]\n public void Continuing_an_assertion_with_occurrence_will_not_be_executed_when_first_assertion_fails()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .FailWith(\"First assertion\")\n .Then\n .WithExpectation(\"{expectedOccurrence} \", c => c\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"Second {0}\", \"assertion\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First assertion\");\n }\n\n [Fact]\n public void Continuing_an_assertion_with_occurrence_overrides_the_previous_defined_expectations()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"First expectation\", c => c\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .WithExpectation(\"{expectedOccurrence} \", c2 => c2\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"Second {0}\", \"assertion\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Exactly 1 time Second \\\"assertion\\\"*\");\n }\n\n [Fact]\n public void Continuing_an_assertion_after_occurrence_check_works()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"{expectedOccurrence} \", c => c\n .ForConstraint(Exactly.Once(), 1)\n .FailWith(\"First assertion\")\n .Then\n .WithExpectation(\"Second expectation \", c2 => c2\n .ForCondition(false)\n .FailWith(\"Second {0}\", \"assertion\")));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second expectation Second \\\"assertion\\\"*\");\n }\n\n [Fact]\n public void Continuing_an_assertion_with_occurrence_check_before_defining_expectation_works()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .FailWith(\"First assertion\")\n .Then\n .ForConstraint(Exactly.Once(), 2)\n .WithExpectation(\"Second expectation \", c => c\n .FailWith(\"Second {0}\", \"assertion\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second expectation Second \\\"assertion\\\"*\");\n }\n\n [Fact]\n public void Does_not_continue_a_chained_assertion_after_the_first_one_failed_the_occurrence_check()\n {\n // Arrange\n var scope = new AssertionScope();\n\n // Act\n AssertionChain.GetOrCreate()\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"First {0}\", \"assertion\")\n .Then\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"Second {0}\", \"assertion\");\n\n string[] failures = scope.Discard();\n\n // Assert\n Assert.Single(failures);\n Assert.Contains(\"First \\\"assertion\\\"\", failures);\n }\n\n [Fact]\n public void Discard_a_scope_after_continuing_chained_assertion()\n {\n // Arrange\n using var scope = new AssertionScope();\n\n // Act\n AssertionChain.GetOrCreate()\n .ForConstraint(Exactly.Once(), 2)\n .FailWith(\"First {0}\", \"assertion\");\n\n var failures = scope.Discard();\n\n // Assert\n Assert.Single(failures);\n Assert.Contains(\"First \\\"assertion\\\"\", failures);\n }\n\n // [Fact]\n // public void Get_info_about_line_breaks_from_parent_scope_after_continuing_chained_assertion()\n // {\n // // Arrange\n // using var scope = new AssertionScope();\n // scope.FormattingOptions.UseLineBreaks = true;\n //\n // // Act\n // var innerScope = AssertionChain.GetOrCreate()\n // .ForConstraint(Exactly.Once(), 1)\n // .FailWith(\"First {0}\", \"assertion\")\n // .Then\n // .UsingLineBreaks;\n //\n // // Assert\n // innerScope.UsingLineBreaks.Should().Be(scope.UsingLineBreaks);\n // }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/EventRaisingExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Events;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Provides extension methods for monitoring and querying events.\n/// \npublic static class EventRaisingExtensions\n{\n /// \n /// Asserts that all occurrences of the event originates from the .\n /// \n /// \n /// Returns only the events that comes from that sender.\n /// \n public static IEventRecording WithSender(this IEventRecording eventRecording, object expectedSender)\n {\n var eventsForSender = new List();\n var otherSenders = new List();\n var assertion = AssertionChain.GetOrCreate();\n\n foreach (OccurredEvent @event in eventRecording)\n {\n assertion\n .ForCondition(@event.Parameters.Length > 0)\n .FailWith(\"Expected event from sender {0}, \" +\n $\"but event {eventRecording.EventName} does not have any parameters\", expectedSender);\n\n if (assertion.Succeeded)\n {\n object sender = @event.Parameters[0];\n\n if (ReferenceEquals(sender, expectedSender))\n {\n eventsForSender.Add(@event);\n }\n else\n {\n otherSenders.Add(sender);\n }\n }\n }\n\n assertion\n .ForCondition(eventsForSender.Count > 0)\n .FailWith(\"Expected sender {0}, but found {1}.\",\n () => expectedSender,\n () => otherSenders.Distinct());\n\n return new FilteredEventRecording(eventRecording, eventsForSender);\n }\n\n /// \n /// Asserts that at least one occurrence of the events has some argument of the expected\n /// type that matches the given predicate.\n /// \n /// \n /// Returns only the events having some argument matching both type and predicate.\n /// \n /// is .\n public static IEventRecording WithArgs(this IEventRecording eventRecording, Expression> predicate)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n Func compiledPredicate = predicate.Compile();\n\n var eventsWithMatchingPredicate = new List();\n\n foreach (OccurredEvent @event in eventRecording)\n {\n IEnumerable typedParameters = @event.Parameters.OfType();\n\n if (typedParameters.Any(parameter => compiledPredicate(parameter)))\n {\n eventsWithMatchingPredicate.Add(@event);\n }\n }\n\n bool foundMatchingEvent = eventsWithMatchingPredicate.Count > 0;\n\n AssertionChain\n .GetOrCreate()\n .ForCondition(foundMatchingEvent)\n .FailWith(\"Expected at least one event with some argument of type <{0}> that matches {1}, but found none.\",\n typeof(T),\n predicate.Body);\n\n return new FilteredEventRecording(eventRecording, eventsWithMatchingPredicate);\n }\n\n /// \n /// Asserts that at least one occurrence of the events has arguments of the expected\n /// type that pairwise match all the given predicates.\n /// \n /// \n /// Returns only the events having arguments matching both type and all predicates.\n /// \n /// \n /// If a is provided as predicate argument, the corresponding event parameter value is ignored.\n /// \n public static IEventRecording WithArgs(this IEventRecording eventRecording, params Expression>[] predicates)\n {\n Func[] compiledPredicates = predicates.Select(p => p?.Compile()).ToArray();\n\n var eventsWithMatchingPredicate = new List();\n\n foreach (OccurredEvent @event in eventRecording)\n {\n var typedParameters = @event.Parameters.OfType().ToArray();\n bool hasArgumentOfRightType = typedParameters.Length > 0;\n\n if (predicates.Length > typedParameters.Length)\n {\n throw new ArgumentException(\n $\"Expected the event to have at least {predicates.Length} parameters of type {typeof(T).ToFormattedString()}, but only found {typedParameters.Length}.\");\n }\n\n bool isMatch = hasArgumentOfRightType;\n\n for (int index = 0; index < predicates.Length && isMatch; index++)\n {\n isMatch = compiledPredicates[index]?.Invoke(typedParameters[index]) ?? true;\n }\n\n if (isMatch)\n {\n eventsWithMatchingPredicate.Add(@event);\n }\n }\n\n bool foundMatchingEvent = eventsWithMatchingPredicate.Count > 0;\n\n if (!foundMatchingEvent)\n {\n AssertionChain\n .GetOrCreate()\n .FailWith(\n \"Expected at least one event with some arguments of type <{0}> that pairwise match {1}, but found none.\",\n typeof(T),\n string.Join(\" | \", predicates.Where(p => p is not null).Select(p => p.Body.ToString())));\n }\n\n return new FilteredEventRecording(eventRecording, eventsWithMatchingPredicate);\n }\n\n /// \n /// Asserts that all occurrences of the events has arguments of type \n /// and are for property .\n /// \n /// \n /// The property name for which the property changed events should have been raised.\n /// \n /// \n /// Returns only the property changed events affecting the particular property name.\n /// \n /// \n /// If a or string.Empty is provided as property name, the events are return as-is.\n /// \n internal static IEventRecording WithPropertyChangeFor(this IEventRecording eventRecording, string propertyName)\n {\n if (string.IsNullOrEmpty(propertyName))\n {\n return eventRecording;\n }\n\n IEnumerable eventsForPropertyName =\n eventRecording.Where(@event => @event.IsAffectingPropertyName(propertyName))\n .ToList();\n\n return new FilteredEventRecording(eventRecording, eventsForPropertyName);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/AggregateExceptionValueFormatter.cs", "using System;\nusing static System.FormattableString;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class AggregateExceptionValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is AggregateException;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var exception = (AggregateException)value;\n\n if (exception.InnerExceptions.Count == 1)\n {\n formattedGraph.AddFragment(\"(aggregated) \");\n\n formatChild(\"inner\", exception.InnerException, formattedGraph);\n }\n else\n {\n formattedGraph.AddLine(Invariant($\"{exception.InnerExceptions.Count} (aggregated) exceptions:\"));\n\n foreach (Exception innerException in exception.InnerExceptions)\n {\n formattedGraph.AddLine(string.Empty);\n formatChild(\"InnerException\", innerException, formattedGraph);\n }\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/AssertionScope.cs", "using System;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents an implicit or explicit scope within which multiple assertions can be collected.\n/// \n/// \n/// This class is supposed to have a very short lifetime and is not safe to be used in assertion that cross thread-boundaries\n/// such as when using or .\n/// \npublic sealed class AssertionScope : IDisposable\n{\n private readonly IAssertionStrategy assertionStrategy;\n\n /// \n /// The default scopes, which were implicitly created by accessing .\n /// \n private static readonly AsyncLocal DefaultScope = new();\n private static readonly AsyncLocal CurrentScope = new();\n private readonly Func callerIdentityProvider = () => CallerIdentifier.DetermineCallerIdentity();\n private readonly ContextDataDictionary reportableData = new();\n private readonly StringBuilder tracing = new();\n\n#pragma warning disable CA2213 // Disposable fields should be disposed\n private AssertionScope parent;\n#pragma warning restore CA2213\n\n /// \n /// Starts an unnamed scope within which multiple assertions can be executed\n /// and which will not throw until the scope is disposed.\n /// \n public AssertionScope()\n : this(() => null, new CollectingAssertionStrategy())\n {\n }\n\n /// \n /// Starts a named scope within which multiple assertions can be executed\n /// and which will not throw until the scope is disposed.\n /// \n public AssertionScope(string name)\n : this(() => name, new CollectingAssertionStrategy())\n {\n }\n\n /// \n /// Starts a new scope based on the given assertion strategy.\n /// \n /// The assertion strategy for this scope.\n /// is .\n public AssertionScope(IAssertionStrategy assertionStrategy)\n : this(() => null, assertionStrategy)\n {\n }\n\n /// \n /// Starts a named scope within which multiple assertions can be executed\n /// and which will not throw until the scope is disposed.\n /// \n public AssertionScope(Func name)\n : this(name, new CollectingAssertionStrategy())\n {\n }\n\n /// \n /// Starts a new scope based on the given assertion strategy and parent assertion scope\n /// \n /// The assertion strategy for this scope.\n /// is .\n private AssertionScope(Func name, IAssertionStrategy assertionStrategy)\n {\n parent = GetParentScope();\n CurrentScope.Value = this;\n\n this.assertionStrategy = assertionStrategy\n ?? throw new ArgumentNullException(nameof(assertionStrategy));\n\n if (parent is not null)\n {\n // Combine the existing Name with the parent.Name if it exists.\n Name = () =>\n {\n var parentName = parent.Name();\n if (parentName.IsNullOrEmpty())\n {\n return name();\n }\n\n if (name().IsNullOrEmpty())\n {\n return parentName;\n }\n\n return parentName + \"/\" + name();\n };\n\n callerIdentityProvider = parent.callerIdentityProvider;\n FormattingOptions = parent.FormattingOptions.Clone();\n }\n else\n {\n Name = name;\n }\n }\n\n /// \n /// Get parent scope.\n /// \n /// The parent scope is any explicitly opened , except\n /// for the implicitly opened through access to or\n /// .\n /// \n /// \n /// The parent scope\n private static AssertionScope GetParentScope()\n {\n if (CurrentScope.Value is not null && CurrentScope.Value != DefaultScope.Value)\n {\n return CurrentScope.Value;\n }\n\n return null;\n }\n\n /// \n /// Gets or sets the name of the current assertion scope, e.g. the path of the object graph\n /// that is being asserted on.\n /// \n /// \n /// The context is provided by a which\n /// only gets evaluated when its value is actually needed (in most cases during a failure).\n /// \n public Func Name { get; }\n\n /// \n /// Gets the current thread-specific assertion scope.\n /// \n public static AssertionScope Current\n {\n get\n {\n if (CurrentScope.Value is not null)\n {\n return CurrentScope.Value;\n }\n\n DefaultScope.Value ??= new AssertionScope(() => null, new DefaultAssertionStrategy());\n return DefaultScope.Value;\n }\n }\n\n /// \n /// Exposes the options the scope will use for formatting objects in case an assertion fails.\n /// \n public FormattingOptions FormattingOptions { get; } = AssertionConfiguration.Current.Formatting.Clone();\n\n /// \n /// Adds a pre-formatted failure message to the current scope.\n /// \n public void AddPreFormattedFailure(string formattedFailureMessage)\n {\n assertionStrategy.HandleFailure(formattedFailureMessage);\n }\n\n /// \n /// Adds some information to the assertion scope that will be included in the message\n /// that is emitted if an assertion fails.\n /// \n internal void AddReportable(string key, string value)\n {\n reportableData.Add(new ContextDataDictionary.DataItem(key, value, reportable: true, requiresFormatting: false));\n }\n\n /// \n /// Adds some information to the assertion scope that will be included in the message\n /// that is emitted if an assertion fails. The value is only calculated on failure.\n /// \n internal void AddReportable(string key, Func valueFunc)\n {\n reportableData.Add(new ContextDataDictionary.DataItem(key, new DeferredReportable(valueFunc), reportable: true,\n requiresFormatting: false));\n }\n\n /// \n /// Adds a block of tracing to the scope for reporting when an assertion fails.\n /// \n public void AppendTracing(string tracingBlock)\n {\n tracing.Append(tracingBlock);\n }\n\n /// \n /// Returns all failures that happened up to this point and ensures they will not cause\n /// to fail the assertion.\n /// \n public string[] Discard()\n {\n return assertionStrategy.DiscardFailures().ToArray();\n }\n\n public bool HasFailures()\n {\n return assertionStrategy.FailureMessages.Any();\n }\n\n /// \n public void Dispose()\n {\n CurrentScope.Value = parent;\n\n if (parent is not null)\n {\n foreach (string failureMessage in assertionStrategy.FailureMessages)\n {\n parent.assertionStrategy.HandleFailure(failureMessage);\n }\n\n parent.reportableData.Add(reportableData);\n parent.AppendTracing(tracing.ToString());\n\n parent = null;\n }\n else\n {\n if (tracing.Length > 0)\n {\n reportableData.Add(new ContextDataDictionary.DataItem(\"trace\", tracing.ToString(), reportable: true, requiresFormatting: false));\n }\n\n assertionStrategy.ThrowIfAny(reportableData.GetReportable());\n }\n }\n\n private sealed class DeferredReportable(Func valueFunc)\n {\n private readonly Lazy lazyValue = new(valueFunc);\n\n public override string ToString() => lazyValue.Value;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentifier.cs", "using System;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Text.RegularExpressions;\nusing System.Threading;\nusing AwesomeAssertions.CallerIdentification;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Tries to extract the name of the variable or invocation on which the assertion is executed.\n/// \n// REFACTOR: Should be internal and treated as an implementation detail of the AssertionScope\npublic static class CallerIdentifier\n{\n public static Action Logger { get; set; } = _ => { };\n\n public static string DetermineCallerIdentity()\n {\n string caller = null;\n\n try\n {\n var stack = new StackTrace(fNeedFileInfo: true);\n\n var allStackFrames = GetFrames(stack);\n\n int searchStart = allStackFrames.Length - 1;\n\n if (StartStackSearchAfterStackFrame.Value is not null)\n {\n searchStart = Array.FindLastIndex(\n allStackFrames,\n allStackFrames.Length - StartStackSearchAfterStackFrame.Value.SkipStackFrameCount,\n frame => !IsCurrentAssembly(frame));\n }\n\n int lastUserStackFrameBeforeAwesomeAssertionsCodeIndex = Array.FindIndex(\n allStackFrames,\n startIndex: 0,\n count: searchStart + 1,\n frame => !IsCurrentAssembly(frame) && !IsDynamic(frame) && !IsDotNet(frame));\n\n for (int i = lastUserStackFrameBeforeAwesomeAssertionsCodeIndex; i < allStackFrames.Length; i++)\n {\n var frame = allStackFrames[i];\n\n Logger(frame.ToString());\n\n if (frame.GetMethod() is not null\n && !IsDynamic(frame)\n && !IsDotNet(frame)\n && !IsCustomAssertion(frame)\n && !IsCurrentAssembly(frame))\n {\n caller = ExtractVariableNameFrom(frame);\n break;\n }\n }\n }\n catch (Exception e)\n {\n // Ignore exceptions, as determination of caller identity is only a nice-to-have\n Logger(e.ToString());\n }\n\n return caller;\n }\n\n private sealed class StackFrameReference : IDisposable\n {\n public int SkipStackFrameCount { get; }\n\n private readonly StackFrameReference previousReference;\n\n public StackFrameReference()\n {\n var stack = new StackTrace();\n\n var allStackFrames = GetFrames(stack);\n\n int firstUserCodeFrameIndex = 0;\n\n while (firstUserCodeFrameIndex < allStackFrames.Length\n && IsCurrentAssembly(allStackFrames[firstUserCodeFrameIndex]))\n {\n firstUserCodeFrameIndex++;\n }\n\n SkipStackFrameCount = (allStackFrames.Length - firstUserCodeFrameIndex) + 1;\n\n previousReference = StartStackSearchAfterStackFrame.Value;\n StartStackSearchAfterStackFrame.Value = this;\n }\n\n public void Dispose()\n {\n StartStackSearchAfterStackFrame.Value = previousReference;\n }\n }\n\n private static readonly AsyncLocal StartStackSearchAfterStackFrame = new();\n\n internal static IDisposable OverrideStackSearchUsingCurrentScope()\n {\n return new StackFrameReference();\n }\n\n internal static bool OnlyOneAssertionScopeOnCallStack()\n {\n var allStackFrames = GetFrames(new StackTrace());\n\n int firstNonAwesomeAssertionsStackFrameIndex = Array.FindIndex(\n allStackFrames,\n frame => !IsCurrentAssembly(frame));\n\n if (firstNonAwesomeAssertionsStackFrameIndex < 0)\n {\n return true;\n }\n\n int startOfSecondAwesomeAssertionsScopeStackFrameIndex = Array.FindIndex(\n allStackFrames,\n startIndex: firstNonAwesomeAssertionsStackFrameIndex + 1,\n frame => IsCurrentAssembly(frame));\n\n return startOfSecondAwesomeAssertionsScopeStackFrameIndex < 0;\n }\n\n private static bool IsCustomAssertion(StackFrame frame)\n {\n MethodBase getMethod = frame.GetMethod();\n\n if (getMethod is not null)\n {\n return\n getMethod.IsDecoratedWithOrInherit() ||\n IsCustomAssertionClass(getMethod.DeclaringType) ||\n getMethod.ReflectedType?.Assembly.IsDefined(typeof(CustomAssertionsAssemblyAttribute)) == true;\n }\n\n return false;\n }\n\n /// \n /// Check if is a custom assertion class.\n /// \n /// \n /// Checking also explicitly the declaring type is necessary for DisplayClasses, which can't be marked\n /// themselves like normal nested classes.\n /// \n /// The class type to check\n /// True if type is a custom assertion class, or nested inside such a class.\n private static bool IsCustomAssertionClass(Type type)\n => type is not null && (type.IsDecoratedWithOrInherit() || IsCustomAssertionClass(type.DeclaringType));\n\n private static bool IsDynamic(StackFrame frame)\n {\n return frame.GetMethod() is { DeclaringType: null };\n }\n\n private static bool IsCurrentAssembly(StackFrame frame)\n {\n return frame.GetMethod()?.DeclaringType?.Assembly == typeof(CallerIdentifier).Assembly;\n }\n\n private static bool IsDotNet(StackFrame frame)\n {\n var frameNamespace = frame.GetMethod()?.DeclaringType?.Namespace;\n const StringComparison comparisonType = StringComparison.OrdinalIgnoreCase;\n\n return frameNamespace?.StartsWith(\"system.\", comparisonType) == true ||\n frameNamespace?.Equals(\"system\", comparisonType) == true;\n }\n\n private static bool IsCompilerServices(StackFrame frame)\n {\n return frame.GetMethod()?.DeclaringType?.Namespace is \"System.Runtime.CompilerServices\";\n }\n\n private static string ExtractVariableNameFrom(StackFrame frame)\n {\n string caller = null;\n string statement = GetSourceCodeStatementFrom(frame);\n\n if (!string.IsNullOrEmpty(statement))\n {\n Logger(statement);\n\n if (!IsBooleanLiteral(statement) && !IsNumeric(statement) && !IsStringLiteral(statement) &&\n !StartsWithNewKeyword(statement))\n {\n caller = statement;\n }\n }\n\n return caller;\n }\n\n private static string GetSourceCodeStatementFrom(StackFrame frame)\n {\n string fileName = frame.GetFileName();\n int expectedLineNumber = frame.GetFileLineNumber();\n\n if (string.IsNullOrEmpty(fileName) || expectedLineNumber == 0)\n {\n return null;\n }\n\n try\n {\n using var reader = new StreamReader(File.OpenRead(fileName));\n string line;\n int currentLine = 1;\n\n while ((line = reader.ReadLine()) is not null && currentLine < expectedLineNumber)\n {\n currentLine++;\n }\n\n return currentLine == expectedLineNumber\n && line != null\n ? GetSourceCodeStatementFrom(frame, reader, line)\n : null;\n }\n catch\n {\n // We don't care. Just assume the symbol file is not available or unreadable\n return null;\n }\n }\n\n private static string GetSourceCodeStatementFrom(StackFrame frame, StreamReader reader, string line)\n {\n int column = frame.GetFileColumnNumber();\n\n if (column > 0)\n {\n line = line.Substring(Math.Min(column - 1, line.Length - 1));\n }\n\n var sb = new CallerStatementBuilder();\n\n do\n {\n sb.Append(line);\n }\n while (!sb.IsDone() && (line = reader.ReadLine()) != null);\n\n return sb.ToString();\n }\n\n private static bool StartsWithNewKeyword(string candidate)\n {\n return Regex.IsMatch(candidate, @\"(?:^|s+)new(?:\\s?\\[|\\s?\\{|\\s\\w+)\");\n }\n\n private static bool IsStringLiteral(string candidate)\n {\n return candidate.StartsWith('\\\"');\n }\n\n private static bool IsNumeric(string candidate)\n {\n const NumberStyles numberStyle = NumberStyles.Float | NumberStyles.AllowThousands;\n return double.TryParse(candidate, numberStyle, CultureInfo.InvariantCulture, out _);\n }\n\n private static bool IsBooleanLiteral(string candidate)\n {\n return candidate is \"true\" or \"false\";\n }\n\n private static StackFrame[] GetFrames(StackTrace stack)\n {\n var frames = stack.GetFrames();\n#if !NET6_0_OR_GREATER\n if (frames == null)\n {\n return [];\n }\n#endif\n return frames\n .Where(frame => !IsCompilerServices(frame))\n .ToArray();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventAssertions.cs", "using System;\nusing System.ComponentModel;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Provides convenient assertion methods on a that can be\n/// used to assert that certain events have been raised.\n/// \npublic class EventAssertions : ReferenceTypeAssertions>\n{\n private const string PropertyChangedEventName = nameof(INotifyPropertyChanged.PropertyChanged);\n private readonly AssertionChain assertionChain;\n\n protected internal EventAssertions(IMonitor monitor, AssertionChain assertionChain)\n : base(monitor.Subject, assertionChain)\n {\n this.assertionChain = assertionChain;\n Monitor = monitor;\n }\n\n /// \n /// Gets the which is being asserted.\n /// \n public IMonitor Monitor { get; }\n\n /// \n /// Asserts that an object has raised a particular event at least once.\n /// \n /// \n /// The name of the event that should have been raised.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public IEventRecording Raise(string eventName, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n IEventRecording recording = Monitor.GetRecordingFor(eventName);\n\n if (!recording.Any())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected object {0} to raise event {1}{reason}, but it did not.\", Monitor.Subject, eventName);\n }\n\n return recording;\n }\n\n /// \n /// Asserts that an object has not raised a particular event.\n /// \n /// \n /// The name of the event that should not be raised.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public void NotRaise(string eventName, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n IEventRecording events = Monitor.GetRecordingFor(eventName);\n\n if (events.Any())\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected object {0} to not raise event {1}{reason}, but it did.\", Monitor.Subject, eventName);\n }\n }\n\n /// \n /// Asserts that an object has raised the event for a particular property.\n /// \n /// \n /// A lambda expression referring to the property for which the property changed event should have been raised, or\n /// to refer to all properties.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Returns only the events having arguments of type targeting the property.\n /// \n public IEventRecording RaisePropertyChangeFor(Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n string propertyName = propertyExpression?.GetPropertyInfo().Name;\n\n IEventRecording recording = Monitor.GetRecordingFor(PropertyChangedEventName);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(recording.Any())\n .FailWith(\n \"Expected object {0} to raise event {1} for property {2}{reason}, but it did not raise that event at all.\",\n Monitor.Subject, PropertyChangedEventName, propertyName);\n\n if (assertionChain.Succeeded)\n {\n var actualPropertyNames = recording\n .SelectMany(@event => @event.Parameters.OfType())\n .Select(eventArgs => eventArgs.PropertyName)\n .Distinct()\n .ToArray();\n\n assertionChain\n .ForCondition(actualPropertyNames.Contains(propertyName))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected object {0} to raise event {1} for property {2}{reason}, but it was only raised for {3}.\",\n Monitor.Subject, PropertyChangedEventName, propertyName, actualPropertyNames);\n }\n\n return recording.WithPropertyChangeFor(propertyName);\n }\n\n /// \n /// Asserts that an object has not raised the event for a particular property.\n /// \n /// \n /// A lambda expression referring to the property for which the property changed event should have been raised.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public void NotRaisePropertyChangeFor(Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n IEventRecording recording = Monitor.GetRecordingFor(PropertyChangedEventName);\n\n string propertyName = propertyExpression?.GetPropertyInfo().Name;\n\n if (propertyName is null)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!recording.Any())\n .FailWith(\n \"Did not expect object {0} to raise the {1} event{reason}, but it did.\",\n Monitor.Subject, PropertyChangedEventName);\n }\n else\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!recording.Any(@event => @event.IsAffectingPropertyName(propertyName)))\n .FailWith(\n \"Did not expect object {0} to raise the {1} event for property {2}{reason}, but it did.\",\n Monitor.Subject, PropertyChangedEventName, propertyName);\n }\n }\n\n protected override string Identifier => \"subject\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/TypeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a meets certain expectations.\n/// \n[DebuggerNonUserCode]\npublic class TypeAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public TypeAssertions(Type type, AssertionChain assertionChain)\n : base(type, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current is equal to the specified type.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return Be(typeof(TExpected), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is equal to the specified type.\n /// \n /// The expected type\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(Type expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject == expected)\n .FailWith(() => GetFailReasonIfTypesAreDifferent(Subject, expected));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts than an instance of the subject type is assignable variable of type .\n /// \n /// The type to which instances of the type should be assignable.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public new AndConstraint BeAssignableTo([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return BeAssignableTo(typeof(T), because, becauseArgs);\n }\n\n /// \n /// Asserts than an instance of the subject type is assignable variable of given .\n /// \n /// The type to which instances of the type should be assignable.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public new AndConstraint BeAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n bool isAssignable = type.IsGenericTypeDefinition\n ? Subject.IsAssignableToOpenGeneric(type)\n : type.IsAssignableFrom(Subject);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(isAssignable)\n .FailWith(\"Expected {context:type} {0} to be assignable to {1}{reason}, but it is not.\",\n Subject, type);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts than an instance of the subject type is not assignable variable of type .\n /// \n /// The type to which instances of the type should not be assignable.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n public new AndConstraint NotBeAssignableTo([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBeAssignableTo(typeof(T), because, becauseArgs);\n }\n\n /// \n /// Asserts than an instance of the subject type is not assignable variable of given .\n /// \n /// The type to which instances of the type should not be assignable.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public new AndConstraint NotBeAssignableTo(Type type,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(type);\n\n bool isAssignable = type.IsGenericTypeDefinition\n ? Subject.IsAssignableToOpenGeneric(type)\n : type.IsAssignableFrom(Subject);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!isAssignable)\n .FailWith(\"Expected {context:type} {0} to not be assignable to {1}{reason}, but it is.\",\n Subject, type);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Creates an error message in case the specified type differs from the\n /// type.\n /// \n /// \n /// A that describes that the two specified types are not the same.\n /// \n private static FailReason GetFailReasonIfTypesAreDifferent(Type actual, Type expected)\n {\n string expectedType = expected.ToFormattedString();\n string actualType = actual.ToFormattedString();\n\n if (expectedType == actualType)\n {\n expectedType = $\"[{expected.AssemblyQualifiedName}]\";\n actualType = $\"[{actual.AssemblyQualifiedName}]\";\n }\n\n return new FailReason($\"Expected type to be {expectedType}{{reason}}, but found {actualType}.\");\n }\n\n /// \n /// Asserts that the current type is not equal to the specified type.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotBe(typeof(TUnexpected), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current type is not equal to the specified type.\n /// \n /// The unexpected type\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(Type unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject != unexpected)\n .FailWith(() => GetFailReasonIfTypesAreEqual(Subject, unexpected));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Creates an error message in case the specified type equals the\n /// type.\n /// \n /// \n /// A that describes that the two specified types are the same.\n /// \n private static FailReason GetFailReasonIfTypesAreEqual(Type actual, Type unexpected)\n {\n string unexpectedType = unexpected.AsFormattableTypeDefinition().ToFormattedString();\n string actualType = actual.AsFormattableTypeDefinition().ToFormattedString();\n\n if (unexpected is not null && unexpectedType == actualType)\n {\n unexpectedType = $\"[{unexpected.AssemblyQualifiedName}]\";\n }\n\n return new FailReason($\"Expected type not to be {unexpectedType}{{reason}}, but it is.\");\n }\n\n /// \n /// Asserts that the current is decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint BeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n IEnumerable attributes = Subject.GetMatchingAttributes();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(attributes.Any())\n .FailWith(\"Expected type {0} to be decorated with {1}{reason}, but the attribute was not found.\",\n Subject, typeof(TAttribute));\n\n return new AndWhichConstraint(this, attributes);\n }\n\n /// \n /// Asserts that the current is decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint BeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n BeDecoratedWith(because, becauseArgs);\n\n IEnumerable attributes = Subject.GetMatchingAttributes(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(attributes.Any())\n .FailWith(\n \"Expected type {0} to be decorated with {1} that matches {2}{reason}, but no matching attribute was found.\",\n Subject, typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndWhichConstraint(this, attributes);\n }\n\n /// \n /// Asserts that the current is decorated with, or inherits from a parent class, the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint BeDecoratedWithOrInherit(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n IEnumerable attributes = Subject.GetMatchingOrInheritedAttributes();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(attributes.Any())\n .FailWith(\"Expected type {0} to be decorated with or inherit {1}{reason}, but the attribute was not found.\",\n Subject, typeof(TAttribute));\n\n return new AndWhichConstraint(this, attributes);\n }\n\n /// \n /// Asserts that the current is decorated with, or inherits from a parent class, an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint BeDecoratedWithOrInherit(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n BeDecoratedWithOrInherit(because, becauseArgs);\n\n IEnumerable attributes = Subject.GetMatchingOrInheritedAttributes(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(attributes.Any())\n .FailWith(\n \"Expected type {0} to be decorated with or inherit {1} that matches {2}{reason}\" +\n \", but no matching attribute was found.\", Subject, typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndWhichConstraint(this, attributes);\n }\n\n /// \n /// Asserts that the current is not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TAttribute : Attribute\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsDecoratedWith())\n .FailWith(\"Expected type {0} to not be decorated with {1}{reason}, but the attribute was found.\",\n Subject, typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with an attribute of type\n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsDecoratedWith(isMatchingAttributePredicate))\n .FailWith(\n \"Expected type {0} to not be decorated with {1} that matches {2}{reason}, but a matching attribute was found.\",\n Subject, typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with and does not inherit from a parent class,\n /// the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWithOrInherit(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsDecoratedWithOrInherit())\n .FailWith(\"Expected type {0} to not be decorated with or inherit {1}{reason}, but the attribute was found.\",\n Subject, typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with and does not inherit from a parent class, an\n /// attribute of type that matches the specified\n /// .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWithOrInherit(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsDecoratedWithOrInherit(isMatchingAttributePredicate))\n .FailWith(\n \"Expected type {0} to not be decorated with or inherit {1} that matches {2}{reason}\" +\n \", but a matching attribute was found.\",\n Subject, typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current implements .\n /// \n /// The interface that should be implemented.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Implement(Type interfaceType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n\n AssertSubjectImplements(interfaceType, because, becauseArgs);\n\n return new AndConstraint(this);\n }\n\n private bool AssertSubjectImplements(Type interfaceType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n bool containsInterface = interfaceType.IsAssignableFrom(Subject) && interfaceType != Subject;\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type {0} to implement interface {1}{reason}\", Subject, interfaceType, chain => chain\n .ForCondition(interfaceType.IsInterface)\n .FailWith(\", but {0} is not an interface.\", interfaceType)\n .Then\n .ForCondition(containsInterface)\n .FailWith(\", but it does not.\"));\n\n return assertionChain.Succeeded;\n }\n\n /// \n /// Asserts that the current implements interface .\n /// \n /// The interface that should be implemented.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Implement([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TInterface : class\n {\n return Implement(typeof(TInterface), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not implement .\n /// \n /// The interface that should be not implemented.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotImplement(Type interfaceType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n\n bool containsInterface = interfaceType.IsAssignableFrom(Subject) && interfaceType != Subject;\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type {0} to not implement interface {1}{reason}\", Subject, interfaceType, chain => chain\n .ForCondition(interfaceType.IsInterface)\n .FailWith(\", but {0} is not an interface.\", interfaceType)\n .Then\n .ForCondition(!containsInterface)\n .FailWith(\", but it does.\", interfaceType));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not implement interface .\n /// \n /// The interface that should not be implemented.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotImplement([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TInterface : class\n {\n return NotImplement(typeof(TInterface), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is derived from .\n /// \n /// The type that should be derived from.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeDerivedFrom(Type baseType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(baseType);\n\n bool isDerivedFrom = baseType.IsGenericTypeDefinition\n ? Subject.IsDerivedFromOpenGeneric(baseType)\n : Subject.IsSubclassOf(baseType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type {0} to be derived from {1}{reason}\", Subject, baseType, chain => chain\n .ForCondition(!baseType.IsInterface)\n .FailWith(\", but {0} is an interface.\", baseType)\n .Then\n .ForCondition(isDerivedFrom)\n .FailWith(\", but it is not.\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is derived from .\n /// \n /// The type that should be derived from.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDerivedFrom([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TBaseClass : class\n {\n return BeDerivedFrom(typeof(TBaseClass), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is not derived from .\n /// \n /// The type that should not be derived from.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDerivedFrom(Type baseType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(baseType);\n\n bool isDerivedFrom = baseType.IsGenericTypeDefinition\n ? Subject.IsDerivedFromOpenGeneric(baseType)\n : Subject.IsSubclassOf(baseType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected type {0} not to be derived from {1}{reason}\", Subject, baseType, chain => chain\n .ForCondition(!baseType.IsInterface)\n .FailWith(\", but {0} is an interface.\", baseType)\n .Then\n .ForCondition(!isDerivedFrom)\n .FailWith(\", but it is.\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not derived from .\n /// \n /// The type that should not be derived from.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDerivedFrom([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TBaseClass : class\n {\n return NotBeDerivedFrom(typeof(TBaseClass), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is sealed.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint BeSealed([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be sealed{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.IsCSharpSealed())\n .FailWith(\"Expected type {0} to be sealed{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not sealed.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint NotBeSealed([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type not to be sealed{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsCSharpSealed())\n .FailWith(\"Expected type {0} not to be sealed{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is abstract.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint BeAbstract([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be abstract{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.IsCSharpAbstract())\n .FailWith(\"Expected {context:type} {0} to be abstract{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not abstract.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint NotBeAbstract([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type not to be abstract{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsCSharpAbstract())\n .FailWith(\"Expected type {0} not to be abstract{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is static.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint BeStatic([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type to be static{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.IsCSharpStatic())\n .FailWith(\"Expected type {0} to be static{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not static.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a class.\n public AndConstraint NotBeStatic([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected type not to be static{reason}, but {context:type} is .\");\n\n if (assertionChain.Succeeded)\n {\n AssertThatSubjectIsClass();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.IsCSharpStatic())\n .FailWith(\"Expected type {0} not to be static{reason}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a property named .\n /// \n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint HaveProperty(\n string name, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Cannot determine if a type has a property named {name} if the type is .\");\n\n PropertyInfo propertyInfo = null;\n\n if (assertionChain.Succeeded)\n {\n propertyInfo = Subject.FindPropertyByName(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is not null)\n .FailWith(() =>\n {\n string subjectDescription = assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : Subject.ToFormattedString();\n\n return new FailReason($\"Expected {subjectDescription} to have a property {name}{{reason}}, but it does not.\");\n });\n }\n\n return new AndWhichConstraint(this, propertyInfo);\n }\n\n /// \n /// Asserts that the current has a property of type named\n /// .\n /// \n /// The type of the property.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n public AndWhichConstraint HaveProperty(\n Type propertyType, string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(propertyType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Cannot determine if a type has a property named {name} if the type is .\");\n\n PropertyInfo propertyInfo = null;\n\n if (assertionChain.Succeeded)\n {\n propertyInfo = Subject.FindPropertyByName(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is not null)\n .FailWith(() =>\n {\n string subjectDescription = assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : Subject.ToFormattedString();\n\n return new FailReason(\n $\"Expected {subjectDescription} to have a property {name} of type {{0}}{{reason}}, but it does not.\",\n propertyType);\n })\n .Then\n .ForCondition(propertyInfo.PropertyType == propertyType)\n .FailWith($\"Expected property {propertyInfo.Name} to be of type {{0}}{{reason}}, but it is not.\",\n propertyType);\n }\n\n return new AndWhichConstraint(this, propertyInfo);\n }\n\n /// \n /// Asserts that the current has a property of type named\n /// .\n /// \n /// The type of the property.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint HaveProperty(\n string name, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveProperty(typeof(TProperty), name, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not have a property named .\n /// \n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotHaveProperty(string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Cannot determine if a type has an unexpected property named {name} if the type is .\");\n\n if (assertionChain.Succeeded)\n {\n PropertyInfo propertyInfo = Subject.FindPropertyByName(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is null)\n .FailWith(() =>\n {\n string subjectDescription = assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : Subject.ToFormattedString();\n\n return new FailReason(\n $\"Did not expect {subjectDescription} to have a property {propertyInfo?.Name}{{reason}}, but it does.\");\n });\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current explicitly implements a property named\n /// from interface .\n /// \n /// The type of the interface.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n public AndConstraint HaveExplicitProperty(\n Type interfaceType, string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {{context:type}} to explicitly implement {{0}}.{name}{{reason}}\" +\n \", but {context:type} is .\", interfaceType);\n\n if (assertionChain.Succeeded && AssertSubjectImplements(interfaceType, because, becauseArgs))\n {\n var explicitlyImplementsProperty = Subject.HasExplicitlyImplementedProperty(interfaceType, name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(explicitlyImplementsProperty)\n .FailWith(\n $\"Expected {{0}} to explicitly implement {{1}}.{name}{{reason}}, but it does not.\",\n Subject, interfaceType);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current explicitly implements a property named\n /// from interface .\n /// \n /// The interface whose member is being explicitly implemented.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint HaveExplicitProperty(\n string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TInterface : class\n {\n return HaveExplicitProperty(typeof(TInterface), name, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not explicitly implement a property named\n /// from interface .\n /// \n /// The type of the interface.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n public AndConstraint NotHaveExplicitProperty(\n Type interfaceType, string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {{context:type}} to not explicitly implement {{0}}.{name}{{reason}}\" +\n \", but {context:type} is .\", interfaceType);\n\n if (assertionChain.Succeeded && AssertSubjectImplements(interfaceType, because, becauseArgs))\n {\n var explicitlyImplementsProperty = Subject.HasExplicitlyImplementedProperty(interfaceType, name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!explicitlyImplementsProperty)\n .FailWith(\n $\"Expected {{0}} to not explicitly implement {{1}}.{name}{{reason}}\" +\n \", but it does.\", Subject, interfaceType);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not explicitly implement a property named\n /// from interface .\n /// \n /// The interface whose member is not being explicitly implemented.\n /// The name of the property.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint NotHaveExplicitProperty(\n string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TInterface : class\n {\n return NotHaveExplicitProperty(typeof(TInterface), name, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current explicitly implements a method named \n /// from interface .\n /// \n /// The type of the interface.\n /// The name of the method.\n /// The expected types of the method parameters.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n /// is .\n public AndConstraint HaveExplicitMethod(\n Type interfaceType, string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected {{context:type}} to explicitly implement {{0}}.{name}\" +\n $\"({GetParameterString(parameterTypes)}){{reason}}, but {{context:type}} is .\",\n interfaceType));\n\n if (assertionChain.Succeeded && AssertSubjectImplements(interfaceType, because, becauseArgs))\n {\n var explicitlyImplementsMethod = Subject.HasMethod($\"{interfaceType}.{name}\", parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(explicitlyImplementsMethod)\n .FailWith(() => new FailReason(\n $\"Expected {{0}} to explicitly implement {{1}}.{name}\" +\n $\"({GetParameterString(parameterTypes)}){{reason}}, but it does not.\",\n Subject, interfaceType));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current explicitly implements a method named \n /// from interface .\n /// \n /// The interface whose member is being explicitly implemented.\n /// The name of the method.\n /// The expected types of the method parameters.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n /// is .\n public AndConstraint HaveExplicitMethod(\n string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TInterface : class\n {\n return HaveExplicitMethod(typeof(TInterface), name, parameterTypes, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not explicitly implement a method named \n /// from interface .\n /// \n /// The type of the interface.\n /// The name of the method.\n /// The expected types of the method parameters.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n /// is empty.\n /// is .\n public AndConstraint NotHaveExplicitMethod(\n Type interfaceType, string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(interfaceType);\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected {{context:type}} to not explicitly implement {{0}}.{name}\" +\n $\"({GetParameterString(parameterTypes)}){{reason}}, but {{context:type}} is .\",\n interfaceType));\n\n if (assertionChain.Succeeded && AssertSubjectImplements(interfaceType, because, becauseArgs))\n {\n var explicitlyImplementsMethod = Subject.HasMethod($\"{interfaceType}.{name}\", parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!explicitlyImplementsMethod)\n .FailWith(() => new FailReason(\n $\"Expected {{0}} to not explicitly implement {{1}}.{name}\" +\n $\"({GetParameterString(parameterTypes)}){{reason}}, but it does.\",\n Subject, interfaceType));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not explicitly implement a method named \n /// from interface .\n /// \n /// The interface whose member is not being explicitly implemented.\n /// The name of the method.\n /// The expected types of the method parameters.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n /// is .\n public AndConstraint NotHaveExplicitMethod(\n string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TInterface : class\n {\n return NotHaveExplicitMethod(typeof(TInterface), name, parameterTypes, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an indexer of type .\n /// with parameter types .\n /// \n /// The type of the indexer.\n /// The parameter types for the indexer.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndWhichConstraint HaveIndexer(\n Type indexerType, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(indexerType);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n string parameterString = GetParameterString(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {{0}} {{context:type}}[{parameterString}] to exist{{reason}}\" +\n \", but {context:type} is .\", indexerType.AsFormattableShortType());\n\n PropertyInfo propertyInfo = null;\n\n if (assertionChain.Succeeded)\n {\n propertyInfo = Subject.GetIndexerByParameterTypes(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is not null)\n .FailWith(\n $\"Expected {{0}} {{1}}[{parameterString}] to exist{{reason}}\" +\n \", but it does not.\", indexerType.AsFormattableShortType(), Subject)\n .Then\n .ForCondition(propertyInfo.PropertyType == indexerType)\n .FailWith(\"Expected {0} to be of type {1}{reason}, but it is not.\",\n propertyInfo, indexerType);\n }\n\n return new AndWhichConstraint(this, propertyInfo, assertionChain,\n $\"[{parameterString}]\");\n }\n\n /// \n /// Asserts that the current does not have an indexer that takes parameter types\n /// .\n /// \n /// The expected indexer's parameter types.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotHaveIndexer(\n IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected indexer {{context:type}}[{GetParameterString(parameterTypes)}] to not exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n if (assertionChain.Succeeded)\n {\n PropertyInfo propertyInfo = Subject.GetIndexerByParameterTypes(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(propertyInfo is null)\n .FailWith(() => new FailReason(\n $\"Expected indexer {{0}}[{GetParameterString(parameterTypes)}] to not exist{{reason}}\" +\n \", but it does.\", Subject));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a method named with parameter types\n /// .\n /// \n /// The name of the method.\n /// The parameter types for the indexer.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n /// is .\n public AndWhichConstraint HaveMethod(\n string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected method {{context:type}}.{name}({GetParameterString(parameterTypes)}) to exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n MethodInfo methodInfo = null;\n\n if (assertionChain.Succeeded)\n {\n methodInfo = Subject.GetMethod(name, parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is not null)\n .FailWith(() =>\n {\n string methodDescription;\n if (methodInfo is null)\n {\n methodDescription = $\"{Subject.AsFormattableTypeDefinition().ToFormattedString()}.{name}\";\n }\n else\n {\n methodDescription = MethodInfoAssertions.GetDescriptionFor(methodInfo);\n }\n\n return new FailReason(\n $\"Expected method {methodDescription}({GetParameterString(parameterTypes)}) to exist{{reason}}\" +\n \", but it does not.\");\n });\n }\n\n return new AndWhichConstraint(this, methodInfo);\n }\n\n /// \n /// Asserts that the current does not expose a method named \n /// with parameter types .\n /// \n /// The name of the method.\n /// The method parameter types.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n /// is .\n public AndConstraint NotHaveMethod(\n string name, IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected method {{context:type}}.{name}({GetParameterString(parameterTypes)}) to not exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n if (assertionChain.Succeeded)\n {\n MethodInfo methodInfo = Subject.GetMethod(name, parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is null)\n .FailWith(() =>\n {\n string methodDescription = MethodInfoAssertions.GetDescriptionFor(methodInfo);\n return new FailReason(\n $\"Expected method {methodDescription}({GetParameterString(parameterTypes)}) to not exist{{reason}}\" +\n \", but it does.\");\n });\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a constructor with .\n /// \n /// The parameter types for the indexer.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint HaveConstructor(\n IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected constructor {{context:type}}({GetParameterString(parameterTypes)}) to exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n ConstructorInfo constructorInfo = null;\n\n if (assertionChain.Succeeded)\n {\n constructorInfo = Subject.GetConstructor(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(constructorInfo is not null)\n .FailWith(() => new FailReason(\n $\"Expected constructor {{0}}({GetParameterString(parameterTypes)}) to exist{{reason}}\" +\n \", but it does not.\", Subject));\n }\n\n return new AndWhichConstraint(this, constructorInfo);\n }\n\n /// \n /// Asserts that the current has a default constructor.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveDefaultConstructor(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveConstructor([], because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not have a constructor with .\n /// \n /// The parameter types for the indexer.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint NotHaveConstructor(\n IEnumerable parameterTypes,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(() => new FailReason(\n $\"Expected constructor {{context:type}}({GetParameterString(parameterTypes)}) not to exist{{reason}}\" +\n \", but {context:type} is .\"));\n\n ConstructorInfo constructorInfo = null;\n\n if (assertionChain.Succeeded)\n {\n constructorInfo = Subject.GetConstructor(parameterTypes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(constructorInfo is null)\n .FailWith(() => new FailReason(\n $\"Expected constructor {{0}}({GetParameterString(parameterTypes)}) not to exist{{reason}}\" +\n \", but it does.\", Subject));\n }\n\n return new AndWhichConstraint(this, constructorInfo);\n }\n\n /// \n /// Asserts that the current does not have a default constructor.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint NotHaveDefaultConstructor(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveConstructor([], because, becauseArgs);\n }\n\n private static string GetParameterString(IEnumerable parameterTypes)\n {\n return string.Join(\", \", parameterTypes.Select(parameterType => parameterType.ToFormattedString()));\n }\n\n /// \n /// Asserts that the current has the specified C# .\n /// \n /// The expected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint HaveAccessModifier(\n CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:type}} to be {accessModifier}{{reason}}, but {{context:type}} is .\");\n\n if (assertionChain.Succeeded)\n {\n CSharpAccessModifier subjectAccessModifier = Subject.GetCSharpAccessModifier();\n\n assertionChain.ForCondition(accessModifier == subjectAccessModifier)\n .BecauseOf(because, becauseArgs)\n .ForCondition(accessModifier == subjectAccessModifier)\n .FailWith(\n $\"Expected {{context:type}} {{0}} to be {accessModifier}{{reason}}\" +\n $\", but it is {subjectAccessModifier}.\", Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not have the specified C# .\n /// \n /// The unexpected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint NotHaveAccessModifier(\n CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected {{context:type}} not to be {accessModifier}{{reason}}, but {{context:type}} is .\");\n\n if (assertionChain.Succeeded)\n {\n CSharpAccessModifier subjectAccessModifier = Subject.GetCSharpAccessModifier();\n\n assertionChain\n .ForCondition(accessModifier != subjectAccessModifier)\n .BecauseOf(because, becauseArgs)\n .ForCondition(accessModifier != subjectAccessModifier)\n .FailWith($\"Expected {{context:type}} {{0}} not to be {accessModifier}{{reason}}, but it is.\",\n Subject);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an implicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveImplicitConversionOperator(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveImplicitConversionOperator(typeof(TSource), typeof(TTarget), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an implicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndWhichConstraint HaveImplicitConversionOperator(\n Type sourceType, Type targetType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(sourceType);\n Guard.ThrowIfArgumentIsNull(targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected public static implicit {0}({1}) to exist{reason}, but {context:type} is .\",\n targetType, sourceType);\n\n MethodInfo methodInfo = null;\n\n if (assertionChain.Succeeded)\n {\n methodInfo = Subject.GetImplicitConversionOperator(sourceType, targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is not null)\n .FailWith(\"Expected public static implicit {0}({1}) to exist{reason}, but it does not.\",\n targetType, sourceType);\n }\n\n return new AndWhichConstraint(this, methodInfo, assertionChain);\n }\n\n /// \n /// Asserts that the current does not have an implicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveImplicitConversionOperator(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveImplicitConversionOperator(typeof(TSource), typeof(TTarget), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not have an implicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndConstraint NotHaveImplicitConversionOperator(\n Type sourceType, Type targetType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(sourceType);\n Guard.ThrowIfArgumentIsNull(targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected public static implicit {0}({1}) to not exist{reason}, but {context:type} is .\",\n targetType, sourceType);\n\n if (assertionChain.Succeeded)\n {\n MethodInfo methodInfo = Subject.GetImplicitConversionOperator(sourceType, targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is null)\n .FailWith(\"Expected public static implicit {0}({1}) to not exist{reason}, but it does.\",\n targetType, sourceType);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an explicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveExplicitConversionOperator(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveExplicitConversionOperator(typeof(TSource), typeof(TTarget), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an explicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndWhichConstraint HaveExplicitConversionOperator(\n Type sourceType, Type targetType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(sourceType);\n Guard.ThrowIfArgumentIsNull(targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected public static explicit {0}({1}) to exist{reason}, but {context:type} is .\",\n targetType, sourceType);\n\n MethodInfo methodInfo = null;\n\n if (assertionChain.Succeeded)\n {\n methodInfo = Subject.GetExplicitConversionOperator(sourceType, targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is not null)\n .FailWith(\"Expected public static explicit {0}({1}) to exist{reason}, but it does not.\",\n targetType, sourceType);\n }\n\n return new AndWhichConstraint(this, methodInfo);\n }\n\n /// \n /// Asserts that the current does not have an explicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveExplicitConversionOperator(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveExplicitConversionOperator(typeof(TSource), typeof(TTarget), because, becauseArgs);\n }\n\n /// \n /// Asserts that the current does not have an explicit conversion operator that converts\n /// into .\n /// \n /// The type to convert from.\n /// The type to convert to.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is .\n public AndConstraint NotHaveExplicitConversionOperator(\n Type sourceType, Type targetType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(sourceType);\n Guard.ThrowIfArgumentIsNull(targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected public static explicit {0}({1}) to not exist{reason}, but {context:type} is .\",\n targetType, sourceType);\n\n if (assertionChain.Succeeded)\n {\n MethodInfo methodInfo = Subject.GetExplicitConversionOperator(sourceType, targetType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(methodInfo is null)\n .FailWith(\"Expected public static explicit {0}({1}) to not exist{reason}, but it does.\",\n targetType, sourceType);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"type\";\n\n private void AssertThatSubjectIsClass()\n {\n if (Subject.IsInterface || Subject.IsValueType || typeof(Delegate).IsAssignableFrom(Subject.BaseType))\n {\n throw new InvalidOperationException($\"{Subject.ToFormattedString()} must be a class.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/EnumAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class EnumAssertions : EnumAssertions>\n where TEnum : struct, Enum\n{\n public EnumAssertions(TEnum subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class EnumAssertions\n where TEnum : struct, Enum\n where TAssertions : EnumAssertions\n{\n public EnumAssertions(TEnum subject, AssertionChain assertionChain)\n : this((TEnum?)subject, assertionChain)\n {\n }\n\n private protected EnumAssertions(TEnum? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n public TEnum? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TEnum expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject?.Equals(expected) == true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TEnum? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Nullable.Equals(Subject, expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TEnum unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject?.Equals(unexpected) != true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TEnum? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(!Nullable.Equals(Subject, unexpected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current value of is defined inside the enum.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDefined([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the enum} to be defined in {0}{reason}, \", typeof(TEnum), chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(Enum.IsDefined(typeof(TEnum), Subject))\n .FailWith(\"but it is not.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current value of is not defined inside the enum.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDefined([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:the enum} to be defined in {0}{reason}, \", typeof(TEnum), chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(!Enum.IsDefined(typeof(TEnum), Subject))\n .FailWith(\"but it is.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue(decimal expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is { } value && GetValue(value) == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to have value {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue(decimal unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(!(Subject is { } value && GetValue(value) == unexpected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to not have value {0}{reason}, but found {1}.\",\n unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the same numeric value as .\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSameValueAs(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : struct, Enum\n {\n CurrentAssertionChain\n .ForCondition(Subject is { } value && GetValue(value) == GetValue(expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to have same value as {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the same numeric value as .\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSameValueAs(T unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : struct, Enum\n {\n CurrentAssertionChain\n .ForCondition(!(Subject is { } value && GetValue(value) == GetValue(unexpected)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to not have same value as {0}{reason}, but found {1}.\",\n unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the same name as .\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSameNameAs(T expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : struct, Enum\n {\n CurrentAssertionChain\n .ForCondition(Subject is { } value && GetName(value) == GetName(expected))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to have same name as {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the same name as .\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSameNameAs(T unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where T : struct, Enum\n {\n CurrentAssertionChain\n .ForCondition(!(Subject is { } value && GetName(value) == GetName(unexpected)))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to not have same name as {0}{reason}, but found {1}.\",\n unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an enum has a specified flag\n /// \n /// The expected flag.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveFlag(TEnum expectedFlag,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject?.HasFlag(expectedFlag) == true)\n .FailWith(\"Expected {context:the enum} to have flag {0}{reason}, but found {1}.\", expectedFlag, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that an enum does not have a specified flag\n /// \n /// The unexpected flag.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveFlag(TEnum unexpectedFlag,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject?.HasFlag(unexpectedFlag) != true)\n .FailWith(\"Expected {context:the enum} to not have flag {0}{reason}.\", unexpectedFlag);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the matches the .\n /// \n /// \n /// The predicate which must be satisfied by the .\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// An which can be used to chain assertions.\n /// is .\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate, nameof(predicate), \"Cannot match an enum against a predicate.\");\n\n CurrentAssertionChain\n .ForCondition(predicate.Compile()(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to match {1}{reason}, but found {0}.\", Subject, predicate.Body);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params TEnum[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(validValues, nameof(validValues),\n \"Cannot assert that an enum is one of a null list of enums\");\n\n Guard.ThrowIfArgumentIsEmpty(validValues, nameof(validValues),\n \"Cannot assert that an enum is one of an empty list of enums\");\n\n CurrentAssertionChain\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:the enum} to be one of {0}{reason}, but found \", validValues)\n .Then\n .ForCondition(validValues.Contains(Subject.Value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the enum} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n private static decimal GetValue(T @enum)\n where T : struct, Enum\n {\n return Convert.ToDecimal(@enum, CultureInfo.InvariantCulture);\n }\n\n private static string GetName(T @enum)\n where T : struct, Enum\n {\n return @enum.ToString();\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/TaskOfTAssertionSpecs.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n#if NET47\nusing AwesomeAssertions.Specs.Common;\n#endif\nusing AwesomeAssertions.Specs.Exceptions;\nusing Xunit;\nusing Xunit.Sdk;\nusing static AwesomeAssertions.FluentActions;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic static class TaskOfTAssertionSpecs\n{\n public class CompleteWithinAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_fail()\n {\n // Arrange\n var timeSpan = 0.Milliseconds();\n Func> action = null;\n\n // Act\n Func testAction = () => action.Should().CompleteWithinAsync(\n timeSpan, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_subject_is_null_with_AssertionScope_it_should_fail()\n {\n // Arrange\n var timeSpan = 0.Milliseconds();\n Func> action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().CompleteWithinAsync(\n timeSpan, \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_task_completes_fast_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).CompleteWithinAsync(100.Milliseconds()))\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Can_chain_another_assertion_on_the_result_of_the_async_operation()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).CompleteWithinAsync(100.Milliseconds()))\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_completes_and_result_is_not_expected_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> funcSubject = () => taskFactory.Task;\n\n (await funcSubject.Should(timer).CompleteWithinAsync(100.Milliseconds()))\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(99);\n timer.Complete();\n\n // Assert\n // TODO message currently shows \"Expected (await funcSubject to be...\", but should be \"Expected funcSubject to be...\",\n // maybe with or without await.\n await action.Should().ThrowAsync().WithMessage(\"*to be 42, but found 99 (difference of 57).\");\n }\n\n [Fact]\n public async Task When_task_completes_and_async_result_is_not_expected_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> funcSubject = () => taskFactory.Task;\n\n await funcSubject.Should(timer).CompleteWithinAsync(100.Milliseconds()).WithResult(42);\n };\n\n taskFactory.SetResult(99);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"Expected funcSubject.Result to be 42, but found 99.\");\n }\n\n [Fact]\n public async Task When_task_completes_late_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n Func> func = () => taskFactory.Task;\n\n return func.Should(timer).CompleteWithinAsync(100.Milliseconds());\n };\n\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_completes_late_it_in_assertion_scope_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n using var _ = new AssertionScope();\n await func.Should(timer).CompleteWithinAsync(100.Milliseconds());\n };\n\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_does_not_complete_the_result_extension_does_not_hang()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n using var _ = new AssertionScope();\n await func.Should(timer).CompleteWithinAsync(100.Milliseconds()).WithResult(2);\n };\n\n timer.Complete();\n\n // Assert\n var assertionTask = action.Should().ThrowAsync()\n .WithMessage(\"Expected*to complete within 100ms.\");\n\n await Awaiting(() => assertionTask).Should().CompleteWithinAsync(200.Seconds());\n }\n\n [Fact]\n public async Task When_task_consumes_time_in_sync_portion_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n Func> func = () =>\n {\n timer.Delay(101.Milliseconds());\n return taskFactory.Task;\n };\n\n return func.Should(timer).CompleteWithinAsync(100.Milliseconds());\n };\n\n taskFactory.SetResult(99);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Canceled_tasks_do_not_cause_a_default_value_to_be_returned()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => t.Task)\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds())\n .WithResult(0);\n\n taskFactory.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Exception_throwing_tasks_do_not_cause_a_default_value_to_be_returned()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => t.Task)\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds())\n .WithResult(0);\n\n taskFactory.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class NotThrowAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_fail()\n {\n // Arrange\n Func> action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().NotThrowAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_task_does_not_throw_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).NotThrowAsync())\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Can_chain_another_assertion_on_the_result_of_the_async_operation()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).NotThrowAsync())\n .Which.Should().Be(10);\n };\n\n taskFactory.SetResult(20);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*func.Result to be 10*\");\n }\n\n [Fact]\n public async Task When_task_throws_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n\n // Act\n Func action = () =>\n {\n Func> func = () => throw new AggregateException();\n\n return func.Should(timer).NotThrowAsync();\n };\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n [Collection(\"UIFacts\")]\n public class NotThrowAsyncUIFacts\n {\n [UIFact]\n public async Task When_task_does_not_throw_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = async () =>\n {\n Func> func = () => taskFactory.Task;\n\n (await func.Should(timer).NotThrowAsync())\n .Which.Should().Be(42);\n };\n\n taskFactory.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [UIFact]\n public async Task When_task_throws_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n\n // Act\n Func action = () =>\n {\n Func> func = () => throw new AggregateException();\n\n return func.Should(timer).NotThrowAsync();\n };\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class NotThrowAfterAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_fail()\n {\n // Arrange\n var waitTime = 0.Milliseconds();\n var pollInterval = 0.Milliseconds();\n Func> action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().NotThrowAfterAsync(waitTime, pollInterval,\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_wait_time_is_negative_it_should_fail()\n {\n // Arrange\n var waitTime = -1.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n var asyncObject = new AsyncClass();\n Func> someFunc = () => asyncObject.ReturnTaskInt();\n\n // Act\n Func act = () => someFunc.Should().NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().ThrowAsync()\n .WithParameterName(\"waitTime\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public async Task When_poll_interval_is_negative_it_should_fail()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = -1.Milliseconds();\n\n var asyncObject = new AsyncClass();\n Func> someFunc = () => asyncObject.ReturnTaskInt();\n\n // Act\n Func act = () => someFunc.Should().NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().ThrowAsync()\n .WithParameterName(\"pollInterval\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public async Task When_exception_is_thrown_before_timeout_it_should_fail()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.CompleteAfter(waitTime);\n\n Func> throwLongerThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n return 42;\n };\n\n // Act\n Func action = () => throwLongerThanWaitTime.Should(clock)\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exceptions after 2s because we passed valid arguments*\");\n }\n\n [Fact]\n public async Task When_exception_is_thrown_after_timeout_it_should_succeed()\n {\n // Arrange\n var waitTime = 6.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.Delay(waitTime);\n\n Func> throwShorterThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Divide(12))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n return 42;\n };\n\n // Act\n Func act = async () =>\n {\n (await throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval))\n .Which.Should().Be(42);\n };\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n }\n\n public class NotThrowAfterAsyncUIFacts\n {\n [UIFact]\n public async Task When_exception_is_thrown_before_timeout_it_should_fail()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.CompleteAfter(waitTime);\n\n Func> throwLongerThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n return 42;\n };\n\n // Act\n Func action = () => throwLongerThanWaitTime.Should(clock)\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exceptions after 2s because we passed valid arguments*\");\n }\n\n [UIFact]\n public async Task When_exception_is_thrown_after_timeout_it_should_succeed()\n {\n // Arrange\n var waitTime = 6.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.Delay(waitTime);\n\n Func> throwShorterThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Divide(12))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n return 42;\n };\n\n // Act\n Func act = async () =>\n {\n (await throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval))\n .Which.Should().Be(42);\n };\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Excluding.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Excluding\n {\n [Fact]\n public void A_member_excluded_by_path_is_described_in_the_failure_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\",\n Age = 13\n };\n\n var customer = new\n {\n Name = \"Jack\",\n Age = 37\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(customer, options => options\n .Excluding(d => d.Age));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Exclude*Age*\");\n }\n\n [Fact]\n public void A_member_excluded_by_predicate_is_described_in_the_failure_message()\n {\n // Arrange\n var subject = new\n {\n Name = \"John\",\n Age = 13\n };\n\n var customer = new\n {\n Name = \"Jack\",\n Age = 37\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(customer, options => options\n .Excluding(ctx => ctx.Path == \"Age\"));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Exclude member when*Age*\");\n }\n\n [Fact]\n public void When_only_the_excluded_property_doesnt_match_it_should_not_throw()\n {\n // Arrange\n var dto = new CustomerDto\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"Dennis\"\n };\n\n // Act / Assert\n dto.Should().BeEquivalentTo(customer, options => options\n .Excluding(d => d.Name)\n .Excluding(d => d.Id));\n }\n\n [Fact]\n public void When_only_the_excluded_property_doesnt_match_it_should_not_throw_if_root_is_a_collection()\n {\n // Arrange\n var dto = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new Customer\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"Dennis\"\n };\n\n // Act / Assert\n new[] { dto }.Should().BeEquivalentTo(new[] { customer }, options => options\n .Excluding(d => d.Name)\n .Excluding(d => d.Id));\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_excluding_members_it_should_pass_if_only_the_excluded_members_are_different()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act =\n () =>\n class1.Should().BeEquivalentTo(class2,\n opts => opts.Excluding(o => o.Field3).Excluding(o => o.Property1));\n\n // Assert\n act.Should().NotThrow(\"the non-excluded fields have the same value\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_excluding_members_it_should_fail_if_any_non_excluded_members_are_different()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\"\n };\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.Excluding(o => o.Property1));\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Field3*\");\n }\n\n [Fact]\n public void When_all_shared_properties_match_it_should_not_throw()\n {\n // Arrange\n var dto = new CustomerDto\n {\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n var customer = new Customer\n {\n Id = 1,\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20),\n Name = \"John\"\n };\n\n // Act / Assert\n dto.Should().BeEquivalentTo(customer, options => options.ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_a_deeply_nested_property_with_a_value_mismatch_is_excluded_it_should_not_throw()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1\n {\n Text = \"Level1\",\n Level = new Level2\n {\n Text = \"Mismatch\"\n }\n }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto\n {\n Text = \"Level1\",\n Level = new Level2Dto\n {\n Text = \"Level2\"\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options.Excluding(r => r.Level.Level.Text));\n }\n\n [Fact]\n public void When_a_deeply_nested_property_with_a_value_mismatch_is_excluded_it_should_not_throw_if_root_is_a_collection()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1\n {\n Text = \"Level1\",\n Level = new Level2\n {\n Text = \"Mismatch\"\n }\n }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto\n {\n Text = \"Level1\",\n Level = new Level2Dto\n {\n Text = \"Level2\"\n }\n }\n };\n\n // Act / Assert\n new[] { subject }.Should().BeEquivalentTo(new[] { expected },\n options => options.Excluding(r => r.Level.Level.Text));\n }\n\n [Fact]\n public void When_a_property_with_a_value_mismatch_is_excluded_using_a_predicate_it_should_not_throw()\n {\n // Arrange\n var subject = new Root\n {\n Text = \"Root\",\n Level = new Level1\n {\n Text = \"Level1\",\n Level = new Level2\n {\n Text = \"Mismatch\"\n }\n }\n };\n\n var expected = new RootDto\n {\n Text = \"Root\",\n Level = new Level1Dto\n {\n Text = \"Level1\",\n Level = new Level2Dto\n {\n Text = \"Level2\"\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, config =>\n config.Excluding(ctx => ctx.Path == \"Level.Level.Text\"));\n }\n\n [Fact]\n public void When_members_are_excluded_by_the_access_modifier_of_the_getter_using_a_predicate_they_should_be_ignored()\n {\n // Arrange\n var subject = new ClassWithAllAccessModifiersForMembers(\"public\", \"protected\",\n \"internal\", \"protected-internal\", \"private\", \"private-protected\");\n\n var expected = new ClassWithAllAccessModifiersForMembers(\"public\", \"protected\",\n \"ignored-internal\", \"ignored-protected-internal\", \"private\", \"private-protected\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, config => config\n .IncludingInternalFields()\n .Excluding(ctx =>\n ctx.WhichGetterHas(CSharpAccessModifier.Internal) ||\n ctx.WhichGetterHas(CSharpAccessModifier.ProtectedInternal)));\n }\n\n [Fact]\n public void When_members_are_excluded_by_the_access_modifier_of_the_setter_using_a_predicate_they_should_be_ignored()\n {\n // Arrange\n var subject = new ClassWithAllAccessModifiersForMembers(\"public\", \"protected\",\n \"internal\", \"protected-internal\", \"private\", \"private-protected\");\n\n var expected = new ClassWithAllAccessModifiersForMembers(\"public\", \"protected\",\n \"ignored-internal\", \"ignored-protected-internal\", \"ignored-private\", \"private-protected\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected, config => config\n .IncludingInternalFields()\n .Excluding(ctx =>\n ctx.WhichSetterHas(CSharpAccessModifier.Internal) ||\n ctx.WhichSetterHas(CSharpAccessModifier.ProtectedInternal) ||\n ctx.WhichSetterHas(CSharpAccessModifier.Private)));\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_excluding_properties_it_should_still_compare_fields()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"color\"\n };\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.ExcludingProperties());\n\n // Assert\n act.Should().Throw().WithMessage(\"*dolor*color*\");\n }\n\n [Fact]\n public void When_excluding_fields_it_should_still_compare_properties()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new ClassWithSomeFieldsAndProperties\n {\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"different\"\n };\n\n // Act\n Action act =\n () => class1.Should().BeEquivalentTo(class2, opts => opts.ExcludingFields());\n\n // Assert\n act.Should().Throw().WithMessage(\"*Property3*consectetur*\");\n }\n\n [Fact]\n public void When_excluding_properties_via_non_array_indexers_it_should_exclude_the_specified_paths()\n {\n // Arrange\n var subject = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 3,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 2\n }\n }\n };\n\n var expected = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 2,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 3\n }\n }\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected,\n options => options\n .Excluding(x => x.List[1].Foo)\n .Excluding(x => x.Dictionary[\"Bar\"].Value));\n }\n\n [Fact]\n public void\n When_excluding_properties_via_non_array_indexers_it_should_exclude_the_specified_paths_if_root_is_a_collection()\n {\n // Arrange\n var subject = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 3,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 2\n }\n }\n };\n\n var expected = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 2,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 3\n }\n }\n };\n\n // Act / Assert\n new[] { subject }.Should().BeEquivalentTo(new[] { expected },\n options => options\n .Excluding(x => x.List[1].Foo)\n .Excluding(x => x.Dictionary[\"Bar\"].Value));\n }\n\n [Fact]\n public void When_excluding_properties_via_non_array_indexers_it_should_not_exclude_paths_with_different_indexes()\n {\n // Arrange\n var subject = new\n {\n List = new[]\n {\n new\n {\n Foo = 1,\n Bar = 2\n },\n new\n {\n Foo = 3,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 1\n },\n [\"Bar\"] = new()\n {\n Value = 2\n }\n }\n };\n\n var expected = new\n {\n List = new[]\n {\n new\n {\n Foo = 5,\n Bar = 2\n },\n new\n {\n Foo = 2,\n Bar = 4\n }\n }.ToList(),\n Dictionary = new Dictionary\n {\n [\"Foo\"] = new()\n {\n Value = 6\n },\n [\"Bar\"] = new()\n {\n Value = 3\n }\n }\n };\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expected,\n options => options\n .Excluding(x => x.List[1].Foo)\n .Excluding(x => x.Dictionary[\"Bar\"].Value));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void\n When_configured_for_runtime_typing_and_properties_are_excluded_the_runtime_type_should_be_used_and_properties_should_be_ignored()\n {\n // Arrange\n object class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n object class2 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\"\n };\n\n // Act / Assert\n class1.Should().BeEquivalentTo(class2, opts => opts.ExcludingProperties().PreferringRuntimeMemberTypes());\n }\n\n [Fact]\n public void When_excluding_virtual_or_abstract_property_exclusion_works_properly()\n {\n var obj1 = new Derived\n {\n DerivedProperty1 = \"Something\",\n DerivedProperty2 = \"A\"\n };\n\n var obj2 = new Derived\n {\n DerivedProperty1 = \"Something\",\n DerivedProperty2 = \"B\"\n };\n\n obj1.Should().BeEquivalentTo(obj2, opt => opt\n .Excluding(o => o.AbstractProperty)\n .Excluding(o => o.VirtualProperty)\n .Excluding(o => o.DerivedProperty2));\n }\n\n [Fact]\n public void Abstract_properties_cannot_be_excluded()\n {\n var obj1 = new Derived\n {\n DerivedProperty1 = \"Something\",\n DerivedProperty2 = \"A\"\n };\n\n var obj2 = new Derived\n {\n DerivedProperty1 = \"Something\",\n DerivedProperty2 = \"B\"\n };\n\n Action act = () => obj1.Should().BeEquivalentTo(obj2, opt => opt\n .Excluding(o => o.AbstractProperty + \"B\"));\n\n act.Should().Throw().WithMessage(\"*(o.AbstractProperty + \\\"B\\\")*cannot be used to select a member*\");\n }\n\n#if NETCOREAPP3_0_OR_GREATER\n [Fact]\n public void Can_exclude_a_default_interface_property_using_an_expression()\n {\n // Arrange\n IHaveDefaultProperty subject = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Value\"\n };\n\n IHaveDefaultProperty expectation = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Another Value\"\n };\n\n // Act\n var act = () => subject.Should().BeEquivalentTo(expectation,\n x => x.Excluding(p => p.DefaultProperty));\n\n // Assert\n act.Should().Throw().Which.Message.Should().NotContain(\"subject.DefaultProperty\");\n }\n\n [Fact]\n public void Can_exclude_a_default_interface_property_using_a_name()\n {\n // Arrange\n IHaveDefaultProperty subject = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Value\"\n };\n\n IHaveDefaultProperty expectation = new ClassReceivedDefaultInterfaceProperty\n {\n NormalProperty = \"Another Value\"\n };\n\n // Act\n var act = () => subject.Should().BeEquivalentTo(expectation,\n x => x.Excluding(info => info.Name.Contains(\"DefaultProperty\")));\n\n // Assert\n act.Should().Throw().Which.Message.Should().NotContain(\"subject.DefaultProperty\");\n }\n\n private class ClassReceivedDefaultInterfaceProperty : IHaveDefaultProperty\n {\n public string NormalProperty { get; set; }\n }\n\n private interface IHaveDefaultProperty\n {\n string NormalProperty { get; set; }\n\n int DefaultProperty => NormalProperty.Length;\n }\n#endif\n\n [Fact]\n public void An_anonymous_object_with_multiple_fields_excludes_correctly()\n {\n // Arrange\n var subject = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n Age = 34\n };\n\n var expectation = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n Age = 29\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.MiddleName, p.LastName, p.Age }));\n }\n\n [Fact]\n public void An_empty_anonymous_object_excludes_nothing()\n {\n // Arrange\n var subject = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n Age = 34\n };\n\n var expectation = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n Age = 29\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { }));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void An_anonymous_object_can_exclude_collections()\n {\n // Arrange\n var subject = new\n {\n Names = new[]\n {\n \"John\",\n \"X.\",\n \"Doe\"\n },\n Age = 34\n };\n\n var expectation = new\n {\n Names = new[]\n {\n \"John\",\n \"W.\",\n \"Smith\"\n },\n Age = 34\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names }));\n }\n\n [Fact]\n public void An_anonymous_object_can_exclude_nested_objects()\n {\n // Arrange\n var subject = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n },\n Age = 34\n };\n\n var expectation = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Age = 34\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names.MiddleName, p.Names.LastName }));\n }\n\n [Fact]\n public void An_anonymous_object_can_exclude_nested_objects_inside_collections()\n {\n // Arrange\n var subject = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Age = 1,\n Color = \"Black\"\n },\n new\n {\n Name = \"Cat\",\n Age = 1,\n Color = \"Black\"\n },\n new\n {\n Name = \"Bird\",\n Age = 1,\n Color = \"Black\"\n },\n }\n };\n\n var expectation = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Age = 1,\n Color = \"Black\"\n },\n new\n {\n Name = \"Dog\",\n Age = 2,\n Color = \"Gray\"\n },\n new\n {\n Name = \"Bird\",\n Age = 3,\n Color = \"Black\"\n },\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names.MiddleName, p.Names.LastName })\n .For(p => p.Pets)\n .Exclude(p => new { p.Age, p.Name }));\n\n // Assert\n act.Should().Throw().Which.Message.Should()\n .NotMatch(\"*Pets[1].Age*\").And\n .NotMatch(\"*Pets[1].Name*\").And\n .Match(\"*Pets[1].Color*\");\n }\n\n [Fact]\n public void An_anonymous_object_can_exclude_nested_objects_inside_nested_collections()\n {\n // Arrange\n var subject = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 2,\n },\n },\n },\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 10\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 21\",\n Age = 3,\n },\n },\n },\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 2,\n },\n },\n },\n },\n };\n\n var expectation = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 2,\n },\n },\n },\n new\n {\n Name = \"Dog\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 1,\n },\n },\n },\n new\n {\n Name = \"Bird\",\n Fleas = new[]\n {\n new\n {\n Name = \"Flea 1\",\n Age = 1,\n },\n new\n {\n Name = \"Flea 2\",\n Age = 2,\n },\n },\n },\n },\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names.MiddleName, p.Names.LastName })\n .For(person => person.Pets)\n .For(pet => pet.Fleas)\n .Exclude(flea => new { flea.Name, flea.Age }));\n\n // Assert\n act.Should().Throw().Which.Message.Should()\n .NotMatch(\"*Pets[*].Fleas[*].Age*\").And\n .NotMatch(\"*Pets[*].Fleas[*].Name*\").And\n .Match(\"*- Exclude*Pets[]Fleas[]Age*\").And\n .Match(\"*- Exclude*Pets[]Fleas[]Name*\");\n }\n\n [Fact]\n public void An_empty_anonymous_object_excludes_nothing_inside_collections()\n {\n // Arrange\n var subject = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"X\",\n LastName = \"Doe\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Age = 1\n },\n new\n {\n Name = \"Cat\",\n Age = 1\n },\n new\n {\n Name = \"Bird\",\n Age = 1\n },\n }\n };\n\n var expectation = new\n {\n Names = new\n {\n FirstName = \"John\",\n MiddleName = \"W.\",\n LastName = \"Smith\",\n },\n Pets = new[]\n {\n new\n {\n Name = \"Dog\",\n Age = 1\n },\n new\n {\n Name = \"Dog\",\n Age = 2\n },\n new\n {\n Name = \"Bird\",\n Age = 1\n },\n }\n };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, opts => opts\n .Excluding(p => new { p.Names.MiddleName, p.Names.LastName })\n .For(p => p.Pets)\n .Exclude(p => new { }));\n\n // Assert\n act.Should().Throw().WithMessage(\"*Pets[1].Name*Pets[1].Age*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/SingleValueFormatter.cs", "using System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class SingleValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is float;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n float singleValue = (float)value;\n\n if (float.IsPositiveInfinity(singleValue))\n {\n formattedGraph.AddFragment(nameof(Single) + \".\" + nameof(float.PositiveInfinity));\n }\n else if (float.IsNegativeInfinity(singleValue))\n {\n formattedGraph.AddFragment(nameof(Single) + \".\" + nameof(float.NegativeInfinity));\n }\n else if (float.IsNaN(singleValue))\n {\n formattedGraph.AddFragment(singleValue.ToString(CultureInfo.InvariantCulture));\n }\n else\n {\n formattedGraph.AddFragment(singleValue.ToString(\"R\", CultureInfo.InvariantCulture) + \"F\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/SimpleTimeSpanAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class SimpleTimeSpanAssertions : SimpleTimeSpanAssertions\n{\n public SimpleTimeSpanAssertions(TimeSpan? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class SimpleTimeSpanAssertions\n where TAssertions : SimpleTimeSpanAssertions\n{\n public SimpleTimeSpanAssertions(TimeSpan? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public TimeSpan? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the time difference of the current is greater than zero.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BePositive([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject > TimeSpan.Zero)\n .FailWith(\"Expected {context:time} to be positive{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is less than zero.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNegative([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject < TimeSpan.Zero)\n .FailWith(\"Expected {context:time} to be negative{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is equal to the\n /// specified time.\n /// \n /// The expected time difference\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(expected == Subject)\n .FailWith(\"Expected {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is not equal to the\n /// specified time.\n /// \n /// The unexpected time difference\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TimeSpan unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(unexpected != Subject)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {0}{reason}.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is less than the\n /// specified time.\n /// \n /// The time difference to which the current value will be compared\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThan(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject < expected)\n .FailWith(\"Expected {context:time} to be less than {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is less than or equal to the\n /// specified time.\n /// \n /// The time difference to which the current value will be compared\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThanOrEqualTo(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject <= expected)\n .FailWith(\"Expected {context:time} to be less than or equal to {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is greater than the\n /// specified time.\n /// \n /// The time difference to which the current value will be compared\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThan(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject > expected)\n .FailWith(\"Expected {context:time} to be greater than {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the time difference of the current is greater than or equal to the\n /// specified time.\n /// \n /// The time difference to which the current value will be compared\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThanOrEqualTo(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject >= expected)\n .FailWith(\"Expected {context:time} to be greater than or equal to {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The expected time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(TimeSpan nearbyTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n TimeSpan minimumValue = nearbyTime - precision;\n TimeSpan maximumValue = nearbyTime + precision;\n\n CurrentAssertionChain\n .ForCondition(Subject >= minimumValue && Subject.Value <= maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be within {0} from {1}{reason}, but found {2}.\",\n precision,\n nearbyTime, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint NotBeCloseTo(TimeSpan distantTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n TimeSpan minimumValue = distantTime - precision;\n TimeSpan maximumValue = distantTime + precision;\n\n CurrentAssertionChain\n .ForCondition(Subject < minimumValue || Subject > maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to not be within {0} from {1}{reason}, but found {2}.\",\n precision,\n distantTime, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TypeValueFormatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic sealed class TypeValueFormatter : IValueFormatter\n{\n public bool CanHandle(object value)\n {\n return value is Type or ShortTypeValue;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n if (value is ShortTypeValue shortValue)\n {\n FormatType(shortValue.Type, formattedGraph.AddFragment, withNamespaces: false);\n }\n else\n {\n FormatType((Type)value, formattedGraph.AddFragment);\n }\n }\n\n /// \n /// Format a type to a friendly name.\n /// \n /// The type to format.\n /// The friendly type name.\n internal static string Format(Type type)\n {\n StringBuilder sb = new();\n FormatType(type, value => sb.Append(value));\n return sb.ToString();\n }\n\n /// \n /// Format a type to a friendly name.\n /// \n /// The type to format.\n /// Function for appending the formatted type part\n /// \n /// If true, all types, including inner types of generic arguments, are formatted\n /// using their full namespace.\n /// \n internal static void FormatType(Type type, Action append, bool withNamespaces = true)\n {\n if (Nullable.GetUnderlyingType(type) is Type nullbase)\n {\n FormatType(nullbase, append, withNamespaces);\n append(\"?\");\n }\n else if (type.IsGenericType)\n {\n if (withNamespaces && !string.IsNullOrEmpty(type.Namespace))\n {\n append(type.Namespace);\n append(\".\");\n }\n\n FormatGenericType(type, append, withNamespaces);\n }\n else if (type.BaseType == typeof(Array))\n {\n FormatArrayType(type, append, withNamespaces);\n }\n else if (LanguageKeywords.TryGetValue(type, out string alias))\n {\n append(alias);\n }\n else if (withNamespaces)\n {\n append(type.FullName);\n }\n else\n {\n append(type.Name);\n }\n }\n\n /// \n /// Format an array type of any dimension.\n /// \n /// The array type. Can have any dimension.\n /// Function for appending the formatted type part.\n /// If true, the type is formatted with its full namespace.\n private static void FormatArrayType(Type type, Action append, bool withNamespace)\n {\n FormatType(type.GetElementType(), append, withNamespace);\n\n append(\"[\");\n append(new string(',', type.GetArrayRank() - 1));\n append(\"]\");\n }\n\n /// \n /// Format a bound or unbound generic type.\n /// \n /// The generic type. Can be bound or unbound generic.\n /// Function for appending the formatted type part.\n /// If true, the type is formatted with its full namespace.\n private static void FormatGenericType(Type type, Action append, bool withNamespace)\n {\n FormatDeclaringTypeNames(type, append);\n\n append(type.Name[..type.Name.LastIndexOf('`')]);\n append(\"<\");\n\n FormatGenericArguments(type, append, withNamespace);\n\n append(\">\");\n }\n\n /// \n /// Format generic arguments of a type.\n /// \n /// The generic base type, of which the generic arguments are formatted.\n /// Function for appending the formatted type part.\n /// If true, the type is formatted with its full namespace.\n private static void FormatGenericArguments(Type type, Action append, bool withNamespace)\n {\n Type[] types = type.GetGenericArguments();\n bool isUnboundType = type.ContainsGenericParameters;\n\n int numberOfGenericArguments = GetNumberOfGenericArguments(type);\n int firstGenericArgumentIndex = types.Length - numberOfGenericArguments;\n for (int index = firstGenericArgumentIndex; index < types.Length; index++)\n {\n if (isUnboundType)\n {\n append(types[index].Name);\n }\n else\n {\n FormatType(types[index], append, withNamespace);\n }\n\n if (index < types.Length - 1)\n {\n append(\", \");\n }\n }\n }\n\n /// \n /// Get number of generic arguments of a type.\n /// \n /// \n /// For nested generic classes like class A<T> { class B<T2> { } },\n /// the inner class also holds the generic arguments of all parent classes,\n /// which we don't want for the formatting.\n /// \n /// The generic type of which to get the generic arguments.\n /// The count of generic arguments which are associated only with .\n private static int GetNumberOfGenericArguments(Type type) =>\n int.Parse(type.Name[(type.Name.LastIndexOf('`') + 1)..], CultureInfo.InvariantCulture);\n\n /// \n /// Format all declaring type names of type .\n /// \n /// The type, of which to format the declaring types.\n /// Function for appending the formatted type part.\n private static void FormatDeclaringTypeNames(Type type, Action append)\n {\n foreach (Type declaringType in GetDeclaringTypes(type))\n {\n // for the declaring types we stick to the default, short notation like Dictionary`2.\n append(declaringType.Name);\n append(\"+\");\n }\n }\n\n /// \n /// Get all declaring types, ordered from outer to inner.\n /// \n /// The base type\n /// All declaring types\n private static List GetDeclaringTypes(Type type)\n {\n if (type.DeclaringType is null)\n {\n return [];\n }\n\n // We don't iterate from inner to outer, because that wouldn't work\n // with an append, but would require an insert, too.\n List declaringTypes = [];\n Type declaringType = type.DeclaringType;\n while (declaringType is not null)\n {\n declaringTypes.Insert(0, declaringType);\n declaringType = declaringType.DeclaringType;\n }\n\n return declaringTypes;\n }\n\n /// \n /// Lookup dictionary to use language keyword instead of type name.\n /// \n private static readonly Dictionary LanguageKeywords = new()\n {\n { typeof(bool), \"bool\" },\n { typeof(byte), \"byte\" },\n { typeof(char), \"char\" },\n { typeof(decimal), \"decimal\" },\n { typeof(double), \"double\" },\n { typeof(float), \"float\" },\n { typeof(int), \"int\" },\n { typeof(long), \"long\" },\n { typeof(object), \"object\" },\n { typeof(sbyte), \"sbyte\" },\n { typeof(short), \"short\" },\n { typeof(string), \"string\" },\n { typeof(uint), \"uint\" },\n { typeof(ulong), \"ulong\" },\n { typeof(void), \"void\" },\n };\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/EnumSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class EnumSpecs\n{\n [Fact]\n public void When_asserting_the_same_enum_member_is_equivalent_it_should_succeed()\n {\n // Arrange\n object subject = EnumOne.One;\n object expectation = EnumOne.One;\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_the_actual_enum_value_is_null_it_should_report_that_properly()\n {\n // Arrange\n var subject = new { NullableEnum = (DayOfWeek?)null };\n\n var expectation = new { NullableEnum = DayOfWeek.Friday };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*5*null*\");\n }\n\n [Fact]\n public void When_the_actual_enum_name_is_null_it_should_report_that_properly()\n {\n // Arrange\n var subject = new { NullableEnum = (DayOfWeek?)null };\n\n var expectation = new { NullableEnum = DayOfWeek.Friday };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, o => o.ComparingEnumsByValue());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*5*null*\");\n }\n\n [Fact]\n public void When_asserting_different_enum_members_are_equivalent_it_should_fail()\n {\n // Arrange\n object subject = EnumOne.One;\n object expectation = EnumOne.Two;\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected *EnumOne.Two {value: 3}*but*EnumOne.One {value: 0}*\");\n }\n\n [Fact]\n public void Comparing_collections_of_enums_by_value_includes_custom_message()\n {\n // Arrange\n EnumOne[] subject = [EnumOne.One];\n EnumOne[] expectation = [EnumOne.Two];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, \"some {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected *EnumOne.Two {value: 3}*some reason*but*EnumOne.One {value: 0}*\");\n }\n\n [Fact]\n public void Comparing_collections_of_enums_by_name_includes_custom_message()\n {\n // Arrange\n EnumOne[] subject = [EnumOne.Two];\n EnumFour[] expectation = [EnumFour.Three];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByName(),\n \"some {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to equal EnumFour.Three {value: 3} by name*some reason*but found EnumOne.Two {value: 3}*\");\n }\n\n [Fact]\n public void Comparing_collections_of_numerics_with_collections_of_enums_includes_custom_message()\n {\n // Arrange\n int[] actual = [1];\n\n TestEnum[] expected = [TestEnum.First];\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByValue(),\n \"some {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*some reason*\");\n }\n\n [Fact]\n public void When_asserting_members_from_different_enum_types_are_equivalent_it_should_compare_by_value_by_default()\n {\n // Arrange\n var subject = new ClassWithEnumOne();\n var expectation = new ClassWithEnumTwo();\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation);\n }\n\n [Fact]\n public void When_asserting_members_from_different_enum_types_are_equivalent_by_value_it_should_succeed()\n {\n // Arrange\n var subject = new ClassWithEnumOne { Enum = EnumOne.One };\n var expectation = new ClassWithEnumThree { Enum = EnumThree.ValueZero };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByValue());\n }\n\n [Fact]\n public void When_asserting_members_from_different_enum_types_are_equivalent_by_string_value_it_should_succeed()\n {\n // Arrange\n var subject = new ClassWithEnumOne { Enum = EnumOne.Two };\n\n var expectation = new ClassWithEnumThree { Enum = EnumThree.Two };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByName());\n }\n\n [Fact]\n public void\n When_asserting_members_from_different_enum_types_are_equivalent_by_value_but_comparing_by_name_it_should_throw()\n {\n // Arrange\n var subject = new ClassWithEnumOne { Enum = EnumOne.Two };\n var expectation = new ClassWithEnumFour { Enum = EnumFour.Three };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByName());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to equal EnumFour.Three {value: 3} by name, but found EnumOne.Two {value: 3}*\");\n }\n\n [Fact]\n public void When_asserting_members_from_different_char_enum_types_are_equivalent_by_value_it_should_succeed()\n {\n // Arrange\n var subject = new ClassWithEnumCharOne { Enum = EnumCharOne.B };\n var expectation = new ClassWithEnumCharTwo { Enum = EnumCharTwo.ValueB };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ComparingEnumsByValue());\n }\n\n [Fact]\n public void When_asserting_enums_typed_as_object_are_equivalent_it_should_succeed()\n {\n // Arrange\n object e1 = EnumOne.One;\n object e2 = EnumOne.One;\n\n // Act / Assert\n e1.Should().BeEquivalentTo(e2);\n }\n\n [Fact]\n public void When_a_numeric_member_is_compared_with_an_enum_it_should_throw()\n {\n // Arrange\n var actual = new { Property = 1 };\n\n var expected = new { Property = TestEnum.First };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByValue());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_string_member_is_compared_with_an_enum_it_should_throw()\n {\n // Arrange\n var actual = new { Property = \"First\" };\n\n var expected = new { Property = TestEnum.First };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByName());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_null_enum_members_are_compared_by_name_it_should_succeed()\n {\n // Arrange\n var actual = new { Property = null as TestEnum? };\n\n var expected = new { Property = null as TestEnum? };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByName());\n }\n\n [Fact]\n public void When_null_enum_members_are_compared_by_value_it_should_succeed()\n {\n // Arrange\n var actual = new { Property = null as TestEnum? };\n\n var expected = new { Property = null as TestEnum? };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByValue());\n }\n\n [Fact]\n public void When_zero_and_null_enum_are_compared_by_value_it_should_throw()\n {\n // Arrange\n var actual = new { Property = (TestEnum)0 };\n\n var expected = new { Property = null as TestEnum? };\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected, options => options.ComparingEnumsByValue());\n\n // Assert\n act.Should().Throw();\n }\n\n public enum TestEnum\n {\n First = 1\n }\n\n [Fact]\n public void When_subject_is_null_and_enum_has_some_value_it_should_throw()\n {\n // Arrange\n object subject = null;\n object expectedEnum = EnumULong.UInt64Max;\n\n // Act\n Action act = () =>\n subject.Should().BeEquivalentTo(expectedEnum, x => x.ComparingEnumsByName(), \"comparing enums should throw\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected*to be equivalent to EnumULong.UInt64Max {value: 18446744073709551615} because comparing enums should throw, but found *\");\n }\n\n [Fact]\n public void When_expectation_is_null_and_subject_enum_has_some_value_it_should_throw_with_a_useful_message()\n {\n // Arrange\n object subjectEnum = EnumULong.UInt64Max;\n object expected = null;\n\n // Act\n Action act = () =>\n subjectEnum.Should().BeEquivalentTo(expected, x => x.ComparingEnumsByName(), \"comparing enums should throw\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to be because comparing enums should throw, but found EnumULong.UInt64Max*\");\n }\n\n [Fact]\n public void When_both_enums_are_equal_and_greater_than_max_long_it_should_not_throw()\n {\n // Arrange\n object enumOne = EnumULong.UInt64Max;\n object enumTwo = EnumULong.UInt64Max;\n\n // Act / Assert\n enumOne.Should().BeEquivalentTo(enumTwo);\n }\n\n [Fact]\n public void When_both_enums_are_equal_and_of_different_underlying_types_it_should_not_throw()\n {\n // Arrange\n object enumOne = EnumLong.Int64Max;\n object enumTwo = EnumULong.Int64Max;\n\n // Act / Assert\n enumOne.Should().BeEquivalentTo(enumTwo);\n }\n\n [Fact]\n public void When_both_enums_are_large_and_not_equal_it_should_throw()\n {\n // Arrange\n object subjectEnum = EnumLong.Int64LessOne;\n object expectedEnum = EnumULong.UInt64Max;\n\n // Act\n Action act = () => subjectEnum.Should().BeEquivalentTo(expectedEnum, \"comparing enums should throw\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected subjectEnum*to equal EnumULong.UInt64Max {value: 18446744073709551615} by value because comparing enums should throw, but found EnumLong.Int64LessOne {value: 9223372036854775806}*\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/DelegateAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that a synchronous method yields the expected result.\n/// \n[DebuggerNonUserCode]\npublic abstract class DelegateAssertions : DelegateAssertionsBase\n where TDelegate : Delegate\n where TAssertions : DelegateAssertions\n{\n private readonly AssertionChain assertionChain;\n\n protected DelegateAssertions(TDelegate @delegate, IExtractExceptions extractor, AssertionChain assertionChain)\n : base(@delegate, extractor, assertionChain, new Clock())\n {\n this.assertionChain = assertionChain;\n }\n\n private protected DelegateAssertions(TDelegate @delegate, IExtractExceptions extractor, AssertionChain assertionChain, IClock clock)\n : base(@delegate, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current throws an exception of type .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public ExceptionAssertions Throw([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw {0}{reason}, but found .\", typeof(TException));\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n Exception exception = InvokeSubjectWithInterception();\n return ThrowInternal(exception, because, becauseArgs);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n /// \n /// Asserts that the current does not throw an exception of type .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotThrow([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw {0}{reason}, but found .\", typeof(TException));\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n Exception exception = InvokeSubjectWithInterception();\n return NotThrowInternal(exception, because, becauseArgs);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current throws an exception of the exact type (and not a derived exception type).\n /// \n /// \n /// The type of the exception it should throw.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Returns an object that allows asserting additional members of the thrown exception.\n /// \n public ExceptionAssertions ThrowExactly([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to throw exactly {0}{reason}, but found .\", typeof(TException));\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n Exception exception = InvokeSubjectWithInterception();\n\n Type expectedType = typeof(TException);\n\n assertionChain\n .ForCondition(exception is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0}{reason}, but no exception was thrown.\", expectedType);\n\n if (assertionChain.Succeeded)\n {\n exception.Should().BeOfType(expectedType, because, becauseArgs);\n }\n\n return new ExceptionAssertions([exception as TException], assertionChain);\n }\n\n return new ExceptionAssertions([], assertionChain);\n }\n\n protected abstract void InvokeSubject();\n\n private protected Exception InvokeSubjectWithInterception()\n {\n Exception actualException = null;\n\n try\n {\n // For the duration of this nested invocation, configure CallerIdentifier\n // to match the contents of the subject rather than our own call site.\n //\n // Action action = () => subject.Should().BeSomething();\n // action.Should().Throw();\n //\n // If an assertion failure occurs, we want the message to talk about \"subject\"\n // not \"action\".\n using (CallerIdentifier.OnlyOneAssertionScopeOnCallStack()\n ? CallerIdentifier.OverrideStackSearchUsingCurrentScope()\n : default)\n {\n InvokeSubject();\n }\n }\n catch (Exception exc)\n {\n actualException = exc;\n }\n\n return actualException;\n }\n\n private protected void FailIfSubjectIsAsyncVoid()\n {\n if (Subject.GetMethodInfo().IsDecoratedWithOrInherit())\n {\n throw new InvalidOperationException(\n \"Cannot use action assertions on an async void method. Assign the async method to a variable of type Func instead of Action so that it can be awaited.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/CollectingAssertionStrategy.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\n\nnamespace AwesomeAssertions.Execution;\n\ninternal class CollectingAssertionStrategy : IAssertionStrategy\n{\n private readonly List failureMessages = [];\n\n /// \n /// Returns the messages for the assertion failures that happened until now.\n /// \n public IEnumerable FailureMessages => failureMessages;\n\n /// \n /// Discards and returns the failure messages that happened up to now.\n /// \n public IEnumerable DiscardFailures()\n {\n var discardedFailures = failureMessages.ToArray();\n failureMessages.Clear();\n return discardedFailures;\n }\n\n /// \n /// Will throw a combined exception for any failures have been collected.\n /// \n public void ThrowIfAny(IDictionary context)\n {\n if (failureMessages.Count > 0)\n {\n var builder = new StringBuilder();\n builder.AppendJoin(Environment.NewLine, failureMessages).AppendLine();\n\n if (context.Any())\n {\n foreach (KeyValuePair pair in context)\n {\n builder.AppendFormat(CultureInfo.InvariantCulture,\n $\"{Environment.NewLine}With {pair.Key}:{Environment.NewLine}{{0}}\", pair.Value);\n }\n }\n\n AssertionEngine.TestFramework.Throw(builder.ToString());\n }\n }\n\n /// \n /// Instructs the strategy to handle a assertion failure.\n /// \n public void HandleFailure(string message)\n {\n failureMessages.Add(message);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/AddNonEmptySymbolParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class AddNonEmptySymbolParsingStrategy : IParsingStrategy\n{\n private Mode mode = Mode.RemoveAllWhitespace;\n private char? precedingSymbol;\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (!char.IsWhiteSpace(symbol))\n {\n statement.Append(symbol);\n mode = Mode.RemoveSuperfluousWhitespace;\n }\n else if (mode is Mode.RemoveSuperfluousWhitespace)\n {\n if (precedingSymbol is { } value && !char.IsWhiteSpace(value))\n {\n statement.Append(symbol);\n }\n }\n else\n {\n // skip the rest\n }\n\n precedingSymbol = symbol;\n\n return ParsingState.GoToNextSymbol;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return false;\n }\n\n public void NotifyEndOfLineReached()\n {\n // Assume all new lines start with whitespace\n mode = Mode.RemoveAllWhitespace;\n }\n\n private enum Mode\n {\n /// \n /// Remove all whitespace until we find a non-whitespace character\n /// \n RemoveAllWhitespace,\n\n /// \n /// Only keep one whitespace character if more than one follow each other.\n /// \n RemoveSuperfluousWhitespace,\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/NonGenericAsyncFunctionAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an asynchronous method yields the expected result.\n/// \npublic class NonGenericAsyncFunctionAssertions : AsyncFunctionAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public NonGenericAsyncFunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain)\n : this(subject, extractor, assertionChain, new Clock())\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Initializes a new instance of the class with custom .\n /// \n public NonGenericAsyncFunctionAssertions(Func subject, IExtractExceptions extractor, AssertionChain assertionChain, IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current will complete within the specified time.\n /// \n /// The allowed time span for the operation.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> CompleteWithinAsync(\n TimeSpan timeSpan, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}, but found .\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n (Task task, TimeSpan remainingTime) = InvokeWithTimer(timeSpan);\n\n assertionChain\n .ForCondition(remainingTime >= TimeSpan.Zero)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n\n if (assertionChain.Succeeded)\n {\n bool completesWithinTimeout = await CompletesWithinTimeoutAsync(task, remainingTime, _ => Task.CompletedTask);\n\n assertionChain\n .ForCondition(completesWithinTimeout)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:task} to complete within {0}{reason}.\", timeSpan);\n }\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not throw any exception.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public async Task> NotThrowAsync(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n try\n {\n await Subject!.Invoke();\n }\n catch (Exception exception)\n {\n return NotThrowInternal(exception, because, becauseArgs);\n }\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current stops throwing any exception\n /// after a specified amount of time.\n /// \n /// \n /// The is invoked. If it raises an exception,\n /// the invocation is repeated until it either stops raising any exceptions\n /// or the specified wait time is exceeded.\n /// \n /// \n /// The time after which the should have stopped throwing any exception.\n /// \n /// \n /// The time between subsequent invocations of the .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// or are negative.\n public Task> NotThrowAfterAsync(TimeSpan waitTime, TimeSpan pollInterval,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(waitTime);\n Guard.ThrowIfArgumentIsNegative(pollInterval);\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw any exceptions after {0}{reason}, but found .\", waitTime);\n\n if (assertionChain.Succeeded)\n {\n return AssertionTaskAsync();\n\n async Task> AssertionTaskAsync()\n {\n TimeSpan? invocationEndTime = null;\n Exception exception = null;\n Common.ITimer timer = Clock.StartTimer();\n\n while (invocationEndTime is null || invocationEndTime < waitTime)\n {\n exception = await InvokeWithInterceptionAsync(Subject);\n\n if (exception is null)\n {\n return new AndConstraint(this);\n }\n\n await Clock.DelayAsync(pollInterval, CancellationToken.None);\n invocationEndTime = timer.Elapsed;\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exceptions after {0}{reason}, but found {1}.\", waitTime, exception);\n\n return new AndConstraint(this);\n }\n }\n\n return Task.FromResult(new AndConstraint(this));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/GivenSelectorSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\npublic class GivenSelectorSpecs\n{\n [Fact]\n public void A_consecutive_subject_should_be_selected()\n {\n // Arrange\n string value = string.Empty;\n\n // Act\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"First selector\")\n .Given(_ => value = \"Second selector\");\n\n // Assert\n value.Should().Be(\"Second selector\");\n }\n\n [Fact]\n public void After_a_failed_condition_a_consecutive_subject_should_be_ignored()\n {\n // Arrange\n string value = string.Empty;\n\n // Act\n AssertionChain.GetOrCreate()\n .ForCondition(false)\n .Given(() => \"First selector\")\n .Given(_ => value = \"Second selector\");\n\n // Assert\n value.Should().BeEmpty();\n }\n\n [Fact]\n public void A_consecutive_condition_should_be_evaluated()\n {\n // Act / Assert\n AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"Subject\")\n .ForCondition(_ => true)\n .FailWith(\"Failed\");\n }\n\n [Fact]\n public void After_a_failed_condition_a_consecutive_condition_should_be_ignored()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(false)\n .Given(() => \"Subject\")\n .ForCondition(_ => throw new ApplicationException())\n .FailWith(\"Failed\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_it_fails_with_a_message_after_selecting_the_subject()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"First\")\n .FailWith(\"First selector\")\n .Then\n .Given(_ => \"Second\")\n .FailWith(\"Second selector\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Second selector\");\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_it_fails_with_a_message_with_arguments_after_selecting_the_subject()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"First\")\n .FailWith(\"{0} selector\", \"First\")\n .Then\n .Given(_ => \"Second\")\n .FailWith(\"{0} selector\", \"Second\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\\\"Second\\\" selector\");\n }\n\n [Fact]\n public void When_continuing_an_assertion_chain_it_fails_with_a_message_with_argument_selectors_after_selecting_the_subject()\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForCondition(true)\n .Given(() => \"First\")\n .FailWith(\"{0} selector\", _ => \"First\")\n .Then\n .Given(_ => \"Second\")\n .FailWith(\"{0} selector\", _ => \"Second\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\\\"Second\\\" selector\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_failure_messages_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .Given(() => \"First\")\n .FailWith(\"First selector\")\n .Then\n .FailWith(\"Second selector\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"First selector\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_failure_messages_with_arguments_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .Given(() => \"First\")\n .FailWith(\"{0} selector\", \"First\")\n .Then\n .FailWith(\"{0} selector\", \"Second\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\\\"First\\\" selector\");\n }\n\n [Fact]\n public void When_continuing_a_failed_assertion_chain_consecutive_failure_messages_with_argument_selectors_are_ignored()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n AssertionChain.GetOrCreate()\n .Given(() => \"First\")\n .FailWith(\"{0} selector\", _ => \"First\")\n .Then\n .FailWith(\"{0} selector\", _ => \"Second\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\\\"First\\\" selector\");\n }\n\n [Fact]\n public void The_failure_message_should_be_preceded_by_the_expectation_after_selecting_a_subject()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectation \", chain => chain\n .Given(() => \"Subject\")\n .FailWith(\"Failure\"));\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expectation Failure\");\n }\n\n [Fact]\n public void\n The_failure_message_should_not_be_preceded_by_the_expectation_after_selecting_a_subject_and_clearing_the_expectation()\n {\n // Act\n Action act = () =>\n {\n AssertionChain.GetOrCreate()\n .WithExpectation(\"Expectation \", chain => chain\n .Given(() => \"Subject\"))\n .Then\n .FailWith(\"Failure\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Failure\");\n }\n\n [Fact]\n public void Clearing_the_expectation_does_not_affect_a_successful_assertion()\n {\n // Act\n var assertionChain = AssertionChain.GetOrCreate();\n\n assertionChain\n .WithExpectation(\"Expectation \", chain => chain\n .Given(() => \"Don't care\")\n .ForCondition(_ => true)\n .FailWith(\"Should not fail\"));\n\n // Assert\n assertionChain.Succeeded.Should().BeTrue();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MethodInfoAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class MethodInfoAssertions : MethodBaseAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public MethodInfoAssertions(MethodInfo methodInfo, AssertionChain assertionChain)\n : base(methodInfo, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the selected method is virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected method to be virtual{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(!Subject.IsNonVirtual())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected method {SubjectDescription} to be virtual{{reason}}, but it is not virtual.\"));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected method is not virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected method not to be virtual{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(Subject.IsNonVirtual())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected method {SubjectDescription} not to be virtual{{reason}}, but it is.\"));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected method is async.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAsync([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected method to be async{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(Subject.IsAsync())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected method {SubjectDescription} to be async{{reason}}, but it is not.\"));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected method is not async.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAsync([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected method not to be async{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(!Subject.IsAsync())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected method {SubjectDescription} not to be async{{reason}}, but it is.\"));\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected method returns void.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint> ReturnVoid(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the return type of method to be void{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(typeof(void) == Subject!.ReturnType)\n .BecauseOf(because, becauseArgs)\n .FailWith($\"Expected the return type of method {Subject.Name} to be void{{reason}}, but it is {{0}}.\",\n Subject.ReturnType);\n }\n\n return new AndConstraint>(this);\n }\n\n /// \n /// Asserts that the selected method returns .\n /// \n /// The expected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint> Return(Type returnType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(returnType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the return type of method to be {0}{reason}, but {context:member} is .\", returnType);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(returnType == Subject!.ReturnType)\n .BecauseOf(because, becauseArgs)\n .FailWith($\"Expected the return type of method {Subject.Name} to be {{0}}{{reason}}, but it is {{1}}.\",\n returnType, Subject.ReturnType);\n }\n\n return new AndConstraint>(this);\n }\n\n /// \n /// Asserts that the selected method returns .\n /// \n /// The expected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint> Return(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return Return(typeof(TReturn), because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected method does not return void.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint> NotReturnVoid(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the return type of method not to be void{reason}, but {context:member} is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(typeof(void) != Subject!.ReturnType)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the return type of method \" + Subject.Name + \" not to be void{reason}, but it is.\");\n }\n\n return new AndConstraint>(this);\n }\n\n /// \n /// Asserts that the selected method does not return .\n /// \n /// The unexpected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint> NotReturn(Type returnType,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(returnType);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n \"Expected the return type of method not to be {0}{reason}, but {context:member} is .\", returnType);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(returnType != Subject!.ReturnType)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected the return type of method \" + Subject.Name + \" not to be {0}{reason}, but it is.\", returnType);\n }\n\n return new AndConstraint>(this);\n }\n\n /// \n /// Asserts that the selected method does not return .\n /// \n /// The unexpected return type.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint> NotReturn(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotReturn(typeof(TReturn), because, becauseArgs);\n }\n\n internal static string GetDescriptionFor(MethodInfo method) =>\n $\"{method.ReturnType.AsFormattableShortType().ToFormattedString()} {method.DeclaringType.ToFormattedString()}.{method.Name}\";\n\n private protected override string SubjectDescription => GetDescriptionFor(Subject);\n\n protected override string Identifier => \"method\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Streams/StreamAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.IO;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Streams;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class StreamAssertions : StreamAssertions\n{\n public StreamAssertions(Stream stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \npublic class StreamAssertions : ReferenceTypeAssertions\n where TSubject : Stream\n where TAssertions : StreamAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public StreamAssertions(TSubject stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n protected override string Identifier => \"stream\";\n\n /// \n /// Asserts that the current is writable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeWritable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be writable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanWrite)\n .FailWith(\"Expected {context:stream} to be writable{reason}, but it was not.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not writable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeWritable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be writable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanWrite)\n .FailWith(\"Expected {context:stream} not to be writable{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is seekable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSeekable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be seekable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanSeek)\n .FailWith(\"Expected {context:stream} to be seekable{reason}, but it was not.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not seekable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSeekable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be seekable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanSeek)\n .FailWith(\"Expected {context:stream} not to be seekable{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is readable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeReadable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be readable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanRead)\n .FailWith(\"Expected {context:stream} to be readable{reason}, but it was not.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not readable.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeReadable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be readable{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanRead)\n .FailWith(\"Expected {context:stream} not to be readable{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the position.\n /// \n /// The expected position of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HavePosition(long expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the position of {context:stream} to be {0}{reason}, but found a reference.\",\n expected);\n\n if (assertionChain.Succeeded)\n {\n long position;\n\n try\n {\n position = Subject!.Position;\n }\n catch (Exception exception)\n when (exception is IOException or NotSupportedException or ObjectDisposedException)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the position of {context:stream} to be {0}{reason}, but it failed with:\"\n + Environment.NewLine + \"{1}\",\n expected, exception.Message);\n\n return new AndConstraint((TAssertions)this);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(position == expected)\n .FailWith(\"Expected the position of {context:stream} to be {0}{reason}, but it was {1}.\",\n expected, position);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have an position.\n /// \n /// The unexpected position of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHavePosition(long unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the position of {context:stream} not to be {0}{reason}, but found a reference.\",\n unexpected);\n\n if (assertionChain.Succeeded)\n {\n long position;\n\n try\n {\n position = Subject!.Position;\n }\n catch (Exception exception)\n when (exception is IOException or NotSupportedException or ObjectDisposedException)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the position of {context:stream} not to be {0}{reason}, but it failed with:\"\n + Environment.NewLine + \"{1}\",\n unexpected, exception.Message);\n\n return new AndConstraint((TAssertions)this);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(position != unexpected)\n .FailWith(\"Expected the position of {context:stream} not to be {0}{reason}, but it was.\",\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the length.\n /// \n /// The expected length of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveLength(long expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the length of {context:stream} to be {0}{reason}, but found a reference.\",\n expected);\n\n if (assertionChain.Succeeded)\n {\n long length;\n\n try\n {\n length = Subject!.Length;\n }\n catch (Exception exception)\n when (exception is IOException or NotSupportedException or ObjectDisposedException)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the length of {context:stream} to be {0}{reason}, but it failed with:\"\n + Environment.NewLine + \"{1}\",\n expected, exception.Message);\n\n return new AndConstraint((TAssertions)this);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(length == expected)\n .FailWith(\"Expected the length of {context:stream} to be {0}{reason}, but it was {1}.\",\n expected, length);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have an length.\n /// \n /// The unexpected length of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveLength(long unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the length of {context:stream} not to be {0}{reason}, but found a reference.\",\n unexpected);\n\n if (assertionChain.Succeeded)\n {\n long length;\n\n try\n {\n length = Subject!.Length;\n }\n catch (Exception exception)\n when (exception is IOException or NotSupportedException or ObjectDisposedException)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected the length of {context:stream} not to be {0}{reason}, but it failed with:\"\n + Environment.NewLine + \"{1}\",\n unexpected, exception.Message);\n\n return new AndConstraint((TAssertions)this);\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(length != unexpected)\n .FailWith(\"Expected the length of {context:stream} not to be {0}{reason}, but it was.\",\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is read-only.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeReadOnly([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be read-only{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanWrite && Subject.CanRead)\n .FailWith(\"Expected {context:stream} to be read-only{reason}, but it was writable or not readable.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not read-only.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeReadOnly([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be read-only{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanWrite || !Subject.CanRead)\n .FailWith(\"Expected {context:stream} not to be read-only{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is write-only.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeWriteOnly([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} to be write-only{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.CanWrite && !Subject.CanRead)\n .FailWith(\"Expected {context:stream} to be write-only{reason}, but it was readable or not writable.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not write-only.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeWriteOnly([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected {context:stream} not to be write-only{reason}, but found a reference.\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject!.CanWrite || Subject.CanRead)\n .FailWith(\"Expected {context:stream} not to be write-only{reason}, but it was.\");\n }\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/MemberMatchingSpecs.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic class MemberMatchingSpecs\n{\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_excluding_missing_members_both_fields_and_properties_should_be_ignored()\n {\n // Arrange\n var class1 = new ClassWithSomeFieldsAndProperties\n {\n Field1 = \"Lorem\",\n Field2 = \"ipsum\",\n Field3 = \"dolor\",\n Property1 = \"sit\",\n Property2 = \"amet\",\n Property3 = \"consectetur\"\n };\n\n var class2 = new { Field1 = \"Lorem\" };\n\n // Act / Assert\n class1.Should().BeEquivalentTo(class2, opts => opts.ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_a_property_shared_by_anonymous_types_doesnt_match_it_should_throw()\n {\n // Arrange\n var subject = new { Age = 36 };\n\n var other = new { Age = 37 };\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(other, options => options.ExcludingMissingMembers());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Nested_properties_can_be_mapped_using_a_nested_expression()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\n e => e.Children[0].Property2,\n s => s.Children[0].Property1));\n }\n\n [Fact]\n public void Nested_properties_can_be_mapped_using_a_nested_type_and_property_names()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property1\"));\n }\n\n [Fact]\n public void Nested_explicitly_implemented_properties_can_be_mapped_using_a_nested_type_and_property_names()\n {\n // Arrange\n var subject =\n new ParentOfSubjectWithExplicitlyImplementedProperty(new[] { new SubjectWithExplicitImplementedProperty() });\n\n ((IProperty)subject.Children[0]).Property = \"Hello\";\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property\"));\n }\n\n [Fact]\n public void Nested_fields_can_be_mapped_using_a_nested_type_and_field_names()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties { Field1 = \"John\", Field2 = \"Mary\" };\n\n var expectation = new ClassWithSomeFieldsAndProperties { Field1 = \"Mary\", Field2 = \"John\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Field1\", \"Field2\")\n .WithMapping(\"Field2\", \"Field1\"));\n }\n\n [Fact]\n public void Nested_properties_can_be_mapped_using_a_nested_type_and_a_property_expression()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\n e => e.Property2, s => s.Property1));\n }\n\n [Fact]\n public void Nested_properties_on_a_collection_can_be_mapped_using_a_dotted_path()\n {\n // Arrange\n var subject = new { Parent = new[] { new SubjectWithProperty1 { Property1 = \"Hello\" } } };\n\n var expectation = new { Parent = new[] { new ExpectationWithProperty2 { Property2 = \"Hello\" } } };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[].Property2\", \"Parent[].Property1\"));\n }\n\n [Fact]\n public void Properties_can_be_mapped_by_name()\n {\n // Arrange\n var subject = new SubjectWithProperty1 { Property1 = \"Hello\" };\n\n var expectation = new ExpectationWithProperty2 { Property2 = \"Hello\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property1\"));\n }\n\n [Fact]\n public void Properties_can_be_mapped_by_name_to_an_explicitly_implemented_property()\n {\n // Arrange\n var subject = new SubjectWithExplicitImplementedProperty();\n\n ((IProperty)subject).Property = \"Hello\";\n\n var expectation = new ExpectationWithProperty2\n {\n Property2 = \"Hello\"\n };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property\"));\n }\n\n [Fact]\n public void Fields_can_be_mapped_by_name()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties { Field1 = \"Hello\", Field2 = \"John\" };\n\n var expectation = new ClassWithSomeFieldsAndProperties { Field1 = \"John\", Field2 = \"Hello\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Field2\", \"Field1\")\n .WithMapping(\"Field1\", \"Field2\"));\n }\n\n [Fact]\n public void Fields_can_be_mapped_to_a_property_by_name()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties { Property1 = \"John\" };\n\n var expectation = new ClassWithSomeFieldsAndProperties { Field1 = \"John\", };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Field1\", \"Property1\")\n .Including(e => e.Field1));\n }\n\n [Fact]\n public void Properties_can_be_mapped_to_a_field_by_expression()\n {\n // Arrange\n var subject = new ClassWithSomeFieldsAndProperties { Field1 = \"John\", };\n\n var expectation = new ClassWithSomeFieldsAndProperties { Property1 = \"John\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(e => e.Property1, s => s.Field1)\n .Including(e => e.Property1));\n }\n\n [Fact]\n public void Properties_can_be_mapped_to_inherited_properties()\n {\n // Arrange\n var subject = new Derived { BaseProperty = \"Hello World\" };\n\n var expectation = new { AnotherProperty = \"Hello World\" };\n\n // Act / Assert\n subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(e => e.AnotherProperty, s => s.BaseProperty));\n }\n\n [Fact]\n public void A_failed_assertion_reports_the_subjects_mapped_property()\n {\n // Arrange\n var subject = new SubjectWithProperty1 { Property1 = \"Hello\" };\n\n var expectation = new ExpectationWithProperty2 { Property2 = \"Hello2\" };\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(e => e.Property2, e => e.Property1));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected property subject.Property1 to be*Hello*\");\n }\n\n [Fact]\n public void An_empty_expectation_member_path_is_not_allowed()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"\", \"Parent[0].Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*member path*\");\n }\n\n [Fact]\n public void An_empty_subject_member_path_is_not_allowed()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[0].Property1\", \"\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*member path*\");\n }\n\n [Fact]\n public void Null_as_the_expectation_member_path_is_not_allowed()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(null, \"Parent[0].Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*member path*\");\n }\n\n [Fact]\n public void Null_as_the_subject_member_path_is_not_allowed()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[0].Property1\", null));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*member path*\");\n }\n\n [Fact]\n public void Subject_and_expectation_member_paths_must_have_the_same_parent()\n {\n var subject = new SubjectWithProperty1();\n var expectation = new ExpectationWithProperty2();\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[].Property1\", \"OtherParent[].Property2\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*parent*\");\n }\n\n [Fact]\n public void Numeric_indexes_in_the_path_are_not_allowed()\n {\n var subject = new { Parent = new[] { new SubjectWithProperty1 { Property1 = \"Hello\" } } };\n\n var expectation = new { Parent = new[] { new ExpectationWithProperty2 { Property2 = \"Hello\" } } };\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent[0].Property2\", \"Parent[0].Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*without specific index*\");\n }\n\n [Fact]\n public void Mapping_to_a_non_existing_subject_member_is_not_allowed()\n {\n // Arrange\n var subject = new SubjectWithProperty1 { Property1 = \"Hello\" };\n\n var expectation = new ExpectationWithProperty2 { Property2 = \"Hello\" };\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"NonExistingProperty\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*not have member NonExistingProperty*\");\n }\n\n [Fact]\n public void A_null_subject_should_result_in_a_normal_assertion_failure()\n {\n // Arrange\n SubjectWithProperty1 subject = null;\n\n ExpectationWithProperty2 expectation = new() { Property2 = \"Hello\" };\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*Expected*ExpectationWithProperty2*found *\");\n }\n\n [Fact]\n public void Nested_types_and_dotted_expectation_member_paths_cannot_be_combined()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Parent.Property2\", \"Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*cannot be a nested path*\");\n }\n\n [Fact]\n public void Nested_types_and_dotted_subject_member_paths_cannot_be_combined()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Parent.Property1\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*cannot be a nested path*\");\n }\n\n [Fact]\n public void The_member_name_on_a_nested_type_mapping_must_be_a_valid_member()\n {\n // Arrange\n var subject = new ParentOfSubjectWithProperty1([new SubjectWithProperty1 { Property1 = \"Hello\" }]);\n\n var expectation = new ParentOfExpectationWithProperty2(\n [\n new ExpectationWithProperty2 { Property2 = \"Hello\" }\n ]);\n\n // Act\n Action act = () => subject.Should()\n .BeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"NonExistingProperty\"));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"*does not have member NonExistingProperty*\");\n }\n\n [Fact]\n public void Exclusion_of_missing_members_works_with_mapping()\n {\n // Arrange\n var subject = new\n {\n Property1 = 1\n };\n\n var expectation = new\n {\n Property2 = 2,\n Ignore = 3\n };\n\n // Act / Assert\n subject.Should()\n .NotBeEquivalentTo(expectation, opt => opt\n .WithMapping(\"Property2\", \"Property1\")\n .ExcludingMissingMembers()\n );\n }\n\n [Fact]\n public void Mapping_works_with_exclusion_of_missing_members()\n {\n // Arrange\n var subject = new\n {\n Property1 = 1\n };\n\n var expectation = new\n {\n Property2 = 2,\n Ignore = 3\n };\n\n // Act / Assert\n subject.Should()\n .NotBeEquivalentTo(expectation, opt => opt\n .ExcludingMissingMembers()\n .WithMapping(\"Property2\", \"Property1\")\n );\n }\n\n [Fact]\n public void Can_map_members_of_a_root_collection()\n {\n // Arrange\n var entity = new Entity\n {\n EntityId = 1,\n Name = \"Test\"\n };\n\n var dto = new EntityDto\n {\n Id = 1,\n Name = \"Test\"\n };\n\n Entity[] entityCol = [entity];\n EntityDto[] dtoCol = [dto];\n\n // Act / Assert\n dtoCol.Should().BeEquivalentTo(entityCol, c =>\n c.WithMapping(s => s.EntityId, d => d.Id));\n }\n\n [Fact]\n public void Can_explicitly_include_a_property_on_a_mapped_type()\n {\n // Arrange\n var expectation = new CustomerWithPropertiesDto\n {\n AddressInformation = new CustomerWithPropertiesDto.ResidenceDto\n {\n Address = \"123 Main St\",\n IsValidated = true,\n },\n };\n\n var subject = new CustomerWithProperty\n {\n Address = new CustomerWithProperty.Residence\n {\n Address = \"123 Main St\",\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o\n .Including(r => r.AddressInformation.Address)\n .WithMapping(s => s.AddressInformation, d => d.Address));\n }\n\n [Fact]\n public void Can_exclude_a_property_on_a_mapped_type()\n {\n // Arrange\n var expectation = new CustomerWithPropertiesDto\n {\n AddressInformation = new CustomerWithPropertiesDto.ResidenceDto\n {\n Address = \"123 Main St\",\n IsValidated = true,\n },\n };\n\n var subject = new CustomerWithProperty\n {\n Address = new CustomerWithProperty.Residence\n {\n Address = \"123 Main St\",\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o\n .Excluding(r => r.AddressInformation.IsValidated)\n .WithMapping(s => s.AddressInformation, d => d.Address));\n }\n\n [Fact]\n public void Can_explicitly_include_a_field_on_a_mapped_type()\n {\n // Arrange\n var expectation = new CustomerWithFieldDto\n {\n AddressInformation = new CustomerWithFieldDto.ResidenceDto\n {\n Address = \"123 Main St\",\n IsValidated = true,\n },\n };\n\n var subject = new CustomerWithField\n {\n Address = new CustomerWithField.Residence\n {\n Address = \"123 Main St\",\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o\n .Including(r => r.AddressInformation.Address)\n .WithMapping(s => s.AddressInformation, d => d.Address));\n }\n\n [Fact]\n public void Can_exclude_a_field_on_a_mapped_type()\n {\n // Arrange\n var expectation = new CustomerWithFieldDto\n {\n AddressInformation = new CustomerWithFieldDto.ResidenceDto\n {\n Address = \"123 Main St\",\n IsValidated = true,\n },\n };\n\n var subject = new CustomerWithField\n {\n Address = new CustomerWithField.Residence\n {\n Address = \"123 Main St\",\n },\n };\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expectation, o => o\n .Excluding(r => r.AddressInformation.IsValidated)\n .WithMapping(s => s.AddressInformation, d => d.Address));\n }\n\n private class CustomerWithProperty\n {\n public Residence Address { get; set; }\n\n public class Residence\n {\n [UsedImplicitly]\n public string Address { get; set; }\n }\n }\n\n private class CustomerWithPropertiesDto\n {\n public ResidenceDto AddressInformation { get; set; }\n\n public class ResidenceDto\n {\n public string Address { get; set; }\n\n public bool IsValidated { get; set; }\n }\n }\n\n private class CustomerWithField\n {\n public Residence Address;\n\n public class Residence\n {\n [UsedImplicitly]\n public string Address;\n }\n }\n\n private class CustomerWithFieldDto\n {\n public ResidenceDto AddressInformation;\n\n public class ResidenceDto\n {\n public string Address;\n\n [UsedImplicitly]\n public bool IsValidated;\n }\n }\n\n private class Entity\n {\n public int EntityId { get; init; }\n\n [UsedImplicitly]\n public string Name { get; init; }\n }\n\n private class EntityDto\n {\n public int Id { get; init; }\n\n [UsedImplicitly]\n public string Name { get; init; }\n }\n\n internal class ParentOfExpectationWithProperty2\n {\n public ExpectationWithProperty2[] Children { get; }\n\n public ParentOfExpectationWithProperty2(ExpectationWithProperty2[] children)\n {\n Children = children;\n }\n }\n\n internal class ParentOfSubjectWithProperty1\n {\n public SubjectWithProperty1[] Children { get; }\n\n public ParentOfSubjectWithProperty1(SubjectWithProperty1[] children)\n {\n Children = children;\n }\n }\n\n internal class ParentOfSubjectWithExplicitlyImplementedProperty\n {\n public SubjectWithExplicitImplementedProperty[] Children { get; }\n\n public ParentOfSubjectWithExplicitlyImplementedProperty(SubjectWithExplicitImplementedProperty[] children)\n {\n Children = children;\n }\n }\n\n internal class SubjectWithProperty1\n {\n public string Property1 { get; set; }\n }\n\n internal class SubjectWithExplicitImplementedProperty : IProperty\n {\n string IProperty.Property { get; set; }\n }\n\n internal interface IProperty\n {\n string Property { get; set; }\n }\n\n internal class ExpectationWithProperty2\n {\n public string Property2 { get; set; }\n }\n\n internal class Base\n {\n public string BaseProperty { get; set; }\n }\n\n internal class Derived : Base\n {\n public string DerivedProperty { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/AssemblyAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \npublic class AssemblyAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public AssemblyAssertions(Assembly assembly, AssertionChain assertionChain)\n : base(assembly, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that an assembly does not reference the specified assembly.\n /// \n /// The assembly which should not be referenced.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotReference(Assembly assembly,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(assembly);\n\n var assemblyName = assembly.GetName().Name;\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected assembly not to reference assembly {0}{reason}, but {context:assembly} is .\",\n assemblyName);\n\n if (assertionChain.Succeeded)\n {\n var subjectName = Subject!.GetName().Name;\n\n IEnumerable references = Subject.GetReferencedAssemblies().Select(x => x.Name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!references.Contains(assemblyName))\n .FailWith(\"Expected assembly {0} not to reference assembly {1}{reason}.\", subjectName, assemblyName);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that an assembly references the specified assembly.\n /// \n /// The assembly which should be referenced.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Reference(Assembly assembly,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(assembly);\n\n var assemblyName = assembly.GetName().Name;\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected assembly to reference assembly {0}{reason}, but {context:assembly} is .\", assemblyName);\n\n if (assertionChain.Succeeded)\n {\n var subjectName = Subject!.GetName().Name;\n\n IEnumerable references = Subject.GetReferencedAssemblies().Select(x => x.Name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(references.Contains(assemblyName))\n .FailWith(\"Expected assembly {0} to reference assembly {1}{reason}, but it does not.\", subjectName, assemblyName);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the assembly defines a type called and .\n /// \n /// The namespace of the class.\n /// The name of the class.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndWhichConstraint DefineType(string @namespace, string name,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(name);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected assembly to define type {0}.{1}{reason}, but {context:assembly} is .\",\n @namespace, name);\n\n Type foundType = null;\n\n if (assertionChain.Succeeded)\n {\n foundType = Subject!.GetTypes().SingleOrDefault(t => t.Namespace == @namespace && t.Name == name);\n\n assertionChain\n .ForCondition(foundType is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected assembly {0} to define type {1}.{2}{reason}, but it does not.\",\n Subject.FullName, @namespace, name);\n }\n\n return new AndWhichConstraint(this, foundType);\n }\n\n /// Asserts that the assembly is unsigned.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeUnsigned([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .FailWith(\"Can't check for assembly signing if {context:assembly} reference is .\");\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.GetName().GetPublicKey() is not { Length: > 0 })\n .FailWith(\n \"Did not expect the assembly {0} to be signed{reason}, but it is.\", Subject.FullName);\n }\n\n return new AndConstraint(this);\n }\n\n /// Asserts that the assembly is signed with the specified public key.\n /// \n /// The base-16 string representation of the public key, like \"e0851575614491c6d25018fadb75\".\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n /// is empty.\n public AndConstraint BeSignedWithPublicKey(string publicKey,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNullOrEmpty(publicKey);\n\n assertionChain\n .ForCondition(Subject is not null)\n .FailWith(\"Can't check for assembly signing if {context:assembly} reference is .\");\n\n if (assertionChain.Succeeded)\n {\n var bytes = Subject!.GetName().GetPublicKey() ?? [];\n string assemblyKey = ToHexString(bytes);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected assembly {0} to have public key {1} \", Subject.FullName, publicKey, chain => chain\n .ForCondition(bytes.Length != 0)\n .FailWith(\"{reason}, but it is unsigned.\")\n .Then\n .ForCondition(string.Equals(assemblyKey, publicKey, StringComparison.OrdinalIgnoreCase))\n .FailWith(\"{reason}, but it has {0} instead.\", assemblyKey));\n }\n\n return new AndConstraint(this);\n }\n\n private static string ToHexString(byte[] bytes) =>\n#if NET6_0_OR_GREATER\n Convert.ToHexString(bytes);\n#else\n BitConverter.ToString(bytes).Replace(\"-\", string.Empty, StringComparison.Ordinal);\n#endif\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"assembly\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/FormatterSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Formatting;\nusing AwesomeAssertions.Specs.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\n[Collection(\"FormatterSpecs\")]\npublic sealed class FormatterSpecs : IDisposable\n{\n [Fact]\n public void Use_configuration_when_highlighting_string_difference()\n {\n // Arrange\n string subject = \"this is a very long string with lots of words that most won't be displayed in the error message!\";\n string expected = \"this is another string that differs after a couple of words.\";\n Action action = () => subject.Should().Be(expected);\n\n int previousStringPrintLength = AssertionConfiguration.Current.Formatting.StringPrintLength;\n try\n {\n // Act\n AssertionConfiguration.Current.Formatting.StringPrintLength = 10;\n\n // Assert\n action.Should().Throw().WithMessage(\"\"\"\n *\n ↓ (actual)\n \"this is a very long…\"\n \"this is another…\"\n ↑ (expected).\n \"\"\");\n }\n finally\n {\n AssertionConfiguration.Current.Formatting.StringPrintLength = previousStringPrintLength;\n }\n }\n\n [Fact]\n public void When_value_contains_cyclic_reference_it_should_create_descriptive_error_message()\n {\n // Arrange\n var parent = new Node();\n parent.Children.Add(new Node());\n parent.Children.Add(parent);\n\n // Act\n string result = Formatter.ToString(parent);\n\n // Assert\n result.Should().ContainEquivalentOf(\"cyclic reference\");\n }\n\n [Fact]\n public void When_the_same_object_appears_twice_in_the_graph_at_different_paths()\n {\n // Arrange\n var a = new A();\n\n var b = new B\n {\n X = a,\n Y = a\n };\n\n // Act\n Action act = () => b.Should().BeNull();\n\n // Assert\n var exception = act.Should().Throw().Which;\n exception.Message.Should().NotContainEquivalentOf(\"cyclic\");\n }\n\n private class A;\n\n private class B\n {\n public A X { get; set; }\n\n public A Y { get; set; }\n }\n\n [Fact]\n public void When_the_subject_or_expectation_contains_reserved_symbols_it_should_escape_then()\n {\n // Arrange\n string result = \"{ a : [{ b : \\\"2016-05-23T10:45:12Z\\\" } ]}\";\n\n string expectedJson = \"{ a : [{ b : \\\"2016-05-23T10:45:12Z\\\" }] }\";\n\n // Act\n Action act = () => result.Should().Be(expectedJson);\n\n // Assert\n act.Should().Throw().WithMessage(\"*at*index 37*\");\n }\n\n [Fact]\n public void When_a_timespan_is_one_tick_it_should_be_formatted_as_positive()\n {\n // Arrange\n var time = TimeSpan.FromTicks(1);\n\n // Act\n string result = Formatter.ToString(time);\n\n // Assert\n result.Should().NotStartWith(\"-\");\n }\n\n [Fact]\n public void When_a_timespan_is_minus_one_tick_it_should_be_formatted_as_negative()\n {\n // Arrange\n var time = TimeSpan.FromTicks(-1);\n\n // Act\n string result = Formatter.ToString(time);\n\n // Assert\n result.Should().StartWith(\"-\");\n }\n\n [Fact]\n public void When_a_datetime_is_very_close_to_the_edges_of_a_datetimeoffset_it_should_not_crash()\n {\n // Arrange\n var dateTime = DateTime.MinValue + 1.Minutes();\n\n // Act\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<00:01:00>\");\n }\n\n [Fact]\n public void When_the_minimum_value_of_a_datetime_is_provided_it_should_return_a_clear_representation()\n {\n // Arrange\n var dateTime = DateTime.MinValue;\n\n // Act\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<0001-01-01 00:00:00.000>\");\n }\n\n [Fact]\n public void When_the_maximum_value_of_a_datetime_is_provided_it_should_return_a_clear_representation()\n {\n // Arrange\n var dateTime = DateTime.MaxValue;\n\n // Act\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<9999-12-31 23:59:59.9999999>\");\n }\n\n [Fact]\n public void When_a_property_throws_an_exception_it_should_ignore_that_and_still_create_a_descriptive_error_message()\n {\n // Arrange\n var subject = new ExceptionThrowingClass();\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Contain(\"Member 'ThrowingProperty' threw an exception: 'CustomMessage'\");\n }\n\n [Fact]\n public void When_an_exception_contains_an_inner_exception_they_should_both_appear_in_the_error_message()\n {\n // Arrange\n Exception subject = new(\"OuterExceptionMessage\", new InvalidOperationException(\"InnerExceptionMessage\"));\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Contain(\"OuterExceptionMessage\")\n .And.Contain(\"InnerExceptionMessage\");\n }\n\n [InlineData(typeof(ulong), \"ulong\")]\n [InlineData(typeof(void), \"void\")]\n [InlineData(typeof(float?), \"float?\")]\n [Theory]\n public void When_the_object_is_a_primitive_type_it_should_be_formatted_as_language_keyword(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(List), \"System.Collections.Generic.List\")]\n [InlineData(typeof(Dictionary<,>), \"System.Collections.Generic.Dictionary\")]\n [InlineData(typeof(Dictionary>, Dictionary>>), \"System.Collections.Generic.Dictionary>, System.Collections.Generic.Dictionary>>\")]\n public void When_the_object_is_a_generic_type_it_should_be_formatted_as_written_in_source_code(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(int[]), \"int[]\")]\n [InlineData(typeof(float[][]), \"float[][]\")]\n [InlineData(typeof(float[][][]), \"float[][][]\")]\n [InlineData(typeof(FormatterSpecs[,]), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs[,]\")]\n [InlineData(typeof((string, int, Type)[,,]), \"System.ValueTuple[,,]\")]\n public void When_the_object_is_an_array_it_should_be_formatted_as_written_in_source_code(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(NestedClass), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs+NestedClass\")]\n [InlineData(typeof(NestedClass), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs+NestedClass\")]\n [InlineData(typeof(NestedClass.InnerClass), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs+NestedClass`1+InnerClass\")]\n public void When_the_object_is_a_nested_class_its_declaring_types_should_be_formatted_like_the_clr_shorthand(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(int?[]), \"int?[]\")]\n [InlineData(typeof((string, int?)), \"System.ValueTuple\")]\n public void When_the_object_contains_a_nullable_type_somewhere_it_should_be_formatted_with_a_questionmark(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(typeof(List), \"List\")]\n [InlineData(typeof(Dictionary<,>), \"Dictionary\")]\n [InlineData(typeof(Dictionary>, Dictionary>>), \"Dictionary>, Dictionary>>\")]\n public void When_the_object_is_a_shortvaluetype_with_generic_type_it_should_be_formatted_as_written_in_source_code_without_namespaces(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject.AsFormattableShortType());\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(null, \"\")]\n [InlineData(typeof(FormatterSpecs), \"AwesomeAssertions.Specs.Formatting.FormatterSpecs\")]\n [InlineData(typeof(List), \"System.Collections.Generic.List\")]\n [InlineData(typeof(Dictionary<,>), \"System.Collections.Generic.Dictionary\")]\n [InlineData(typeof(Dictionary>, Dictionary>>), \"System.Collections.Generic.Dictionary\")]\n public void When_the_object_is_requested_to_be_formatted_as_type_definition_it_should_format_without_generic_argument_details(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject.AsFormattableTypeDefinition());\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(null, \"\")]\n [InlineData(typeof(FormatterSpecs), \"FormatterSpecs\")]\n [InlineData(typeof(List), \"List\")]\n [InlineData(typeof(Dictionary<,>), \"Dictionary\")]\n [InlineData(typeof(Dictionary>, Dictionary>>), \"Dictionary\")]\n public void When_the_object_is_requested_to_be_formatted_as_short_type_definition_it_should_format_without_generic_argument_details_and_without_namespaces(Type subject, string expected)\n {\n // Act\n string result = Formatter.ToString(subject.AsFormattableShortTypeDefinition());\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Fact]\n public void When_the_object_is_a_class_without_namespace_it_should_be_formatted_with_the_class_name_only()\n {\n // Act\n string result = Formatter.ToString(typeof(AssertionScopeSpecsWithoutNamespace));\n\n // Assert\n result.Should().Be(nameof(AssertionScopeSpecsWithoutNamespace));\n }\n\n private sealed class NestedClass\n {\n public sealed class InnerClass;\n }\n\n private sealed class NestedClass\n {\n public sealed class InnerClass;\n }\n\n [Fact]\n public void When_the_object_is_a_generic_type_without_custom_string_representation_it_should_show_the_properties()\n {\n // Arrange\n var stuff = new List>\n {\n new()\n {\n StuffId = 1,\n Description = \"Stuff_1\",\n Children = [1, 2, 3, 4]\n },\n new()\n {\n StuffId = 2,\n Description = \"Stuff_2\",\n Children = [1, 2, 3, 4]\n }\n };\n\n var expectedStuff = new List>\n {\n new()\n {\n StuffId = 1,\n Description = \"Stuff_1\",\n Children = [1, 2, 3, 4]\n },\n new()\n {\n StuffId = 2,\n Description = \"WRONG_DESCRIPTION\",\n Children = [1, 2, 3, 4]\n }\n };\n\n // Act\n Action act = () => stuff.Should().NotBeNull()\n .And.Equal(expectedStuff, (t1, t2) => t1.StuffId == t2.StuffId && t1.Description == t2.Description);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"\"\"\n Expected stuff to be equal to\n {\n AwesomeAssertions.Specs.Formatting.FormatterSpecs+Stuff\n {\n Children = {1, 2, 3, 4},\n Description = \"Stuff_1\",\n StuffId = 1\n },\n AwesomeAssertions.Specs.Formatting.FormatterSpecs+Stuff\n {\n Children = {1, 2, 3, 4},\n Description = \"WRONG_DESCRIPTION\",\n StuffId = 2\n }\n }, but\n {\n AwesomeAssertions.Specs.Formatting.FormatterSpecs+Stuff\n {\n Children = {1, 2, 3, 4},\n Description = \"Stuff_1\",\n StuffId = 1\n },\n AwesomeAssertions.Specs.Formatting.FormatterSpecs+Stuff\n {\n Children = {1, 2, 3, 4},\n Description = \"Stuff_2\",\n StuffId = 2\n }\n } differs at index 1.\n \"\"\");\n }\n\n [Fact]\n public void When_the_object_is_a_user_defined_type_it_should_show_the_name_on_the_initial_line()\n {\n // Arrange\n var stuff = new StuffRecord(42, \"description\", new ChildRecord(24), [10, 20, 30, 40]);\n\n // Act\n Action act = () => stuff.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\n \"\"\"\n Expected stuff to be , but found AwesomeAssertions.Specs.Formatting.FormatterSpecs+StuffRecord\n {\n RecordChildren = {10, 20, 30, 40},\n RecordDescription = \"description\",\n RecordId = 42,\n SingleChild = AwesomeAssertions.Specs.Formatting.FormatterSpecs+ChildRecord\n {\n ChildRecordId = 24\n }\n }.\n \"\"\");\n }\n\n [Fact]\n public void When_the_object_is_an_anonymous_type_it_should_show_the_properties_recursively()\n {\n // Arrange\n var stuff = new\n {\n Description = \"absent\",\n SingleChild = new { ChildId = 8 },\n Children = new[] { 1, 2, 3, 4 },\n };\n\n var expectedStuff = new\n {\n SingleChild = new { ChildId = 4 },\n Children = new[] { 10, 20, 30, 40 },\n };\n\n // Act\n Action act = () => stuff.Should().Be(expectedStuff);\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Be(\n \"\"\"\n Expected stuff to be\n {\n Children = {10, 20, 30, 40},\n SingleChild =\n {\n ChildId = 4\n }\n }, but found\n {\n Children = {1, 2, 3, 4},\n Description = \"absent\",\n SingleChild =\n {\n ChildId = 8\n }\n }.\n \"\"\");\n }\n\n [Fact]\n public void\n When_the_object_is_a_list_of_anonymous_type_it_should_show_the_properties_recursively_with_newlines_and_indentation()\n {\n // Arrange\n var stuff = new[]\n {\n new\n {\n Description = \"absent\",\n },\n new\n {\n Description = \"absent\",\n },\n };\n\n var expectedStuff = new[]\n {\n new\n {\n ComplexChildren = new[]\n {\n new { Property = \"hello\" },\n new { Property = \"goodbye\" },\n },\n },\n };\n\n // Act\n Action act = () => stuff.Should().BeEquivalentTo(expectedStuff);\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\n \"\"\"\n Expected stuff to be a collection with 1 item(s), but*\n {\n {\n Description = \"absent\"\n },*\n {\n Description = \"absent\"\n }\n }\n contains 1 item(s) more than\n\n {\n {\n ComplexChildren =*\n {\n {\n Property = \"hello\"\n },*\n {\n Property = \"goodbye\"\n }\n }\n }\n }.*\n \"\"\");\n }\n\n [Fact]\n public void When_the_object_is_an_empty_anonymous_type_it_should_show_braces_on_the_same_line()\n {\n // Arrange\n var stuff = new\n {\n };\n\n // Act\n Action act = () => stuff.Should().BeNull();\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"*but found { }*\");\n }\n\n [Fact]\n public void When_the_object_is_a_tuple_it_should_show_the_properties_recursively()\n {\n // Arrange\n (int TupleId, string Description, List Children) stuff = (1, \"description\", [1, 2, 3, 4]);\n\n (int, string, List) expectedStuff = (2, \"WRONG_DESCRIPTION\", new List { 4, 5, 6, 7 });\n\n // Act\n Action act = () => stuff.Should().Be(expectedStuff);\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\n \"\"\"\n Expected stuff to be equal to*\n {\n Item1 = 2,*\n Item2 = \"WRONG_DESCRIPTION\",*\n Item3 = {4, 5, 6, 7}\n }, but found*\n {\n Item1 = 1,*\n Item2 = \"description\",*\n Item3 = {1, 2, 3, 4}\n }.*\n \"\"\");\n }\n\n [Fact]\n public void When_the_object_is_a_record_it_should_show_the_properties_recursively()\n {\n // Arrange\n var stuff = new StuffRecord(\n RecordId: 9,\n RecordDescription: \"descriptive\",\n SingleChild: new ChildRecord(ChildRecordId: 80),\n RecordChildren: [4, 5, 6, 7]);\n\n var expectedStuff = new\n {\n RecordDescription = \"WRONG_DESCRIPTION\",\n };\n\n // Act\n Action act = () => stuff.Should().Be(expectedStuff);\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\n \"\"\"\n Expected stuff to be*\n {\n RecordDescription = \"WRONG_DESCRIPTION\"\n }, but found AwesomeAssertions.Specs.Formatting.FormatterSpecs+StuffRecord\n {\n RecordChildren = {4, 5, 6, 7},*\n RecordDescription = \"descriptive\",*\n RecordId = 9,*\n SingleChild = AwesomeAssertions.Specs.Formatting.FormatterSpecs+ChildRecord\n {\n ChildRecordId = 80\n }\n }.\n \"\"\");\n }\n\n [Fact]\n public void When_the_to_string_override_throws_it_should_use_the_default_behavior()\n {\n // Arrange\n var subject = new NullThrowingToStringImplementation();\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Contain(\"SomeProperty\");\n }\n\n [Fact]\n public void\n When_the_maximum_recursion_depth_is_met_it_should_give_a_descriptive_message()\n {\n // Arrange\n var head = new Node();\n var node = head;\n\n int maxDepth = 10;\n int iterations = (maxDepth / 2) + 1; // Each iteration adds two levels of depth to the graph\n\n foreach (int i in Enumerable.Range(0, iterations))\n {\n var newHead = new Node();\n node.Children.Add(newHead);\n node = newHead;\n }\n\n // Act\n string result = Formatter.ToString(head, new FormattingOptions\n {\n MaxDepth = maxDepth\n });\n\n // Assert\n result.Should().ContainEquivalentOf($\"maximum recursion depth of {maxDepth}\");\n }\n\n [Fact]\n public void When_the_maximum_recursion_depth_is_never_reached_it_should_render_the_entire_graph()\n {\n // Arrange\n var head = new Node();\n var node = head;\n\n int iterations = 10;\n\n foreach (int i in Enumerable.Range(0, iterations))\n {\n var newHead = new Node();\n node.Children.Add(newHead);\n node = newHead;\n }\n\n // Act\n string result = Formatter.ToString(head, new FormattingOptions\n {\n // Each iteration adds two levels of depth to the graph\n MaxDepth = (iterations * 2) + 1\n });\n\n // Assert\n result.Should().NotContainEquivalentOf(\"maximum recursion depth\");\n }\n\n [Fact]\n public void When_formatting_a_collection_exceeds_the_max_line_count_it_should_cut_off_the_result()\n {\n // Arrange\n var collection = Enumerable.Range(0, 20)\n .Select(i => new StuffWithAField\n {\n Description = $\"Property {i}\",\n Field = $\"Field {i}\",\n StuffId = i\n })\n .ToArray();\n\n // Act\n string result = Formatter.ToString(collection, new FormattingOptions\n {\n MaxLines = 50\n });\n\n // Assert\n result.Should().Match(\"*Output has exceeded*50*line*\");\n }\n\n [Fact]\n public void When_formatting_a_byte_array_it_should_limit_the_items()\n {\n // Arrange\n byte[] value = new byte[1000];\n new Random().NextBytes(value);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Match(\"{0x*, …968 more…}\");\n }\n\n [Fact]\n public void When_formatting_with_default_behavior_it_should_include_non_private_fields()\n {\n // Arrange\n var stuffWithAField = new StuffWithAField { Field = \"Some Text\" };\n\n // Act\n string result = Formatter.ToString(stuffWithAField);\n\n // Assert\n result.Should().Contain(\"Field\").And.Contain(\"Some Text\");\n result.Should().NotContain(\"privateField\");\n }\n\n [Fact]\n public void When_formatting_unsigned_integer_it_should_have_c_sharp_postfix()\n {\n // Arrange\n uint value = 12U;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12u\");\n }\n\n [Fact]\n public void When_formatting_long_integer_it_should_have_c_sharp_postfix()\n {\n // Arrange\n long value = 12L;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12L\");\n }\n\n [Fact]\n public void When_formatting_unsigned_long_integer_it_should_have_c_sharp_postfix()\n {\n // Arrange\n ulong value = 12UL;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12UL\");\n }\n\n [Fact]\n public void When_formatting_short_integer_it_should_have_f_sharp_postfix()\n {\n // Arrange\n short value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12s\");\n }\n\n [Fact]\n public void When_formatting_unsigned_short_integer_it_should_have_f_sharp_postfix()\n {\n // Arrange\n ushort value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12us\");\n }\n\n [Fact]\n public void When_formatting_byte_it_should_use_hexadecimal_notation()\n {\n // Arrange\n byte value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"0x0C\");\n }\n\n [Fact]\n public void When_formatting_signed_byte_it_should_have_f_sharp_postfix()\n {\n // Arrange\n sbyte value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12y\");\n }\n\n [Fact]\n public void When_formatting_single_it_should_have_c_sharp_postfix()\n {\n // Arrange\n float value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12F\");\n }\n\n [Fact]\n public void When_formatting_single_positive_infinity_it_should_be_property_reference()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"Single.PositiveInfinity\");\n }\n\n [Fact]\n public void When_formatting_single_negative_infinity_it_should_be_property_reference()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"Single.NegativeInfinity\");\n }\n\n [Fact]\n public void When_formatting_single_it_should_have_max_precision()\n {\n // Arrange\n float value = 1 / 3F;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().BeOneOf(\"0.33333334F\", \"0.333333343F\");\n }\n\n [Fact]\n public void When_formatting_single_not_a_number_it_should_just_say_nan()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n // NaN is not even equal to itself so its type does not matter.\n result.Should().Be(\"NaN\");\n }\n\n [Fact]\n public void When_formatting_double_integer_it_should_have_decimal_point()\n {\n // Arrange\n double value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12.0\");\n }\n\n [Fact]\n public void When_formatting_double_with_big_exponent_it_should_have_exponent()\n {\n // Arrange\n double value = 1E+30;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"1E+30\");\n }\n\n [Fact]\n public void When_formatting_double_positive_infinity_it_should_be_property_reference()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"Double.PositiveInfinity\");\n }\n\n [Fact]\n public void When_formatting_double_negative_infinity_it_should_be_property_reference()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"Double.NegativeInfinity\");\n }\n\n [Fact]\n public void When_formatting_double_not_a_number_it_should_just_say_nan()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n // NaN is not even equal to itself so its type does not matter.\n result.Should().Be(\"NaN\");\n }\n\n [Fact]\n public void When_formatting_double_it_should_have_max_precision()\n {\n // Arrange\n double value = 1 / 3D;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().BeOneOf(\"0.3333333333333333\", \"0.33333333333333331\");\n }\n\n [Fact]\n public void When_formatting_decimal_it_should_have_c_sharp_postfix()\n {\n // Arrange\n decimal value = 12;\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(\"12M\");\n }\n\n [Fact]\n public void When_formatting_a_pending_task_it_should_return_the_task_status()\n {\n // Arrange\n Task bar = new TaskCompletionSource().Task;\n\n // Act\n string result = Formatter.ToString(bar);\n\n // Assert\n result.Should().Be(\"System.Threading.Tasks.Task {Status=WaitingForActivation}\");\n }\n\n [Fact]\n public void When_formatting_a_completion_source_it_should_include_the_underlying_task()\n {\n // Arrange\n var completionSource = new TaskCompletionSource();\n\n // Act\n string result = Formatter.ToString(completionSource);\n\n // Assert\n result.Should().Match(\"*TaskCompletionSource*System.Threading.Tasks.Task*Status=WaitingForActivation*\");\n }\n\n private class MyKey\n {\n public int KeyProp { get; set; }\n }\n\n private class MyValue\n {\n public int ValueProp { get; set; }\n }\n\n [Fact]\n public void When_formatting_a_dictionary_it_should_format_keys_and_values()\n {\n // Arrange\n var subject = new Dictionary\n {\n [new MyKey { KeyProp = 13 }] = new() { ValueProp = 37 }\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Match(\"*{*[*MyKey*KeyProp = 13*] = *MyValue*ValueProp = 37*}*\");\n }\n\n [Fact]\n public void When_formatting_an_empty_dictionary_it_should_be_clear_from_the_message()\n {\n // Arrange\n var subject = new Dictionary();\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Match(\"{empty}\");\n }\n\n [Fact]\n public void When_formatting_a_large_dictionary_it_should_limit_the_number_of_formatted_entries()\n {\n // Arrange\n var subject = Enumerable.Range(0, 50).ToDictionary(e => e, e => e);\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Match(\"*…18 more…*\");\n }\n\n [Fact]\n public void\n When_formatting_multiple_items_with_a_custom_string_representation_using_line_breaks_it_should_end_lines_with_a_comma()\n {\n // Arrange\n object[] subject = [new ClassAWithToStringOverride(), new ClassBWithToStringOverride()];\n\n // Act\n string result = Formatter.ToString(subject, new FormattingOptions { UseLineBreaks = true });\n\n // Assert\n result.Should().Contain($\"One override, {Environment.NewLine}\");\n result.Should().Contain($\"Other override{Environment.NewLine}\");\n }\n\n private class ClassAWithToStringOverride\n {\n public override string ToString() => \"One override\";\n }\n\n private class ClassBWithToStringOverride\n {\n public override string ToString() => \"Other override\";\n }\n\n public class BaseStuff\n {\n public int StuffId { get; set; }\n\n public string Description { get; set; }\n }\n\n public class StuffWithAField\n {\n public int StuffId { get; set; }\n\n public string Description { get; set; }\n\n public string Field;\n#pragma warning disable 169, CA1823, IDE0044, RCS1169\n private string privateField;\n#pragma warning restore 169, CA1823, IDE0044, RCS1169\n }\n\n public class Stuff : BaseStuff\n {\n public List Children { get; set; }\n }\n\n private record StuffRecord(int RecordId, string RecordDescription, ChildRecord SingleChild, List RecordChildren);\n\n private record ChildRecord(int ChildRecordId);\n\n [Fact]\n public void When_defining_a_custom_value_formatter_it_should_respect_the_overrides()\n {\n // Arrange\n var value = new CustomClass();\n var formatter = new CustomClassValueFormatter();\n using var _ = new FormatterScope(formatter);\n\n // Act\n string str = Formatter.ToString(value);\n\n // Assert\n str.Should().Match(\n \"*CustomClass\" + Environment.NewLine +\n \"{\" + Environment.NewLine +\n \" IntProperty = 0\" + Environment.NewLine +\n \"}*\");\n }\n\n private class CustomClass\n {\n public int IntProperty { get; set; }\n\n public string StringProperty { get; set; }\n }\n\n private class CustomClassValueFormatter : DefaultValueFormatter\n {\n public override bool CanHandle(object value) => value is CustomClass;\n\n protected override MemberInfo[] GetMembers(Type type)\n {\n return base\n .GetMembers(type)\n .Where(e => e.GetUnderlyingType() != typeof(string))\n .ToArray();\n }\n\n protected override string TypeDisplayName(Type type) => type.Name;\n }\n\n [Fact]\n public void When_defining_a_custom_enumerable_value_formatter_it_should_respect_the_overrides()\n {\n // Arrange\n var values = new CustomClass[]\n {\n new() { IntProperty = 1 },\n new() { IntProperty = 2 }\n };\n\n var formatter = new SingleItemValueFormatter();\n using var _ = new FormatterScope(formatter);\n\n // Act\n string str = Formatter.ToString(values);\n\n str.Should().Match(Environment.NewLine +\n \"{*AwesomeAssertions*FormatterSpecs+CustomClass\" + Environment.NewLine +\n \" {\" + Environment.NewLine +\n \" IntProperty = 1,\" + Environment.NewLine +\n \" StringProperty = \" + Environment.NewLine +\n \" },*…1 more…*}*\");\n }\n\n private class SingleItemValueFormatter : EnumerableValueFormatter\n {\n protected override int MaxItems => 1;\n\n public override bool CanHandle(object value) => value is IEnumerable;\n }\n\n private sealed class FormatterScope : IDisposable\n {\n private readonly IValueFormatter formatter;\n\n public FormatterScope(IValueFormatter formatter)\n {\n this.formatter = formatter;\n Formatter.AddFormatter(formatter);\n }\n\n public void Dispose() => Formatter.RemoveFormatter(formatter);\n }\n\n public void Dispose() => AssertionEngine.ResetToDefaults();\n}\n\ninternal class ExceptionThrowingClass\n{\n public string ThrowingProperty => throw new InvalidOperationException(\"CustomMessage\");\n}\n\ninternal class NullThrowingToStringImplementation\n{\n public NullThrowingToStringImplementation()\n {\n SomeProperty = \"SomeProperty\";\n }\n\n public string SomeProperty { get; set; }\n\n public override string ToString()\n {\n return null;\n }\n}\n\ninternal class Node\n{\n public Node()\n {\n Children = [];\n }\n\n public static Node Default { get; } = new();\n\n public List Children { get; set; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ReferenceTypeAssertionsSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ReferenceTypeAssertionsSpecs\n{\n [Fact]\n public void When_the_same_objects_are_expected_to_be_the_same_it_should_not_fail()\n {\n // Arrange\n var subject = new ClassWithCustomEqualMethod(1);\n var referenceToSubject = subject;\n\n // Act / Assert\n subject.Should().BeSameAs(referenceToSubject);\n }\n\n [Fact]\n public void When_two_different_objects_are_expected_to_be_the_same_it_should_fail_with_a_clear_explanation()\n {\n // Arrange\n var subject = new\n {\n Name = \"John Doe\"\n };\n\n var otherObject = new\n {\n UserName = \"JohnDoe\"\n };\n\n // Act\n Action act = () => subject.Should().BeSameAs(otherObject, \"they are {0} {1}\", \"the\", \"same\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"\"\"\n Expected subject to refer to\n {\n UserName = \"JohnDoe\"\n } because they are the same, but found\n {\n Name = \"John Doe\"\n }.\n \"\"\");\n }\n\n [Fact]\n public void When_a_derived_class_has_longer_formatting_than_the_base_class()\n {\n var subject = new SimpleComplexBase[] { new Complex(\"goodbye\"), new Simple() };\n Action act = () => subject.Should().BeEmpty();\n act.Should().Throw()\n .WithMessage(\n \"\"\"\n Expected subject to be empty, but found at least one item\n {\n AwesomeAssertions.Specs.Primitives.Complex\n {\n Statement = \"goodbye\"\n }\n }.\n \"\"\");\n }\n\n [Fact]\n public void When_two_different_objects_are_expected_not_to_be_the_same_it_should_not_fail()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var notSameObject = new ClassWithCustomEqualMethod(1);\n\n // Act / Assert\n someObject.Should().NotBeSameAs(notSameObject);\n }\n\n [Fact]\n public void When_two_equal_object_are_expected_not_to_be_the_same_it_should_fail()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n ClassWithCustomEqualMethod sameObject = someObject;\n\n // Act\n Action act = () => someObject.Should().NotBeSameAs(sameObject, \"they are {0} {1}\", \"the\", \"same\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect someObject to refer to*ClassWithCustomEqualMethod(1) because they are the same.\");\n }\n\n [Fact]\n public void When_object_is_of_the_expected_type_it_should_not_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act / Assert\n aString.Should().BeOfType(typeof(string));\n }\n\n [Fact]\n public void When_object_is_of_the_expected_open_generic_type_it_should_not_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act / Assert\n aList.Should().BeOfType(typeof(List<>));\n }\n\n [Fact]\n public void When_object_is_not_of_the_expected_open_generic_type_it_should_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act\n Action action = () => aList.Should().BeOfType(typeof(Dictionary<,>));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type to be System.Collections.Generic.Dictionary, but found System.Collections.Generic.List.\");\n }\n\n [Fact]\n public void When_object_is_null_it_should_throw()\n {\n // Arrange\n string aString = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n aString.Should().BeOfType(typeof(string));\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected aString to be string, but found .\");\n }\n\n [Fact]\n public void When_object_is_not_of_the_expected_type_it_should_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act\n Action action = () => aString.Should().BeOfType(typeof(int));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type to be int, but found string.\");\n }\n\n [Fact]\n public void When_an_assertion_fails_on_BeOfType_succeeding_message_should_be_included()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var item = string.Empty;\n item.Should().BeOfType();\n item.Should().BeOfType();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to be int, but found string.*\" +\n \"Expected type to be long, but found string.\");\n }\n\n [Fact]\n public void When_object_is_of_the_unexpected_type_it_should_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act\n Action action = () => aString.Should().NotBeOfType(typeof(string));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type not to be [\" + typeof(string).AssemblyQualifiedName + \"], but it is.\");\n }\n\n [Fact]\n public void When_object_is_of_the_unexpected_generic_type_it_should_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act\n Action action = () => aString.Should().NotBeOfType();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type not to be [\" + typeof(string).AssemblyQualifiedName + \"], but it is.\");\n }\n\n [Fact]\n public void When_object_is_of_the_unexpected_open_generic_type_it_should_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act\n Action action = () => aList.Should().NotBeOfType(typeof(List<>));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type not to be [\" + typeof(List<>).AssemblyQualifiedName + \"], but it is.\");\n }\n\n [Fact]\n public void When_object_is_not_of_the_expected_type_it_should_not_throw()\n {\n // Arrange\n string aString = \"blah\";\n\n // Act / Assert\n aString.Should().NotBeOfType(typeof(int));\n }\n\n [Fact]\n public void When_object_is_not_of_the_unexpected_open_generic_type_it_should_not_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act / Assert\n aList.Should().NotBeOfType(typeof(Dictionary<,>));\n }\n\n [Fact]\n public void When_generic_object_is_not_of_the_unexpected_type_it_should_not_throw()\n {\n // Arrange\n var aList = new List();\n\n // Act / Assert\n aList.Should().NotBeOfType();\n }\n\n [Fact]\n public void When_non_generic_object_is_not_of_the_unexpected_open_generic_type_it_should_not_throw()\n {\n // Arrange\n var aString = \"blah\";\n\n // Act / Assert\n aString.Should().NotBeOfType(typeof(Dictionary<,>));\n }\n\n [Fact]\n public void When_asserting_object_is_not_of_type_and_it_is_null_it_should_throw()\n {\n // Arrange\n string aString = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n aString.Should().NotBeOfType(typeof(string));\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected aString not to be string, but found .\");\n }\n\n [Fact]\n public void When_object_satisfies_predicate_it_should_not_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act / Assert\n someObject.Should().Match(o => o != null);\n }\n\n [Fact]\n public void When_typed_object_satisfies_predicate_it_should_not_throw()\n {\n // Arrange\n var someObject = new SomeDto\n {\n Name = \"Dennis Doomen\",\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20)\n };\n\n // Act / Assert\n someObject.Should().Match(o => o.Age > 0);\n }\n\n [Fact]\n public void When_object_does_not_match_the_predicate_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().Match(o => o == null, \"it is not initialized yet\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someObject to match (o == null) because it is not initialized yet*\");\n }\n\n [Fact]\n public void When_a_typed_object_does_not_match_the_predicate_it_should_throw()\n {\n // Arrange\n var someObject = new SomeDto\n {\n Name = \"Dennis Doomen\",\n Age = 36,\n Birthdate = new DateTime(1973, 9, 20)\n };\n\n // Act\n Action act = () => someObject.Should().Match((SomeDto d) => d.Name.Length == 0, \"it is not initialized yet\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someObject to match (d.Name.Length == 0) because it is not initialized yet*\");\n }\n\n [Fact]\n public void When_object_is_matched_against_a_null_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().Match(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot match an object against a predicate.*\");\n }\n\n #region Structure Reporting\n\n [Fact]\n public void When_an_assertion_on_two_objects_fails_it_should_show_the_properties_of_the_class()\n {\n // Arrange\n var subject = new SomeDto\n {\n Age = 37,\n Birthdate = 20.September(1973),\n Name = \"Dennis\"\n };\n\n var other = new SomeDto\n {\n Age = 2,\n Birthdate = 22.February(2009),\n Name = \"Teddie\"\n };\n\n // Act\n Action act = () => subject.Should().Be(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be*AwesomeAssertions*SomeDto*{*Age = 2*Birthdate = <2009-02-22>*\" +\n \" Name = \\\"Teddie\\\"*}, but found*AwesomeAssertions*SomeDto*{*Age = 37*\" +\n \" Birthdate = <1973-09-20>*Name = \\\"Dennis\\\"*}.\");\n }\n\n [Fact]\n public void When_an_assertion_on_two_objects_fails_and_they_implement_tostring_it_should_show_their_string_representation()\n {\n // Arrange\n object subject = 3;\n object other = 4;\n\n // Act\n Action act = () => subject.Should().Be(other);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be 4, but found 3.\");\n }\n\n [Fact]\n public void When_an_assertion_on_two_unknown_objects_fails_it_should_report_the_type_name()\n {\n // Arrange\n var subject = new object();\n var other = new object();\n\n // Act\n Action act = () => subject.Should().Be(other);\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected subject to be System.Object (HashCode={other.GetHashCode()}), \" +\n $\"but found System.Object (HashCode={subject.GetHashCode()}).\");\n }\n\n #endregion\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n var subject = new ReferenceTypeAssertionsDummy(null);\n\n // Act\n Action action = () => subject.Equals(subject);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean BeSameAs() instead?\");\n }\n\n public class ReferenceTypeAssertionsDummy : ReferenceTypeAssertions\n {\n public ReferenceTypeAssertionsDummy(object subject)\n : base(subject, AssertionChain.GetOrCreate())\n {\n }\n\n protected override string Identifier => string.Empty;\n }\n }\n}\n\npublic class SomeDto\n{\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n}\n\ninternal class ClassWithCustomEqualMethod\n{\n public ClassWithCustomEqualMethod(int key)\n {\n Key = key;\n }\n\n private int Key { get; }\n\n private bool Equals(ClassWithCustomEqualMethod other)\n {\n if (other is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, other))\n {\n return true;\n }\n\n return other.Key == Key;\n }\n\n public override bool Equals(object obj)\n {\n if (obj is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n if (obj.GetType() != typeof(ClassWithCustomEqualMethod))\n {\n return false;\n }\n\n return Equals((ClassWithCustomEqualMethod)obj);\n }\n\n public override int GetHashCode()\n {\n return Key;\n }\n\n public static bool operator ==(ClassWithCustomEqualMethod left, ClassWithCustomEqualMethod right)\n {\n return Equals(left, right);\n }\n\n public static bool operator !=(ClassWithCustomEqualMethod left, ClassWithCustomEqualMethod right)\n {\n return !Equals(left, right);\n }\n\n public override string ToString()\n {\n return $\"ClassWithCustomEqualMethod({Key})\";\n }\n}\n\npublic abstract class SimpleComplexBase;\n\npublic class Simple : SimpleComplexBase\n{\n public override string ToString() => \"Simple(Hello)\";\n}\n\npublic class Complex : SimpleComplexBase\n{\n public string Statement { get; set; }\n\n public Complex(string statement)\n {\n Statement = statement;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateTimeOffsetAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeOffsetAssertions\n : DateTimeOffsetAssertions\n{\n public DateTimeOffsetAssertions(DateTimeOffset? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeOffsetAssertions\n where TAssertions : DateTimeOffsetAssertions\n{\n public DateTimeOffsetAssertions(DateTimeOffset? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public DateTimeOffset? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current represents the same point in time as the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to represent the same point in time as {0}{reason}, \",\n expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject == expected)\n .FailWith(\"but {0} does not.\", Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current represents the same point in time as the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateTimeOffset? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (!expected.HasValue)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.HasValue)\n .FailWith(\"Expected {context:the date and time} to be {reason}, but it was {0}.\", Subject);\n }\n else\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to represent the same point in time as {0}{reason}, \",\n expected, chain => chain.ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject == expected)\n .FailWith(\"but {0} does not.\", Subject));\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not represent the same point in time as the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:the date and time} to represent the same point in time as {0}{reason}, but it did.\",\n unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not represent the same point in time as the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateTimeOffset? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:the date and time} to represent the same point in time as {0}{reason}, but it did.\",\n unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value, including its offset.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeExactly(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be exactly {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.EqualsExact(expected))\n .FailWith(\"but it was {0}.\", Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value, including its offset.\n /// Comparison is performed using \n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeExactly(DateTimeOffset? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (!expected.HasValue)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(!Subject.HasValue)\n .FailWith(\"Expected {context:the date and time} to be {reason}, but it was {0}.\", Subject);\n }\n else\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be exactly {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.EqualsExact(expected.Value))\n .FailWith(\"but it was {0}.\", Subject));\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not exactly equal to the value.\n /// Comparison is performed using \n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeExactly(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject?.EqualsExact(unexpected) != true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:the date and time} to be exactly {0}{reason}, but it was.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeExactly(DateTimeOffset? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(!((Subject == null && unexpected == null) ||\n (Subject != null && unexpected != null && Subject.Value.EqualsExact(unexpected.Value))))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:the date and time} to be exactly {0}{reason}, but it was.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The expected time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(DateTimeOffset nearbyTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n long distanceToMinInTicks = (nearbyTime - DateTimeOffset.MinValue).Ticks;\n DateTimeOffset minimumValue = nearbyTime.AddTicks(-Math.Min(precision.Ticks, distanceToMinInTicks));\n\n long distanceToMaxInTicks = (DateTimeOffset.MaxValue - nearbyTime).Ticks;\n DateTimeOffset maximumValue = nearbyTime.AddTicks(Math.Min(precision.Ticks, distanceToMaxInTicks));\n\n TimeSpan? difference = (Subject - nearbyTime)?.Duration();\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be within {0} from {1}{reason}\", precision, nearbyTime,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject >= minimumValue && Subject <= maximumValue)\n .FailWith(\", but {0} was off by {1}.\", Subject, difference));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values must differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint NotBeCloseTo(DateTimeOffset distantTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n long distanceToMinInTicks = (distantTime - DateTimeOffset.MinValue).Ticks;\n DateTimeOffset minimumValue = distantTime.AddTicks(-Math.Min(precision.Ticks, distanceToMinInTicks));\n\n long distanceToMaxInTicks = (DateTimeOffset.MaxValue - distantTime).Ticks;\n DateTimeOffset maximumValue = distantTime.AddTicks(Math.Min(precision.Ticks, distanceToMaxInTicks));\n\n CurrentAssertionChain\n .ForCondition(Subject < minimumValue || Subject > maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:the date and time} to be within {0} from {1}{reason}, but it was {2}.\",\n precision,\n distantTime, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is before the specified value.\n /// \n /// The that the current value is expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeBefore(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject < expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be before {0}{reason}, but it was {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not before the specified value.\n /// \n /// The that the current value is not expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeBefore(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or before the specified value.\n /// \n /// The that the current value is expected to be on or before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrBefore(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject <= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be on or before {0}{reason}, but it was {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor before the specified value.\n /// \n /// The that the current value is not expected to be on nor before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrBefore(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is after the specified value.\n /// \n /// The that the current value is expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAfter(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject > expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be after {0}{reason}, but it was {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not after the specified value.\n /// \n /// The that the current value is not expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAfter(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or after the specified value.\n /// \n /// The that the current value is expected to be on or after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrAfter(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject >= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be on or after {0}{reason}, but it was {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor after the specified value.\n /// \n /// The that the current value is expected not to be on nor after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrAfter(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has the year.\n /// \n /// The expected year of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveYear(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the year part of {context:the date} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Year == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Year));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the year.\n /// \n /// The year that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveYear(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the year part of {context:the date} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Year != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the month.\n /// \n /// The expected month of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMonth(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the month part of {context:the date} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Month == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Month));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the month.\n /// \n /// The month that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMonth(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the month part of {context:the date} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Month != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the day.\n /// \n /// The expected day of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveDay(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the day part of {context:the date} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Day == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Day));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the day.\n /// \n /// The day that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveDay(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the day part of {context:the date} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Day != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the hour.\n /// \n /// The expected hour of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveHour(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the hour part of {context:the time} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Hour == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Hour));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the hour.\n /// \n /// The hour that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveHour(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the hour part of {context:the time} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Hour != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the minute.\n /// \n /// The expected minutes of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMinute(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the minute part of {context:the time} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Minute == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Minute));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the minute.\n /// \n /// The minute that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMinute(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the minute part of {context:the time} to be {0}{reason}, \", unexpected,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Minute != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the second.\n /// \n /// The expected seconds of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSecond(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the seconds part of {context:the time} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Second == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Second));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the second.\n /// \n /// The second that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSecond(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the seconds part of {context:the time} to be {0}{reason}, \", unexpected,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Second != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the offset.\n /// \n /// The expected offset of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveOffset(TimeSpan expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the offset of {context:the date} to be {0}{reason}, \", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Offset == expected)\n .FailWith(\"but it was {0}.\", Subject.Value.Offset));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the offset.\n /// \n /// The offset that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveOffset(TimeSpan unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the offset of {context:the date} to be {0}{reason}, \", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Offset != unexpected)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// exceeds the specified compared to another .\n /// \n /// \n /// The amount of time that the current should exceed compared to another .\n /// \n public DateTimeOffsetRangeAssertions BeMoreThan(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.MoreThan, timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// is equal to or exceeds the specified compared to another .\n /// \n /// \n /// The amount of time that the current should be equal or exceed compared to\n /// another .\n /// \n public DateTimeOffsetRangeAssertions BeAtLeast(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.AtLeast, timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// differs exactly the specified compared to another .\n /// \n /// \n /// The amount of time that the current should differ exactly compared to another .\n /// \n public DateTimeOffsetRangeAssertions BeExactly(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.Exactly, timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// is within the specified compared to another .\n /// \n /// \n /// The amount of time that the current should be within another .\n /// \n public DateTimeOffsetRangeAssertions BeWithin(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.Within, timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// differs at maximum the specified compared to another .\n /// \n /// \n /// The maximum amount of time that the current should differ compared to another .\n /// \n public DateTimeOffsetRangeAssertions BeLessThan(TimeSpan timeSpan)\n {\n return new DateTimeOffsetRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject,\n TimeSpanCondition.LessThan, timeSpan);\n }\n\n /// \n /// Asserts that the current has the date.\n /// \n /// The expected date portion of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSameDateAs(DateTimeOffset expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n DateTime expectedDate = expected.Date;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the date part of {context:the date and time} to be {0}{reason}, \", expectedDate,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\", expectedDate)\n .Then\n .ForCondition(Subject.Value.Date == expectedDate)\n .FailWith(\"but it was {0}.\", Subject.Value.Date));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not the date.\n /// \n /// The date that is not to match the date portion of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSameDateAs(DateTimeOffset unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n DateTime unexpectedDate = unexpected.Date;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the date part of {context:the date and time} to be {0}{reason}, \", unexpectedDate,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\"but found a DateTimeOffset.\")\n .Then\n .ForCondition(Subject.Value.Date != unexpectedDate)\n .FailWith(\"but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateTimeOffset?[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateTimeOffset[] validValues)\n {\n return BeOneOf(validValues.Cast());\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOneOf(validValues.Cast(), because, becauseArgs);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be one of {0}{reason}, but it was {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XAttributeAssertions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class XAttributeAssertions : ReferenceTypeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n public XAttributeAssertions(XAttribute attribute, AssertionChain assertionChain)\n : base(attribute, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current equals the attribute.\n /// \n /// The expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(XAttribute expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject?.Name == expected?.Name && Subject?.Value == expected?.Value)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current does not equal the attribute,\n /// using its implementation.\n /// \n /// The unexpected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(XAttribute unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!(Subject?.Name == unexpected?.Name && Subject?.Value == unexpected?.Value))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context} to be {0}{reason}.\", unexpected);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the attribute to have value {0}{reason}, but {context:member} is .\", expected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(Subject!.Value == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} \\\"{0}\\\" to have value {1}{reason}, but found {2}.\",\n Subject.Name, expected, Subject.Value);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"XML attribute\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/GuidAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the correct state.\n/// \n[DebuggerNonUserCode]\npublic class GuidAssertions : GuidAssertions\n{\n public GuidAssertions(Guid? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the correct state.\n/// \n[DebuggerNonUserCode]\npublic class GuidAssertions\n where TAssertions : GuidAssertions\n{\n public GuidAssertions(Guid? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public Guid? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n #region BeEmpty / NotBeEmpty\n\n /// \n /// Asserts that the is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == Guid.Empty)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:Guid} to be empty{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeEmpty([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject is { } value && value != Guid.Empty)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:Guid} to be empty{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n #region Be / NotBe\n\n /// \n /// Asserts that the is equal to the GUID.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The format of is invalid.\n public AndConstraint Be(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (!Guid.TryParse(expected, out Guid expectedGuid))\n {\n throw new ArgumentException($\"Unable to parse \\\"{expected}\\\" as a valid GUID\", nameof(expected));\n }\n\n return Be(expectedGuid, because, becauseArgs);\n }\n\n /// \n /// Asserts that the is equal to the GUID.\n /// \n /// The expected value to compare the actual value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(Guid expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:Guid} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is not equal to the GUID.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// The format of is invalid.\n public AndConstraint NotBe(string unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n if (!Guid.TryParse(unexpected, out Guid unexpectedGuid))\n {\n throw new ArgumentException($\"Unable to parse \\\"{unexpected}\\\" as a valid GUID\", nameof(unexpected));\n }\n\n return NotBe(unexpectedGuid, because, becauseArgs);\n }\n\n /// \n /// Asserts that the is not equal to the GUID.\n /// \n /// The unexpected value to compare the actual value with.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(Guid unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:Guid} to be {0}{reason}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n #endregion\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() or BeOneOf() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/TypeSelector.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Allows for fluent filtering a list of types.\n/// \npublic class TypeSelector : IEnumerable\n{\n private List types;\n\n public TypeSelector(Type type)\n : this([type])\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// is or contains .\n public TypeSelector(IEnumerable types)\n {\n Guard.ThrowIfArgumentIsNull(types);\n Guard.ThrowIfArgumentContainsNull(types);\n\n this.types = types.ToList();\n }\n\n /// \n /// The resulting objects.\n /// \n public Type[] ToArray()\n {\n return types.ToArray();\n }\n\n /// \n /// Determines whether a type is a subclass of another type, but NOT the same type.\n /// \n public TypeSelector ThatDeriveFrom()\n {\n types = types.Where(type => type.IsSubclassOf(typeof(TBase))).ToList();\n return this;\n }\n\n /// \n /// Determines whether a type is not a subclass of another type.\n /// \n public TypeSelector ThatDoNotDeriveFrom()\n {\n types = types.Where(type => !type.IsSubclassOf(typeof(TBase))).ToList();\n return this;\n }\n\n /// \n /// Determines whether a type implements an interface (but is not the interface itself).\n /// \n public TypeSelector ThatImplement()\n {\n types = types\n .Where(t => typeof(TInterface).IsAssignableFrom(t) && t != typeof(TInterface))\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type does not implement an interface (but is not the interface itself).\n /// \n public TypeSelector ThatDoNotImplement()\n {\n types = types\n .Where(t => !typeof(TInterface).IsAssignableFrom(t) && t != typeof(TInterface))\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type is decorated with a particular attribute.\n /// \n public TypeSelector ThatAreDecoratedWith()\n where TAttribute : Attribute\n {\n types = types\n .Where(t => t.IsDecoratedWith())\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type is decorated with, or inherits from a parent class, a particular attribute.\n /// \n public TypeSelector ThatAreDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n types = types\n .Where(t => t.IsDecoratedWithOrInherit())\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type is not decorated with a particular attribute.\n /// \n public TypeSelector ThatAreNotDecoratedWith()\n where TAttribute : Attribute\n {\n types = types\n .Where(t => !t.IsDecoratedWith())\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether a type is not decorated with and does not inherit from a parent class, a particular attribute.\n /// \n public TypeSelector ThatAreNotDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n types = types\n .Where(t => !t.IsDecoratedWithOrInherit())\n .ToList();\n\n return this;\n }\n\n /// \n /// Determines whether the namespace of type is exactly .\n /// \n public TypeSelector ThatAreInNamespace(string @namespace)\n {\n types = types.Where(t => t.Namespace == @namespace).ToList();\n return this;\n }\n\n /// \n /// Determines whether the namespace of type is exactly not .\n /// \n public TypeSelector ThatAreNotInNamespace(string @namespace)\n {\n types = types.Where(t => t.Namespace != @namespace).ToList();\n return this;\n }\n\n /// \n /// Determines whether the namespace of type starts with .\n /// \n public TypeSelector ThatAreUnderNamespace(string @namespace)\n {\n types = types.Where(t => t.IsUnderNamespace(@namespace)).ToList();\n return this;\n }\n\n /// \n /// Determines whether the namespace of type does not start with .\n /// \n public TypeSelector ThatAreNotUnderNamespace(string @namespace)\n {\n types = types.Where(t => !t.IsUnderNamespace(@namespace)).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are value types\n /// \n public TypeSelector ThatAreValueTypes()\n {\n types = types.Where(t => t.IsValueType).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are not value types\n /// \n public TypeSelector ThatAreNotValueTypes()\n {\n types = types.Where(t => !t.IsValueType).ToList();\n return this;\n }\n\n /// \n /// Determines whether the type is a class\n /// \n public TypeSelector ThatAreClasses()\n {\n types = types.Where(t => t.IsClass).ToList();\n return this;\n }\n\n /// \n /// Determines whether the type is not a class\n /// \n public TypeSelector ThatAreNotClasses()\n {\n types = types.Where(t => !t.IsClass).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are abstract\n /// \n public TypeSelector ThatAreAbstract()\n {\n types = types.Where(t => t.IsCSharpAbstract()).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are not abstract\n /// \n public TypeSelector ThatAreNotAbstract()\n {\n types = types.Where(t => !t.IsCSharpAbstract()).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are sealed\n /// \n public TypeSelector ThatAreSealed()\n {\n types = types.Where(t => t.IsSealed).ToList();\n return this;\n }\n\n /// \n /// Filters and returns the types that are not sealed\n /// \n public TypeSelector ThatAreNotSealed()\n {\n types = types.Where(t => !t.IsSealed).ToList();\n return this;\n }\n\n /// \n /// Filters and returns only the types that are interfaces\n /// \n public TypeSelector ThatAreInterfaces()\n {\n types = types.Where(t => t.IsInterface).ToList();\n return this;\n }\n\n /// \n /// Filters and returns only the types that are not interfaces\n /// \n public TypeSelector ThatAreNotInterfaces()\n {\n types = types.Where(t => !t.IsInterface).ToList();\n return this;\n }\n\n /// \n /// Determines whether the type is static\n /// \n public TypeSelector ThatAreStatic()\n {\n types = types.Where(t => t.IsCSharpStatic()).ToList();\n return this;\n }\n\n /// \n /// Determines whether the type is not static\n /// \n public TypeSelector ThatAreNotStatic()\n {\n types = types.Where(t => !t.IsCSharpStatic()).ToList();\n return this;\n }\n\n /// \n /// Allows to filter the types with the passed\n /// \n public TypeSelector ThatSatisfy(Func predicate)\n {\n types = types.Where(predicate).ToList();\n return this;\n }\n\n /// \n /// Filters and returns only the types which have access modifier .\n /// \n /// Required access modifier for types\n public TypeSelector ThatHaveAccessModifier(CSharpAccessModifier accessModifier)\n {\n types = types.Where(t => t.GetCSharpAccessModifier() == accessModifier).ToList();\n return this;\n }\n\n /// \n /// Filters and returns only the types which don't have access modifier .\n /// \n /// Unwanted access modifier for types\n public TypeSelector ThatDoNotHaveAccessModifier(CSharpAccessModifier accessModifier)\n {\n types = types.Where(t => t.GetCSharpAccessModifier() != accessModifier).ToList();\n return this;\n }\n\n /// \n /// Returns T for the types which are or ; the type itself otherwise\n /// \n public TypeSelector UnwrapTaskTypes()\n {\n types = types.ConvertAll(type =>\n {\n if (type.IsGenericType)\n {\n Type genericTypeDefinition = type.GetGenericTypeDefinition();\n if (genericTypeDefinition == typeof(Task<>) || genericTypeDefinition == typeof(ValueTask<>))\n {\n return type.GetGenericArguments().Single();\n }\n }\n\n return type == typeof(Task) || type == typeof(ValueTask) ? typeof(void) : type;\n });\n\n return this;\n }\n\n /// \n /// Returns T for the types which are or implement the ; the type itself otherwise\n /// \n public TypeSelector UnwrapEnumerableTypes()\n {\n var unwrappedTypes = new List();\n\n foreach (Type type in types)\n {\n if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))\n {\n unwrappedTypes.Add(type.GetGenericArguments().Single());\n }\n else\n {\n var iEnumerableImplementations = type\n .GetInterfaces()\n .Where(iType => iType.IsGenericType && iType.GetGenericTypeDefinition() == typeof(IEnumerable<>))\n .Select(ied => ied.GetGenericArguments().Single())\n .ToList();\n\n if (iEnumerableImplementations.Count > 0)\n {\n unwrappedTypes.AddRange(iEnumerableImplementations);\n }\n else\n {\n unwrappedTypes.Add(type);\n }\n }\n }\n\n types = unwrappedTypes;\n return this;\n }\n\n /// \n /// Returns an enumerator that iterates through the collection.\n /// \n /// \n /// A that can be used to iterate through the collection.\n /// \n /// 1\n public IEnumerator GetEnumerator()\n {\n return types.GetEnumerator();\n }\n\n /// \n /// Returns an enumerator that iterates through a collection.\n /// \n /// \n /// An object that can be used to iterate through the collection.\n /// \n /// 2\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class Miscellaneous\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n var someObject = new Exception();\n\n // Act / Assert\n someObject.Should()\n .BeOfType()\n .And\n .NotBeNull();\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n var someObject = new Exception();\n\n // Act\n var action = () => someObject.Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() or BeSameAs() instead?\");\n }\n }\n\n internal class DumbObjectEqualityComparer : IEqualityComparer\n {\n // ReSharper disable once MemberHidesStaticFromOuterClass\n public new bool Equals(object x, object y)\n {\n return (x == y) || (x is not null && y is not null && x.Equals(y));\n }\n\n public int GetHashCode(object obj) => obj.GetHashCode();\n }\n}\n\ninternal class DummyBaseClass;\n\ninternal sealed class DummyImplementingClass : DummyBaseClass, IDisposable\n{\n public void Dispose()\n {\n // Ignore\n }\n}\n\ninternal class SomeClass\n{\n public SomeClass(int key)\n {\n Key = key;\n }\n\n public int Key { get; }\n\n public override string ToString() => $\"SomeClass({Key})\";\n}\n\ninternal class SomeClassEqualityComparer : IEqualityComparer\n{\n public bool Equals(SomeClass x, SomeClass y)\n {\n return (x == y) || (x is not null && y is not null && x.Key.Equals(y.Key));\n }\n\n public int GetHashCode(SomeClass obj) => obj.Key;\n}\n\ninternal class SomeClassAssertions : ObjectAssertions\n{\n public SomeClassAssertions(SomeClass value)\n : base(value, AssertionChain.GetOrCreate())\n {\n }\n}\n\ninternal static class AssertionExtensions\n{\n public static SomeClassAssertions Should(this SomeClass value) => new(value);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainEquivalentOf.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]ContainEquivalentOf specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class ContainEquivalentOf\n {\n [Fact]\n public void When_collection_contains_object_equal_of_another_it_should_succeed()\n {\n // Arrange\n var item = new Customer { Name = \"John\" };\n Customer[] collection = [new Customer { Name = \"Jane\" }, item];\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_collection_contains_object_equivalent_of_another_it_should_succeed()\n {\n // Arrange\n Customer[] collection = [new Customer { Name = \"Jane\" }, new Customer { Name = \"John\" }];\n var item = new Customer { Name = \"John\" };\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_character_collection_does_contain_equivalent_it_should_succeed()\n {\n // Arrange\n char[] collection = \"abc123ab\".ToCharArray();\n char item = 'c';\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item);\n }\n\n [Fact]\n public void Can_chain_a_successive_assertion_on_the_matching_item()\n {\n // Arrange\n char[] collection = \"abc123ab\".ToCharArray();\n char item = 'c';\n\n // Act\n var act = () => collection.Should().ContainEquivalentOf(item).Which.Should().Be('C');\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection[2] to be equal to C, but found c.\");\n }\n\n [Fact]\n public void When_string_collection_does_contain_same_string_with_other_case_it_should_throw()\n {\n // Arrange\n string[] collection = [\"a\", \"b\", \"c\"];\n string item = \"C\";\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection {\\\"a\\\", \\\"b\\\", \\\"c\\\"} to contain equivalent of \\\"C\\\".*\");\n }\n\n [Fact]\n public void When_string_collection_does_contain_same_string_it_should_throw_with_a_useful_message()\n {\n // Arrange\n string[] collection = [\"a\"];\n string item = \"b\";\n\n // Act\n Action act = () =>\n collection.Should().ContainEquivalentOf(item, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_object_equivalent_of_another_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int item = 4;\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item);\n\n // Act / Assert\n act.Should().Throw().WithMessage(\"Expected collection {1, 2, 3} to contain equivalent of 4.*\");\n }\n\n [Fact]\n public void When_asserting_collection_to_contain_equivalent_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int expectation = 1;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainEquivalentOf(expectation, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain equivalent of 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_contains_equivalent_null_object_it_should_succeed()\n {\n // Arrange\n int?[] collection = [1, 2, 3, null];\n int? item = null;\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_collection_does_not_contain_equivalent_null_object_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int? item = null;\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected collection {1, 2, 3} to contain equivalent of .*\");\n }\n\n [Fact]\n public void When_empty_collection_does_not_contain_equivalent_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n int item = 1;\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected collection {empty} to contain equivalent of 1.*\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_equivalent_because_of_second_property_it_should_throw()\n {\n // Arrange\n Customer[] subject =\n [\n new Customer\n {\n Name = \"John\",\n Age = 18\n },\n new Customer\n {\n Name = \"Jane\",\n Age = 18\n }\n ];\n\n var item = new Customer { Name = \"John\", Age = 20 };\n\n // Act\n Action act = () => subject.Should().ContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_does_contain_equivalent_by_including_single_property_it_should_not_throw()\n {\n // Arrange\n Customer[] collection =\n [\n new Customer\n {\n Name = \"John\",\n Age = 18\n },\n new Customer\n {\n Name = \"Jane\",\n Age = 18\n }\n ];\n\n var item = new Customer { Name = \"John\", Age = 20 };\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(item, options => options.Including(x => x.Name));\n }\n\n [Fact]\n public void Tracing_should_be_included_in_the_assertion_output()\n {\n // Arrange\n Customer[] collection =\n [\n new Customer\n {\n Name = \"John\",\n Age = 18\n },\n new Customer\n {\n Name = \"Jane\",\n Age = 18\n }\n ];\n\n var item = new Customer { Name = \"John\", Age = 21 };\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item, options => options.WithTracing());\n\n // Assert\n act.Should().Throw().WithMessage(\"*Equivalency was proven*\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_ContainEquivalentOf_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n object item = null;\n\n // Act\n Action act = () => collection.Should().ContainEquivalentOf(item, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_collection_contains_object_equivalent_of_boxed_object_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n object boxedValue = 2;\n\n // Act / Assert\n collection.Should().ContainEquivalentOf(boxedValue);\n }\n }\n\n public class NotContainEquivalentOf\n {\n [Fact]\n public void When_collection_contains_object_equal_to_another_it_should_throw()\n {\n // Arrange\n var item = 1;\n int[] collection = [0, 1];\n\n // Act\n Action act = () =>\n collection.Should().NotContainEquivalentOf(item, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {0, 1} not to contain*because we want to test the failure message, \" +\n \"but found one at index 1.*With configuration*\");\n }\n\n [Fact]\n public void When_collection_contains_several_objects_equal_to_another_it_should_throw()\n {\n // Arrange\n var item = 1;\n int[] collection = [0, 1, 1];\n\n // Act\n Action act = () =>\n collection.Should().NotContainEquivalentOf(item, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {0, 1, 1} not to contain*because we want to test the failure message, \" +\n \"but found several at indices {1, 2}.*With configuration*\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_to_contain_equivalent_but_collection_is_null_it_should_throw()\n {\n // Arrange\n var item = 1;\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainEquivalentOf(item);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected collection*not to contain*but collection is .\");\n }\n\n [Fact]\n public void When_injecting_a_null_config_to_NotContainEquivalentOf_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n object item = null;\n\n // Act\n Action act = () => collection.Should().NotContainEquivalentOf(item, config: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"config\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_to_not_contain_equivalent_it_should_succeed()\n {\n // Arrange\n int[] collection = [];\n int item = 4;\n\n // Act / Assert\n collection.Should().NotContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_asserting_a_null_collection_to_not_contain_equivalent_of__then_it_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainEquivalentOf(1, config => config, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to contain *failure message*, but collection is .\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_object_equivalent_of_unexpected_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int item = 4;\n\n // Act / Assert\n collection.Should().NotContainEquivalentOf(item);\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_equivalent_it_should_respect_config()\n {\n // Arrange\n Customer[] collection =\n [\n new Customer\n {\n Name = \"John\",\n Age = 18\n },\n new Customer\n {\n Name = \"Jane\",\n Age = 18\n }\n ];\n\n var item = new Customer { Name = \"John\", Age = 20 };\n\n // Act\n Action act = () => collection.Should().NotContainEquivalentOf(item, options => options.Excluding(x => x.Age));\n\n // Assert\n act.Should().Throw().WithMessage(\"*Exclude*Age*\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_equivalent_it_should_allow_combining_inside_assertion_scope()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int another = 3;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n collection.Should()\n .NotContainEquivalentOf(another, \"because we want to test {0}\", \"first message\")\n .And\n .HaveCount(4, \"because we want to test {0}\", \"second message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*not to contain*first message*but found one at index 2.*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/Iterator.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// A smarter enumerator that can provide information about the relative location (current, first, last)\n/// of the current item within the collection without unnecessarily iterating the collection.\n/// \ninternal sealed class Iterator : IEnumerator\n{\n private const int InitialIndex = -1;\n private readonly IEnumerable enumerable;\n private readonly int? maxItems;\n private IEnumerator enumerator;\n private T current;\n private T next;\n\n private bool hasNext;\n private bool hasCurrent;\n\n private bool hasCompleted;\n\n public Iterator(IEnumerable enumerable, int maxItems = int.MaxValue)\n {\n this.enumerable = enumerable;\n this.maxItems = maxItems;\n\n Reset();\n }\n\n public void Reset()\n {\n Index = InitialIndex;\n\n enumerator = enumerable.GetEnumerator();\n hasCurrent = false;\n hasNext = false;\n hasCompleted = false;\n current = default;\n next = default;\n }\n\n public int Index { get; private set; }\n\n public bool IsFirst => Index == 0;\n\n public bool IsLast => (hasCurrent && !hasNext) || HasReachedMaxItems;\n\n object IEnumerator.Current => Current;\n\n public T Current\n {\n get\n {\n if (!hasCurrent)\n {\n throw new InvalidOperationException($\"Please call {nameof(MoveNext)} first\");\n }\n\n return current;\n }\n\n private set\n {\n current = value;\n hasCurrent = true;\n }\n }\n\n public bool MoveNext()\n {\n if (!hasCompleted && FetchCurrent())\n {\n PrefetchNext();\n return true;\n }\n\n hasCompleted = true;\n return false;\n }\n\n private bool FetchCurrent()\n {\n if (hasNext && !HasReachedMaxItems)\n {\n Current = next;\n Index++;\n\n return true;\n }\n\n if (enumerator.MoveNext() && !HasReachedMaxItems)\n {\n Current = enumerator.Current;\n Index++;\n\n return true;\n }\n\n hasCompleted = true;\n\n return false;\n }\n\n public bool HasReachedMaxItems => Index == maxItems;\n\n private void PrefetchNext()\n {\n if (enumerator.MoveNext())\n {\n next = enumerator.Current;\n hasNext = true;\n }\n else\n {\n next = default;\n hasNext = false;\n }\n }\n\n public bool IsEmpty\n {\n get\n {\n if (!hasCurrent && !hasCompleted)\n {\n throw new InvalidOperationException($\"Please call {nameof(MoveNext)} first\");\n }\n\n return Index == InitialIndex;\n }\n }\n\n public void Dispose()\n {\n enumerator.Dispose();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MethodBaseAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic abstract class MethodBaseAssertions : MemberInfoAssertions\n where TSubject : MethodBase\n where TAssertions : MethodBaseAssertions\n{\n private readonly AssertionChain assertionChain;\n\n protected MethodBaseAssertions(TSubject subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the selected member has the specified C# .\n /// \n /// The expected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint HaveAccessModifier(\n CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected method to be {accessModifier}{{reason}}, but {{context:method}} is .\");\n\n if (assertionChain.Succeeded)\n {\n CSharpAccessModifier subjectAccessModifier = Subject.GetCSharpAccessModifier();\n\n assertionChain\n .ForCondition(accessModifier == subjectAccessModifier)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subject = GetSubjectDescription(assertionChain);\n\n return new FailReason(\n $\"Expected {subject} to be {accessModifier}{{reason}}, but it is {subjectAccessModifier}.\");\n });\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the selected member does not have the specified C# .\n /// \n /// The unexpected C# access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// is not a value.\n public AndConstraint NotHaveAccessModifier(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsOutOfRange(accessModifier);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith($\"Expected method not to be {accessModifier}{{reason}}, but {{context:member}} is .\");\n\n if (assertionChain.Succeeded)\n {\n CSharpAccessModifier subjectAccessModifier = Subject.GetCSharpAccessModifier();\n\n assertionChain\n .ForCondition(accessModifier != subjectAccessModifier)\n .BecauseOf(because, becauseArgs)\n .FailWith(() =>\n {\n string subject = GetSubjectDescription(assertionChain);\n\n return new FailReason($\"Expected {subject} not to be {accessModifier}{{reason}}, but it is.\");\n });\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n internal static string GetParameterString(MethodBase methodBase)\n {\n IEnumerable parameterTypes = methodBase.GetParameters().Select(p => p.ParameterType);\n\n return string.Join(\", \", parameterTypes.Select(p => p.AsFormattableShortType().ToFormattedString()));\n }\n\n private protected string GetSubjectDescription(AssertionChain assertionChain) =>\n assertionChain.HasOverriddenCallerIdentifier\n ? assertionChain.CallerIdentifier\n : $\"{Identifier} {Subject.ToFormattedString()}\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/XElementValueFormatter.cs", "using System;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class XElementValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is XElement;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var element = (XElement)value;\n\n formattedGraph.AddFragment(element.HasElements\n ? FormatElementWithChildren(element)\n : FormatElementWithoutChildren(element));\n }\n\n private static string FormatElementWithoutChildren(XElement element)\n {\n return element.ToString().EscapePlaceholders();\n }\n\n private static string FormatElementWithChildren(XElement element)\n {\n string[] lines = SplitIntoSeparateLines(element);\n\n // Can't use env.newline because the input doc may have unix or windows style\n // line-breaks\n string firstLine = lines[0].RemoveNewLines();\n string lastLine = lines[^1].RemoveNewLines();\n\n string formattedElement = firstLine + \"…\" + lastLine;\n return formattedElement.EscapePlaceholders();\n }\n\n private static string[] SplitIntoSeparateLines(XElement element)\n {\n string formattedXml = element.ToString();\n return formattedXml.Split([Environment.NewLine], StringSplitOptions.None);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/XDocumentValueFormatter.cs", "using System.Xml.Linq;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class XDocumentValueFormatter : IValueFormatter\n{\n public bool CanHandle(object value)\n {\n return value is XDocument;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var document = (XDocument)value;\n\n if (document.Root is not null)\n {\n formatChild(\"root\", document.Root, formattedGraph);\n }\n else\n {\n formattedGraph.AddFragment(\"[XML document without root element]\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/TaskAssertionSpecs.cs", "using System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\nusing static AwesomeAssertions.FluentActions;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic static class TaskAssertionSpecs\n{\n public class Extension\n {\n [Fact]\n public void When_getting_the_subject_it_should_remain_unchanged()\n {\n // Arrange\n Func> subject = () => Task.FromResult(42);\n\n // Act\n Action action = () => subject.Should().Subject.As().Should().BeSameAs(subject);\n\n // Assert\n action.Should().NotThrow(\"the Subject should remain the same\");\n }\n }\n\n public class NotThrow\n {\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n Func> subject = () => Task.FromResult(42);\n\n // Act\n Action action = () => subject.Should().Subject.As().Should().BeSameAs(subject);\n\n // Assert\n action.Should().NotThrow(\"the Subject should remain the same\").And.NotBeNull();\n }\n }\n\n public class NotThrowAfter\n {\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n Func> subject = () => Task.FromResult(42);\n\n // Act\n Action action = () => subject.Should().Subject.As().Should().BeSameAs(subject);\n\n // Assert\n action.Should().NotThrowAfter(1.Seconds(), 1.Seconds()).And.NotBeNull();\n }\n }\n\n public class CompleteWithinAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_throw()\n {\n // Arrange\n var timeSpan = 0.Milliseconds();\n Func action = null;\n\n // Act\n Func testAction = () => action.Should().CompleteWithinAsync(\n timeSpan, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_task_completes_fast_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n taskFactory.Awaiting(t => (Task)t.Task).Should(timer).CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_consumes_time_in_sync_portion_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t =>\n {\n // simulate sync work longer than accepted time\n timer.Delay(101.Milliseconds());\n return (Task)t.Task;\n })\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_completes_late_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n taskFactory.Awaiting(t => (Task)t.Task).Should(timer).CompleteWithinAsync(100.Milliseconds());\n\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Canceled_tasks_are_also_completed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Excepted_tasks_unexpectedly_completed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer)\n .CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class NotCompleteWithinAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_throw()\n {\n // Arrange\n var timeSpan = 0.Milliseconds();\n Func action = null;\n\n // Act\n Func testAction = () => action.Should().NotCompleteWithinAsync(\n timeSpan, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_task_completes_fast_it_should_throw()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task).Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_consumes_time_in_sync_portion_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t =>\n {\n // simulate sync work longer than accepted time\n timer.Delay(101.Milliseconds());\n return (Task)t.Task;\n })\n .Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_completes_late_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task).Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Canceled_tasks_are_also_completed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task).Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Excepted_tasks_unexpectedly_completed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () => taskFactory\n .Awaiting(t => (Task)t.Task).Should(timer)\n .NotCompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class ThrowAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = () => action.Should().ThrowAsync(\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_subject_is_null_in_assertion_scope_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().ThrowAsync(\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_task_throws_it_should_succeed()\n {\n // Act\n Func action = () =>\n {\n return\n Awaiting(() => Task.FromException(new InvalidOperationException(\"foo\")))\n .Should().ThrowAsync();\n };\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_throws_unexpected_exception_it_should_fail()\n {\n // Act\n Func action = () =>\n {\n return\n Awaiting(() => Task.FromException(new NotSupportedException(\"foo\")))\n .Should().ThrowAsync();\n };\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown,\"\n + \" but found :*foo*\");\n }\n\n [Fact]\n public async Task When_task_completes_without_exception_it_should_fail()\n {\n // Act\n Func action = () =>\n {\n return\n Awaiting(() => Task.CompletedTask)\n .Should().ThrowAsync();\n };\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown, but no exception was thrown.\");\n }\n }\n\n public class ThrowWithinAsync\n {\n [Fact]\n public async Task When_subject_is_null_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = () => action.Should().ThrowWithinAsync(\n 100.Milliseconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public async Task When_subject_is_null_in_assertion_scope_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().ThrowWithinAsync(\n 100.Milliseconds(), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Theory]\n [InlineData(99)]\n [InlineData(100)]\n public async Task When_task_throws_fast_it_should_succeed(int delay)\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(100.Ticks());\n };\n\n timer.Delay(delay.Ticks());\n taskFactory.SetException(new InvalidOperationException(\"foo\"));\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_throws_slow_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(100.Ticks());\n };\n\n timer.Delay(101.Ticks());\n taskFactory.SetException(new InvalidOperationException(\"foo\"));\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_task_throws_asynchronous_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return Awaiting(() => (Task)taskFactory.Task)\n .Should(timer).ThrowWithinAsync(1.Seconds());\n };\n\n _ = action.Invoke();\n taskFactory.SetException(new InvalidOperationException(\"foo\"));\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_not_completes_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(\n 100.Ticks(), \"because we want to test the failure {0}\", \"message\");\n };\n\n timer.Delay(101.Ticks());\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown within 10.0µs\"\n + \" because we want to test the failure message,\"\n + \" but no exception was thrown.\");\n }\n\n [Fact]\n public async Task When_task_completes_without_exception_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(100.Milliseconds());\n };\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown within 100ms, but no exception was thrown.\");\n }\n\n [Fact]\n public async Task When_task_throws_unexpected_exception_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return taskFactory\n .Awaiting(t => (Task)t.Task)\n .Should(timer).ThrowWithinAsync(100.Milliseconds());\n };\n\n taskFactory.SetException(new NotSupportedException(\"foo\"));\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown within 100ms,\"\n + \" but found :*foo*\");\n }\n\n [Fact]\n public async Task When_task_throws_unexpected_exception_asynchronous_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return Awaiting(() => (Task)taskFactory.Task)\n .Should(timer).ThrowWithinAsync(1.Seconds());\n };\n\n _ = action.Invoke();\n taskFactory.SetException(new NotSupportedException(\"foo\"));\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\n \"Expected a to be thrown within 1s,\"\n + \" but found :*foo*\");\n }\n\n [Fact]\n public async Task When_task_is_canceled_before_timeout_it_succeeds()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return Awaiting(() => (Task)taskFactory.Task)\n .Should(timer).ThrowWithinAsync(1.Seconds());\n };\n\n _ = action.Invoke();\n\n taskFactory.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_task_is_canceled_after_timeout_it_fails()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n {\n return Awaiting(() => (Task)taskFactory.Task)\n .Should(timer).ThrowWithinAsync(1.Seconds());\n };\n\n _ = action.Invoke();\n\n timer.Delay(1.Seconds());\n taskFactory.SetCanceled();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n }\n\n public class ThrowExactlyAsync\n {\n [Fact]\n public async Task Does_not_continue_assertion_on_exact_exception_type()\n {\n // Arrange\n var a = () => Task.Delay(1);\n\n // Act\n using var scope = new AssertionScope();\n await a.Should().ThrowExactlyAsync();\n\n // Assert\n scope.Discard().Should().ContainSingle()\n .Which.Should().Match(\"*InvalidOperationException*no exception*\");\n }\n }\n\n [Collection(\"UIFacts\")]\n public class CompleteWithinAsyncUIFacts\n {\n [UIFact]\n public async Task When_task_completes_fast_it_should_succeed()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n taskFactory.Awaiting(t => (Task)t.Task).Should(timer).CompleteWithinAsync(100.Milliseconds());\n\n taskFactory.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [UIFact]\n public async Task When_task_completes_late_it_should_fail()\n {\n // Arrange\n var timer = new FakeClock();\n var taskFactory = new TaskCompletionSource();\n\n // Act\n Func action = () =>\n taskFactory.Awaiting(t => (Task)t.Task).Should(timer).CompleteWithinAsync(100.Milliseconds());\n\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [UIFact]\n public async Task When_task_is_checking_synchronization_context_it_should_succeed()\n {\n // Arrange\n Func task = CheckContextAsync;\n\n // Act\n Func action = () => this.Awaiting(_ => task()).Should().CompleteWithinAsync(1.Seconds());\n\n // Assert\n await action.Should().NotThrowAsync();\n\n async Task CheckContextAsync()\n {\n await Task.Delay(1);\n SynchronizationContext.Current.Should().NotBeNull();\n }\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/ExecutionTimeAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Provides methods for asserting that the execution time of an satisfies certain conditions.\n/// \npublic class ExecutionTimeAssertions\n{\n private readonly ExecutionTime execution;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The execution on which time must be asserted.\n public ExecutionTimeAssertions(ExecutionTime executionTime, AssertionChain assertionChain)\n {\n execution = executionTime ?? throw new ArgumentNullException(nameof(executionTime));\n CurrentAssertionChain = assertionChain;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Checks the executing action if it satisfies a condition.\n /// If the execution runs into an exception, then this will rethrow it.\n /// \n /// Condition to check on the current elapsed time.\n /// Polling stops when condition returns the expected result.\n /// The rate at which the condition is re-checked.\n /// The elapsed time. (use this, don't measure twice)\n private (bool isRunning, TimeSpan elapsed) PollUntil(Func condition, bool expectedResult, TimeSpan rate)\n {\n TimeSpan elapsed = execution.ElapsedTime;\n bool isRunning = execution.IsRunning;\n\n while (isRunning)\n {\n if (condition(elapsed) == expectedResult)\n {\n break;\n }\n\n isRunning = !execution.Task.Wait(rate);\n elapsed = execution.ElapsedTime;\n }\n\n if (execution.Exception is not null)\n {\n // rethrow captured exception\n throw execution.Exception;\n }\n\n return (isRunning, elapsed);\n }\n\n /// \n /// Asserts that the execution time of the operation is less than or equal to a specified amount of time.\n /// \n /// \n /// The maximum allowed duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThanOrEqualTo(TimeSpan maxDuration,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration <= maxDuration, expectedResult: false, rate: maxDuration);\n\n CurrentAssertionChain\n .ForCondition(elapsed <= maxDuration)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" +\n execution.ActionDescription.EscapePlaceholders() +\n \" should be less than or equal to {0}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{1}.\",\n maxDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the execution time of the operation is less than a specified amount of time.\n /// \n /// \n /// The maximum allowed duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeLessThan(TimeSpan maxDuration,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration < maxDuration, expectedResult: false, rate: maxDuration);\n\n CurrentAssertionChain\n .ForCondition(elapsed < maxDuration)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" +\n execution.ActionDescription.EscapePlaceholders() + \" should be less than {0}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{1}.\",\n maxDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the execution time of the operation is greater than or equal to a specified amount of time.\n /// \n /// \n /// The minimum allowed duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThanOrEqualTo(TimeSpan minDuration,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration >= minDuration, expectedResult: true, rate: minDuration);\n\n CurrentAssertionChain\n .ForCondition(elapsed >= minDuration)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" +\n execution.ActionDescription.EscapePlaceholders() +\n \" should be greater than or equal to {0}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{1}.\",\n minDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the execution time of the operation is greater than a specified amount of time.\n /// \n /// \n /// The minimum allowed duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeGreaterThan(TimeSpan minDuration,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration > minDuration, expectedResult: true, rate: minDuration);\n\n CurrentAssertionChain\n .ForCondition(elapsed > minDuration)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" +\n execution.ActionDescription.EscapePlaceholders() + \" should be greater than {0}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{1}.\",\n minDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the execution time of the operation is within the expected duration.\n /// by a specified precision.\n /// \n /// \n /// The expected duration.\n /// \n /// \n /// The maximum amount of time which the execution time may differ from the expected duration.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(TimeSpan expectedDuration, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n TimeSpan minimumValue = expectedDuration - precision;\n TimeSpan maximumValue = expectedDuration + precision;\n\n // for polling we only use max condition, we don't want poll to stop if\n // elapsed time didn't even get to the acceptable range\n (bool isRunning, TimeSpan elapsed) = PollUntil(duration => duration <= maximumValue, expectedResult: false, rate: maximumValue);\n\n CurrentAssertionChain\n .ForCondition(elapsed >= minimumValue && elapsed <= maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Execution of \" + execution.ActionDescription.EscapePlaceholders() +\n \" should be within {0} from {1}{reason}, but it required \" +\n (isRunning ? \"more than \" : \"exactly \") + \"{2}.\",\n precision,\n expectedDuration,\n elapsed);\n\n return new AndConstraint(this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\n \"Equals is not part of Awesome Assertions. Did you mean BeLessThanOrEqualTo() or BeGreaterThanOrEqualTo() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XmlNodeFormatter.cs", "using System.Xml;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Xml;\n\npublic class XmlNodeFormatter : IValueFormatter\n{\n public bool CanHandle(object value)\n {\n return value is XmlNode;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n string outerXml = ((XmlNode)value).OuterXml;\n\n const int maxLength = 20;\n\n if (outerXml.Length > maxLength)\n {\n outerXml = outerXml.Substring(0, maxLength).TrimEnd() + \"…\";\n }\n\n formattedGraph.AddLine(outerXml.EscapePlaceholders());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MethodInfoSelectorAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Types;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains assertions for the objects returned by the parent .\n/// \n[DebuggerNonUserCode]\npublic class MethodInfoSelectorAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The methods to assert.\n /// is .\n public MethodInfoSelectorAssertions(AssertionChain assertionChain, params MethodInfo[] methods)\n {\n this.assertionChain = assertionChain;\n Guard.ThrowIfArgumentIsNull(methods);\n\n SubjectMethods = methods;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public IEnumerable SubjectMethods { get; }\n\n /// \n /// Asserts that the selected methods are virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] nonVirtualMethods = GetAllNonVirtualMethodsFromSelection();\n\n assertionChain\n .ForCondition(nonVirtualMethods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to be virtual{reason}, but the following methods are not virtual:\n {{GetDescriptionsFor(nonVirtualMethods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods are not virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] virtualMethods = GetAllVirtualMethodsFromSelection();\n\n assertionChain\n .ForCondition(virtualMethods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods not to be virtual{reason}, but the following methods are virtual:\n {{GetDescriptionsFor(virtualMethods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n private MethodInfo[] GetAllNonVirtualMethodsFromSelection()\n {\n return SubjectMethods.Where(method => method.IsNonVirtual()).ToArray();\n }\n\n private MethodInfo[] GetAllVirtualMethodsFromSelection()\n {\n return SubjectMethods.Where(method => !method.IsNonVirtual()).ToArray();\n }\n\n /// \n /// Asserts that the selected methods are async.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAsync([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] nonAsyncMethods = SubjectMethods.Where(method => !method.IsAsync()).ToArray();\n\n assertionChain\n .ForCondition(nonAsyncMethods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to be async{reason}, but the following methods are not:\n {{GetDescriptionsFor(nonAsyncMethods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods are not async.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAsync([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] asyncMethods = SubjectMethods.Where(method => method.IsAsync()).ToArray();\n\n assertionChain\n .ForCondition(asyncMethods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods not to be async{reason}, but the following methods are:\n {{GetDescriptionsFor(asyncMethods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods are decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n return BeDecoratedWith(_ => true, because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected methods are decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n MethodInfo[] methodsWithoutAttribute = GetMethodsWithout(isMatchingAttributePredicate);\n\n assertionChain\n .ForCondition(methodsWithoutAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to be decorated with {0}{reason}, but the following methods are not:\n {{GetDescriptionsFor(methodsWithoutAttribute)}}\n \"\"\", typeof(TAttribute)));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods are not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n return NotBeDecoratedWith(_ => true, because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected methods are not decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n MethodInfo[] methodsWithAttribute = GetMethodsWith(isMatchingAttributePredicate);\n\n assertionChain\n .ForCondition(methodsWithAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to not be decorated with {0}{reason}, but the following methods are:\n {{GetDescriptionsFor(methodsWithAttribute)}}\n \"\"\", typeof(TAttribute)));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods have specified .\n /// \n /// The expected access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] methods = SubjectMethods.Where(pi => pi.GetCSharpAccessModifier() != accessModifier).ToArray();\n\n assertionChain\n .ForCondition(methods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to be {{accessModifier}}{reason}, but the following methods are not:\n {{GetDescriptionsFor(methods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected methods don't have specified \n /// \n /// The expected access modifier.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(CSharpAccessModifier accessModifier,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n MethodInfo[] methods = SubjectMethods.Where(pi => pi.GetCSharpAccessModifier() == accessModifier).ToArray();\n\n assertionChain\n .ForCondition(methods.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $$\"\"\"\n Expected all selected methods to not be {{accessModifier}}{reason}, but the following methods are:\"\n {{GetDescriptionsFor(methods)}}\n \"\"\"));\n\n return new AndConstraint(this);\n }\n\n private MethodInfo[] GetMethodsWithout(Expression> isMatchingPredicate)\n where TAttribute : Attribute\n {\n return SubjectMethods.Where(method => !method.IsDecoratedWith(isMatchingPredicate)).ToArray();\n }\n\n private MethodInfo[] GetMethodsWith(Expression> isMatchingPredicate)\n where TAttribute : Attribute\n {\n return SubjectMethods.Where(method => method.IsDecoratedWith(isMatchingPredicate)).ToArray();\n }\n\n private static string GetDescriptionsFor(IEnumerable methods)\n {\n IEnumerable descriptions = methods.Select(method => MethodInfoAssertions.GetDescriptionFor(method));\n\n return string.Join(Environment.NewLine, descriptions);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n#pragma warning disable CA1822 // Do not change signature of a public member\n protected string Context => \"method\";\n#pragma warning restore CA1822\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/EnumValueFormatter.cs", "using System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class EnumValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public virtual bool CanHandle(object value)\n {\n return value is Enum;\n }\n\n /// \n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n string typePart = value.GetType().Name;\n string namePart = value.ToString().Replace(\", \", \"|\", StringComparison.Ordinal);\n\n string valuePart = Convert.ToDecimal(value, CultureInfo.InvariantCulture)\n .ToString(CultureInfo.InvariantCulture);\n\n formattedGraph.AddFragment($\"{typePart}.{namePart} {{value: {valuePart}}}\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/ActionAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that an yields the expected result.\n/// \n[DebuggerNonUserCode]\npublic class ActionAssertions : DelegateAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public ActionAssertions(Action subject, IExtractExceptions extractor, AssertionChain assertionChain)\n : base(subject, extractor, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n public ActionAssertions(Action subject, IExtractExceptions extractor, AssertionChain assertionChain, IClock clock)\n : base(subject, extractor, assertionChain, clock)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current does not throw any exception.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotThrow([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw{reason}, but found .\");\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n Exception exception = InvokeSubjectWithInterception();\n return NotThrowInternal(exception, because, becauseArgs);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current stops throwing any exception\n /// after a specified amount of time.\n /// \n /// \n /// The delegate is invoked. If it raises an exception,\n /// the invocation is repeated until it either stops raising any exceptions\n /// or the specified wait time is exceeded.\n /// \n /// \n /// The time after which the delegate should have stopped throwing any exception.\n /// \n /// \n /// The time between subsequent invocations of the delegate.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// or are negative.\n public AndConstraint NotThrowAfter(TimeSpan waitTime, TimeSpan pollInterval,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(waitTime);\n Guard.ThrowIfArgumentIsNegative(pollInterval);\n\n assertionChain\n .ForCondition(Subject is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context} not to throw after {0}{reason}, but found .\", waitTime);\n\n if (assertionChain.Succeeded)\n {\n FailIfSubjectIsAsyncVoid();\n\n TimeSpan? invocationEndTime = null;\n Exception exception = null;\n ITimer timer = Clock.StartTimer();\n\n while (invocationEndTime is null || invocationEndTime < waitTime)\n {\n exception = InvokeSubjectWithInterception();\n\n if (exception is null)\n {\n break;\n }\n\n Clock.Delay(pollInterval);\n invocationEndTime = timer.Elapsed;\n }\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(exception is null)\n .FailWith(\"Did not expect any exceptions after {0}{reason}, but found {1}.\", waitTime, exception);\n }\n\n return new AndConstraint(this);\n }\n\n protected override void InvokeSubject()\n {\n Subject();\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n protected override string Identifier => \"action\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/CallerStatementBuilder.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class CallerStatementBuilder\n{\n private readonly StringBuilder statement;\n private readonly List priorityOrderedParsingStrategies;\n private ParsingState parsingState = ParsingState.InProgress;\n\n internal CallerStatementBuilder()\n {\n statement = new StringBuilder();\n\n priorityOrderedParsingStrategies =\n [\n new QuotesParsingStrategy(),\n new MultiLineCommentParsingStrategy(),\n new SingleLineCommentParsingStrategy(),\n new SemicolonParsingStrategy(),\n new ShouldCallParsingStrategy(),\n new AwaitParsingStrategy(),\n new AddNonEmptySymbolParsingStrategy()\n ];\n }\n\n internal void Append(string symbols)\n {\n using var symbolEnumerator = symbols.GetEnumerator();\n\n while (symbolEnumerator.MoveNext() && parsingState != ParsingState.Done)\n {\n var hasParsingStrategyWaitingForEndContext = priorityOrderedParsingStrategies\n .Exists(s => s.IsWaitingForContextEnd());\n\n parsingState = ParsingState.InProgress;\n\n foreach (var parsingStrategy in\n priorityOrderedParsingStrategies\n .SkipWhile(parsingStrategy =>\n hasParsingStrategyWaitingForEndContext\n && !parsingStrategy.IsWaitingForContextEnd()))\n {\n parsingState = parsingStrategy.Parse(symbolEnumerator.Current, statement);\n\n if (parsingState != ParsingState.InProgress)\n {\n break;\n }\n }\n }\n\n if (IsDone())\n {\n return;\n }\n\n priorityOrderedParsingStrategies\n .ForEach(strategy => strategy.NotifyEndOfLineReached());\n }\n\n internal bool IsDone() => parsingState == ParsingState.Done;\n\n public override string ToString() => statement.ToString();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/TimeOnlyAssertions.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class TimeOnlyAssertions : TimeOnlyAssertions\n{\n public TimeOnlyAssertions(TimeOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class TimeOnlyAssertions\n where TAssertions : TimeOnlyAssertions\n{\n public TimeOnlyAssertions(TimeOnly? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public TimeOnly? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TimeOnly? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(TimeOnly? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is within the specified time\n /// from the specified value.\n /// \n /// \n /// The expected time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(TimeOnly nearbyTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n TimeSpan? difference = Subject != null\n ? MinimumDifference(Subject.Value, nearbyTime)\n : null;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the time} to be within {0} from {1}{reason}, \", precision, nearbyTime,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(Subject?.IsCloseTo(nearbyTime, precision) == true)\n .FailWith(\"but {0} was off by {1}.\", Subject, difference));\n\n return new AndConstraint((TAssertions)this);\n }\n\n private static TimeSpan? MinimumDifference(TimeOnly a, TimeOnly b)\n {\n var diff1 = a - b;\n var diff2 = b - a;\n\n return diff1 < diff2 ? diff1 : diff2;\n }\n\n /// \n /// Asserts that the current is not within the specified time\n /// from the specified value.\n /// \n /// \n /// The time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values must differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint NotBeCloseTo(TimeOnly distantTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:the time} to be within {0} from {1}{reason}, \", precision, distantTime,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\"but found .\")\n .Then\n .ForCondition(Subject?.IsCloseTo(distantTime, precision) == false)\n .FailWith(\"but it was {0}.\", Subject));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is before the specified value.\n /// \n /// The that the current value is expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeBefore(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject < expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not before the specified value.\n /// \n /// The that the current value is not expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeBefore(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or before the specified value.\n /// \n /// The that the current value is expected to be on or before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrBefore(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject <= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be on or before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor before the specified value.\n /// \n /// The that the current value is not expected to be on nor before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrBefore(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is after the specified value.\n /// \n /// The that the current value is expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAfter(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject > expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not after the specified value.\n /// \n /// The that the current value is not expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAfter(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or after the specified value.\n /// \n /// The that the current value is expected to be on or after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrAfter(TimeOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject >= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be on or after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor after the specified value.\n /// \n /// The that the current value is expected not to be on nor after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrAfter(TimeOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has the hour.\n /// \n /// The expected hour of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveHours(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the hours part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject.Value.Hour == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Hour));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the hour.\n /// \n /// The hour that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveHours(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.HasValue)\n .FailWith(\"Did not expect the hours part of {context:the time} to be {0}{reason}, but found a TimeOnly.\",\n unexpected)\n .Then\n .ForCondition(Subject.Value.Hour != unexpected)\n .FailWith(\"Did not expect the hours part of {context:the time} to be {0}{reason}, but it was.\", unexpected,\n Subject.Value.Hour);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the minute.\n /// \n /// The expected minute of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMinutes(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the minutes part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Minute == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Minute));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the minute.\n /// \n /// The minute that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMinutes(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the minutes part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Minute != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the second.\n /// \n /// The expected second of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSeconds(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the seconds part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Second == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Second));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the second.\n /// \n /// The second that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSeconds(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the seconds part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Second != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the millisecond.\n /// \n /// The expected millisecond of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMilliseconds(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the milliseconds part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Millisecond == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Millisecond));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the millisecond.\n /// \n /// The millisecond that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMilliseconds(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the milliseconds part of {context:the time} to be {0}{reason}\", unexpected,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a TimeOnly.\")\n .Then\n .ForCondition(Subject.Value.Millisecond != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params TimeOnly?[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params TimeOnly[] validValues)\n {\n return BeOneOf(validValues.Cast());\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOneOf(validValues.Cast(), because, becauseArgs);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:time} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateTimeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeAssertions : DateTimeAssertions\n{\n public DateTimeAssertions(DateTime? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeAssertions\n where TAssertions : DateTimeAssertions\n{\n public DateTimeAssertions(DateTime? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public DateTime? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateTime expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateTime? expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateTime? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The expected time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values may differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint BeCloseTo(DateTime nearbyTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n long distanceToMinInTicks = (nearbyTime - DateTime.MinValue).Ticks;\n DateTime minimumValue = nearbyTime.AddTicks(-Math.Min(precision.Ticks, distanceToMinInTicks));\n\n long distanceToMaxInTicks = (DateTime.MaxValue - nearbyTime).Ticks;\n DateTime maximumValue = nearbyTime.AddTicks(Math.Min(precision.Ticks, distanceToMaxInTicks));\n\n TimeSpan? difference = (Subject - nearbyTime)?.Duration();\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be within {0} from {1}{reason}\", precision, nearbyTime,\n chain => chain\n .ForCondition(Subject is not null)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject >= minimumValue && Subject <= maximumValue)\n .FailWith(\", but {0} was off by {1}.\", Subject, difference));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not within the specified time\n /// from the specified value.\n /// \n /// \n /// Use this assertion when, for example the database truncates datetimes to nearest 20ms. If you want to assert to the exact datetime,\n /// use .\n /// \n /// \n /// The time to compare the actual value with.\n /// \n /// \n /// The maximum amount of time which the two values must differ.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is negative.\n public AndConstraint NotBeCloseTo(DateTime distantTime, TimeSpan precision,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNegative(precision);\n\n long distanceToMinInTicks = (distantTime - DateTime.MinValue).Ticks;\n DateTime minimumValue = distantTime.AddTicks(-Math.Min(precision.Ticks, distanceToMinInTicks));\n\n long distanceToMaxInTicks = (DateTime.MaxValue - distantTime).Ticks;\n DateTime maximumValue = distantTime.AddTicks(Math.Min(precision.Ticks, distanceToMaxInTicks));\n\n CurrentAssertionChain\n .ForCondition(Subject < minimumValue || Subject > maximumValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Did not expect {context:the date and time} to be within {0} from {1}{reason}, but it was {2}.\",\n precision,\n distantTime, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is before the specified value.\n /// \n /// The that the current value is expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeBefore(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject < expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not before the specified value.\n /// \n /// The that the current value is not expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeBefore(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or before the specified value.\n /// \n /// The that the current value is expected to be on or before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrBefore(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject <= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be on or before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor before the specified value.\n /// \n /// The that the current value is not expected to be on nor before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrBefore(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is after the specified value.\n /// \n /// The that the current value is expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAfter(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject > expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not after the specified value.\n /// \n /// The that the current value is not expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAfter(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or after the specified value.\n /// \n /// The that the current value is expected to be on or after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrAfter(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject >= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be on or after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor after the specified value.\n /// \n /// The that the current value is expected not to be on nor after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrAfter(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has the year.\n /// \n /// The expected year of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveYear(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the year part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject.Value.Year == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Year));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the year.\n /// \n /// The year that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveYear(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.HasValue)\n .FailWith(\"Did not expect the year part of {context:the date} to be {0}{reason}, but found a DateTime.\",\n unexpected)\n .Then\n .ForCondition(Subject.Value.Year != unexpected)\n .FailWith(\"Did not expect the year part of {context:the date} to be {0}{reason}, but it was.\", unexpected,\n Subject.Value.Year);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the month.\n /// \n /// The expected month of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMonth(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the month part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Month == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Month));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the month.\n /// \n /// The month that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMonth(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the month part of {context:the date} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Month != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the day.\n /// \n /// The expected day of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveDay(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the day part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Day == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Day));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the day.\n /// \n /// The day that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveDay(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the day part of {context:the date} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Day != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the hour.\n /// \n /// The expected hour of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveHour(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the hour part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Hour == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Hour));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the hour.\n /// \n /// The hour that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveHour(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the hour part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\", unexpected)\n .Then\n .ForCondition(Subject.Value.Hour != unexpected)\n .FailWith(\", but it was.\", unexpected, Subject.Value.Hour));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the minute.\n /// \n /// The expected minutes of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMinute(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the minute part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Minute == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Minute));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the minute.\n /// \n /// The minute that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMinute(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the minute part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\", unexpected)\n .Then\n .ForCondition(Subject.Value.Minute != unexpected)\n .FailWith(\", but it was.\", unexpected, Subject.Value.Minute));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the second.\n /// \n /// The expected seconds of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveSecond(int expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the seconds part of {context:the time} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Second == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Second));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the second.\n /// \n /// The second that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveSecond(int unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the seconds part of {context:the time} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Second != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// exceeds the specified compared to another .\n /// \n /// \n /// The amount of time that the current should exceed compared to another .\n /// \n public DateTimeRangeAssertions BeMoreThan(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.MoreThan,\n timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// is equal to or exceeds the specified compared to another .\n /// \n /// \n /// The amount of time that the current should be equal or exceed compared to\n /// another .\n /// \n public DateTimeRangeAssertions BeAtLeast(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.AtLeast,\n timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// differs exactly the specified compared to another .\n /// \n /// \n /// The amount of time that the current should differ exactly compared to another .\n /// \n public DateTimeRangeAssertions BeExactly(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.Exactly,\n timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// is within the specified compared to another .\n /// \n /// \n /// The amount of time that the current should be within another .\n /// \n public DateTimeRangeAssertions BeWithin(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.Within,\n timeSpan);\n }\n\n /// \n /// Returns a object that can be used to assert that the current \n /// differs at maximum the specified compared to another .\n /// \n /// \n /// The maximum amount of time that the current should differ compared to another .\n /// \n public DateTimeRangeAssertions BeLessThan(TimeSpan timeSpan)\n {\n return new DateTimeRangeAssertions((TAssertions)this, CurrentAssertionChain, Subject, TimeSpanCondition.LessThan,\n timeSpan);\n }\n\n /// \n /// Asserts that the current has the date.\n /// \n /// The expected date portion of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSameDateAs(DateTime expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n DateTime expectedDate = expected.Date;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the date part of {context:the date and time} to be {0}{reason}\", expectedDate,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\", expectedDate)\n .Then\n .ForCondition(Subject.Value.Date == expectedDate)\n .FailWith(\", but found {1}.\", expectedDate, Subject.Value));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not the date.\n /// \n /// The date that is not to match the date portion of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSameDateAs(DateTime unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n DateTime unexpectedDate = unexpected.Date;\n\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the date part of {context:the date and time} to be {0}{reason}\", unexpectedDate,\n chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Date != unexpectedDate)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateTime?[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateTime[] validValues)\n {\n return BeOneOf(validValues.Cast());\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOneOf(validValues.Cast(), because, becauseArgs);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date and time} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the represents a value in the .\n /// \n /// \n /// The expected that the current value must represent.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeIn(DateTimeKind expectedKind,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:the date and time} to be in \" + expectedKind + \"{reason}\", chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(Subject.Value.Kind == expectedKind)\n .FailWith(\", but found \" + Subject.Value.Kind + \".\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the does not represent a value in a specific kind.\n /// \n /// \n /// The that the current value should not represent.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeIn(DateTimeKind unexpectedKind,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect {context:the date and time} to be in \" + unexpectedKind + \"{reason}\", chain => chain\n .Given(() => Subject)\n .ForCondition(subject => subject.HasValue)\n .FailWith(\", but found a DateTime.\")\n .Then\n .ForCondition(subject => subject.GetValueOrDefault().Kind != unexpectedKind)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/XmlReaderValueFormatter.cs", "using System.Xml;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class XmlReaderValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is XmlReader;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var reader = (XmlReader)value;\n\n if (reader.ReadState == ReadState.Initial)\n {\n reader.Read();\n }\n\n var result = \"\\\"\" + reader.ReadOuterXml() + \"\\\"\";\n\n formattedGraph.AddFragment(result);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateOnlyAssertions.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class DateOnlyAssertions : DateOnlyAssertions\n{\n public DateOnlyAssertions(DateOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class DateOnlyAssertions\n where TAssertions : DateOnlyAssertions\n{\n public DateOnlyAssertions(DateOnly? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public DateOnly? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateOnly expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is exactly equal to the value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(DateOnly? expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be {0}{reason}, but found {1}.\",\n expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateOnly unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current or is not equal to the value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(DateOnly? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} not to be {0}{reason}, but it is.\", unexpected);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is before the specified value.\n /// \n /// The that the current value is expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeBefore(DateOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject < expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not before the specified value.\n /// \n /// The that the current value is not expected to be before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeBefore(DateOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or before the specified value.\n /// \n /// The that the current value is expected to be on or before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrBefore(DateOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject <= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be on or before {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor before the specified value.\n /// \n /// The that the current value is not expected to be on nor before.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrBefore(DateOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeAfter(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is after the specified value.\n /// \n /// The that the current value is expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeAfter(DateOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject > expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is not after the specified value.\n /// \n /// The that the current value is not expected to be after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeAfter(DateOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOnOrBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current is either on, or after the specified value.\n /// \n /// The that the current value is expected to be on or after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOnOrAfter(DateOnly expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject >= expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be on or after {0}{reason}, but found {1}.\", expected,\n Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current is neither on, nor after the specified value.\n /// \n /// The that the current value is expected not to be on nor after.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeOnOrAfter(DateOnly unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeBefore(unexpected, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has the year.\n /// \n /// The expected year of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveYear(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the year part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found .\")\n .Then\n .ForCondition(Subject.Value.Year == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Year));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the year.\n /// \n /// The year that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveYear(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject.HasValue)\n .FailWith(\"Did not expect the year part of {context:the date} to be {0}{reason}, but found a DateOnly.\",\n unexpected)\n .Then\n .ForCondition(Subject.Value.Year != unexpected)\n .FailWith(\"Did not expect the year part of {context:the date} to be {0}{reason}, but it was.\", unexpected,\n Subject.Value.Year);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the month.\n /// \n /// The expected month of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveMonth(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the month part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateOnly.\")\n .Then\n .ForCondition(Subject.Value.Month == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Month));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the month.\n /// \n /// The month that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveMonth(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the month part of {context:the date} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateOnly.\")\n .Then\n .ForCondition(Subject.Value.Month != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current has the day.\n /// \n /// The expected day of the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveDay(int expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected the day part of {context:the date} to be {0}{reason}\", expected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateOnly.\")\n .Then\n .ForCondition(Subject.Value.Day == expected)\n .FailWith(\", but found {0}.\", Subject.Value.Day));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have the day.\n /// \n /// The day that should not be in the current value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveDay(int unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Did not expect the day part of {context:the date} to be {0}{reason}\", unexpected, chain => chain\n .ForCondition(Subject.HasValue)\n .FailWith(\", but found a DateOnly.\")\n .Then\n .ForCondition(Subject.Value.Day != unexpected)\n .FailWith(\", but it was.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateOnly?[] validValues)\n {\n return BeOneOf(validValues, string.Empty);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n public AndConstraint BeOneOf(params DateOnly[] validValues)\n {\n return BeOneOf(validValues.Cast());\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return BeOneOf(validValues.Cast(), because, becauseArgs);\n }\n\n /// \n /// Asserts that the is one of the specified .\n /// \n /// \n /// The values that are valid.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeOneOf(IEnumerable validValues,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(validValues.Contains(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:date} to be one of {0}{reason}, but found {1}.\", validValues, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/SelectionRulesSpecs.Browsability.cs", "using System;\nusing System.ComponentModel;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Equivalency.Specs;\n\npublic partial class SelectionRulesSpecs\n{\n public class Browsability\n {\n [Fact]\n public void When_browsable_field_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_browsable_property_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n BrowsableProperty = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n BrowsableProperty = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_advanced_browsable_field_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n AdvancedBrowsableField = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n AdvancedBrowsableField = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_advanced_browsable_property_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n AdvancedBrowsableProperty = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n AdvancedBrowsableProperty = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_explicitly_browsable_field_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n ExplicitlyBrowsableField = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n ExplicitlyBrowsableField = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_explicitly_browsable_property_differs_excluding_non_browsable_members_should_not_affect_result()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n ExplicitlyBrowsableProperty = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n ExplicitlyBrowsableProperty = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_non_browsable_field_differs_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n NonBrowsableField = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n NonBrowsableField = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_non_browsable_property_differs_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n NonBrowsableProperty = 0\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n NonBrowsableProperty = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_property_is_non_browsable_only_in_subject_excluding_non_browsable_members_should_not_make_it_succeed()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n PropertyThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n PropertyThatMightBeNonBrowsable = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected property subject.PropertyThatMightBeNonBrowsable to be 1, but found 0.*\");\n }\n\n [Fact]\n public void\n When_property_is_non_browsable_only_in_subject_ignoring_non_browsable_members_on_subject_should_make_it_succeed()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n PropertyThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n PropertyThatMightBeNonBrowsable = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(\n expectation,\n config => config.IgnoringNonBrowsableMembersOnSubject().ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_non_browsable_property_on_subject_is_ignored_but_is_present_on_expectation_it_should_fail()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n PropertyThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n PropertyThatMightBeNonBrowsable = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.IgnoringNonBrowsableMembersOnSubject());\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expectation has*ThatMightBeNonBrowsable that is non-browsable in the other object, and non-browsable \" +\n \"members on the subject are ignored with the current configuration*\");\n }\n\n [Fact]\n public void Only_ignore_non_browsable_matching_members()\n {\n // Arrange\n var subject = new\n {\n NonExisting = 0\n };\n\n var expectation = new\n {\n Existing = 1\n };\n\n // Act\n Action action = () => subject.Should().BeEquivalentTo(expectation, config => config.IgnoringNonBrowsableMembersOnSubject());\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_property_is_non_browsable_only_in_expectation_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n PropertyThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n PropertyThatMightBeNonBrowsable = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_field_is_non_browsable_only_in_subject_excluding_non_browsable_members_should_not_make_it_succeed()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n FieldThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n FieldThatMightBeNonBrowsable = 1\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected field subject.FieldThatMightBeNonBrowsable to be 1, but found 0.*\");\n }\n\n [Fact]\n public void When_field_is_non_browsable_only_in_subject_ignoring_non_browsable_members_on_subject_should_make_it_succeed()\n {\n // Arrange\n var subject =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n FieldThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n FieldThatMightBeNonBrowsable = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(\n expectation,\n config => config.IgnoringNonBrowsableMembersOnSubject().ExcludingMissingMembers());\n }\n\n [Fact]\n public void When_field_is_non_browsable_only_in_expectation_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n FieldThatMightBeNonBrowsable = 0\n };\n\n var expectation =\n new ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n FieldThatMightBeNonBrowsable = 1\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expectation, config => config.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_property_is_missing_from_subject_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject =\n new\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2\n /* NonBrowsableProperty missing */\n };\n\n var expected = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2,\n NonBrowsableProperty = 2\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_field_is_missing_from_subject_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject =\n new\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n /* NonBrowsableField missing */\n NonBrowsableProperty = 2\n };\n\n var expected = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2,\n NonBrowsableProperty = 2\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_property_is_missing_from_expectation_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2,\n NonBrowsableProperty = 2\n };\n\n var expected =\n new\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2\n /* NonBrowsableProperty missing */\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void When_field_is_missing_from_expectation_excluding_non_browsable_members_should_make_it_succeed()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n NonBrowsableField = 2,\n NonBrowsableProperty = 2\n };\n\n var expected =\n new\n {\n BrowsableField = 1,\n BrowsableProperty = 1,\n ExplicitlyBrowsableField = 1,\n ExplicitlyBrowsableProperty = 1,\n AdvancedBrowsableField = 1,\n AdvancedBrowsableProperty = 1,\n /* NonBrowsableField missing */\n NonBrowsableProperty = 2\n };\n\n // Act & Assert\n subject.Should().BeEquivalentTo(expected, opt => opt.ExcludingNonBrowsableMembers());\n }\n\n [Fact]\n public void\n When_non_browsable_members_are_excluded_it_should_still_be_possible_to_explicitly_include_non_browsable_field()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n NonBrowsableField = 1\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n NonBrowsableField = 2\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(\n expectation,\n opt => opt.IncludingFields().ExcludingNonBrowsableMembers().Including(e => e.NonBrowsableField));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected field subject.NonBrowsableField to be 2, but found 1.*\");\n }\n\n [Fact]\n public void\n When_non_browsable_members_are_excluded_it_should_still_be_possible_to_explicitly_include_non_browsable_property()\n {\n // Arrange\n var subject = new ClassWithNonBrowsableMembers\n {\n NonBrowsableProperty = 1\n };\n\n var expectation = new ClassWithNonBrowsableMembers\n {\n NonBrowsableProperty = 2\n };\n\n // Act\n Action action =\n () => subject.Should().BeEquivalentTo(\n expectation,\n opt => opt.IncludingProperties().ExcludingNonBrowsableMembers().Including(e => e.NonBrowsableProperty));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected property subject.NonBrowsableProperty to be 2, but found 1.*\");\n }\n\n private class ClassWithNonBrowsableMembers\n {\n [UsedImplicitly]\n public int BrowsableField = -1;\n\n [UsedImplicitly]\n public int BrowsableProperty { get; set; }\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Always)]\n public int ExplicitlyBrowsableField = -1;\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Always)]\n public int ExplicitlyBrowsableProperty { get; set; }\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Advanced)]\n public int AdvancedBrowsableField = -1;\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Advanced)]\n public int AdvancedBrowsableProperty { get; set; }\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Never)]\n public int NonBrowsableField = -1;\n\n [UsedImplicitly]\n [EditorBrowsable(EditorBrowsableState.Never)]\n public int NonBrowsableProperty { get; set; }\n }\n\n private class ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable\n {\n [UsedImplicitly]\n public int BrowsableProperty { get; set; }\n\n [UsedImplicitly]\n public int FieldThatMightBeNonBrowsable = -1;\n\n [UsedImplicitly]\n public int PropertyThatMightBeNonBrowsable { get; set; }\n }\n\n private class ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable\n {\n [UsedImplicitly]\n public int BrowsableProperty { get; set; }\n\n [EditorBrowsable(EditorBrowsableState.Never)]\n [UsedImplicitly]\n public int FieldThatMightBeNonBrowsable = -1;\n\n [EditorBrowsable(EditorBrowsableState.Never)]\n [UsedImplicitly]\n public int PropertyThatMightBeNonBrowsable { get; set; }\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/BooleanAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class BooleanAssertions\n : BooleanAssertions\n{\n public BooleanAssertions(bool? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class BooleanAssertions\n where TAssertions : BooleanAssertions\n{\n public BooleanAssertions(bool? value, AssertionChain assertionChain)\n {\n CurrentAssertionChain = assertionChain;\n Subject = value;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public bool? Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeFalse([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == false)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:boolean} to be {0}{reason}, but found {1}.\", false, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeTrue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:boolean} to be {0}{reason}, but found {1}.\", true, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is equal to the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(bool expected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:boolean} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is not equal to the specified value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(bool unexpected, [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:boolean} not to be {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value implies the specified value.\n /// \n /// The right hand side of the implication\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Imply(bool consequent,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n bool? antecedent = Subject;\n\n CurrentAssertionChain\n .ForCondition(antecedent is not null)\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected {context:antecedent} ({0}) to imply consequent ({1}){reason}, \", antecedent, consequent,\n chain => chain\n .FailWith(\"but found null.\")\n .Then\n .ForCondition(!antecedent.Value || consequent)\n .FailWith(\"but it did not.\"));\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Streams/BufferedStreamAssertions.cs", "using System.Diagnostics;\nusing System.IO;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Streams;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n///\n[DebuggerNonUserCode]\npublic class BufferedStreamAssertions : BufferedStreamAssertions\n{\n public BufferedStreamAssertions(BufferedStream stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n }\n}\n\npublic class BufferedStreamAssertions : StreamAssertions\n where TAssertions : BufferedStreamAssertions\n{\n#if NET6_0_OR_GREATER || NETSTANDARD2_1\n\n private readonly AssertionChain assertionChain;\n\n public BufferedStreamAssertions(BufferedStream stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current has the buffer size.\n /// \n /// The expected buffer size of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveBufferSize(int expected,\n [System.Diagnostics.CodeAnalysis.StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the buffer size of {context:stream} to be {0}{reason}, but found a reference.\",\n expected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.BufferSize == expected)\n .FailWith(\"Expected the buffer size of {context:stream} to be {0}{reason}, but it was {1}.\",\n expected, Subject.BufferSize);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the current does not have a buffer size of .\n /// \n /// The unexpected buffer size of the current stream.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveBufferSize(int unexpected,\n [System.Diagnostics.CodeAnalysis.StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\"Expected the buffer size of {context:stream} not to be {0}{reason}, but found a reference.\",\n unexpected);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject!.BufferSize != unexpected)\n .FailWith(\"Expected the buffer size of {context:stream} not to be {0}{reason}, but it was.\",\n unexpected);\n }\n\n return new AndConstraint((TAssertions)this);\n }\n#else\n public BufferedStreamAssertions(BufferedStream stream, AssertionChain assertionChain)\n : base(stream, assertionChain)\n {\n }\n#endif\n\n protected override string Identifier => \"buffered stream\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringStartStrategy.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringStartStrategy : IStringComparisonStrategy\n{\n private readonly IEqualityComparer comparer;\n private readonly string predicateDescription;\n\n public StringStartStrategy(IEqualityComparer comparer, string predicateDescription)\n {\n this.comparer = comparer;\n this.predicateDescription = predicateDescription;\n }\n\n public string ExpectationDescription => $\"Expected {{context:string}} to {predicateDescription} \";\n\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n assertionChain\n .ForCondition(subject.Length >= expected.Length)\n .FailWith($\"{ExpectationDescription}{{0}}{{reason}}, but {{1}} is too short.\", expected, subject);\n\n if (!assertionChain.Succeeded)\n {\n return;\n }\n\n int indexOfMismatch = subject.IndexOfFirstMismatch(expected, comparer);\n\n if (indexOfMismatch < 0 || indexOfMismatch >= expected.Length)\n {\n return;\n }\n\n assertionChain.FailWith(\n $\"{ExpectationDescription}{{0}}{{reason}}, but {{1}} differs near {subject.IndexedSegmentAt(indexOfMismatch)}.\",\n expected, subject);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringEndStrategy.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringEndStrategy : IStringComparisonStrategy\n{\n private readonly IEqualityComparer comparer;\n private readonly string predicateDescription;\n\n public StringEndStrategy(IEqualityComparer comparer, string predicateDescription)\n {\n this.comparer = comparer;\n this.predicateDescription = predicateDescription;\n }\n\n public string ExpectationDescription => $\"Expected {{context:string}} to {predicateDescription} \";\n\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n assertionChain\n .ForCondition(subject!.Length >= expected.Length)\n .FailWith($\"{ExpectationDescription}{{0}}{{reason}}, but {{1}} is too short.\", expected, subject);\n\n if (!assertionChain.Succeeded)\n {\n return;\n }\n\n int indexOfMismatch = subject.Substring(subject.Length - expected.Length).IndexOfFirstMismatch(expected, comparer);\n\n if (indexOfMismatch < 0)\n {\n return;\n }\n\n assertionChain.FailWith(\n $\"{ExpectationDescription}{{0}}{{reason}}, but {{1}} differs near {subject.IndexedSegmentAt(indexOfMismatch)}.\",\n expected, subject);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AssertionExtensions.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.IO;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Collections;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Numeric;\nusing AwesomeAssertions.Primitives;\nusing AwesomeAssertions.Specialized;\nusing AwesomeAssertions.Streams;\nusing AwesomeAssertions.Types;\nusing AwesomeAssertions.Xml;\nusing JetBrains.Annotations;\nusing NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute;\n#if !NETSTANDARD2_0\nusing AwesomeAssertions.Events;\n#endif\n\nnamespace AwesomeAssertions;\n\n/// \n/// Contains extension methods for custom assertions in unit tests.\n/// \n[DebuggerNonUserCode]\npublic static class AssertionExtensions\n{\n private static readonly AggregateExceptionExtractor Extractor = new();\n\n static AssertionExtensions()\n {\n AssertionEngine.EnsureInitialized();\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n /// is .\n /// is .\n [Pure]\n public static Action Invoking(this T subject, Action action)\n {\n Guard.ThrowIfArgumentIsNull(subject);\n Guard.ThrowIfArgumentIsNull(action);\n\n return () => action(subject);\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n /// is .\n /// is .\n [Pure]\n public static Func Invoking(this T subject, Func action)\n {\n Guard.ThrowIfArgumentIsNull(subject);\n Guard.ThrowIfArgumentIsNull(action);\n\n return () => action(subject);\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n [Pure]\n public static Func Awaiting(this T subject, Func action)\n {\n return () => action(subject);\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n [Pure]\n public static Func> Awaiting(this T subject, Func> action)\n {\n return () => action(subject);\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n [Pure]\n public static Func Awaiting(this T subject, Func action)\n {\n return () => action(subject).AsTask();\n }\n\n /// \n /// Invokes the specified action on a subject so that you can chain it\n /// with any of the assertions from \n /// \n [Pure]\n public static Func> Awaiting(this T subject, Func> action)\n {\n return () => action(subject).AsTask();\n }\n\n /// \n /// Provides methods for asserting the execution time of a method or property.\n /// \n /// The object that exposes the method or property.\n /// A reference to the method or property to measure the execution time of.\n /// \n /// Returns an object for asserting that the execution time matches certain conditions.\n /// \n /// is .\n /// is .\n [MustUseReturnValue /* do not use Pure because this method executes the action before returning to the caller */]\n public static MemberExecutionTime ExecutionTimeOf(this T subject, Expression> action,\n StartTimer createTimer = null)\n {\n Guard.ThrowIfArgumentIsNull(subject);\n Guard.ThrowIfArgumentIsNull(action);\n\n createTimer ??= () => new StopwatchTimer();\n\n return new MemberExecutionTime(subject, action, createTimer);\n }\n\n /// \n /// Provides methods for asserting the execution time of an action.\n /// \n /// An action to measure the execution time of.\n /// \n /// Returns an object for asserting that the execution time matches certain conditions.\n /// \n /// is .\n [MustUseReturnValue /* do not use Pure because this method executes the action before returning to the caller */]\n public static ExecutionTime ExecutionTime(this Action action, StartTimer createTimer = null)\n {\n createTimer ??= () => new StopwatchTimer();\n\n return new ExecutionTime(action, createTimer);\n }\n\n /// \n /// Provides methods for asserting the execution time of an async action.\n /// \n /// \n /// Returns an object for asserting that the execution time matches certain conditions.\n /// \n /// is .\n [MustUseReturnValue /* do not use Pure because this method executes the action before returning to the caller */]\n public static ExecutionTime ExecutionTime(this Func action)\n {\n return new ExecutionTime(action, () => new StopwatchTimer());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static ExecutionTimeAssertions Should(this ExecutionTime executionTime)\n {\n return new ExecutionTimeAssertions(executionTime, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static AssemblyAssertions Should([NotNull] this Assembly assembly)\n {\n return new AssemblyAssertions(assembly, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static XDocumentAssertions Should([NotNull] this XDocument actualValue)\n {\n return new XDocumentAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static XElementAssertions Should([NotNull] this XElement actualValue)\n {\n return new XElementAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static XAttributeAssertions Should([NotNull] this XAttribute actualValue)\n {\n return new XAttributeAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static StreamAssertions Should([NotNull] this Stream actualValue)\n {\n return new StreamAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static BufferedStreamAssertions Should([NotNull] this BufferedStream actualValue)\n {\n return new BufferedStreamAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Forces enumerating a collection. Should be used to assert that a method that uses the\n /// keyword throws a particular exception.\n /// \n [Pure]\n public static Action Enumerating(this Func enumerable)\n {\n return () => ForceEnumeration(enumerable);\n }\n\n /// \n /// Forces enumerating a collection. Should be used to assert that a method that uses the\n /// keyword throws a particular exception.\n /// \n [Pure]\n public static Action Enumerating(this Func> enumerable)\n {\n return () => ForceEnumeration(enumerable);\n }\n\n /// \n /// Forces enumerating a collection of the provided .\n /// Should be used to assert that a method that uses the keyword throws a particular exception.\n /// \n /// The object that exposes the method or property.\n /// A reference to the method or property to force enumeration of.\n public static Action Enumerating(this T subject, Func> enumerable)\n {\n return () => ForceEnumeration(subject, enumerable);\n }\n\n private static void ForceEnumeration(Func enumerable)\n {\n foreach (object _ in enumerable())\n {\n // Do nothing\n }\n }\n\n private static void ForceEnumeration(T subject, Func enumerable)\n {\n foreach (object _ in enumerable(subject))\n {\n // Do nothing\n }\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static ObjectAssertions Should([NotNull] this object actualValue)\n {\n return new ObjectAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static BooleanAssertions Should(this bool actualValue)\n {\n return new BooleanAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableBooleanAssertions Should(this bool? actualValue)\n {\n return new NullableBooleanAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static GuidAssertions Should(this Guid actualValue)\n {\n return new GuidAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableGuidAssertions Should(this Guid? actualValue)\n {\n return new NullableGuidAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static GenericCollectionAssertions Should([NotNull] this IEnumerable actualValue)\n {\n return new GenericCollectionAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static StringCollectionAssertions Should([NotNull] this IEnumerable @this)\n {\n return new StringCollectionAssertions(@this, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static GenericDictionaryAssertions, TKey, TValue> Should(\n [NotNull] this IDictionary actualValue)\n {\n return new GenericDictionaryAssertions, TKey, TValue>(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current of .\n /// \n [Pure]\n public static GenericDictionaryAssertions>, TKey, TValue> Should(\n [NotNull] this IEnumerable> actualValue)\n {\n return new GenericDictionaryAssertions>, TKey, TValue>(actualValue,\n AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static GenericDictionaryAssertions Should(\n [NotNull] this TCollection actualValue)\n where TCollection : IEnumerable>\n {\n return new GenericDictionaryAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static DateTimeAssertions Should(this DateTime actualValue)\n {\n return new DateTimeAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static DateTimeOffsetAssertions Should(this DateTimeOffset actualValue)\n {\n return new DateTimeOffsetAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableDateTimeAssertions Should(this DateTime? actualValue)\n {\n return new NullableDateTimeAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableDateTimeOffsetAssertions Should(this DateTimeOffset? actualValue)\n {\n return new NullableDateTimeOffsetAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n#if NET6_0_OR_GREATER\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static DateOnlyAssertions Should(this DateOnly actualValue)\n {\n return new DateOnlyAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableDateOnlyAssertions Should(this DateOnly? actualValue)\n {\n return new NullableDateOnlyAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static TimeOnlyAssertions Should(this TimeOnly actualValue)\n {\n return new TimeOnlyAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableTimeOnlyAssertions Should(this TimeOnly? actualValue)\n {\n return new NullableTimeOnlyAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n#endif\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static ComparableTypeAssertions Should([NotNull] this IComparable comparableValue)\n {\n return new ComparableTypeAssertions(comparableValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this int actualValue)\n {\n return new Int32Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this int? actualValue)\n {\n return new NullableInt32Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this uint actualValue)\n {\n return new UInt32Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this uint? actualValue)\n {\n return new NullableUInt32Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this decimal actualValue)\n {\n return new DecimalAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this decimal? actualValue)\n {\n return new NullableDecimalAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this byte actualValue)\n {\n return new ByteAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this byte? actualValue)\n {\n return new NullableByteAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this sbyte actualValue)\n {\n return new SByteAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this sbyte? actualValue)\n {\n return new NullableSByteAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this short actualValue)\n {\n return new Int16Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this short? actualValue)\n {\n return new NullableInt16Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this ushort actualValue)\n {\n return new UInt16Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this ushort? actualValue)\n {\n return new NullableUInt16Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this long actualValue)\n {\n return new Int64Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this long? actualValue)\n {\n return new NullableInt64Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this ulong actualValue)\n {\n return new UInt64Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this ulong? actualValue)\n {\n return new NullableUInt64Assertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this float actualValue)\n {\n return new SingleAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this float? actualValue)\n {\n return new NullableSingleAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NumericAssertions Should(this double actualValue)\n {\n return new DoubleAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableNumericAssertions Should(this double? actualValue)\n {\n return new NullableDoubleAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static StringAssertions Should([NotNull] this string actualValue)\n {\n return new StringAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static SimpleTimeSpanAssertions Should(this TimeSpan actualValue)\n {\n return new SimpleTimeSpanAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current nullable .\n /// \n [Pure]\n public static NullableSimpleTimeSpanAssertions Should(this TimeSpan? actualValue)\n {\n return new NullableSimpleTimeSpanAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static TypeAssertions Should([NotNull] this Type subject)\n {\n return new TypeAssertions(subject, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n /// is .\n [Pure]\n public static TypeSelectorAssertions Should(this TypeSelector typeSelector)\n {\n Guard.ThrowIfArgumentIsNull(typeSelector);\n\n return new TypeSelectorAssertions(AssertionChain.GetOrCreate(), typeSelector.ToArray());\n }\n\n /// \n /// Returns a object\n /// that can be used to assert the current .\n /// \n /// \n [Pure]\n public static ConstructorInfoAssertions Should([NotNull] this ConstructorInfo constructorInfo)\n {\n return new ConstructorInfoAssertions(constructorInfo, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the current .\n /// \n /// \n [Pure]\n public static MethodInfoAssertions Should([NotNull] this MethodInfo methodInfo)\n {\n return new MethodInfoAssertions(methodInfo, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the methods returned by the\n /// current .\n /// \n /// \n /// is .\n [Pure]\n public static MethodInfoSelectorAssertions Should(this MethodInfoSelector methodSelector)\n {\n Guard.ThrowIfArgumentIsNull(methodSelector);\n\n return new MethodInfoSelectorAssertions(AssertionChain.GetOrCreate(), methodSelector.ToArray());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n /// \n [Pure]\n public static PropertyInfoAssertions Should([NotNull] this PropertyInfo propertyInfo)\n {\n return new PropertyInfoAssertions(propertyInfo, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the properties returned by the\n /// current .\n /// \n /// \n /// is .\n [Pure]\n public static PropertyInfoSelectorAssertions Should(this PropertyInfoSelector propertyInfoSelector)\n {\n Guard.ThrowIfArgumentIsNull(propertyInfoSelector);\n\n return new PropertyInfoSelectorAssertions(AssertionChain.GetOrCreate(), propertyInfoSelector.ToArray());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static ActionAssertions Should([NotNull] this Action action)\n {\n return new ActionAssertions(action, Extractor, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NonGenericAsyncFunctionAssertions Should([NotNull] this Func action)\n {\n return new NonGenericAsyncFunctionAssertions(action, Extractor, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current System.Func{Task{T}}.\n /// \n [Pure]\n public static GenericAsyncFunctionAssertions Should([NotNull] this Func> action)\n {\n return new GenericAsyncFunctionAssertions(action, Extractor, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static FunctionAssertions Should([NotNull] this Func func)\n {\n return new FunctionAssertions(func, Extractor, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static TaskCompletionSourceAssertions Should(this TaskCompletionSource tcs)\n {\n return new TaskCompletionSourceAssertions(tcs, AssertionChain.GetOrCreate());\n }\n\n#if !NETSTANDARD2_0\n\n /// \n /// Starts monitoring for its events.\n /// \n /// The object for which to monitor the events.\n /// is .\n public static IMonitor Monitor(this T eventSource)\n {\n return new EventMonitor(eventSource, new EventMonitorOptions());\n }\n\n /// \n /// Starts monitoring for its events using the given .\n /// \n /// The object for which to monitor the events.\n /// \n /// Options to configure the EventMonitor.\n /// \n /// is .\n public static IMonitor Monitor(this T eventSource, Action configureOptions)\n {\n Guard.ThrowIfArgumentIsNull(configureOptions, nameof(configureOptions));\n\n var options = new EventMonitorOptions();\n configureOptions(options);\n return new EventMonitor(eventSource, options);\n }\n\n#endif\n\n#if NET6_0_OR_GREATER\n /// \n /// Returns a object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static TaskCompletionSourceAssertions Should(this TaskCompletionSource tcs)\n {\n return new TaskCompletionSourceAssertions(tcs, AssertionChain.GetOrCreate());\n }\n\n#endif\n\n /// \n /// Safely casts the specified object to the type specified through .\n /// \n /// \n /// Has been introduced to allow casting objects without breaking the fluent API.\n /// \n /// The to cast to\n [Pure]\n public static TTo As(this object subject)\n {\n return subject is TTo to ? to : default;\n }\n\n #region Prevent chaining on AndConstraint\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this ReferenceTypeAssertions _)\n where TAssertions : ReferenceTypeAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this BooleanAssertions _)\n where TAssertions : BooleanAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateTimeAssertions _)\n where TAssertions : DateTimeAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateTimeOffsetAssertions _)\n where TAssertions : DateTimeOffsetAssertions\n {\n InvalidShouldCall();\n }\n\n#if NET6_0_OR_GREATER\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateOnlyAssertions _)\n where TAssertions : DateOnlyAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this TimeOnlyAssertions _)\n where TAssertions : TimeOnlyAssertions\n {\n InvalidShouldCall();\n }\n\n#endif\n\n /// \n /// You are asserting the itself. Remove the Should() method directly following And.\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this ExecutionTimeAssertions _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this GuidAssertions _)\n where TAssertions : GuidAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this MethodInfoSelectorAssertions _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this NumericAssertionsBase _)\n where TSubject : struct, IComparable\n where TAssertions : NumericAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this PropertyInfoSelectorAssertions _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this SimpleTimeSpanAssertions _)\n where TAssertions : SimpleTimeSpanAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this TaskCompletionSourceAssertionsBase _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this TypeSelectorAssertions _)\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this EnumAssertions _)\n where TEnum : struct, Enum\n where TAssertions : EnumAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateTimeRangeAssertions _)\n where TAssertions : DateTimeAssertions\n {\n InvalidShouldCall();\n }\n\n /// \n [Obsolete(\"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'\", error: true)]\n public static void Should(this DateTimeOffsetRangeAssertions _)\n where TAssertions : DateTimeOffsetAssertions\n {\n InvalidShouldCall();\n }\n\n [DoesNotReturn]\n private static void InvalidShouldCall()\n {\n throw new InvalidOperationException(\n \"You are asserting the 'AndConstraint' itself. Remove the 'Should()' method directly following 'And'.\");\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MemberInfoAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic abstract class MemberInfoAssertions : ReferenceTypeAssertions\n where TSubject : MemberInfo\n where TAssertions : MemberInfoAssertions\n{\n private readonly AssertionChain assertionChain;\n\n protected MemberInfoAssertions(TSubject subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the selected member is decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint, TAttribute> BeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n return BeDecoratedWith(_ => true, because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected member is not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n return NotBeDecoratedWith(_ => true, because, becauseArgs);\n }\n\n /// \n /// Asserts that the selected member is decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndWhichConstraint, TAttribute> BeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {Identifier} to be decorated with {{0}}{{reason}}\" +\n \", but {context:member} is .\", typeof(TAttribute));\n\n IEnumerable attributes = [];\n\n if (assertionChain.Succeeded)\n {\n attributes = Subject.GetMatchingAttributes(isMatchingAttributePredicate);\n\n assertionChain\n .ForCondition(attributes.Any())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected {Identifier} {SubjectDescription} to be decorated with {{0}}{{reason}}\" +\n \", but that attribute was not found.\", typeof(TAttribute)));\n }\n\n return new AndWhichConstraint, TAttribute>(this, attributes);\n }\n\n /// \n /// Asserts that the selected member is not decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .ForCondition(Subject is not null)\n .FailWith(\n $\"Expected {Identifier} to not be decorated with {{0}}{{reason}}\" +\n \", but {context:member} is .\", typeof(TAttribute));\n\n if (assertionChain.Succeeded)\n {\n IEnumerable attributes = Subject.GetMatchingAttributes(isMatchingAttributePredicate);\n\n assertionChain\n .ForCondition(!attributes.Any())\n .BecauseOf(because, becauseArgs)\n .FailWith(() => new FailReason(\n $\"Expected {Identifier} {SubjectDescription} to not be decorated with {{0}}{{reason}}\" +\n \", but that attribute was found.\", typeof(TAttribute)));\n }\n\n return new AndConstraint((TAssertions)this);\n }\n\n protected override string Identifier => \"member\";\n\n private protected virtual string SubjectDescription => $\"{Subject.DeclaringType}.{Subject.Name}\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/PropertyInfoSelectorAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Types;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains assertions for the objects returned by the parent .\n/// \n[DebuggerNonUserCode]\npublic class PropertyInfoSelectorAssertions\n{\n /// \n /// Initializes a new instance of the class, for a number of objects.\n /// \n /// The properties to assert.\n /// is .\n public PropertyInfoSelectorAssertions(AssertionChain assertionChain, params PropertyInfo[] properties)\n {\n CurrentAssertionChain = assertionChain;\n Guard.ThrowIfArgumentIsNull(properties);\n\n SubjectProperties = properties;\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public IEnumerable SubjectProperties { get; }\n\n /// \n /// Asserts that the selected properties are virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n PropertyInfo[] nonVirtualProperties = GetAllNonVirtualPropertiesFromSelection();\n\n CurrentAssertionChain\n .ForCondition(nonVirtualProperties.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties to be virtual{reason}, but the following properties are not virtual:\" +\n Environment.NewLine + GetDescriptionsFor(nonVirtualProperties));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected properties are not virtual.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeVirtual([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n PropertyInfo[] virtualProperties = GetAllVirtualPropertiesFromSelection();\n\n CurrentAssertionChain\n .ForCondition(virtualProperties.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties not to be virtual{reason}, but the following properties are virtual:\" +\n Environment.NewLine + GetDescriptionsFor(virtualProperties));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected properties have a setter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeWritable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n PropertyInfo[] readOnlyProperties = GetAllReadOnlyPropertiesFromSelection();\n\n CurrentAssertionChain\n .ForCondition(readOnlyProperties.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties to have a setter{reason}, but the following properties do not:\" +\n Environment.NewLine + GetDescriptionsFor(readOnlyProperties));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected properties do not have a setter.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeWritable([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n PropertyInfo[] writableProperties = GetAllWritablePropertiesFromSelection();\n\n CurrentAssertionChain\n .ForCondition(writableProperties.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected selected properties to not have a setter{reason}, but the following properties do:\" +\n Environment.NewLine + GetDescriptionsFor(writableProperties));\n\n return new AndConstraint(this);\n }\n\n private PropertyInfo[] GetAllReadOnlyPropertiesFromSelection()\n {\n return SubjectProperties.Where(property => !property.CanWrite).ToArray();\n }\n\n private PropertyInfo[] GetAllWritablePropertiesFromSelection()\n {\n return SubjectProperties.Where(property => property.CanWrite).ToArray();\n }\n\n private PropertyInfo[] GetAllNonVirtualPropertiesFromSelection()\n {\n return SubjectProperties.Where(property => !property.IsVirtual()).ToArray();\n }\n\n private PropertyInfo[] GetAllVirtualPropertiesFromSelection()\n {\n return SubjectProperties.Where(property => property.IsVirtual()).ToArray();\n }\n\n /// \n /// Asserts that the selected properties are decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n PropertyInfo[] propertiesWithoutAttribute = GetPropertiesWithout();\n\n CurrentAssertionChain\n .ForCondition(propertiesWithoutAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties to be decorated with {0}{reason}\" +\n \", but the following properties are not:\" + Environment.NewLine +\n GetDescriptionsFor(propertiesWithoutAttribute), typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected properties are not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n PropertyInfo[] propertiesWithAttribute = GetPropertiesWith();\n\n CurrentAssertionChain\n .ForCondition(propertiesWithAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected all selected properties not to be decorated with {0}{reason}\" +\n \", but the following properties are:\" + Environment.NewLine +\n GetDescriptionsFor(propertiesWithAttribute), typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n private PropertyInfo[] GetPropertiesWithout()\n where TAttribute : Attribute\n {\n return SubjectProperties.Where(property => !property.IsDecoratedWith()).ToArray();\n }\n\n private PropertyInfo[] GetPropertiesWith()\n where TAttribute : Attribute\n {\n return SubjectProperties.Where(property => property.IsDecoratedWith()).ToArray();\n }\n\n private static string GetDescriptionsFor(IEnumerable properties)\n {\n IEnumerable descriptions = properties.Select(property => Formatter.ToString(property));\n\n return string.Join(Environment.NewLine, descriptions);\n }\n\n /// \n /// Returns the type of the subject the assertion applies on.\n /// \n#pragma warning disable CA1822 // Do not change signature of a public member\n protected string Context => \"property info\";\n#pragma warning restore CA1822\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/PropertyInfoFormatter.cs", "using System.Reflection;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class PropertyInfoFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is PropertyInfo;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var property = (PropertyInfo)value;\n formatChild(\"type\", property.DeclaringType!.AsFormattableShortType(), formattedGraph);\n formattedGraph.AddFragment($\".{property.Name}\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/Reason.cs", "using System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents the reason for a structural equivalency assertion.\n/// \npublic class Reason\n{\n public Reason([StringSyntax(\"CompositeFormat\")] string formattedMessage, object[] arguments)\n {\n FormattedMessage = formattedMessage;\n Arguments = arguments;\n }\n\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n public string FormattedMessage { get; set; }\n\n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public object[] Arguments { get; set; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/TypeSelectorAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Types;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that all s in a \n/// meet certain expectations.\n/// \n[DebuggerNonUserCode]\npublic class TypeSelectorAssertions\n{\n /// \n /// Initializes a new instance of the class.\n /// \n /// is or contains .\n public TypeSelectorAssertions(AssertionChain assertionChain, params Type[] types)\n {\n CurrentAssertionChain = assertionChain;\n Guard.ThrowIfArgumentIsNull(types);\n Guard.ThrowIfArgumentContainsNull(types);\n\n Subject = types;\n }\n\n /// \n /// Gets the object whose value is being asserted.\n /// \n public IEnumerable Subject { get; }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that the current is decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDecoratedWith([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Type[] typesWithoutAttribute = Subject\n .Where(type => !type.IsDecoratedWith())\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithoutAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be decorated with {0}{reason}, but the attribute was not found on the following types:\n {{GetDescriptionsFor(typesWithoutAttribute)}}.\n \"\"\",\n typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n Type[] typesWithoutMatchingAttribute = Subject\n .Where(type => !type.IsDecoratedWith(isMatchingAttributePredicate))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithoutMatchingAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be decorated with {0} that matches {1}{reason}, but no matching attribute was found on the following types:\n {{GetDescriptionsFor(typesWithoutMatchingAttribute)}}.\n \"\"\",\n typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is decorated with, or inherits from a parent class, the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeDecoratedWithOrInherit(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Type[] typesWithoutAttribute = Subject\n .Where(type => !type.IsDecoratedWithOrInherit())\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithoutAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be decorated with or inherit {0}{reason}, but the attribute was not found on the following types:\n {{GetDescriptionsFor(typesWithoutAttribute)}}.\n \"\"\",\n typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is decorated with, or inherits from a parent class, an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint BeDecoratedWithOrInherit(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n Type[] typesWithoutMatchingAttribute = Subject\n .Where(type => !type.IsDecoratedWithOrInherit(isMatchingAttributePredicate))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithoutMatchingAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be decorated with or inherit {0} that matches {1}{reason}, but no matching attribute was found on the following types:\n {{GetDescriptionsFor(typesWithoutMatchingAttribute)}}.\n \"\"\",\n typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWith([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Type[] typesWithAttribute = Subject\n .Where(type => type.IsDecoratedWith())\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to not be decorated with {0}{reason}, but the attribute was found on the following types:\n {{GetDescriptionsFor(typesWithAttribute)}}.\n \"\"\",\n typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWith(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n Type[] typesWithMatchingAttribute = Subject\n .Where(type => type.IsDecoratedWith(isMatchingAttributePredicate))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithMatchingAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to not be decorated with {0} that matches {1}{reason}, but a matching attribute was found on the following types:\n {{GetDescriptionsFor(typesWithMatchingAttribute)}}.\n \"\"\",\n typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with and does not inherit from a parent class, the specified .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeDecoratedWithOrInherit(\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Type[] typesWithAttribute = Subject\n .Where(type => type.IsDecoratedWithOrInherit())\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to not be decorated with or inherit {0}{reason}, but the attribute was found on the following types:\n {{GetDescriptionsFor(typesWithAttribute)}}.\n \"\"\",\n typeof(TAttribute));\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not decorated with and does not inherit from a parent class, an attribute of type \n /// that matches the specified .\n /// \n /// \n /// The predicate that the attribute must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint NotBeDecoratedWithOrInherit(\n Expression> isMatchingAttributePredicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TAttribute : Attribute\n {\n Guard.ThrowIfArgumentIsNull(isMatchingAttributePredicate);\n\n Type[] typesWithMatchingAttribute = Subject\n .Where(type => type.IsDecoratedWithOrInherit(isMatchingAttributePredicate))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesWithMatchingAttribute.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to not be decorated with or inherit {0} that matches {1}{reason}, but a matching attribute was found on the following types:\n {{GetDescriptionsFor(typesWithMatchingAttribute)}}.\n \"\"\",\n typeof(TAttribute), isMatchingAttributePredicate);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the selected types are sealed\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeSealed([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var notSealedTypes = Subject.Where(type => !type.IsCSharpSealed()).ToArray();\n\n CurrentAssertionChain.ForCondition(notSealedTypes.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be sealed{reason}, but the following types are not:\n {{GetDescriptionsFor(notSealedTypes)}}.\n \"\"\");\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the all are not sealed classes\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeSealed([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var sealedTypes = Subject.Where(type => type.IsCSharpSealed()).ToArray();\n\n CurrentAssertionChain.ForCondition(sealedTypes.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types not to be sealed{reason}, but the following types are:\n {{GetDescriptionsFor(sealedTypes)}}.\n \"\"\");\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is in the specified .\n /// \n /// \n /// The namespace that the type must be in.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeInNamespace(string @namespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Type[] typesNotInNamespace = Subject\n .Where(t => t.Namespace != @namespace)\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesNotInNamespace.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected all types to be in namespace {0}{reason}, but the following types are in a different namespace:\n {{GetDescriptionsFor(typesNotInNamespace)}}.\n \"\"\",\n @namespace);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current is not in the specified .\n /// \n /// \n /// The namespace that the type must not be in.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeInNamespace(string @namespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Type[] typesInNamespace = Subject\n .Where(t => t.Namespace == @namespace)\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesInNamespace.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected no types to be in namespace {0}{reason}, but the following types are in the namespace:\n {{GetDescriptionsFor(typesInNamespace)}}.\n \"\"\",\n @namespace);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the namespace of the current starts with the specified .\n /// \n /// \n /// The namespace that the namespace of the type must start with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeUnderNamespace(string @namespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Type[] typesNotUnderNamespace = Subject\n .Where(t => !t.IsUnderNamespace(@namespace))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesNotUnderNamespace.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected the namespaces of all types to start with {0}{reason}, but the namespaces of the following types do not start with it:\n {{GetDescriptionsFor(typesNotUnderNamespace)}}.\n \"\"\",\n @namespace);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the namespace of the current \n /// does not starts with the specified .\n /// \n /// \n /// The namespace that the namespace of the type must not start with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeUnderNamespace(string @namespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Type[] typesUnderNamespace = Subject\n .Where(t => t.IsUnderNamespace(@namespace))\n .ToArray();\n\n CurrentAssertionChain\n .ForCondition(typesUnderNamespace.Length == 0)\n .BecauseOf(because, becauseArgs)\n .FailWith($$\"\"\"\n Expected the namespaces of all types to not start with {0}{reason}, but the namespaces of the following types start with it:\n {{GetDescriptionsFor(typesUnderNamespace)}}.\n \"\"\",\n @namespace);\n\n return new AndConstraint(this);\n }\n\n private static string GetDescriptionsFor(IEnumerable types)\n {\n IEnumerable descriptions = types.Select(type => GetDescriptionFor(type));\n return string.Join(Environment.NewLine, descriptions);\n }\n\n private static string GetDescriptionFor(Type type)\n {\n return type.ToString();\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\n \"Equals is not part of Awesome Assertions. Did you mean BeInNamespace() or BeDecoratedWith() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ExpressionValueFormatter.cs", "using System;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class ExpressionValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is Expression;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(value.ToString().Replace(\" = \", \" == \", StringComparison.Ordinal));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeEquivalentTo.cs", "using System;\nusing System.Collections.Immutable;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeEquivalentTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeEquivalentTo\n {\n [Fact]\n public void When_two_collections_contain_the_same_elements_it_should_treat_them_as_equivalent()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1, 2];\n\n // Act / Assert\n collection1.Should().BeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_a_collection_contains_same_elements_it_should_treat_it_as_equivalent()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().BeEquivalentTo([3, 1, 2]);\n }\n\n [Fact]\n public void When_character_collections_are_equivalent_it_should_not_throw()\n {\n // Arrange\n char[] list1 = \"abc123ab\".ToCharArray();\n char[] list2 = \"abc123ab\".ToCharArray();\n\n // Act / Assert\n list1.Should().BeEquivalentTo(list2);\n }\n\n [Fact]\n public void When_collections_are_not_equivalent_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2];\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2, \"we treat {0} alike\", \"all\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*collection*2 item(s)*we treat all alike, but *1 item(s) more than*\");\n }\n\n [Fact]\n public void When_collections_with_duplicates_are_not_equivalent_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3, 1];\n int[] collection2 = [1, 2, 3, 3];\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1[3]*to be 3, but found 1*\");\n }\n\n [Fact]\n public void When_testing_for_equivalence_against_empty_collection_it_should_throw()\n {\n // Arrange\n int[] subject = [1, 2, 3];\n int[] otherCollection = [];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be a collection with 0 item(s), but*contains 3 item(s)*\");\n }\n\n [Fact]\n public void When_two_collections_are_both_empty_it_should_treat_them_as_equivalent()\n {\n // Arrange\n int[] subject = [];\n int[] otherCollection = [];\n\n // Act / Assert\n subject.Should().BeEquivalentTo(otherCollection);\n }\n\n [Fact]\n public void When_testing_for_equivalence_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = null;\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected**but found {1, 2, 3}*\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equivalent_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act =\n () => collection.Should()\n .BeEquivalentTo(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to be *\");\n }\n\n [Fact]\n public void Default_immutable_arrays_should_be_equivalent()\n {\n // Arrange\n ImmutableArray collection = default;\n ImmutableArray collection1 = default;\n\n // Act / Assert\n collection.Should().BeEquivalentTo(collection1);\n }\n\n [Fact]\n public void Default_immutable_lists_should_be_equivalent()\n {\n // Arrange\n ImmutableList collection = default;\n ImmutableList collection1 = default;\n\n // Act / Assert\n collection.Should().BeEquivalentTo(collection1);\n }\n\n [Fact]\n public void Can_ignore_casing_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"first\", \"test\", \"last\" };\n var expectation = new[] { \"first\", \"TEST\", \"last\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"first\", \" test\", \"last\" };\n var expectation = new[] { \"first\", \"test\", \"last\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"first\", \"test \", \"last\" };\n var expectation = new[] { \"first\", \"test\", \"last\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"first\", \"A\\nB\\r\\nC\", \"last\" };\n var expectation = new[] { \"first\", \"A\\r\\nB\\nC\", \"last\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringNewlineStyle());\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void When_collection_is_not_equivalent_to_another_smaller_collection_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_large_collection_is_equivalent_to_another_equally_size_collection_it_should_throw()\n {\n // Arrange\n var collection1 = Enumerable.Repeat(1, 10000);\n var collection2 = Enumerable.Repeat(1, 10000);\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_is_not_equivalent_to_another_equally_sized_collection_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1, 4];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_collections_are_unexpectedly_equivalent_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1, 2];\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 {1, 2, 3} not*equivalent*{3, 1, 2}.\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equivalent_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] actual = null;\n int[] expectation = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n actual.Should().NotBeEquivalentTo(expectation, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*be equivalent because we want to test the behaviour with a null subject, but found *\");\n }\n\n [Fact]\n public void When_non_empty_collection_is_not_expected_to_be_equivalent_to_an_empty_collection_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_testing_collections_not_to_be_equivalent_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = null;\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify inequivalence against a collection.*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void When_testing_collections_not_to_be_equivalent_against_same_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n var collection1 = collection;\n\n // Act\n Action act = () => collection.Should().NotBeEquivalentTo(collection1,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not to be equivalent*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_a_collections_is_equivalent_to_an_approximate_copy_it_should_throw()\n {\n // Arrange\n double[] collection = [1.0, 2.0, 3.0];\n double[] collection1 = [1.5, 2.5, 3.5];\n\n // Act\n Action act = () => collection.Should().NotBeEquivalentTo(collection1, opt => opt\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.5))\n .WhenTypeIs(),\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not to be equivalent*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equivalent_with_options_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] actual = null;\n int[] expectation = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n actual.Should().NotBeEquivalentTo(expectation, opt => opt, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual not to be equivalent *failure message*, but found .*\");\n }\n\n [Fact]\n public void Default_immutable_array_should_not_be_equivalent_to_initialized_immutable_array()\n {\n // Arrange\n ImmutableArray subject = default;\n ImmutableArray expectation = ImmutableArray.Create(\"a\", \"b\", \"c\");\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(expectation);\n }\n\n [Fact]\n public void Immutable_array_should_not_be_equivalent_to_default_immutable_array()\n {\n // Arrange\n ImmutableArray collection = ImmutableArray.Create(\"a\", \"b\", \"c\");\n ImmutableArray collection1 = default;\n\n // Act / Assert\n collection.Should().NotBeEquivalentTo(collection1);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ReferenceTypeAssertionsSpecs.Satisfy.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ReferenceTypeAssertionsSpecs\n{\n public class Satisfy\n {\n [Fact]\n public void Object_satisfying_inspector_does_not_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act / Assert\n someObject.Should().Satisfy(x => x.Should().NotBeNull());\n }\n\n [Fact]\n public void Object_not_satisfying_inspector_throws()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().Satisfy(o => o.Should().BeNull(\"it is not initialized yet\"));\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"\"\"\n Expected {nameof(someObject)} to match inspector, but the inspector was not satisfied:\n *Expected o to be because it is not initialized yet, but found System.Object*\n \"\"\");\n }\n\n [Fact]\n public void Object_satisfied_against_null_throws()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().Satisfy(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify an object against a inspector.*\");\n }\n\n [Fact]\n public void Typed_object_satisfying_inspector_does_not_throw()\n {\n // Arrange\n var personDto = new PersonDto\n {\n Name = \"Name Nameson\",\n Birthdate = new DateTime(2000, 1, 1),\n };\n\n // Act / Assert\n personDto.Should().Satisfy(o => o.Age.Should().BeGreaterThan(0));\n }\n\n [Fact]\n public void Complex_typed_object_satisfying_inspector_does_not_throw()\n {\n // Arrange\n var complexDto = new PersonAndAddressDto\n {\n Person = new PersonDto\n {\n Name = \"Name Nameson\",\n Birthdate = new DateTime(2000, 1, 1),\n },\n Address = new AddressDto\n {\n Street = \"Named St.\",\n Number = \"42\",\n City = \"Nowhere\",\n Country = \"Neverland\",\n PostalCode = \"12345\",\n }\n };\n\n // Act / Assert\n complexDto.Should().Satisfy(dto =>\n {\n dto.Person.Should().Satisfy(person =>\n {\n person.Name.Should().Be(\"Name Nameson\");\n person.Age.Should().BeGreaterThan(0);\n person.Birthdate.Should().Be(1.January(2000));\n });\n\n dto.Address.Should().Satisfy(address =>\n {\n address.Street.Should().Be(\"Named St.\");\n address.Number.Should().Be(\"42\");\n address.City.Should().Be(\"Nowhere\");\n address.Country.Should().Be(\"Neverland\");\n address.PostalCode.Should().Be(\"12345\");\n });\n });\n }\n\n [Fact]\n public void Typed_object_not_satisfying_inspector_throws()\n {\n // Arrange\n var personDto = new PersonDto\n {\n Name = \"Name Nameson\",\n Birthdate = new DateTime(2000, 1, 1),\n };\n\n // Act\n Action act = () => personDto.Should().Satisfy(d =>\n {\n d.Name.Should().Be(\"Someone Else\");\n d.Age.Should().BeLessThan(20);\n d.Birthdate.Should().BeAfter(1.January(2001));\n });\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"\"\"\n Expected {nameof(personDto)} to match inspector, but the inspector was not satisfied:\n *Expected d.Name*\n *Expected d.Age*\n *Expected d.Birthdate*\n \"\"\");\n }\n\n [Fact]\n public void Complex_typed_object_not_satisfying_inspector_throws()\n {\n // Arrange\n var complexDto = new PersonAndAddressDto\n {\n Person = new PersonDto\n {\n Name = \"Buford Howard Tannen\",\n Birthdate = new DateTime(1937, 3, 26),\n },\n Address = new AddressDto\n {\n Street = \"Mason Street\",\n Number = \"1809\",\n City = \"Hill Valley\",\n Country = \"United States\",\n PostalCode = \"CA 91905\",\n },\n };\n\n // Act\n Action act = () => complexDto.Should().Satisfy(dto =>\n {\n dto.Person.Should().Satisfy(person =>\n {\n person.Name.Should().Be(\"Biff Tannen\");\n person.Age.Should().Be(48);\n person.Birthdate.Should().Be(26.March(1937));\n });\n\n dto.Address.Should().Satisfy(address =>\n {\n address.Street.Should().Be(\"Mason Street\");\n address.Number.Should().Be(\"1809\");\n address.City.Should().Be(\"Hill Valley, San Diego County, California\");\n address.Country.Should().Be(\"United States\");\n address.PostalCode.Should().Be(\"CA 91905\");\n });\n });\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"\"\"\n Expected {nameof(complexDto)} to match inspector, but the inspector was not satisfied:\n *Expected dto.Person to match inspector*\n *Expected person.Name*\n *Expected dto.Address to match inspector*\n *Expected address.City*\n \"\"\");\n }\n\n [Fact]\n public void Typed_object_satisfied_against_incorrect_type_throws()\n {\n // Arrange\n var personDto = new PersonDto();\n\n // Act\n Action act = () => personDto.Should().Satisfy(dto => dto.Should().NotBeNull());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected {nameof(personDto)} to be assignable to {typeof(AddressDto)}, but {typeof(PersonDto)} is not.\");\n }\n\n [Fact]\n public void Sub_class_satisfied_against_base_class_does_not_throw()\n {\n // Arrange\n var subClass = new SubClass\n {\n Number = 42,\n Date = new DateTime(2021, 1, 1),\n Text = \"Some text\"\n };\n\n // Act / Assert\n subClass.Should().Satisfy(x =>\n {\n x.Number.Should().Be(42);\n x.Date.Should().Be(1.January(2021));\n });\n }\n\n [Fact]\n public void Base_class_satisfied_against_sub_class_throws()\n {\n // Arrange\n var baseClass = new BaseClass\n {\n Number = 42,\n Date = new DateTime(2021, 1, 1),\n };\n\n // Act\n Action act = () => baseClass.Should().Satisfy(x =>\n {\n x.Number.Should().Be(42);\n x.Date.Should().Be(1.January(2021));\n x.Text.Should().Be(\"Some text\");\n });\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected {nameof(baseClass)} to be assignable to {typeof(SubClass)}, but {typeof(BaseClass)} is not.\");\n }\n\n [Fact]\n public void Nested_assertion_on_null_throws()\n {\n // Arrange\n var complexDto = new PersonAndAddressDto\n {\n Person = new PersonDto\n {\n Name = \"Buford Howard Tannen\",\n },\n Address = null,\n };\n\n // Act\n Action act = () => complexDto.Should().Satisfy(dto =>\n {\n dto.Person.Name.Should().Be(\"Buford Howard Tannen\");\n dto.Address.Should().Satisfy(address => address.City.Should().Be(\"Hill Valley\"));\n });\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"\"\"\n Expected {nameof(complexDto)} to match inspector, but the inspector was not satisfied:\n *Expected dto.Address to be assignable to {typeof(AddressDto)}, but found .\n \"\"\");\n }\n\n [Fact]\n public void Using_nested_assertion_scope()\n {\n // Arrange\n var complexDto = new PersonAndAddressDto\n {\n Person = new PersonDto\n {\n Name = \"Buford Howard Tannen\",\n },\n Address = null,\n };\n\n // Act\n Action act = () => complexDto.Should().Satisfy(dto =>\n {\n dto.Person.Name.Should().Be(\"Buford Howard Tannen\");\n\n using (new AssertionScope())\n {\n dto.Address.Should().Satisfy(address => address.City.Should().Be(\"Hill Valley\"));\n }\n });\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"\"\"\n Expected {nameof(complexDto)} to match inspector, but the inspector was not satisfied:\n *Expected dto.Address to be assignable to {typeof(AddressDto)}, but found .\n \"\"\");\n }\n\n [Fact]\n public void Using_assertion_scope_with_null_subject()\n {\n // Arrange\n object subject = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n subject.Should().Satisfy(x => x.Should().NotBeNull());\n }\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be assignable to object, but found .\");\n }\n\n [Fact]\n public void Using_assertion_scope_with_subject_satisfied_against_incorrect_type_throws()\n {\n // Arrange\n var personDto = new PersonDto();\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n personDto.Should().Satisfy(dto => dto.Should().NotBeNull());\n }\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n $\"Expected {nameof(personDto)} to be assignable to {typeof(AddressDto)}, but {typeof(PersonDto)} is not.\");\n }\n }\n\n private class PersonDto\n {\n public string Name { get; init; }\n\n public DateTime Birthdate { get; init; }\n\n public int Age => DateTime.UtcNow.Subtract(Birthdate).Days / 365;\n }\n\n private class PersonAndAddressDto\n {\n public PersonDto Person { get; init; }\n\n public AddressDto Address { get; init; }\n }\n\n private class AddressDto\n {\n public string Street { get; init; }\n\n public string Number { get; init; }\n\n public string City { get; init; }\n\n public string PostalCode { get; init; }\n\n public string Country { get; init; }\n }\n\n private class BaseClass\n {\n public int Number { get; init; }\n\n public DateTime Date { get; init; }\n }\n\n private sealed class SubClass : BaseClass\n {\n public string Text { get; init; }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/StringValueFormatter.cs", "namespace AwesomeAssertions.Formatting;\n\npublic class StringValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is string;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n string result = $\"\"\"\n \"{value}\"\n \"\"\";\n\n formattedGraph.AddFragment(result);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TaskFormatter.cs", "using System.Threading.Tasks;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Provides a human-readable version of a generic or non-generic \n/// including its state.\n/// \npublic class TaskFormatter : IValueFormatter\n{\n public bool CanHandle(object value)\n {\n return value is Task;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var task = (Task)value;\n formatChild(\"type\", task.GetType(), formattedGraph);\n formattedGraph.AddFragment($\" {{Status={task.Status}}}\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.Linq;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n // If you try to implement support for IReadOnlyDictionary, these tests should still succeed.\n public class SanityChecks\n {\n [Fact]\n public void When_the_same_dictionaries_are_expected_to_be_the_same_it_should_not_fail()\n {\n // Arrange\n IDictionary dictionary = new Dictionary();\n IDictionary referenceToDictionary = dictionary;\n\n // Act / Assert\n dictionary.Should().BeSameAs(referenceToDictionary);\n }\n\n [Fact]\n public void When_the_same_custom_dictionaries_are_expected_to_be_the_same_it_should_not_fail()\n {\n // Arrange\n IDictionary dictionary = new DictionaryNotImplementingIReadOnlyDictionary();\n IDictionary referenceToDictionary = dictionary;\n\n // Act / Assert\n dictionary.Should().BeSameAs(referenceToDictionary);\n }\n\n [Fact]\n public void When_object_type_is_exactly_equal_to_the_specified_type_it_should_not_fail()\n {\n // Arrange\n IDictionary dictionary = new DictionaryNotImplementingIReadOnlyDictionary();\n\n // Act / Assert\n dictionary.Should().BeOfType>();\n }\n\n [Fact]\n public void When_a_dictionary_does_not_implement_the_read_only_interface_it_should_have_dictionary_assertions()\n {\n // Arrange\n IDictionary dictionary = new DictionaryNotImplementingIReadOnlyDictionary();\n\n // Act / Assert\n dictionary.Should().NotContainKey(0, \"Dictionaries not implementing IReadOnlyDictionary \"\n + \"should be supported at least until Awesome Assertions 6.0.\");\n }\n }\n\n public class OtherDictionaryAssertions\n {\n [Theory]\n [MemberData(nameof(SingleDictionaryData))]\n public void When_a_dictionary_like_collection_contains_the_expected_key_and_value_it_should_succeed(T subject)\n where T : IEnumerable>\n {\n // Assert\n subject.Should().Contain(1, 42);\n }\n\n [Theory]\n [MemberData(nameof(SingleDictionaryData))]\n public void When_using_a_dictionary_like_collection_it_should_preserve_reference_equality(T subject)\n where T : IEnumerable>\n {\n // Act / Assert\n subject.Should().BeSameAs(subject);\n }\n\n [Theory]\n [MemberData(nameof(SingleDictionaryData))]\n public void When_a_dictionary_like_collection_contains_the_expected_key_it_should_succeed(T subject)\n where T : IEnumerable>\n {\n // Act / Assert\n subject.Should().ContainKey(1);\n }\n\n [Theory]\n [MemberData(nameof(SingleDictionaryData))]\n public void When_a_dictionary_like_collection_contains_the_expected_value_it_should_succeed(T subject)\n where T : IEnumerable>\n {\n // Act / Assert\n subject.Should().ContainValue(42);\n }\n\n [Theory]\n [MemberData(nameof(DictionariesData))]\n public void When_comparing_dictionary_like_collections_for_equality_it_should_succeed(T1 subject, T2 expected)\n where T1 : IEnumerable>\n where T2 : IEnumerable>\n {\n // Act / Assert\n subject.Should().Equal(expected);\n }\n\n [Theory]\n [MemberData(nameof(DictionariesData))]\n public void When_comparing_dictionary_like_collections_for_inequality_it_should_throw(T1 subject, T2 expected)\n where T1 : IEnumerable>\n where T2 : IEnumerable>\n {\n // Act\n Action act = () => subject.Should().NotEqual(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n public static TheoryData SingleDictionaryData() =>\n new(Dictionaries());\n\n public static object[] Dictionaries()\n {\n return\n [\n new Dictionary { [1] = 42 },\n new TrueReadOnlyDictionary(new Dictionary { [1] = 42 }),\n new List> { new(1, 42) }\n ];\n }\n\n public static TheoryData DictionariesData()\n {\n var pairs =\n from x in Dictionaries()\n from y in Dictionaries()\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should()\n .HaveCount(2)\n .And.ContainKey(1)\n .And.ContainValue(\"Two\");\n }\n }\n\n /// \n /// This class only implements ,\n /// as also implements .\n /// \n /// The type of the keys in the dictionary.\n /// The type of the values in the dictionary.\n private class TrueReadOnlyDictionary : IReadOnlyDictionary\n {\n private readonly IReadOnlyDictionary dictionary;\n\n public TrueReadOnlyDictionary(IReadOnlyDictionary dictionary)\n {\n this.dictionary = dictionary;\n }\n\n public TValue this[TKey key] => dictionary[key];\n\n public IEnumerable Keys => dictionary.Keys;\n\n public IEnumerable Values => dictionary.Values;\n\n public int Count => dictionary.Count;\n\n public bool ContainsKey(TKey key) => dictionary.ContainsKey(key);\n\n public IEnumerator> GetEnumerator() => dictionary.GetEnumerator();\n\n public bool TryGetValue(TKey key, out TValue value) => dictionary.TryGetValue(key, out value);\n\n IEnumerator IEnumerable.GetEnumerator() => dictionary.GetEnumerator();\n }\n\n internal class TrackingTestDictionary : IDictionary\n {\n private readonly IDictionary entries;\n\n public TrackingTestDictionary(params KeyValuePair[] entries)\n {\n this.entries = entries.ToDictionary(e => e.Key, e => e.Value);\n Enumerator = new TrackingDictionaryEnumerator(entries);\n }\n\n public TrackingDictionaryEnumerator Enumerator { get; }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public IEnumerator> GetEnumerator()\n {\n Enumerator.IncreaseEnumerationCount();\n Enumerator.Reset();\n return Enumerator;\n }\n\n public void Add(KeyValuePair item)\n {\n entries.Add(item);\n }\n\n public void Clear()\n {\n entries.Clear();\n }\n\n public bool Contains(KeyValuePair item)\n {\n return entries.Contains(item);\n }\n\n public void CopyTo(KeyValuePair[] array, int arrayIndex)\n {\n entries.CopyTo(array, arrayIndex);\n }\n\n public bool Remove(KeyValuePair item)\n {\n return entries.Remove(item);\n }\n\n public int Count\n {\n get { return entries.Count; }\n }\n\n public bool IsReadOnly\n {\n get { return entries.IsReadOnly; }\n }\n\n public bool ContainsKey(int key)\n {\n return entries.ContainsKey(key);\n }\n\n public void Add(int key, string value)\n {\n entries.Add(key, value);\n }\n\n public bool Remove(int key)\n {\n return entries.Remove(key);\n }\n\n public bool TryGetValue(int key, out string value)\n {\n return entries.TryGetValue(key, out value);\n }\n\n public string this[int key]\n {\n get { return entries[key]; }\n set { entries[key] = value; }\n }\n\n public ICollection Keys\n {\n get { return entries.Keys; }\n }\n\n public ICollection Values\n {\n get { return entries.Values; }\n }\n }\n\n internal sealed class TrackingDictionaryEnumerator : IEnumerator>\n {\n private readonly KeyValuePair[] values;\n private int index;\n\n public TrackingDictionaryEnumerator(KeyValuePair[] values)\n {\n index = -1;\n this.values = values;\n }\n\n public int LoopCount { get; private set; }\n\n public void IncreaseEnumerationCount()\n {\n LoopCount++;\n }\n\n public void Dispose()\n {\n }\n\n public bool MoveNext()\n {\n index++;\n return index < values.Length;\n }\n\n public void Reset()\n {\n index = -1;\n }\n\n public KeyValuePair Current\n {\n get { return values[index]; }\n }\n\n object IEnumerator.Current\n {\n get { return Current; }\n }\n }\n\n internal class DictionaryNotImplementingIReadOnlyDictionary : IDictionary\n {\n private readonly Dictionary dictionary = [];\n\n public TValue this[TKey key] { get => dictionary[key]; set => throw new NotImplementedException(); }\n\n public ICollection Keys => dictionary.Keys;\n\n public ICollection Values => dictionary.Values;\n\n public int Count => dictionary.Count;\n\n public bool IsReadOnly => ((ICollection>)dictionary).IsReadOnly;\n\n public void Add(TKey key, TValue value) => throw new NotImplementedException();\n\n public void Add(KeyValuePair item) => throw new NotImplementedException();\n\n public void Clear() => throw new NotImplementedException();\n\n public bool Contains(KeyValuePair item) => dictionary.Contains(item);\n\n public bool ContainsKey(TKey key) => dictionary.ContainsKey(key);\n\n public void CopyTo(KeyValuePair[] array, int arrayIndex) => throw new NotImplementedException();\n\n public IEnumerator> GetEnumerator() => dictionary.GetEnumerator();\n\n public bool Remove(TKey key) => throw new NotImplementedException();\n\n public bool Remove(KeyValuePair item) => throw new NotImplementedException();\n\n public bool TryGetValue(TKey key, out TValue value) => dictionary.TryGetValue(key, out value);\n\n IEnumerator IEnumerable.GetEnumerator() => dictionary.GetEnumerator();\n }\n\n public class MyClass\n {\n public int SomeProperty { get; set; }\n\n protected bool Equals(MyClass other)\n {\n return SomeProperty == other.SomeProperty;\n }\n\n public override bool Equals(object obj)\n {\n if (obj is null)\n {\n return false;\n }\n\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n\n if (obj.GetType() != GetType())\n {\n return false;\n }\n\n return Equals((MyClass)obj);\n }\n\n public override int GetHashCode()\n {\n return SomeProperty;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringWildcardMatchingStrategy.cs", "using System;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringWildcardMatchingStrategy : IStringComparisonStrategy\n{\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n bool isMatch = IsMatch(subject, expected);\n\n if (isMatch != Negate)\n {\n return;\n }\n\n if (Negate)\n {\n assertionChain.FailWith($\"{ExpectationDescription}but {{1}} matches.\", expected, subject);\n }\n else\n {\n assertionChain.FailWith($\"{ExpectationDescription}but {{1}} does not.\", expected, subject);\n }\n }\n\n private bool IsMatch(string subject, string expected)\n {\n RegexOptions options = IgnoreCase\n ? RegexOptions.IgnoreCase | RegexOptions.CultureInvariant\n : RegexOptions.None;\n\n string input = CleanNewLines(subject);\n string pattern = ConvertWildcardToRegEx(CleanNewLines(expected));\n\n return Regex.IsMatch(input, pattern, options | RegexOptions.Singleline);\n }\n\n private static string ConvertWildcardToRegEx(string wildcardExpression)\n {\n return \"^\"\n + Regex.Escape(wildcardExpression)\n .Replace(\"\\\\*\", \".*\", StringComparison.Ordinal)\n .Replace(\"\\\\?\", \".\", StringComparison.Ordinal)\n + \"$\";\n }\n\n private string CleanNewLines(string input)\n {\n if (IgnoreAllNewlines)\n {\n return input.RemoveNewLines();\n }\n\n if (IgnoreNewlineStyle)\n {\n return input.RemoveNewlineStyle();\n }\n\n return input;\n }\n\n public string ExpectationDescription\n {\n get\n {\n var builder = new StringBuilder();\n\n builder\n .Append(Negate ? \"Did not expect \" : \"Expected \")\n .Append(\"{context:string}\")\n .Append(IgnoreCase ? \" to match the equivalent of\" : \" to match\")\n .Append(\" {0}{reason}, \");\n\n return builder.ToString();\n }\n }\n\n /// \n /// Gets or sets a value indicating whether the subject should not match the pattern.\n /// \n public bool Negate { get; init; }\n\n /// \n /// Gets or sets a value indicating whether the matching process should ignore any casing difference.\n /// \n public bool IgnoreCase { get; init; }\n\n /// \n /// Ignores all newline differences\n /// \n public bool IgnoreAllNewlines { get; init; }\n\n /// \n /// Ignores the difference between environment newline differences\n /// \n public bool IgnoreNewlineStyle { get; init; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TimeSpanValueFormatter.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class TimeSpanValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is TimeSpan;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var timeSpan = (TimeSpan)value;\n\n if (timeSpan == TimeSpan.MinValue)\n {\n formattedGraph.AddFragment(\"min time span\");\n return;\n }\n\n if (timeSpan == TimeSpan.MaxValue)\n {\n formattedGraph.AddFragment(\"max time span\");\n return;\n }\n\n List fragments = GetNonZeroFragments(timeSpan);\n\n if (fragments.Count == 0)\n {\n formattedGraph.AddFragment(\"default\");\n }\n\n string sign = timeSpan.Ticks >= 0 ? string.Empty : \"-\";\n\n if (fragments.Count == 1)\n {\n formattedGraph.AddFragment(sign + fragments.Single());\n }\n else\n {\n formattedGraph.AddFragment(sign + fragments.JoinUsingWritingStyle());\n }\n }\n\n private static List GetNonZeroFragments(TimeSpan timeSpan)\n {\n TimeSpan absoluteTimespan = timeSpan.Duration();\n\n var fragments = new List();\n\n AddDaysIfNotZero(absoluteTimespan, fragments);\n AddHoursIfNotZero(absoluteTimespan, fragments);\n AddMinutesIfNotZero(absoluteTimespan, fragments);\n AddSecondsIfNotZero(absoluteTimespan, fragments);\n AddMilliSecondsIfNotZero(absoluteTimespan, fragments);\n AddMicrosecondsIfNotZero(absoluteTimespan, fragments);\n\n return fragments;\n }\n\n private static void AddMicrosecondsIfNotZero(TimeSpan timeSpan, List fragments)\n {\n var ticks = timeSpan.Ticks % TimeSpan.TicksPerMillisecond;\n\n if (ticks > 0)\n {\n var microSeconds = ticks * (1000.0 / TimeSpan.TicksPerMillisecond);\n fragments.Add(microSeconds.ToString(\"0.0\", CultureInfo.InvariantCulture) + \"µs\");\n }\n }\n\n private static void AddSecondsIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Seconds > 0)\n {\n string result = timeSpan.Seconds.ToString(CultureInfo.InvariantCulture);\n\n fragments.Add(result + \"s\");\n }\n }\n\n private static void AddMilliSecondsIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Milliseconds > 0)\n {\n var result = timeSpan.Milliseconds.ToString(CultureInfo.InvariantCulture);\n\n fragments.Add(result + \"ms\");\n }\n }\n\n private static void AddMinutesIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Minutes > 0)\n {\n fragments.Add(timeSpan.Minutes.ToString(CultureInfo.InvariantCulture) + \"m\");\n }\n }\n\n private static void AddHoursIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Hours > 0)\n {\n fragments.Add(timeSpan.Hours.ToString(CultureInfo.InvariantCulture) + \"h\");\n }\n }\n\n private static void AddDaysIfNotZero(TimeSpan timeSpan, List fragments)\n {\n if (timeSpan.Days > 0)\n {\n fragments.Add(timeSpan.Days.ToString(CultureInfo.InvariantCulture) + \"d\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/GuidValueFormatter.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class GuidValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is Guid;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment($\"{{{value}}}\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ExceptionValueFormatter.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class ExceptionValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is Exception;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((Exception)value).ToString());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/NullValueFormatter.cs", "namespace AwesomeAssertions.Formatting;\n\npublic class NullValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is null;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(\"\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Xml/XmlElementAssertions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Xml;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Xml;\n\n/// \n/// Contains a number of methods to assert that an \n/// is in the expected state./>\n/// \n[DebuggerNonUserCode]\npublic class XmlElementAssertions : XmlNodeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// \n public XmlElementAssertions(XmlElement xmlElement, AssertionChain assertionChain)\n : base(xmlElement, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that the current has the specified\n /// inner text.\n /// \n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveInnerText(string expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.InnerText == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have value {0}{reason}, but found {1}.\",\n expected, Subject.InnerText);\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has an attribute\n /// with the specified \n /// and .\n /// \n /// The name of the expected attribute\n /// The value of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveAttribute(string expectedName, string expectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveAttributeWithNamespace(expectedName, string.Empty, expectedValue, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has an attribute\n /// with the specified , \n /// and .\n /// \n /// The name of the expected attribute\n /// The namespace of the expected attribute\n /// The value of the expected attribute\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveAttributeWithNamespace(\n string expectedName,\n string expectedNamespace,\n string expectedValue,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n XmlAttribute attribute = Subject.Attributes[expectedName, expectedNamespace];\n\n string expectedFormattedName =\n (string.IsNullOrEmpty(expectedNamespace) ? string.Empty : $\"{{{expectedNamespace}}}\")\n + expectedName;\n\n assertionChain\n .ForCondition(attribute is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have attribute {0}\"\n + \" with value {1}{reason}, but found no such attribute in {2}\",\n expectedFormattedName, expectedValue, Subject);\n\n if (assertionChain.Succeeded)\n {\n assertionChain\n .ForCondition(attribute!.Value == expectedValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected attribute {0} in {context:subject} to have value {1}{reason}, but found {2}.\",\n expectedFormattedName, expectedValue, attribute.Value);\n }\n\n return new AndConstraint(this);\n }\n\n /// \n /// Asserts that the current has a direct child element with the specified\n /// name, ignoring the namespace.\n /// \n /// The name of the expected child element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElement(\n string expectedName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveElementWithNamespace(expectedName, null, because, becauseArgs);\n }\n\n /// \n /// Asserts that the current has a direct child element with the specified\n /// name and namespace.\n /// \n /// The name of the expected child element\n /// The namespace of the expected child element\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveElementWithNamespace(\n string expectedName,\n string expectedNamespace,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n XmlElement element = expectedNamespace == null ? Subject[expectedName] : Subject[expectedName, expectedNamespace];\n\n string expectedFormattedName =\n (string.IsNullOrEmpty(expectedNamespace) ? string.Empty : $\"{{{expectedNamespace}}}\")\n + expectedName;\n\n assertionChain\n .ForCondition(element is not null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:subject} to have child element {0}{reason}, but no such child element was found.\",\n expectedFormattedName.EscapePlaceholders());\n\n return new AndWhichConstraint(this, element, assertionChain, \"/\" + expectedName);\n }\n\n protected override string Identifier => \"XML element\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/XAttributeValueFormatter.cs", "using System.Xml.Linq;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class XAttributeValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is XAttribute;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((XAttribute)value).ToString());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/Int32ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class Int32ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is int;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((int)value).ToString(CultureInfo.InvariantCulture));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DecimalValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DecimalValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is decimal;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((decimal)value).ToString(CultureInfo.InvariantCulture) + \"M\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/Int64ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class Int64ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is long;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((long)value).ToString(CultureInfo.InvariantCulture) + \"L\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/Int16ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class Int16ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is short;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((short)value).ToString(CultureInfo.InvariantCulture) + \"s\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/UInt64ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class UInt64ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is ulong;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((ulong)value).ToString(CultureInfo.InvariantCulture) + \"UL\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/UInt32ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class UInt32ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is uint;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((uint)value).ToString(CultureInfo.InvariantCulture) + \"u\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/UInt16ValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class UInt16ValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is ushort;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((ushort)value).ToString(CultureInfo.InvariantCulture) + \"us\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/SByteValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class SByteValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is sbyte;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(((sbyte)value).ToString(CultureInfo.InvariantCulture) + \"y\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ByteValueFormatter.cs", "using System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class ByteValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is byte;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n formattedGraph.AddFragment(\"0x\" + ((byte)value).ToString(\"X2\", CultureInfo.InvariantCulture));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/DateOnlyValueFormatter.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class DateOnlyValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is DateOnly;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var dateOnly = (DateOnly)value;\n formattedGraph.AddFragment(dateOnly.ToString(\"\", CultureInfo.InvariantCulture));\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TimeOnlyValueFormatter.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class TimeOnlyValueFormatter : IValueFormatter\n{\n /// \n /// Indicates whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n public bool CanHandle(object value)\n {\n return value is TimeOnly;\n }\n\n public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild)\n {\n var timeOnly = (TimeOnly)value;\n formattedGraph.AddFragment(timeOnly.ToString(\"\", CultureInfo.InvariantCulture));\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/MaximumMatchingSolver.cs", "using System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// The class encapsulates the algorithm\n/// for solving the maximum matching problem (see ).\n/// See https://en.wikipedia.org/wiki/Maximum_cardinality_matching for more details.
\n/// A simplified variation of the Ford-Fulkerson algorithm is used for solving the problem.\n/// See https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm for more details.\n///
\ninternal class MaximumMatchingSolver\n{\n private readonly MaximumMatchingProblem problem;\n private readonly Dictionary, List>> matchingElementsByPredicate = [];\n\n public MaximumMatchingSolver(MaximumMatchingProblem problem)\n {\n this.problem = problem;\n }\n\n /// \n /// Solves the maximum matching problem;\n /// \n public MaximumMatchingSolution Solve()\n {\n var matches = new MatchCollection();\n\n foreach (var predicate in problem.Predicates)\n {\n // At each step of the algorithm we search for a solution which contains the current predicate\n // and increases the total number of matches (i.e. Augmenting Flow through the current predicate in the Ford-Fulkerson terminology).\n var newMatches = FindMatchForPredicate(predicate, matches);\n matches.UpdateFrom(newMatches);\n }\n\n var elementsByMatchedPredicate = matches.ToDictionary(match => match.Predicate, match => match.Element);\n\n return new MaximumMatchingSolution(problem, elementsByMatchedPredicate);\n }\n\n /// \n /// To find a solution which contains the specified predicate and increases the total number of matches\n /// we:
\n /// - Search for a free element which matches the specified predicate.
\n /// - Or take over an element which was previously matched with another predicate and repeat the procedure for the previously matched predicate.
\n /// - We are basically searching for a path in the graph of matches between predicates and elements which would start at the specified predicate\n /// and end at an unmatched element.
\n /// - Breadth first search used to traverse the graph.
\n ///
\n private IEnumerable FindMatchForPredicate(Predicate predicate, MatchCollection currentMatches)\n {\n var visitedElements = new HashSet>();\n var breadthFirstSearchTracker = new BreadthFirstSearchTracker(predicate, currentMatches);\n\n while (breadthFirstSearchTracker.TryDequeueUnMatchedPredicate(out var unmatchedPredicate))\n {\n var notVisitedMatchingElements =\n GetMatchingElements(unmatchedPredicate).Where(element => !visitedElements.Contains(element));\n\n foreach (var element in notVisitedMatchingElements)\n {\n visitedElements.Add(element);\n\n if (currentMatches.Contains(element))\n {\n breadthFirstSearchTracker.ReassignElement(element, unmatchedPredicate);\n }\n else\n {\n var finalMatch = new Match { Predicate = unmatchedPredicate, Element = element };\n return breadthFirstSearchTracker.GetMatchChain(finalMatch);\n }\n }\n }\n\n return [];\n }\n\n private List> GetMatchingElements(Predicate predicate)\n {\n if (!matchingElementsByPredicate.TryGetValue(predicate, out var matchingElements))\n {\n matchingElements = problem.Elements.Where(element => predicate.Matches(element.Value)).ToList();\n matchingElementsByPredicate.Add(predicate, matchingElements);\n }\n\n return matchingElements;\n }\n\n private struct Match\n {\n public Predicate Predicate;\n public Element Element;\n }\n\n private sealed class MatchCollection : IEnumerable\n {\n private readonly Dictionary, Match> matchesByElement = [];\n\n public void UpdateFrom(IEnumerable matches)\n {\n foreach (var match in matches)\n {\n matchesByElement[match.Element] = match;\n }\n }\n\n public Predicate GetMatchedPredicate(Element element)\n {\n return matchesByElement[element].Predicate;\n }\n\n public bool Contains(Element element) => matchesByElement.ContainsKey(element);\n\n public IEnumerator GetEnumerator() => matchesByElement.Values.GetEnumerator();\n\n IEnumerator IEnumerable.GetEnumerator() => matchesByElement.Values.GetEnumerator();\n }\n\n private sealed class BreadthFirstSearchTracker\n {\n private readonly Queue> unmatchedPredicatesQueue = new();\n private readonly Dictionary, Match> previousMatchByPredicate = [];\n\n private readonly MatchCollection originalMatches;\n\n public BreadthFirstSearchTracker(Predicate unmatchedPredicate, MatchCollection originalMatches)\n {\n unmatchedPredicatesQueue.Enqueue(unmatchedPredicate);\n\n this.originalMatches = originalMatches;\n }\n\n public bool TryDequeueUnMatchedPredicate(out Predicate unmatchedPredicate)\n {\n if (unmatchedPredicatesQueue.Count == 0)\n {\n unmatchedPredicate = null;\n return false;\n }\n\n unmatchedPredicate = unmatchedPredicatesQueue.Dequeue();\n return true;\n }\n\n public void ReassignElement(Element element, Predicate newMatchedPredicate)\n {\n var previouslyMatchedPredicate = originalMatches.GetMatchedPredicate(element);\n\n previousMatchByPredicate.Add(previouslyMatchedPredicate,\n new Match { Predicate = newMatchedPredicate, Element = element });\n\n unmatchedPredicatesQueue.Enqueue(previouslyMatchedPredicate);\n }\n\n public IEnumerable GetMatchChain(Match lastMatch)\n {\n var match = lastMatch;\n\n do\n {\n yield return match;\n }\n while (previousMatchByPredicate.TryGetValue(match.Predicate, out match));\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AsyncAssertionsExtensions.cs", "using System.Diagnostics.CodeAnalysis;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Specialized;\n\nnamespace AwesomeAssertions;\n\npublic static class AsyncAssertionsExtensions\n{\n#pragma warning disable AV1755 // \"Name of async method ... should end with Async\"; Async suffix is too noisy in fluent API\n /// \n /// Asserts that the completed provides the specified result.\n /// \n /// The containing the .\n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Please note that this assertion cannot identify whether the previous assertion was successful or not.\n /// In case it was not successful and it is running within an active \n /// there is no current result to compare with.\n /// So, this extension will compare with the default value.\n /// \n public static async Task, T>> WithResult(\n this Task, T>> task,\n T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var andWhichConstraint = await task;\n var subject = andWhichConstraint.Subject;\n subject.Should().Be(expected, because, becauseArgs);\n\n return andWhichConstraint;\n }\n\n /// \n /// Asserts that the completed provides the specified result.\n /// \n /// The containing the .\n /// The expected value.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task, T>> WithResult(\n this Task, T>> task,\n T expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n var andWhichConstraint = await task;\n var subject = andWhichConstraint.Subject;\n subject.Should().Be(expected, because, becauseArgs);\n\n return andWhichConstraint;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableBooleanAssertions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableBooleanAssertions : NullableBooleanAssertions\n{\n public NullableBooleanAssertions(bool? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableBooleanAssertions : BooleanAssertions\n where TAssertions : NullableBooleanAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableBooleanAssertions(bool? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable boolean value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected a value{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable boolean value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable boolean value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable boolean value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that the value is equal to the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(bool? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is not equal to the specified value.\n /// \n /// The unexpected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBe(bool? unexpected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject != unexpected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable boolean} not to be {0}{reason}, but found {1}.\", unexpected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeFalse([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not false)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable boolean} not to be {0}{reason}, but found {1}.\", false, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that the value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeTrue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject is not true)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable boolean} not to be {0}{reason}, but found {1}.\", true, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/MethodInfoExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class MethodInfoExtensions\n{\n /// \n /// A sum of all possible . It's needed to calculate what options were used when decorating with .\n /// They are a subset of which can be checked on a type and therefore this mask has to be applied to check only for options.\n /// \n private static readonly Lazy ImplementationOptionsMask =\n new(() => Enum.GetValues(typeof(MethodImplOptions)).Cast().Sum(x => x));\n\n internal static bool IsAsync(this MethodInfo methodInfo)\n {\n return methodInfo.IsDecoratedWith();\n }\n\n internal static IEnumerable GetMatchingAttributes(this MemberInfo memberInfo,\n Expression> isMatchingAttributePredicate)\n where TAttribute : Attribute\n {\n var customAttributes = memberInfo.GetCustomAttributes(inherit: false).ToList();\n\n if (typeof(TAttribute) == typeof(MethodImplAttribute) && memberInfo is MethodBase methodBase)\n {\n (bool success, MethodImplAttribute methodImplAttribute) = RecreateMethodImplAttribute(methodBase);\n if (success)\n {\n customAttributes.Add(methodImplAttribute as TAttribute);\n }\n }\n\n return customAttributes\n .Where(isMatchingAttributePredicate.Compile());\n }\n\n internal static bool IsNonVirtual(this MethodInfo method)\n {\n return !method.IsVirtual || method.IsFinal;\n }\n\n private static (bool success, MethodImplAttribute attribute) RecreateMethodImplAttribute(MethodBase methodBase)\n {\n MethodImplAttributes implementationFlags = methodBase.MethodImplementationFlags;\n\n int implementationFlagsMatchingImplementationOptions =\n (int)implementationFlags & ImplementationOptionsMask.Value;\n\n MethodImplOptions implementationOptions = (MethodImplOptions)implementationFlagsMatchingImplementationOptions;\n\n if (implementationOptions != default)\n {\n return (true, new MethodImplAttribute(implementationOptions));\n }\n\n return (false, null);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/ExtensibilitySpecs.cs", "using System;\nusing AwesomeAssertions.Primitives;\nusing ExampleExtensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class ExtensibilitySpecs\n{\n [Fact]\n public void Methods_marked_as_custom_assertion_are_ignored_during_caller_identification()\n {\n // Arrange\n var myClient = new MyCustomer\n {\n Active = false\n };\n\n // Act\n Action act = () => myClient.Should().BeActive(\"because we don't work with old clients\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected myClient to be true because we don't work with old clients, but found False.\");\n }\n\n [Fact]\n public void Methods_in_assemblies_marked_as_custom_assertion_are_ignored_during_caller_identification()\n {\n // Arrange\n string palindrome = \"fluent\";\n\n // Act\n Action act = () => palindrome.Should().BePalindromic();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected palindrome to be*tneulf*\");\n }\n\n [Fact]\n public void Methods_and_generated_methods_in_classes_marked_as_custom_assertions_are_ignored_during_caller_identification()\n {\n string expectedSubjectName = \"any\";\n\n // Act\n Action act = () => expectedSubjectName.Should().MethodWithGeneratedDisplayClass();\n\n // Arrange\n act.Should().Throw()\n .WithMessage(\"Expected expectedSubjectName something, failure \\\"message\\\"\");\n }\n}\n\n[CustomAssertions]\npublic static class CustomAssertionExtensions\n{\n public static void MethodWithGeneratedDisplayClass(this StringAssertions assertions)\n {\n assertions.CurrentAssertionChain\n .WithExpectation(\"Expected {context:FallbackIdentifier} something\", chain =>\n chain\n .ForCondition(condition: false)\n .FailWith(\", failure {0}\", \"message\")\n );\n }\n}\n\ninternal class MyCustomer\n{\n public bool Active { get; set; }\n}\n\ninternal static class MyCustomerExtensions\n{\n public static MyCustomerAssertions Should(this MyCustomer customer)\n {\n return new MyCustomerAssertions(customer);\n }\n}\n\ninternal class MyCustomerAssertions\n{\n private readonly MyCustomer customer;\n\n public MyCustomerAssertions(MyCustomer customer)\n {\n this.customer = customer;\n }\n\n [CustomAssertion]\n public void BeActive(string because = \"\", params object[] becauseArgs)\n {\n customer.Active.Should().BeTrue(because, becauseArgs);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateTimeOffsetRangeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n\nnamespace AwesomeAssertions.Primitives;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that two objects differ in the expected way.\n/// \n/// \n/// You can use the and \n/// for a more fluent way of specifying a or a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeOffsetRangeAssertions\n where TAssertions : DateTimeOffsetAssertions\n{\n #region Private Definitions\n\n private readonly TAssertions parentAssertions;\n private readonly TimeSpanPredicate predicate;\n\n private readonly Dictionary predicates = new()\n {\n [TimeSpanCondition.MoreThan] = new TimeSpanPredicate((ts1, ts2) => ts1 > ts2, \"more than\"),\n [TimeSpanCondition.AtLeast] = new TimeSpanPredicate((ts1, ts2) => ts1 >= ts2, \"at least\"),\n [TimeSpanCondition.Exactly] = new TimeSpanPredicate((ts1, ts2) => ts1 == ts2, \"exactly\"),\n [TimeSpanCondition.Within] = new TimeSpanPredicate((ts1, ts2) => ts1 <= ts2, \"within\"),\n [TimeSpanCondition.LessThan] = new TimeSpanPredicate((ts1, ts2) => ts1 < ts2, \"less than\")\n };\n\n private readonly DateTimeOffset? subject;\n private readonly TimeSpan timeSpan;\n\n #endregion\n\n protected internal DateTimeOffsetRangeAssertions(TAssertions parentAssertions, AssertionChain assertionChain,\n DateTimeOffset? subject,\n TimeSpanCondition condition,\n TimeSpan timeSpan)\n {\n this.parentAssertions = parentAssertions;\n CurrentAssertionChain = assertionChain;\n this.subject = subject;\n this.timeSpan = timeSpan;\n\n predicate = predicates[condition];\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that a occurs a specified amount of time before another .\n /// \n /// \n /// The to compare the subject with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Before(DateTimeOffset target,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be \" + predicate.DisplayText +\n \" {0} before {1}{reason}, but found a DateTime.\", timeSpan, target);\n\n if (CurrentAssertionChain.Succeeded)\n {\n TimeSpan actual = target - subject.Value;\n\n CurrentAssertionChain\n .ForCondition(predicate.IsMatchedBy(actual, timeSpan))\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:the date and time} {0} to be \" + predicate.DisplayText +\n \" {1} before {2}{reason}, but it is \" + PositionRelativeToTarget(subject.Value, target) + \" by {3}.\",\n subject, timeSpan, target, actual.Duration());\n }\n\n return new AndConstraint(parentAssertions);\n }\n\n /// \n /// Asserts that a occurs a specified amount of time after another .\n /// \n /// \n /// The to compare the subject with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint After(DateTimeOffset target,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:the date and time} to be \" + predicate.DisplayText +\n \" {0} after {1}{reason}, but found a DateTime.\", timeSpan, target);\n\n if (CurrentAssertionChain.Succeeded)\n {\n TimeSpan actual = subject.Value - target;\n\n CurrentAssertionChain\n .ForCondition(predicate.IsMatchedBy(actual, timeSpan))\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:the date and time} {0} to be \" + predicate.DisplayText +\n \" {1} after {2}{reason}, but it is \" + PositionRelativeToTarget(subject.Value, target) + \" by {3}.\",\n subject, timeSpan, target, actual.Duration());\n }\n\n return new AndConstraint(parentAssertions);\n }\n\n private static string PositionRelativeToTarget(DateTimeOffset actual, DateTimeOffset target)\n {\n return (actual - target) >= TimeSpan.Zero ? \"ahead\" : \"behind\";\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Before() or After() instead?\");\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/FormattingOptionsSpecs.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\n[Collection(\"ConfigurationSpecs\")]\npublic sealed class FormattingOptionsSpecs : IDisposable\n{\n [Fact]\n public void When_global_formatting_settings_are_modified()\n {\n AssertionConfiguration.Current.Formatting.UseLineBreaks = true;\n AssertionConfiguration.Current.Formatting.MaxDepth = 123;\n AssertionConfiguration.Current.Formatting.MaxLines = 33;\n AssertionConfiguration.Current.Formatting.StringPrintLength = 321;\n\n AssertionScope.Current.FormattingOptions.UseLineBreaks.Should().BeTrue();\n AssertionScope.Current.FormattingOptions.MaxDepth.Should().Be(123);\n AssertionScope.Current.FormattingOptions.MaxLines.Should().Be(33);\n AssertionScope.Current.FormattingOptions.StringPrintLength.Should().Be(321);\n }\n\n [Fact]\n public void When_a_custom_formatter_exists_in_any_loaded_assembly_it_should_override_the_default_formatters()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Scan;\n\n var subject = new SomeClassWithCustomFormatter\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(\"Property = SomeValue\", \"it should use my custom formatter\");\n }\n\n [Fact]\n public void When_a_base_class_has_a_custom_formatter_it_should_override_the_default_formatters()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Scan;\n\n var subject = new SomeClassInheritedFromClassWithCustomFormatterLvl1\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(\"Property = SomeValue\", \"it should use my custom formatter\");\n }\n\n [Fact]\n public void When_there_are_multiple_custom_formatters_it_should_select_a_more_specific_one()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Scan;\n\n var subject = new SomeClassInheritedFromClassWithCustomFormatterLvl2\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(\"Property is SomeValue\", \"it should use my custom formatter\");\n }\n\n [Fact]\n public void When_a_base_class_has_multiple_custom_formatters_it_should_work_the_same_as_for_the_base_class()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Scan;\n\n var subject = new SomeClassInheritedFromClassWithCustomFormatterLvl3\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(\"Property is SomeValue\", \"it should use my custom formatter\");\n }\n\n [Fact]\n public void When_no_custom_formatter_exists_in_the_specified_assembly_it_should_use_the_default()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterAssembly = \"AwesomeAssertions\";\n\n var subject = new SomeClassWithCustomFormatter\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(subject.ToString());\n }\n\n [Fact]\n public void When_formatter_scanning_is_disabled_it_should_use_the_default_formatters()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Disabled;\n\n var subject = new SomeClassWithCustomFormatter\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(subject.ToString());\n }\n\n [Fact]\n public void When_no_formatter_scanning_is_configured_it_should_use_the_default_formatters()\n {\n // Arrange\n AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Disabled;\n\n var subject = new SomeClassWithCustomFormatter\n {\n Property = \"SomeValue\"\n };\n\n // Act\n string result = Formatter.ToString(subject);\n\n // Assert\n result.Should().Be(subject.ToString());\n }\n\n public class SomeClassWithCustomFormatter\n {\n public string Property { get; set; }\n\n public override string ToString()\n {\n return \"The value of my property is \" + Property;\n }\n }\n\n public class SomeOtherClassWithCustomFormatter\n {\n [UsedImplicitly]\n public string Property { get; set; }\n\n public override string ToString()\n {\n return \"The value of my property is \" + Property;\n }\n }\n\n public class SomeClassInheritedFromClassWithCustomFormatterLvl1 : SomeClassWithCustomFormatter;\n\n public class SomeClassInheritedFromClassWithCustomFormatterLvl2 : SomeClassInheritedFromClassWithCustomFormatterLvl1;\n\n public class SomeClassInheritedFromClassWithCustomFormatterLvl3 : SomeClassInheritedFromClassWithCustomFormatterLvl2;\n\n public static class CustomFormatter\n {\n [ValueFormatter]\n public static int Bar(SomeClassWithCustomFormatter _)\n {\n return -1;\n }\n\n [ValueFormatter]\n public static void Foo(SomeClassWithCustomFormatter value, FormattedObjectGraph output)\n {\n output.AddFragment(\"Property = \" + value.Property);\n }\n\n [ValueFormatter]\n [SuppressMessage(\"ReSharper\", \"CA1801\")]\n public static void Foo(SomeOtherClassWithCustomFormatter _, FormattedObjectGraph output)\n {\n throw new XunitException(\"Should never be called\");\n }\n\n [ValueFormatter]\n public static void Foo(SomeClassInheritedFromClassWithCustomFormatterLvl2 value, FormattedObjectGraph output)\n {\n output.AddFragment(\"Property is \" + value.Property);\n }\n\n [ValueFormatter]\n public static void Foo2(SomeClassInheritedFromClassWithCustomFormatterLvl2 value, FormattedObjectGraph output)\n {\n output.AddFragment(\"Property is \" + value.Property);\n }\n }\n\n public void Dispose()\n {\n AssertionEngine.ResetToDefaults();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// Collection assertion specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class Chaining\n {\n [Fact]\n public void Chaining_something_should_do_something()\n {\n // Arrange\n var languages = new[] { \"C#\" };\n\n // Act\n var act = () => languages.Should().ContainSingle()\n .Which.Should().EndWith(\"script\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected languages[0]*\");\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should()\n .HaveCount(3)\n .And\n .HaveElementAt(1, 2)\n .And\n .NotContain(4);\n }\n\n [Fact]\n public void When_the_collection_is_ordered_according_to_the_subsequent_ascending_assertion_it_should_succeed()\n {\n // Arrange\n (int, string)[] collection =\n [\n (1, \"a\"),\n (2, \"b\"),\n (2, \"c\"),\n (3, \"a\")\n ];\n\n // Act / Assert\n collection.Should()\n .BeInAscendingOrder(x => x.Item1)\n .And\n .ThenBeInAscendingOrder(x => x.Item2);\n }\n\n [Fact]\n public void When_the_collection_is_not_ordered_according_to_the_subsequent_ascending_assertion_it_should_fail()\n {\n // Arrange\n (int, string)[] collection =\n [\n (1, \"a\"),\n (2, \"b\"),\n (2, \"c\"),\n (3, \"a\")\n ];\n\n // Act\n Action action = () => collection.Should()\n .BeInAscendingOrder(x => x.Item1)\n .And\n .BeInAscendingOrder(x => x.Item2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection*to be ordered \\\"by Item2\\\"*\");\n }\n\n [Fact]\n public void\n When_the_collection_is_ordered_according_to_the_subsequent_ascending_assertion_with_comparer_it_should_succeed()\n {\n // Arrange\n (int, string)[] collection =\n [\n (1, \"a\"),\n (2, \"B\"),\n (2, \"b\"),\n (3, \"a\")\n ];\n\n // Act / Assert\n collection.Should()\n .BeInAscendingOrder(x => x.Item1)\n .And\n .ThenBeInAscendingOrder(x => x.Item2, StringComparer.InvariantCultureIgnoreCase);\n }\n\n [Fact]\n public void When_the_collection_is_ordered_according_to_the_multiple_subsequent_ascending_assertions_it_should_succeed()\n {\n // Arrange\n (int, string, double)[] collection =\n [\n (1, \"a\", 1.1),\n (2, \"b\", 1.2),\n (2, \"c\", 1.3),\n (3, \"a\", 1.1)\n ];\n\n // Act / Assert\n collection.Should()\n .BeInAscendingOrder(x => x.Item1)\n .And\n .ThenBeInAscendingOrder(x => x.Item2)\n .And\n .ThenBeInAscendingOrder(x => x.Item3);\n }\n\n [Fact]\n public void When_the_collection_is_ordered_according_to_the_subsequent_descending_assertion_it_should_succeed()\n {\n // Arrange\n (int, string)[] collection =\n [\n (3, \"a\"),\n (2, \"c\"),\n (2, \"b\"),\n (1, \"a\")\n ];\n\n // Act / Assert\n collection.Should()\n .BeInDescendingOrder(x => x.Item1)\n .And\n .ThenBeInDescendingOrder(x => x.Item2);\n }\n\n [Fact]\n public void When_the_collection_is_not_ordered_according_to_the_subsequent_descending_assertion_it_should_fail()\n {\n // Arrange\n (int, string)[] collection =\n [\n (3, \"a\"),\n (2, \"c\"),\n (2, \"b\"),\n (1, \"a\")\n ];\n\n // Act\n Action action = () => collection.Should()\n .BeInDescendingOrder(x => x.Item1)\n .And\n .BeInDescendingOrder(x => x.Item2);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection*to be ordered \\\"by Item2\\\"*\");\n }\n\n [Fact]\n public void\n When_the_collection_is_ordered_according_to_the_subsequent_descending_assertion_with_comparer_it_should_succeed()\n {\n // Arrange\n (int, string)[] collection =\n [\n (3, \"a\"),\n (2, \"b\"),\n (2, \"B\"),\n (1, \"a\")\n ];\n\n // Act / Assert\n collection.Should()\n .BeInDescendingOrder(x => x.Item1)\n .And\n .ThenBeInDescendingOrder(x => x.Item2, StringComparer.InvariantCultureIgnoreCase);\n }\n\n [Fact]\n public void When_the_collection_is_ordered_according_to_the_multiple_subsequent_descending_assertions_it_should_succeed()\n {\n // Arrange\n (int, string, double)[] collection =\n [\n (3, \"a\", 1.1),\n (2, \"c\", 1.3),\n (2, \"b\", 1.2),\n (1, \"a\", 1.1)\n ];\n\n // Act / Assert\n collection.Should()\n .BeInDescendingOrder(x => x.Item1)\n .And\n .ThenBeInDescendingOrder(x => x.Item2)\n .And\n .ThenBeInDescendingOrder(x => x.Item3);\n }\n\n [Fact]\n public void When_asserting_ordering_by_property_of_a_null_collection_failed_inside_a_scope_then_a_subsequent_assertion_is_not_evaluated()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n collection.Should().BeInAscendingOrder(o => o.Text)\n .And.NotBeEmpty(\"this won't be asserted\");\n }\n };\n\n // AssertText but found .\n act.Should().Throw()\n .WithMessage(\"*Text*found*.\");\n }\n\n [Fact]\n public void When_asserting_ordering_with_given_comparer_of_a_null_collection_failed_inside_a_scope_then_a_subsequent_assertion_is_not_evaluated()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n collection.Should().BeInAscendingOrder(Comparer.Default)\n .And.NotBeEmpty(\"this won't be asserted\");\n }\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*found*.\");\n }\n\n [Fact]\n public void When_asserting_ordering_of_an_unordered_collection_failed_inside_a_scope_then_a_subsequent_assertion_is_not_evaluated()\n {\n // Arrange\n int[] collection = [1, 27, 12];\n\n // Act\n Action action = () =>\n {\n using (new AssertionScope())\n {\n collection.Should().BeInAscendingOrder(\"because numbers are ordered\")\n .And.BeEmpty(\"this won't be asserted\");\n }\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*item at index 1 is in wrong order.\");\n }\n }\n\n private class ByLastCharacterComparer : IComparer\n {\n public int Compare(string x, string y)\n {\n return Nullable.Compare(x?[^1], y?[^1]);\n }\n }\n}\n\ninternal class CountingGenericEnumerable : IEnumerable\n{\n private readonly IEnumerable backingSet;\n\n public CountingGenericEnumerable(IEnumerable backingSet)\n {\n this.backingSet = backingSet;\n GetEnumeratorCallCount = 0;\n }\n\n public int GetEnumeratorCallCount { get; private set; }\n\n public IEnumerator GetEnumerator()\n {\n GetEnumeratorCallCount++;\n return backingSet.GetEnumerator();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n}\n\ninternal class CountingGenericCollection : ICollection\n{\n private readonly ICollection backingSet;\n\n public CountingGenericCollection(ICollection backingSet)\n {\n this.backingSet = backingSet;\n }\n\n public int GetEnumeratorCallCount { get; private set; }\n\n public IEnumerator GetEnumerator()\n {\n GetEnumeratorCallCount++;\n return backingSet.GetEnumerator();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public void Add(TElement item) { throw new NotImplementedException(); }\n\n public void Clear() { throw new NotImplementedException(); }\n\n public bool Contains(TElement item) { throw new NotImplementedException(); }\n\n public void CopyTo(TElement[] array, int arrayIndex) { throw new NotImplementedException(); }\n\n public bool Remove(TElement item) { throw new NotImplementedException(); }\n\n public int GetCountCallCount { get; private set; }\n\n public int Count\n {\n get\n {\n GetCountCallCount++;\n return backingSet.Count;\n }\n }\n\n public bool IsReadOnly { get; private set; }\n}\n\ninternal sealed class TrackingTestEnumerable : IEnumerable\n{\n public TrackingTestEnumerable(params int[] values)\n {\n Enumerator = new TrackingEnumerator(values);\n }\n\n public TrackingEnumerator Enumerator { get; }\n\n public IEnumerator GetEnumerator()\n {\n Enumerator.IncreaseEnumerationCount();\n Enumerator.Reset();\n return Enumerator;\n }\n\n IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n}\n\ninternal sealed class TrackingEnumerator : IEnumerator\n{\n private readonly int[] values;\n private int index;\n\n public TrackingEnumerator(int[] values)\n {\n index = -1;\n\n this.values = values;\n }\n\n public int LoopCount { get; private set; }\n\n public void IncreaseEnumerationCount()\n {\n LoopCount++;\n }\n\n public bool MoveNext()\n {\n index++;\n return index < values.Length;\n }\n\n public void Reset()\n {\n index = -1;\n }\n\n public void Dispose() { }\n\n object IEnumerator.Current => Current;\n\n public int Current => values[index];\n}\n\ninternal class OneTimeEnumerable : IEnumerable\n{\n private readonly T[] items;\n private int enumerations;\n\n public OneTimeEnumerable(params T[] items) => this.items = items;\n\n IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n\n public IEnumerator GetEnumerator()\n {\n if (enumerations++ > 0)\n {\n throw new InvalidOperationException(\"OneTimeEnumerable can be enumerated one time only\");\n }\n\n return items.AsEnumerable().GetEnumerator();\n }\n}\n\ninternal class SomeClass\n{\n public string Text { get; set; }\n\n public int Number { get; set; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/TypeEnumerableExtensionsSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing TypeEnumerableExtensionsSpecs.BaseNamespace;\nusing TypeEnumerableExtensionsSpecs.BaseNamespace.Nested;\nusing TypeEnumerableExtensionsSpecs.Internal;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs\n{\n public class TypeEnumerableExtensionsSpecs\n {\n [Fact]\n public void When_selecting_types_that_decorated_with_attribute_it_should_return_the_correct_type()\n {\n Type[] types =\n [\n typeof(JustAClass), typeof(ClassWithSomeAttribute), typeof(ClassDerivedFromClassWithSomeAttribute)\n ];\n\n types.ThatAreDecoratedWith()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(ClassWithSomeAttribute));\n }\n\n [Fact]\n public void When_selecting_types_that_decorated_with_attribute_or_inherit_it_should_return_the_correct_type()\n {\n Type[] types =\n [\n typeof(JustAClass), typeof(ClassWithSomeAttribute), typeof(ClassDerivedFromClassWithSomeAttribute)\n ];\n\n types.ThatAreDecoratedWithOrInherit()\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(ClassWithSomeAttribute))\n .And.Contain(typeof(ClassDerivedFromClassWithSomeAttribute));\n }\n\n [Fact]\n public void When_selecting_types_that_not_decorated_with_attribute_it_should_return_the_correct_type()\n {\n Type[] types =\n [\n typeof(JustAClass), typeof(ClassWithSomeAttribute), typeof(ClassDerivedFromClassWithSomeAttribute)\n ];\n\n types.ThatAreNotDecoratedWith()\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(JustAClass))\n .And.Contain(typeof(ClassDerivedFromClassWithSomeAttribute));\n }\n\n [Fact]\n public void When_selecting_types_that_not_decorated_with_attribute_or_inherit_it_should_return_the_correct_type()\n {\n Type[] types =\n [\n typeof(JustAClass), typeof(ClassWithSomeAttribute), typeof(ClassDerivedFromClassWithSomeAttribute)\n ];\n\n types.ThatAreNotDecoratedWithOrInherit()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(JustAClass));\n }\n\n [Fact]\n public void When_selecting_types_in_namespace_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(BaseNamespaceClass), typeof(NestedNamespaceClass)];\n\n types.ThatAreInNamespace(typeof(BaseNamespaceClass).Namespace)\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(BaseNamespaceClass));\n }\n\n [Fact]\n public void When_selecting_types_under_namespace_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(BaseNamespaceClass), typeof(NestedNamespaceClass)];\n\n types.ThatAreUnderNamespace(typeof(BaseNamespaceClass).Namespace)\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(BaseNamespaceClass))\n .And.Contain(typeof(NestedNamespaceClass));\n }\n\n [Fact]\n public void When_selecting_derived_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(SomeBaseClass), typeof(SomeClassDerivedFromSomeBaseClass)];\n\n types.ThatDeriveFrom()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(SomeClassDerivedFromSomeBaseClass));\n }\n\n [Fact]\n public void When_selecting_types_that_implement_interface_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(ClassImplementingJustAnInterface), typeof(IJustAnInterface)];\n\n types.ThatImplement()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(ClassImplementingJustAnInterface));\n }\n\n [Fact]\n public void When_selecting_only_the_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(IJustAnInterface)];\n\n types.ThatAreClasses()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(JustAClass));\n }\n\n [Fact]\n public void When_selecting_not_a_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(IJustAnInterface)];\n\n types.ThatAreNotClasses()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(IJustAnInterface));\n }\n\n [Fact]\n public void When_selecting_static_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(AStaticClass)];\n\n types.ThatAreStatic()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(AStaticClass));\n }\n\n [Fact]\n public void When_selecting_not_a_static_classes_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(AStaticClass)];\n\n types.ThatAreNotStatic()\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(JustAClass));\n }\n\n [Fact]\n public void When_selecting_types_with_predicate_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(JustAClass), typeof(AStaticClass)];\n\n types.ThatSatisfy(t => t.IsSealed && t.IsAbstract)\n .Should()\n .ContainSingle()\n .Which.Should().Be(typeof(AStaticClass));\n }\n\n [Fact]\n public void When_unwrap_task_types_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(Task), typeof(List)];\n\n types.UnwrapTaskTypes()\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(JustAClass))\n .And.Contain(typeof(List));\n }\n\n [Fact]\n public void When_unwrap_enumerable_types_it_should_return_the_correct_type()\n {\n Type[] types = [typeof(Task), typeof(List)];\n\n types.UnwrapEnumerableTypes()\n .Should()\n .HaveCount(2)\n .And.Contain(typeof(Task))\n .And.Contain(typeof(IJustAnInterface));\n }\n }\n}\n\n#region Internal classes used in unit tests\n\nnamespace TypeEnumerableExtensionsSpecs.BaseNamespace\n{\n internal class BaseNamespaceClass;\n}\n\nnamespace TypeEnumerableExtensionsSpecs.BaseNamespace.Nested\n{\n internal class NestedNamespaceClass;\n}\n\nnamespace TypeEnumerableExtensionsSpecs.Internal\n{\n internal interface IJustAnInterface;\n\n internal class JustAClass;\n\n internal static class AStaticClass;\n\n internal class SomeBaseClass;\n\n internal class SomeClassDerivedFromSomeBaseClass : SomeBaseClass;\n\n internal class ClassImplementingJustAnInterface : IJustAnInterface;\n\n [Some]\n internal class ClassWithSomeAttribute;\n\n internal class ClassDerivedFromClassWithSomeAttribute : ClassWithSomeAttribute;\n\n [AttributeUsage(AttributeTargets.Class)]\n internal class SomeAttribute : Attribute;\n}\n\n#endregion\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/AssemblyAssertionSpecs.cs", "using System;\nusing System.Reflection;\nusing AssemblyA;\nusing AssemblyB;\nusing AwesomeAssertions.Specs.Types;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class AssemblyAssertionSpecs\n{\n public class NotReference\n {\n [Fact]\n public void When_an_assembly_is_not_referenced_and_should_not_reference_is_asserted_it_should_succeed()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act / Assert\n assemblyB.Should().NotReference(assemblyA);\n }\n\n [Fact]\n public void When_an_assembly_is_not_referenced_it_should_allow_chaining()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act / Assert\n assemblyB.Should().NotReference(assemblyA)\n .And.NotBeNull();\n }\n\n [Fact]\n public void When_an_assembly_is_referenced_and_should_not_reference_is_asserted_it_should_fail()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().NotReference(assemblyB);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_is_null_not_reference_should_fail()\n {\n // Arrange\n Assembly assemblyA = null;\n Assembly assemblyB = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().NotReference(assemblyB, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected assembly not to reference assembly \\\"AssemblyB\\\" *failure message*, but assemblyA is .\");\n }\n\n [Fact]\n public void When_an_assembly_is_not_referencing_null_it_should_throw()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().NotReference(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"assembly\");\n }\n }\n\n public class Reference\n {\n [Fact]\n public void When_an_assembly_is_referenced_and_should_reference_is_asserted_it_should_succeed()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act / Assert\n assemblyA.Should().Reference(assemblyB);\n }\n\n [Fact]\n public void When_an_assembly_is_referenced_it_should_allow_chaining()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act / Assert\n assemblyA.Should().Reference(assemblyB)\n .And.NotBeNull();\n }\n\n [Fact]\n public void When_an_assembly_is_not_referenced_and_should_reference_is_asserted_it_should_fail()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n var assemblyB = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyB.Should().Reference(assemblyA);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_is_null_reference_should_fail()\n {\n // Arrange\n Assembly assemblyA = null;\n Assembly assemblyB = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().Reference(assemblyB, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected assembly to reference assembly \\\"AssemblyB\\\" *failure message*, but assemblyA is .\");\n }\n\n [Fact]\n public void When_an_assembly_is_referencing_null_it_should_throw()\n {\n // Arrange\n var assemblyA = FindAssembly.Containing();\n\n // Act\n Action act = () => assemblyA.Should().Reference(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"assembly\");\n }\n }\n\n public class DefineType\n {\n [Fact]\n public void Can_find_a_specific_type()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act / Assert\n thisAssembly\n .Should().DefineType(GetType().Namespace, typeof(WellKnownClassWithAttribute).Name)\n .Which.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void Can_continue_assertions_on_the_found_type()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act\n Action act = () => thisAssembly\n .Should().DefineType(GetType().Namespace, typeof(WellKnownClassWithAttribute).Name)\n .Which.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*WellKnownClassWithAttribute*decorated*SerializableAttribute*not found.\");\n }\n\n [Fact]\n public void\n When_an_assembly_does_not_define_a_type_and_Should_DefineType_is_asserted_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act\n Action act = () => thisAssembly.Should().DefineType(\"FakeNamespace\", \"FakeName\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected assembly \\\"{thisAssembly.FullName}\\\" \" +\n \"to define type \\\"FakeNamespace\\\".\\\"FakeName\\\" \" +\n \"because we want to test the failure message, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_define_type_should_fail()\n {\n // Arrange\n Assembly thisAssembly = null;\n\n // Act\n Action act = () =>\n thisAssembly.Should().DefineType(GetType().Namespace, \"WellKnownClassWithAttribute\",\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected assembly to define type *.\\\"WellKnownClassWithAttribute\\\" *failure message*\" +\n \", but thisAssembly is .\");\n }\n\n [Fact]\n public void When_an_assembly_defining_a_type_with_a_null_name_it_should_throw()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act\n Action act = () => thisAssembly.Should().DefineType(GetType().Namespace, null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_an_assembly_defining_a_type_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var thisAssembly = GetType().Assembly;\n\n // Act\n Action act = () => thisAssembly.Should().DefineType(GetType().Namespace, string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_an_assembly_is_null_and_Should_BeNull_is_asserted_it_should_succeed()\n {\n // Arrange\n Assembly thisAssembly = null;\n\n // Act / Assert\n thisAssembly\n .Should().BeNull();\n }\n }\n\n public class BeUnsigned\n {\n [Theory]\n [InlineData(null)]\n [InlineData(\"\")]\n public void Guards_for_unsigned_assembly(string noKey)\n {\n // Arrange\n var unsignedAssembly = FindAssembly.Stub(noKey);\n\n // Act & Assert\n unsignedAssembly.Should().BeUnsigned();\n }\n\n [Fact]\n public void Throws_for_signed_assembly()\n {\n // Arrange\n var signedAssembly = FindAssembly.Stub(\"0123456789ABCEF007\");\n\n // Act\n Action act = () => signedAssembly.Should().BeUnsigned(\"this assembly is never shipped\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the assembly * to be signed because this assembly is never shipped, but it is.\");\n }\n\n [Fact]\n public void Throws_for_null_subject()\n {\n // Arrange\n Assembly nullAssembly = null;\n\n // Act\n Action act = () => nullAssembly.Should().BeUnsigned();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Can't check for assembly signing if nullAssembly reference is .\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var unsignedAssembly = FindAssembly.Stub(\"\");\n\n // Act & Assert\n unsignedAssembly.Should().BeUnsigned().And.NotBeNull();\n }\n }\n\n public class BeSignedWithPublicKey\n {\n [Theory]\n [InlineData(\"0123456789ABCEF007\")]\n [InlineData(\"0123456789abcef007\")]\n [InlineData(\"0123456789ABcef007\")]\n public void Guards_for_signed_assembly_with_expected_public_key(string publicKey)\n {\n // Arrange\n var signedAssembly = FindAssembly.Stub(\"0123456789ABCEF007\");\n\n // Act & Assert\n signedAssembly.Should().BeSignedWithPublicKey(publicKey);\n }\n\n [Theory]\n [InlineData(null)]\n [InlineData(\"\")]\n public void Throws_for_unsigned_assembly(string noKey)\n {\n // Arrange\n var unsignedAssembly = FindAssembly.Stub(noKey);\n\n // Act\n Action act = () => unsignedAssembly.Should().BeSignedWithPublicKey(\"1234\", \"signing is part of the contract\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected assembly * to have public key \\\"1234\\\" because signing is part of the contract, but it is unsigned.\");\n }\n\n [Fact]\n public void Throws_signed_assembly_with_different_public_key()\n {\n // Arrange\n var signedAssembly = FindAssembly.Stub(\"0123456789ABCEF007\");\n\n // Act\n Action act = () => signedAssembly.Should().BeSignedWithPublicKey(\"1234\", \"signing is part of the contract\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected assembly * to have public key \\\"1234\\\" because signing is part of the contract, but it has * instead.\");\n }\n\n [Fact]\n public void Throws_for_null_assembly()\n {\n // Arrange\n Assembly nullAssembly = null;\n\n // Act\n Action act = () => nullAssembly.Should().BeSignedWithPublicKey(\"1234\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Can't check for assembly signing if nullAssembly reference is .\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var key = \"0123456789ABCEF007\";\n var signedAssembly = FindAssembly.Stub(key);\n\n // Act & Assert\n signedAssembly.Should().BeSignedWithPublicKey(key).And.NotBeNull();\n }\n }\n}\n\n[DummyClass(\"name\", true)]\npublic class WellKnownClassWithAttribute;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/TaskCompletionSourceAssertionSpecs.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class TaskCompletionSourceAssertionSpecs\n{\n#if NET6_0_OR_GREATER\n public class NonGeneric\n {\n [Fact]\n public async Task When_it_completes_in_time_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds());\n subject.SetResult();\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_did_not_complete_in_time_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to complete within 1s because test testArg.\");\n }\n\n [Fact]\n public async Task When_it_is_null_it_should_fail()\n {\n // Arrange\n TaskCompletionSource subject = null;\n\n // Act\n Func action = () => subject.Should().CompleteWithinAsync(1.Seconds());\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to complete within 1s, but found .\");\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_it_is_not_expected_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n subject.SetResult();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*to not complete within*because test testArg*\");\n }\n\n [Fact]\n public async Task When_it_is_canceled_before_completion_and_it_is_not_expected_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n subject.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_it_throws_before_completion_and_it_is_not_expected_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n subject.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_it_did_not_complete_in_time_and_it_is_not_expected_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_is_null_and_we_validate_to_not_complete_it_should_fail()\n {\n // Arrange\n TaskCompletionSource subject = null;\n\n // Act\n Func action = () => subject.Should().NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to not complete within 1s because test testArg, but found .\");\n }\n\n [Fact]\n public async Task When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n\n // Act\n Func action = () => Task.FromResult(subject.Should().Equals(subject));\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean CompleteWithinAsync() instead?\");\n }\n\n [Fact]\n public async Task Canceled_tasks_are_also_completed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds());\n subject.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Excepted_tasks_unexpectedly_completed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds());\n subject.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n }\n#endif\n\n public class Generic\n {\n [Fact]\n public async Task When_it_completes_in_time_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds());\n subject.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task Canceled_tasks_do_not_return_default_value()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds()).WithResult(false);\n subject.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Exception_throwing_tasks_do_not_cause_a_default_value_to_be_returned()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds()).WithResult(false);\n subject.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_result_is_expected_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = async () => (await subject.Should(timer).CompleteWithinAsync(1.Seconds())).Which.Should().Be(42);\n subject.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_async_result_is_expected_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds()).WithResult(42);\n subject.SetResult(42);\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_result_is_not_expected_it_should_fail()\n {\n // Arrange\n var testSubject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = async () =>\n (await testSubject.Should(timer).CompleteWithinAsync(1.Seconds())).Which.Should().Be(42);\n\n testSubject.SetResult(99);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected *testSubject* to be 42, but found 99 (difference of 57).\");\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_async_result_is_not_expected_it_should_fail()\n {\n // Arrange\n var testSubject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => testSubject.Should(timer).CompleteWithinAsync(1.Seconds()).WithResult(42);\n testSubject.SetResult(99);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected testSubject.Result to be 42, but found 99.\");\n }\n\n [Fact]\n public async Task When_it_did_not_complete_in_time_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).CompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to complete within 1s because test testArg.\");\n }\n\n [Fact]\n public async Task When_it_is_null_it_should_fail()\n {\n // Arrange\n TaskCompletionSource subject = null;\n\n // Act\n Func action = () => subject.Should().CompleteWithinAsync(1.Seconds());\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Expected subject to complete within 1s, but found .\");\n }\n\n [Fact]\n public async Task When_it_completes_in_time_and_it_is_not_expected_it_should_fail()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n subject.SetResult(true);\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect*to complete within*because test testArg*\");\n }\n\n [Fact]\n public async Task Canceled_tasks_are_also_completed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n subject.SetCanceled();\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Excepted_tasks_unexpectedly_completed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n subject.SetException(new OperationCanceledException());\n timer.Complete();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_it_did_not_complete_in_time_and_it_is_not_expected_it_should_succeed()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n var timer = new FakeClock();\n\n // Act\n Func action = () => subject.Should(timer).NotCompleteWithinAsync(1.Seconds());\n timer.Complete();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_it_is_null_and_we_validate_to_not_complete_it_should_fail()\n {\n // Arrange\n TaskCompletionSource subject = null;\n\n // Act\n Func action = () => subject.Should().NotCompleteWithinAsync(1.Seconds(), \"test {0}\", \"testArg\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect subject to complete within 1s because test testArg, but found .\");\n }\n\n [Fact]\n public async Task When_accidentally_using_equals_with_generic_it_should_throw_a_helpful_error()\n {\n // Arrange\n var subject = new TaskCompletionSource();\n\n // Act\n Func> action = () => Task.FromResult(subject.Should().Equals(subject));\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean CompleteWithinAsync() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Build/CompressionExtensions.cs", "using System.IO;\nusing Nuke.Common.IO;\nusing SharpCompress.Common;\nusing SharpCompress.Readers;\n\npublic static class CompressionExtensions\n{\n public static void UnTarXzTo(this AbsolutePath archive, AbsolutePath directory)\n {\n using Stream stream = File.OpenRead(archive);\n\n using var reader = ReaderFactory.Open(stream);\n\n while (reader.MoveToNextEntry())\n {\n if (reader.Entry.IsDirectory)\n {\n continue;\n }\n\n reader.WriteEntryToDirectory(directory, new ExtractionOptions\n {\n ExtractFullPath = true,\n Overwrite = true\n });\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Events/EventAssertionSpecs.cs", "#if NET47\nusing System.Reflection.Emit;\n#endif\n\nusing System;\nusing System.ComponentModel;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Events;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Events;\n\n[Collection(\"EventMonitoring\")]\npublic class EventAssertionSpecs\n{\n public class ShouldRaise\n {\n [Fact]\n public void When_asserting_an_event_that_doesnt_exist_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitoredSubject = subject.Monitor();\n\n // Act\n // ReSharper disable once AccessToDisposedClosure\n Action act = () => monitoredSubject.Should().Raise(\"NonExistingEvent\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Not monitoring any events named \\\"NonExistingEvent\\\".\");\n }\n\n [Fact]\n public void When_asserting_that_an_event_was_not_raised_and_it_doesnt_exist_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n Action act = () => monitor.Should().NotRaise(\"NonExistingEvent\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Not monitoring any events named \\\"NonExistingEvent\\\".\");\n }\n\n [Fact]\n public void When_an_event_was_not_raised_it_should_throw_and_use_the_reason()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n Action act = () => monitor.Should().Raise(\"PropertyChanged\", \"{0} should cause the event to get raised\", \"Foo()\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected object \" + Formatter.ToString(subject) +\n \" to raise event \\\"PropertyChanged\\\" because Foo() should cause the event to get raised, but it did not.\");\n }\n\n [Fact]\n public void When_the_expected_event_was_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithoutSender();\n\n // Act / Assert\n monitor.Should().Raise(\"PropertyChanged\");\n }\n\n [Fact]\n public void When_an_unexpected_event_was_raised_it_should_throw_and_use_the_reason()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithoutSender();\n\n // Act\n Action act = () =>\n monitor.Should().NotRaise(\"PropertyChanged\", \"{0} should cause the event to get raised\", \"Foo()\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected object \" + Formatter.ToString(subject) +\n \" to not raise event \\\"PropertyChanged\\\" because Foo() should cause the event to get raised, but it did.\");\n }\n\n [Fact]\n public void When_an_unexpected_event_was_not_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act / Assert\n monitor.Should().NotRaise(\"PropertyChanged\");\n }\n\n [Fact]\n public void When_the_event_sender_is_not_the_expected_object_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithoutSender();\n\n // Act\n Action act = () => monitor.Should().Raise(\"PropertyChanged\").WithSender(subject);\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected sender {Formatter.ToString(subject)}, but found {{}}.\");\n }\n\n [Fact]\n public void When_the_event_sender_is_the_expected_object_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSender();\n\n // Act / Assert\n monitor.Should().Raise(\"PropertyChanged\").WithSender(subject);\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_WithArgs_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act\n Action act = () => monitor.Should()\n .Raise(\"NonConventionalEvent\")\n .WithArgs(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_the_event_parameters_dont_match_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithoutSender();\n\n // Act\n Action act = () => monitor\n .Should().Raise(\"PropertyChanged\")\n .WithArgs(args => args.PropertyName == \"SomeProperty\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected at least one event with some argument of type*PropertyChangedEventArgs*matches*(args.PropertyName == \\\"SomeProperty\\\"), but found none.\");\n }\n\n [Fact]\n public void When_the_event_args_are_of_a_different_type_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act\n Action act = () => monitor\n .Should().Raise(\"PropertyChanged\")\n .WithArgs(args => args.Cancel);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*event*argument*type*CancelEventArgs>*\");\n }\n\n [Fact]\n public void When_the_event_parameters_do_match_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act / Assert\n monitor\n .Should().Raise(\"PropertyChanged\")\n .WithArgs(args => args.PropertyName == \"SomeProperty\");\n }\n\n [Fact]\n public void When_running_in_parallel_it_should_not_throw()\n {\n // Arrange\n void Action(int _)\n {\n EventRaisingClass subject = new();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSender();\n monitor.Should().Raise(\"PropertyChanged\");\n }\n\n // Act\n Action act = () => Enumerable.Range(0, 1000)\n .AsParallel()\n .ForAll(Action);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_monitored_class_event_has_fired_it_should_be_possible_to_reset_the_event_monitor()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var eventMonitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act\n eventMonitor.Clear();\n\n // Assert\n eventMonitor.Should().NotRaise(\"PropertyChanged\");\n }\n\n [Fact]\n public void When_a_non_conventional_event_with_a_specific_argument_was_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act / Assert\n monitor\n .Should().Raise(\"NonConventionalEvent\")\n .WithArgs(args => args == \"third argument\");\n }\n\n [Fact]\n public void When_a_non_conventional_event_with_many_specific_arguments_was_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act / Assert\n monitor\n .Should().Raise(\"NonConventionalEvent\")\n .WithArgs(null, args => args == \"third argument\");\n }\n\n [Fact]\n public void When_a_predicate_based_parameter_assertion_expects_more_parameters_then_an_event_has_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act\n Action act = () => monitor\n .Should().Raise(nameof(EventRaisingClass.NonConventionalEvent))\n .WithArgs(null, null, null, args => args == \"fourth argument\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*4 parameters*String*, but*2*\");\n }\n\n [Fact]\n public void When_a_non_conventional_event_with_a_specific_argument_was_not_raised_it_should_throw()\n {\n // Arrange\n const int wrongArgument = 3;\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act\n Action act = () => monitor\n .Should().Raise(\"NonConventionalEvent\")\n .WithArgs(args => args == wrongArgument);\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"Expected at least one event with some argument*type*int*matches*(args == {wrongArgument})\" +\n \", but found none.\");\n }\n\n [Fact]\n public void When_a_non_conventional_event_with_many_specific_arguments_was_not_raised_it_should_throw()\n {\n // Arrange\n const string wrongArgument = \"not a third argument\";\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseNonConventionalEvent(\"first argument\", 2, \"third argument\");\n\n // Act\n Action act = () => monitor\n .Should().Raise(\"NonConventionalEvent\")\n .WithArgs(null, args => args == wrongArgument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected at least one event with some arguments*match*\\\"(args == \\\"\" + wrongArgument +\n \"\\\")\\\", but found none.\");\n }\n\n [Fact]\n public void When_a_specific_event_is_expected_it_should_return_only_relevant_events()\n {\n // Arrange\n var observable = new EventRaisingClass();\n using var monitor = observable.Monitor();\n\n // Act\n observable.RaiseEventWithSpecificSender(\"Foo\");\n observable.RaiseEventWithSpecificSender(\"Bar\");\n observable.RaiseNonConventionalEvent(\"don't care\", 123, \"don't care\");\n\n // Assert\n var recording = monitor\n .Should()\n .Raise(nameof(observable.PropertyChanged));\n\n recording.EventName.Should().Be(nameof(observable.PropertyChanged));\n recording.EventObject.Should().BeSameAs(observable);\n recording.EventHandlerType.Should().Be(typeof(PropertyChangedEventHandler));\n recording.Should().HaveCount(2, \"because only two property changed events were raised\");\n }\n\n [Fact]\n public void When_a_specific_sender_is_expected_it_should_return_only_relevant_events()\n {\n // Arrange\n var observable = new EventRaisingClass();\n using var monitor = observable.Monitor();\n\n // Act\n observable.RaiseEventWithSpecificSender(observable);\n observable.RaiseEventWithSpecificSender(new object());\n\n // Assert\n var recording = monitor\n .Should()\n .Raise(nameof(observable.PropertyChanged))\n .WithSender(observable);\n\n recording.Should().ContainSingle().Which.Parameters[0].Should().BeSameAs(observable);\n }\n\n [Fact]\n public void When_constraints_are_specified_it_should_filter_the_events_based_on_those_constraints()\n {\n // Arrange\n var observable = new EventRaisingClass();\n using var monitor = observable.Monitor();\n\n // Act\n observable.RaiseEventWithSenderAndPropertyName(\"Foo\");\n observable.RaiseEventWithSenderAndPropertyName(\"Boo\");\n\n // Assert\n var recording = monitor\n .Should()\n .Raise(nameof(observable.PropertyChanged))\n .WithSender(observable)\n .WithArgs(args => args.PropertyName == \"Boo\");\n\n recording\n .Should().ContainSingle(\"because we were expecting a specific property change\")\n .Which.Parameters[^1].Should().BeOfType()\n .Which.PropertyName.Should().Be(\"Boo\");\n }\n\n [Fact]\n public void When_events_are_raised_regardless_of_time_tick_it_should_return_by_invocation_order()\n {\n // Arrange\n var observable = new TestEventRaisingInOrder();\n\n using var monitor = observable.Monitor(conf =>\n conf.ConfigureTimestampProvider(() => 11.January(2022).At(12, 00).AsUtc()));\n\n // Act\n observable.RaiseAllEvents();\n\n // Assert\n monitor.OccurredEvents[0].EventName.Should().Be(nameof(TestEventRaisingInOrder.InterfaceEvent));\n monitor.OccurredEvents[0].Sequence.Should().Be(0);\n\n monitor.OccurredEvents[1].EventName.Should().Be(nameof(TestEventRaisingInOrder.Interface2Event));\n monitor.OccurredEvents[1].Sequence.Should().Be(1);\n\n monitor.OccurredEvents[2].EventName.Should().Be(nameof(TestEventRaisingInOrder.Interface3Event));\n monitor.OccurredEvents[2].Sequence.Should().Be(2);\n }\n\n [Fact]\n public void When_monitoring_a_class_it_should_be_possible_to_attach_to_additional_interfaces_on_the_same_object()\n {\n // Arrange\n var subject = new TestEventRaising();\n using var outerMonitor = subject.Monitor();\n using var innerMonitor = subject.Monitor();\n\n // Act\n subject.RaiseBothEvents();\n\n // Assert\n outerMonitor.Should().Raise(\"InterfaceEvent\");\n innerMonitor.Should().Raise(\"Interface2Event\");\n }\n }\n\n public class ShouldRaisePropertyChanged\n {\n [Fact]\n public void When_a_property_changed_event_was_raised_for_the_expected_property_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n subject.RaiseEventWithSenderAndPropertyName(\"SomeOtherProperty\");\n\n // Act / Assert\n monitor.Should().RaisePropertyChangeFor(x => x.SomeProperty);\n }\n\n [Fact]\n public void When_an_expected_property_changed_event_was_raised_for_all_properties_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(null);\n\n // Act / Assert\n monitor.Should().RaisePropertyChangeFor(null);\n }\n\n [Fact]\n public void When_a_property_changed_event_for_a_specific_property_was_not_raised_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n Action act = () => monitor.Should().RaisePropertyChangeFor(x => x.SomeProperty, \"the property was changed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected object \" + Formatter.ToString(subject) +\n \" to raise event \\\"PropertyChanged\\\" for property \\\"SomeProperty\\\" because the property was changed, but it did not*\");\n }\n\n [Fact]\n public void When_a_property_agnostic_property_changed_event_for_was_not_raised_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n monitor.Should().RaisePropertyChangeFor(null);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected object \" + Formatter.ToString(subject) +\n \" to raise event \\\"PropertyChanged\\\" for property , but it did not*\");\n }\n\n [Fact]\n public void\n When_the_property_changed_event_was_raised_for_the_wrong_property_it_should_throw_and_include_the_actual_properties_raised()\n {\n // Arrange\n var bar = new EventRaisingClass();\n using var monitor = bar.Monitor();\n bar.RaiseEventWithSenderAndPropertyName(\"OtherProperty1\");\n bar.RaiseEventWithSenderAndPropertyName(\"OtherProperty2\");\n bar.RaiseEventWithSenderAndPropertyName(\"OtherProperty2\");\n\n // Act\n Action act = () => monitor.Should().RaisePropertyChangeFor(b => b.SomeProperty);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*property*SomeProperty*but*OtherProperty1*OtherProperty2*\");\n }\n\n [Fact]\n public void\n The_number_of_property_changed_recorded_for_a_specific_property_matches_the_number_of_times_it_was_raised_specifically()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeProperty));\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeProperty));\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeOtherProperty));\n\n // Act\n monitor.Should().RaisePropertyChangeFor(x => x.SomeProperty).Should().HaveCount(2);\n }\n\n [Fact]\n public void\n The_number_of_property_changed_recorded_for_a_specific_property_matches_the_number_of_times_it_was_raised_including_agnostic_property()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeProperty));\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeOtherProperty));\n subject.RaiseEventWithSenderAndPropertyName(null);\n subject.RaiseEventWithSenderAndPropertyName(string.Empty);\n\n // Act\n monitor.Should().RaisePropertyChangeFor(x => x.SomeProperty).Should().HaveCount(3);\n }\n\n [Fact]\n public void\n The_number_of_property_changed_recorded_matches_the_number_of_times_it_was_raised()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeProperty));\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeOtherProperty));\n subject.RaiseEventWithSenderAndPropertyName(null);\n subject.RaiseEventWithSenderAndPropertyName(string.Empty);\n\n // Act\n monitor.Should().RaisePropertyChangeFor(null).Should().HaveCount(4);\n }\n }\n\n public class ShouldNotRaisePropertyChanged\n {\n [Fact]\n public void When_a_property_changed_event_was_raised_by_monitored_class_it_should_be_possible_to_reset_the_event_monitor()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var eventMonitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act\n eventMonitor.Clear();\n\n // Assert\n eventMonitor.Should().NotRaisePropertyChangeFor(e => e.SomeProperty);\n }\n\n [Fact]\n public void When_a_property_changed_event_for_an_unexpected_property_was_raised_it_should_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeProperty\");\n\n // Act\n Action act = () => monitor.Should().NotRaisePropertyChangeFor(x => x.SomeProperty, \"nothing happened\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect object \" + Formatter.ToString(subject) +\n \" to raise the \\\"PropertyChanged\\\" event for property \\\"SomeProperty\\\" because nothing happened, but it did.\");\n }\n\n [Fact]\n public void When_a_property_changed_event_for_another_than_the_unexpected_property_was_raised_it_should_not_throw()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(\"SomeOtherProperty\");\n\n // Act / Assert\n monitor.Should().NotRaisePropertyChangeFor(x => x.SomeProperty);\n }\n\n [Fact]\n public void Throw_for_an_agnostic_property_when_any_property_changed_is_recorded()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(nameof(EventRaisingClass.SomeOtherProperty));\n\n // Act\n Action act = () => monitor.Should().NotRaisePropertyChangeFor(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect object \" + Formatter.ToString(subject) +\n \" to raise the \\\"PropertyChanged\\\" event, but it did.\");\n }\n\n [Fact]\n public void Throw_for_a_specific_property_when_an_agnostic_property_changed_is_recorded()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n subject.RaiseEventWithSenderAndPropertyName(null);\n\n // Act\n Action act = () => monitor.Should().NotRaisePropertyChangeFor(x => x.SomeProperty);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect object \" + Formatter.ToString(subject) +\n \" to raise the \\\"PropertyChanged\\\" event for property \\\"SomeProperty\\\", but it did.\");\n }\n }\n\n public class PreconditionChecks\n {\n [Fact]\n public void When_monitoring_a_null_object_it_should_throw()\n {\n // Arrange\n EventRaisingClass subject = null;\n\n // Act\n Action act = () => subject.Monitor();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot monitor the events of a object*\");\n }\n\n [Fact]\n public void When_nesting_monitoring_requests_scopes_should_be_isolated()\n {\n // Arrange\n var eventSource = new EventRaisingClass();\n using var outerScope = eventSource.Monitor();\n\n // Act\n using var innerScope = eventSource.Monitor();\n\n // Assert\n ((object)innerScope).Should().NotBeSameAs(outerScope);\n }\n\n [Fact]\n public void When_monitoring_an_object_with_invalid_property_expression_it_should_throw()\n {\n // Arrange\n var eventSource = new EventRaisingClass();\n using var monitor = eventSource.Monitor();\n Func func = e => e.SomeOtherProperty;\n\n // Act\n Action act = () => monitor.Should().RaisePropertyChangeFor(e => func(e));\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expression\");\n }\n\n [Fact]\n public void Event_assertions_should_expose_the_monitor()\n {\n // Arrange\n var subject = new EventRaisingClass();\n using var monitor = subject.Monitor();\n\n // Act\n var exposedMonitor = monitor.Should().Monitor;\n\n // Assert\n ((object)exposedMonitor).Should().BeSameAs(monitor);\n }\n }\n\n public class Metadata\n {\n [Fact]\n public void When_monitoring_an_object_it_should_monitor_all_the_events_it_exposes()\n {\n // Arrange\n var eventSource = new ClassThatRaisesEventsItself();\n using var eventMonitor = eventSource.Monitor();\n\n // Act\n EventMetadata[] metadata = eventMonitor.MonitoredEvents;\n\n // Assert\n metadata.Should().BeEquivalentTo(\n [\n new\n {\n EventName = nameof(ClassThatRaisesEventsItself.InterfaceEvent),\n HandlerType = typeof(EventHandler)\n },\n new\n {\n EventName = nameof(ClassThatRaisesEventsItself.PropertyChanged),\n HandlerType = typeof(PropertyChangedEventHandler)\n }\n ]);\n }\n\n [Fact]\n public void When_monitoring_an_object_through_an_interface_it_should_monitor_only_the_events_it_exposes()\n {\n // Arrange\n var eventSource = new ClassThatRaisesEventsItself();\n using var monitor = eventSource.Monitor();\n\n // Act\n EventMetadata[] metadata = monitor.MonitoredEvents;\n\n // Assert\n metadata.Should().BeEquivalentTo(\n [\n new\n {\n EventName = nameof(IEventRaisingInterface.InterfaceEvent),\n HandlerType = typeof(EventHandler)\n }\n ]);\n }\n\n#if NETFRAMEWORK // DefineDynamicAssembly is obsolete in .NET Core\n [Fact]\n public void When_an_object_doesnt_expose_any_events_it_should_throw()\n {\n // Arrange\n object eventSource = CreateProxyObject();\n\n // Act\n Action act = () => eventSource.Monitor();\n\n // Assert\n act.Should().Throw().WithMessage(\"*not expose any events*\");\n }\n\n [Fact]\n public void When_monitoring_interface_of_a_class_and_no_recorder_exists_for_an_event_it_should_throw()\n {\n // Arrange\n var eventSource = (IEventRaisingInterface)CreateProxyObject();\n using var eventMonitor = eventSource.Monitor();\n\n // Act\n Action action = () => eventMonitor.GetRecordingFor(\"SomeEvent\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Not monitoring any events named \\\"SomeEvent\\\".\");\n }\n\n private object CreateProxyObject()\n {\n Type baseType = typeof(EventRaisingClass);\n Type interfaceType = typeof(IEventRaisingInterface);\n\n AssemblyName assemblyName = new() { Name = baseType.Assembly.FullName + \".GeneratedForTest\" };\n\n AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName,\n AssemblyBuilderAccess.Run);\n\n ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, false);\n string typeName = baseType.Name + \"_GeneratedForTest\";\n\n TypeBuilder typeBuilder =\n moduleBuilder.DefineType(typeName, TypeAttributes.Public, baseType, [interfaceType]);\n\n MethodBuilder addHandler = EmitAddRemoveEventHandler(\"add\");\n typeBuilder.DefineMethodOverride(addHandler, interfaceType.GetMethod(\"add_InterfaceEvent\"));\n MethodBuilder removeHandler = EmitAddRemoveEventHandler(\"remove\");\n typeBuilder.DefineMethodOverride(removeHandler, interfaceType.GetMethod(\"remove_InterfaceEvent\"));\n\n Type generatedType = typeBuilder.CreateType();\n return Activator.CreateInstance(generatedType);\n\n MethodBuilder EmitAddRemoveEventHandler(string methodName)\n {\n MethodBuilder method =\n typeBuilder.DefineMethod($\"{interfaceType.FullName}.{methodName}_InterfaceEvent\",\n MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.Final |\n MethodAttributes.HideBySig |\n MethodAttributes.NewSlot);\n\n method.SetReturnType(typeof(void));\n method.SetParameters(typeof(EventHandler));\n ILGenerator gen = method.GetILGenerator();\n gen.Emit(OpCodes.Ret);\n return method;\n }\n }\n\n#endif\n\n [Fact]\n public void When_event_exists_on_class_but_not_on_monitored_interface_it_should_not_allow_monitoring_it()\n {\n // Arrange\n var eventSource = new ClassThatRaisesEventsItself();\n using var eventMonitor = eventSource.Monitor();\n\n // Act\n Action action = () => eventMonitor.GetRecordingFor(\"PropertyChanged\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Not monitoring any events named \\\"PropertyChanged\\\".\");\n }\n\n [Fact]\n public void When_an_object_raises_two_events_it_should_provide_the_data_about_those_occurrences()\n {\n // Arrange\n DateTime utcNow = 17.September(2017).At(21, 00).AsUtc();\n\n var eventSource = new EventRaisingClass();\n using var monitor = eventSource.Monitor(opt => opt.ConfigureTimestampProvider(() => utcNow));\n\n // Act\n eventSource.RaiseEventWithSenderAndPropertyName(\"theProperty\");\n\n utcNow += 1.Hours();\n\n eventSource.RaiseNonConventionalEvent(\"first\", 123, \"third\");\n\n // Assert\n monitor.OccurredEvents.Should().BeEquivalentTo(\n [\n new\n {\n EventName = \"PropertyChanged\",\n TimestampUtc = utcNow - 1.Hours(),\n Parameters = new object[] { eventSource, new PropertyChangedEventArgs(\"theProperty\") }\n },\n new\n {\n EventName = \"NonConventionalEvent\",\n TimestampUtc = utcNow,\n Parameters = new object[] { \"first\", 123, \"third\" }\n }\n ], o => o.WithStrictOrdering());\n }\n\n [Fact]\n public void When_monitoring_interface_with_inherited_event_it_should_not_throw()\n {\n // Arrange\n var eventSource = (IInheritsEventRaisingInterface)new ClassThatRaisesEventsItself();\n\n // Act\n Action action = () => eventSource.Monitor();\n\n // Assert\n action.Should().NotThrow();\n }\n }\n\n public class WithArgs\n {\n [Fact]\n public void One_matching_argument_type_before_mismatching_types_passes()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new B());\n a.OnEvent(new C());\n\n // Act / Assert\n IEventRecording filteredEvents = aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs();\n filteredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void One_matching_argument_type_after_mismatching_types_passes()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new B());\n\n // Act / Assert\n IEventRecording filteredEvents = aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs();\n filteredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void Throws_when_none_of_the_arguments_are_of_the_expected_type()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new C());\n\n // Act\n Action act = () => aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*event*argument*\");\n }\n\n [Fact]\n public void One_matching_argument_type_anywhere_between_mismatching_types_passes()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new B());\n a.OnEvent(new C());\n\n // Act / Assert\n IEventRecording filteredEvents = aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs();\n filteredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void One_matching_argument_type_anywhere_between_mismatching_types_with_parameters_passes()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new B());\n a.OnEvent(new C());\n\n // Act / Assert\n IEventRecording filteredEvents = aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs(_ => true);\n filteredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void Mismatching_argument_types_with_one_parameter_matching_a_different_type_fails()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new C());\n\n // Act\n Action act = () => aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs(_ => true);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*event*argument*type*B*none*\");\n }\n\n [Fact]\n public void Mismatching_argument_types_with_two_or_more_parameters_matching_a_different_type_fails()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new C());\n\n // Act\n Action act = () => aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs(_ => true, _ => false);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*event*parameters*type*B*found*\");\n }\n\n [Fact]\n public void One_matching_argument_type_with_two_or_more_parameters_matching_a_mismatching_type_fails()\n {\n // Arrange\n A a = new();\n using var aMonitor = a.Monitor();\n\n a.OnEvent(new C());\n a.OnEvent(new B());\n\n // Act\n Action act = () => aMonitor.GetRecordingFor(nameof(A.Event)).WithArgs(_ => true, _ => false);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*event*parameters*type*B*found*\");\n }\n }\n\n public class MonitorDefaultBehavior\n {\n [Fact]\n public void Broken_event_add_accessors_fails()\n {\n // Arrange\n var sut = new TestEventBrokenEventHandlerRaising();\n\n // Act / Assert\n sut.Invoking(c =>\n {\n using var monitor = c.Monitor();\n }).Should().Throw();\n }\n\n [Fact]\n public void Broken_event_remove_accessors_fails()\n {\n // Arrange\n var sut = new TestEventBrokenEventHandlerRaising();\n\n // Act / Assert\n sut.Invoking(c =>\n {\n using var monitor = c.Monitor();\n }).Should().Throw();\n }\n }\n\n public class IgnoreMisbehavingEventAccessors\n {\n [Fact]\n public void Monitoring_class_with_broken_event_add_accessor_succeeds()\n {\n // Arrange\n var classToMonitor = new TestEventBrokenEventHandlerRaising();\n\n // Act / Assert\n classToMonitor.Invoking(c =>\n {\n using var monitor = c.Monitor(opt => opt.IgnoringEventAccessorExceptions());\n }).Should().NotThrow();\n }\n\n [Fact]\n public void Class_with_broken_event_remove_accessor_succeeds()\n {\n // Arrange\n var classToMonitor = new TestEventBrokenEventHandlerRaising();\n\n // Act / Assert\n classToMonitor.Invoking(c =>\n {\n using var monitor = c.Monitor(opt => opt.IgnoringEventAccessorExceptions());\n }).Should().NotThrow();\n }\n\n [Fact]\n public void Recording_event_with_broken_add_accessor_succeeds()\n {\n // Arrange\n var classToMonitor = new TestEventBrokenEventHandlerRaising();\n\n using var monitor =\n classToMonitor.Monitor(opt =>\n opt.IgnoringEventAccessorExceptions().RecordingEventsWithBrokenAccessor());\n\n //Act\n classToMonitor.RaiseOkEvent();\n\n //Assert\n monitor.MonitoredEvents.Should().HaveCount(1);\n }\n\n [Fact]\n public void Ignoring_broken_event_accessor_should_also_not_record_events()\n {\n // Arrange\n var classToMonitor = new TestEventBrokenEventHandlerRaising();\n\n using var monitor = classToMonitor.Monitor(opt => opt.IgnoringEventAccessorExceptions());\n\n //Act\n classToMonitor.RaiseOkEvent();\n\n //Assert\n monitor.MonitoredEvents.Should().BeEmpty();\n }\n }\n\n private interface IAddOkEvent\n {\n event EventHandler OkEvent;\n }\n\n private interface IAddFailingRecordableEvent\n {\n public event EventHandler AddFailingRecorableEvent;\n }\n\n private interface IAddFailingEvent\n {\n public event EventHandler AddFailingEvent;\n }\n\n private interface IRemoveFailingEvent\n {\n public event EventHandler RemoveFailingEvent;\n }\n\n private class TestEventBrokenEventHandlerRaising\n : IAddFailingEvent, IRemoveFailingEvent, IAddOkEvent, IAddFailingRecordableEvent\n {\n public event EventHandler AddFailingEvent\n {\n add => throw new InvalidOperationException(\"Add is failing\");\n remove => OkEvent -= value;\n }\n\n public event EventHandler AddFailingRecorableEvent\n {\n add\n {\n OkEvent += value;\n throw new InvalidOperationException(\"Add is failing\");\n }\n\n remove => OkEvent -= value;\n }\n\n public event EventHandler OkEvent;\n\n public event EventHandler RemoveFailingEvent\n {\n add => OkEvent += value;\n remove => throw new InvalidOperationException(\"Remove is failing\");\n }\n\n public void RaiseOkEvent()\n {\n OkEvent?.Invoke(this, EventArgs.Empty);\n }\n }\n\n public class A\n {\n#pragma warning disable MA0046\n public event EventHandler Event;\n#pragma warning restore MA0046\n\n public void OnEvent(object o)\n {\n Event.Invoke(nameof(A), o);\n }\n }\n\n public class B;\n\n public class C;\n\n public class ClassThatRaisesEventsItself : IInheritsEventRaisingInterface\n {\n#pragma warning disable RCS1159\n public event PropertyChangedEventHandler PropertyChanged;\n#pragma warning restore RCS1159\n\n public event EventHandler InterfaceEvent;\n\n protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)\n {\n PropertyChanged?.Invoke(this, e);\n }\n\n protected virtual void OnInterfaceEvent()\n {\n InterfaceEvent?.Invoke(this, EventArgs.Empty);\n }\n }\n\n public class TestEventRaising : IEventRaisingInterface, IEventRaisingInterface2\n {\n public event EventHandler InterfaceEvent;\n\n public event EventHandler Interface2Event;\n\n public void RaiseBothEvents()\n {\n InterfaceEvent?.Invoke(this, EventArgs.Empty);\n Interface2Event?.Invoke(this, EventArgs.Empty);\n }\n }\n\n private class TestEventRaisingInOrder : IEventRaisingInterface, IEventRaisingInterface2, IEventRaisingInterface3\n {\n public event EventHandler Interface3Event;\n\n public event EventHandler Interface2Event;\n\n public event EventHandler InterfaceEvent;\n\n public void RaiseAllEvents()\n {\n InterfaceEvent?.Invoke(this, EventArgs.Empty);\n Interface2Event?.Invoke(this, EventArgs.Empty);\n Interface3Event?.Invoke(this, EventArgs.Empty);\n }\n }\n\n public interface IEventRaisingInterface\n {\n event EventHandler InterfaceEvent;\n }\n\n public interface IEventRaisingInterface2\n {\n event EventHandler Interface2Event;\n }\n\n public interface IEventRaisingInterface3\n {\n event EventHandler Interface3Event;\n }\n\n public interface IInheritsEventRaisingInterface : IEventRaisingInterface;\n\n public class EventRaisingClass : INotifyPropertyChanged\n {\n public string SomeProperty { get; set; }\n\n public int SomeOtherProperty { get; set; }\n\n public event PropertyChangedEventHandler PropertyChanged = (_, _) => { };\n\n#pragma warning disable MA0046\n public event Action NonConventionalEvent = (_, _, _) => { };\n#pragma warning restore MA0046\n\n public void RaiseNonConventionalEvent(string first, int second, string third)\n {\n NonConventionalEvent.Invoke(first, second, third);\n }\n\n public void RaiseEventWithoutSender()\n {\n#pragma warning disable AV1235, MA0091 // 'sender' is deliberately null\n PropertyChanged(null, new PropertyChangedEventArgs(\"\"));\n#pragma warning restore AV1235, MA0091\n }\n\n public void RaiseEventWithSender()\n {\n PropertyChanged(this, new PropertyChangedEventArgs(\"\"));\n }\n\n public void RaiseEventWithSpecificSender(object sender)\n {\n#pragma warning disable MA0091\n PropertyChanged(sender, new PropertyChangedEventArgs(\"\"));\n#pragma warning restore MA0091\n }\n\n public void RaiseEventWithSenderAndPropertyName(string propertyName)\n {\n PropertyChanged(this, new PropertyChangedEventArgs(propertyName));\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/DateTimeRangeAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals\n/// \n/// Contains a number of methods to assert that two objects differ in the expected way.\n/// \n/// \n/// You can use the and\n/// for a more fluent\n/// way of specifying a or a .\n/// \n[DebuggerNonUserCode]\npublic class DateTimeRangeAssertions\n where TAssertions : DateTimeAssertions\n{\n #region Private Definitions\n\n private readonly TAssertions parentAssertions;\n private readonly TimeSpanPredicate predicate;\n\n private readonly Dictionary predicates = new()\n {\n [TimeSpanCondition.MoreThan] = new TimeSpanPredicate((ts1, ts2) => ts1 > ts2, \"more than\"),\n [TimeSpanCondition.AtLeast] = new TimeSpanPredicate((ts1, ts2) => ts1 >= ts2, \"at least\"),\n [TimeSpanCondition.Exactly] = new TimeSpanPredicate((ts1, ts2) => ts1 == ts2, \"exactly\"),\n [TimeSpanCondition.Within] = new TimeSpanPredicate((ts1, ts2) => ts1 <= ts2, \"within\"),\n [TimeSpanCondition.LessThan] = new TimeSpanPredicate((ts1, ts2) => ts1 < ts2, \"less than\")\n };\n\n private readonly DateTime? subject;\n private readonly TimeSpan timeSpan;\n\n #endregion\n\n protected internal DateTimeRangeAssertions(TAssertions parentAssertions, AssertionChain assertionChain,\n DateTime? subject,\n TimeSpanCondition condition,\n TimeSpan timeSpan)\n {\n this.parentAssertions = parentAssertions;\n CurrentAssertionChain = assertionChain;\n this.subject = subject;\n this.timeSpan = timeSpan;\n\n predicate = predicates[condition];\n }\n\n /// \n /// Provides access to the that this assertion class was initialized with.\n /// \n public AssertionChain CurrentAssertionChain { get; }\n\n /// \n /// Asserts that a occurs a specified amount of time before another .\n /// \n /// \n /// The to compare the subject with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Before(DateTime target,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected date and/or time {0} to be \" + predicate.DisplayText +\n \" {1} before {2}{reason}, but found a DateTime.\",\n subject, timeSpan, target);\n\n if (CurrentAssertionChain.Succeeded)\n {\n TimeSpan actual = target - subject.Value;\n\n CurrentAssertionChain\n .ForCondition(predicate.IsMatchedBy(actual, timeSpan))\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:the date and time} {0} to be \" + predicate.DisplayText +\n \" {1} before {2}{reason}, but it is \" + PositionRelativeToTarget(subject.Value, target) + \" by {3}.\",\n subject, timeSpan, target, actual.Duration());\n }\n\n return new AndConstraint(parentAssertions);\n }\n\n /// \n /// Asserts that a occurs a specified amount of time after another .\n /// \n /// \n /// The to compare the subject with.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint After(DateTime target,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n CurrentAssertionChain\n .ForCondition(subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected date and/or time {0} to be \" + predicate.DisplayText +\n \" {1} after {2}{reason}, but found a DateTime.\",\n subject, timeSpan, target);\n\n if (CurrentAssertionChain.Succeeded)\n {\n TimeSpan actual = subject.Value - target;\n\n CurrentAssertionChain\n .ForCondition(predicate.IsMatchedBy(actual, timeSpan))\n .BecauseOf(because, becauseArgs)\n .FailWith(\n \"Expected {context:the date and time} {0} to be \" + predicate.DisplayText +\n \" {1} after {2}{reason}, but it is \" + PositionRelativeToTarget(subject.Value, target) + \" by {3}.\",\n subject, timeSpan, target, actual.Duration());\n }\n\n return new AndConstraint(parentAssertions);\n }\n\n private static string PositionRelativeToTarget(DateTime actual, DateTime target)\n {\n return (actual - target) >= TimeSpan.Zero ? \"ahead\" : \"behind\";\n }\n\n /// \n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean Before() or After() instead?\");\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/IValueFormatter.cs", "namespace AwesomeAssertions.Formatting;\n\n/// \n/// Represents a strategy for formatting an arbitrary value into a human-readable string representation.\n/// \n/// \n/// Add custom formatters using .\n/// \npublic interface IValueFormatter\n{\n /// \n /// Indicates\n /// whether the current can handle the specified .\n /// \n /// The value for which to create a .\n /// \n /// if the current can handle the specified value; otherwise, .\n /// \n bool CanHandle(object value);\n\n /// \n /// Returns a human-readable representation of .\n /// \n /// The value to format into a human-readable representation\n /// \n /// An object to write the textual representation to.\n /// \n /// \n /// Contains additional information that the implementation should take into account.\n /// \n /// \n /// Allows the formatter to recursively format any child objects.\n /// \n /// \n /// DO NOT CALL directly, but use \n /// instead. This will ensure cyclic dependencies are properly detected.\n /// Also, the may throw\n /// an that must be ignored by implementations of this interface.\n /// \n void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XmlNodeAssertionSpecs.cs", "using System;\nusing System.Xml;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XmlNodeAssertionSpecs\n{\n public class BeSameAs\n {\n [Fact]\n public void When_asserting_an_xml_node_is_the_same_as_the_same_xml_node_it_should_succeed()\n {\n // Arrange\n var doc = new XmlDocument();\n\n // Act / Assert\n doc.Should().BeSameAs(doc);\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_same_as_a_different_xml_node_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var otherNode = new XmlDocument();\n otherNode.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeSameAs(otherNode, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theDocument to refer to because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_same_as_a_different_xml_node_it_should_fail_with_descriptive_message_and_truncate_xml()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"Some very long text that should be truncated.\");\n var otherNode = new XmlDocument();\n otherNode.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeSameAs(otherNode, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theDocument to refer to because we want to test the failure message, but found Some very long….\");\n }\n\n [Fact]\n public void When_asserting_the_equality_of_an_xml_node_but_is_null_it_should_throw_appropriately()\n {\n // Arrange\n XmlDocument theDocument = null;\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () => theDocument.Should().BeSameAs(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theDocument to refer to *xml*, but found .\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_asserting_an_xml_node_is_null_and_it_is_it_should_succeed()\n {\n // Arrange\n XmlNode node = null;\n\n // Act / Assert\n node.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_null_but_it_is_not_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\");\n\n // Act\n Action act = () =>\n xmlDoc.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_null_but_it_is_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theDocument to be because we want to test the failure message,\" +\n \" but found .\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_asserting_a_non_null_xml_node_is_not_null_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\");\n\n // Act / Assert\n xmlDoc.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_node_is_not_null_it_should_fail()\n {\n // Arrange\n XmlDocument xmlDoc = null;\n\n // Act\n Action act = () =>\n xmlDoc.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_node_is_not_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n XmlDocument theDocument = null;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theDocument not to be because we want to test the failure message.\");\n }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void When_asserting_an_xml_node_is_equivalent_to_the_same_xml_node_it_should_succeed()\n {\n // Arrange\n var doc = new XmlDocument();\n\n // Act / Assert\n doc.Should().BeEquivalentTo(doc);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_with_other_contents_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected local name of element in theDocument at \\\"/\\\" to be \\\"expected\\\" because we want to test the failure message, but found \\\"subject\\\".\");\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_with_same_contents_it_should_succeed()\n {\n // Arrange\n var xml = \"datadata\";\n\n var subject = new XmlDocument();\n subject.LoadXml(xml);\n var expected = new XmlDocument();\n expected.LoadXml(xml);\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_assertion_an_xml_node_is_equivalent_to_a_different_xml_node_with_different_namespace_prefix_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument();\n subject.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_which_differs_only_on_unused_namespace_declaration_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument();\n subject.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_a_different_XmlDocument_which_differs_on_a_child_element_name_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected local name of element in theDocument at \\\"/xml/child\\\" to be \\\"expected\\\" because we want to test the failure message, but found \\\"subject\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_which_differs_on_a_child_element_namespace_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected namespace of element \\\"data\\\" in theDocument at \\\"/xml/child\\\" to be \\\"urn:b\\\" because we want to test the failure message, but found \\\"urn:a\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_contains_an_unexpected_node_type_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"data\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected Element \\\"data\\\" in theDocument at \\\"/xml\\\" because we want to test the failure message, but found content \\\"data\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_contains_extra_elements_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected end of document in theDocument because we want to test the failure message, but found \\\"data\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_lacks_elements_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected \\\"data\\\" in theDocument because we want to test the failure message, but found end of document.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_lacks_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message, but found none.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_has_extra_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect to find attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_has_different_attribute_values_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" to have value \\\"c\\\" because we want to test the failure message, but found \\\"b\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_has_attribute_with_different_namespace_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect to find attribute \\\"ns:a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_which_has_different_text_contents_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"a\");\n var expected = new XmlDocument();\n expected.LoadXml(\"b\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected content to be \\\"b\\\" in theDocument at \\\"/xml\\\" because we want to test the failure message, but found \\\"a\\\".\");\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_equivalent_to_different_xml_node_with_different_comments_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument();\n subject.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_to_different_xml_node_with_different_insignificant_whitespace_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument { PreserveWhitespace = true };\n\n subject.LoadXml(\"\");\n\n var expected = new XmlDocument { PreserveWhitespace = true };\n\n expected.LoadXml(\"\\n \\n \\r\\n\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_that_contains_an_unsupported_node_it_should_throw_a_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n\n // Act\n Action act = () => theDocument.Should().BeEquivalentTo(theDocument);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"CDATA found at /xml is not supported for equivalency comparison.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_node_is_equivalent_that_isnt_it_should_include_the_right_location_in_the_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"\");\n var expected = new XmlDocument();\n expected.LoadXml(\"\");\n\n // Act\n Action act = () => theDocument.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected attribute \\\"c\\\" in theDocument at \\\"/xml/b\\\" to have value \\\"e\\\", but found \\\"d\\\".\");\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void When_asserting_an_xml_node_is_not_equivalent_to_som_other_xml_node_it_should_succeed()\n {\n // Arrange\n var subject = new XmlDocument();\n subject.LoadXml(\"a\");\n var unexpected = new XmlDocument();\n unexpected.LoadXml(\"b\");\n\n // Act / Assert\n subject.Should().NotBeEquivalentTo(unexpected);\n }\n\n [Fact]\n public void When_asserting_an_xml_node_is_not_equivalent_to_same_xml_node_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = new XmlDocument();\n theDocument.LoadXml(\"a\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(theDocument, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect theDocument to be equivalent because we want to test the failure message, but it is.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/FormattedObjectGraph.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// This class is used by the class to collect all the output of the (nested calls of an) into\n/// a the final representation.\n/// \n/// \n/// The will ensure that the number of lines will be limited\n/// to the maximum number of lines provided through its constructor. It will throw\n/// a if the number of lines exceeds the maximum.\n/// \npublic class FormattedObjectGraph\n{\n private readonly int maxLines;\n private readonly List lines = [];\n private readonly StringBuilder lineBuilder = new();\n private int indentation;\n private string lineBuilderWhitespace = string.Empty;\n\n public FormattedObjectGraph(int maxLines)\n {\n this.maxLines = maxLines;\n }\n\n /// \n /// The number of spaces that should be used by every indentation level.\n /// \n public static int SpacesPerIndentation => 4;\n\n /// \n /// Returns the number of lines of text currently in the graph.\n /// \n public int LineCount => lines.Count + (lineBuilder.Length > 0 ? 1 : 0);\n\n /// \n /// Starts a new line with the provided text fragment. Additional text can be added to\n /// that same line through .\n /// \n public void AddFragmentOnNewLine(string fragment)\n {\n FlushCurrentLine();\n\n AddFragment(fragment);\n }\n\n /// \n /// Starts a new line with the provided line of text that does not allow\n /// adding more fragments of text.\n /// \n public void AddLine(string line)\n {\n FlushCurrentLine();\n\n AppendWithoutExceedingMaximumLines(Whitespace + line);\n }\n\n /// \n /// Adds a new fragment of text to the current line.\n /// \n public void AddFragment(string fragment)\n {\n if (lineBuilderWhitespace.Length > 0)\n {\n lineBuilder.Append(lineBuilderWhitespace);\n lineBuilderWhitespace = string.Empty;\n }\n\n lineBuilder.Append(fragment);\n }\n\n /// \n /// Adds a new line if there are no lines and no fragment that would cause a new line.\n /// \n internal void EnsureInitialNewLine()\n {\n if (LineCount == 0)\n {\n InsertInitialNewLine();\n }\n }\n\n /// \n /// Inserts an empty line as the first line unless it is already.\n /// \n private void InsertInitialNewLine()\n {\n if (lines.Count == 0 || !string.IsNullOrEmpty(lines[0]))\n {\n lines.Insert(0, string.Empty);\n lineBuilderWhitespace = Whitespace;\n }\n }\n\n private void FlushCurrentLine()\n {\n string line = lineBuilder.ToString().TrimEnd();\n if (line.Length > 0)\n {\n AppendWithoutExceedingMaximumLines(lineBuilderWhitespace + line);\n }\n\n lineBuilder.Clear();\n lineBuilderWhitespace = Whitespace;\n }\n\n private void AppendWithoutExceedingMaximumLines(string line)\n {\n if (lines.Count == maxLines)\n {\n lines.Add(string.Empty);\n\n lines.Add(\n $\"(Output has exceeded the maximum of {maxLines} lines. \" +\n $\"Increase {nameof(FormattingOptions)}.{nameof(FormattingOptions.MaxLines)} on {nameof(AssertionScope)} or {nameof(AssertionConfiguration)} to include more lines.)\");\n\n throw new MaxLinesExceededException();\n }\n\n lines.Add(line);\n }\n\n /// \n /// Increases the indentation of every line written into this text block until the returned disposable is disposed.\n /// \n /// \n /// The amount of spacing used for each indentation level is determined by .\n /// \n public IDisposable WithIndentation()\n {\n indentation++;\n\n return new Disposable(() =>\n {\n if (indentation > 0)\n {\n indentation--;\n }\n });\n }\n\n /// \n /// Returns the final textual multi-line representation of the object graph.\n /// \n public override string ToString()\n {\n return string.Join(Environment.NewLine, lines.Concat([lineBuilder.ToString()]));\n }\n\n internal PossibleMultilineFragment KeepOnSingleLineAsLongAsPossible()\n {\n return new PossibleMultilineFragment(this);\n }\n\n private string Whitespace => MakeWhitespace(indentation);\n\n private static string MakeWhitespace(int indent) => new(' ', indent * SpacesPerIndentation);\n\n /// \n /// Write fragments that may be on a single line or span multiple lines,\n /// and this is not known until later parts of the fragment are written.\n /// \n internal record PossibleMultilineFragment\n {\n private readonly FormattedObjectGraph parentGraph;\n private readonly int startingLineBuilderIndex;\n private readonly int startingLineCount;\n\n public PossibleMultilineFragment(FormattedObjectGraph parentGraph)\n {\n this.parentGraph = parentGraph;\n startingLineBuilderIndex = parentGraph.lineBuilder.Length;\n startingLineCount = parentGraph.lines.Count;\n }\n\n /// \n /// Write the fragment at the position the graph was in when this instance was created.\n ///\n /// \n /// If more lines have been added since this instance was created then write the\n /// fragment on a new line, otherwise write it on the same line.\n /// \n /// \n internal void AddStartingLineOrFragment(string fragment)\n {\n if (FormatOnSingleLine)\n {\n parentGraph.lineBuilder.Insert(startingLineBuilderIndex, fragment);\n }\n else\n {\n parentGraph.InsertInitialNewLine();\n parentGraph.lines.Insert(startingLineCount + 1, parentGraph.Whitespace + fragment);\n InsertAtStartOfLine(startingLineCount + 2, MakeWhitespace(1));\n }\n }\n\n private bool FormatOnSingleLine => parentGraph.lines.Count == startingLineCount;\n\n private void InsertAtStartOfLine(int lineIndex, string insertion)\n {\n if (!parentGraph.lines[lineIndex].StartsWith(insertion, StringComparison.Ordinal))\n {\n parentGraph.lines[lineIndex] = parentGraph.lines[lineIndex].Insert(0, insertion);\n }\n }\n\n public void InsertLineOrFragment(string fragment)\n {\n if (FormatOnSingleLine)\n {\n parentGraph.lineBuilder.Insert(startingLineBuilderIndex, fragment);\n }\n else\n {\n parentGraph.lines[startingLineCount] = parentGraph.lines[startingLineCount]\n .Insert(startingLineBuilderIndex, InsertNewLineIntoFragment(fragment));\n }\n }\n\n private string InsertNewLineIntoFragment(string fragment)\n {\n if (StartingLineHasBeenAddedTo())\n {\n return fragment + Environment.NewLine + MakeWhitespace(parentGraph.indentation + 1);\n }\n\n return fragment;\n }\n\n private bool StartingLineHasBeenAddedTo() => parentGraph.lines[startingLineCount].Length > startingLineBuilderIndex;\n\n /// \n /// If more lines have been added since this instance was created then write the\n /// fragment on a new line, otherwise write it on the same line.\n /// \n internal void AddLineOrFragment(string fragment)\n {\n if (FormatOnSingleLine)\n {\n parentGraph.AddFragment(fragment);\n }\n else\n {\n parentGraph.AddFragmentOnNewLine(fragment);\n }\n }\n\n internal void AddFragment(string fragment) => parentGraph.AddFragment(fragment);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/DelegateAssertionsBase.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions.Specialized;\n\n/// \n/// Contains a number of methods to assert that a method yields the expected result.\n/// \n[DebuggerNonUserCode]\npublic abstract class DelegateAssertionsBase\n : ReferenceTypeAssertions>\n where TDelegate : Delegate\n where TAssertions : DelegateAssertionsBase\n{\n private readonly AssertionChain assertionChain;\n\n private protected IExtractExceptions Extractor { get; }\n\n private protected DelegateAssertionsBase(TDelegate @delegate, IExtractExceptions extractor, AssertionChain assertionChain,\n IClock clock)\n : base(@delegate, assertionChain)\n {\n this.assertionChain = assertionChain;\n Extractor = extractor ?? throw new ArgumentNullException(nameof(extractor));\n Clock = clock ?? throw new ArgumentNullException(nameof(clock));\n }\n\n private protected IClock Clock { get; }\n\n protected ExceptionAssertions ThrowInternal(\n Exception exception,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where TException : Exception\n {\n TException[] expectedExceptions = Extractor.OfType(exception).ToArray();\n\n assertionChain\n .BecauseOf(because, becauseArgs)\n .WithExpectation(\"Expected a <{0}> to be thrown{reason}, \", typeof(TException), chain => chain\n .ForCondition(exception is not null)\n .FailWith(\"but no exception was thrown.\")\n .Then\n .ForCondition(expectedExceptions.Length > 0)\n .FailWith(\"but found <{0}>:\" + Environment.NewLine + \"{1}.\",\n exception?.GetType(),\n exception));\n\n return new ExceptionAssertions(expectedExceptions, assertionChain);\n }\n\n protected AndConstraint NotThrowInternal(Exception exception, [StringSyntax(\"CompositeFormat\")] string because,\n object[] becauseArgs)\n {\n assertionChain\n .ForCondition(exception is null)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect any exception{reason}, but found {0}.\", exception);\n\n return new AndConstraint((TAssertions)this);\n }\n\n protected AndConstraint NotThrowInternal(Exception exception,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n where TException : Exception\n {\n IEnumerable exceptions = Extractor.OfType(exception);\n\n assertionChain\n .ForCondition(!exceptions.Any())\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {0}{reason}, but found {1}.\", typeof(TException), exception);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AndWhichConstraint.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Provides a property that can be used in chained assertions where the prior assertions returns a\n/// single object that the assertion continues on.\n/// \npublic class AndWhichConstraint : AndConstraint\n{\n private readonly AssertionChain assertionChain;\n private readonly string pathPostfix;\n private readonly Lazy getSubject;\n\n /// \n /// Creates an object that allows continuing an assertion executed through and\n /// which resulted in a single .\n /// \n public AndWhichConstraint(TParent parent, TSubject subject)\n : base(parent)\n {\n getSubject = new Lazy(() => subject);\n }\n\n /// \n /// Creates an object that allows continuing an assertion executed through and\n /// which resulted in a single on an existing , but where\n /// the previous caller identifier is post-fixed with .\n /// \n public AndWhichConstraint(TParent parent, TSubject subject, AssertionChain assertionChain, string pathPostfix = \"\")\n : base(parent)\n {\n getSubject = new Lazy(() => subject);\n\n this.assertionChain = assertionChain;\n this.pathPostfix = pathPostfix;\n }\n\n /// \n /// Creates an object that allows continuing an assertion executed through and\n /// which resulted in a potential collection of objects through .\n /// \n /// \n /// If contains more than one object, a clear exception is thrown.\n /// \n public AndWhichConstraint(TParent parent, IEnumerable subjects)\n : base(parent)\n {\n getSubject = new Lazy(() => Single(subjects));\n }\n\n /// \n /// Creates an object that allows continuing an assertion executed through and\n /// which resulted in a potential collection of objects through on an\n /// existing , but where\n /// the previous caller identifier is post-fixed with .\n /// \n /// \n /// If contains more than one object, a clear exception is thrown.\n /// \n public AndWhichConstraint(TParent parent, IEnumerable subjects, AssertionChain assertionChain, string pathPostfix)\n : base(parent)\n {\n getSubject = new Lazy(() => Single(subjects));\n\n this.assertionChain = assertionChain;\n this.pathPostfix = pathPostfix;\n }\n\n private static TSubject Single(IEnumerable subjects)\n {\n TSubject[] matchedElements = subjects.ToArray();\n\n if (matchedElements.Length > 1)\n {\n string foundObjects = string.Join(Environment.NewLine,\n matchedElements.Select(ele => \"\\t\" + Formatter.ToString(ele)));\n\n string message = \"More than one object found. AwesomeAssertions cannot determine which object is meant.\"\n + $\" Found objects:{Environment.NewLine}{foundObjects}\";\n\n AssertionEngine.TestFramework.Throw(message);\n }\n\n return matchedElements.Single();\n }\n\n /// \n /// Returns the single result of a prior assertion that is used to select a nested or collection item.\n /// \n /// \n /// Just a convenience property that returns the same value as .\n /// \n public TSubject Subject => Which;\n\n /// \n /// Returns the single result of a prior assertion that is used to select a nested or collection item.\n /// \n public TSubject Which\n {\n get\n {\n if (pathPostfix is not null and not \"\")\n {\n assertionChain.WithCallerPostfix(pathPostfix).ReuseOnce();\n }\n\n return getSubject.Value;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/SingleLineCommentParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class SingleLineCommentParsingStrategy : IParsingStrategy\n{\n private bool isCommentContext;\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (isCommentContext)\n {\n return ParsingState.GoToNextSymbol;\n }\n\n var doesSymbolStartComment = symbol is '/' && statement is [.., '/'];\n\n if (!doesSymbolStartComment)\n {\n return ParsingState.InProgress;\n }\n\n isCommentContext = true;\n statement.Remove(statement.Length - 1, 1);\n return ParsingState.GoToNextSymbol;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return isCommentContext;\n }\n\n public void NotifyEndOfLineReached()\n {\n if (isCommentContext)\n {\n isCommentContext = false;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/TestFrameworkFactory.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Configuration;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Determines the test framework, either by scanning the current app domain for known test framework assemblies or by\n/// passing the framework name directly.\n/// \ninternal static class TestFrameworkFactory\n{\n private static readonly Dictionary Frameworks = new()\n {\n [TestFramework.MSpec] = new MSpecFramework(),\n [TestFramework.NUnit] = new NUnitTestFramework(),\n [TestFramework.MsTest] = new MSTestFrameworkV2(),\n\n // Keep TUnitFramework and XUnitTestFramework last as they use a try/catch approach\n [TestFramework.TUnit] = new TUnitFramework(),\n [TestFramework.XUnit2] = new XUnitTestFramework(\"xunit.assert\"),\n [TestFramework.XUnit3] = new XUnitTestFramework(\"xunit.v3.assert\"),\n };\n\n public static ITestFramework GetFramework(TestFramework? testFrameWork)\n {\n ITestFramework framework = null;\n\n if (testFrameWork is not null)\n {\n framework = AttemptToDetectUsingSetting((TestFramework)testFrameWork);\n }\n\n framework ??= AttemptToDetectUsingDynamicScanning();\n\n return framework ?? new FallbackTestFramework();\n }\n\n private static ITestFramework AttemptToDetectUsingSetting(TestFramework framework)\n {\n if (!Frameworks.TryGetValue(framework, out ITestFramework implementation))\n {\n string frameworks = string.Join(\", \", Frameworks.Keys);\n var message =\n $\"AwesomeAssertions was configured to use the test framework '{framework}' but this is not supported. \" +\n $\"Please use one of the supported frameworks: {frameworks}.\";\n\n throw new InvalidOperationException(message);\n }\n\n if (!implementation.IsAvailable)\n {\n string frameworks = string.Join(\", \", Frameworks.Keys);\n\n var innerMessage = implementation is LateBoundTestFramework lateBoundTestFramework\n ? $\"the required assembly '{lateBoundTestFramework.AssemblyName}' could not be found\"\n : \"it could not be found\";\n\n var message =\n $\"AwesomeAssertions was configured to use the test framework '{framework}' but {innerMessage}. \" +\n $\"Please use one of the supported frameworks: {frameworks}.\";\n\n throw new InvalidOperationException(message);\n }\n\n return implementation;\n }\n\n private static ITestFramework AttemptToDetectUsingDynamicScanning()\n {\n return Frameworks.Values.FirstOrDefault(framework => framework.IsAvailable);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringContainsStrategy.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringContainsStrategy : IStringComparisonStrategy\n{\n private readonly IEqualityComparer comparer;\n private readonly OccurrenceConstraint occurrenceConstraint;\n\n public StringContainsStrategy(IEqualityComparer comparer, OccurrenceConstraint occurrenceConstraint)\n {\n this.comparer = comparer;\n this.occurrenceConstraint = occurrenceConstraint;\n }\n\n public string ExpectationDescription => \"Expected {context:string} {0} to contain the equivalent of \";\n\n public void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected)\n {\n int actual = subject.CountSubstring(expected, comparer);\n\n assertionChain\n .ForConstraint(occurrenceConstraint, actual)\n .FailWith(\n $\"{ExpectationDescription}{{1}} {{expectedOccurrence}}{{reason}}, but found it {actual.Times()}.\",\n subject, expected);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableDateOnlyAssertions.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableDateOnlyAssertions : NullableDateOnlyAssertions\n{\n public NullableDateOnlyAssertions(DateOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableDateOnlyAssertions : DateOnlyAssertions\n where TAssertions : NullableDateOnlyAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableDateOnlyAssertions(DateOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable date} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:nullable date} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableTimeOnlyAssertions.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableTimeOnlyAssertions : NullableTimeOnlyAssertions\n{\n public NullableTimeOnlyAssertions(TimeOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableTimeOnlyAssertions : TimeOnlyAssertions\n where TAssertions : NullableTimeOnlyAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableTimeOnlyAssertions(TimeOnly? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable time} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:nullable time} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/ContextDataDictionary.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents a collection of data items that are associated with an .\n/// \ninternal class ContextDataDictionary\n{\n private readonly List items = [];\n\n public IDictionary GetReportable()\n {\n return items.Where(item => item.Reportable).ToDictionary(item => item.Key, item => item.Value);\n }\n\n public string AsStringOrDefault(string key)\n {\n DataItem item = items.SingleOrDefault(i => i.Key == key);\n\n if (item is not null)\n {\n if (item.RequiresFormatting)\n {\n return Formatter.ToString(item.Value);\n }\n\n return item.Value.ToString();\n }\n\n return null;\n }\n\n public void Add(ContextDataDictionary contextDataDictionary)\n {\n foreach (DataItem item in contextDataDictionary.items)\n {\n Add(item.Clone());\n }\n }\n\n public void Add(DataItem item)\n {\n int existingItemIndex = items.FindIndex(i => i.Key == item.Key);\n if (existingItemIndex >= 0)\n {\n items[existingItemIndex] = item;\n }\n else\n {\n items.Add(item);\n }\n }\n\n public class DataItem(string key, object value, bool reportable, bool requiresFormatting)\n {\n public string Key { get; } = key;\n\n public object Value { get; } = value;\n\n public bool Reportable { get; } = reportable;\n\n public bool RequiresFormatting { get; } = requiresFormatting;\n\n public DataItem Clone()\n {\n object clone = Value is ICloneable2 cloneable ? cloneable.Clone() : Value;\n return new DataItem(Key, clone, Reportable, RequiresFormatting);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableEnumAssertions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \npublic class NullableEnumAssertions : NullableEnumAssertions>\n where TEnum : struct, Enum\n{\n public NullableEnumAssertions(TEnum? subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \npublic class NullableEnumAssertions : EnumAssertions\n where TEnum : struct, Enum\n where TAssertions : NullableEnumAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableEnumAssertions(TEnum? subject, AssertionChain assertionChain)\n : base(subject, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable enum} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndWhichConstraint((TAssertions)this, Subject.GetValueOrDefault(), assertionChain, \".Value\");\n }\n\n /// \n /// Asserts that a nullable is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndWhichConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:nullable enum} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/QuotesParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class QuotesParsingStrategy : IParsingStrategy\n{\n private char isQuoteEscapeSymbol = '\\\\';\n private bool isQuoteContext;\n private char? previousChar;\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (symbol is '\"')\n {\n if (isQuoteContext)\n {\n if (previousChar != isQuoteEscapeSymbol)\n {\n isQuoteContext = false;\n isQuoteEscapeSymbol = '\\\\';\n previousChar = null;\n statement.Append(symbol);\n return ParsingState.GoToNextSymbol;\n }\n }\n else\n {\n isQuoteContext = true;\n\n if (IsVerbatim(statement))\n {\n isQuoteEscapeSymbol = '\"';\n }\n }\n }\n\n if (isQuoteContext)\n {\n statement.Append(symbol);\n }\n\n previousChar = symbol;\n return isQuoteContext ? ParsingState.GoToNextSymbol : ParsingState.InProgress;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return isQuoteContext;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n\n private bool IsVerbatim(StringBuilder statement)\n {\n return (previousChar is '@' && statement is [.., '$', '@'])\n || (previousChar is '$' && statement is [.., '@', '$']);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableDateTimeAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableDateTimeAssertions : NullableDateTimeAssertions\n{\n public NullableDateTimeAssertions(DateTime? expected, AssertionChain assertionChain)\n : base(expected, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableDateTimeAssertions : DateTimeAssertions\n where TAssertions : NullableDateTimeAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableDateTimeAssertions(DateTime? expected, AssertionChain assertionChain)\n : base(expected, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:nullable date and time} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:nullable date and time} to have a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableDateTimeOffsetAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableDateTimeOffsetAssertions : NullableDateTimeOffsetAssertions\n{\n public NullableDateTimeOffsetAssertions(DateTimeOffset? expected, AssertionChain assertionChain)\n : base(expected, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableDateTimeOffsetAssertions : DateTimeOffsetAssertions\n where TAssertions : NullableDateTimeOffsetAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableDateTimeOffsetAssertions(DateTimeOffset? expected, AssertionChain assertionChain)\n : base(expected, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:variable} to have a value{reason}, but found {0}\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect {context:variable} to have a value{reason}, but found {0}\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/EnumerableExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class EnumerableExtensions\n{\n public static ICollection ConvertOrCastToCollection(this IEnumerable source)\n {\n return source as ICollection ?? source.ToList();\n }\n\n public static IList ConvertOrCastToList(this IEnumerable source)\n {\n return source as IList ?? source.ToList();\n }\n\n /// \n /// Searches for the first different element in two sequences using specified \n /// \n /// The type of the elements of the sequence.\n /// The type of the elements of the sequence.\n /// The first sequence to compare.\n /// The second sequence to compare.\n /// Method that is used to compare 2 elements with the same index.\n /// Index at which two sequences have elements that are not equal, or -1 if enumerables are equal\n public static int IndexOfFirstDifferenceWith(this IEnumerable first, IEnumerable second,\n Func equalityComparison)\n {\n using IEnumerator firstEnumerator = first.GetEnumerator();\n using IEnumerator secondEnumerator = second.GetEnumerator();\n int index = 0;\n\n while (true)\n {\n bool isFirstCompleted = !firstEnumerator.MoveNext();\n bool isSecondCompleted = !secondEnumerator.MoveNext();\n\n if (isFirstCompleted && isSecondCompleted)\n {\n return -1;\n }\n\n if (isFirstCompleted != isSecondCompleted)\n {\n return index;\n }\n\n if (!equalityComparison(firstEnumerator.Current, secondEnumerator.Current))\n {\n return index;\n }\n\n index++;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/SubsequentOrderingAssertions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Collections;\n\n[DebuggerNonUserCode]\npublic class SubsequentOrderingAssertions\n : GenericCollectionAssertions, T>\n{\n private readonly IOrderedEnumerable previousOrderedEnumerable;\n private bool subsequentOrdering;\n\n public SubsequentOrderingAssertions(IEnumerable actualValue, IOrderedEnumerable previousOrderedEnumerable, AssertionChain assertionChain)\n : base(actualValue, assertionChain)\n {\n this.previousOrderedEnumerable = previousOrderedEnumerable;\n }\n\n /// \n /// Asserts that a subsequence is ordered in ascending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> ThenBeInAscendingOrder(\n Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return ThenBeInAscendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a subsequence is ordered in ascending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> ThenBeInAscendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return ThenBeOrderedBy(propertyExpression, comparer, SortOrder.Ascending, because, becauseArgs);\n }\n\n /// \n /// Asserts that a subsequence is ordered in descending order according to the value of the specified\n /// .\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n public AndConstraint> ThenBeInDescendingOrder(\n Expression> propertyExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return ThenBeInDescendingOrder(propertyExpression, GetComparer(), because, becauseArgs);\n }\n\n /// \n /// Asserts that a subsequence is ordered in descending order according to the value of the specified\n /// and implementation.\n /// \n /// \n /// A lambda expression that references the property that should be used to determine the expected ordering.\n /// \n /// \n /// The object that should be used to determine the expected ordering.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// \n /// Empty and single element collections are considered to be ordered both in ascending and descending order at the same time.\n /// \n /// is .\n public AndConstraint> ThenBeInDescendingOrder(\n Expression> propertyExpression, IComparer comparer,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(comparer, nameof(comparer),\n \"Cannot assert collection ordering without specifying a comparer.\");\n\n return ThenBeOrderedBy(propertyExpression, comparer, SortOrder.Descending, because, becauseArgs);\n }\n\n private AndConstraint> ThenBeOrderedBy(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n [StringSyntax(\"CompositeFormat\")] string because,\n object[] becauseArgs)\n {\n subsequentOrdering = true;\n return BeOrderedBy(propertyExpression, comparer, direction, because, becauseArgs);\n }\n\n internal sealed override IOrderedEnumerable GetOrderedEnumerable(\n Expression> propertyExpression,\n IComparer comparer,\n SortOrder direction,\n ICollection unordered)\n {\n if (subsequentOrdering)\n {\n Func keySelector = propertyExpression.Compile();\n\n IOrderedEnumerable expectation = direction == SortOrder.Ascending\n ? previousOrderedEnumerable.ThenBy(keySelector, comparer)\n : previousOrderedEnumerable.ThenByDescending(keySelector, comparer);\n\n return expectation;\n }\n\n return base.GetOrderedEnumerable(propertyExpression, comparer, direction, unordered);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeSelectorSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Types;\nusing Internal.AbstractAndNotAbstractClasses.Test;\nusing Internal.InterfaceAndClasses.Test;\nusing Internal.Main.Test;\nusing Internal.NotOnlyClasses.Test;\nusing Internal.Other.Test;\nusing Internal.Other.Test.Common;\nusing Internal.SealedAndNotSealedClasses.Test;\nusing Internal.StaticAndNonStaticClasses.Test;\nusing Internal.UnwrapSelectorTestTypes.Test;\nusing Internal.ValueTypesAndNotValueTypes.Test;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Types\n{\n public class TypeSelectorSpecs\n {\n [Fact]\n public void When_type_selector_is_created_with_a_null_type_it_should_throw()\n {\n // Arrange\n TypeSelector propertyInfoSelector;\n\n // Act\n Action act = () => propertyInfoSelector = new TypeSelector((Type)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_type_selector_is_created_with_a_null_type_list_it_should_throw()\n {\n // Arrange\n TypeSelector propertyInfoSelector;\n\n // Act\n Action act = () => propertyInfoSelector = new TypeSelector((Type[])null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_type_selector_is_null_then_should_should_throw()\n {\n // Arrange\n TypeSelector propertyInfoSelector = null;\n\n // Act\n var act = () => propertyInfoSelector.Should();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"typeSelector\");\n }\n\n [Fact]\n public void When_selecting_types_that_derive_from_a_specific_class_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassDerivedFromSomeBaseClass).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatDeriveFrom();\n\n // Assert\n types.Should().ContainSingle()\n .Which.Should().Be(typeof(ClassDerivedFromSomeBaseClass));\n }\n\n [Fact]\n public void When_selecting_types_that_derive_from_a_specific_generic_class_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassDerivedFromSomeGenericBaseClass).Assembly;\n\n // Act\n TypeSelector types = AllTypes.From(assembly).ThatDeriveFrom>();\n\n // Assert\n types.ToArray().Should().ContainSingle()\n .Which.Should().Be(typeof(ClassDerivedFromSomeGenericBaseClass));\n }\n\n [Fact]\n public void When_selecting_types_that_do_not_derive_from_a_specific_class_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassDerivedFromSomeBaseClass).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.Main.Test\")\n .ThatDoNotDeriveFrom();\n\n // Assert\n types.Should()\n .HaveCount(12);\n }\n\n [Fact]\n public void When_selecting_types_that_do_not_derive_from_a_specific_generic_class_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassDerivedFromSomeGenericBaseClass).Assembly;\n\n // Act\n TypeSelector types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.Main.Test\")\n .ThatDoNotDeriveFrom>();\n\n // Assert\n types.ToArray().Should()\n .HaveCount(12);\n }\n\n [Fact]\n public void When_selecting_types_that_implement_a_specific_interface_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassImplementingSomeInterface).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatImplement();\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(ClassImplementingSomeInterface))\n .And.Contain(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_selecting_types_that_do_not_implement_a_specific_interface_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassImplementingSomeInterface).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.Main.Test\")\n .ThatDoNotImplement();\n\n // Assert\n types.Should()\n .HaveCount(10);\n }\n\n [Fact]\n public void When_selecting_types_that_are_decorated_with_a_specific_attribute_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatAreDecoratedWith();\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(ClassWithSomeAttribute))\n .And.Contain(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_decorated_with_a_specific_attribute_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatAreNotDecoratedWith();\n\n // Assert\n types.Should()\n .NotBeEmpty()\n .And.NotContain(typeof(ClassWithSomeAttribute))\n .And.NotContain(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_selecting_types_from_specific_namespace_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatAreInNamespace(\"Internal.Other.Test\");\n\n // Assert\n types.Should().ContainSingle()\n .Which.Should().Be(typeof(SomeOtherClass));\n }\n\n [Fact]\n public void When_selecting_types_other_than_from_specific_namespace_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreUnderNamespace(\"Internal.Other\")\n .ThatAreNotInNamespace(\"Internal.Other.Test\");\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(SomeCommonClass));\n }\n\n [Fact]\n public void When_selecting_types_from_specific_namespace_or_sub_namespaces_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly).ThatAreUnderNamespace(\"Internal.Other.Test\");\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(SomeOtherClass))\n .And.Contain(typeof(SomeCommonClass));\n }\n\n [Fact]\n public void When_selecting_types_other_than_from_specific_namespace_or_sub_namespaces_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreUnderNamespace(\"Internal.Other\")\n .ThatAreNotUnderNamespace(\"Internal.Other.Test\");\n\n // Assert\n types.Should()\n .BeEmpty();\n }\n\n [Fact]\n public void When_combining_type_selection_filters_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreDecoratedWith()\n .ThatImplement()\n .ThatAreInNamespace(\"Internal.Main.Test\");\n\n // Assert\n types.Should().ContainSingle()\n .Which.Should().Be(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_using_the_single_type_ctor_of_TypeSelector_it_should_contain_that_singe_type()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttribute);\n\n // Act\n var typeSelector = new TypeSelector(type);\n\n // Assert\n typeSelector\n .ToArray()\n .Should()\n .ContainSingle()\n .Which.Should().Be(type);\n }\n\n [Fact]\n public void When_selecting_types_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreDecoratedWith();\n\n // Assert\n types.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_types_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreDecoratedWithOrInherit();\n\n // Assert\n types.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_types_not_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreNotDecoratedWith();\n\n // Assert\n types.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_types_not_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreNotDecoratedWithOrInherit();\n\n // Assert\n types.Should().BeEmpty();\n }\n\n [Fact]\n public void When_selecting_types_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeNonInheritableAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreDecoratedWith();\n\n // Assert\n types.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_types_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeNonInheritableAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreDecoratedWithOrInherit();\n\n // Assert\n types.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_types_not_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeNonInheritableAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreNotDecoratedWith();\n\n // Assert\n types.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_types_not_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_types()\n {\n // Arrange\n Type type = typeof(ClassWithSomeNonInheritableAttributeDerived);\n\n // Act\n IEnumerable types = type.Types().ThatAreNotDecoratedWithOrInherit();\n\n // Assert\n types.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_global_types_from_global_namespace_it_should_succeed()\n {\n // Arrange\n TypeSelector types = new[] { typeof(ClassInGlobalNamespace) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreUnderNamespace(null);\n\n // Assert\n filteredTypes.As>().Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_global_types_not_from_global_namespace_it_should_succeed()\n {\n // Arrange\n TypeSelector types = new[] { typeof(ClassInGlobalNamespace) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreNotUnderNamespace(null);\n\n // Assert\n filteredTypes.As>().Should().BeEmpty();\n }\n\n [Fact]\n public void When_selecting_local_types_from_global_namespace_it_should_succeed()\n {\n // Arrange\n TypeSelector types = new[] { typeof(SomeBaseClass) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreUnderNamespace(null);\n\n // Assert\n filteredTypes.As>().Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_local_types_not_from_global_namespace_it_should_succeed()\n {\n // Arrange\n TypeSelector types = new[] { typeof(SomeBaseClass) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreNotUnderNamespace(null);\n\n // Assert\n filteredTypes.As>().Should().BeEmpty();\n }\n\n [Fact]\n public void When_selecting_a_prefix_of_a_namespace_it_should_not_match()\n {\n // Arrange\n TypeSelector types = new[] { typeof(SomeBaseClass) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreUnderNamespace(\"Internal.Main.Tes\");\n\n // Assert\n filteredTypes.As>().Should().BeEmpty();\n }\n\n [Fact]\n public void When_deselecting_a_prefix_of_a_namespace_it_should_not_match()\n {\n // Arrange\n TypeSelector types = new[] { typeof(SomeBaseClass) }.Types();\n\n // Act\n TypeSelector filteredTypes = types.ThatAreNotUnderNamespace(\"Internal.Main.Tes\");\n\n // Assert\n filteredTypes.As>().Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_types_that_are_classes_it_should_return_the_correct_types()\n {\n // Arrange\n TypeSelector types = new[]\n {\n typeof(NotOnlyClassesClass), typeof(NotOnlyClassesEnumeration), typeof(INotOnlyClassesInterface)\n }.Types();\n\n // Act\n IEnumerable filteredTypes = types.ThatAreClasses();\n\n // Assert\n filteredTypes.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(NotOnlyClassesClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(NotOnlyClassesClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.NotOnlyClasses.Test\")\n .ThatAreNotClasses();\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(INotOnlyClassesInterface))\n .And.Contain(typeof(NotOnlyClassesEnumeration));\n }\n\n [Fact]\n public void When_selecting_types_that_are_value_types_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(InternalEnumValueType).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.ValueTypesAndNotValueTypes.Test\")\n .ThatAreValueTypes();\n\n // Assert\n types.Should()\n .HaveCount(3);\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_value_types_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(InternalEnumValueType).Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.ValueTypesAndNotValueTypes.Test\")\n .ThatAreNotValueTypes();\n\n // Assert\n types.Should()\n .HaveCount(3);\n }\n\n [Fact]\n public void When_selecting_types_that_are_abstract_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(AbstractClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.AbstractAndNotAbstractClasses.Test\")\n .ThatAreAbstract();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(AbstractClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_abstract_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(NotAbstractClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.AbstractAndNotAbstractClasses.Test\")\n .ThatAreNotAbstract();\n\n // Assert\n types.Should()\n .HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_types_that_are_sealed_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(SealedClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.SealedAndNotSealedClasses.Test\")\n .ThatAreSealed();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(SealedClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_sealed_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(NotSealedClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.SealedAndNotSealedClasses.Test\")\n .ThatAreNotSealed();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(NotSealedClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_static_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(StaticClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.StaticAndNonStaticClasses.Test\")\n .ThatAreStatic();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(StaticClass));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_static_classes_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(StaticClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.StaticAndNonStaticClasses.Test\")\n .ThatAreNotStatic();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(NotAStaticClass));\n }\n\n [Fact]\n public void When_selecting_types_with_predicate_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(SomeBaseClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatSatisfy(t => t.GetCustomAttribute() is not null);\n\n // Assert\n types.Should()\n .HaveCount(3)\n .And.Contain(typeof(ClassWithSomeAttribute))\n .And.Contain(typeof(ClassWithSomeAttributeDerived))\n .And.Contain(typeof(ClassWithSomeAttributeThatImplementsSomeInterface));\n }\n\n [Fact]\n public void When_unwrap_task_types_it_should_return_the_correct_types()\n {\n IEnumerable types = typeof(ClassToExploreUnwrappedTaskTypes)\n .Methods()\n .ReturnTypes()\n .UnwrapTaskTypes();\n\n types.Should()\n .BeEquivalentTo([typeof(int), typeof(void), typeof(void), typeof(string), typeof(bool)]);\n }\n\n [Fact]\n public void When_unwrap_enumerable_types_it_should_return_the_correct_types()\n {\n IEnumerable types = typeof(ClassToExploreUnwrappedEnumerableTypes)\n .Methods()\n .ReturnTypes()\n .UnwrapEnumerableTypes();\n\n types.Should()\n .HaveCount(4)\n .And.Contain(typeof(IEnumerable))\n .And.Contain(typeof(bool))\n .And.Contain(typeof(int))\n .And.Contain(typeof(string));\n }\n\n [Fact]\n public void When_selecting_types_that_are_interfaces_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(InternalInterface).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.InterfaceAndClasses.Test\")\n .ThatAreInterfaces();\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(InternalInterface));\n }\n\n [Fact]\n public void When_selecting_types_that_are_not_interfaces_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = typeof(InternalNotInterfaceClass).GetTypeInfo().Assembly;\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.InterfaceAndClasses.Test\")\n .ThatAreNotInterfaces();\n\n // Assert\n types.Should()\n .HaveCount(2)\n .And.Contain(typeof(InternalNotInterfaceClass))\n .And.Contain(typeof(InternalAbstractClass));\n }\n\n [Fact]\n public void When_selecting_types_by_access_modifier_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = Assembly.GetExecutingAssembly();\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.PublicAndInternalClasses.Test\")\n .ThatHaveAccessModifier(CSharpAccessModifier.Public);\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(Internal.PublicAndInternalClasses.Test.PublicClass));\n }\n\n [Fact]\n public void When_selecting_types_excluding_access_modifier_it_should_return_the_correct_types()\n {\n // Arrange\n Assembly assembly = Assembly.GetExecutingAssembly();\n\n // Act\n IEnumerable types = AllTypes.From(assembly)\n .ThatAreInNamespace(\"Internal.PublicAndInternalClasses.Test\")\n .ThatDoNotHaveAccessModifier(CSharpAccessModifier.Public);\n\n // Assert\n types.Should()\n .ContainSingle()\n .Which.Should().Be(typeof(Internal.PublicAndInternalClasses.Test.InternalClass));\n }\n }\n}\n\n#region Internal classes used in unit tests\n\nnamespace Internal.Main.Test\n{\n internal class SomeBaseClass;\n\n internal class ClassDerivedFromSomeBaseClass : SomeBaseClass;\n\n internal class SomeGenericBaseClass\n {\n public T Value { get; set; }\n }\n\n internal class ClassDerivedFromSomeGenericBaseClass : SomeGenericBaseClass;\n\n internal interface ISomeInterface;\n\n internal class ClassImplementingSomeInterface : ISomeInterface;\n\n [AttributeUsage(AttributeTargets.Class)]\n internal class SomeAttribute : Attribute;\n\n [AttributeUsage(AttributeTargets.Class, Inherited = false)]\n internal class SomeNonInheritableAttribute : Attribute;\n\n [Some]\n internal class ClassWithSomeAttribute\n {\n public string Property1 { get; set; }\n\n public void Method1()\n {\n }\n }\n\n internal class ClassWithSomeAttributeDerived : ClassWithSomeAttribute;\n\n [SomeNonInheritable]\n internal class ClassWithSomeNonInheritableAttribute\n {\n public string Property1 { get; set; }\n\n public void Method1()\n {\n }\n }\n\n internal class ClassWithSomeNonInheritableAttributeDerived : ClassWithSomeNonInheritableAttribute;\n\n [Some]\n internal class ClassWithSomeAttributeThatImplementsSomeInterface : ISomeInterface\n {\n public string Property2 { get; set; }\n\n public void Method2()\n {\n }\n }\n}\n\nnamespace Internal.Other.Test\n{\n internal class SomeOtherClass;\n}\n\nnamespace Internal.Other.Test.Common\n{\n internal class SomeCommonClass;\n}\n\nnamespace Internal.NotOnlyClasses.Test\n{\n internal class NotOnlyClassesClass;\n\n internal enum NotOnlyClassesEnumeration;\n\n internal interface INotOnlyClassesInterface;\n}\n\nnamespace Internal.StaticAndNonStaticClasses.Test\n{\n internal static class StaticClass;\n\n internal class NotAStaticClass;\n}\n\nnamespace Internal.AbstractAndNotAbstractClasses.Test\n{\n internal abstract class AbstractClass;\n\n internal class NotAbstractClass;\n\n internal static class NotAbstractStaticClass;\n}\n\nnamespace Internal.InterfaceAndClasses.Test\n{\n internal interface InternalInterface;\n\n internal abstract class InternalAbstractClass;\n\n internal class InternalNotInterfaceClass;\n}\n\nnamespace Internal.UnwrapSelectorTestTypes.Test\n{\n internal class ClassToExploreUnwrappedTaskTypes\n {\n internal int DoWithInt() { return default; }\n\n internal Task DoWithTask() { return Task.CompletedTask; }\n\n internal ValueTask DoWithValueTask() { return default; }\n\n internal Task DoWithIntTask() { return Task.FromResult(string.Empty); }\n\n internal ValueTask DoWithBoolValueTask() { return new ValueTask(false); }\n }\n\n internal class ClassToExploreUnwrappedEnumerableTypes\n {\n internal IEnumerable DoWithTask() { return default; }\n\n internal List DoWithIntTask() { return default; }\n\n internal ClassImplementingMultipleEnumerable DoWithBoolValueTask() { return default; }\n }\n\n internal class ClassImplementingMultipleEnumerable : IEnumerable, IEnumerable\n {\n private readonly IEnumerable integers = [];\n private readonly IEnumerable strings = [];\n\n public IEnumerator GetEnumerator() => integers.GetEnumerator();\n\n IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)integers).GetEnumerator();\n\n IEnumerator IEnumerable.GetEnumerator() => strings.GetEnumerator();\n }\n}\n\nnamespace Internal.SealedAndNotSealedClasses.Test\n{\n internal sealed class SealedClass;\n\n internal class NotSealedClass;\n}\n\nnamespace Internal.PublicAndInternalClasses.Test\n{\n public class PublicClass;\n\n internal class InternalClass;\n}\n\nnamespace Internal.ValueTypesAndNotValueTypes.Test\n{\n internal struct InternalStructValueType;\n\n internal record struct InternalRecordStructValueType;\n\n internal class InternalClassNotValueType;\n\n internal record InternalRecordClass;\n\n internal enum InternalEnumValueType;\n\n internal interface InternalInterfaceNotValueType;\n}\n\n#pragma warning disable RCS1110, S3903 // Declare type inside namespace.\ninternal class ClassInGlobalNamespace;\n#pragma warning restore RCS1110, S3903\n\n#endregion\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/MultiLineCommentParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class MultiLineCommentParsingStrategy : IParsingStrategy\n{\n private bool isCommentContext;\n private char? commentContextPreviousChar;\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (isCommentContext)\n {\n var isEndOfMultilineComment = symbol is '/' && commentContextPreviousChar is '*';\n\n if (isEndOfMultilineComment)\n {\n isCommentContext = false;\n commentContextPreviousChar = null;\n }\n else\n {\n commentContextPreviousChar = symbol;\n }\n\n return ParsingState.GoToNextSymbol;\n }\n\n var isStartOfMultilineComment = symbol is '*' && statement is [.., '/'];\n\n if (isStartOfMultilineComment)\n {\n statement.Remove(statement.Length - 1, 1);\n isCommentContext = true;\n return ParsingState.GoToNextSymbol;\n }\n\n return ParsingState.InProgress;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return isCommentContext;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/TypeFormattingExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\ninternal static class TypeFormattingExtensions\n{\n /// \n /// Gets a type which can be formatted to a type definition like Dictionary<TKey, TValue>\n /// \n /// The original type\n /// The type's definition if generic, or the original type.\n public static Type AsFormattableTypeDefinition(this Type type)\n {\n if (type is not null && type.IsGenericType && !type.IsGenericTypeDefinition)\n {\n return type.GetGenericTypeDefinition();\n }\n\n return type;\n }\n\n /// \n /// Gets a type which can be formatted to a type definition like Dictionary<TKey, TValue> without namespaces.\n /// \n /// The original type\n /// A value representing the type's definition if generic, or the original type for formatting.\n public static object AsFormattableShortTypeDefinition(this Type type)\n {\n if (type is null)\n {\n return null;\n }\n\n return new ShortTypeValue(type.AsFormattableTypeDefinition());\n }\n\n /// \n /// Gets a wrapper for formatting a type without namespaces.\n /// \n /// The original type\n /// A value representing the incoming type for formatting without namespaces.\n public static ShortTypeValue AsFormattableShortType(this Type type) =>\n type is null ? null : new ShortTypeValue(type);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableSimpleTimeSpanAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableSimpleTimeSpanAssertions : NullableSimpleTimeSpanAssertions\n{\n public NullableSimpleTimeSpanAssertions(TimeSpan? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n/// \n/// You can use the \n/// for a more fluent way of specifying a .\n/// \n[DebuggerNonUserCode]\npublic class NullableSimpleTimeSpanAssertions : SimpleTimeSpanAssertions\n where TAssertions : NullableSimpleTimeSpanAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableSimpleTimeSpanAssertions(TimeSpan? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected a value{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that the value is equal to the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(TimeSpan? expected,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/TypeReflector.cs", "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class TypeReflector\n{\n public static IEnumerable GetAllTypesFromAppDomain(Func predicate)\n {\n return AppDomain.CurrentDomain\n .GetAssemblies()\n .Where(a => !IsDynamic(a) && IsRelevant(a) && predicate(a))\n .SelectMany(GetExportedTypes).ToArray();\n }\n\n private static bool IsRelevant(Assembly ass)\n {\n string assemblyName = ass.GetName().Name;\n\n return\n assemblyName is not null &&\n !assemblyName.StartsWith(\"microsoft.\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"xunit\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"jetbrains.\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"system\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"mscorlib\", StringComparison.OrdinalIgnoreCase) &&\n !assemblyName.StartsWith(\"newtonsoft\", StringComparison.OrdinalIgnoreCase);\n }\n\n private static bool IsDynamic(Assembly assembly)\n {\n return assembly.GetType().FullName is \"System.Reflection.Emit.AssemblyBuilder\"\n or \"System.Reflection.Emit.InternalAssemblyBuilder\";\n }\n\n private static IEnumerable GetExportedTypes(Assembly assembly)\n {\n try\n {\n return assembly.GetExportedTypes();\n }\n catch (ReflectionTypeLoadException ex)\n {\n return ex.Types;\n }\n catch (FileLoadException)\n {\n return [];\n }\n catch (Exception)\n {\n return [];\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/NullableGuidAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableGuidAssertions : NullableGuidAssertions\n{\n public NullableGuidAssertions(Guid? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableGuidAssertions : GuidAssertions\n where TAssertions : NullableGuidAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableGuidAssertions(Guid? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n this.assertionChain = assertionChain;\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected a value{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that the value is equal to the specified value.\n /// \n /// The expected value\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint Be(Guid? expected, [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject == expected)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected {context:Guid} to be {0}{reason}, but found {1}.\", expected, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/FunctionExceptionAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n#if NET47\nusing AwesomeAssertions.Specs.Common;\n#endif\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class FunctionExceptionAssertionSpecs\n{\n [Fact]\n public void When_subject_is_null_when_not_expecting_an_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Action testAction = () =>\n {\n using var _ = new AssertionScope();\n action.Should().NotThrow(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n testAction.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_method_throws_an_empty_AggregateException_it_should_fail()\n {\n // Arrange\n Func act = () => throw new AggregateException();\n\n // Act\n Action act2 = () => act.Should().NotThrow();\n\n // Assert\n act2.Should().Throw();\n }\n\n#pragma warning disable xUnit1026 // Theory methods should use all of their parameters\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public void When_the_expected_exception_is_wrapped_it_should_succeed(Func action, T _)\n where T : Exception\n {\n // Act/Assert\n action.Should().Throw();\n }\n\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public void When_the_expected_exception_is_not_wrapped_it_should_fail(Func action, T _)\n where T : Exception\n {\n // Act\n Action act2 = () => action.Should().NotThrow();\n\n // Assert\n act2.Should().Throw();\n }\n#pragma warning restore xUnit1026 // Theory methods should use all of their parameters\n\n public static TheoryData, Exception> AggregateExceptionTestData()\n {\n Func[] tasks =\n [\n AggregateExceptionWithLeftNestedException,\n AggregateExceptionWithRightNestedException\n ];\n\n Exception[] types =\n [\n new AggregateException(),\n new ArgumentNullException(),\n new InvalidOperationException()\n ];\n\n var data = new TheoryData, Exception>();\n\n foreach (var task in tasks)\n {\n foreach (var type in types)\n {\n data.Add(task, type);\n }\n }\n\n data.Add(EmptyAggregateException, new AggregateException());\n\n return data;\n }\n\n private static int AggregateExceptionWithLeftNestedException()\n {\n var ex1 = new AggregateException(new InvalidOperationException());\n var ex2 = new ArgumentNullException();\n var wrapped = new AggregateException(ex1, ex2);\n\n throw wrapped;\n }\n\n private static int AggregateExceptionWithRightNestedException()\n {\n var ex1 = new ArgumentNullException();\n var ex2 = new AggregateException(new InvalidOperationException());\n var wrapped = new AggregateException(ex1, ex2);\n\n throw wrapped;\n }\n\n private static int EmptyAggregateException()\n {\n throw new AggregateException();\n }\n\n [Fact]\n public void Function_Assertions_should_expose_subject()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Func subject = f.Should().Subject;\n\n // Assert\n subject.Should().BeSameAs(f);\n }\n\n #region Throw\n\n [Fact]\n public void When_subject_is_null_when_an_exception_should_be_thrown_it_should_throw()\n {\n // Arrange\n Func act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n act.Should().Throw(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_function_throws_the_expected_exception_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act / Assert\n f.Should().Throw();\n }\n\n [Fact]\n public void When_function_throws_subclass_of_the_expected_exception_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act / Assert\n f.Should().Throw();\n }\n\n [Fact]\n public void When_function_does_not_throw_expected_exception_it_should_fail()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Action action = () => f.Should().Throw();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_not_throw_expected_exception_but_throws_aggregate_it_should_fail_with_inner_exception()\n {\n // Arrange\n Func f = () => throw new AggregateException(new ArgumentNullException());\n\n // Act\n Action action = () => f.Should().Throw();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_throw_expected_exception_but_in_aggregate_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new AggregateException(new ArgumentNullException());\n\n // Act / Assert\n f.Should().Throw();\n }\n\n [Fact]\n public void\n When_function_does_not_throw_expected_exception_but_throws_aggregate_in_aggregate_it_should_fail_with_inner_exception_one_level_deep()\n {\n // Arrange\n Func f = () => throw new AggregateException(new AggregateException(new ArgumentNullException()));\n\n // Act\n Action action = () => f.Should().Throw();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_throw_expected_exception_but_in_aggregate_in_aggregate_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new AggregateException(new AggregateException(new ArgumentNullException()));\n\n // Act / Assert\n f.Should().Throw();\n }\n\n [Fact]\n public void When_function_does_not_throw_any_exception_it_should_fail()\n {\n // Arrange\n Func f = () => 12;\n\n // Act\n Action action = () => f.Should().Throw(\"that's what I {0}\", \"said\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*that's what I said*but*no exception*\");\n }\n\n #endregion\n\n #region ThrowExactly\n\n [Fact]\n public void When_subject_is_null_when_an_exact_exception_should_be_thrown_it_should_throw()\n {\n // Arrange\n Func act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n act.Should().ThrowExactly(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_function_throws_the_expected_exact_exception_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act / Assert\n f.Should().ThrowExactly();\n }\n\n [Fact]\n public void When_function_throws_aggregate_exception_with_inner_exception_of_the_expected_exact_exception_it_should_fail()\n {\n // Arrange\n Func f = () => throw new AggregateException(new ArgumentException());\n\n // Act\n Action action = () => f.Should().ThrowExactly();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*ArgumentException*but*AggregateException*\");\n }\n\n [Fact]\n public void When_function_throws_subclass_of_the_expected_exact_exception_it_should_fail()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Action action = () => f.Should().ThrowExactly();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*ArgumentException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_not_throw_expected_exact_exception_it_should_fail()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Action action = () => f.Should().ThrowExactly();\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_does_not_throw_any_exception_when_expected_exact_it_should_fail()\n {\n // Arrange\n Func f = () => 12;\n\n // Act\n Action action = () => f.Should().ThrowExactly(\"that's what I {0}\", \"said\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*InvalidCastException*that's what I said*but*no exception*\");\n }\n\n #endregion\n\n #region NotThrow\n\n [Fact]\n public void When_subject_is_null_when_an_exception_should_not_be_thrown_it_should_throw()\n {\n // Arrange\n Func act = null;\n\n // Act\n Action action = () => act.Should().NotThrow(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\");\n }\n\n [Fact]\n public void When_subject_is_null_when_a_generic_exception_should_not_be_thrown_it_should_throw()\n {\n // Arrange\n Func act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n act.Should().NotThrow(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_function_does_not_throw_exception_and_that_was_expected_it_should_succeed_then_continue_assertion()\n {\n // Arrange\n Func f = () => 12;\n\n // Act / Assert\n f.Should().NotThrow().Which.Should().Be(12);\n }\n\n [Fact]\n public void When_function_throw_exception_and_that_was_not_expected_it_should_fail()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n Action action = () => f.Should().NotThrow(\"that's what he {0}\", \"told me\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*no*exception*that's what he told me*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void When_function_throw_aggregate_exception_and_that_was_not_expected_it_should_fail_with_inner_exception_in_message()\n {\n // Arrange\n Func f = () => throw new AggregateException(new ArgumentNullException());\n\n // Act\n Action action = () => f.Should().NotThrow(\"that's what he {0}\", \"told me\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*no*exception*that's what he told me*but*ArgumentNullException*\");\n }\n\n [Fact]\n public void\n When_function_throw_aggregate_in_aggregate_exception_and_that_was_not_expected_it_should_fail_with_most_inner_exception_in_message()\n {\n // Arrange\n Func f = () => throw new AggregateException(new AggregateException(new ArgumentNullException()));\n\n // Act\n Action action = () => f.Should().NotThrow(\"that's what he {0}\", \"told me\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*no*exception*that's what he told me*but*ArgumentNullException*\");\n }\n\n #endregion\n\n #region NotThrowAfter\n\n [Fact]\n public void When_subject_is_null_it_should_throw()\n {\n // Arrange\n var waitTime = 0.Milliseconds();\n var pollInterval = 0.Milliseconds();\n Func action = null;\n\n // Act\n Action testAction = () =>\n {\n using var _ = new AssertionScope();\n action.Should().NotThrowAfter(waitTime, pollInterval, \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n testAction.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_wait_time_is_negative_it_should_throw()\n {\n // Arrange\n var waitTime = -1.Milliseconds();\n var pollInterval = 10.Milliseconds();\n Func someFunc = () => 0;\n\n // Act\n Action action = () =>\n someFunc.Should().NotThrowAfter(waitTime, pollInterval);\n\n // Assert\n action.Should().Throw()\n .WithParameterName(\"waitTime\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_poll_interval_is_negative_it_should_throw()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = -1.Milliseconds();\n Func someAction = () => 0;\n\n // Act\n Action action = () =>\n someAction.Should().NotThrowAfter(waitTime, pollInterval);\n\n // Assert\n action.Should().Throw()\n .WithParameterName(\"pollInterval\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_but_it_was_it_should_throw()\n {\n // Arrange\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n Func throwLongerThanWaitTime = () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n return 0;\n };\n\n // Act\n Action action = () =>\n throwLongerThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect any exceptions after 100ms because we passed valid arguments*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_and_none_was_it_should_not_throw()\n {\n // Arrange\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n Func throwShorterThanWaitTime = () =>\n {\n if (timer.Elapsed <= waitTime.Divide(2))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n return 0;\n };\n\n // Act\n throwShorterThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval);\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_the_func_result_should_be_returned()\n {\n // Arrange\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n Func throwShorterThanWaitTime = () =>\n {\n if (timer.Elapsed <= waitTime.Divide(2))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n return 42;\n };\n\n // Act\n Action act = () => throwShorterThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval)\n .Which.Should().Be(43);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected throwShorterThanWaitTime.Result to be 43*\");\n }\n\n [Fact]\n public void When_an_assertion_fails_on_NotThrowAfter_succeeding_message_should_be_included()\n {\n // Arrange\n var waitTime = TimeSpan.Zero;\n var pollInterval = TimeSpan.Zero;\n Func throwingFunction = () => throw new Exception();\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n throwingFunction.Should().NotThrowAfter(waitTime, pollInterval)\n .And.BeNull();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Did not expect any exceptions after*\");\n }\n\n #endregion\n\n #region NotThrow\n\n [Fact]\n public void\n When_function_does_not_throw_at_all_when_some_particular_exception_was_not_expected_it_should_succeed_but_then_cannot_continue_assertion()\n {\n // Arrange\n Func f = () => 12;\n\n // Act / Assert\n f.Should().NotThrow();\n }\n\n [Fact]\n public void When_function_does_throw_exception_and_that_exception_was_not_expected_it_should_fail()\n {\n // Arrange\n Func f = () => throw new InvalidOperationException(\"custom message\");\n\n // Act\n Action action = () => f.Should().NotThrow(\"it was so {0}\", \"fast\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"*Did not expect System.InvalidOperationException because it was so fast, but found System.InvalidOperationException: custom message*\");\n }\n\n [Fact]\n public void When_function_throw_one_exception_but_other_was_not_expected_it_should_succeed()\n {\n // Arrange\n Func f = () => throw new ArgumentNullException();\n\n // Act\n f.Should().NotThrow();\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/PropertyInfoSelector.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Allows for fluent selection of properties of a type through reflection.\n/// \npublic class PropertyInfoSelector : IEnumerable\n{\n private IEnumerable selectedProperties;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The type from which to select properties.\n /// is .\n public PropertyInfoSelector(Type type)\n : this([type])\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The types from which to select properties.\n /// is or contains .\n public PropertyInfoSelector(IEnumerable types)\n {\n Guard.ThrowIfArgumentIsNull(types);\n Guard.ThrowIfArgumentContainsNull(types);\n\n selectedProperties = types.SelectMany(t => t\n .GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance\n | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static));\n }\n\n /// \n /// Only select the properties that have at least one public or internal accessor\n /// \n public PropertyInfoSelector ThatArePublicOrInternal\n {\n get\n {\n selectedProperties = selectedProperties.Where(property =>\n {\n return property.GetGetMethod(nonPublic: true) is { IsPublic: true } or { IsAssembly: true }\n || property.GetSetMethod(nonPublic: true) is { IsPublic: true } or { IsAssembly: true };\n });\n\n return this;\n }\n }\n\n /// \n /// Only select the properties that are abstract\n /// \n public PropertyInfoSelector ThatAreAbstract\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => property.IsAbstract());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are not abstract\n /// \n public PropertyInfoSelector ThatAreNotAbstract\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => !property.IsAbstract());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are static\n /// \n public PropertyInfoSelector ThatAreStatic\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => property.IsStatic());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are not static\n /// \n public PropertyInfoSelector ThatAreNotStatic\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => !property.IsStatic());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are virtual\n /// \n public PropertyInfoSelector ThatAreVirtual\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => property.IsVirtual());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are not virtual\n /// \n public PropertyInfoSelector ThatAreNotVirtual\n {\n get\n {\n selectedProperties = selectedProperties.Where(property => !property.IsVirtual());\n return this;\n }\n }\n\n /// \n /// Only select the properties that are decorated with an attribute of the specified type.\n /// \n public PropertyInfoSelector ThatAreDecoratedWith()\n where TAttribute : Attribute\n {\n selectedProperties = selectedProperties.Where(property => property.IsDecoratedWith());\n return this;\n }\n\n /// \n /// Only select the properties that are decorated with, or inherits from a parent class, an attribute of the specified type.\n /// \n public PropertyInfoSelector ThatAreDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n selectedProperties = selectedProperties.Where(property => property.IsDecoratedWithOrInherit());\n return this;\n }\n\n /// \n /// Only select the properties that are not decorated with an attribute of the specified type.\n /// \n public PropertyInfoSelector ThatAreNotDecoratedWith()\n where TAttribute : Attribute\n {\n selectedProperties = selectedProperties.Where(property => !property.IsDecoratedWith());\n return this;\n }\n\n /// \n /// Only select the properties that are not decorated with and does not inherit from a parent class an attribute of the specified type.\n /// \n public PropertyInfoSelector ThatAreNotDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n selectedProperties = selectedProperties.Where(property => !property.IsDecoratedWithOrInherit());\n return this;\n }\n\n /// \n /// Only select the properties that return the specified type\n /// \n public PropertyInfoSelector OfType()\n {\n selectedProperties = selectedProperties.Where(property => property.PropertyType == typeof(TReturn));\n return this;\n }\n\n /// \n /// Only select the properties that do not return the specified type\n /// \n public PropertyInfoSelector NotOfType()\n {\n selectedProperties = selectedProperties.Where(property => property.PropertyType != typeof(TReturn));\n return this;\n }\n\n /// \n /// Select return types of the properties\n /// \n public TypeSelector ReturnTypes()\n {\n var returnTypes = selectedProperties.Select(property => property.PropertyType);\n\n return new TypeSelector(returnTypes);\n }\n\n /// \n /// The resulting objects.\n /// \n public PropertyInfo[] ToArray()\n {\n return selectedProperties.ToArray();\n }\n\n /// \n /// Returns an enumerator that iterates through the collection.\n /// \n /// \n /// A that can be used to iterate through the collection.\n /// \n /// 1\n public IEnumerator GetEnumerator()\n {\n return selectedProperties.GetEnumerator();\n }\n\n /// \n /// Returns an enumerator that iterates through a collection.\n /// \n /// \n /// An object that can be used to iterate through the collection.\n /// \n /// 2\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/LateBoundTestFramework.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.IO;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Execution;\n\ninternal abstract class LateBoundTestFramework : ITestFramework\n{\n private readonly bool loadAssembly;\n private Func exceptionFactory;\n\n protected LateBoundTestFramework(bool loadAssembly = false)\n {\n this.loadAssembly = loadAssembly;\n exceptionFactory = _ => throw new InvalidOperationException($\"{nameof(IsAvailable)} must be called first.\");\n }\n\n [DoesNotReturn]\n public void Throw(string message) => throw exceptionFactory(message);\n\n public bool IsAvailable\n {\n get\n {\n var assembly = FindExceptionAssembly();\n var exceptionType = assembly?.GetType(ExceptionFullName);\n\n exceptionFactory = exceptionType != null\n ? message => (Exception)Activator.CreateInstance(exceptionType, message)\n : _ => throw new InvalidOperationException($\"{GetType().Name} is not available\");\n\n return exceptionType is not null;\n }\n }\n\n private Assembly FindExceptionAssembly()\n {\n var assembly = Array.Find(AppDomain.CurrentDomain.GetAssemblies(), a => a.GetName().Name == AssemblyName);\n\n if (assembly is null && loadAssembly)\n {\n try\n {\n return Assembly.Load(new AssemblyName(AssemblyName));\n }\n catch (FileNotFoundException)\n {\n return null;\n }\n catch (FileLoadException)\n {\n return null;\n }\n }\n\n return assembly;\n }\n\n protected internal abstract string AssemblyName { get; }\n\n protected abstract string ExceptionFullName { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedTheoryAttributeDiscoverer.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedTheoryAttributeDiscoverer : TheoryDiscoverer\n{\n public CulturedTheoryAttributeDiscoverer(IMessageSink diagnosticMessageSink)\n : base(diagnosticMessageSink)\n {\n }\n\n protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions,\n ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow)\n {\n var cultures = GetCultures(theoryAttribute);\n\n return cultures.Select(culture => new CulturedXunitTestCase(DiagnosticMessageSink,\n discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, culture,\n dataRow)).ToList();\n }\n\n protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions,\n ITestMethod testMethod, IAttributeInfo theoryAttribute)\n {\n var cultures = GetCultures(theoryAttribute);\n\n return cultures.Select(culture => new CulturedXunitTheoryTestCase(DiagnosticMessageSink,\n discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, culture))\n .ToList();\n }\n\n private static string[] GetCultures(IAttributeInfo culturedTheoryAttribute)\n {\n var ctorArgs = culturedTheoryAttribute.GetConstructorArguments().ToArray();\n var cultures = Reflector.ConvertArguments(ctorArgs, [typeof(string[])]).Cast().Single();\n\n if (cultures is null || cultures.Length == 0)\n {\n cultures = [\"en-US\", \"fr-FR\"];\n }\n\n return cultures;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/MethodInfoSelector.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing static System.Reflection.BindingFlags;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Allows for fluent selection of methods of a type through reflection.\n/// \npublic class MethodInfoSelector : IEnumerable\n{\n private IEnumerable selectedMethods;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The type from which to select methods.\n /// is .\n public MethodInfoSelector(Type type)\n : this([type])\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The types from which to select methods.\n /// is or contains .\n public MethodInfoSelector(IEnumerable types)\n {\n Guard.ThrowIfArgumentIsNull(types);\n Guard.ThrowIfArgumentContainsNull(types);\n\n selectedMethods = types.SelectMany(t => t\n .GetMethods(DeclaredOnly | Instance | Static | Public | NonPublic)\n .Where(method => !HasSpecialName(method)));\n }\n\n /// \n /// Only select the methods that are public or internal.\n /// \n public MethodInfoSelector ThatArePublicOrInternal\n {\n get\n {\n selectedMethods = selectedMethods.Where(method => method.IsPublic || method.IsAssembly);\n return this;\n }\n }\n\n /// \n /// Only select the methods without a return value\n /// \n public MethodInfoSelector ThatReturnVoid\n {\n get\n {\n selectedMethods = selectedMethods.Where(method => method.ReturnType == typeof(void));\n return this;\n }\n }\n\n /// \n /// Only select the methods with a return value\n /// \n public MethodInfoSelector ThatDoNotReturnVoid\n {\n get\n {\n selectedMethods = selectedMethods.Where(method => method.ReturnType != typeof(void));\n return this;\n }\n }\n\n /// \n /// Only select the methods that return the specified type\n /// \n public MethodInfoSelector ThatReturn()\n {\n selectedMethods = selectedMethods.Where(method => method.ReturnType == typeof(TReturn));\n return this;\n }\n\n /// \n /// Only select the methods that do not return the specified type\n /// \n public MethodInfoSelector ThatDoNotReturn()\n {\n selectedMethods = selectedMethods.Where(method => method.ReturnType != typeof(TReturn));\n return this;\n }\n\n /// \n /// Only select the methods that are decorated with an attribute of the specified type.\n /// \n public MethodInfoSelector ThatAreDecoratedWith()\n where TAttribute : Attribute\n {\n selectedMethods = selectedMethods.Where(method => method.IsDecoratedWith());\n return this;\n }\n\n /// \n /// Only select the methods that are decorated with, or inherits from a parent class, an attribute of the specified type.\n /// \n public MethodInfoSelector ThatAreDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n selectedMethods = selectedMethods.Where(method => method.IsDecoratedWithOrInherit());\n return this;\n }\n\n /// \n /// Only select the methods that are not decorated with an attribute of the specified type.\n /// \n public MethodInfoSelector ThatAreNotDecoratedWith()\n where TAttribute : Attribute\n {\n selectedMethods = selectedMethods.Where(method => !method.IsDecoratedWith());\n return this;\n }\n\n /// \n /// Only select the methods that are not decorated with and does not inherit from a parent class, an attribute of the specified type.\n /// \n public MethodInfoSelector ThatAreNotDecoratedWithOrInherit()\n where TAttribute : Attribute\n {\n selectedMethods = selectedMethods.Where(method => !method.IsDecoratedWithOrInherit());\n return this;\n }\n\n /// \n /// Only return methods that are abstract\n /// \n public MethodInfoSelector ThatAreAbstract()\n {\n selectedMethods = selectedMethods.Where(method => method.IsAbstract);\n return this;\n }\n\n /// \n /// Only return methods that are not abstract\n /// \n public MethodInfoSelector ThatAreNotAbstract()\n {\n selectedMethods = selectedMethods.Where(method => !method.IsAbstract);\n return this;\n }\n\n /// \n /// Only return methods that are async.\n /// \n public MethodInfoSelector ThatAreAsync()\n {\n selectedMethods = selectedMethods.Where(method => method.IsAsync());\n return this;\n }\n\n /// \n /// Only return methods that are not async.\n /// \n public MethodInfoSelector ThatAreNotAsync()\n {\n selectedMethods = selectedMethods.Where(method => !method.IsAsync());\n return this;\n }\n\n /// \n /// Only return methods that are static.\n /// \n public MethodInfoSelector ThatAreStatic()\n {\n selectedMethods = selectedMethods.Where(method => method.IsStatic);\n return this;\n }\n\n /// \n /// Only return methods that are not static.\n /// \n public MethodInfoSelector ThatAreNotStatic()\n {\n selectedMethods = selectedMethods.Where(method => !method.IsStatic);\n return this;\n }\n\n /// \n /// Only return methods that are virtual.\n /// \n public MethodInfoSelector ThatAreVirtual()\n {\n selectedMethods = selectedMethods.Where(method => !method.IsNonVirtual());\n return this;\n }\n\n /// \n /// Only return methods that are not virtual.\n /// \n public MethodInfoSelector ThatAreNotVirtual()\n {\n selectedMethods = selectedMethods.Where(method => method.IsNonVirtual());\n return this;\n }\n\n /// \n /// Select return types of the methods\n /// \n public TypeSelector ReturnTypes()\n {\n var returnTypes = selectedMethods.Select(mi => mi.ReturnType);\n\n return new TypeSelector(returnTypes);\n }\n\n /// \n /// The resulting objects.\n /// \n public MethodInfo[] ToArray()\n {\n return selectedMethods.ToArray();\n }\n\n /// \n /// Determines whether the specified method has a special name (like properties and events).\n /// \n private static bool HasSpecialName(MethodInfo method)\n {\n return (method.Attributes & MethodAttributes.SpecialName) == MethodAttributes.SpecialName;\n }\n\n /// \n /// Returns an enumerator that iterates through the collection.\n /// \n /// \n /// A that can be used to iterate through the collection.\n /// \n /// 1\n public IEnumerator GetEnumerator()\n {\n return selectedMethods.GetEnumerator();\n }\n\n /// \n /// Returns an enumerator that iterates through a collection.\n /// \n /// \n /// An object that can be used to iterate through the collection.\n /// \n /// 2\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/GivenSelectorExtensions.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Execution;\n\ninternal static class GivenSelectorExtensions\n{\n public static ContinuationOfGiven> AssertCollectionIsNotNull(\n this GivenSelector> givenSelector)\n {\n return givenSelector\n .ForCondition(items => items is not null)\n .FailWith(\"but found collection is .\");\n }\n\n public static ContinuationOfGiven> AssertEitherCollectionIsNotEmpty(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .ForCondition(items => items.Count > 0 || length == 0)\n .FailWith(\"but found empty collection.\")\n .Then\n .ForCondition(items => items.Count == 0 || length > 0)\n .FailWith(\"but found {0}.\", items => items);\n }\n\n public static ContinuationOfGiven> AssertCollectionHasEnoughItems(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .Given(items => items.ConvertOrCastToCollection())\n .AssertCollectionHasEnoughItems(length);\n }\n\n public static ContinuationOfGiven> AssertCollectionHasEnoughItems(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .ForCondition(items => items.Count >= length)\n .FailWith(\"but {0} contains {1} item(s) less.\", items => items, items => length - items.Count);\n }\n\n public static ContinuationOfGiven> AssertCollectionHasNotTooManyItems(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .ForCondition(items => items.Count <= length)\n .FailWith(\"but {0} contains {1} item(s) too many.\", items => items, items => items.Count - length);\n }\n\n public static ContinuationOfGiven> AssertCollectionsHaveSameCount(\n this GivenSelector> givenSelector, int length)\n {\n return givenSelector\n .AssertEitherCollectionIsNotEmpty(length)\n .Then\n .AssertCollectionHasEnoughItems(length)\n .Then\n .AssertCollectionHasNotTooManyItems(length);\n }\n\n public static ContinuationOfGiven> AssertCollectionsHaveSameItems(\n this GivenSelector> givenSelector,\n ICollection expected, Func, ICollection, int> findIndex)\n {\n return givenSelector\n .Given>(actual => new CollectionWithIndex(actual, findIndex(actual, expected)))\n .ForCondition(diff => diff.As>().Index == -1)\n .FailWith(\"but {0} differs at index {1}.\",\n diff => diff.As>().Items,\n diff => diff.As>().Index);\n }\n\n private sealed class CollectionWithIndex : ICollection\n {\n public ICollection Items { get; }\n\n public int Index { get; }\n\n public CollectionWithIndex(ICollection items, int index)\n {\n Items = items;\n Index = index;\n }\n\n public int Count => Items.Count;\n\n public bool IsReadOnly => Items.IsReadOnly;\n\n public void Add(T item) => Items.Add(item);\n\n public void Clear() => Items.Clear();\n\n public bool Contains(T item) => Items.Contains(item);\n\n public void CopyTo(T[] array, int arrayIndex) => Items.CopyTo(array, arrayIndex);\n\n public IEnumerator GetEnumerator() => Items.GetEnumerator();\n\n public bool Remove(T item) => Items.Remove(item);\n\n IEnumerator IEnumerable.GetEnumerator() => Items.GetEnumerator();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AssertionsApiSpecs.cs", "using System;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Types;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs;\n\npublic sealed class AssertionsApiSpecs\n{\n [Fact]\n public void Assertions_types_have_property_names_by_convention()\n {\n static bool IsAssertionsClass(Type type)\n {\n if (type.IsDefined(typeof(CompilerGeneratedAttribute)))\n {\n return false;\n }\n\n string name = type.Name;\n int lastIndex = type.Name.LastIndexOf('`');\n if (lastIndex >= 0)\n {\n name = name[..lastIndex];\n }\n\n return name.EndsWith(\"Assertions\", StringComparison.Ordinal);\n }\n\n Assembly awesomeAssertionsAssembly = typeof(AssertionScope).Assembly;\n TypeSelector assertionsClasses = awesomeAssertionsAssembly.Types()\n .ThatAreClasses()\n .ThatAreNotAbstract()\n .ThatAreNotStatic()\n .ThatSatisfy(IsAssertionsClass);\n\n assertionsClasses.AsEnumerable().Should().AllSatisfy(\n type => type.Should().HaveProperty(\"CurrentAssertionChain\"));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ObjectExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class ObjectExtensions\n{\n public static Func GetComparer()\n {\n if (typeof(T).IsValueType)\n {\n // Avoid causing any boxing for value types\n return (actual, expected) => EqualityComparer.Default.Equals(actual, expected);\n }\n\n if (typeof(T) != typeof(object))\n {\n // CompareNumerics is only relevant for numerics boxed in an object.\n return (actual, expected) => actual is null\n ? expected is null\n : expected is not null && EqualityComparer.Default.Equals(actual, expected);\n }\n\n return (actual, expected) => actual is null\n ? expected is null\n : expected is not null\n && (EqualityComparer.Default.Equals(actual, expected) || CompareNumerics(actual, expected));\n }\n\n private static bool CompareNumerics(object actual, object expected)\n {\n Type expectedType = expected.GetType();\n Type actualType = actual.GetType();\n\n return actualType != expectedType\n && actual.IsNumericType()\n && expected.IsNumericType()\n && CanConvert(actual, expected, actualType, expectedType)\n && CanConvert(expected, actual, expectedType, actualType);\n }\n\n private static bool CanConvert(object source, object target, Type sourceType, Type targetType)\n {\n try\n {\n var converted = source.ConvertTo(targetType);\n\n return source.Equals(converted.ConvertTo(sourceType))\n && converted.Equals(target);\n }\n catch\n {\n // ignored\n return false;\n }\n }\n\n private static object ConvertTo(this object source, Type targetType)\n {\n return Convert.ChangeType(source, targetType, CultureInfo.InvariantCulture);\n }\n\n private static bool IsNumericType(this object obj)\n {\n // \"is not null\" is due to https://github.com/dotnet/runtime/issues/47920#issuecomment-774481505\n return obj is not null and (\n int or\n long or\n float or\n double or\n decimal or\n sbyte or\n byte or\n short or\n ushort or\n uint or\n ulong);\n }\n\n /// \n /// Convenience method to format an object to a string using the class.\n /// \n public static string ToFormattedString(this object source)\n {\n return Formatter.ToString(source);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/PropertyInfoSelectorSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing AwesomeAssertions.Types;\nusing Internal.Main.Test;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class PropertyInfoSelectorSpecs\n{\n [Fact]\n public void When_property_info_selector_is_created_with_a_null_type_it_should_throw()\n {\n // Arrange\n PropertyInfoSelector propertyInfoSelector;\n\n // Act\n Action act = () => propertyInfoSelector = new PropertyInfoSelector((Type)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_property_info_selector_is_created_with_a_null_type_list_it_should_throw()\n {\n // Arrange\n PropertyInfoSelector propertyInfoSelector;\n\n // Act\n Action act = () => propertyInfoSelector = new PropertyInfoSelector((Type[])null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_property_info_selector_is_null_then_should_should_throw()\n {\n // Arrange\n PropertyInfoSelector propertyInfoSelector = null;\n\n // Act\n Action act = () => propertyInfoSelector.Should();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"propertyInfoSelector\");\n }\n\n [Fact]\n public void When_selecting_properties_from_types_in_an_assembly_it_should_return_the_applicable_properties()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable properties = assembly.Types()\n .ThatAreDecoratedWith()\n .Properties();\n\n // Assert\n properties.Should()\n .HaveCount(2)\n .And.Contain(m => m.Name == \"Property1\")\n .And.Contain(m => m.Name == \"Property2\");\n }\n\n [Fact]\n public void When_selecting_properties_that_are_public_or_internal_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInternalAndPublicProperties);\n\n // Act\n IEnumerable properties = type.Properties().ThatArePublicOrInternal.ToArray();\n\n // Assert\n properties.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_abstract_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreAbstract.ToArray();\n\n // Assert\n properties.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_not_abstract_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotAbstract.ToArray();\n\n // Assert\n properties.Should().HaveCount(10);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_static_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreStatic.ToArray();\n\n // Assert\n properties.Should().HaveCount(4);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_not_static_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotStatic.ToArray();\n\n // Assert\n properties.Should().HaveCount(8);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_virtual_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreVirtual.ToArray();\n\n // Assert\n properties.Should().HaveCount(7);\n }\n\n [Fact]\n public void When_selecting_properties_that_are_not_virtual_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotVirtual.ToArray();\n\n // Assert\n properties.Should().HaveCount(5);\n }\n\n [Fact]\n public void When_selecting_properties_decorated_with_specific_attribute_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreDecoratedWith().ToArray();\n\n // Assert\n properties.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_properties_not_decorated_with_specific_attribute_it_should_return_only_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n properties.Should()\n .NotBeEmpty()\n .And.NotContain(p => p.Name == \"PublicVirtualStringPropertyWithAttribute\")\n .And.NotContain(p => p.Name == \"ProtectedVirtualIntPropertyWithAttribute\");\n }\n\n [Fact]\n public void When_selecting_methods_that_return_a_specific_type_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().OfType().ToArray();\n\n // Assert\n properties.Should().HaveCount(8);\n }\n\n [Fact]\n public void When_selecting_methods_that_do_not_return_a_specific_type_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties().NotOfType().ToArray();\n\n // Assert\n properties.Should().HaveCount(4);\n }\n\n [Fact]\n public void\n When_selecting_properties_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreDecoratedWith().ToArray();\n\n // Assert\n properties.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_properties_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable properties =\n type.Properties().ThatAreDecoratedWithOrInherit().ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_properties_not_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable properties = type.Properties().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_properties_not_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable properties =\n type.Properties().ThatAreNotDecoratedWithOrInherit().ToArray();\n\n // Assert\n properties.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_properties_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable properties =\n type.Properties().ThatAreDecoratedWith().ToArray();\n\n // Assert\n properties.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_properties_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable properties = type.Properties()\n .ThatAreDecoratedWithOrInherit().ToArray();\n\n // Assert\n properties.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_properties_not_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable properties =\n type.Properties().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_properties_not_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable properties = type.Properties()\n .ThatAreNotDecoratedWithOrInherit().ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_properties_return_types_it_should_return_the_correct_types()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable returnTypes = type.Properties().ReturnTypes().ToArray();\n\n // Assert\n returnTypes.Should()\n .BeEquivalentTo(\n [\n typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string),\n typeof(string), typeof(int), typeof(int), typeof(int), typeof(int)\n ]);\n }\n\n public class ThatArePublicOrInternal\n {\n [Fact]\n public void When_combining_filters_to_filter_methods_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForPropertySelector);\n\n // Act\n IEnumerable properties = type.Properties()\n .ThatArePublicOrInternal\n .OfType()\n .ThatAreDecoratedWith()\n .ToArray();\n\n // Assert\n properties.Should().ContainSingle();\n }\n\n [Fact]\n public void When_a_property_only_has_a_public_setter_it_should_be_included_in_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPublicSetter);\n\n // Act\n IEnumerable properties = type.Properties().ThatArePublicOrInternal.ToArray();\n\n // Assert\n properties.Should().HaveCount(3);\n }\n\n private class TestClassForPublicSetter\n {\n private static string myPrivateStaticStringField;\n\n public static string PublicStaticStringProperty { set => myPrivateStaticStringField = value; }\n\n public static string InternalStaticStringProperty { get; set; }\n\n public int PublicIntProperty { get; init; }\n }\n\n [Fact]\n public void When_selecting_properties_with_at_least_one_accessor_being_private_should_return_the_applicable_properties()\n {\n // Arrange\n Type type = typeof(TestClassForPrivateAccessors);\n\n // Act\n IEnumerable properties = type.Properties().ThatArePublicOrInternal.ToArray();\n\n // Assert\n properties.Should().HaveCount(4);\n }\n\n private class TestClassForPrivateAccessors\n {\n public bool PublicBoolPrivateGet { private get; set; }\n\n public bool PublicBoolPrivateSet { get; private set; }\n\n internal bool InternalBoolPrivateGet { private get; set; }\n\n internal bool InternalBoolPrivateSet { get; private set; }\n }\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class TestClassForPropertySelectorWithInternalAndPublicProperties\n{\n public static string PublicStaticStringProperty { get; }\n\n internal static string InternalStaticStringProperty { get; set; }\n\n protected static string ProtectedStaticStringProperty { get; set; }\n\n private static string PrivateStaticStringProperty { get; set; }\n}\n\ninternal abstract class TestClassForPropertySelector\n{\n private static string myPrivateStaticStringField;\n\n public static string PublicStaticStringProperty { set => myPrivateStaticStringField = value; }\n\n internal static string InternalStaticStringProperty { get; set; }\n\n protected static string ProtectedStaticStringProperty { get; set; }\n\n private static string PrivateStaticStringProperty { get; set; }\n\n // An abstract method/property is implicitly a virtual method/property.\n public abstract string PublicAbstractStringProperty { get; set; }\n\n public abstract string PublicAbstractStringPropertyWithSetterOnly { set; }\n\n private string myPrivateStringField;\n\n public virtual string PublicVirtualStringProperty { set => myPrivateStringField = value; }\n\n [DummyProperty]\n public virtual string PublicVirtualStringPropertyWithAttribute { get; set; }\n\n public virtual int PublicVirtualIntPropertyWithPrivateSetter { get; private set; }\n\n internal virtual int InternalVirtualIntPropertyWithPrivateSetter { get; private set; }\n\n [DummyProperty]\n protected virtual int ProtectedVirtualIntPropertyWithAttribute { get; set; }\n\n private int PrivateIntProperty { get; set; }\n}\n\ninternal class TestClassForPropertySelectorWithInheritableAttribute\n{\n [DummyProperty]\n public virtual string PublicVirtualStringPropertyWithAttribute { get; set; }\n}\n\ninternal class TestClassForPropertySelectorWithNonInheritableAttribute\n{\n [DummyPropertyNonInheritableAttribute]\n public virtual string PublicVirtualStringPropertyWithAttribute { get; set; }\n}\n\ninternal class TestClassForPropertySelectorWithInheritableAttributeDerived : TestClassForPropertySelectorWithInheritableAttribute\n{\n public override string PublicVirtualStringPropertyWithAttribute { get; set; }\n}\n\ninternal class TestClassForPropertySelectorWithNonInheritableAttributeDerived : TestClassForPropertySelectorWithNonInheritableAttribute\n{\n public override string PublicVirtualStringPropertyWithAttribute { get; set; }\n}\n\n[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = false)]\npublic class DummyPropertyNonInheritableAttributeAttribute : Attribute\n{\n public DummyPropertyNonInheritableAttributeAttribute()\n {\n }\n\n public DummyPropertyNonInheritableAttributeAttribute(string value)\n {\n Value = value;\n }\n\n public string Value { get; private set; }\n}\n\n[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]\npublic class DummyPropertyAttribute : Attribute\n{\n public DummyPropertyAttribute()\n {\n }\n\n public DummyPropertyAttribute(string value)\n {\n Value = value;\n }\n\n public string Value { get; private set; }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/MethodInfoSelectorSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Types;\nusing Internal.Main.Test;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class MethodInfoSelectorSpecs\n{\n [Fact]\n public void When_method_info_selector_is_created_with_a_null_type_it_should_throw()\n {\n // Arrange\n MethodInfoSelector methodInfoSelector;\n\n // Act\n Action act = () => methodInfoSelector = new MethodInfoSelector((Type)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_method_info_selector_is_created_with_a_null_type_list_it_should_throw()\n {\n // Arrange\n MethodInfoSelector methodInfoSelector;\n\n // Act\n Action act = () => methodInfoSelector = new MethodInfoSelector((Type[])null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"types\");\n }\n\n [Fact]\n public void When_method_info_selector_is_null_then_should_should_throw()\n {\n // Arrange\n MethodInfoSelector methodInfoSelector = null;\n\n // Act\n var act = () => methodInfoSelector.Should();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"methodSelector\");\n }\n\n [Fact]\n public void When_selecting_methods_from_types_in_an_assembly_it_should_return_the_applicable_methods()\n {\n // Arrange\n Assembly assembly = typeof(ClassWithSomeAttribute).Assembly;\n\n // Act\n IEnumerable methods = assembly.Types()\n .ThatAreDecoratedWith()\n .Methods();\n\n // Assert\n methods.Should()\n .HaveCount(2)\n .And.Contain(m => m.Name == \"Method1\")\n .And.Contain(m => m.Name == \"Method2\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_public_or_internal_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatArePublicOrInternal;\n\n // Assert\n const int PublicMethodCount = 2;\n const int InternalMethodCount = 1;\n methods.Should().HaveCount(PublicMethodCount + InternalMethodCount);\n }\n\n [Fact]\n public void When_selecting_methods_decorated_with_specific_attribute_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreDecoratedWith().ToArray();\n\n // Assert\n methods.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_methods_not_decorated_with_specific_attribute_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n methods.Should()\n .NotBeEmpty()\n .And.NotContain(m => m.Name == \"PublicVirtualVoidMethodWithAttribute\")\n .And.NotContain(m => m.Name == \"ProtectedVirtualVoidMethodWithAttribute\");\n }\n\n [Fact]\n public void When_selecting_methods_that_return_a_specific_type_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatReturn().ToArray();\n\n // Assert\n methods.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_methods_that_do_not_return_a_specific_type_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatDoNotReturn().ToArray();\n\n // Assert\n methods.Should().HaveCount(5);\n }\n\n [Fact]\n public void When_selecting_methods_without_return_value_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatReturnVoid.ToArray();\n\n // Assert\n methods.Should().HaveCount(4);\n }\n\n [Fact]\n public void When_selecting_methods_with_return_value_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods().ThatDoNotReturnVoid.ToArray();\n\n // Assert\n methods.Should().HaveCount(3);\n }\n\n [Fact]\n public void When_combining_filters_to_filter_methods_it_should_return_only_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n IEnumerable methods = type.Methods()\n .ThatArePublicOrInternal\n .ThatReturnVoid\n .ToArray();\n\n // Assert\n methods.Should().HaveCount(2);\n }\n\n [Fact]\n public void When_selecting_methods_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreDecoratedWith().ToArray();\n\n // Assert\n methods.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_methods_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreDecoratedWithOrInherit().ToArray();\n\n // Assert\n methods.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_methods_not_decorated_with_an_inheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotDecoratedWith().ToArray();\n\n // Assert\n methods.Should().ContainSingle();\n }\n\n [Fact]\n public void\n When_selecting_methods_not_decorated_with_or_inheriting_an_inheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotDecoratedWithOrInherit().ToArray();\n\n // Assert\n methods.Should().BeEmpty();\n }\n\n [Fact]\n public void When_selecting_methods_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreDecoratedWith()\n .ToArray();\n\n // Assert\n methods.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_methods_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable methods =\n type.Methods().ThatAreDecoratedWithOrInherit().ToArray();\n\n // Assert\n methods.Should().BeEmpty();\n }\n\n [Fact]\n public void\n When_selecting_methods_not_decorated_with_a_noninheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotDecoratedWith()\n .ToArray();\n\n // Assert\n methods.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_methods_that_are_abstract_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithAbstractAndVirtualMethods);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreAbstract().ToArray();\n\n // Assert\n methods.Should().HaveCount(3);\n }\n\n [Fact]\n public void When_selecting_methods_that_are_not_abstract_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithAbstractAndVirtualMethods);\n\n // Act\n IEnumerable methods = type.Methods().ThatAreNotAbstract().ToArray();\n\n // Assert\n methods.Should().HaveCount(10);\n }\n\n [Fact]\n public void When_selecting_methods_that_are_async_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithAsyncAndNonAsyncMethod);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreAsync().ToArray();\n\n // Assert\n methods.Should().ContainSingle()\n .Which.Name.Should().Be(\"PublicAsyncMethod\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_not_async_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithAsyncAndNonAsyncMethod);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreNotAsync().ToArray();\n\n // Assert\n methods.Should().ContainSingle()\n .Which.Name.Should().Be(\"PublicNonAsyncMethod\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_virtual_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreVirtual().ToArray();\n\n // Assert\n methods.Should()\n .NotBeEmpty()\n .And.Contain(m => m.Name == \"PublicVirtualVoidMethodWithAttribute\")\n .And.Contain(m => m.Name == \"ProtectedVirtualVoidMethodWithAttribute\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_not_virtual_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreNotVirtual().ToArray();\n\n // Assert\n methods.Should()\n .NotBeEmpty()\n .And.NotContain(m => m.Name == \"PublicVirtualVoidMethodWithAttribute\")\n .And.NotContain(m => m.Name == \"ProtectedVirtualVoidMethodWithAttribute\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_static_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithStaticAndNonStaticMethod);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreStatic().ToArray();\n\n // Assert\n methods.Should().ContainSingle()\n .Which.Name.Should().Be(\"PublicStaticMethod\");\n }\n\n [Fact]\n public void When_selecting_methods_that_are_not_static_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithStaticAndNonStaticMethod);\n\n // Act\n MethodInfo[] methods = type.Methods().ThatAreNotStatic().ToArray();\n\n // Assert\n methods.Should().ContainSingle()\n .Which.Name.Should().Be(\"PublicNonStaticMethod\");\n }\n\n [Fact]\n public void\n When_selecting_methods_not_decorated_with_or_inheriting_a_noninheritable_attribute_it_should_only_return_the_applicable_methods()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelectorWithNonInheritableAttributeDerived);\n\n // Act\n IEnumerable methods =\n type.Methods().ThatAreNotDecoratedWithOrInherit().ToArray();\n\n // Assert\n methods.Should().ContainSingle();\n }\n\n [Fact]\n public void When_selecting_methods_return_types_it_should_return_the_correct_types()\n {\n // Arrange\n Type type = typeof(TestClassForMethodReturnTypesSelector);\n\n // Act\n IEnumerable returnTypes = type.Methods().ReturnTypes().ToArray();\n\n // Assert\n returnTypes.Should()\n .HaveCount(3)\n .And.Contain(typeof(void))\n .And.Contain(typeof(int))\n .And.Contain(typeof(string));\n }\n\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n Type type = typeof(TestClassForMethodSelector);\n\n // Act\n var action = () => type.Methods().Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class TestClassForMethodSelector\n{\n#pragma warning disable 67, S3264 // \"event is never used\"\n public event EventHandler SomethingChanged = (_, _) => { };\n#pragma warning restore 67, S3264\n\n public virtual void PublicVirtualVoidMethod()\n {\n }\n\n [DummyMethod]\n public virtual void PublicVirtualVoidMethodWithAttribute()\n {\n }\n\n internal virtual int InternalVirtualIntMethod()\n {\n return 0;\n }\n\n [DummyMethod]\n protected virtual void ProtectedVirtualVoidMethodWithAttribute()\n {\n }\n\n private void PrivateVoidDoNothing()\n {\n }\n\n protected virtual string ProtectedVirtualStringMethod()\n {\n return \"\";\n }\n\n private string PrivateStringMethod()\n {\n return \"\";\n }\n}\n\ninternal class TestClassForMethodSelectorWithInheritableAttribute\n{\n [DummyMethod]\n public virtual void PublicVirtualVoidMethodWithAttribute() { }\n}\n\ninternal class TestClassForMethodSelectorWithNonInheritableAttribute\n{\n [DummyMethodNonInheritableAttribute]\n public virtual void PublicVirtualVoidMethodWithAttribute() { }\n}\n\ninternal class TestClassForMethodSelectorWithInheritableAttributeDerived : TestClassForMethodSelectorWithInheritableAttribute\n{\n public override void PublicVirtualVoidMethodWithAttribute() { }\n}\n\ninternal class TestClassForMethodSelectorWithNonInheritableAttributeDerived\n : TestClassForMethodSelectorWithNonInheritableAttribute\n{\n public override void PublicVirtualVoidMethodWithAttribute() { }\n}\n\ninternal class TestClassForMethodSelectorWithAsyncAndNonAsyncMethod\n{\n public async Task PublicAsyncMethod() => await Task.Yield();\n\n public Task PublicNonAsyncMethod() => Task.CompletedTask;\n}\n\ninternal class TestClassForMethodSelectorWithStaticAndNonStaticMethod\n{\n public static void PublicStaticMethod() { }\n\n public void PublicNonStaticMethod() { }\n}\n\ninternal class TestClassForMethodReturnTypesSelector\n{\n public void SomeMethod() { }\n\n public int AnotherMethod() { return default; }\n\n public string OneMoreMethod() { return default; }\n}\n\n[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]\npublic class DummyMethodNonInheritableAttributeAttribute : Attribute\n{\n public bool Filter { get; set; }\n}\n\n[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]\npublic class DummyMethodAttribute : Attribute\n{\n public bool Filter { get; set; }\n}\n\ninternal abstract class TestClassForMethodSelectorWithAbstractAndVirtualMethods\n{\n public abstract void PublicAbstractMethod();\n\n protected abstract void ProtectedAbstractMethod();\n\n internal abstract void InternalAbstractMethod();\n\n public static void PublicStaticMethod() { }\n\n protected static void ProtectedStaticMethod() { }\n\n internal static void InternalStaticMethod() { }\n\n public virtual void PublicVirtualMethod() { }\n\n protected virtual void ProptectedVirtualMethod() { }\n\n internal virtual void InternalVirtualMethod() { }\n\n public void PublicNotAbstractMethod() { }\n\n protected void ProtectedNotAbstractMethod() { }\n\n internal void InternalNotAbstractMethod() { }\n\n private void PrivateAbstractMethod() { }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableNumericAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableNumericAssertions : NullableNumericAssertions>\n where T : struct, IComparable\n{\n public NullableNumericAssertions(T? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NullableNumericAssertions : NumericAssertionsBase\n where T : struct, IComparable\n where TAssertions : NullableNumericAssertions\n{\n private readonly AssertionChain assertionChain;\n\n public NullableNumericAssertions(T? value, AssertionChain assertionChain)\n : base(assertionChain)\n {\n Subject = value;\n this.assertionChain = assertionChain;\n }\n\n public override T? Subject { get; }\n\n /// \n /// Asserts that a nullable numeric value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint HaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected a value{reason}.\");\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable numeric value is not .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotBeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return HaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that a nullable numeric value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint NotHaveValue([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n assertionChain\n .ForCondition(!Subject.HasValue)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Did not expect a value{reason}, but found {0}.\", Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n\n /// \n /// Asserts that a nullable numeric value is .\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public AndConstraint BeNull([StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n return NotHaveValue(because, becauseArgs);\n }\n\n /// \n /// Asserts that the is satisfied.\n /// \n /// \n /// The predicate which must be satisfied\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n /// is .\n public AndConstraint Match(Expression> predicate,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n assertionChain\n .ForCondition(predicate.Compile()(Subject))\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected value to match {0}{reason}, but found {1}.\", predicate, Subject);\n\n return new AndConstraint((TAssertions)this);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeEmpty.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeEmpty specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void When_collection_is_empty_as_expected_it_should_not_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().BeEmpty();\n }\n\n [Fact]\n public void When_collection_is_not_empty_unexpectedly_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().BeEmpty(\"that's what we expect\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be empty because that's what we expect, but found at least one item*1*\");\n }\n\n [Fact]\n public void When_asserting_collection_with_items_is_not_empty_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotBeEmpty();\n }\n\n [Fact]\n public void When_asserting_collection_with_items_is_not_empty_it_should_enumerate_the_collection_only_once()\n {\n // Arrange\n var trackingEnumerable = new TrackingTestEnumerable(1, 2, 3);\n\n // Act\n trackingEnumerable.Should().NotBeEmpty();\n\n // Assert\n trackingEnumerable.Enumerator.LoopCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_collection_without_items_is_not_empty_it_should_fail()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_collection_without_items_is_not_empty_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to be empty because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().BeEmpty(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to be empty *failure message*, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([]);\n\n // Act\n collection.Should().BeEmpty();\n\n // Assert\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_non_empty_collection_is_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([1, 2, 3]);\n\n // Act\n Action act = () => collection.Should().BeEmpty();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be empty, but found at least one item {1}.\");\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotBeEmpty(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to be empty *failure message*, but found .\");\n }\n\n [Fact]\n public void When_asserting_an_infinite_collection_to_be_empty_it_should_throw_correctly()\n {\n // Arrange\n var collection = new InfiniteEnumerable();\n\n // Act\n Action act = () => collection.Should().BeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void When_asserting_collection_to_be_not_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotBeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_not_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([42]);\n\n // Act\n collection.Should().NotBeEmpty();\n\n // Assert\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n }\n\n private sealed class InfiniteEnumerable : IEnumerable\n {\n public IEnumerator GetEnumerator() => new InfiniteEnumerator();\n\n IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n }\n\n private sealed class InfiniteEnumerator : IEnumerator\n {\n public bool MoveNext() => true;\n\n public void Reset() { }\n\n public object Current => new();\n\n object IEnumerator.Current => Current;\n\n public void Dispose() { }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/ObjectExtensionsSpecs.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class ObjectExtensionsSpecs\n{\n [Theory]\n [MemberData(nameof(GetNonEquivalentNumericData))]\n public void When_comparing_non_equivalent_boxed_numerics_it_should_fail(object actual, object expected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, expected);\n\n // Assert\n success.Should().BeFalse();\n }\n\n public static TheoryData GetNonEquivalentNumericData => new()\n {\n { double.Epsilon, 0M }, // double.Epsilon cannot be represented in Decimal\n { 0M, double.Epsilon },\n { double.Epsilon, 0.3M }, // 0.3M cannot be represented in double\n { 0.3M, double.Epsilon },\n { (byte)2, 256 }, // 256 cannot be represented in byte\n { 256, (byte)2 },\n { -1, (ushort)65535 }, // 65535 is -1 casted to ushort\n { (ushort)65535, -1 },\n { 0.02d, 0 },\n { 0, 0.02d },\n { 0.02f, 0 },\n { 0, 0.02f },\n { long.MaxValue, 9.22337204E+18 },\n { 9.22337204E+18, long.MaxValue },\n { 9223372030000000000L, 9.22337204E+18 },\n { 9.22337204E+18, 9223372030000000000L }\n };\n\n [Theory]\n [MemberData(nameof(GetNumericAndNumericData))]\n public void When_comparing_a_numeric_to_a_numeric_it_should_succeed(object actual, object expected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, expected);\n\n // Assert\n success.Should().BeTrue();\n }\n\n public static TheoryData GetNumericAndNumericData()\n {\n var pairs =\n from x in GetNumericIConvertibles()\n from y in GetNumericIConvertibles()\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n [Theory]\n [MemberData(nameof(GetNonNumericAndNumericData))]\n public void When_comparing_a_non_numeric_to_a_numeric_it_should_fail(object actual, object unexpected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, unexpected);\n\n // Assert\n success.Should().BeFalse();\n }\n\n public static TheoryData GetNonNumericAndNumericData()\n {\n var pairs =\n from x in GetNonNumericIConvertibles()\n from y in GetNumericIConvertibles()\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n [Theory]\n [MemberData(nameof(GetNumericAndNonNumericData))]\n public void When_comparing_a_numeric_to_a_non_numeric_it_should_fail(object actual, object unexpected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, unexpected);\n\n // Assert\n success.Should().BeFalse();\n }\n\n public static TheoryData GetNumericAndNonNumericData()\n {\n var pairs =\n from x in GetNumericIConvertibles()\n from y in GetNonNumericIConvertibles()\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n [Theory]\n [MemberData(nameof(GetNonNumericAndNonNumericData))]\n public void When_comparing_a_non_numeric_to_a_non_numeric_it_should_fail(object actual, object unexpected)\n {\n // Arrange\n Func comparer = ObjectExtensions.GetComparer();\n\n // Act\n bool success = comparer(actual, unexpected);\n\n // Assert\n success.Should().BeFalse();\n }\n\n public static TheoryData GetNonNumericAndNonNumericData()\n {\n object[] nonNumerics = GetNonNumericIConvertibles();\n\n var pairs =\n from x in nonNumerics\n from y in nonNumerics\n where x != y\n select (x, y);\n\n var data = new TheoryData();\n\n foreach (var (x, y) in pairs)\n {\n data.Add(x, y);\n }\n\n return data;\n }\n\n private static object[] GetNumericIConvertibles()\n {\n return\n [\n (byte)1,\n (sbyte)1,\n (short)1,\n (ushort)1,\n 1,\n 1U,\n 1L,\n 1UL,\n 1F,\n 1D,\n 1M,\n ];\n }\n\n private static object[] GetNonNumericIConvertibles()\n {\n return\n [\n true,\n '\\u0001',\n new DateTime(1),\n DBNull.Value,\n \"1\"\n ];\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventHandlerFactory.cs", "using System;\nusing System.Reflection;\nusing System.Reflection.Emit;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Static methods that aid in generic event subscription\n/// \ninternal static class EventHandlerFactory\n{\n /// \n /// Generates an eventhandler for an event of type eventSignature that calls RegisterEvent on recorder\n /// when invoked.\n /// \n public static Delegate GenerateHandler(Type eventSignature, EventRecorder recorder)\n {\n Type returnType = GetDelegateReturnType(eventSignature);\n Type[] parameters = GetDelegateParameterTypes(eventSignature);\n\n Module module = recorder.GetType()\n .Module;\n\n var eventHandler = new DynamicMethod(\n eventSignature.Name + \"DynamicHandler\",\n returnType,\n AppendParameterListThisReference(parameters),\n module);\n\n MethodInfo methodToCall = typeof(EventRecorder).GetMethod(nameof(EventRecorder.RecordEvent),\n BindingFlags.Instance | BindingFlags.Public);\n\n ILGenerator ilGen = eventHandler.GetILGenerator();\n\n // Make room for the one and only local variable in our function\n ilGen.DeclareLocal(typeof(object[]));\n\n // Create the object array for the parameters and store in local var index 0\n ilGen.Emit(OpCodes.Ldc_I4, parameters.Length);\n ilGen.Emit(OpCodes.Newarr, typeof(object));\n ilGen.Emit(OpCodes.Stloc_0);\n\n for (var index = 0; index < parameters.Length; index++)\n {\n // Push the object array onto the evaluation stack\n ilGen.Emit(OpCodes.Ldloc_0);\n\n // Push the array index to store our parameter in onto the evaluation stack\n ilGen.Emit(OpCodes.Ldc_I4, index);\n\n // Load the parameter\n ilGen.Emit(OpCodes.Ldarg, index + 1);\n\n // Box value-type parameters\n if (parameters[index].IsValueType)\n {\n ilGen.Emit(OpCodes.Box, parameters[index]);\n }\n\n // Store the parameter in the object array\n ilGen.Emit(OpCodes.Stelem_Ref);\n }\n\n // Push the this-reference on the stack as param 0 for calling the handler\n ilGen.Emit(OpCodes.Ldarg_0);\n\n // Push the object array onto the stack as param 1 for calling the handler\n ilGen.Emit(OpCodes.Ldloc_0);\n\n // Call the handler\n ilGen.EmitCall(OpCodes.Callvirt, methodToCall, null);\n\n ilGen.Emit(OpCodes.Ret);\n\n return eventHandler.CreateDelegate(eventSignature, recorder);\n }\n\n /// \n /// Finds the Return Type of a Delegate.\n /// \n private static Type GetDelegateReturnType(Type d)\n {\n MethodInfo invoke = DelegateInvokeMethod(d);\n return invoke.ReturnType;\n }\n\n /// \n /// Returns an Array of Types that make up a delegate's parameter signature.\n /// \n private static Type[] GetDelegateParameterTypes(Type d)\n {\n MethodInfo invoke = DelegateInvokeMethod(d);\n\n ParameterInfo[] parameterInfo = invoke.GetParameters();\n var parameters = new Type[parameterInfo.Length];\n\n for (var index = 0; index < parameterInfo.Length; index++)\n {\n parameters[index] = parameterInfo[index].ParameterType;\n }\n\n return parameters;\n }\n\n /// \n /// Returns an array of types appended with an EventRecorder reference at the beginning.\n /// \n private static Type[] AppendParameterListThisReference(Type[] parameters)\n {\n var newList = new Type[parameters.Length + 1];\n newList[0] = typeof(EventRecorder);\n\n for (var index = 0; index < parameters.Length; index++)\n {\n newList[index + 1] = parameters[index];\n }\n\n return newList;\n }\n\n /// \n /// Returns T/F Dependent on a Type Being a Delegate.\n /// \n private static bool TypeIsDelegate(Type d)\n {\n if (d.BaseType != typeof(MulticastDelegate))\n {\n return false;\n }\n\n MethodInfo invoke = d.GetMethod(\"Invoke\");\n return invoke is not null;\n }\n\n /// \n /// Returns the MethodInfo for the Delegate's \"Invoke\" Method.\n /// \n private static MethodInfo DelegateInvokeMethod(Type d)\n {\n if (!TypeIsDelegate(d))\n {\n throw new ArgumentException(\"Type is not a Delegate!\", nameof(d));\n }\n\n MethodInfo invoke = d.GetMethod(\"Invoke\");\n return invoke;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AssertionFailureSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class AssertionFailureSpecs\n{\n private static readonly string AssertionsTestSubClassName = typeof(AssertionsTestSubClass).Name;\n\n [Fact]\n public void When_reason_starts_with_because_it_should_not_do_anything()\n {\n // Arrange\n var assertions = new AssertionsTestSubClass();\n\n // Act\n Action action = () =>\n assertions.AssertFail(\"because {0} should always fail.\", AssertionsTestSubClassName);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected it to fail because AssertionsTestSubClass should always fail.\");\n }\n\n [Fact]\n public void When_reason_does_not_start_with_because_it_should_be_added()\n {\n // Arrange\n var assertions = new AssertionsTestSubClass();\n\n // Act\n Action action = () =>\n assertions.AssertFail(\"{0} should always fail.\", AssertionsTestSubClassName);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected it to fail because AssertionsTestSubClass should always fail.\");\n }\n\n [Fact]\n public void When_reason_starts_with_because_but_is_prefixed_with_blanks_it_should_not_do_anything()\n {\n // Arrange\n var assertions = new AssertionsTestSubClass();\n\n // Act\n Action action = () =>\n assertions.AssertFail(\"\\r\\nbecause {0} should always fail.\", AssertionsTestSubClassName);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected it to fail\\r\\nbecause AssertionsTestSubClass should always fail.\");\n }\n\n [Fact]\n public void When_reason_does_not_start_with_because_but_is_prefixed_with_blanks_it_should_add_because_after_the_blanks()\n {\n // Arrange\n var assertions = new AssertionsTestSubClass();\n\n // Act\n Action action = () =>\n assertions.AssertFail(\"\\r\\n{0} should always fail.\", AssertionsTestSubClassName);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected it to fail\\r\\nbecause AssertionsTestSubClass should always fail.\");\n }\n\n internal class AssertionsTestSubClass\n {\n private readonly AssertionChain assertionChain = AssertionChain.GetOrCreate();\n\n public void AssertFail(string because, params object[] becauseArgs)\n {\n assertionChain\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected it to fail{reason}\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/PredicateLambdaExpressionValueFormatterSpecs.cs", "using System;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class PredicateLambdaExpressionValueFormatterSpecs\n{\n private readonly PredicateLambdaExpressionValueFormatter formatter = new();\n\n [Fact]\n public void Constructor_expression_with_argument_can_be_formatted()\n {\n // Arrange\n Expression expression = (string arg) => new TestItem { Value = arg };\n\n // Act\n string result = Formatter.ToString(expression);\n\n // Assert\n result.Should().Be(\"new TestItem() {Value = arg}\");\n }\n\n [Fact]\n public void Constructor_expression_can_be_simplified()\n {\n // Arrange\n string value = \"foo\";\n Expression expression = () => new TestItem { Value = value };\n\n // Act\n string result = Formatter.ToString(expression);\n\n // Assert\n result.Should().Be(\"new TestItem() {Value = \\\"foo\\\"}\");\n }\n\n private sealed class TestItem\n {\n public string Value { get; set; }\n }\n\n [Fact]\n public void When_first_level_properties_are_tested_for_equality_against_constants_then_output_should_be_readable()\n {\n // Act\n string result = Format(a => a.Text == \"foo\" && a.Number == 123);\n\n // Assert\n result.Should().Be(\"(a.Text == \\\"foo\\\") AndAlso (a.Number == 123)\");\n }\n\n [Fact]\n public void\n When_first_level_properties_are_tested_for_equality_against_constant_expressions_then_output_should_contain_values_of_constant_expressions()\n {\n // Arrange\n var expectedText = \"foo\";\n var expectedNumber = 123;\n\n // Act\n string result = Format(a => a.Text == expectedText && a.Number == expectedNumber);\n\n // Assert\n result.Should().Be(\"(a.Text == \\\"foo\\\") AndAlso (a.Number == 123)\");\n }\n\n [Fact]\n public void When_more_than_two_conditions_are_joined_with_and_operator_then_output_should_not_have_nested_parenthesis()\n {\n // Act\n string result = Format(a => a.Text == \"123\" && a.Number >= 0 && a.Number <= 1000);\n\n // Assert\n result.Should().Be(\"(a.Text == \\\"123\\\") AndAlso (a.Number >= 0) AndAlso (a.Number <= 1000)\");\n }\n\n [Fact]\n public void When_condition_contains_extension_method_then_extension_method_must_be_formatted()\n {\n // Act\n string result = Format(a => a.TextIsNotBlank() && a.Number >= 0 && a.Number <= 1000);\n\n // Assert\n result.Should().Be(\"a.TextIsNotBlank() AndAlso (a.Number >= 0) AndAlso (a.Number <= 1000)\");\n }\n\n [Fact]\n public void When_condition_contains_linq_extension_method_then_extension_method_must_be_formatted()\n {\n // Arrange\n int[] allowed = [1, 2, 3];\n\n // Act\n string result = Format(a => allowed.Contains(a));\n\n // Assert\n result.Should().Be(\"value(System.Int32[]).Contains(a)\");\n }\n\n [Fact]\n public void Formatting_a_lifted_binary_operator()\n {\n // Arrange\n var subject = new ClassWithNullables { Number = 42 };\n\n // Act\n Action act = () => subject.Should().Match(e => e.Number > 43);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*e.Number > *43*\");\n }\n\n private string Format(Expression> expression) => Format(expression);\n\n private string Format(Expression> expression)\n {\n var graph = new FormattedObjectGraph(maxLines: 100);\n\n formatter.Format(expression, graph, new FormattingContext(), null);\n\n return graph.ToString();\n }\n}\n\ninternal class ClassWithNullables\n{\n public int? Number { get; set; }\n}\n\ninternal class SomeClass\n{\n public string Text { get; set; }\n\n public int Number { get; set; }\n}\n\ninternal static class SomeClassExtensions\n{\n public static bool TextIsNotBlank(this SomeClass someObject) => !string.IsNullOrWhiteSpace(someObject.Text);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/GlobalConfigurationSpecs.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Configuration;\nusing AwesomeAssertions.Execution;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\n[Collection(\"ConfigurationSpecs\")]\npublic sealed class GlobalConfigurationSpecs : IDisposable\n{\n [Fact]\n public void Concurrently_accessing_the_configuration_is_safe()\n {\n // Act\n Action act = () => Parallel.For(\n 0,\n 10000,\n new ParallelOptions\n {\n MaxDegreeOfParallelism = 8\n },\n __ =>\n {\n AssertionConfiguration.Current.Formatting.ValueFormatterAssembly = string.Empty;\n _ = AssertionConfiguration.Current.Formatting.ValueFormatterDetectionMode;\n }\n );\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Can_override_the_runtime_test_framework_implementation()\n {\n // Arrange\n AssertionEngine.TestFramework = new NotImplementedTestFramework();\n\n // Act\n var act = () => 1.Should().Be(2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_override_the_runtime_test_framework()\n {\n // Arrange\n AssertionEngine.Configuration.TestFramework = TestFramework.NUnit;\n\n // Act\n var act = () => 1.Should().Be(2);\n\n // Assert\n act.Should().Throw().WithMessage(\"*nunit.framework*\");\n }\n\n private class NotImplementedTestFramework : ITestFramework\n {\n public bool IsAvailable => true;\n\n public void Throw(string message) => throw new NotImplementedException();\n }\n\n public void Dispose() => AssertionEngine.ResetToDefaults();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/OccurrenceConstraintSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class OccurrenceConstraintSpecs\n{\n public static TheoryData PassingConstraints => new()\n {\n { AtLeast.Once(), 1 },\n { AtLeast.Once(), 2 },\n { AtLeast.Twice(), 2 },\n { AtLeast.Twice(), 3 },\n { AtLeast.Thrice(), 3 },\n { AtLeast.Thrice(), 4 },\n { AtLeast.Times(4), 4 },\n { AtLeast.Times(4), 5 },\n { 4.TimesOrMore(), 4 },\n { 4.TimesOrMore(), 5 },\n { AtMost.Once(), 0 },\n { AtMost.Once(), 1 },\n { AtMost.Twice(), 1 },\n { AtMost.Twice(), 2 },\n { AtMost.Thrice(), 2 },\n { AtMost.Thrice(), 3 },\n { AtMost.Times(4), 3 },\n { AtMost.Times(4), 4 },\n { 4.TimesOrLess(), 4 },\n { 4.TimesOrLess(), 1 },\n { Exactly.Once(), 1 },\n { Exactly.Twice(), 2 },\n { Exactly.Thrice(), 3 },\n { Exactly.Times(4), 4 },\n { 4.TimesExactly(), 4 },\n { LessThan.Twice(), 1 },\n { LessThan.Thrice(), 2 },\n { LessThan.Times(4), 3 },\n { MoreThan.Once(), 2 },\n { MoreThan.Twice(), 3 },\n { MoreThan.Thrice(), 4 },\n { MoreThan.Times(4), 5 }\n };\n\n [Theory]\n [MemberData(nameof(PassingConstraints))]\n public void Occurrence_constraint_passes(OccurrenceConstraint constraint, int occurrences)\n {\n // Act / Assert\n AssertionChain.GetOrCreate()\n .ForConstraint(constraint, occurrences)\n .FailWith(\"\");\n }\n\n public static TheoryData FailingConstraints => new()\n {\n { AtLeast.Once(), 0 },\n { AtLeast.Twice(), 1 },\n { AtLeast.Thrice(), 2 },\n { AtLeast.Times(4), 3 },\n { 4.TimesOrMore(), 3 },\n { AtMost.Once(), 2 },\n { AtMost.Twice(), 3 },\n { AtMost.Thrice(), 4 },\n { AtMost.Times(4), 5 },\n { 4.TimesOrLess(), 5 },\n { Exactly.Once(), 0 },\n { Exactly.Once(), 2 },\n { Exactly.Twice(), 1 },\n { Exactly.Twice(), 3 },\n { Exactly.Thrice(), 2 },\n { Exactly.Thrice(), 4 },\n { Exactly.Times(4), 3 },\n { Exactly.Times(4), 5 },\n { 4.TimesExactly(), 1 },\n { LessThan.Twice(), 2 },\n { LessThan.Twice(), 3 },\n { LessThan.Thrice(), 3 },\n { LessThan.Thrice(), 4 },\n { LessThan.Times(4), 4 },\n { LessThan.Times(4), 5 },\n { MoreThan.Once(), 0 },\n { MoreThan.Once(), 1 },\n { MoreThan.Twice(), 1 },\n { MoreThan.Twice(), 2 },\n { MoreThan.Thrice(), 2 },\n { MoreThan.Thrice(), 3 },\n { MoreThan.Times(4), 3 },\n { MoreThan.Times(4), 4 },\n };\n\n [Theory]\n [MemberData(nameof(FailingConstraints))]\n public void Occurrence_constraint_fails(OccurrenceConstraint constraint, int occurrences)\n {\n // Act\n Action act = () => AssertionChain.GetOrCreate()\n .ForConstraint(constraint, occurrences)\n .FailWith($\"Expected occurrence to be {constraint.Mode} {constraint.ExpectedCount}, but it was {occurrences}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected occurrence to be *, but it was *\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedXunitTestCase.cs", "using System;\nusing System.ComponentModel;\nusing System.Globalization;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedXunitTestCase : XunitTestCase\n{\n private string culture;\n\n [EditorBrowsable(EditorBrowsableState.Never)]\n [Obsolete(\"Called by the de-serializer; should only be called by deriving classes for de-serialization purposes\")]\n public CulturedXunitTestCase() { }\n\n public CulturedXunitTestCase(IMessageSink diagnosticMessageSink,\n TestMethodDisplay defaultMethodDisplay,\n TestMethodDisplayOptions defaultMethodDisplayOptions,\n ITestMethod testMethod,\n string culture,\n object[] testMethodArguments = null)\n : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)\n {\n Initialize(culture);\n }\n\n private void Initialize(string culture)\n {\n this.culture = culture;\n\n Traits.Add(\"Culture\", culture);\n\n DisplayName += $\"[{culture}]\";\n }\n\n protected override string GetUniqueID() => $\"{base.GetUniqueID()}[{culture}]\";\n\n public override void Deserialize(IXunitSerializationInfo data)\n {\n base.Deserialize(data);\n\n Initialize(data.GetValue(\"Culture\"));\n }\n\n public override void Serialize(IXunitSerializationInfo data)\n {\n base.Serialize(data);\n\n data.AddValue(\"Culture\", culture);\n }\n\n public override async Task RunAsync(IMessageSink diagnosticMessageSink,\n IMessageBus messageBus,\n object[] constructorArguments,\n ExceptionAggregator aggregator,\n CancellationTokenSource cancellationTokenSource)\n {\n CultureInfo originalCulture = CurrentCulture;\n CultureInfo originalUICulture = CurrentUICulture;\n\n try\n {\n var cultureInfo = new CultureInfo(culture);\n CurrentCulture = cultureInfo;\n CurrentUICulture = cultureInfo;\n\n return await base.RunAsync(diagnosticMessageSink, messageBus, constructorArguments, aggregator,\n cancellationTokenSource);\n }\n finally\n {\n CurrentCulture = originalCulture;\n CurrentUICulture = originalUICulture;\n }\n }\n\n private static CultureInfo CurrentCulture\n {\n get => CultureInfo.CurrentCulture;\n set => CultureInfo.CurrentCulture = value;\n }\n\n private static CultureInfo CurrentUICulture\n {\n get => CultureInfo.CurrentUICulture;\n set => CultureInfo.CurrentUICulture = value;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XDocumentAssertionSpecs.cs", "using System;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XDocumentAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_asserting_a_xml_document_is_equal_to_the_same_xml_document_it_should_succeed()\n {\n // Arrange\n var document = new XDocument();\n var sameXDocument = document;\n\n // Act / Assert\n document.Should().Be(sameXDocument);\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equal_to_a_different_xml_document_it_should_fail()\n {\n // Arrange\n var theDocument = new XDocument();\n var otherXDocument = new XDocument();\n\n // Act\n Action act = () =>\n theDocument.Should().Be(otherXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be [XML document without root element], but found [XML document without root element].\");\n }\n\n [Fact]\n public void When_the_expected_element_is_null_it_fails()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().Be(new XDocument(), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be [XML document without root element] *failure message*, but found .\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_documents_are_null_it_succeeds()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().Be(null);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_document_is_expected_to_equal_null_it_fails()\n {\n // Arrange\n XDocument theDocument = new();\n\n // Act\n Action act = () => theDocument.Should().Be(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be *failure message*, but found [XML document without root element].\");\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equal_to_a_different_xml_document_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().Be(otherXDocument, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be because we want to test the failure message, but found .\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_asserting_a_xml_document_is_not_equal_to_a_different_xml_document_it_should_succeed()\n {\n // Arrange\n var document = new XDocument();\n var otherXDocument = new XDocument();\n\n // Act / Assert\n document.Should().NotBe(otherXDocument);\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_not_equal_to_the_same_xml_document_it_should_fail()\n {\n // Arrange\n var theDocument = new XDocument();\n var sameXDocument = theDocument;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBe(sameXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be [XML document without root element].\");\n }\n\n [Fact]\n public void When_a_null_document_is_not_supposed_to_be_a_document_it_succeeds()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act / Assert\n theDocument.Should().NotBe(new XDocument());\n }\n\n [Fact]\n public void When_a_document_is_not_supposed_to_be_null_it_succeeds()\n {\n // Arrange\n XDocument theDocument = new();\n\n // Act / Assert\n theDocument.Should().NotBe(null);\n }\n\n [Fact]\n public void When_a_null_document_is_not_supposed_to_be_equal_to_null_it_fails()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().NotBe(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theDocument to be *failure message*.\");\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_not_equal_to_the_same_xml_document_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var sameXDocument = theDocument;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBe(sameXDocument, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be because we want to test the failure message.\");\n }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void When_asserting_a_xml_document_is_equivalent_to_the_same_xml_document_it_should_succeed()\n {\n // Arrange\n var document = new XDocument();\n var sameXDocument = document;\n\n // Act / Assert\n document.Should().BeEquivalentTo(sameXDocument);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_selfclosing_document_is_equivalent_to_a_different_xml_document_with_same_structure_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n document.Should().BeEquivalentTo(otherXDocument);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_equivalent_to_a_different_xml_document_with_same_structure_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n document.Should().BeEquivalentTo(otherXDocument);\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equivalent_to_a_xml_document_with_elements_missing_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(otherXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in theDocument at \\\"/parent\\\", but found Element \\\"child2\\\".\");\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_equivalent_to_a_different_xml_document_with_extra_elements_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child2\\\" in theDocument at \\\"/parent\\\", but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_with_selfclosing_child_is_equivalent_to_a_different_xml_document_with_subchild_child_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(otherXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child\\\" in theDocument at \\\"/parent/child\\\", but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_equivalent_to_a_different_xml_document_elements_missing_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in theDocument at \\\"/parent\\\" because we want to test the failure message,\"\n + \" but found Element \\\"child2\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_equivalent_to_a_different_xml_document_with_extra_elements_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child2\\\" in theDocument at \\\"/parent\\\" because we want to test the failure message,\"\n + \" but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void When_a_document_is_null_then_be_equivalent_to_null_succeeds()\n {\n XDocument theDocument = null;\n\n // Act / Assert\n theDocument.Should().BeEquivalentTo(null);\n }\n\n [Fact]\n public void When_a_document_is_null_then_be_equivalent_to_a_document_fails()\n {\n XDocument theDocument = null;\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(\n XDocument.Parse(\"\"), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theDocument to be equivalent to *failure message*\" +\n \", but found \\\"\\\".\");\n }\n\n [Fact]\n public void When_a_document_is_equivalent_to_null_it_fails()\n {\n XDocument theDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theDocument to be equivalent to \\\"\\\" *failure message*\" +\n \", but found .\");\n }\n\n [Fact]\n public void\n When_assertion_an_xml_document_is_equivalent_to_a_different_xml_document_with_different_namespace_prefix_it_should_succeed()\n {\n // Arrange\n var subject = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_a_different_xml_document_which_differs_only_on_unused_namespace_declaration_it_should_succeed()\n {\n // Arrange\n var subject = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_lacks_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message, but found none.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_has_extra_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect to find attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_has_different_attribute_values_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"a\\\" in theDocument at \\\"/xml/element\\\" to have value \\\"c\\\" because we want to test the failure message, but found \\\"b\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_has_attribute_with_different_namespace_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect to find attribute \\\"ns:a\\\" in theDocument at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_which_has_different_text_contents_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"a\");\n var expected = XDocument.Parse(\"b\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected content to be \\\"b\\\" in theDocument at \\\"/xml\\\" because we want to test the failure message, but found \\\"a\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_document_is_equivalent_to_different_xml_document_with_different_comments_it_should_succeed()\n {\n // Arrange\n var subject = XDocument.Parse(\"\");\n var expected = XDocument.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_an_xml_document_but_has_different_attribute_value_it_should_fail_with_xpath_to_difference()\n {\n // Arrange\n XDocument actual = XDocument.Parse(\"\");\n XDocument expected = XDocument.Parse(\"\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"/xml/b\\\"*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_document_with_repeating_element_names_but_differs_it_should_fail_with_index_xpath_to_difference()\n {\n // Arrange\n XDocument actual = XDocument.Parse(\n \"\");\n\n XDocument expected = XDocument.Parse(\n \"\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"/xml/xml2[3]/a[2]\\\"*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_document_with_repeating_element_names_on_different_levels_but_differs_it_should_fail_with_index_xpath_to_difference()\n {\n // Arrange\n XDocument actual = XDocument.Parse(\n \"\");\n\n XDocument expected = XDocument.Parse(\n \"\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"/xml/xml[3]/xml[2]\\\"*\");\n }\n\n [Fact]\n public void\n When_asserting_equivalence_of_document_with_repeating_element_names_with_different_parents_but_differs_it_should_fail_with_index_xpath_to_difference()\n {\n // Arrange\n XDocument actual = XDocument.Parse(\n \"\");\n\n XDocument expected = XDocument.Parse(\n \"\");\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"/root/xml1[3]/xml2[2]\\\"*\");\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_elements_missing_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n document.Should().NotBeEquivalentTo(otherXDocument);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_extra_elements_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n document.Should().NotBeEquivalentTo(otherXDocument);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_same_structure_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherXDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(otherXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_xml_document_is_not_equivalent_to_the_same_xml_document_it_should_fail()\n {\n // Arrange\n var theDocument = new XDocument();\n var sameXDocument = theDocument;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(sameXDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_same_structure_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var otherDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(otherDocument, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_same_contents_but_different_ns_prefixes_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(@\"\");\n var otherXDocument = XDocument.Parse(@\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(otherXDocument, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_a_different_xml_document_with_same_contents_but_extra_unused_xmlns_declaration_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(@\"\");\n var otherDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(otherDocument);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_document_is_not_equivalent_to_the_same_xml_document_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n var sameXDocument = theDocument;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeEquivalentTo(sameXDocument, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theDocument to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void When_a_null_document_is_unexpected_equivalent_to_null_it_fails()\n {\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().NotBeEquivalentTo(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theDocument to be equivalent *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_a_null_document_is_not_equivalent_to_a_document_it_succeeds()\n {\n XDocument theDocument = null;\n\n // Act / Assert\n theDocument.Should().NotBeEquivalentTo(XDocument.Parse(\"\"));\n }\n\n [Fact]\n public void When_a_document_is_not_equivalent_to_null_it_succeeds()\n {\n XDocument theDocument = XDocument.Parse(\"\");\n\n // Act / Assert\n theDocument.Should().NotBeEquivalentTo(null);\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_asserting_a_null_xml_document_is_null_it_should_succeed()\n {\n // Arrange\n XDocument document = null;\n\n // Act / Assert\n document.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_a_non_null_xml_document_is_null_it_should_fail()\n {\n // Arrange\n var theDocument = new XDocument();\n\n // Act\n Action act = () =>\n theDocument.Should().BeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be , but found [XML document without root element].\");\n }\n\n [Fact]\n public void When_asserting_a_non_null_xml_document_is_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to be because we want to test the failure message, but found .\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_asserting_a_non_null_xml_document_is_not_null_it_should_succeed()\n {\n // Arrange\n var document = new XDocument();\n\n // Act / Assert\n document.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_document_is_not_null_it_should_fail()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected theDocument not to be .\");\n }\n\n [Fact]\n public void When_asserting_a_null_xml_document_is_not_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () =>\n theDocument.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument not to be because we want to test the failure message.\");\n }\n }\n\n public class HaveRoot\n {\n [Fact]\n public void When_asserting_document_has_root_element_and_it_does_it_should_succeed_and_return_it_for_chaining()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n XElement root = document.Should().HaveRoot(\"parent\").Subject;\n\n // Assert\n root.Should().BeSameAs(document.Root);\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => theDocument.Should().HaveRoot(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element \\\"unknown\\\", but found .\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveRoot(\"unknown\", \"because we want to test the failure message\");\n\n // Assert\n string expectedMessage = \"Expected theDocument to have root element \\\"unknown\\\"\" +\n \" because we want to test the failure message\" +\n $\", but found {Formatter.ToString(theDocument)}.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_asserting_a_null_document_has_root_element_it_should_fail()\n {\n // Arrange\n XDocument theDocument = null;\n\n // Act\n Action act = () => theDocument.Should().HaveRoot(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has a root element if the document itself is .\");\n }\n\n [Fact]\n public void When_asserting_a_document_has_a_root_element_with_a_null_name_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => theDocument.Should().HaveRoot(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has a root element if the expected name is *\");\n }\n\n [Fact]\n public void When_asserting_a_document_has_a_root_element_with_a_null_xname_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => theDocument.Should().HaveRoot((XName)null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has a root element if the expected name is *\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_with_ns_and_it_does_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveRoot(XName.Get(\"parent\", \"http://www.example.com/2012/test\"));\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_with_ns_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveRoot(XName.Get(\"unknown\", \"http://www.example.com/2012/test\"));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element \\\"{http://www.example.com/2012/test}unknown\\\", but found .\");\n }\n\n [Fact]\n public void Can_chain_another_assertion_on_the_root_element()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => theDocument.Should().HaveRoot(\"parent\").Which.Should().HaveElement(\"unknownChild\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument/parent to have child element*unknownChild*\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_element_with_ns_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveRoot(XName.Get(\"unknown\", \"http://www.example.com/2012/test\"),\n \"because we want to test the failure message\");\n\n // Assert\n string expectedMessage =\n \"Expected theDocument to have root element \\\"{http://www.example.com/2012/test}unknown\\\"\" +\n \" because we want to test the failure message\" +\n $\", but found {Formatter.ToString(theDocument)}.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n }\n\n public class HaveElement\n {\n [Fact]\n public void When_document_has_the_expected_child_element_it_should_not_throw_and_return_the_element_for_chaining()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n XElement element = document.Should().HaveElement(\"child\").Subject;\n\n // Assert\n element.Should().BeSameAs(document.Element(\"parent\").Element(\"child\"));\n }\n\n [Fact]\n public void Can_chain_another_assertion_on_the_root_element()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n var act = () => document.Should().HaveElement(\"child\").Which.Should().HaveElement(\"grandChild\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected document/child to have child element*grandChild*\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_with_child_element_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveElement(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element with child \\\"unknown\\\", but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_with_child_element_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveElement(\"unknown\", \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element with child \\\"unknown\\\" because we want to test the failure message,\"\n + \" but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_document_has_root_with_child_element_with_ns_and_it_does_it_should_succeed()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElement(XName.Get(\"child\", \"http://www.example.org/2012/test\"));\n }\n\n [Fact]\n public void When_asserting_document_has_root_with_child_element_with_ns_but_it_does_not_it_should_fail()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n document.Should().HaveElement(XName.Get(\"unknown\", \"http://www.example.org/2012/test\"));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected document to have root element with child \\\"{http://www.example.org/2012/test}unknown\\\",\"\n + \" but no such child element was found.\");\n }\n\n [Fact]\n public void\n When_asserting_document_has_root_with_child_element_with_ns_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theDocument = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theDocument.Should().HaveElement(XName.Get(\"unknown\", \"http://www.example.org/2012/test\"),\n \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theDocument to have root element with child \\\"{http://www.example.org/2012/test}unknown\\\"\"\n + \" because we want to test the failure message, but no such child element was found.\");\n }\n\n [Fact]\n public void\n When_asserting_document_has_root_with_child_element_with_attributes_it_should_be_possible_to_use_which_to_assert_on_the_element()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n XElement matchedElement = document.Should().HaveElement(\"child\").Subject;\n\n // Assert\n matchedElement.Should().BeOfType().And.HaveAttributeWithValue(\"attr\", \"1\");\n matchedElement.Name.Should().Be(XName.Get(\"child\"));\n }\n\n [Fact]\n public void When_asserting_a_null_document_has_an_element_it_should_fail()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () => document.Should().HaveElement(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has an element if the document itself is .\");\n }\n\n [Fact]\n public void When_asserting_a_document_without_root_element_has_an_element_it_should_fail()\n {\n // Arrange\n XDocument document = new();\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n document.Should().HaveElement(\"unknown\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected document to have root element with child \\\"unknown\\\", but it has no root element.\");\n }\n\n [Fact]\n public void When_asserting_a_document_has_an_element_with_a_null_name_it_should_fail()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has an element if the expected name is *\");\n }\n\n [Fact]\n public void When_asserting_a_document_has_an_element_with_a_null_xname_it_should_fail()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement((XName)null);\n\n // Assert\n act.Should().ThrowExactly().WithMessage(\n \"Cannot assert the document has an element if the expected name is *\");\n }\n }\n\n public class HaveElementWithValue\n {\n [Fact]\n public void The_document_cannot_be_null()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void The_expected_element_with_the_expected_value_is_valid()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElementWithValue(\"child\", \"b\");\n }\n\n [Fact]\n public void Throws_when_element_is_not_found()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(\"grandchild\", \"f\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*grandchild*f*element*isn't found*\");\n }\n\n [Fact]\n public void Throws_when_element_found_but_value_does_not_match()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(\"child\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*c*element*does not have such a value*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_with_namespace_is_null()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue((XName)null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(\"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null_and_searching_with_namespace()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(XNamespace.None + \"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void The_document_cannot_be_null_and_using_a_namespace()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () =>\n document.Should()\n .HaveElementWithValue(XNamespace.None + \"child\", \"b\", \"we want to test the {0} message\", \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*failure message*element itself is *\");\n }\n\n [Fact]\n public void Has_element_with_namespace_and_specified_value()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElementWithValue(XNamespace.None + \"child\", \"b\");\n }\n\n [Fact]\n public void Throws_when_element_with_namespace_is_not_found()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n document.Should().HaveElementWithValue(XNamespace.None + \"grandchild\", \"f\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\"*grandchild*f*element*isn't found*\");\n }\n\n [Fact]\n public void Throws_when_element_with_namespace_found_but_value_does_not_match()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElementWithValue(XNamespace.None + \"child\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*c*element*does not have such a value*\");\n }\n }\n\n public class HaveElementWithOccurrence\n {\n [Fact]\n public void When_asserting_document_has_two_child_elements_and_it_does_it_succeeds()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElement(\"child\", Exactly.Twice());\n }\n\n [Fact]\n public void Asserting_document_null_inside_an_assertion_scope_it_checks_the_whole_assertion_scope_before_failing()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n document.Should().HaveElement(\"child\", Exactly.Twice());\n document.Should().HaveElement(\"child\", Exactly.Twice());\n }\n };\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void\n Asserting_with_document_root_null_inside_an_assertion_scope_it_checks_the_whole_assertion_scope_before_failing()\n {\n // Arrange\n XDocument document = new();\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n document.Should().HaveElement(\"child\", Exactly.Twice());\n document.Should().HaveElement(\"child\", Exactly.Twice());\n }\n };\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_asserting_document_has_two_child_elements_but_it_does_have_three_it_fails()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement(\"child\", Exactly.Twice());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected document to have a root element containing a child \\\"child\\\"*exactly*2 times, but found it 3 times*\");\n }\n\n [Fact]\n public void Document_is_valid_and_expected_null_with_string_overload_it_fails()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement(null, Exactly.Twice());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has an element if the expected name is .*\");\n }\n\n [Fact]\n public void Document_is_valid_and_expected_null_with_x_name_overload_it_fails()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement((XName)null, Exactly.Twice());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the document has an element count if the element name is .*\");\n }\n\n [Fact]\n public void Chaining_after_a_successful_occurrence_check_does_continue_the_assertion()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act / Assert\n document.Should().HaveElement(\"child\", AtLeast.Twice())\n .Which.Should().NotBeNull();\n }\n\n [Fact]\n public void Chaining_after_a_non_successful_occurrence_check_does_not_continue_the_assertion()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => document.Should().HaveElement(\"child\", Exactly.Once())\n .Which.Should().NotBeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected document to have a root element containing a child \\\"child\\\"*exactly*1 time, but found it 3 times.\");\n }\n\n [Fact]\n public void When_asserting_a_null_document_to_have_an_element_count_it_should_fail()\n {\n // Arrange\n XDocument xDocument = null;\n\n // Act\n Action act = () => xDocument.Should().HaveElement(\"child\", AtLeast.Once());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the count if the document itself is .\");\n }\n }\n\n public class NotHaveElement\n {\n [Fact]\n public void The_document_cannot_be_null()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () => document.Should().NotHaveElement(\"child\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void The_document_does_not_have_this_element()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n document.Should().NotHaveElement(\"c\");\n }\n\n [Fact]\n public void Throws_when_element_found_but_expected_to_be_absent()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().NotHaveElement(\"child\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Did not*child*element*was found*\");\n }\n\n [Fact]\n public void Throws_when_unexpected_element_is_null()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().NotHaveElement(null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*unexpectedElement*\");\n }\n\n [Fact]\n public void Throws_when_unexpected_element_is_null_with_namespace()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => document.Should().NotHaveElement((XName)null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*unexpectedElement*\");\n }\n\n [Fact]\n public void Throws_when_null_with_namespace()\n {\n // Arrange\n XDocument document = null;\n\n // Act\n Action act = () =>\n document.Should()\n .NotHaveElement(XNamespace.None + \"child\", \"we want to test the {0} message\", \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*failure message*element itself is *\");\n }\n\n [Fact]\n public void Not_have_element_with_with_namespace()\n {\n // Arrange\n var document = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n document.Should().NotHaveElement(XNamespace.None + \"c\");\n }\n }\n\n public class NotHaveElementWithValue\n {\n [Fact]\n public void The_document_cannot_be_null()\n {\n // Arrange\n XDocument element = null;\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void Throws_when_element_with_specified_value_is_found()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not*element*child*value*b*does have this value*\");\n }\n\n [Fact]\n public void Passes_when_element_not_found()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(\"c\", \"f\");\n }\n\n [Fact]\n public void Passes_when_element_found_but_value_does_not_match()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(\"child\", \"c\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null_with_namespace()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue((XName)null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null_with_namespace()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void The_document_cannot_be_null_and_searching_with_namespace()\n {\n // Arrange\n XDocument element = null;\n\n // Act\n Action act = () =>\n element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"b\", \"we want to test the {0} message\",\n \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*failure message*element itself is *\");\n }\n\n [Fact]\n public void Throws_when_element_with_specified_value_is_found_with_namespace()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not expect*element*child*value*b*does have this value*\");\n }\n\n [Fact]\n public void Passes_when_element_with_namespace_not_found()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(XNamespace.None + \"c\", \"f\");\n }\n\n [Fact]\n public void Passes_when_element_with_namespace_found_but_value_does_not_match()\n {\n // Arrange\n var element = XDocument.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"c\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeNaN.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeNaN\n {\n [Fact]\n public void NaN_is_equal_to_NaN_when_its_a_float()\n {\n // Arrange\n float actual = float.NaN;\n\n // Act / Assert\n actual.Should().BeNaN();\n }\n\n [InlineData(-1f)]\n [InlineData(0f)]\n [InlineData(1f)]\n [InlineData(float.MinValue)]\n [InlineData(float.MaxValue)]\n [InlineData(float.Epsilon)]\n [InlineData(float.NegativeInfinity)]\n [InlineData(float.PositiveInfinity)]\n [Theory]\n public void Should_fail_when_asserting_normal_float_value_to_be_NaN(float actual)\n {\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_normal_float_value_to_be_NaN()\n {\n // Arrange\n float actual = 1;\n\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual to be NaN, but found 1F.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_NaN_as_float()\n {\n // Arrange\n float actual = float.NaN;\n\n // Act / Assert\n actual.Should().BeNaN()\n .And.Be(actual);\n }\n\n [Fact]\n public void NaN_is_equal_to_NaN_when_its_a_double()\n {\n // Arrange\n double actual = double.NaN;\n\n // Act / Assert\n actual.Should().BeNaN();\n }\n\n [InlineData(-1d)]\n [InlineData(0d)]\n [InlineData(1d)]\n [InlineData(double.MinValue)]\n [InlineData(double.MaxValue)]\n [InlineData(double.Epsilon)]\n [InlineData(double.NegativeInfinity)]\n [InlineData(double.PositiveInfinity)]\n [Theory]\n public void Should_fail_when_asserting_normal_double_value_to_be_NaN(double actual)\n {\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_normal_double_value_to_be_NaN()\n {\n // Arrange\n double actual = 1;\n\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual to be NaN, but found 1.0.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_NaN_as_double()\n {\n // Arrange\n double actual = double.NaN;\n\n // Act / Assert\n actual.Should().BeNaN()\n .And.Be(actual);\n }\n\n [Fact]\n public void NaN_is_equal_to_NaN_when_its_a_nullable_float()\n {\n // Arrange\n float? actual = float.NaN;\n\n // Act / Assert\n actual.Should().BeNaN();\n }\n\n [InlineData(null)]\n [InlineData(-1f)]\n [InlineData(0f)]\n [InlineData(1f)]\n [InlineData(float.MinValue)]\n [InlineData(float.MaxValue)]\n [InlineData(float.Epsilon)]\n [InlineData(float.NegativeInfinity)]\n [InlineData(float.PositiveInfinity)]\n [Theory]\n public void Should_fail_when_asserting_nullable_normal_float_value_to_be_NaN(float? actual)\n {\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_nullable_normal_float_value_to_be_NaN()\n {\n // Arrange\n float? actual = 1;\n\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual to be NaN, but found 1F.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_NaN_as_nullable_float()\n {\n // Arrange\n float? actual = float.NaN;\n\n // Act / Assert\n actual.Should().BeNaN()\n .And.Be(actual);\n }\n\n [Fact]\n public void NaN_is_equal_to_NaN_when_its_a_nullable_double()\n {\n // Arrange\n double? actual = double.NaN;\n\n // Act / Assert\n actual.Should().BeNaN();\n }\n\n [InlineData(null)]\n [InlineData(-1d)]\n [InlineData(0d)]\n [InlineData(1d)]\n [InlineData(double.MinValue)]\n [InlineData(double.MaxValue)]\n [InlineData(double.Epsilon)]\n [InlineData(double.NegativeInfinity)]\n [InlineData(double.PositiveInfinity)]\n [Theory]\n public void Should_fail_when_asserting_nullable_normal_double_value_to_be_NaN(double? actual)\n {\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_nullable_normal_double_value_to_be_NaN()\n {\n // Arrange\n double? actual = 1;\n\n // Act\n Action act = () => actual.Should().BeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual to be NaN, but found 1.0.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_NaN_as_nullable_double()\n {\n // Arrange\n double? actual = double.NaN;\n\n // Act / Assert\n actual.Should().BeNaN()\n .And.Be(actual);\n }\n }\n\n public class NotBeNaN\n {\n [InlineData(-1f)]\n [InlineData(0f)]\n [InlineData(1f)]\n [InlineData(float.MinValue)]\n [InlineData(float.MaxValue)]\n [InlineData(float.Epsilon)]\n [InlineData(float.NegativeInfinity)]\n [InlineData(float.PositiveInfinity)]\n [Theory]\n public void Normal_float_is_never_equal_to_NaN(float actual)\n {\n // Act / Assert\n actual.Should().NotBeNaN();\n }\n\n [Fact]\n public void Should_fail_when_asserting_NaN_as_float()\n {\n // Arrange\n float actual = float.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_NaN_as_float()\n {\n // Arrange\n float actual = float.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect actual to be NaN.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_normal_float_value()\n {\n // Arrange\n float actual = 1;\n\n // Act / Assert\n actual.Should().NotBeNaN()\n .And.Be(actual);\n }\n\n [InlineData(-1d)]\n [InlineData(0d)]\n [InlineData(1d)]\n [InlineData(double.MinValue)]\n [InlineData(double.MaxValue)]\n [InlineData(double.Epsilon)]\n [InlineData(double.NegativeInfinity)]\n [InlineData(double.PositiveInfinity)]\n [Theory]\n public void Normal_double_is_never_equal_to_NaN(double actual)\n {\n // Act / Assert\n actual.Should().NotBeNaN();\n }\n\n [Fact]\n public void Should_fail_when_asserting_NaN_as_double()\n {\n // Arrange\n double actual = double.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_NaN_as_double()\n {\n // Arrange\n double actual = double.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect actual to be NaN.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_normal_double_value()\n {\n // Arrange\n double actual = 1;\n\n // Act / Assert\n actual.Should().NotBeNaN()\n .And.Be(actual);\n }\n\n [InlineData(null)]\n [InlineData(-1f)]\n [InlineData(0f)]\n [InlineData(1f)]\n [InlineData(float.MinValue)]\n [InlineData(float.MaxValue)]\n [InlineData(float.Epsilon)]\n [InlineData(float.NegativeInfinity)]\n [InlineData(float.PositiveInfinity)]\n [Theory]\n public void Normal_nullable_float_is_never_equal_to_NaN(float? actual)\n {\n // Act / Assert\n actual.Should().NotBeNaN();\n }\n\n [Fact]\n public void Should_fail_when_asserting_NaN_as_nullable_float()\n {\n // Arrange\n float? actual = float.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_NaN_as_nullable_float()\n {\n // Arrange\n float? actual = float.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect actual to be NaN.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_normal_nullable_float_value()\n {\n // Arrange\n float? actual = 1;\n\n // Act / Assert\n actual.Should().NotBeNaN()\n .And.Be(actual);\n }\n\n [InlineData(null)]\n [InlineData(-1d)]\n [InlineData(0d)]\n [InlineData(1d)]\n [InlineData(double.MinValue)]\n [InlineData(double.MaxValue)]\n [InlineData(double.Epsilon)]\n [InlineData(double.NegativeInfinity)]\n [InlineData(double.PositiveInfinity)]\n [Theory]\n public void Normal_nullable_double_is_never_equal_to_NaN(double? actual)\n {\n // Act / Assert\n actual.Should().NotBeNaN();\n }\n\n [Fact]\n public void Should_fail_when_asserting_NaN_as_nullable_double()\n {\n // Arrange\n double? actual = double.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_a_descriptive_message_when_asserting_NaN_as_nullable_double()\n {\n // Arrange\n double? actual = double.NaN;\n\n // Act\n Action act = () => actual.Should().NotBeNaN();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect actual to be NaN.\");\n }\n\n [Fact]\n public void Should_chain_when_asserting_normal_nullable_double_value()\n {\n // Arrange\n double? actual = 1;\n\n // Act / Assert\n actual.Should().NotBeNaN()\n .And.Be(actual);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/AsyncFunctionExceptionAssertionSpecs.cs", "// ReSharper disable AsyncVoidLambda\n\nusing System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\n#if NET47\nusing AwesomeAssertions.Specs.Common;\n#endif\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class AsyncFunctionExceptionAssertionSpecs\n{\n [Fact]\n public void When_getting_the_subject_it_should_remain_unchanged()\n {\n // Arrange\n Func subject = () => Task.FromResult(42);\n\n // Act\n Action action = () => subject.Should().Subject.As().Should().BeSameAs(subject);\n\n // Assert\n action.Should().NotThrow(\"the Subject should remain the same\");\n }\n\n [Fact]\n public async Task When_subject_is_null_when_expecting_an_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().ThrowAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_subject_is_null_when_not_expecting_a_generic_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().NotThrowAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_subject_is_null_when_not_expecting_an_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().NotThrowAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_async_method_throws_an_empty_AggregateException_it_should_fail()\n {\n // Arrange\n Func act = () => throw new AggregateException();\n\n // Act\n Func act2 = () => act.Should().NotThrowAsync();\n\n // Assert\n await act2.Should().ThrowAsync();\n }\n\n [Collection(\"UIFacts\")]\n public partial class UIFacts\n {\n [UIFact]\n public async Task When_async_method_throws_an_empty_AggregateException_on_UI_thread_it_should_fail()\n {\n // Arrange\n Func act = () => throw new AggregateException();\n\n // Act\n Func act2 = () => act.Should().NotThrowAsync();\n\n // Assert\n await act2.Should().ThrowAsync();\n }\n }\n\n [Fact]\n public async Task When_async_method_throws_a_nested_AggregateException_it_should_provide_the_message()\n {\n // Arrange\n Func act = () => throw new AggregateException(new ArgumentException(\"That was wrong.\"));\n\n // Act & Assert\n await act.Should().ThrowAsync().WithMessage(\"That was wrong.\");\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task When_async_method_throws_a_nested_AggregateException_on_UI_thread_it_should_provide_the_message()\n {\n // Arrange\n Func act = () => throw new AggregateException(new ArgumentException(\"That was wrong.\"));\n\n // Act & Assert\n await act.Should().ThrowAsync().WithMessage(\"That was wrong.\");\n }\n }\n\n [Fact]\n public async Task When_async_method_throws_a_flat_AggregateException_it_should_provide_the_message()\n {\n // Arrange\n Func act = () => throw new AggregateException(\"That was wrong as well.\");\n\n // Act & Assert\n await act.Should().ThrowAsync().WithMessage(\"That was wrong as well.\");\n }\n\n [Fact]\n public async Task When_async_method_throws_a_nested_AggregateException_it_should_provide_unwrapped_exception_to_predicate()\n {\n // Arrange\n Func act = () => throw new AggregateException(new ArgumentException(\"That was wrong.\"));\n\n // Act & Assert\n await act.Should().ThrowAsync()\n .Where(i => i.Message == \"That was wrong.\");\n }\n\n [Fact]\n public async Task When_async_method_throws_a_flat_AggregateException_it_should_provide_it_to_predicate()\n {\n // Arrange\n Func act = () => throw new AggregateException(\"That was wrong as well.\");\n\n // Act & Assert\n await act.Should().ThrowAsync()\n .Where(i => i.Message == \"That was wrong as well.\");\n }\n\n#pragma warning disable xUnit1026 // Theory methods should use all of their parameters\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public async Task When_the_expected_exception_is_wrapped_async_it_should_succeed(Func action, T _)\n where T : Exception\n {\n // Act/Assert\n await action.Should().ThrowAsync();\n }\n\n [UITheory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public async Task When_the_expected_exception_is_wrapped_on_UI_thread_async_it_should_succeed(Func action, T _)\n where T : Exception\n {\n // Act/Assert\n await action.Should().ThrowAsync();\n }\n\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public async Task When_the_expected_exception_is_not_wrapped_async_it_should_fail(Func action, T _)\n where T : Exception\n {\n // Act\n Func act2 = () => action.Should().NotThrowAsync();\n\n // Assert\n await act2.Should().ThrowAsync();\n }\n\n [UITheory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public async Task When_the_expected_exception_is_not_wrapped_on_UI_thread_async_it_should_fail(Func action, T _)\n where T : Exception\n {\n // Act\n Func act2 = () => action.Should().NotThrowAsync();\n\n // Assert\n await act2.Should().ThrowAsync();\n }\n#pragma warning restore xUnit1026 // Theory methods should use all of their parameters\n\n public static TheoryData, Exception> AggregateExceptionTestData()\n {\n Func[] tasks =\n [\n AggregateExceptionWithLeftNestedException,\n AggregateExceptionWithRightNestedException\n ];\n\n Exception[] types =\n [\n new AggregateException(),\n new ArgumentNullException(),\n new InvalidOperationException()\n ];\n\n var data = new TheoryData, Exception>();\n\n foreach (var task in tasks)\n {\n foreach (var type in types)\n {\n data.Add(task, type);\n }\n }\n\n data.Add(EmptyAggregateException, new AggregateException());\n\n return data;\n }\n\n private static Task AggregateExceptionWithLeftNestedException()\n {\n var ex1 = new AggregateException(new InvalidOperationException());\n var ex2 = new ArgumentNullException();\n var wrapped = new AggregateException(ex1, ex2);\n\n return FromException(wrapped);\n }\n\n private static Task AggregateExceptionWithRightNestedException()\n {\n var ex1 = new ArgumentNullException();\n var ex2 = new AggregateException(new InvalidOperationException());\n var wrapped = new AggregateException(ex1, ex2);\n\n return FromException(wrapped);\n }\n\n private static Task EmptyAggregateException()\n {\n return FromException(new AggregateException());\n }\n\n private static Task FromException(AggregateException exception)\n {\n return Task.FromException(exception);\n }\n\n [Fact]\n public async Task When_subject_throws_subclass_of_expected_exact_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.ArgumentNullException.\");\n }\n\n [Fact]\n public async Task When_subject_ValueTask_throws_subclass_of_expected_exact_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.ArgumentNullException.\");\n }\n\n [Fact]\n public async Task When_subject_throws_aggregate_exception_and_not_expected_exact_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAggregateExceptionAsync())\n .Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.AggregateException.\");\n }\n\n [Fact]\n public async Task When_subject_throws_aggregate_exception_and_not_expected_exact_exception_through_ValueTask_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAggregateExceptionAsyncValueTask())\n .Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected type to be System.ArgumentException because IFoo.Do should do that, but found System.AggregateException.\");\n }\n\n [Fact]\n public async Task When_subject_throws_the_expected_exact_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act / Assert\n await asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().ThrowExactlyAsync();\n }\n\n [Fact]\n public async Task When_subject_throws_the_expected_exact_exception_through_ValueTask_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act / Assert\n await asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().ThrowExactlyAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_expected_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_expected_exception_through_ValueTask_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_subject_is_null_it_should_be_null()\n {\n // Arrange\n Func subject = null;\n\n // Act\n Func action = () => subject.Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"*found *\");\n }\n\n [Fact]\n public async Task When_async_method_throws_async_expected_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_expected_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.SucceedAsync())\n .Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected a to be thrown because IFoo.Do should do that, but no exception was thrown.\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_expected_exception_through_ValueTask_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.SucceedAsyncValueTask())\n .Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected a to be thrown because IFoo.Do should do that, but no exception was thrown.\");\n }\n\n [Fact]\n public async Task When_async_method_throws_unexpected_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected a to be thrown because IFoo.Do should do that, but found *\");\n }\n\n [Fact]\n public async Task When_async_method_throws_unexpected_exception_through_ValueTask_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\n \"Expected a to be thrown because IFoo.Do should do that, but found *\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_exception_and_that_was_expected_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.SucceedAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_exception_through_ValueTask_and_that_was_expected_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.SucceedAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_async_exception_and_that_was_expected_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.SucceedAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task When_async_method_does_not_throw_async_exception_on_UI_thread_and_that_was_expected_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.SucceedAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n }\n\n [Fact]\n public async Task When_subject_throws_subclass_of_expected_async_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync(\"because {0} should do that\", \"IFoo.Do\");\n }\n\n [Fact]\n public async Task When_function_of_task_int_in_async_method_throws_the_expected_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Func> f = () => asyncObject.ThrowTaskIntAsync(true);\n\n // Act / Assert\n await f.Should().ThrowAsync();\n }\n\n [Fact]\n public async Task When_function_of_task_int_in_async_method_throws_not_excepted_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Func> f = () => asyncObject.ThrowTaskIntAsync(true);\n\n // Act / Assert\n await f.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_subject_is_null_when_expecting_an_exact_exception_it_should_throw()\n {\n // Arrange\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n await action.Should().ThrowExactlyAsync(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_subject_throws_subclass_of_expected_async_exact_exception_it_should_throw()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n Func testAction = () => action.Should().ThrowExactlyAsync(\"ABCDE\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*ArgumentException*ABCDE*ArgumentNullException*\");\n }\n\n [Fact]\n public async Task When_subject_throws_aggregate_exception_instead_of_exact_exception_it_should_throw()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAggregateExceptionAsync();\n Func testAction = () => action.Should().ThrowExactlyAsync(\"ABCDE\");\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*ArgumentException*ABCDE*AggregateException*\");\n }\n\n [Fact]\n public async Task When_subject_throws_expected_async_exact_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task When_subject_throws_on_UI_thread_expected_async_exact_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().ThrowExactlyAsync(\"because {0} should do that\", \"IFoo.Do\");\n }\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_and_no_exception_was_expected_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exception, but found System.ArgumentException*\");\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_through_ValueTask_and_no_exception_was_expected_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exception, but found System.ArgumentException*\");\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_and_expected_not_to_throw_another_one_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task\n When_async_method_throws_exception_through_ValueTask_and_expected_not_to_throw_another_one_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_and_expected_not_to_throw_async_another_one_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject.ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(_ => asyncObject.SucceedAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task\n When_async_method_succeeds_and_expected_not_to_throw_particular_exception_through_ValueTask_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(_ => asyncObject.SucceedAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_expected_not_to_be_thrown_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsync())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect System.ArgumentException, but found*\");\n }\n\n [Fact]\n public async Task When_async_method_throws_exception_expected_through_ValueTask_not_to_be_thrown_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowAsyncValueTask())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect System.ArgumentException, but found*\");\n }\n\n [Fact]\n public async Task When_async_method_of_T_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(_ => asyncObject.ReturnTaskInt())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_ValueTask_async_method_of_T_succeeds_and_expected_not_to_throw_particular_exception_it_should_succeed()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(_ => asyncObject.ReturnValueTaskInt())\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_of_T_throws_exception_expected_not_to_be_thrown_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowTaskIntAsync(true))\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect System.ArgumentException, but found System.ArgumentException*\");\n }\n\n [Fact]\n public async Task When_ValueTask_async_method_of_T_throws_exception_expected_not_to_be_thrown_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n\n // Act\n Func action = () => asyncObject\n .Awaiting(x => x.ThrowValueTaskIntAsync(true))\n .Should().NotThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect System.ArgumentException, but found System.ArgumentException*\");\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_inner_exception_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new InvalidOperationException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerException();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_inner_exception_from_argument_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new InvalidOperationException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerException(typeof(InvalidOperationException));\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_inner_exception_exactly_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerExceptionExactly();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_inner_exception_exactly_defined_in_arguments_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerExceptionExactly(typeof(ArgumentException));\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_aggregate_exception_containing_expected_exception_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new InvalidOperationException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_throws_the_expected_exception_it_should_succeed()\n {\n // Arrange\n Func task = () => Throw.Async();\n\n // Act\n Func action = () => task\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_the_expected_inner_exception_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerException();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*InvalidOperation*Argument*\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_the_expected_inner_exception_from_argument_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerException(typeof(InvalidOperationException));\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*InvalidOperation*Argument*\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_the_expected_inner_exception_exactly_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentNullException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerExceptionExactly();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*ArgumentException*ArgumentNullException*\");\n }\n\n [Fact]\n public async Task\n When_async_method_does_not_throw_the_expected_inner_exception_exactly_defined_in_arguments_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async(new AggregateException(new ArgumentNullException()));\n\n // Act\n Func action = () => task\n .Should().ThrowAsync()\n .WithInnerExceptionExactly(typeof(ArgumentException));\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*ArgumentException*ArgumentNullException*\");\n }\n\n [Fact]\n public async Task When_async_method_does_not_throw_the_expected_exception_it_should_fail()\n {\n // Arrange\n Func task = () => Throw.Async();\n\n // Act\n Func action = () => task\n .Should().ThrowAsync();\n\n // Assert\n await action.Should().ThrowAsync().WithMessage(\"*InvalidOperation*Argument*\");\n }\n\n#pragma warning disable MA0147\n [Fact]\n public void When_asserting_async_void_method_should_throw_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Action asyncVoidMethod = async () => await asyncObject.IncompleteTask();\n\n // Act\n Action action = () => asyncVoidMethod.Should().Throw();\n\n // Assert\n action.Should().Throw(\"*async*void*\");\n }\n\n [Fact]\n public void When_asserting_async_void_method_should_throw_exactly_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Action asyncVoidMethod = async () => await asyncObject.IncompleteTask();\n\n // Act\n Action action = () => asyncVoidMethod.Should().ThrowExactly();\n\n // Assert\n action.Should().Throw(\"*async*void*\");\n }\n\n [Fact]\n public void When_asserting_async_void_method_should_not_throw_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Action asyncVoidMethod = async () => await asyncObject.IncompleteTask();\n\n // Act\n Action action = () => asyncVoidMethod.Should().NotThrow();\n\n // Assert\n action.Should().Throw(\"*async*void*\");\n }\n\n [Fact]\n public void When_asserting_async_void_method_should_not_throw_specific_exception_it_should_fail()\n {\n // Arrange\n var asyncObject = new AsyncClass();\n Action asyncVoidMethod = async () => await asyncObject.IncompleteTask();\n\n // Act\n Action action = () => asyncVoidMethod.Should().NotThrow();\n\n // Assert\n action.Should().Throw(\"*async*void*\");\n }\n#pragma warning restore MA0147\n\n [Fact]\n public async Task When_a_method_throws_with_a_matching_parameter_name_it_should_succeed()\n {\n // Arrange\n Func task = () => new AsyncClass().ThrowAsync(new ArgumentNullException(\"someParameter\"));\n\n // Act\n Func act = () =>\n task.Should().ThrowAsync()\n .WithParameterName(\"someParameter\");\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_a_method_throws_with_a_non_matching_parameter_name_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n Func task = () => new AsyncClass().ThrowAsync(new ArgumentNullException(\"someOtherParameter\"));\n\n // Act\n Func act = () =>\n task.Should().ThrowAsync()\n .WithParameterName(\"someParameter\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n await act.Should().ThrowAsync()\n .WithMessage(\"*with parameter name \\\"someParameter\\\"*we want to test the failure message*\\\"someOtherParameter\\\"*\");\n }\n\n #region NotThrowAfterAsync\n\n [Fact]\n public async Task When_wait_time_is_zero_for_async_func_executed_with_wait_it_should_not_throw()\n {\n // Arrange\n var waitTime = 0.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var asyncObject = new AsyncClass();\n Func someFunc = () => asyncObject.SucceedAsync();\n\n // Act\n Func act = () => someFunc.Should(clock).NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_poll_interval_is_zero_for_async_func_executed_with_wait_it_should_not_throw()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = 0.Milliseconds();\n\n var clock = new FakeClock();\n var asyncObject = new AsyncClass();\n Func someFunc = () => asyncObject.SucceedAsync();\n\n // Act\n Func act = () => someFunc.Should(clock).NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n\n [Fact]\n public async Task When_subject_is_null_for_async_func_it_should_throw()\n {\n // Arrange\n var waitTime = 0.Milliseconds();\n var pollInterval = 0.Milliseconds();\n Func action = null;\n\n // Act\n Func testAction = async () =>\n {\n using var _ = new AssertionScope();\n\n await action.Should().NotThrowAfterAsync(waitTime, pollInterval,\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n await testAction.Should().ThrowAsync()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public async Task When_wait_time_is_negative_for_async_func_it_should_throw()\n {\n // Arrange\n var waitTime = -1.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n var asyncObject = new AsyncClass();\n Func someFunc = () => asyncObject.SucceedAsync();\n\n // Act\n Func act = () => someFunc.Should().NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().ThrowAsync()\n .WithParameterName(\"waitTime\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public async Task When_poll_interval_is_negative_for_async_func_it_should_throw()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = -1.Milliseconds();\n\n var asyncObject = new AsyncClass();\n Func someFunc = () => asyncObject.SucceedAsync();\n\n // Act\n Func act = () => someFunc.Should().NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().ThrowAsync()\n .WithParameterName(\"pollInterval\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public async Task When_no_exception_should_be_thrown_for_null_async_func_after_wait_time_it_should_throw()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n Func func = null;\n\n // Act\n Func action = () => func.Should()\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"*but found *\");\n }\n\n [Fact]\n public async Task When_no_exception_should_be_thrown_for_async_func_after_wait_time_but_it_was_it_should_throw()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.CompleteAfter(waitTime);\n\n Func throwLongerThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n };\n\n // Act\n Func action = () => throwLongerThanWaitTime.Should(clock)\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exceptions after 2s because we passed valid arguments*\");\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task\n When_no_exception_should_be_thrown_on_UI_thread_for_async_func_after_wait_time_but_it_was_it_should_throw()\n {\n // Arrange\n var waitTime = 2.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.CompleteAfter(waitTime);\n\n Func throwLongerThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n };\n\n // Act\n Func action = () => throwLongerThanWaitTime.Should(clock)\n .NotThrowAfterAsync(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n await action.Should().ThrowAsync()\n .WithMessage(\"Did not expect any exceptions after 2s because we passed valid arguments*\");\n }\n }\n\n [Fact]\n public async Task When_no_exception_should_be_thrown_for_async_func_after_wait_time_and_none_was_it_should_not_throw()\n {\n // Arrange\n var waitTime = 6.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.Delay(waitTime);\n\n Func throwShorterThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Divide(12))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n };\n\n // Act\n Func act = () => throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n\n public partial class UIFacts\n {\n [UIFact]\n public async Task\n When_no_exception_should_be_thrown_on_UI_thread_for_async_func_after_wait_time_and_none_was_it_should_not_throw()\n {\n // Arrange\n var waitTime = 6.Seconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n clock.Delay(waitTime);\n\n Func throwShorterThanWaitTime = async () =>\n {\n if (timer.Elapsed <= waitTime.Divide(12))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n\n await Task.Yield();\n };\n\n // Act\n Func act = () => throwShorterThanWaitTime.Should(clock).NotThrowAfterAsync(waitTime, pollInterval);\n\n // Assert\n await act.Should().NotThrowAsync();\n }\n }\n\n #endregion\n}\n\ninternal class AsyncClass\n{\n public Task ThrowAsync()\n where TException : Exception, new() =>\n ThrowAsync(new TException());\n\n public Task ThrowAsync(Exception exception) =>\n Throw.Async(exception);\n\n public ValueTask ThrowAsyncValueTask()\n where TException : Exception, new() =>\n Throw.AsyncValueTask(new TException());\n\n public Task ThrowAggregateExceptionAsync()\n where TException : Exception, new() =>\n Throw.Async(new AggregateException(new TException()));\n\n public ValueTask ThrowAggregateExceptionAsyncValueTask()\n where TException : Exception, new() =>\n Throw.AsyncValueTask(new AggregateException(new TException()));\n\n public async Task SucceedAsync()\n {\n await Task.FromResult(0);\n }\n\n public async ValueTask SucceedAsyncValueTask()\n {\n await Task.FromResult(0);\n }\n\n public Task ReturnTaskInt()\n {\n return Task.FromResult(0);\n }\n\n public ValueTask ReturnValueTaskInt()\n {\n return new ValueTask(0);\n }\n\n public Task IncompleteTask()\n {\n return new TaskCompletionSource().Task;\n }\n\n public async Task ThrowTaskIntAsync(bool throwException)\n where TException : Exception, new()\n {\n await Task.Yield();\n\n if (throwException)\n {\n throw new TException();\n }\n\n return 123;\n }\n\n public async ValueTask ThrowValueTaskIntAsync(bool throwException)\n where TException : Exception, new()\n {\n await Task.Yield();\n\n if (throwException)\n {\n throw new TException();\n }\n\n return 123;\n }\n}\n\ninternal static class Throw\n{\n public static Task Async()\n where TException : Exception, new() =>\n Async(new TException());\n\n public static async Task Async(Exception expcetion)\n {\n await Task.Yield();\n throw expcetion;\n }\n\n public static async ValueTask AsyncValueTask(Exception expcetion)\n {\n await Task.Yield();\n throw expcetion;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/UInt16Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class UInt16Assertions : NumericAssertions\n{\n internal UInt16Assertions(ushort value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(ushort subject, ushort expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/UInt64Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class UInt64Assertions : NumericAssertions\n{\n internal UInt64Assertions(ulong value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(ulong subject, ulong expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n decimal difference = (decimal)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableUInt16Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableUInt16Assertions : NullableNumericAssertions\n{\n internal NullableUInt16Assertions(ushort? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(ushort subject, ushort expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableUInt64Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableUInt64Assertions : NullableNumericAssertions\n{\n internal NullableUInt64Assertions(ulong? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(ulong subject, ulong expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n decimal difference = (decimal)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/FailReason.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// Represents the assertion fail reason. Contains the message and arguments for message's numbered placeholders.\n/// \n/// \n/// In addition to the numbered -style placeholders, messages may contain a\n/// few specialized placeholders as well. For instance, {reason} will be replaced with the reason of the\n/// assertion as passed to .\n/// \n/// Other named placeholders will be replaced with the scope data passed through\n/// .\n/// \n/// \n/// Finally, a description of the current subject can be passed through the {context:description} placeholder.\n/// This is used in the message if no explicit context is specified through the constructor.\n/// \n/// \n/// Note that only 10 args are supported in combination with a {reason}.\n/// \n/// \npublic class FailReason\n{\n /// \n /// Initializes a new instance of the class.\n /// \n /// \n /// \n /// \n public FailReason(string message, params object[] args)\n {\n Message = message;\n Args = args;\n }\n\n /// \n /// Message to be displayed in case of failed assertion. May contain numbered\n /// -style placeholders as well as specialized placeholders.\n /// \n public string Message { get; }\n\n /// \n /// Arguments for the numbered -style placeholders of .\n /// \n public object[] Args { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedXunitTheoryTestCaseRunner.cs", "using System;\nusing System.Globalization;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedXunitTheoryTestCaseRunner : XunitTheoryTestCaseRunner\n{\n private readonly string culture;\n private CultureInfo originalCulture;\n private CultureInfo originalUICulture;\n\n public CulturedXunitTheoryTestCaseRunner(CulturedXunitTheoryTestCase culturedXunitTheoryTestCase,\n string displayName,\n string skipReason,\n object[] constructorArguments,\n IMessageSink diagnosticMessageSink,\n IMessageBus messageBus,\n ExceptionAggregator aggregator,\n CancellationTokenSource cancellationTokenSource)\n : base(culturedXunitTheoryTestCase, displayName, skipReason, constructorArguments, diagnosticMessageSink, messageBus,\n aggregator, cancellationTokenSource)\n {\n culture = culturedXunitTheoryTestCase.Culture;\n }\n\n protected override Task AfterTestCaseStartingAsync()\n {\n try\n {\n originalCulture = CurrentCulture;\n originalUICulture = CurrentUICulture;\n\n var cultureInfo = new CultureInfo(culture);\n CurrentCulture = cultureInfo;\n CurrentUICulture = cultureInfo;\n }\n catch (Exception ex)\n {\n Aggregator.Add(ex);\n return Task.FromResult(0);\n }\n\n return base.AfterTestCaseStartingAsync();\n }\n\n protected override Task BeforeTestCaseFinishedAsync()\n {\n if (originalUICulture is not null)\n {\n CurrentUICulture = originalUICulture;\n }\n\n if (originalCulture is not null)\n {\n CurrentCulture = originalCulture;\n }\n\n return base.BeforeTestCaseFinishedAsync();\n }\n\n private static CultureInfo CurrentCulture\n {\n get => CultureInfo.CurrentCulture;\n set => CultureInfo.CurrentCulture = value;\n }\n\n private static CultureInfo CurrentUICulture\n {\n get => CultureInfo.CurrentUICulture;\n set => CultureInfo.CurrentUICulture = value;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/StringExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class StringExtensions\n{\n /// \n /// Finds the first index at which the does not match the \n /// string anymore, accounting for the specified .\n /// \n public static int IndexOfFirstMismatch(this string value, string expected, IEqualityComparer comparer)\n {\n for (int index = 0; index < value.Length; index++)\n {\n if (index >= expected.Length || !comparer.Equals(value[index..(index + 1)], expected[index..(index + 1)]))\n {\n return index;\n }\n }\n\n return -1;\n }\n\n /// \n /// Gets the quoted three characters at the specified index of a string, including the index itself.\n /// \n public static string IndexedSegmentAt(this string value, int index)\n {\n int length = Math.Min(value.Length - index, 3);\n string formattedString = Formatter.ToString(value.Substring(index, length));\n\n return $\"{formattedString} (index {index})\".EscapePlaceholders();\n }\n\n /// \n /// Replaces all numeric indices from a path like \"property[0].nested\" and returns \"property[].nested\"\n /// \n public static string WithoutSpecificCollectionIndices(this string indexedPath)\n {\n return Regex.Replace(indexedPath, @\"\\[[0-9]+\\]\", \"[]\");\n }\n\n /// \n /// Determines whether a string contains a specific index like `[0]` instead of just `[]`.\n /// \n public static bool ContainsSpecificCollectionIndex(this string indexedPath)\n {\n return Regex.IsMatch(indexedPath, @\"\\[[0-9]+\\]\");\n }\n\n /// \n /// Replaces all characters that might conflict with formatting placeholders with their escaped counterparts.\n /// \n public static string EscapePlaceholders(this string value) =>\n value.Replace(\"{\", \"{{\", StringComparison.Ordinal).Replace(\"}\", \"}}\", StringComparison.Ordinal);\n\n /// \n /// Joins a string with one or more other strings using a specified separator.\n /// \n /// \n /// Any string that is empty (including the original string) is ignored.\n /// \n public static string Combine(this string @this, string other, string separator = \".\")\n {\n if (@this.Length == 0)\n {\n return other.Length != 0 ? other : string.Empty;\n }\n\n if (other.StartsWith('['))\n {\n separator = string.Empty;\n }\n\n return @this + separator + other;\n }\n\n /// \n /// Changes the first character of a string to uppercase.\n /// \n public static string Capitalize(this string @this)\n {\n if (@this.Length == 0)\n {\n return @this;\n }\n\n char[] charArray = @this.ToCharArray();\n charArray[0] = char.ToUpperInvariant(charArray[0]);\n return new string(charArray);\n }\n\n /// \n /// Appends tab character at the beginning of each line in a string.\n /// \n /// \n public static string IndentLines(this string @this)\n {\n return string.Join(Environment.NewLine,\n @this.Split(new[] { '\\r', '\\n' }, StringSplitOptions.RemoveEmptyEntries).Select(x => $\"\\t{x}\"));\n }\n\n public static string RemoveNewLines(this string @this)\n {\n return @this.Replace(\"\\n\", string.Empty, StringComparison.Ordinal)\n .Replace(\"\\r\", string.Empty, StringComparison.Ordinal);\n }\n\n public static string RemoveNewlineStyle(this string @this)\n {\n return @this.Replace(\"\\r\\n\", \"\\n\", StringComparison.Ordinal)\n .Replace(\"\\r\", \"\\n\", StringComparison.Ordinal);\n }\n\n public static string RemoveTrailingWhitespaceFromLines(this string input)\n {\n // This regex matches whitespace characters (\\s) that are followed by a line ending (\\r?\\n)\n return Regex.Replace(input, @\"[ \\t]+(?=\\r?\\n)\", string.Empty);\n }\n\n /// \n /// Counts the number of times the appears within a string by using the specified .\n /// \n public static int CountSubstring(this string str, string substring, IEqualityComparer comparer)\n {\n string actual = str ?? string.Empty;\n string search = substring ?? string.Empty;\n\n int count = 0;\n int maxIndex = actual.Length - search.Length;\n for (int index = 0; index <= maxIndex; index++)\n {\n if (comparer.Equals(actual[index..(index + search.Length)], search))\n {\n count++;\n }\n }\n\n return count;\n }\n\n /// \n /// Determines if the is longer than 8 characters or contains an .\n /// \n public static bool IsLongOrMultiline(this string value)\n {\n const int humanReadableLength = 8;\n return value.Length > humanReadableLength || value.Contains(Environment.NewLine, StringComparison.Ordinal);\n }\n\n public static bool IsNullOrEmpty([NotNullWhen(false)] this string value)\n {\n return string.IsNullOrEmpty(value);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/DoubleAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class DoubleAssertions : NumericAssertions\n{\n internal DoubleAssertions(double value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override bool IsNaN(double value) => double.IsNaN(value);\n\n private protected override string CalculateDifferenceForFailureMessage(double subject, double expected)\n {\n var difference = subject - expected;\n return difference != 0 ? difference.ToString(\"R\", CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/SingleAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class SingleAssertions : NumericAssertions\n{\n internal SingleAssertions(float value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override bool IsNaN(float value) => float.IsNaN(value);\n\n private protected override string CalculateDifferenceForFailureMessage(float subject, float expected)\n {\n float difference = subject - expected;\n return difference != 0 ? difference.ToString(\"R\", CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableSingleAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableSingleAssertions : NullableNumericAssertions\n{\n internal NullableSingleAssertions(float? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override bool IsNaN(float value) => float.IsNaN(value);\n\n private protected override string CalculateDifferenceForFailureMessage(float subject, float expected)\n {\n float difference = subject - expected;\n return difference != 0 ? difference.ToString(\"R\", CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableDoubleAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableDoubleAssertions : NullableNumericAssertions\n{\n internal NullableDoubleAssertions(double? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override bool IsNaN(double value) => double.IsNaN(value);\n\n private protected override string CalculateDifferenceForFailureMessage(double subject, double expected)\n {\n double difference = subject - expected;\n return difference != 0 ? difference.ToString(\"R\", CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Collections;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// This part of the class contains assertions of general generic string collections\n/// \npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n [Fact]\n public void When_using_StringCollectionAssertions_the_AndConstraint_should_have_the_correct_type()\n {\n // Arrange\n MethodInfo[] methodInfo =\n typeof(StringCollectionAssertions>).GetMethods(\n BindingFlags.Public | BindingFlags.Instance);\n\n // Act\n var methods =\n from method in methodInfo\n where !method.IsSpecialName // Exclude Properties\n where method.DeclaringType != typeof(object)\n where method.Name != \"Equals\"\n select new { method.Name, method.ReturnType };\n\n // Assert\n Type[] expectedTypes =\n [\n typeof(AndConstraint>>),\n typeof(AndConstraint>)\n ];\n\n methods.Should().OnlyContain(method => expectedTypes.Any(e => e.IsAssignableFrom(method.ReturnType)));\n }\n\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var someCollection = new List { \"one\", \"two\", \"three\" };\n\n // Act\n Action action = () => someCollection.Should().Equals(someCollection);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Equals is not part of Awesome Assertions. Did you mean BeSameAs(), Equal(), or BeEquivalentTo() instead?\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/Int16Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class Int16Assertions : NumericAssertions\n{\n internal Int16Assertions(short value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(short subject, short expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/UInt32Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class UInt32Assertions : NumericAssertions\n{\n internal UInt32Assertions(uint value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(uint subject, uint expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n long difference = (long)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/ExecutionTimeAssertionsSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Specialized;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class ExecutionTimeAssertionsSpecs\n{\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_less_than_or_equal_to_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(610)).Should().BeLessThanOrEqualTo(500.Milliseconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(610)) should be less than or equal to 500ms because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_less_than_or_equal_to_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(0)).Should().BeLessThanOrEqualTo(500.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_less_than_or_equal_to_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(510);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThanOrEqualTo(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than or equal to 100ms, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_less_than_or_equal_to_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeLessThanOrEqualTo(1.Seconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_throw_if_there_is_less_than_or_equal_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThanOrEqualTo(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than or equal to 100ms, but it required more than*\");\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () =>\n subject.ExecutionTimeOf(s => s.AddRange(new object[] { })).Should().BeLessThanOrEqualTo(1.Nanoseconds());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(0))\n .Should().BeLessThanOrEqualTo(500.Milliseconds())\n .And.BeCloseTo(0.Seconds(), 500.Milliseconds());\n }\n }\n\n public class BeLessThan\n {\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_less_than_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(610)).Should().BeLessThan(500.Milliseconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(610)) should be less than 500ms because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_less_than_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(0)).Should().BeLessThan(500.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_less_than_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(510);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than 100ms, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_async_action_is_not_less_than_a_limit_it_should_throw()\n {\n // Arrange\n Func someAction = () => Task.Delay(TimeSpan.FromMilliseconds(150));\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than 100ms, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_less_than_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeLessThan(2.Seconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_async_action_is_less_than_a_limit_it_should_not_throw()\n {\n // Arrange\n Func someAction = () => Task.Delay(TimeSpan.FromMilliseconds(100));\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeLessThan(20.Seconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_throw_if_there_is_less_than_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(100.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be less than 100ms, but it required more than*\");\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.AddRange(new object[] { })).Should().BeLessThan(1.Nanoseconds());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n }\n\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_greater_than_or_equal_to_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(100)).Should().BeGreaterThanOrEqualTo(1.Seconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(100)) should be greater than or equal to 1s because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_greater_than_or_equal_to_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(100)).Should().BeGreaterThanOrEqualTo(50.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_greater_than_or_equal_to_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeGreaterThanOrEqualTo(1.Seconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be greater than or equal to 1s, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_greater_than_or_equal_to_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeGreaterThanOrEqualTo(50.Milliseconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_not_throw_if_there_is_greater_than_or_equal_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeGreaterThanOrEqualTo(100.Milliseconds());\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () =>\n subject.ExecutionTimeOf(s => s.AddRange(new object[] { })).Should().BeGreaterThanOrEqualTo(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(100))\n .Should().BeGreaterThanOrEqualTo(50.Milliseconds())\n .And.BeCloseTo(0.Seconds(), 500.Milliseconds());\n }\n }\n\n public class BeGreaterThan\n {\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_greater_than_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(100)).Should().BeGreaterThan(1.Seconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(100)) should be greater than 1s because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_greater_than_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(200)).Should().BeGreaterThan(100.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_greater_than_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(100);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeGreaterThan(1.Seconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be greater than 1s, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_greater_than_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(200);\n\n // Act / Assert\n someAction.ExecutionTime().Should().BeGreaterThan(100.Milliseconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_not_throw_if_there_is_greater_than_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeGreaterThan(100.Milliseconds());\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.AddRange(new object[] { })).Should().BeGreaterThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n }\n\n public class BeCloseTo\n {\n [Fact]\n public void When_asserting_that_execution_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(200)).Should().BeCloseTo(100.Milliseconds(),\n -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_not_close_to_a_limit_it_should_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.Sleep(200)).Should().BeCloseTo(100.Milliseconds(),\n 50.Milliseconds(),\n \"we like speed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*(s.Sleep(200)) should be within 50ms from 100ms because we like speed, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_a_member_is_close_to_a_limit_it_should_not_throw()\n {\n // Arrange\n var subject = new SleepingClass();\n var timer = new TestTimer(() => 210.Milliseconds());\n\n // Act / Assert\n subject.ExecutionTimeOf(s => s.Sleep(0), () => timer).Should().BeCloseTo(200.Milliseconds(),\n 150.Milliseconds());\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_not_close_to_a_limit_it_should_throw()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(200);\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeCloseTo(100.Milliseconds(), 50.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be within 50ms from 100ms, but it required*\");\n }\n\n [Fact]\n public void When_the_execution_time_of_an_action_is_close_to_a_limit_it_should_not_throw()\n {\n // Arrange\n Action someAction = () => { };\n var timer = new TestTimer(() => 210.Milliseconds());\n\n // Act / Assert\n someAction.ExecutionTime(() => timer).Should().BeCloseTo(200.Milliseconds(), 15.Milliseconds());\n }\n\n [Fact]\n public void When_action_runs_indefinitely_it_should_be_stopped_and_throw_if_there_is_be_close_to_condition()\n {\n // Arrange\n Action someAction = () =>\n {\n // lets cause a deadlock\n var semaphore = new Semaphore(0, 1); // my weapon of choice is a semaphore\n semaphore.WaitOne(); // oops\n };\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeCloseTo(100.Milliseconds(), 50.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*action should be within 50ms from 100ms, but it required*\");\n }\n\n [Fact]\n public void Actions_with_brackets_fail_with_correctly_formatted_message()\n {\n // Arrange\n var subject = new List();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(s => s.AddRange(new object[] { }))\n .Should().BeCloseTo(1.Days(), 50.Milliseconds());\n\n // Assert\n act.Should().ThrowExactly()\n .Which.Message.Should().Contain(\"{}\").And.NotContain(\"{0}\");\n }\n }\n\n public class ExecutingTime\n {\n [Fact]\n public void When_action_runs_inside_execution_time_exceptions_are_captured_and_rethrown()\n {\n // Arrange\n Action someAction = () => throw new ArgumentException(\"Let's say somebody called the wrong method.\");\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(200.Milliseconds());\n\n // Assert\n act.Should().Throw().WithMessage(\"Let's say somebody called the wrong method.\");\n }\n\n [Fact]\n public void Stopwatch_is_not_stopped_after_first_execution_time_assertion()\n {\n // Arrange\n Action someAction = () => Thread.Sleep(300);\n\n // Act / Assert\n // I know it's not meant to be used like this,\n // but since you can, it should still give consistent results\n ExecutionTime time = someAction.ExecutionTime();\n time.Should().BeGreaterThan(100.Milliseconds());\n time.Should().BeGreaterThan(200.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_on_null_execution_it_should_throw()\n {\n // Arrange\n ExecutionTime executionTime = null;\n\n // Act\n Func act = () => new ExecutionTimeAssertions(executionTime, AssertionChain.GetOrCreate());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"executionTime\");\n }\n\n [Fact]\n public void When_asserting_on_null_action_it_should_throw()\n {\n // Arrange\n Action someAction = null;\n\n // Act\n Action act = () => someAction.ExecutionTime().Should().BeLessThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n\n [Fact]\n public void When_asserting_on_null_func_it_should_throw()\n {\n // Arrange\n Func someFunc = null;\n\n // Act\n Action act = () => someFunc.ExecutionTime().Should().BeLessThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n\n [Fact]\n public void When_asserting_execution_time_of_null_action_it_should_throw()\n {\n // Arrange\n object subject = null;\n\n // Act\n var act = () => subject.ExecutionTimeOf(s => s.ToString()).Should().BeLessThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"subject\");\n }\n\n [Fact]\n public void When_asserting_execution_time_of_null_it_should_throw()\n {\n // Arrange\n var subject = new object();\n\n // Act\n Action act = () => subject.ExecutionTimeOf(null).Should().BeLessThan(1.Days());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var subject = new object();\n\n // Act\n var act = () => subject.ExecutionTimeOf(s => s.ToString()).Should().Equals(1.Seconds());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Equals is not part of Awesome Assertions. Did you mean BeLessThanOrEqualTo() or BeGreaterThanOrEqualTo() instead?\");\n }\n }\n\n internal class SleepingClass\n {\n public void Sleep(int milliseconds)\n {\n Thread.Sleep(milliseconds);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableInt16Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableInt16Assertions : NullableNumericAssertions\n{\n internal NullableInt16Assertions(short? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(short subject, short expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableUInt32Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableUInt32Assertions : NullableNumericAssertions\n{\n internal NullableUInt32Assertions(uint? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(uint subject, uint expected)\n {\n if (subject < 10 && expected < 10)\n {\n return null;\n }\n\n long difference = (long)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/Int32Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class Int32Assertions : NumericAssertions\n{\n internal Int32Assertions(int value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(int subject, int expected)\n {\n if (subject is > 0 and < 10 && expected is > 0 and < 10)\n {\n return null;\n }\n\n long difference = (long)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/Int64Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class Int64Assertions : NumericAssertions\n{\n internal Int64Assertions(long value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(long subject, long expected)\n {\n if (subject is > 0 and < 10 && expected is > 0 and < 10)\n {\n return null;\n }\n\n decimal difference = (decimal)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableInt32Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableInt32Assertions : NullableNumericAssertions\n{\n internal NullableInt32Assertions(int? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(int subject, int expected)\n {\n if (subject is > 0 and < 10 && expected is > 0 and < 10)\n {\n return null;\n }\n\n long difference = (long)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableInt64Assertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableInt64Assertions : NullableNumericAssertions\n{\n internal NullableInt64Assertions(long? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(long subject, long expected)\n {\n if (subject is > 0 and < 10 && expected is > 0 and < 10)\n {\n return null;\n }\n\n decimal difference = (decimal)subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/FakeClock.cs", "using System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\n#if NET8_0_OR_GREATER\nusing ITimer = AwesomeAssertions.Common.ITimer;\n#endif\n\nnamespace AwesomeAssertions.Specs;\n\n/// \n/// Implementation of for testing purposes only.\n/// \n/// \n/// It allows you to control the \"current\" date and time for test purposes.\n/// \ninternal class FakeClock : IClock\n{\n private readonly TaskCompletionSource delayTask = new();\n\n private TimeSpan elapsedTime = TimeSpan.Zero;\n\n Task IClock.DelayAsync(TimeSpan delay, CancellationToken cancellationToken)\n {\n elapsedTime += delay;\n return delayTask.Task;\n }\n\n public ITimer StartTimer() => new TestTimer(() => elapsedTime);\n\n /// \n /// Advances the internal clock.\n /// \n public void Delay(TimeSpan timeToDelay)\n {\n elapsedTime += timeToDelay;\n }\n\n /// \n /// Simulates the completion of the pending delay task.\n /// \n public void Complete()\n {\n // the value is not relevant\n delayTask.SetResult(true);\n }\n\n /// \n /// Simulates the completion of the pending delay task after the internal clock has been advanced.\n /// \n public void CompleteAfter(TimeSpan timeSpan)\n {\n Delay(timeSpan);\n\n // the value is not relevant\n delayTask.SetResult(true);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeGreaterThan.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeGreaterThan\n {\n [Fact]\n public void When_a_value_is_greater_than_smaller_value_it_should_not_throw()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act / Assert\n value.Should().BeGreaterThan(smallerValue);\n }\n\n [Fact]\n public void When_a_value_is_greater_than_greater_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(greaterValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_greater_than_same_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int sameValue = 2;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(sameValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_greater_than_greater_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(greaterValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 3 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_another_float()\n {\n // Act\n Action act = () => float.NaN.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_cannot_be_greater_than_NaN()\n {\n // Act\n Action act = () => 3.4F.Should().BeGreaterThan(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_another_double()\n {\n // Act\n Action act = () => double.NaN.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_greater_than_NaN()\n {\n // Act\n Action act = () => 3.4D.Should().BeGreaterThan(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_greater_than_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_byte()\n {\n // Arrange\n var value = (byte)1;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(1);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_non_null_path_for_difference_on_byte()\n {\n // Arrange\n var value = (byte)1;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(2);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5, 5)]\n [InlineData(1, 10)]\n [InlineData(0, 5)]\n [InlineData(0, 0)]\n [InlineData(-1, 5)]\n [InlineData(-1, -1)]\n [InlineData(10, 10)]\n public void To_test_the_null_path_for_difference_on_int(int subject, int expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5L, 5L)]\n [InlineData(1L, 10L)]\n [InlineData(0L, 5L)]\n [InlineData(0L, 0L)]\n [InlineData(-1L, 5L)]\n [InlineData(-1L, -1L)]\n [InlineData(10L, 10L)]\n public void To_test_the_null_path_for_difference_on_long(long subject, long expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(1, 1)]\n [InlineData(10, 10)]\n [InlineData(10, 11)]\n public void To_test_the_null_path_for_difference_on_ushort(ushort subject, ushort expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AssertionExtensions.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Specialized;\n\nnamespace AwesomeAssertions.Specs;\n\ninternal static class AssertionExtensions\n{\n private static readonly AggregateExceptionExtractor Extractor = new();\n\n public static NonGenericAsyncFunctionAssertions Should(this Func action, IClock clock)\n {\n return new NonGenericAsyncFunctionAssertions(action, Extractor, AssertionChain.GetOrCreate(), clock);\n }\n\n public static GenericAsyncFunctionAssertions Should(this Func> action, IClock clock)\n {\n return new GenericAsyncFunctionAssertions(action, Extractor, AssertionChain.GetOrCreate(), clock);\n }\n\n public static ActionAssertions Should(this Action action, IClock clock)\n {\n return new ActionAssertions(action, Extractor, AssertionChain.GetOrCreate(), clock);\n }\n\n public static FunctionAssertions Should(this Func func, IClock clock)\n {\n return new FunctionAssertions(func, Extractor, AssertionChain.GetOrCreate(), clock);\n }\n\n public static TaskCompletionSourceAssertions Should(this TaskCompletionSource tcs, IClock clock)\n {\n return new TaskCompletionSourceAssertions(tcs, AssertionChain.GetOrCreate(), clock);\n }\n\n#if NET6_0_OR_GREATER\n public static TaskCompletionSourceAssertions Should(this TaskCompletionSource tcs, IClock clock)\n {\n return new TaskCompletionSourceAssertions(tcs, AssertionChain.GetOrCreate(), clock);\n }\n\n#endif\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeLessThan.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeLessThan\n {\n [Fact]\n public void When_a_value_is_less_than_greater_value_it_should_not_throw()\n {\n // Arrange\n int value = 1;\n int greaterValue = 2;\n\n // Act / Assert\n value.Should().BeLessThan(greaterValue);\n }\n\n [Fact]\n public void When_a_value_is_less_than_smaller_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act\n Action act = () => value.Should().BeLessThan(smallerValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_less_than_same_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int sameValue = 2;\n\n // Act\n Action act = () => value.Should().BeLessThan(sameValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_less_than_smaller_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act\n Action act = () => value.Should().BeLessThan(smallerValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be less than 1 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_another_float()\n {\n // Act\n Action act = () => float.NaN.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_can_never_be_less_than_NaN()\n {\n // Act\n Action act = () => 3.4F.Should().BeLessThan(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_another_double()\n {\n // Act\n Action act = () => double.NaN.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_less_than_NaN()\n {\n // Act\n Action act = () => 3.4D.Should().BeLessThan(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_less_than_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Theory]\n [InlineData(5, -1)]\n [InlineData(10, 5)]\n [InlineData(10, -1)]\n public void To_test_the_remaining_paths_for_difference_on_int(int subject, int expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeLessThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5L, -1L)]\n [InlineData(10L, 5L)]\n [InlineData(10L, -1L)]\n public void To_test_the_remaining_paths_for_difference_on_long(long subject, long expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeLessThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Streams/StreamAssertionSpecs.cs", "using System;\nusing System.IO;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Streams;\n\npublic class StreamAssertionSpecs\n{\n public class BeWritable\n {\n [Fact]\n public void When_having_a_writable_stream_be_writable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Writable = true };\n\n // Act / Assert\n stream.Should().BeWritable();\n }\n\n [Fact]\n public void When_having_a_non_writable_stream_be_writable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Writable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeWritable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be writable *failure message*, but it was not.\");\n }\n\n [Fact]\n public void When_null_be_writable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeWritable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be writable *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeWritable\n {\n [Fact]\n public void When_having_a_non_writable_stream_be_not_writable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Writable = false };\n\n // Act / Assert\n stream.Should().NotBeWritable();\n }\n\n [Fact]\n public void When_having_a_writable_stream_be_not_writable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Writable = true };\n\n // Act\n Action act = () =>\n stream.Should().NotBeWritable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be writable *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_writable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeWritable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be writable *failure message*, but found a reference.\");\n }\n }\n\n public class BeSeekable\n {\n [Fact]\n public void When_having_a_seekable_stream_be_seekable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true };\n\n // Act / Assert\n stream.Should().BeSeekable();\n }\n\n [Fact]\n public void When_having_a_non_seekable_stream_be_seekable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeSeekable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be seekable *failure message*, but it was not.\");\n }\n\n [Fact]\n public void When_null_be_seekable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeSeekable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be seekable *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeSeekable\n {\n [Fact]\n public void When_having_a_non_seekable_stream_be_not_seekable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = false };\n\n // Act / Assert\n stream.Should().NotBeSeekable();\n }\n\n [Fact]\n public void When_having_a_seekable_stream_be_not_seekable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true };\n\n // Act\n Action act = () =>\n stream.Should().NotBeSeekable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be seekable *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_seekable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeSeekable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be seekable *failure message*, but found a reference.\");\n }\n }\n\n public class BeReadable\n {\n [Fact]\n public void When_having_a_readable_stream_be_readable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = true };\n\n // Act / Assert\n stream.Should().BeReadable();\n }\n\n [Fact]\n public void When_having_a_non_readable_stream_be_readable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeReadable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be readable *failure message*, but it was not.\");\n }\n\n [Fact]\n public void When_null_be_readable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeReadable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be readable *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeReadable\n {\n [Fact]\n public void When_having_a_non_readable_stream_be_not_readable_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = false };\n\n // Act / Assert\n stream.Should().NotBeReadable();\n }\n\n [Fact]\n public void When_having_a_readable_stream_be_not_readable_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = true };\n\n // Act\n Action act = () =>\n stream.Should().NotBeReadable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be readable *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_readable_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeReadable(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be readable *failure message*, but found a reference.\");\n }\n }\n\n public class HavePosition\n {\n [Fact]\n public void When_a_stream_has_the_expected_position_it_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, Position = 10 };\n\n // Act / Assert\n stream.Should().HavePosition(10);\n }\n\n [Fact]\n public void When_a_stream_has_the_unexpected_position_it_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, Position = 1 };\n\n // Act\n Action act = () =>\n stream.Should().HavePosition(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream to be 10* *failure message*, but it was 1*.\");\n }\n\n [Fact]\n public void When_null_have_position_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().HavePosition(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream to be 10* *failure message*, but found a reference.\");\n }\n\n [Theory]\n [MemberData(nameof(GetPositionExceptions), MemberType = typeof(StreamAssertionSpecs))]\n public void When_a_throwing_stream_should_have_a_position_it_should_fail(Exception exception)\n {\n // Arrange\n using var stream = new ExceptingStream(exception);\n\n // Act\n Action act = () =>\n stream.Should().HavePosition(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream to be 10* *failure message*, \" +\n \"but it failed with*GetPositionExceptionMessage*\");\n }\n }\n\n public class NotHavePosition\n {\n [Fact]\n public void When_a_stream_does_not_have_an_unexpected_position_it_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, Position = 1 };\n\n // Act / Assert\n stream.Should().NotHavePosition(10);\n }\n\n [Fact]\n public void When_a_stream_does_have_the_unexpected_position_it_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, Position = 10 };\n\n // Act\n Action act = () =>\n stream.Should().NotHavePosition(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream not to be 10* *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_have_position_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotHavePosition(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream not to be 10* *failure message*, but found a reference.\");\n }\n\n [Theory]\n [MemberData(nameof(GetPositionExceptions), MemberType = typeof(StreamAssertionSpecs))]\n public void When_a_throwing_stream_should_not_have_a_position_it_should_fail(Exception exception)\n {\n // Arrange\n using var stream = new ExceptingStream(exception);\n\n // Act\n Action act = () =>\n stream.Should().NotHavePosition(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the position of stream not to be 10* *failure message*, \" +\n \"but it failed with*GetPositionExceptionMessage*\");\n }\n }\n\n public static TheoryData GetPositionExceptions => new()\n {\n // https://docs.microsoft.com/en-us/dotnet/api/system.io.stream.position#exceptions\n new IOException(\"GetPositionExceptionMessage\"),\n new NotSupportedException(\"GetPositionExceptionMessage\"),\n new ObjectDisposedException(\"GetPositionExceptionMessage\")\n };\n\n public class HaveLength\n {\n [Fact]\n public void When_a_stream_has_the_expected_length_it_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, WithLength = 10 };\n\n // Act / Assert\n stream.Should().HaveLength(10);\n }\n\n [Fact]\n public void When_a_stream_has_an_unexpected_length_it_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, WithLength = 1 };\n\n // Act\n Action act = () =>\n stream.Should().HaveLength(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream to be 10* *failure message*, but it was 1*.\");\n }\n\n [Fact]\n public void When_null_have_length_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().HaveLength(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream to be 10* *failure message*, but found a reference.\");\n }\n\n [Theory]\n [MemberData(nameof(GetLengthExceptions), MemberType = typeof(StreamAssertionSpecs))]\n public void When_a_throwing_stream_should_have_a_length_it_should_fail(Exception exception)\n {\n // Arrange\n using var stream = new ExceptingStream(exception);\n\n // Act\n Action act = () =>\n stream.Should().HaveLength(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream to be 10* *failure message*, \" +\n \"but it failed with*GetLengthExceptionMessage*\");\n }\n }\n\n public class NotHaveLength\n {\n [Fact]\n public void When_a_stream_does_not_have_an_unexpected_length_it_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, WithLength = 1 };\n\n // Act / Assert\n stream.Should().NotHaveLength(10);\n }\n\n [Fact]\n public void When_a_stream_does_have_the_unexpected_length_it_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Seekable = true, WithLength = 10 };\n\n // Act\n Action act = () =>\n stream.Should().NotHaveLength(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream not to be 10* *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_have_length_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotHaveLength(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream not to be 10* *failure message*, but found a reference.\");\n }\n\n [Theory]\n [MemberData(nameof(GetLengthExceptions), MemberType = typeof(StreamAssertionSpecs))]\n public void When_a_throwing_stream_should_not_have_a_length_it_should_fail(Exception exception)\n {\n // Arrange\n using var stream = new ExceptingStream(exception);\n\n // Act\n Action act = () =>\n stream.Should().NotHaveLength(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the length of stream not to be 10* *failure message*, \" +\n \"but it failed with*GetLengthExceptionMessage*\");\n }\n }\n\n public static TheoryData GetLengthExceptions => new()\n {\n // https://docs.microsoft.com/en-us/dotnet/api/system.io.stream.length#exceptions\n new IOException(\"GetLengthExceptionMessage\"),\n new NotSupportedException(\"GetLengthExceptionMessage\"),\n new ObjectDisposedException(\"GetLengthExceptionMessage\")\n };\n\n public class BeReadOnly\n {\n [Fact]\n public void When_having_a_readonly_stream_be_read_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = false };\n\n // Act / Assert\n stream.Should().BeReadOnly();\n }\n\n [Fact]\n public void When_having_a_writable_stream_be_read_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = true };\n\n // Act\n Action act = () =>\n stream.Should().BeReadOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be read-only *failure message*, but it was writable or not readable.\");\n }\n\n [Fact]\n public void When_having_a_non_readable_stream_be_read_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeReadOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be read-only *failure message*, but it was writable or not readable.\");\n }\n\n [Fact]\n public void When_null_be_read_only_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeReadOnly(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be read-only *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeReadOnly\n {\n [Fact]\n public void When_having_a_non_readable_stream_be_not_read_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = false };\n\n // Act / Assert\n stream.Should().NotBeReadOnly();\n }\n\n [Fact]\n public void When_having_a_writable_stream_be_not_read_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = true };\n\n // Act / Assert\n stream.Should().NotBeReadOnly();\n }\n\n [Fact]\n public void When_having_a_readonly_stream_be_not_read_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = false };\n\n // Act\n Action act = () =>\n stream.Should().NotBeReadOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be read-only *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_read_only_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeReadOnly(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be read-only *failure message*, but found a reference.\");\n }\n }\n\n public class BeWriteOnly\n {\n [Fact]\n public void When_having_a_writeonly_stream_be_write_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = true };\n\n // Act / Assert\n stream.Should().BeWriteOnly();\n }\n\n [Fact]\n public void When_having_a_readable_stream_be_write_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = true };\n\n // Act\n Action act = () =>\n stream.Should().BeWriteOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be write-only *failure message*, but it was readable or not writable.\");\n }\n\n [Fact]\n public void When_having_a_non_writable_stream_be_write_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = false };\n\n // Act\n Action act = () =>\n stream.Should().BeWriteOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be write-only *failure message*, but it was readable or not writable.\");\n }\n\n [Fact]\n public void When_null_be_write_only_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().BeWriteOnly(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream to be write-only *failure message*, but found a reference.\");\n }\n }\n\n public class NotBeWriteOnly\n {\n [Fact]\n public void When_having_a_non_writable_stream_be_not_write_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = false };\n\n // Act / Assert\n stream.Should().NotBeWriteOnly();\n }\n\n [Fact]\n public void When_having_a_readable_stream_be_not_write_only_should_succeed()\n {\n // Arrange\n using var stream = new TestStream { Readable = true, Writable = true };\n\n // Act / Assert\n stream.Should().NotBeWriteOnly();\n }\n\n [Fact]\n public void When_having_a_writeonly_stream_be_not_write_only_should_fail()\n {\n // Arrange\n using var stream = new TestStream { Readable = false, Writable = true };\n\n // Act\n Action act = () =>\n stream.Should().NotBeWriteOnly(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be write-only *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_be_write_only_should_fail()\n {\n // Arrange\n TestStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotBeWriteOnly(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected stream not to be write-only *failure message*, but found a reference.\");\n }\n }\n}\n\ninternal class ExceptingStream : Stream\n{\n private readonly Exception exception;\n\n public ExceptingStream(Exception exception)\n {\n this.exception = exception;\n }\n\n public override bool CanRead => true;\n\n public override bool CanSeek => true;\n\n public override bool CanWrite => true;\n\n public override long Length => throw exception;\n\n public override long Position\n {\n get => throw exception;\n set => throw new NotImplementedException();\n }\n\n public override void Flush() => throw new NotImplementedException();\n\n public override int Read(byte[] buffer, int offset, int count) => throw new NotImplementedException();\n\n public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException();\n\n public override void SetLength(long value) => throw new NotImplementedException();\n\n public override void Write(byte[] buffer, int offset, int count) => throw new NotImplementedException();\n}\n\ninternal class TestStream : Stream\n{\n public bool Readable { private get; set; }\n\n public bool Seekable { private get; set; }\n\n public bool Writable { private get; set; }\n\n public long WithLength { private get; set; }\n\n public override bool CanRead => Readable;\n\n public override bool CanSeek => Seekable;\n\n public override bool CanWrite => Writable;\n\n public override long Length => WithLength;\n\n public override long Position { get; set; }\n\n public override void Flush() => throw new NotImplementedException();\n\n public override int Read(byte[] buffer, int offset, int count) => throw new NotImplementedException();\n\n public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException();\n\n public override void SetLength(long value) => throw new NotImplementedException();\n\n public override void Write(byte[] buffer, int offset, int count) => throw new NotImplementedException();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeXmlSerializable.cs", "using System;\nusing System.Globalization;\nusing System.Xml;\nusing System.Xml.Schema;\nusing System.Xml.Serialization;\nusing AwesomeAssertions.Extensions;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeXmlSerializable\n {\n [Fact]\n public void When_an_object_is_xml_serializable_it_should_succeed()\n {\n // Arrange\n var subject = new XmlSerializableClass\n {\n Name = \"John\",\n Id = 1\n };\n\n // Act / Assert\n subject.Should().BeXmlSerializable();\n }\n\n [Fact]\n public void When_an_object_is_not_xml_serializable_it_should_fail()\n {\n // Arrange\n var subject = new NonPublicClass\n {\n Name = \"John\"\n };\n\n // Act\n Action act = () => subject.Should().BeXmlSerializable(\"we need to store it on {0}\", \"disk\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"*to be serializable because we need to store it on disk, but serialization failed with:*NonPublicClass*\");\n }\n\n [Fact]\n public void When_an_object_is_xml_serializable_but_doesnt_restore_all_properties_it_should_fail()\n {\n // Arrange\n var subject = new XmlSerializableClassNotRestoringAllProperties\n {\n Name = \"John\",\n BirthDay = 20.September(1973)\n };\n\n // Act\n Action act = () => subject.Should().BeXmlSerializable();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be serializable, but serialization failed with:*Name*to be*\");\n }\n }\n\n public class XmlSerializableClass\n {\n [UsedImplicitly]\n public string Name { get; set; }\n\n public int Id;\n }\n\n public class XmlSerializableClassNotRestoringAllProperties : IXmlSerializable\n {\n [UsedImplicitly]\n public string Name { get; set; }\n\n public DateTime BirthDay { get; set; }\n\n public XmlSchema GetSchema()\n {\n return null;\n }\n\n public void ReadXml(XmlReader reader)\n {\n BirthDay = DateTime.Parse(reader.ReadElementContentAsString(), CultureInfo.InvariantCulture);\n }\n\n public void WriteXml(XmlWriter writer)\n {\n writer.WriteString(BirthDay.ToString(CultureInfo.InvariantCulture));\n }\n }\n\n internal class NonPublicClass\n {\n [UsedImplicitly]\n public string Name { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeLessThan.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeLessThan\n {\n [Fact]\n public void A_float_can_never_be_less_than_NaN()\n {\n // Arrange\n float? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeLessThan(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_another_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_less_than_NaN()\n {\n // Arrange\n double? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeLessThan(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_another_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeLessThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Theory]\n [InlineData(5, -1)]\n [InlineData(10, 5)]\n [InlineData(10, -1)]\n public void To_test_the_remaining_paths_for_difference_on_nullable_int(int? subject, int expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeLessThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5L, -1L)]\n [InlineData(10L, 5L)]\n [InlineData(10L, -1L)]\n public void To_test_the_remaining_paths_for_difference_on_nullable_long(long? subject, long expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeLessThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XElementAssertionSpecs.cs", "using System;\nusing System.Xml.Linq;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XElementAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_asserting_an_xml_element_is_equal_to_the_same_xml_element_it_should_succeed()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n var sameElement = new XElement(\"element\");\n\n // Act / Assert\n theElement.Should().Be(sameElement);\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_equal_to_a_different_xml_element_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n var otherElement = new XElement(\"other\");\n\n // Act\n Action act = () =>\n theElement.Should().Be(otherElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to be*other*because we want to test the failure message, but found *element*\");\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_equal_to_an_xml_element_with_a_deep_difference_it_should_fail()\n {\n // Arrange\n var theElement =\n new XElement(\"parent\",\n new XElement(\"child\",\n new XElement(\"grandChild2\")));\n\n var expected =\n new XElement(\"parent\",\n new XElement(\"child\",\n new XElement(\"grandChild\")));\n\n // Act\n Action act = () => theElement.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to be , but found .\");\n }\n\n [Fact]\n public void When_the_expected_element_is_null_it_fails()\n {\n // Arrange\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().Be(new XElement(\"other\"), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to be *failure message*, but found .\");\n }\n\n [Fact]\n public void When_element_is_expected_to_equal_null_it_fails()\n {\n // Arrange\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () => theElement.Should().Be(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to be *failure message*, but found .\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_are_null_it_succeeds()\n {\n // Arrange\n XElement theElement = null;\n\n // Act / Assert\n theElement.Should().Be(null);\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_asserting_an_xml_element_is_not_equal_to_a_different_xml_element_it_should_succeed()\n {\n // Arrange\n var element = new XElement(\"element\");\n var otherElement = new XElement(\"other\");\n\n // Act / Assert\n element.Should().NotBe(otherElement);\n }\n\n [Fact]\n public void When_asserting_a_deep_xml_element_is_not_equal_to_a_different_xml_element_it_should_succeed()\n {\n // Arrange\n var differentElement =\n new XElement(\"parent\",\n new XElement(\"child\",\n new XElement(\"grandChild\")));\n\n var element =\n new XElement(\"parent\",\n new XElement(\"child\",\n new XElement(\"grandChild2\")));\n\n // Act / Assert\n element.Should().NotBe(differentElement);\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_not_equal_to_the_same_xml_element_it_should_fail()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n var sameElement = theElement;\n\n // Act\n Action act = () =>\n theElement.Should().NotBe(sameElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theElement to be because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_an_element_is_not_supposed_to_be_null_it_succeeds()\n {\n // Arrange\n XElement theElement = new(\"element\");\n\n // Act / Assert\n theElement.Should().NotBe(null);\n }\n\n [Fact]\n public void When_a_null_element_is_not_supposed_to_be_an_element_it_succeeds()\n {\n // Arrange\n XElement theElement = null;\n\n // Act / Assert\n theElement.Should().NotBe(new XElement(\"other\"));\n }\n\n [Fact]\n public void When_a_null_element_is_not_supposed_to_be_null_it_fails()\n {\n // Arrange\n XElement theElement = null;\n\n // Act\n Action act = () => theElement.Should().NotBe(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theElement to be *failure message*.\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_asserting_an_xml_element_is_null_and_it_is_it_should_succeed()\n {\n // Arrange\n XElement element = null;\n\n // Act / Assert\n element.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_null_but_it_is_not_it_should_fail()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().BeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to be , but found .\");\n }\n\n [Fact]\n public void When_asserting_an_xml_element_is_null_but_it_is_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to be because we want to test the failure message, but found .\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_asserting_a_non_null_xml_element_is_not_null_it_should_succeed()\n {\n // Arrange\n var element = new XElement(\"element\");\n\n // Act / Assert\n element.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_element_is_not_null_it_should_fail()\n {\n // Arrange\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotBeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected theElement not to be .\");\n }\n\n [Fact]\n public void When_asserting_a_null_xml_element_is_not_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement not to be because we want to test the failure message.\");\n }\n }\n\n public class BeEquivalentTo\n {\n [Fact]\n public void When_asserting_a_xml_element_is_equivalent_to_the_same_xml_element_it_should_succeed()\n {\n // Arrange\n var element = new XElement(\"element\");\n var sameXElement = element;\n\n // Act / Assert\n element.Should().BeEquivalentTo(sameXElement);\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_equivalent_to_a_different_xml_element_with_same_structure_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().BeEquivalentTo(otherXElement);\n }\n\n [Fact]\n public void When_asserting_an_empty_xml_element_is_equivalent_to_a_different_selfclosing_xml_element_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().BeEquivalentTo(otherElement);\n }\n\n [Fact]\n public void When_asserting_a_selfclosing_xml_element_is_equivalent_to_a_different_empty_xml_element_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().BeEquivalentTo(otherElement);\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_equivalent_to_a_xml_element_with_elements_missing_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in theElement at \\\"/parent\\\", but found Element \\\"child2\\\".\");\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_equivalent_to_a_different_xml_element_with_extra_elements_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child2\\\" in theElement at \\\"/parent\\\", but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_equivalent_to_a_different_xml_element_elements_missing_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected EndElement \\\"parent\\\" in theElement at \\\"/parent\\\" because we want to test the failure message, but found Element \\\"child2\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_equivalent_to_a_different_xml_element_with_extra_elements_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Element \\\"child2\\\" in theElement at \\\"/parent\\\" because we want to test the failure message, but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_empty_xml_element_is_equivalent_to_a_different_xml_element_with_text_content_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"text\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(otherXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected content \\\"text\\\" in theElement at \\\"/parent/child\\\" because we want to test the failure message, but found EndElement \\\"parent\\\".\");\n }\n\n [Fact]\n public void When_an_element_is_null_then_be_equivalent_to_null_succeeds()\n {\n XElement theElement = null;\n\n // Act / Assert\n theElement.Should().BeEquivalentTo(null);\n }\n\n [Fact]\n public void When_an_element_is_null_then_be_equivalent_to_an_element_fails()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(new XElement(\"element\"), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to be equivalent to *failure message*, but found \\\"\\\".\");\n }\n\n [Fact]\n public void When_an_element_is_equivalent_to_null_it_fails()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to be equivalent to \\\"\\\" *failure message*, but found .\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_a_different_xml_element_with_different_namespace_prefix_it_should_succeed()\n {\n // Arrange\n var subject = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_a_different_xml_element_which_differs_only_on_unused_namespace_declaration_it_should_succeed()\n {\n // Arrange\n var subject = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_lacks_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"a\\\" in theElement at \\\"/xml/element\\\" because we want to test the failure message, but found none.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_has_extra_attributes_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect to find attribute \\\"a\\\" in theElement at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_has_different_attribute_values_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"a\\\" in theElement at \\\"/xml/element\\\" to have value \\\"c\\\" because we want to test the failure message, but found \\\"b\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_has_attribute_with_different_namespace_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect to find attribute \\\"ns:a\\\" in theElement at \\\"/xml/element\\\" because we want to test the failure message.\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_which_has_different_text_contents_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"a\");\n var expected = XElement.Parse(\"b\");\n\n // Act\n Action act = () =>\n theElement.Should().BeEquivalentTo(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected content to be \\\"b\\\" in theElement at \\\"/xml\\\" because we want to test the failure message, but found \\\"a\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_element_is_equivalent_to_different_xml_element_with_different_comments_it_should_succeed()\n {\n // Arrange\n var subject = XElement.Parse(\"\");\n var expected = XElement.Parse(\"\");\n\n // Act / Assert\n subject.Should().BeEquivalentTo(expected);\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_elements_missing_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().NotBeEquivalentTo(otherXElement);\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_extra_elements_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act / Assert\n element.Should().NotBeEquivalentTo(otherXElement);\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_same_structure_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_same_contents_but_different_ns_prefixes_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n var otherXElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_same_contents_but_extra_unused_xmlns_declaration_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(@\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(otherXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_xml_element_is_not_equivalent_to_the_same_xml_element_it_should_fail()\n {\n // Arrange\n var theElement = new XElement(\"element\");\n var sameXElement = theElement;\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(sameXElement);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_a_different_xml_element_with_same_structure_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var otherXElement = XElement.Parse(\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(otherXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void\n When_asserting_a_xml_element_is_not_equivalent_to_the_same_xml_element_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\");\n var sameXElement = theElement;\n\n // Act\n Action act = () =>\n theElement.Should().NotBeEquivalentTo(sameXElement, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to be equivalent because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void When_a_null_element_is_unexpected_equivalent_to_null_it_fails()\n {\n XElement theElement = null;\n\n // Act\n Action act = () => theElement.Should().NotBeEquivalentTo(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theElement to be equivalent *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_a_null_element_is_not_equivalent_to_an_element_it_succeeds()\n {\n XElement theElement = null;\n\n // Act / Assert\n theElement.Should().NotBeEquivalentTo(new XElement(\"element\"));\n }\n\n [Fact]\n public void When_an_element_is_not_equivalent_to_null_it_succeeds()\n {\n XElement theElement = new(\"element\");\n\n // Act / Assert\n theElement.Should().NotBeEquivalentTo(null);\n }\n }\n\n public class HaveValue\n {\n [Fact]\n public void When_asserting_element_has_a_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"grega\");\n\n // Act / Assert\n element.Should().HaveValue(\"grega\");\n }\n\n [Fact]\n public void When_asserting_element_has_a_specific_value_but_it_has_a_different_value_it_should_throw()\n {\n // Arrange\n var theElement = XElement.Parse(\"grega\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveValue(\"stamac\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement 'user' to have value \\\"stamac\\\", but found \\\"grega\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_element_has_a_specific_value_but_it_has_a_different_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"grega\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveValue(\"stamac\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement 'user' to have value \\\"stamac\\\" because we want to test the failure message, but found \\\"grega\\\".\");\n }\n\n [Fact]\n public void When_xml_element_is_null_then_have_value_should_fail()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveValue(\"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the element to have value \\\"value\\\" *failure message*, but theElement is .\");\n }\n }\n\n public class HaveAttribute\n {\n [Fact]\n public void Passes_when_attribute_found()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().HaveAttribute(\"name\");\n }\n\n [Fact]\n public void Passes_when_attribute_found_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().HaveAttribute(XName.Get(\"name\", \"http://www.example.com/2012/test\"));\n }\n\n [Fact]\n public void Throws_when_attribute_is_not_found()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(\"age\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"age\\\"*failure message*, but found no such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_attribute_is_not_found_with_namespace()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(XName.Get(\"age\", \"http://www.example.com/2012/test\"),\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"{http://www.example.com/2012/test}age\\\"\"\n + \"*failure message*but found no such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_xml_element_is_null()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(\"name\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"name\\\" in element *failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_xml_element_is_null_with_namespace()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute((XName)\"name\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"name\\\" in element*failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_null()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_null_with_namespace()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute((XName)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_empty()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n }\n\n public class NotHaveAttribute\n {\n [Fact]\n public void Passes_when_attribute_not_found()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().NotHaveAttribute(\"surname\");\n }\n\n [Fact]\n public void Passes_when_attribute_not_found_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().NotHaveAttribute(XName.Get(\"surname\", \"http://www.example.com/2012/test\"));\n }\n\n [Fact]\n public void Throws_when_attribute_is_found()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(\"name\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to have attribute \\\"name\\\"*failure message*, but found such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_attribute_is_found_with_namespace()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(XName.Get(\"name\", \"http://www.example.com/2012/test\"),\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to have attribute \\\"{http://www.example.com/2012/test}name\\\"\"\n + \"*failure message*but found such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_xml_element_is_null()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(\"name\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect attribute \\\"name\\\" in element *failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_xml_element_is_null_with_namespace()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute((XName)\"name\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect attribute \\\"name\\\" in element*failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_null()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_null_with_namespace()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute((XName)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n\n [Fact]\n public void Throws_when_expectation_is_empty()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttribute(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n }\n\n public class HaveAttributeWithValue\n {\n [Fact]\n public void When_asserting_element_has_attribute_with_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().HaveAttributeWithValue(\"name\", \"martin\");\n }\n\n [Fact]\n public void When_asserting_element_has_attribute_with_ns_and_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().HaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"martin\");\n }\n\n [Fact]\n public void When_asserting_element_has_attribute_with_specific_value_but_attribute_does_not_exist_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(\"age\", \"36\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"age\\\" with value \\\"36\\\", but found no such attribute in \");\n }\n\n [Fact]\n public void When_asserting_element_has_attribute_with_ns_and_specific_value_but_attribute_does_not_exist_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(XName.Get(\"age\", \"http://www.example.com/2012/test\"), \"36\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"{http://www.example.com/2012/test}age\\\" with value \\\"36\\\",\"\n + \" but found no such attribute in \");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_specific_value_but_attribute_does_not_exist_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n theElement.Should().HaveAttributeWithValue(\"age\", \"36\", \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"age\\\" with value \\\"36\\\" because we want to test the failure message,\"\n + \" but found no such attribute in \");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_ns_and_specific_value_but_attribute_does_not_exist_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(XName.Get(\"age\", \"http://www.example.com/2012/test\"), \"36\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have attribute \\\"{http://www.example.com/2012/test}age\\\" with value \\\"36\\\"\"\n + \" because we want to test the failure message,\"\n + \" but found no such attribute in \");\n }\n\n [Fact]\n public void When_asserting_element_has_attribute_with_specific_value_but_attribute_has_different_value_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(\"name\", \"dennis\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"name\\\" in theElement to have value \\\"dennis\\\", but found \\\"martin\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_ns_and_specific_value_but_attribute_has_different_value_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"dennis\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"{http://www.example.com/2012/test}name\\\" in theElement to have value \\\"dennis\\\", but found \\\"martin\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_specific_value_but_attribute_has_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should()\n .HaveAttributeWithValue(\"name\", \"dennis\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"name\\\" in theElement to have value \\\"dennis\\\"\"\n + \" because we want to test the failure message, but found \\\"martin\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_element_has_attribute_with_ns_and_specific_value_but_attribute_has_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"dennis\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected attribute \\\"{http://www.example.com/2012/test}name\\\" in theElement to have value \\\"dennis\\\"\"\n + \" because we want to test the failure message, but found \\\"martin\\\".\");\n }\n\n [Fact]\n public void When_xml_element_is_null_then_have_attribute_should_fail()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(\"name\", \"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"name\\\" in element to have value \\\"value\\\" *failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void When_xml_element_is_null_then_have_attribute_with_XName_should_fail()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue((XName)\"name\", \"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"name\\\" in element to have value \\\"value\\\" *failure message*\" +\n \", but theElement is .\");\n }\n\n [Fact]\n public void When_asserting_element_has_an_attribute_with_a_null_name_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(null, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n\n [Fact]\n public void When_asserting_element_has_an_attribute_with_a_null_XName_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue((XName)null, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n\n [Fact]\n public void When_asserting_element_has_an_attribute_with_an_empty_name_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithValue(string.Empty, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expectedName\");\n }\n }\n\n public class NotHaveAttributeWithValue\n {\n [Fact]\n public void Passes_when_attribute_does_not_fit()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(\"surname\", \"martin\");\n }\n\n [Fact]\n public void Passes_when_attribute_does_not_fit_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(XName.Get(\"surname\", \"http://www.example.com/2012/test\"), \"martin\");\n }\n\n [Fact]\n public void Passes_when_attribute_and_value_does_not_fit()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(\"surname\", \"mike\");\n }\n\n [Fact]\n public void Passes_when_attribute_and_value_does_not_fit_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(XName.Get(\"surname\", \"http://www.example.com/2012/test\"), \"mike\");\n }\n\n [Fact]\n public void Passes_when_attribute_fits_and_value_does_not()\n {\n // Arrange\n var element = XElement.Parse(@\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(\"name\", \"mike\");\n }\n\n [Fact]\n public void Passes_when_attribute_fits_and_value_does_not_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\"\"\"\"\"\");\n\n // Act / Assert\n element.Should().NotHaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"mike\");\n }\n\n [Fact]\n public void Throws_when_attribute_and_name_fits()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n theElement.Should()\n .NotHaveAttributeWithValue(\"name\", \"martin\", \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to have attribute \\\"name\\\" with value \\\"martin\\\" because we want to test the failure message,\"\n + \" but found such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_attribute_and_name_fits_with_namespace()\n {\n // Arrange\n var theElement = XElement.Parse(\"\"\"\"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(XName.Get(\"name\", \"http://www.example.com/2012/test\"), \"martin\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theElement to have attribute \\\"{http://www.example.com/2012/test}name\\\" with value \\\"martin\\\"\"\n + \" because we want to test the failure message,\"\n + \" but found such attribute in *\");\n }\n\n [Fact]\n public void Throws_when_element_is_null()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(\"name\", \"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect attribute \\\"name\\\" in element to have value \\\"value\\\"*failure message*, but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_element_is_null_with_namespace()\n {\n XElement theElement = null;\n\n // Act\n Action act = () =>\n theElement.Should()\n .NotHaveAttributeWithValue((XName)\"name\", \"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect attribute \\\"name\\\" in element to have value \\\"value\\\"*failure message*, but theElement is .\");\n }\n\n [Fact]\n public void Throws_when_expected_is_null()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(null, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n\n [Fact]\n public void Throws_when_expected_is_null_with_namespace()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue((XName)null, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n\n [Fact]\n public void Throws_when_expected_attribute_is_something_but_value_is_null()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(\"some\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedValue\");\n }\n\n [Fact]\n public void Throws_when_expected_attribute_is_something_but_value_is_null_with_namespace()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue((XName)\"some\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedValue\");\n }\n\n [Fact]\n public void Throws_when_expected_is_empty()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().NotHaveAttributeWithValue(string.Empty, \"value\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"unexpectedName\");\n }\n }\n\n public class HaveElement\n {\n [Fact]\n public void When_asserting_element_has_child_element_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElement(\"child\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_with_ns_and_it_does_it_should_succeed()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElement(XName.Get(\"child\", \"http://www.example.com/2012/test\"));\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(\"unknown\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"unknown\\\", but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_with_ns_but_it_does_not_it_should_fail()\n {\n // Arrange\n var theElement = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(XName.Get(\"unknown\", \"http://www.example.com/2012/test\"));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"{{http://www.example.com/2012/test}}unknown\\\", but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(\"unknown\", \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"unknown\\\" because we want to test the failure message,\"\n + \" but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_with_ns_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theElement = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(XName.Get(\"unknown\", \"http://www.example.com/2012/test\"),\n \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"{{http://www.example.com/2012/test}}unknown\\\"\"\n + \" because we want to test the failure message, but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_element_has_child_element_it_should_return_the_matched_element_in_the_which_property()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \"\"\");\n\n // Act\n var matchedElement = element.Should().HaveElement(\"child\").Subject;\n\n // Assert\n matchedElement.Should().BeOfType()\n .And.HaveAttributeWithValue(\"attr\", \"1\");\n\n matchedElement.Name.Should().Be(XName.Get(\"child\"));\n }\n\n [Fact]\n public void When_asserting_element_has_a_child_element_with_a_null_name_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_asserting_element_has_a_child_element_with_a_null_XName_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement((XName)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_asserting_element_has_a_child_element_with_an_empty_name_it_should_throw()\n {\n XElement theElement = new(\"element\");\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"expected\");\n }\n }\n\n public class HaveElementWithOccurrence\n {\n [Fact]\n public void Element_has_two_child_elements_and_it_expected_does_it_succeeds()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElement(\"child\", Exactly.Twice());\n }\n\n [Fact]\n public void Asserting_element_inside_an_assertion_scope_it_checks_the_whole_assertion_scope_before_failing()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () =>\n {\n using (new AssertionScope())\n {\n element.Should().HaveElement(\"child\", Exactly.Twice());\n element.Should().HaveElement(\"child\", Exactly.Twice());\n }\n };\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void Element_has_two_child_elements_and_three_expected_it_fails()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElement(\"child\", Exactly.Twice());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected element to have an element \\\"child\\\"*exactly*2 times, but found it 3 times.\");\n }\n\n [Fact]\n public void Element_is_valid_and_expected_null_with_string_overload_it_fails()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElement(null, Exactly.Twice());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the element has an element if the expected name is .*\");\n }\n\n [Fact]\n public void Element_is_valid_and_expected_null_with_x_name_overload_it_fails()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElement((XName)null, Exactly.Twice());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert the element has an element count if the element name is .*\");\n }\n\n [Fact]\n public void Chaining_after_a_successful_occurrence_check_does_continue_the_assertion()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElement(\"child\", AtLeast.Twice())\n .Which.Should().NotBeNull();\n }\n\n [Fact]\n public void Chaining_after_a_non_successful_occurrence_check_does_not_continue_the_assertion()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n \n \n \n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElement(\"child\", Exactly.Once())\n .Which.Should().NotBeNull();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected element to have an element \\\"child\\\"*exactly*1 time, but found it 3 times.\");\n }\n\n [Fact]\n public void Null_element_is_expected_to_have_an_element_count_it_should_fail()\n {\n // Arrange\n XElement xElement = null;\n\n // Act\n Action act = () => xElement.Should().HaveElement(\"child\", AtLeast.Once());\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected* to have an element with count of *, but the element itself is .\");\n }\n }\n\n public class HaveElementWithValue\n {\n [Fact]\n public void The_element_cannot_be_null()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void Has_element_with_specified_value()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElementWithValue(\"child\", \"b\");\n }\n\n [Fact]\n public void Throws_when_element_is_not_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(\"c\", \"f\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*c*f*element*isn't found*\");\n }\n\n [Fact]\n public void Throws_when_element_found_but_value_does_not_match()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(\"child\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*c*element*does not have such a value*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue((XName)null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(\"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(XNamespace.None + \"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void The_element_cannot_be_null_and_searching_with_namespace()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () =>\n element.Should()\n .HaveElementWithValue(XNamespace.None + \"child\", \"b\", \"we want to test the {0} message\", \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*failure message*element itself is *\");\n }\n\n [Fact]\n public void Has_element_with_specified_value_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().HaveElementWithValue(XNamespace.None + \"child\", \"b\");\n }\n\n [Fact]\n public void Throws_when_element_with_namespace_not_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n element.Should().HaveElementWithValue(XNamespace.None + \"c\", \"f\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\"*c*f*element*isn't found*\");\n }\n\n [Fact]\n public void Throws_when_element_with_namespace_found_but_value_does_not_match()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().HaveElementWithValue(XNamespace.None + \"child\", \"c\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*c*element*does not have such a value*\");\n }\n }\n\n public class NotHaveElement\n {\n [Fact]\n public void The_element_cannot_be_null()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () => element.Should().NotHaveElement(\"child\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void Element_does_not_have_this_child_element()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElement(\"c\");\n }\n\n [Fact]\n public void Throws_when_element_found_but_expected_to_be_absent()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElement(\"child\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Did not*child*element*was found*\");\n }\n\n [Fact]\n public void Throws_when_unexpected_element_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElement(null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*unexpectedElement*\");\n }\n\n [Fact]\n public void Throws_when_unexpected_element_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElement((XName)null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*unexpectedElement*\");\n }\n\n [Fact]\n public void The_element_cannot_be_null_and_searching_with_namespace()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () =>\n element.Should()\n .NotHaveElement(XNamespace.None + \"child\", \"we want to test the {0} message\", \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*failure message*element itself is *\");\n }\n\n [Fact]\n public void Not_have_element_with_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElement(XNamespace.None + \"c\");\n }\n }\n\n public class NotHaveElementWithValue\n {\n [Fact]\n public void The_element_cannot_be_null()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*element itself is *\");\n }\n\n [Fact]\n public void Throws_when_element_with_specified_value_is_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not*element*child*value*b*does have this value*\");\n }\n\n [Fact]\n public void Passes_when_element_not_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(\"c\", \"f\");\n }\n\n [Fact]\n public void Passes_when_element_found_but_value_does_not_match()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(\"child\", \"c\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_element_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue((XName)null, \"a\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedElement*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(\"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void Throws_when_expected_value_is_null_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*expectedValue*\");\n }\n\n [Fact]\n public void The_element_cannot_be_null_and_searching_with_namespace()\n {\n // Arrange\n XElement element = null;\n\n // Act\n Action act = () =>\n element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"b\", \"we want to test the {0} message\",\n \"failure\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*child*b*failure message*element itself is *\");\n }\n\n [Fact]\n public void Throws_when_element_with_specified_value_is_found_with_namespace()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act\n Action act = () => element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"b\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not expect*element*child*value*b*does have this value*\");\n }\n\n [Fact]\n public void Passes_when_element_with_namespace_not_found()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(XNamespace.None + \"c\", \"f\");\n }\n\n [Fact]\n public void Passes_when_element_with_namespace_found_but_value_does_not_match()\n {\n // Arrange\n var element = XElement.Parse(\n \"\"\"\n \n a\n b\n \n \"\"\");\n\n // Act / Assert\n element.Should().NotHaveElementWithValue(XNamespace.None + \"child\", \"c\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/NotThrowSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\n#if NET47\nusing AwesomeAssertions.Specs.Common;\n#endif\nusing Xunit;\nusing Xunit.Sdk;\nusing static AwesomeAssertions.Extensions.FluentTimeSpanExtensions;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class NotThrowSpecs\n{\n [Fact]\n public void When_subject_is_null_when_an_exception_should_not_be_thrown_it_should_throw()\n {\n // Arrange\n Action act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n act.Should().NotThrow(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n [Fact]\n public void When_a_specific_exception_should_not_be_thrown_but_it_was_it_should_throw()\n {\n // Arrange\n Does foo = Does.Throw(new ArgumentException(\"An exception was forced\"));\n\n // Act\n Action action =\n () => foo.Invoking(f => f.Do()).Should().NotThrow(\"we passed valid arguments\");\n\n // Assert\n action\n .Should().Throw().WithMessage(\n \"Did not expect System.ArgumentException because we passed valid arguments, \" +\n \"but found System.ArgumentException: An exception was forced*\");\n }\n\n [Fact]\n public void When_a_specific_exception_should_not_be_thrown_but_another_was_it_should_succeed()\n {\n // Arrange\n Does foo = Does.Throw();\n\n // Act / Assert\n foo.Invoking(f => f.Do()).Should().NotThrow();\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_but_it_was_it_should_throw()\n {\n // Arrange\n Does foo = Does.Throw(new ArgumentException(\"An exception was forced\"));\n\n // Act\n Action action = () => foo.Invoking(f => f.Do()).Should().NotThrow(\"we passed valid arguments\");\n\n // Assert\n action\n .Should().Throw().WithMessage(\n \"Did not expect any exception because we passed valid arguments, \" +\n \"but found System.ArgumentException: An exception was forced*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_and_none_was_it_should_not_throw()\n {\n // Arrange\n Does foo = Does.NotThrow();\n\n // Act / Assert\n foo.Invoking(f => f.Do()).Should().NotThrow();\n }\n\n [Fact]\n public void When_subject_is_null_when_it_should_not_throw_it_should_throw()\n {\n // Arrange\n Action act = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n\n act.Should().NotThrowAfter(0.Milliseconds(), 0.Milliseconds(),\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*found *\")\n .Where(e => !e.Message.Contains(\"NullReferenceException\"));\n }\n\n#pragma warning disable CS1998, MA0147\n [Fact]\n public void When_subject_is_async_it_should_throw()\n {\n // Arrange\n Action someAsyncAction = async () => { };\n\n // Act\n Action action = () =>\n someAsyncAction.Should().NotThrowAfter(1.Milliseconds(), 1.Milliseconds());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Cannot use action assertions on an async void method.*\");\n }\n#pragma warning restore CS1998, MA0147\n\n [Fact]\n public void When_wait_time_is_negative_it_should_throw()\n {\n // Arrange\n var waitTime = -1.Milliseconds();\n var pollInterval = 10.Milliseconds();\n Action someAction = () => { };\n\n // Act\n Action action = () =>\n someAction.Should().NotThrowAfter(waitTime, pollInterval);\n\n // Assert\n action.Should().Throw()\n .WithParameterName(\"waitTime\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_poll_interval_is_negative_it_should_throw()\n {\n // Arrange\n var waitTime = 10.Milliseconds();\n var pollInterval = -1.Milliseconds();\n Action someAction = () => { };\n\n // Act\n Action action = () =>\n someAction.Should().NotThrowAfter(waitTime, pollInterval);\n\n // Assert\n action.Should().Throw()\n .WithParameterName(\"pollInterval\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_but_it_was_it_should_throw()\n {\n // Arrange\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n\n Action throwLongerThanWaitTime = () =>\n {\n if (timer.Elapsed < waitTime.Multiply(1.5))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n };\n\n // Act\n Action action = () =>\n throwLongerThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval, \"we passed valid arguments\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect any exceptions after 100ms because we passed valid arguments*\");\n }\n\n [Fact]\n public void When_no_exception_should_be_thrown_after_wait_time_and_none_was_it_should_not_throw()\n {\n // Arrange\n var clock = new FakeClock();\n var timer = clock.StartTimer();\n var waitTime = 100.Milliseconds();\n var pollInterval = 10.Milliseconds();\n\n Action throwShorterThanWaitTime = () =>\n {\n if (timer.Elapsed <= waitTime.Divide(2))\n {\n throw new ArgumentException(\"An exception was forced\");\n }\n };\n\n // Act / Assert\n throwShorterThanWaitTime.Should(clock).NotThrowAfter(waitTime, pollInterval);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/EnumAssertionSpecs.cs", "using System;\nusing System.Reflection;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic enum EnumULong : ulong\n{\n Int64Max = long.MaxValue,\n UInt64LessOne = ulong.MaxValue - 1,\n UInt64Max = ulong.MaxValue\n}\n\npublic enum EnumLong : long\n{\n Int64Max = long.MaxValue,\n Int64LessOne = long.MaxValue - 1\n}\n\npublic class EnumAssertionSpecs\n{\n public class HaveFlag\n {\n [Fact]\n public void When_enum_has_the_expected_flag_it_should_succeed()\n {\n // Arrange\n TestEnum someObject = TestEnum.One | TestEnum.Two;\n\n // Act / Assert\n someObject.Should().HaveFlag(TestEnum.One);\n }\n\n [Fact]\n public void When_null_enum_does_not_have_the_expected_flag_it_should_fail()\n {\n // Arrange\n TestEnum? someObject = null;\n\n // Act\n Action act = () => someObject.Should().HaveFlag(TestEnum.Three);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_enum_does_not_have_specified_flag_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TestEnum someObject = TestEnum.One | TestEnum.Two;\n\n // Act\n Action act = () => someObject.Should().HaveFlag(TestEnum.Three, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected*have flag TestEnum.Three {value: 4}*because we want to test the failure message*but found TestEnum.One|Two {value: 3}.\");\n }\n }\n\n public class NotHaveFlag\n {\n [Fact]\n public void When_enum_does_not_have_the_unexpected_flag_it_should_succeed()\n {\n // Arrange\n TestEnum someObject = TestEnum.One | TestEnum.Two;\n\n // Act / Assert\n someObject.Should().NotHaveFlag(TestEnum.Three);\n }\n\n [Fact]\n public void When_enum_does_have_specified_flag_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TestEnum someObject = TestEnum.One | TestEnum.Two;\n\n // Act\n Action act = () => someObject.Should().NotHaveFlag(TestEnum.Two, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected*someObject*to not have flag TestEnum.Two {value: 2}*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_null_enum_does_not_have_the_expected_flag_it_should_not_fail()\n {\n // Arrange\n TestEnum? someObject = null;\n\n // Act / Assert\n someObject.Should().NotHaveFlag(TestEnum.Three);\n }\n }\n\n [Flags]\n public enum TestEnum\n {\n None = 0,\n One = 1,\n Two = 2,\n Three = 4\n }\n\n [Flags]\n public enum OtherEnum\n {\n Default,\n First,\n Second\n }\n\n public class Be\n {\n [Fact]\n public void When_enums_are_equal_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnum expected = MyEnum.One;\n\n // Act / Assert\n subject.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(null, null)]\n [InlineData(MyEnum.One, MyEnum.One)]\n public void When_nullable_enums_are_equal_it_should_succeed(MyEnum? subject, MyEnum? expected)\n {\n // Act / Assert\n subject.Should().Be(expected);\n }\n\n [Fact]\n public void When_a_null_enum_and_an_enum_are_unequal_it_should_throw()\n {\n // Arrange\n MyEnum? subject = null;\n MyEnum expected = MyEnum.Two;\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_enums_are_unequal_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnum expected = MyEnum.Two;\n\n // Act\n Action act = () => subject.Should().Be(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*subject*because we want to test the failure message*\");\n }\n\n [Theory]\n [InlineData(null, MyEnum.One)]\n [InlineData(MyEnum.One, null)]\n [InlineData(MyEnum.One, MyEnum.Two)]\n public void When_nullable_enums_are_equal_it_should_throw(MyEnum? subject, MyEnum? expected)\n {\n // Act\n Action act = () => subject.Should().Be(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_enums_are_unequal_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnum expected = MyEnum.Two;\n\n // Act / Assert\n subject.Should().NotBe(expected);\n }\n\n [Fact]\n public void When_a_null_enum_and_an_enum_are_unequal_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = null;\n MyEnum expected = MyEnum.Two;\n\n // Act / Assert\n subject.Should().NotBe(expected);\n }\n\n [Theory]\n [InlineData(null, MyEnum.One)]\n [InlineData(MyEnum.One, null)]\n [InlineData(MyEnum.One, MyEnum.Two)]\n public void When_nullable_enums_are_unequal_it_should_succeed(MyEnum? subject, MyEnum? expected)\n {\n // Act / Assert\n subject.Should().NotBe(expected);\n }\n\n [Fact]\n public void When_enums_are_equal_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnum expected = MyEnum.One;\n\n // Act\n Action act = () => subject.Should().NotBe(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Theory]\n [InlineData(null, null)]\n [InlineData(MyEnum.One, MyEnum.One)]\n public void When_nullable_enums_are_unequal_it_should_throw(MyEnum? subject, MyEnum? expected)\n {\n // Act\n Action act = () => subject.Should().NotBe(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public enum MyEnum\n {\n One = 1,\n Two = 2\n }\n\n public class HaveValue\n {\n [Fact]\n public void When_enum_has_the_expected_value_it_should_succeed()\n {\n // Arrange\n TestEnum someObject = TestEnum.One;\n\n // Act / Assert\n someObject.Should().HaveValue(1);\n }\n\n [Fact]\n public void When_null_enum_does_not_have_the_expected_value_it_should_fail()\n {\n // Arrange\n TestEnum? someObject = null;\n\n // Act\n Action act = () => someObject.Should().HaveValue(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_enum_does_not_have_specified_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TestEnum someObject = TestEnum.One;\n\n // Act\n Action act = () => someObject.Should().HaveValue(3, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*have value 3*because we want to test the failure message*but found*\");\n }\n\n [Fact]\n public void When_nullable_enum_has_value_it_should_be_chainable()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n\n // Act / Assert\n subject.Should().HaveValue()\n .Which.Should().Be(MyEnum.One);\n }\n\n [Fact]\n public void When_nullable_enum_does_not_have_value_it_should_throw()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n Action act = () => subject.Should().HaveValue(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotHaveValue\n {\n [Fact]\n public void When_enum_does_not_have_the_unexpected_value_it_should_succeed()\n {\n // Arrange\n TestEnum someObject = TestEnum.One;\n\n // Act / Assert\n someObject.Should().NotHaveValue(3);\n }\n\n [Fact]\n public void When_enum_does_have_specified_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TestEnum someObject = TestEnum.One;\n\n // Act\n Action act = () => someObject.Should().NotHaveValue(1, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*someObject*to not have value 1*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_null_enum_does_not_have_the_expected_value_it_should_not_fail()\n {\n // Arrange\n TestEnum? someObject = null;\n\n // Act / Assert\n someObject.Should().NotHaveValue(3);\n }\n\n [Fact]\n public void When_nullable_enum_does_not_have_value_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act / Assert\n subject.Should().NotHaveValue();\n }\n\n [Fact]\n public void When_nullable_enum_has_value_it_should_throw()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n\n // Act\n Action act = () => subject.Should().NotHaveValue(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class HaveSameValueAs\n {\n [Fact]\n public void When_enums_have_equal_values_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherOne;\n\n // Act / Assert\n subject.Should().HaveSameValueAs(expected);\n }\n\n [Fact]\n public void When_nullable_enums_have_equal_values_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherOne;\n\n // Act / Assert\n subject.Should().HaveSameValueAs(expected);\n }\n\n [Fact]\n public void When_enums_have_equal_values_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherTwo;\n\n // Act\n Action act = () => subject.Should().HaveSameValueAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Theory]\n [InlineData(null, MyEnumOtherName.OtherOne)]\n [InlineData(MyEnum.One, MyEnumOtherName.OtherTwo)]\n public void When_nullable_enums_have_equal_values_it_should_throw(MyEnum? subject, MyEnumOtherName expected)\n {\n // Act\n Action act = () => subject.Should().HaveSameValueAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotHaveSameValueAs\n {\n [Fact]\n public void When_enum_have_unequal_values_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherTwo;\n\n // Act / Assert\n subject.Should().NotHaveSameValueAs(expected);\n }\n\n [Theory]\n [InlineData(null, MyEnumOtherName.OtherOne)]\n [InlineData(MyEnum.One, MyEnumOtherName.OtherTwo)]\n public void When_nullable_enums_have_unequal_values_it_should_succeed(MyEnum? subject, MyEnumOtherName expected)\n {\n // Act / Assert\n subject.Should().NotHaveSameValueAs(expected);\n }\n\n [Fact]\n public void When_enums_have_unequal_values_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherOne;\n\n // Act\n Action act = () => subject.Should().NotHaveSameValueAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_nullable_enums_have_unequal_values_it_should_throw()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n MyEnumOtherName expected = MyEnumOtherName.OtherOne;\n\n // Act\n Action act = () => subject.Should().NotHaveSameValueAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public enum MyEnumOtherName\n {\n OtherOne = 1,\n OtherTwo = 2\n }\n\n public class HaveSameNameAs\n {\n [Fact]\n public void When_enums_have_equal_names_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.One;\n\n // Act / Assert\n subject.Should().HaveSameNameAs(expected);\n }\n\n [Fact]\n public void When_nullable_enums_have_equal_names_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.One;\n\n // Act / Assert\n subject.Should().HaveSameNameAs(expected);\n }\n\n [Fact]\n public void When_enums_have_equal_names_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.Two;\n\n // Act\n Action act = () => subject.Should().HaveSameNameAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Theory]\n [InlineData(null, MyEnumOtherValue.One)]\n [InlineData(MyEnum.One, MyEnumOtherValue.Two)]\n public void When_nullable_enums_have_equal_names_it_should_throw(MyEnum? subject, MyEnumOtherValue expected)\n {\n // Act\n Action act = () => subject.Should().HaveSameNameAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotHaveSameNameAs\n {\n [Fact]\n public void When_senum_have_unequal_names_it_should_succeed()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.Two;\n\n // Act / Assert\n subject.Should().NotHaveSameNameAs(expected);\n }\n\n [Theory]\n [InlineData(null, MyEnumOtherValue.One)]\n [InlineData(MyEnum.One, MyEnumOtherValue.Two)]\n public void When_nullable_enums_have_unequal_names_it_should_succeed(MyEnum? subject, MyEnumOtherValue expected)\n {\n // Act / Assert\n subject.Should().NotHaveSameNameAs(expected);\n }\n\n [Fact]\n public void When_enums_have_unequal_names_it_should_throw()\n {\n // Arrange\n MyEnum subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.One;\n\n // Act\n Action act = () => subject.Should().NotHaveSameNameAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_nullable_enums_have_unequal_names_it_should_throw()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n MyEnumOtherValue expected = MyEnumOtherValue.One;\n\n // Act\n Action act = () => subject.Should().NotHaveSameNameAs(expected, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public enum MyEnumOtherValue\n {\n One = 11,\n Two = 22\n }\n\n public class BeNull\n {\n [Fact]\n public void When_nullable_enum_is_null_it_should_succeed()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act / Assert\n subject.Should().BeNull();\n }\n\n [Fact]\n public void When_nullable_enum_is_not_null_it_should_throw()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n\n // Act\n Action act = () => subject.Should().BeNull(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_nullable_enum_is_not_null_it_should_be_chainable()\n {\n // Arrange\n MyEnum? subject = MyEnum.One;\n\n // Act / Assert\n subject.Should().NotBeNull()\n .Which.Should().Be(MyEnum.One);\n }\n\n [Fact]\n public void When_nullable_enum_is_null_it_should_throw()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n Action act = () => subject.Should().NotBeNull(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*because we want to test the failure message*\");\n }\n }\n\n public class Match\n {\n [Fact]\n public void An_enum_matching_the_predicate_should_not_throw()\n {\n // Arrange\n BindingFlags flags = BindingFlags.Public;\n\n // Act / Assert\n flags.Should().Match(x => x == BindingFlags.Public);\n }\n\n [Fact]\n public void An_enum_not_matching_the_predicate_should_throw_with_the_predicate_in_the_message()\n {\n // Arrange\n BindingFlags flags = BindingFlags.Public;\n\n // Act\n Action act = () => flags.Should().Match(x => x == BindingFlags.Static, \"that's what we need\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Static*because that's what we need*found*Public*\");\n }\n\n [Fact]\n public void An_enum_cannot_be_compared_with_a_null_predicate()\n {\n // Act\n Action act = () => BindingFlags.Public.Should().Match(null);\n\n // Assert\n act.Should().Throw().WithMessage(\"*null*predicate*\");\n }\n }\n\n public class BeOneOf\n {\n [Fact]\n public void An_enum_that_is_one_of_the_expected_values_should_not_throw()\n {\n // Arrange\n BindingFlags flags = BindingFlags.Public;\n\n // Act / Assert\n flags.Should().BeOneOf(BindingFlags.Public, BindingFlags.ExactBinding);\n }\n\n [Fact]\n public void Throws_when_the_enums_is_not_one_of_the_expected_enums()\n {\n // Arrange\n BindingFlags flags = BindingFlags.DeclaredOnly;\n\n // Act / Assert\n Action act = () =>\n flags.Should().BeOneOf([BindingFlags.Public, BindingFlags.ExactBinding], \"that's what we need\");\n\n act.Should()\n .Throw()\n .WithMessage(\"Expected*Public*ExactBinding*because that's what we need*found*DeclaredOnly*\");\n }\n\n [Fact]\n public void An_enum_cannot_be_part_of_an_empty_list()\n {\n // Arrange\n BindingFlags flags = BindingFlags.DeclaredOnly;\n\n // Act / Assert\n Action act = () => flags.Should().BeOneOf([]);\n\n act.Should()\n .Throw()\n .WithMessage(\"Cannot*empty list of enums*\");\n }\n\n [Fact]\n public void An_enum_cannot_be_part_of_a_null_list()\n {\n // Arrange\n BindingFlags flags = BindingFlags.DeclaredOnly;\n\n // Act / Assert\n Action act = () => flags.Should().BeOneOf(null);\n\n act.Should()\n .Throw()\n .WithMessage(\"Cannot*null list of enums*\");\n }\n }\n\n public class BeDefined\n {\n [Fact]\n public void A_valid_entry_of_an_enum_is_defined()\n {\n // Arrange\n var dayOfWeek = DayOfWeek.Monday;\n\n // Act / Assert\n dayOfWeek.Should().BeDefined();\n }\n\n [Fact]\n public void If_a_value_casted_to_an_enum_type_and_it_does_not_exist_in_the_enum_it_throws()\n {\n // Arrange\n var dayOfWeek = (DayOfWeek)999;\n\n // Act\n Action act = () => dayOfWeek.Should().BeDefined(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected *to be defined in*failure message*, but it is not*\");\n }\n\n [Fact]\n public void A_null_entry_of_an_enum_throws()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n Action act = () => subject.Should().BeDefined();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected *to be defined in*, but found .\");\n }\n }\n\n public class NotBeDefined\n {\n [Fact]\n public void An_invalid_entry_of_an_enum_is_not_defined_passes()\n {\n // Arrange\n var dayOfWeek = (DayOfWeek)999;\n\n // Act / Assert\n dayOfWeek.Should().NotBeDefined();\n }\n\n [Fact]\n public void A_valid_entry_of_an_enum_is_not_defined_fails()\n {\n // Arrange\n var dayOfWeek = DayOfWeek.Monday;\n\n // Act\n Action act = () => dayOfWeek.Should().NotBeDefined();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*to be defined in*, but it is.\");\n }\n\n [Fact]\n public void A_null_value_of_an_enum_is_not_defined_and_throws()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n Action act = () => subject.Should().NotBeDefined();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect *to be defined in*, but found .\");\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n MyEnum? subject = null;\n\n // Act\n var action = () => subject.Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/DefaultAssertionStrategy.cs", "using System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Execution;\n\n[ExcludeFromCodeCoverage]\ninternal class DefaultAssertionStrategy : IAssertionStrategy\n{\n /// \n /// Returns the messages for the assertion failures that happened until now.\n /// \n public IEnumerable FailureMessages => [];\n\n /// \n /// Instructs the strategy to handle a assertion failure.\n /// \n public void HandleFailure(string message)\n {\n AssertionEngine.TestFramework.Throw(message);\n }\n\n /// \n /// Discards and returns the failure messages that happened up to now.\n /// \n public IEnumerable DiscardFailures() => [];\n\n /// \n /// Will throw a combined exception for any failures have been collected.\n /// \n public void ThrowIfAny(IDictionary context)\n {\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.BeEquivalentTo.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class BeEquivalentTo\n {\n [Fact]\n public void When_asserting_collections_to_be_equivalent_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act =\n () => collection.Should()\n .BeEquivalentTo(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*not to be *\");\n }\n\n [Fact]\n public void When_collections_with_duplicates_are_not_equivalent_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\", \"one\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\", \"three\"];\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1[3]*to be *\\\"one\\\"*\\\"three\\\"*\");\n }\n\n [Fact]\n public void When_testing_for_equivalence_against_empty_collection_it_should_throw()\n {\n // Arrange\n IEnumerable subject = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = new string[0];\n\n // Act\n Action act = () => subject.Should().BeEquivalentTo(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject*to be a collection with 0 item(s), but*contains 3 item(s)*\");\n }\n\n [Fact]\n public void When_testing_for_equivalence_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = null;\n\n // Act\n Action act = () => collection1.Should().BeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1*to be , but found {\\\"one\\\", \\\"two\\\", \\\"three\\\"}*\");\n }\n\n [Fact]\n public void When_two_collections_are_both_empty_it_should_treat_them_as_equivalent()\n {\n // Arrange\n IEnumerable subject = new string[0];\n IEnumerable otherCollection = new string[0];\n\n // Act / Assert\n subject.Should().BeEquivalentTo(otherCollection);\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_elements_it_should_treat_them_as_equivalent()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"three\", \"two\", \"one\"];\n\n // Act / Assert\n collection1.Should().BeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_two_arrays_contain_the_same_elements_it_should_treat_them_as_equivalent()\n {\n // Arrange\n string[] array1 = [\"one\", \"two\", \"three\"];\n string[] array2 = [\"three\", \"two\", \"one\"];\n\n // Act / Assert\n array1.Should().BeEquivalentTo(array2);\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_not_equivalent_to_a_different_collection()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"three\", \"one\"];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equivalent_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable actual = null;\n IEnumerable expectation = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expectation,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual not to be equivalent because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collections_are_unexpectedly_equivalent_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"three\", \"one\", \"two\"];\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 {\\\"one\\\", \\\"two\\\", \\\"three\\\"} not*equivalent*{\\\"three\\\", \\\"one\\\", \\\"two\\\"}.\");\n }\n\n [Fact]\n public void When_non_empty_collection_is_not_expected_to_be_equivalent_to_an_empty_collection_it_should_succeed()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = new string[0];\n\n // Act / Assert\n collection1.Should().NotBeEquivalentTo(collection2);\n }\n\n [Fact]\n public void When_testing_collections_not_to_be_equivalent_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = null;\n\n // Act\n Action act = () => collection1.Should().NotBeEquivalentTo(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify inequivalence against a collection.*\");\n }\n\n [Fact]\n public void When_testing_collections_not_to_be_equivalent_against_same_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable collection1 = collection;\n\n // Act\n Action act = () => collection.Should().NotBeEquivalentTo(collection1,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not to be equivalent*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeGreaterThan.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeGreaterThan\n {\n [Fact]\n public void A_float_can_never_be_greater_than_NaN()\n {\n // Arrange\n float? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_another_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_greater_than_NaN()\n {\n // Arrange\n double? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_another_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Theory]\n [InlineData(5, 5)]\n [InlineData(1, 10)]\n [InlineData(0, 5)]\n [InlineData(0, 0)]\n [InlineData(-1, 5)]\n [InlineData(-1, -1)]\n [InlineData(10, 10)]\n public void To_test_the_null_path_for_difference_on_nullable_int(int? subject, int expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_nullable_byte()\n {\n // Arrange\n var value = (byte?)1;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(1);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_non_null_path_for_difference_on_nullable_byte()\n {\n // Arrange\n var value = (byte?)1;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(2);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_nullable_decimal()\n {\n // Arrange\n var value = (decimal?)11.0;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(11M);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_short()\n {\n // Arrange\n var value = (short?)11;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(11);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_nullable_short()\n {\n // Arrange\n var value = (short?)11;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(11);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Fact]\n public void To_test_the_null_path_for_difference_on_nullable_ushort()\n {\n // Arrange\n var value = (ushort?)11;\n\n // Act\n Action act = () => value.Should().BeGreaterThan(11);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n\n [Theory]\n [InlineData(5L, 5L)]\n [InlineData(1L, 10L)]\n [InlineData(0L, 5L)]\n [InlineData(0L, 0L)]\n [InlineData(-1L, 5L)]\n [InlineData(-1L, -1L)]\n [InlineData(10L, 10L)]\n public void To_test_the_null_path_for_difference_on_nullable_long(long? subject, long expectation)\n {\n // Arrange\n // Act\n Action act = () => subject.Should().BeGreaterThan(expectation);\n\n // Assert\n act\n .Should().Throw()\n .Which.Message.Should().NotMatch(\"*(difference of 0)*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/Guard.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class Guard\n{\n public static void ThrowIfArgumentIsNull([ValidatedNotNull][NoEnumeration] T obj,\n [CallerArgumentExpression(nameof(obj))]\n string paramName = \"\")\n {\n if (obj is null)\n {\n throw new ArgumentNullException(paramName);\n }\n }\n\n public static void ThrowIfArgumentIsNull([ValidatedNotNull][NoEnumeration] T obj, string paramName, string message)\n {\n if (obj is null)\n {\n throw new ArgumentNullException(paramName, message);\n }\n }\n\n public static void ThrowIfArgumentIsNullOrEmpty([ValidatedNotNull] string str,\n [CallerArgumentExpression(nameof(str))]\n string paramName = \"\")\n {\n if (string.IsNullOrEmpty(str))\n {\n ThrowIfArgumentIsNull(str, paramName);\n throw new ArgumentException(\"The value cannot be an empty string.\", paramName);\n }\n }\n\n public static void ThrowIfArgumentIsNullOrEmpty([ValidatedNotNull] string str, string paramName, string message)\n {\n if (string.IsNullOrEmpty(str))\n {\n ThrowIfArgumentIsNull(str, paramName, message);\n throw new ArgumentException(message, paramName);\n }\n }\n\n public static void ThrowIfArgumentIsOutOfRange(T value, [CallerArgumentExpression(nameof(value))] string paramName = \"\")\n where T : Enum\n {\n if (!Enum.IsDefined(typeof(T), value))\n {\n throw new ArgumentOutOfRangeException(paramName);\n }\n }\n\n public static void ThrowIfArgumentContainsNull(IEnumerable values,\n [CallerArgumentExpression(nameof(values))]\n string paramName = \"\")\n {\n if (values.Any(t => t is null))\n {\n throw new ArgumentNullException(paramName, \"Collection contains a null value\");\n }\n }\n\n public static void ThrowIfArgumentIsEmpty(IEnumerable values, string paramName, string message)\n {\n if (!values.Any())\n {\n throw new ArgumentException(message, paramName);\n }\n }\n\n public static void ThrowIfArgumentIsEmpty(string str, string paramName, string message)\n {\n if (str.Length == 0)\n {\n throw new ArgumentException(message, paramName);\n }\n }\n\n public static void ThrowIfArgumentIsNegative(TimeSpan timeSpan,\n [CallerArgumentExpression(nameof(timeSpan))]\n string paramName = \"\")\n {\n if (timeSpan < TimeSpan.Zero)\n {\n throw new ArgumentOutOfRangeException(paramName, \"The value must be non-negative.\");\n }\n }\n\n public static void ThrowIfArgumentIsNegative(float value, [CallerArgumentExpression(nameof(value))] string paramName = \"\")\n {\n if (value < 0)\n {\n throw new ArgumentOutOfRangeException(paramName, \"The value must be non-negative.\");\n }\n }\n\n public static void ThrowIfArgumentIsNegative(double value, [CallerArgumentExpression(nameof(value))] string paramName = \"\")\n {\n if (value < 0)\n {\n throw new ArgumentOutOfRangeException(paramName, \"The value must be non-negative.\");\n }\n }\n\n public static void ThrowIfArgumentIsNegative(decimal value, [CallerArgumentExpression(nameof(value))] string paramName = \"\")\n {\n if (value < 0)\n {\n throw new ArgumentOutOfRangeException(paramName, \"The value must be non-negative.\");\n }\n }\n\n /// \n /// Workaround to make dotnet_code_quality.null_check_validation_methods work\n /// https://github.com/dotnet/roslyn-analyzers/issues/3451#issuecomment-606690452\n /// \n [AttributeUsage(AttributeTargets.Parameter)]\n private sealed class ValidatedNotNullAttribute : Attribute;\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/ExceptionAssertionSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class ExceptionAssertionSpecs\n{\n [Fact]\n public void When_method_throws_an_empty_AggregateException_it_should_fail()\n {\n // Arrange\n Action act = () => throw new AggregateException();\n\n // Act\n Action act2 = () => act.Should().NotThrow();\n\n // Assert\n act2.Should().Throw();\n }\n\n#pragma warning disable xUnit1026 // Theory methods should use all of their parameters\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public void When_the_expected_exception_is_wrapped_it_should_succeed(Action action, T _)\n where T : Exception\n {\n // Act/Assert\n action.Should().Throw();\n }\n\n [Theory]\n [MemberData(nameof(AggregateExceptionTestData))]\n public void When_the_expected_exception_is_not_wrapped_it_should_fail(Action action, T _)\n where T : Exception\n {\n // Act\n Action act2 = () => action.Should().NotThrow();\n\n // Assert\n act2.Should().Throw();\n }\n#pragma warning restore xUnit1026 // Theory methods should use all of their parameters\n\n public static TheoryData AggregateExceptionTestData()\n {\n Action[] tasks =\n [\n AggregateExceptionWithLeftNestedException,\n AggregateExceptionWithRightNestedException\n ];\n\n Exception[] types =\n [\n new AggregateException(),\n new ArgumentNullException(),\n new InvalidOperationException()\n ];\n\n var data = new TheoryData();\n\n foreach (var task in tasks)\n {\n foreach (var type in types)\n {\n data.Add(task, type);\n }\n }\n\n data.Add(EmptyAggregateException, new AggregateException());\n\n return data;\n }\n\n private static void AggregateExceptionWithLeftNestedException()\n {\n var ex1 = new AggregateException(new InvalidOperationException());\n var ex2 = new ArgumentNullException();\n var wrapped = new AggregateException(ex1, ex2);\n\n throw wrapped;\n }\n\n private static void AggregateExceptionWithRightNestedException()\n {\n var ex1 = new ArgumentNullException();\n var ex2 = new AggregateException(new InvalidOperationException());\n var wrapped = new AggregateException(ex1, ex2);\n\n throw wrapped;\n }\n\n private static void EmptyAggregateException()\n {\n throw new AggregateException();\n }\n\n [Fact]\n public void ThrowExactly_when_subject_throws_subclass_of_expected_exception_it_should_throw()\n {\n // Arrange\n Action act = () => throw new ArgumentNullException();\n\n try\n {\n // Act\n act.Should().ThrowExactly(\"because {0} should do that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should()\n .Match(\n \"Expected type to be System.ArgumentException because Does.Do should do that, but found System.ArgumentNullException.\");\n }\n }\n\n [Fact]\n public void ThrowExactly_when_subject_throws_aggregate_exception_instead_of_expected_exception_it_should_throw()\n {\n // Arrange\n Action act = () => throw new AggregateException(new ArgumentException());\n\n try\n {\n // Act\n act.Should().ThrowExactly(\"because {0} should do that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should()\n .Match(\n \"Expected type to be System.ArgumentException because Does.Do should do that, but found System.AggregateException.\");\n }\n }\n\n [Fact]\n public void ThrowExactly_when_subject_throws_expected_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new ArgumentNullException();\n\n // Act / Assert\n act.Should().ThrowExactly();\n }\n}\n\npublic class SomeTestClass\n{\n internal const string ExceptionMessage = \"someMessage\";\n\n public IList Strings = new List();\n\n public void Throw()\n {\n throw new ArgumentException(ExceptionMessage);\n }\n}\n\npublic abstract class Does\n{\n public abstract void Do();\n\n public abstract void Do(string someParam);\n\n public abstract int Return();\n\n public static Does Throw(TException exception)\n where TException : Exception\n {\n return new DoesThrow(exception);\n }\n\n public static Does Throw()\n where TException : Exception, new()\n {\n return Throw(new TException());\n }\n\n public static Does NotThrow() => new DoesNotThrow();\n\n private class DoesThrow : Does\n where TException : Exception\n {\n private readonly TException exception;\n\n public DoesThrow(TException exception)\n {\n this.exception = exception;\n }\n\n public override void Do() => throw exception;\n\n public override void Do(string someParam) => throw exception;\n\n public override int Return() => throw exception;\n }\n\n private class DoesNotThrow : Does\n {\n public override void Do() { }\n\n public override void Do(string someParam) { }\n\n public override int Return() => 42;\n }\n}\n\ninternal class ExceptionWithProperties : Exception\n{\n public ExceptionWithProperties(string propertyValue)\n {\n Property = propertyValue;\n }\n\n public string Property { get; set; }\n}\n\ninternal class ExceptionWithEmptyToString : Exception\n{\n public override string ToString()\n {\n return string.Empty;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeInRange.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeInRange\n {\n [Fact]\n public void When_a_value_is_outside_a_range_it_should_throw()\n {\n // Arrange\n float value = 3.99F;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5, \"because that's the valid range\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5* because that\\'s the valid range, but found*3.99*\");\n }\n\n [Fact]\n public void When_a_value_is_inside_a_range_it_should_not_throw()\n {\n // Arrange\n int value = 4;\n\n // Act / Assert\n value.Should().BeInRange(3, 5);\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_in_range_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeInRange(0, 1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_in_range_of_two_floats()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5*, but found*NaN*\");\n }\n\n [Theory]\n [InlineData(float.NaN, 5F)]\n [InlineData(5F, float.NaN)]\n public void A_float_can_never_be_in_a_range_containing_NaN(float minimumValue, float maximumValue)\n {\n // Arrange\n float value = 4.5F;\n\n // Act\n Action act = () => value.Should().BeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*NaN*\");\n }\n\n [Fact]\n public void A_NaN_is_never_in_range_of_two_doubles()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5*, but found*NaN*\");\n }\n\n [Theory]\n [InlineData(double.NaN, 5)]\n [InlineData(5, double.NaN)]\n public void A_double_can_never_be_in_a_range_containing_NaN(double minimumValue, double maximumValue)\n {\n // Arrange\n double value = 4.5D;\n\n // Act\n Action act = () => value.Should().BeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*NaN*\");\n }\n }\n\n public class NotBeInRange\n {\n [Fact]\n public void When_a_value_is_inside_an_unexpected_range_it_should_throw()\n {\n // Arrange\n float value = 4.99F;\n\n // Act\n Action act = () => value.Should().NotBeInRange(4, 5, \"because that's the invalid range\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to not be between*4* and*5* because that\\'s the invalid range, but found*4.99*\");\n }\n\n [Fact]\n public void When_a_value_is_outside_an_unexpected_range_it_should_not_throw()\n {\n // Arrange\n float value = 3.99F;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_not_in_range_to_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().NotBeInRange(0, 1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_inside_any_range_of_floats()\n {\n // Arrange\n float value = float.NaN;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n\n [Theory]\n [InlineData(float.NaN, 1F)]\n [InlineData(1F, float.NaN)]\n public void Cannot_use_NaN_in_a_range_of_floats(float minimumValue, float maximumValue)\n {\n // Arrange\n float value = 4.5F;\n\n // Act\n Action act = () => value.Should().NotBeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_inside_any_range_of_doubles()\n {\n // Arrange\n double value = double.NaN;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n\n [Theory]\n [InlineData(double.NaN, 1D)]\n [InlineData(1D, double.NaN)]\n public void Cannot_use_NaN_in_a_range_of_doubles(double minimumValue, double maximumValue)\n {\n // Arrange\n double value = 4.5D;\n\n // Act\n Action act = () => value.Should().NotBeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.ContainEquivalentOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]ContainEquivalentOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class ContainEquivalentOf\n {\n [Fact]\n public void Succeed_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing test.\";\n string expect = \"TEST\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_contain_another()\n {\n // Arrange\n string actual = \" this is a string containing test.\";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing test. \";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing \\rA\\nB\\r\\nC.\\n\";\n string expect = \"A\\r\\nB\\nC\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n }\n\n [InlineData(\"aa\", \"A\")]\n [InlineData(\"aCCa\", \"acca\")]\n [Theory]\n public void Should_pass_when_contains_equivalent_of(string actual, string equivalentSubstring)\n {\n // Assert\n actual.Should().ContainEquivalentOf(equivalentSubstring);\n }\n\n [Fact]\n public void Should_fail_contain_equivalent_of_when_not_contains()\n {\n // Act\n Action act = () =>\n \"a\".Should().ContainEquivalentOf(\"aa\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string \\\"a\\\" to contain the equivalent of \\\"aa\\\" at least 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void Should_throw_when_null_equivalent_is_expected()\n {\n // Act\n Action act = () =>\n \"a\".Should().ContainEquivalentOf(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void Should_throw_when_empty_equivalent_is_expected()\n {\n // Act\n Action act = () =>\n \"a\".Should().ContainEquivalentOf(\"\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert string containment against an empty string.*\")\n .WithParameterName(\"expected\");\n }\n\n public class ContainEquivalentOfExactly\n {\n [Fact]\n public void When_containment_equivalent_of_once_is_asserted_against_null_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"a\";\n string expectedSubstring = null;\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Once());\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_exactly_once_is_asserted_and_actual_value_is_null_then_it_should_throw_earlier()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act\n Action act = () =>\n actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Once(), \"that is {0}\", \"required\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * to contain the equivalent of \\\"XyZ\\\" exactly 1 time because that is required, but found it 0 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_exactly_is_asserted_and_actual_value_contains_the_expected_string_exactly_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_exactly_is_asserted_and_actual_value_contains_the_expected_string_but_not_exactly_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Times(3));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" exactly 3 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_exactly_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEf\\\" to contain the equivalent of \\\"xyS\\\" exactly 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void When_containment_equivalent_of_exactly_once_is_asserted_against_an_empty_string_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"a\";\n string expectedSubstring = \"\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, Exactly.Once());\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against an empty string.*\");\n }\n }\n }\n\n public class ContainEquivalentOfAtLeast\n {\n [Fact]\n public void\n When_string_containment_equivalent_of_at_least_is_asserted_and_actual_value_contains_the_expected_string_at_least_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, AtLeast.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_least_is_asserted_and_actual_value_contains_the_expected_string_but_not_at_least_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, AtLeast.Times(3));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" at least 3 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_least_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, AtLeast.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEf\\\" to contain the equivalent of \\\"xyS\\\" at least 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_least_once_is_asserted_and_actual_value_is_null_then_it_should_throw_earlier()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, AtLeast.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain the equivalent of \\\"XyZ\\\" at least 1 time, but found it 0 times.\");\n }\n }\n\n public class ContainEquivalentOfMoreThan\n {\n [Fact]\n public void\n When_string_containment_equivalent_of_more_than_is_asserted_and_actual_value_contains_the_expected_string_more_than_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, MoreThan.Times(1));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_more_than_is_asserted_and_actual_value_contains_the_expected_string_but_not_more_than_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, MoreThan.Times(2));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" more than 2 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_more_than_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, MoreThan.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEf\\\" to contain the equivalent of \\\"xyS\\\" more than 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_more_than_once_is_asserted_and_actual_value_is_null_then_it_should_throw_earlier()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, MoreThan.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain the equivalent of \\\"XyZ\\\" more than 1 time, but found it 0 times.\");\n }\n }\n\n public class ContainEquivalentOfAtMost\n {\n [Fact]\n public void\n When_string_containment_equivalent_of_at_most_is_asserted_and_actual_value_contains_the_expected_string_at_most_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, AtMost.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_most_is_asserted_and_actual_value_contains_the_expected_string_but_not_at_most_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, AtMost.Times(1));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" at most 1 time, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_most_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, AtMost.Once());\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_at_most_once_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, AtMost.Once());\n }\n }\n\n public class ContainEquivalentOfLessThan\n {\n [Fact]\n public void\n When_string_containment_equivalent_of_less_than_is_asserted_and_actual_value_contains_the_expected_string_less_than_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, LessThan.Times(3));\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_less_than_is_asserted_and_actual_value_contains_the_expected_string_but_not_less_than_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEBcDF\";\n string expectedSubstring = \"Bcd\";\n\n // Act\n Action act = () => actual.Should().ContainEquivalentOf(expectedSubstring, LessThan.Times(2));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * \\\"abCDEBcDF\\\" to contain the equivalent of \\\"Bcd\\\" less than 2 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_less_than_twice_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n string actual = \"abCDEf\";\n string expectedSubstring = \"xyS\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, LessThan.Twice());\n }\n\n [Fact]\n public void\n When_string_containment_equivalent_of_less_than_twice_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XyZ\";\n\n // Act / Assert\n actual.Should().ContainEquivalentOf(expectedSubstring, LessThan.Twice());\n }\n }\n\n public class NotContainEquivalentOf\n {\n [Fact]\n public void Succeed_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act / Assert\n actual.Should().NotContainEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_not_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing test.\";\n string expect = \"TEST\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_not_contain_another()\n {\n // Arrange\n string actual = \" this is a string containing test.\";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_not_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing test. \";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_not_contain_another()\n {\n // Arrange\n string actual = \"this is a string containing \\rA\\nB\\r\\nC.\\n\";\n string expect = \"\\nA\\r\\nB\\rC\";\n\n // Act\n Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_asserting_string_does_not_contain_equivalent_of_null()\n {\n // Act\n Action act = () =>\n \"a\".Should().NotContainEquivalentOf(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect string to contain the equivalent of , but found \\\"a\\\".\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_string_does_not_contain_equivalent_of_empty()\n {\n // Act\n Action act = () =>\n \"a\".Should().NotContainEquivalentOf(\"\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect string to contain the equivalent of \\\"\\\", but found \\\"a\\\".\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_string_does_not_contain_equivalent_of_another_string_but_it_does()\n {\n // Act\n Action act = () =>\n \"Hello, world!\".Should().NotContainEquivalentOf(\", worLD!\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect string to contain the equivalent of \\\", worLD!\\\" but found \\\"Hello, world!\\\".\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_string_does_not_contain_equivalent_of_another_string()\n {\n // Act / Assert\n \"aAa\".Should().NotContainEquivalentOf(\"aa \");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeInRange.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeInRange\n {\n [Theory]\n [InlineData(float.NaN, 5F)]\n [InlineData(5F, float.NaN)]\n public void A_float_can_never_be_in_a_range_containing_NaN(float minimumValue, float maximumValue)\n {\n // Arrange\n float? value = 4.5F;\n\n // Act\n Action act = () => value.Should().BeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_in_range_of_two_floats()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5*, but found*NaN*\");\n }\n\n [Theory]\n [InlineData(double.NaN, 5)]\n [InlineData(5, double.NaN)]\n public void A_double_can_never_be_in_a_range_containing_NaN(double minimumValue, double maximumValue)\n {\n // Arrange\n double? value = 4.5;\n\n // Act\n Action act = () => value.Should().BeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_in_range_of_two_doubles()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeInRange(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be between*4* and*5*, but found*NaN*\");\n }\n }\n\n public class NotBeInRange\n {\n [Theory]\n [InlineData(float.NaN, 1F)]\n [InlineData(1F, float.NaN)]\n public void Cannot_use_NaN_in_a_range_of_floats(float minimumValue, float maximumValue)\n {\n // Arrange\n float? value = 4.5F;\n\n // Act\n Action act = () => value.Should().NotBeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_inside_any_range_of_floats()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n\n [Theory]\n [InlineData(double.NaN, 1D)]\n [InlineData(1D, double.NaN)]\n public void Cannot_use_NaN_in_a_range_of_doubles(double minimumValue, double maximumValue)\n {\n // Arrange\n double? value = 4.5D;\n\n // Act\n Action act = () => value.Should().NotBeInRange(minimumValue, maximumValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_inside_any_range_of_doubles()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act / Assert\n value.Should().NotBeInRange(4, 5);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/GivenSelector.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents a chaining object returned from to continue the assertion using\n/// an object returned by a selector.\n/// \npublic class GivenSelector\n{\n private readonly AssertionChain assertionChain;\n private readonly T selector;\n\n internal GivenSelector(Func selector, AssertionChain assertionChain)\n {\n this.assertionChain = assertionChain;\n\n this.selector = assertionChain.Succeeded ? selector() : default;\n }\n\n public bool Succeeded => assertionChain.Succeeded;\n\n /// \n /// Specify the condition that must be satisfied upon the subject selected through a prior selector.\n /// \n /// \n /// If the assertion will be treated as successful and no exceptions will be thrown.\n /// \n /// \n /// The condition will not be evaluated if the prior assertion failed,\n /// nor will throw any exceptions.\n /// \n /// is .\n public GivenSelector ForCondition(Func predicate)\n {\n Guard.ThrowIfArgumentIsNull(predicate);\n\n if (assertionChain.Succeeded)\n {\n assertionChain.ForCondition(predicate(selector));\n }\n\n return this;\n }\n\n public GivenSelector ForConstraint(OccurrenceConstraint constraint, Func func)\n {\n Guard.ThrowIfArgumentIsNull(func);\n\n if (assertionChain.Succeeded)\n {\n assertionChain.ForConstraint(constraint, func(selector));\n }\n\n return this;\n }\n\n public GivenSelector Given(Func selector)\n {\n Guard.ThrowIfArgumentIsNull(selector);\n\n return new GivenSelector(() => selector(this.selector), assertionChain);\n }\n\n public ContinuationOfGiven FailWith(string message)\n {\n return FailWith(message, Array.Empty());\n }\n\n public ContinuationOfGiven FailWith(string message, params Func[] args)\n {\n if (assertionChain.PreviousAssertionSucceeded)\n {\n object[] mappedArguments = args.Select(a => a(selector)).ToArray();\n return FailWith(message, mappedArguments);\n }\n\n return new ContinuationOfGiven(this);\n }\n\n public ContinuationOfGiven FailWith(string message, params object[] args)\n {\n assertionChain.FailWith(message, args);\n return new ContinuationOfGiven(this);\n }\n\n public ContinuationOfGiven FailWith(Func message)\n {\n assertionChain.FailWith(message(selector));\n return new ContinuationOfGiven(this);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/PropertyInfoExtensions.cs", "using System.Reflection;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class PropertyInfoExtensions\n{\n internal static bool IsVirtual(this PropertyInfo property)\n {\n MethodInfo methodInfo = property.GetGetMethod(nonPublic: true) ?? property.GetSetMethod(nonPublic: true);\n return !methodInfo.IsNonVirtual();\n }\n\n internal static bool IsStatic(this PropertyInfo property)\n {\n MethodInfo methodInfo = property.GetGetMethod(nonPublic: true) ?? property.GetSetMethod(nonPublic: true);\n return methodInfo.IsStatic;\n }\n\n internal static bool IsAbstract(this PropertyInfo property)\n {\n MethodInfo methodInfo = property.GetGetMethod(nonPublic: true) ?? property.GetSetMethod(nonPublic: true);\n return methodInfo.IsAbstract;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/PropertyInfoSelectorAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Types;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class PropertyInfoSelectorAssertionSpecs\n{\n public class BeVirtual\n {\n [Fact]\n public void When_asserting_properties_are_virtual_and_they_are_it_should_succeed()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesVirtual));\n\n // Act / Assert\n propertyInfoSelector.Should().BeVirtual();\n }\n\n [Fact]\n public void When_asserting_properties_are_virtual_but_non_virtual_properties_are_found_it_should_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithNonVirtualPublicProperties));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().BeVirtual();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_properties_are_virtual_but_non_virtual_properties_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithNonVirtualPublicProperties));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().BeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected properties\" +\n \" to be virtual because we want to test the error message,\" +\n \" but the following properties are not virtual:*\" +\n \"ClassWithNonVirtualPublicProperties.PublicNonVirtualProperty*\" +\n \"ClassWithNonVirtualPublicProperties.InternalNonVirtualProperty*\" +\n \"ClassWithNonVirtualPublicProperties.ProtectedNonVirtualProperty\");\n }\n }\n\n public class NotBeVirtual\n {\n [Fact]\n public void When_asserting_properties_are_not_virtual_and_they_are_not_it_should_succeed()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithNonVirtualPublicProperties));\n\n // Act / Assert\n propertyInfoSelector.Should().NotBeVirtual();\n }\n\n [Fact]\n public void When_asserting_properties_are_not_virtual_but_virtual_properties_are_found_it_should_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesVirtual));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().NotBeVirtual();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_properties_are_not_virtual_but_virtual_properties_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesVirtual));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().NotBeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected properties\" +\n \" not to be virtual because we want to test the error message,\" +\n \" but the following properties are virtual*\" +\n \"*ClassWithAllPropertiesVirtual.PublicVirtualProperty\" +\n \"*ClassWithAllPropertiesVirtual.InternalVirtualProperty\" +\n \"*ClassWithAllPropertiesVirtual.ProtectedVirtualProperty\");\n }\n }\n\n public class BeDecoratedWith\n {\n [Fact]\n public void When_asserting_properties_are_decorated_with_attribute_and_they_are_it_should_succeed()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute));\n\n // Act / Assert\n propertyInfoSelector.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_properties_are_decorated_with_attribute_and_they_are_not_it_should_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute))\n .ThatArePublicOrInternal;\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_properties_are_decorated_with_attribute_and_they_are_not_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should()\n .BeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected properties to be decorated with\" +\n \" AwesomeAssertions*DummyPropertyAttribute because we want to test the error message,\" +\n \" but the following properties are not:*\" +\n \"ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.PublicProperty*\" +\n \"ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.InternalProperty*\" +\n \"ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.ProtectedProperty\");\n }\n }\n\n public class NotBeDecoratedWith\n {\n [Fact]\n public void When_asserting_properties_are_not_decorated_with_attribute_and_they_are_not_it_should_succeed()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute));\n\n // Act / Assert\n propertyInfoSelector.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_properties_are_not_decorated_with_attribute_and_they_are_it_should_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute))\n .ThatArePublicOrInternal;\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should().NotBeDecoratedWith();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_properties_are_not_decorated_with_attribute_and_they_are_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n propertyInfoSelector.Should()\n .NotBeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected properties not to be decorated*\" +\n \"DummyPropertyAttribute*\" +\n \"because we want to test the error message*\" +\n \"ClassWithAllPropertiesDecoratedWithDummyAttribute.PublicProperty*\" +\n \"ClassWithAllPropertiesDecoratedWithDummyAttribute.InternalProperty*\" +\n \"ClassWithAllPropertiesDecoratedWithDummyAttribute.ProtectedProperty*\");\n }\n }\n\n public class BeWritable\n {\n [Fact]\n public void When_a_read_only_property_is_expected_to_be_writable_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithReadOnlyProperties));\n\n // Act\n Action action = () => propertyInfoSelector.Should().BeWritable(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\n \"Expected all selected properties to have a setter because we want to test the error message, \" +\n \"but the following properties do not:*\" +\n \"ClassWithReadOnlyProperties.ReadOnlyProperty*\" +\n \"ClassWithReadOnlyProperties.ReadOnlyProperty2\");\n }\n\n [Fact]\n public void When_writable_properties_are_expected_to_be_writable_it_should_not_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithOnlyWritableProperties));\n\n // Act / Assert\n propertyInfoSelector.Should().BeWritable();\n }\n }\n\n public class NotBeWritable\n {\n [Fact]\n public void When_a_writable_property_is_expected_to_be_read_only_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithWritableProperties));\n\n // Act\n Action action = () => propertyInfoSelector.Should().NotBeWritable(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\n \"Expected selected properties to not have a setter because we want to test the error message, \" +\n \"but the following properties do:*\" +\n \"ClassWithWritableProperties.ReadWriteProperty*\" +\n \"ClassWithWritableProperties.ReadWriteProperty2\");\n }\n\n [Fact]\n public void When_read_only_properties_are_expected_to_not_be_writable_it_should_not_throw()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithOnlyReadOnlyProperties));\n\n // Act / Assert\n propertyInfoSelector.Should().NotBeWritable();\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var someObject = new PropertyInfoSelectorAssertions(AssertionChain.GetOrCreate());\n\n // Act\n var action = () => someObject.Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n\n [Fact]\n public void A_failing_check_on_a_generic_class_includes_the_generic_type_in_the_failure_message()\n {\n // Arrange\n var propertyInfoSelector = new PropertyInfoSelector(typeof(GenericClassWithOnlyReadOnlyProperties));\n\n // Act\n Action action = () => propertyInfoSelector.Should().BeWritable(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected all selected properties to have a setter because we want to test the error message, \" +\n \"but the following properties do not:*\" +\n \"GenericClassWithOnlyReadOnlyProperties.ReadOnlyProperty\");\n }\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class ClassWithAllPropertiesVirtual\n{\n public virtual string PublicVirtualProperty { set { } }\n\n internal virtual string InternalVirtualProperty => null;\n\n protected virtual string ProtectedVirtualProperty { get; set; }\n}\n\ninternal interface IInterfaceWithProperty\n{\n string PublicNonVirtualProperty { get; set; }\n}\n\ninternal class ClassWithNonVirtualPublicProperties : IInterfaceWithProperty\n{\n public string PublicNonVirtualProperty { get; set; }\n\n internal string InternalNonVirtualProperty { get; set; }\n\n protected string ProtectedNonVirtualProperty { get; set; }\n}\n\ninternal class ClassWithReadOnlyProperties\n{\n public string ReadOnlyProperty => \"\";\n\n public string ReadOnlyProperty2 => \"\";\n\n public string ReadWriteProperty { get => \"\"; set { } }\n}\n\ninternal class ClassWithWritableProperties\n{\n public string ReadOnlyProperty => \"\";\n\n public string ReadWriteProperty { get => \"\"; set { } }\n\n public string ReadWriteProperty2 { get => \"\"; set { } }\n}\n\ninternal class ClassWithOnlyWritableProperties\n{\n public string ReadWriteProperty { set { } }\n}\n\ninternal class ClassWithOnlyReadOnlyProperties\n{\n public string ReadOnlyProperty => \"\";\n\n public string ReadOnlyProperty2 => \"\";\n}\n\ninternal class GenericClassWithOnlyReadOnlyProperties\n{\n public TSubject ReadOnlyProperty => default;\n}\n\ninternal class ClassWithAllPropertiesDecoratedWithDummyAttribute\n{\n [DummyProperty(\"Value\")]\n public string PublicProperty { get; set; }\n\n [DummyProperty(\"Value\")]\n [DummyProperty(\"OtherValue\")]\n public string PublicPropertyWithSameAttributeTwice { get; set; }\n\n [DummyProperty]\n internal string InternalProperty { get; set; }\n\n [DummyProperty]\n protected string ProtectedProperty { get; set; }\n}\n\ninternal class ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute\n{\n public string PublicProperty { get; set; }\n\n internal string InternalProperty { get; set; }\n\n protected string ProtectedProperty { get; set; }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeInAscendingOrder.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeInAscendingOrder specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeInAscendingOrder\n {\n [Fact]\n public void When_asserting_a_null_collection_to_be_in_ascending_order_it_should_throw()\n {\n // Arrange\n List result = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n result.Should().BeInAscendingOrder();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*but found *\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_ascendingly_ordered_collection_are_ordered_ascending_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ascendingly_ordered_collection_are_ordered_ascending_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_unordered_collection_are_ordered_ascending_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 6, 12, 15, 12, 17, 26];\n\n // Act\n Action action = () => collection.Should().BeInAscendingOrder(\"because numbers are ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to be in ascending order because numbers are ordered,\" +\n \" but found {1, 6, 12, 15, 12, 17, 26} where item at index 3 is in wrong order.\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_ascending_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 6, 12, 15, 12, 17, 26];\n\n // Act\n Action action = () => collection.Should().BeInAscendingOrder(Comparer.Default, \"because numbers are ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to be in ascending order because numbers are ordered,\" +\n \" but found {1, 6, 12, 15, 12, 17, 26} where item at index 3 is in wrong order.\");\n }\n\n [Fact]\n public void Items_can_be_ordered_by_the_identity_function()\n {\n // Arrange\n int[] collection = [1, 2];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(x => x);\n }\n\n [Fact]\n public void When_asserting_empty_collection_with_no_parameters_ordered_in_ascending_it_should_succeed()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder();\n }\n\n [Fact]\n public void When_asserting_empty_collection_by_property_expression_ordered_in_ascending_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(o => o.Number);\n }\n\n [Fact]\n public void When_asserting_single_element_collection_with_no_parameters_ordered_in_ascending_it_should_succeed()\n {\n // Arrange\n int[] collection = [42];\n\n // Act / Assert\n collection.Should().BeInAscendingOrder();\n }\n\n [Fact]\n public void When_asserting_single_element_collection_by_property_expression_ordered_in_ascending_it_should_succeed()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(o => o.Number);\n }\n\n [Fact]\n public void Can_use_a_cast_expression_in_the_ordering_expression()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act & Assert\n collection.Should().BeInAscendingOrder(o => (float)o.Number);\n }\n\n [Fact]\n public void Can_use_an_index_into_a_list_in_the_ordering_expression()\n {\n // Arrange\n List[] collection =\n [\n [new() { Text = \"a\", Number = 1 }]\n ];\n\n // Act & Assert\n collection.Should().BeInAscendingOrder(o => o[0].Number);\n }\n\n [Fact]\n public void Can_use_an_index_into_an_array_in_the_ordering_expression()\n {\n // Arrange\n SomeClass[][] collection =\n [\n [new SomeClass { Text = \"a\", Number = 1 }]\n ];\n\n // Act & Assert\n collection.Should().BeInAscendingOrder(o => o[0].Number);\n }\n\n [Fact]\n public void Unsupported_ordering_expressions_are_invalid()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.Number > 1);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Expression <*> cannot be used to select a member.*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_ascending_using_the_specified_property_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.Text, \"it should be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*ordered*Text*should be sorted*a*b*c*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_ascending_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act\n Action act = () =>\n collection.Should().BeInAscendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase, \"it should be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*ordered*Text*should be sorted*a*b*c*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ascendingly_ordered_collection_are_ordered_ascending_using_the_specified_property_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(o => o.Numeric);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ascendingly_ordered_collection_are_ordered_ascending_using_the_specified_property_and_the_given_comparer_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act / Assert\n collection.Should().BeInAscendingOrder(o => o.Numeric, Comparer.Default);\n }\n\n [Fact]\n public void When_strings_are_in_ascending_order_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"alpha\", \"beta\", \"theta\"];\n\n // Act / Assert\n strings.Should().BeInAscendingOrder();\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_it_should_throw()\n {\n // Arrange\n string[] strings = [\"theta\", \"alpha\", \"beta\"];\n\n // Act\n Action act = () => strings.Should().BeInAscendingOrder(\"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*ascending*of reasons*index 0*\");\n }\n\n [Fact]\n public void When_strings_are_in_ascending_order_according_to_a_custom_comparer_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"alpha\", \"beta\", \"theta\"];\n\n // Act / Assert\n strings.Should().BeInAscendingOrder(new ByLastCharacterComparer());\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_according_to_a_custom_comparer_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"thomas\"];\n\n // Act\n Action act = () => strings.Should().BeInAscendingOrder(new ByLastCharacterComparer(), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*ascending*of reasons*index 1*\");\n }\n\n [Fact]\n public void When_strings_are_in_ascending_order_according_to_a_custom_lambda_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"alpha\", \"beta\", \"theta\"];\n\n // Act / Assert\n strings.Should().BeInAscendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]));\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_according_to_a_custom_lambda_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"thomas\"];\n\n // Act\n Action act = () =>\n strings.Should().BeInAscendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*ascending*of reasons*index 1*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_null_collection_are_ordered_using_the_specified_property_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.Text);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Text*found*null*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_null_collection_are_ordered_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(Comparer.Default);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*found*null*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_null_collection_are_ordered_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*Text*found*null*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_collection_are_ordered_and_the_specified_property_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder((Expression>)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert collection ordering without specifying a property*\")\n .WithParameterName(\"propertyExpression\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_collection_are_ordered_and_the_given_comparer_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(comparer: null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert collection ordering without specifying a comparer*\")\n .WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_ay_collection_are_ordered_using_an_invalid_property_expression_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().BeInAscendingOrder(o => o.GetHashCode());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expression*o.GetHashCode()*cannot be used to select a member*\");\n }\n }\n\n public class NotBeInAscendingOrder\n {\n [Fact]\n public void When_asserting_a_null_collection_to_not_be_in_ascending_order_it_should_throw()\n {\n // Arrange\n List result = null;\n\n // Act\n Action act = () => result.Should().NotBeInAscendingOrder();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*but found *\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_unordered_collection_are_not_in_ascending_order_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 5, 3];\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_not_in_ascending_order_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 5, 3];\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_ascendingly_ordered_collection_are_not_in_ascending_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act\n Action action = () => collection.Should().NotBeInAscendingOrder(\"because numbers are not ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order because numbers are not ordered,\" +\n \" but found {1, 2, 2, 3}.\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ascendingly_ordered_collection_are_not_in_ascending_order_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act\n Action action = () =>\n collection.Should().NotBeInAscendingOrder(Comparer.Default, \"because numbers are not ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order because numbers are not ordered,\" +\n \" but found {1, 2, 2, 3}.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_by_property_expression_to_not_be_ordered_in_ascending_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.Number);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection {empty} to not be ordered \\\"by Number\\\" and not result in {empty}.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_with_no_parameters_not_be_ordered_in_ascending_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(\"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order because I say so, but found {empty}.\");\n }\n\n [Fact]\n public void When_asserting_single_element_collection_with_no_parameters_not_be_ordered_in_ascending_it_should_throw()\n {\n // Arrange\n int[] collection = [42];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order, but found {42}.\");\n }\n\n [Fact]\n public void\n When_asserting_single_element_collection_by_property_expression_to_not_be_ordered_in_ascending_it_should_throw()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.Number);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_ascending_ordered_collection_are_not_ordered_ascending_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(Comparer.Default, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in ascending order*should not be sorted*1*2*3*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_ascendingly_ordered_collection_are_not_ordered_ascending_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n int[] collection = [3, 2, 1];\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_ascending_ordered_collection_are_not_ordered_ascending_using_the_specified_property_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"a\", Numeric = 3 },\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 }\n };\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.Text, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*a*b*c*not be ordered*Text*should not be sorted*a*b*c*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ordered_collection_are_not_ordered_ascending_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"A\", Numeric = 1 },\n new { Text = \"b\", Numeric = 2 },\n new { Text = \"C\", Numeric = 3 }\n };\n\n // Act\n Action act = () =>\n collection.Should()\n .NotBeInAscendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*A*b*C*not be ordered*Text*should not be sorted*A*b*C*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_ascendingly_ordered_collection_are_not_ordered_ascending_using_the_specified_property_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 3 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 1 }\n };\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder(o => o.Numeric);\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_ascendingly_ordered_collection_are_not_ordered_ascending_using_the_specified_property_and_the_given_comparer_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 3 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 1 }\n };\n\n // Act / Assert\n collection.Should().NotBeInAscendingOrder(o => o.Numeric, Comparer.Default);\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"beta\", \"alpha\", \"theta\"];\n\n // Act / Assert\n strings.Should().NotBeInAscendingOrder();\n }\n\n [Fact]\n public void When_strings_are_in_ascending_order_unexpectedly_it_should_throw()\n {\n // Arrange\n string[] strings = [\"alpha\", \"beta\", \"theta\"];\n\n // Act\n Action act = () => strings.Should().NotBeInAscendingOrder(\"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*ascending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_according_to_a_custom_comparer_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"barbara\"];\n\n // Act / Assert\n strings.Should().NotBeInAscendingOrder(new ByLastCharacterComparer());\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_ascending_order_according_to_a_custom_comparer_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"thomas\", \"roy\"];\n\n // Act\n Action act = () => strings.Should().NotBeInAscendingOrder(new ByLastCharacterComparer(), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*ascending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_strings_are_not_in_ascending_order_according_to_a_custom_lambda_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"thomas\"];\n\n // Act / Assert\n strings.Should().NotBeInAscendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]));\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_ascending_order_according_to_a_custom_lambda_it_should_throw()\n {\n // Arrange\n string[] strings = [\"barbara\", \"dennis\", \"roy\"];\n\n // Act\n Action act = () =>\n strings.Should().NotBeInAscendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*ascending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_null_collection_are_not_ordered_using_the_specified_property_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotBeInAscendingOrder(o => o.Text);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Text*found*null*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_null_collection_are_not_ordered_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotBeInAscendingOrder(Comparer.Default);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*found*null*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_null_collection_are_not_ordered_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Text*found*null*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_collection_are_not_ordered_and_the_specified_property_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder((Expression>)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert collection ordering without specifying a property*propertyExpression*\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_collection_are_not_ordered_and_the_given_comparer_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(comparer: null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert collection ordering without specifying a comparer*comparer*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_ay_collection_are_not_ordered_using_an_invalid_property_expression_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInAscendingOrder(o => o.GetHashCode());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expression*o.GetHashCode()*cannot be used to select a member*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCountGreaterThanOrEqualTo.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveCountGreaterThanOrEqualTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCountGreaterThanOrEqualTo\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_greater_than_or_equal_to_less_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountGreaterThanOrEqualTo(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_greater_than_or_equal_to_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCountGreaterThanOrEqualTo(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_collection_has_a_count_greater_than_or_equal_to_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () =>\n collection.Should().HaveCountGreaterThanOrEqualTo(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain at least 4 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_greater_than_or_equal_to_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCountGreaterThanOrEqualTo(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*at least*1*we want to test the behaviour with a null subject*found *\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountGreaterThanOrEqualTo(3).And.Contain(1);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCountLessThanOrEqualTo.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveCountLessOrEqualTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCountLessThanOrEqualTo\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_less_than_or_equal_to_less_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountLessThanOrEqualTo(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_less_than_or_equal_to_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCountLessThanOrEqualTo(2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_collection_has_a_count_less_than_or_equal_to_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () =>\n collection.Should().HaveCountLessThanOrEqualTo(2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain at most 2 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_less_than_or_equal_to_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCountLessThanOrEqualTo(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*at most*1*we want to test the behaviour with a null subject*found *\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountLessThanOrEqualTo(3).And.Contain(1);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.Be.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void A_value_is_equal_to_the_same_value()\n {\n // Arrange\n int value = 1;\n int sameValue = 1;\n\n // Act\n value.Should().Be(sameValue);\n }\n\n [Fact]\n public void A_value_is_not_equal_to_another_value()\n {\n // Arrange\n int value = 1;\n int differentValue = 2;\n\n // Act\n Action act = () => value.Should().Be(differentValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 2 because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void A_value_is_equal_to_the_same_nullable_value()\n {\n // Arrange\n int value = 2;\n int? nullableValue = 2;\n\n // Act\n value.Should().Be(nullableValue);\n }\n\n [Fact]\n public void A_value_is_not_equal_to_null()\n {\n // Arrange\n int value = 2;\n int? nullableValue = null;\n\n // Act\n Action act = () => value.Should().Be(nullableValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*, but found 2.\");\n }\n\n [Fact]\n public void Null_is_not_equal_to_another_nullable_value()\n {\n // Arrange\n int? value = 2;\n\n // Act\n Action action = () => ((int?)null).Should().Be(value);\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Expected*2, but found .\");\n }\n\n [InlineData(0, 0)]\n [InlineData(null, null)]\n [Theory]\n public void A_nullable_value_is_equal_to_the_same_nullable_value(int? subject, int? expected)\n {\n // Act / Assert\n subject.Should().Be(expected);\n }\n\n [InlineData(0, 1)]\n [InlineData(0, null)]\n [InlineData(null, 0)]\n [Theory]\n public void A_nullable_value_is_not_equal_to_another_nullable_value(int? subject, int? expected)\n {\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Null_is_not_equal_to_another_value()\n {\n // Arrange\n int? subject = null;\n int expected = 1;\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_that_a_float_value_is_equal_to_a_different_value_it_should_throw()\n {\n // Arrange\n float value = 3.5F;\n\n // Act\n Action act = () => value.Should().Be(3.4F, \"we want to test the error message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be *3.4* because we want to test the error message, but found *3.5*\");\n }\n\n [Fact]\n public void When_asserting_that_a_float_value_is_equal_to_the_same_value_it_should_not_throw()\n {\n // Arrange\n float value = 3.5F;\n\n // Act / Assert\n value.Should().Be(3.5F);\n }\n\n [Fact]\n public void When_asserting_that_a_null_float_value_is_equal_to_some_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n\n // Act\n Action act = () => value.Should().Be(3.5F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be *3.5* but found .\");\n }\n\n [Fact]\n public void When_asserting_that_a_double_value_is_equal_to_a_different_value_it_should_throw()\n {\n // Arrange\n double value = 3.5;\n\n // Act\n Action act = () => value.Should().Be(3.4, \"we want to test the error message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 3.4 because we want to test the error message, but found 3.5*.\");\n }\n\n [Fact]\n public void When_asserting_that_a_double_value_is_equal_to_the_same_value_it_should_not_throw()\n {\n // Arrange\n double value = 3.5;\n\n // Act / Assert\n value.Should().Be(3.5);\n }\n\n [Fact]\n public void When_asserting_that_a_null_double_value_is_equal_to_some_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n\n // Act\n Action act = () => value.Should().Be(3.5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 3.5, but found .\");\n }\n\n [Fact]\n public void When_asserting_that_a_decimal_value_is_equal_to_a_different_value_it_should_throw()\n {\n // Arrange\n decimal value = 3.5m;\n\n // Act\n Action act = () => value.Should().Be(3.4m, \"we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected value to be*3.4* because we want to test the error message, but found*3.5*\");\n }\n\n [Fact]\n public void When_asserting_that_a_decimal_value_is_equal_to_the_same_value_it_should_not_throw()\n {\n // Arrange\n decimal value = 3.5m;\n\n // Act / Assert\n value.Should().Be(3.5m);\n }\n\n [Fact]\n public void When_asserting_that_a_null_decimal_value_is_equal_to_some_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n decimal someValue = 3.5m;\n\n // Act\n Action act = () => value.Should().Be(someValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be*3.5*, but found .\");\n }\n\n [Fact]\n public void Nan_is_never_equal_to_a_normal_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().Be(3.4F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be *3.4F, but found NaN*\");\n }\n\n [Fact]\n public void NaN_can_be_compared_to_NaN_when_its_a_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n value.Should().Be(float.NaN);\n }\n\n [Fact]\n public void Nan_is_never_equal_to_a_normal_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().Be(3.4D);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be *3.4, but found NaN*\");\n }\n\n [Fact]\n public void NaN_can_be_compared_to_NaN_when_its_a_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n value.Should().Be(double.NaN);\n }\n }\n\n public class NotBe\n {\n [InlineData(1, 2)]\n [InlineData(null, 2)]\n [Theory]\n public void A_nullable_value_is_not_equal_to_another_value(int? subject, int unexpected)\n {\n // Act\n subject.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void A_value_is_not_different_from_the_same_value()\n {\n // Arrange\n int value = 1;\n int sameValue = 1;\n\n // Act\n Action act = () => value.Should().NotBe(sameValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Did not expect value to be 1 because we want to test the failure message.\");\n }\n\n [InlineData(null, null)]\n [InlineData(0, 0)]\n [Theory]\n public void A_nullable_value_is_not_different_from_the_same_value(int? subject, int? unexpected)\n {\n // Act\n Action act = () => subject.Should().NotBe(unexpected);\n\n // Assert\n act.Should().Throw();\n }\n\n [InlineData(0, 1)]\n [InlineData(0, null)]\n [InlineData(null, 0)]\n [Theory]\n public void A_nullable_value_is_different_from_another_value(int? subject, int? unexpected)\n {\n // Act / Assert\n subject.Should().NotBe(unexpected);\n }\n }\n\n public class Bytes\n {\n [Fact]\n public void When_asserting_a_byte_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n byte value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_sbyte_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n sbyte value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_short_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n short value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_an_ushort_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n ushort value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_an_uint_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n uint value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_long_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n long value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_an_ulong_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n ulong value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n }\n\n public class NullableBytes\n {\n [Fact]\n public void When_asserting_a_nullable_byte_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n byte? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_sbyte_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n sbyte? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_short_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n short? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_ushort_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n ushort? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_uint_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n uint? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_long_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n long? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n\n [Fact]\n public void When_asserting_a_nullable_nullable_ulong_value_it_should_treat_is_any_numeric_value()\n {\n // Arrange\n ulong? value = 2;\n\n // Act / Assert\n value.Should().Be(2);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/MethodInfoAssertionSpecs.cs", "using System;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class MethodInfoAssertionSpecs\n{\n public class BeVirtual\n {\n [Fact]\n public void When_asserting_a_method_is_virtual_and_it_is_then_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithAllMethodsVirtual).GetParameterlessMethod(\"PublicVirtualDoNothing\");\n\n // Act / Assert\n methodInfo.Should().BeVirtual();\n }\n\n [Fact]\n public void When_asserting_a_method_is_virtual_but_it_is_not_then_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithNonVirtualPublicMethods).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method void AwesomeAssertions*ClassWithNonVirtualPublicMethods.PublicDoNothing\" +\n \" to be virtual because we want to test the error message,\" +\n \" but it is not virtual.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_virtual_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().BeVirtual(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method to be virtual *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotBeVirtual\n {\n [Fact]\n public void When_asserting_a_method_is_not_virtual_and_it_is_not_then_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithNonVirtualPublicMethods).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeVirtual();\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_virtual_but_it_is_then_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithAllMethodsVirtual).GetParameterlessMethod(\"PublicVirtualDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method *ClassWithAllMethodsVirtual.PublicVirtualDoNothing\" +\n \" not to be virtual because we want to test the error message,\" +\n \" but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_virtual_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeVirtual(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method not to be virtual *failure message*, but methodInfo is .\");\n }\n }\n\n public class BeDecoratedWithOfT\n {\n [Fact]\n public void When_asserting_a_method_is_decorated_with_attribute_and_it_is_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_and_it_is_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"DoNotInlineMe\");\n\n // Act / Assert\n methodInfo.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_constructor_is_decorated_with_an_attribute_and_it_is_it_succeeds()\n {\n // Arrange\n ConstructorInfo constructorMethodInfo =\n typeof(ClassWithMethodWithImplementationAttribute).GetConstructor(Type.EmptyTypes);\n\n // Act / Assert\n constructorMethodInfo.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_constructor_is_decorated_with_an_attribute_and_it_is_not_it_throws()\n {\n // Arrange\n ConstructorInfo constructorMethodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetConstructor([typeof(string)]);\n\n // Act\n Action act = () =>\n constructorMethodInfo.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw(\n \"Expected constructor AwesomeAssertions.Specs.Types.ClassWithMethodsThatAreNotDecoratedWithDummyAttribute(string parameter) \" +\n \"to be decorated with System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_and_it_is_not_it_throws()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothing to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_with_no_options_and_it_is_it_throws()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"NoOptions\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodWithImplementationAttribute.NoOptions to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_with_zero_as_options_and_it_is_it_throws()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"ZeroOptions\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodWithImplementationAttribute.ZeroOptions to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_class_is_decorated_with_an_attribute_and_it_is_not_it_throws()\n {\n // Arrange\n var type = typeof(ClassWithAllMethodsDecoratedWithDummyAttribute);\n\n // Act\n Action act = () =>\n type.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type AwesomeAssertions*ClassWithAllMethodsDecoratedWithDummyAttribute to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but the attribute was not found.\");\n }\n\n [Fact]\n public void When_a_method_is_decorated_with_an_attribute_it_should_allow_chaining_assertions_on_it()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () => methodInfo.Should().BeDecoratedWith().Which.Filter.Should().BeFalse();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_but_it_is_not_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.PublicDoNothing to be decorated with \" +\n \"AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but that attribute was not found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_BeDecoratedWith_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () => methodInfo.Should().BeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_attribute_matching_a_predicate_and_it_is_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().BeDecoratedWith(d => d.Filter);\n }\n\n [Fact]\n public void When_asserting_a_method_is_decorated_with_an_attribute_matching_a_predicate_and_it_is_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"DoNotInlineMe\");\n\n // Act / Assert\n methodInfo.Should().BeDecoratedWith(x => x.Value == MethodImplOptions.NoInlining);\n }\n\n [Fact]\n public void\n When_asserting_a_method_is_decorated_with_an_attribute_matching_a_predicate_but_it_is_not_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should()\n .BeDecoratedWith(d => !d.Filter, \"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.PublicDoNothing to be decorated with \" +\n \"AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but that attribute was not found.\");\n }\n\n [Fact]\n public void\n When_asserting_a_method_is_decorated_with_an_attribute_matching_a_predicate_but_it_is_not_it_throws()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"DoNotInlineMe\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith(x => x.Value == MethodImplOptions.AggressiveInlining);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodWithImplementationAttribute.DoNotInlineMe to be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was not found.\");\n }\n\n [Fact]\n public void\n When_asserting_a_method_is_decorated_with_an_attribute_and_multiple_attributes_match_continuation_using_the_matched_value_should_fail()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\n \"PublicDoNothingWithSameAttributeTwice\");\n\n // Act\n Action act =\n () =>\n methodInfo.Should()\n .BeDecoratedWith()\n .Which.Filter.Should()\n .BeTrue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_is_null_be_decorated_withOfT_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().BeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method to be decorated with *.DummyMethodAttribute *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotBeDecoratedWithOfT\n {\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_attribute_and_it_is_not_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_an_attribute_and_it_is_not_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_constructor_is_not_decorated_with_an_attribute_and_it_is_not_it_succeeds()\n {\n // Arrange\n ConstructorInfo constructorMethodInfo =\n typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute).GetConstructor([typeof(string)]);\n\n // Act / Assert\n constructorMethodInfo.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_constructor_is_not_decorated_with_an_attribute_and_it_is_it_throws()\n {\n // Arrange\n ConstructorInfo constructorMethodInfo =\n typeof(ClassWithMethodWithImplementationAttribute).GetConstructor([typeof(string[])]);\n\n // Act\n Action act = () =>\n constructorMethodInfo.Should().NotBeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected constructor AwesomeAssertions.Specs.Types.ClassWithMethodWithImplementationAttribute(string[]) \" +\n \"to not be decorated with System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_an_attribute_but_it_is_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothing to not be decorated with \" +\n \"AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but that attribute was found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_an_attribute_and_it_is_it_throws()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithMethodWithImplementationAttribute).GetParameterlessMethod(\"DoNotInlineMe\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeDecoratedWith();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithMethodWithImplementationAttribute.DoNotInlineMe to not be decorated with \" +\n \"System.Runtime.CompilerServices.MethodImplAttribute, but that attribute was found.\");\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_decorated_with_attribute_matching_a_predicate_and_it_is_not_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeDecoratedWith(d => !d.Filter);\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotBeDecoratedWith_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () => methodInfo.Should().NotBeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void\n When_asserting_a_method_is_not_decorated_with_an_attribute_matching_a_predicate_but_it_is_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo =\n typeof(ClassWithAllMethodsDecoratedWithDummyAttribute).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should()\n .NotBeDecoratedWith(d => d.Filter, \"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method void AwesomeAssertions*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothing to not be decorated with \" +\n \"AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but that attribute was found.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_decorated_withOfT_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method to not be decorated with *.DummyMethodAttribute *failure message*\" +\n \", but methodInfo is .\");\n }\n }\n\n public class BeAsync\n {\n [Fact]\n public void When_asserting_a_method_is_async_and_it_is_then_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithAllMethodsAsync).GetParameterlessMethod(\"PublicAsyncDoNothing\");\n\n // Act / Assert\n methodInfo.Should().BeAsync();\n }\n\n [Fact]\n public void When_asserting_a_method_is_async_but_it_is_not_then_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithNonAsyncMethods).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().BeAsync(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method Task AwesomeAssertions*ClassWithNonAsyncMethods.PublicDoNothing\" +\n \" to be async because we want to test the error message,\" +\n \" but it is not.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_async_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().BeAsync(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method to be async *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotBeAsync\n {\n [Fact]\n public void When_asserting_a_method_is_not_async_and_it_is_not_then_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithNonAsyncMethods).GetParameterlessMethod(\"PublicDoNothing\");\n\n // Act / Assert\n methodInfo.Should().NotBeAsync();\n }\n\n [Fact]\n public void When_asserting_a_method_is_not_async_but_it_is_then_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(ClassWithAllMethodsAsync).GetParameterlessMethod(\"PublicAsyncDoNothing\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeAsync(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*ClassWithAllMethodsAsync.PublicAsyncDoNothing*\" +\n \"not to be async*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_async_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotBeAsync(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method not to be async *failure message*, but methodInfo is .\");\n }\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class ClassWithAllMethodsVirtual\n{\n public virtual void PublicVirtualDoNothing()\n {\n }\n\n internal virtual void InternalVirtualDoNothing()\n {\n }\n\n protected virtual void ProtectedVirtualDoNothing()\n {\n }\n}\n\ninternal interface IInterfaceWithPublicMethod\n{\n void PublicDoNothing();\n}\n\ninternal class ClassWithNonVirtualPublicMethods : IInterfaceWithPublicMethod\n{\n public void PublicDoNothing()\n {\n }\n\n internal void InternalDoNothing()\n {\n }\n\n protected void ProtectedDoNothing()\n {\n }\n}\n\ninternal class ClassWithAllMethodsDecoratedWithDummyAttribute\n{\n [DummyMethod(Filter = true)]\n public void PublicDoNothing()\n {\n }\n\n [DummyMethod(Filter = true)]\n [DummyMethod(Filter = false)]\n public void PublicDoNothingWithSameAttributeTwice()\n {\n }\n\n [DummyMethod]\n protected void ProtectedDoNothing()\n {\n }\n\n [DummyMethod]\n private void PrivateDoNothing()\n {\n }\n}\n\ninternal class ClassWithMethodsThatAreNotDecoratedWithDummyAttribute\n{\n public ClassWithMethodsThatAreNotDecoratedWithDummyAttribute(string _) { }\n\n public void PublicDoNothing()\n {\n }\n\n protected void ProtectedDoNothing()\n {\n }\n\n private void PrivateDoNothing()\n {\n }\n}\n\ninternal class ClassWithAllMethodsAsync\n{\n public async Task PublicAsyncDoNothing()\n {\n await Task.Yield();\n }\n\n internal async Task InternalAsyncDoNothing()\n {\n await Task.Yield();\n }\n\n protected async Task ProtectedAsyncDoNothing()\n {\n await Task.Yield();\n }\n}\n\ninternal class ClassWithNonAsyncMethods\n{\n public Task PublicDoNothing()\n {\n return Task.CompletedTask;\n }\n\n internal Task InternalDoNothing()\n {\n return Task.CompletedTask;\n }\n\n protected Task ProtectedDoNothing()\n {\n return Task.CompletedTask;\n }\n}\n\ninternal class ClassWithMethodWithImplementationAttribute\n{\n [MethodImpl(MethodImplOptions.NoOptimization)]\n public ClassWithMethodWithImplementationAttribute() { }\n\n [MethodImpl(MethodImplOptions.NoOptimization)]\n public ClassWithMethodWithImplementationAttribute(string[] _) { }\n\n [MethodImpl(MethodImplOptions.NoInlining)]\n public void DoNotInlineMe() { }\n\n [MethodImpl]\n public void NoOptions() { }\n\n [MethodImpl((MethodImplOptions)0)]\n public void ZeroOptions() { }\n}\n\ninternal class ClassWithPublicMethods\n{\n public void PublicDoNothing()\n {\n }\n\n public void DoNothingWithParameter(int _)\n {\n }\n}\n\ninternal class GenericClassWithNonPublicMethods\n{\n protected void PublicDoNothing()\n {\n }\n\n internal void DoNothingWithParameter(TSubject _)\n {\n }\n\n private void DoNothingWithAnotherParameter(string _)\n {\n }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeSelectorAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Types;\nusing DummyNamespace;\nusing DummyNamespace.InnerDummyNamespace;\nusing DummyNamespaceTwo;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class TypeSelectorAssertionSpecs\n{\n public class BeSealed\n {\n [Fact]\n public void When_all_types_are_sealed_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(Sealed)\n ]);\n\n // Act / Assert\n types.Should().BeSealed();\n }\n\n [Fact]\n public void When_any_type_is_not_sealed_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(Sealed),\n typeof(Abstract)\n ]);\n\n // Act\n Action act = () => types.Should().BeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be sealed *failure message*, but the following types are not:*.Abstract.\");\n }\n }\n\n public class NotBeSealed\n {\n [Fact]\n public void When_all_types_are_not_sealed_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(Abstract)\n ]);\n\n // Act / Assert\n types.Should().NotBeSealed();\n }\n\n [Fact]\n public void When_any_type_is_sealed_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(Abstract),\n typeof(Sealed)\n ]);\n\n // Act\n Action act = () => types.Should().NotBeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all types not to be sealed *failure message*, but the following types are:*.Sealed.\");\n }\n }\n\n public class BeDecoratedWith\n {\n [Fact]\n public void When_asserting_a_selection_of_decorated_types_is_decorated_with_an_attribute_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute)\n ]);\n\n // Act / Assert\n types.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_selection_of_non_decorated_types_is_decorated_with_an_attribute_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute),\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should().BeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be decorated with *.DummyClassAttribute *failure message*\" +\n \", but the attribute was not found on the following types:\" +\n \"**.ClassWithoutAttribute*.OtherClassWithoutAttribute.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_TypeSelector_BeDecoratedWith_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithAttribute));\n\n // Act\n Action act = () => types.Should()\n .BeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_a_selection_of_types_with_unexpected_attribute_property_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute),\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should()\n .BeDecoratedWith(\n a => a.Name == \"Expected\" && a.IsEnabled, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be decorated with *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\") * a.IsEnabled *failure message*, but no matching attribute was found on \" +\n \"the following types:*.ClassWithoutAttribute*.OtherClassWithoutAttribute.\");\n }\n }\n\n public class BeDecoratedWithOrInherit\n {\n [Fact]\n public void When_asserting_a_selection_of_decorated_types_inheriting_an_attribute_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithInheritedAttribute)\n ]);\n\n // Act / Assert\n types.Should().BeDecoratedWithOrInherit();\n }\n\n [Fact]\n public void When_asserting_a_selection_of_non_decorated_types_inheriting_an_attribute_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute),\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should().BeDecoratedWithOrInherit(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be decorated with or inherit *.DummyClassAttribute *failure message*\" +\n \", but the attribute was not found on the following types:\" +\n \"*.ClassWithoutAttribute*.OtherClassWithoutAttribute.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_TypeSelector_BeDecoratedWithOrInherit_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithAttribute));\n\n // Act\n Action act = () => types.Should()\n .BeDecoratedWithOrInherit(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void\n When_asserting_a_selection_of_types_with_some_inheriting_attributes_with_unexpected_attribute_property_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute),\n typeof(ClassWithInheritedAttribute),\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should()\n .BeDecoratedWithOrInherit(\n a => a.Name == \"Expected\" && a.IsEnabled, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be decorated with or inherit *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\")*a.IsEnabled *failure message*, but no matching attribute was found \" +\n \"on the following types:*.ClassWithoutAttribute*.OtherClassWithoutAttribute.\");\n }\n }\n\n public class NotBeDecoratedWith\n {\n [Fact]\n public void When_asserting_a_selection_of_non_decorated_types_is_not_decorated_with_an_attribute_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act / Assert\n types.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_a_selection_of_decorated_types_is_not_decorated_with_an_attribute_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(ClassWithAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should().NotBeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to not be decorated *.DummyClassAttribute *failure message*\" +\n \", but the attribute was found on the following types:*.ClassWithAttribute.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_TypeSelector_NotBeDecoratedWith_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithAttribute));\n\n // Act\n Action act = () => types.Should()\n .NotBeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_a_selection_of_types_with_unexpected_attribute_and_unexpected_attribute_property_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(ClassWithAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should()\n .NotBeDecoratedWith(\n a => a.Name == \"Expected\" && a.IsEnabled, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to not be decorated with *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\") * a.IsEnabled *failure message*, but a matching attribute was found \" +\n \"on the following types:*.ClassWithAttribute.\");\n }\n }\n\n public class NotBeDecoratedWithOrInherit\n {\n [Fact]\n public void When_asserting_a_selection_of_non_decorated_types_does_not_inherit_an_attribute_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(OtherClassWithoutAttribute)\n ]);\n\n // Act / Assert\n types.Should().NotBeDecoratedWithOrInherit();\n }\n\n [Fact]\n public void When_asserting_a_selection_of_decorated_types_does_not_inherit_an_attribute_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithoutAttribute),\n typeof(ClassWithInheritedAttribute)\n ]);\n\n // Act\n Action act = () =>\n types.Should().NotBeDecoratedWithOrInherit(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to not be decorated with or inherit *.DummyClassAttribute *failure message*\" +\n \", but the attribute was found on the following types:*.ClassWithInheritedAttribute.\");\n }\n\n [Fact]\n public void When_a_selection_of_types_do_inherit_unexpected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithInheritedAttribute));\n\n // Act\n Action act = () => types.Should()\n .NotBeDecoratedWithOrInherit(\n a => a.Name == \"Expected\" && a.IsEnabled, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to not be decorated with or inherit *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\") * a.IsEnabled *failure message*, but a matching attribute was found \" +\n \"on the following types:*.ClassWithInheritedAttribute.\");\n }\n\n [Fact]\n public void When_a_selection_of_types_do_not_inherit_unexpected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithoutAttribute));\n\n // Act / Assert\n types.Should()\n .NotBeDecoratedWithOrInherit(a => a.Name == \"Expected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_TypeSelector_NotBeDecoratedWithOrInherit_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassWithAttribute));\n\n // Act\n Action act = () => types.Should()\n .NotBeDecoratedWithOrInherit(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n }\n\n public class BeInNamespace\n {\n [Fact]\n public void When_a_type_is_in_the_expected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespace));\n\n // Act / Assert\n types.Should().BeInNamespace(nameof(DummyNamespace));\n }\n\n [Fact]\n public void When_a_type_is_not_in_the_expected_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act\n Action act = () =>\n types.Should().BeInNamespace(nameof(DummyNamespace), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be in namespace \\\"DummyNamespace\\\" *failure message*, but the following types \" +\n \"are in a different namespace:*.ClassNotInDummyNamespace*.OtherClassNotInDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_in_the_expected_global_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInGlobalNamespace));\n\n // Act / Assert\n types.Should().BeInNamespace(null);\n }\n\n [Fact]\n public void When_a_type_in_the_global_namespace_is_not_in_the_expected_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInGlobalNamespace));\n\n // Act\n Action act = () => types.Should().BeInNamespace(nameof(DummyNamespace));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be in namespace \\\"DummyNamespace\\\", but the following types \" +\n \"are in a different namespace:*ClassInGlobalNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_not_in_the_expected_global_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act\n Action act = () => types.Should().BeInNamespace(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all types to be in namespace , but the following types are in a different namespace:\" +\n \"*.ClassInDummyNamespace*.ClassNotInDummyNamespace*.OtherClassNotInDummyNamespace.\");\n }\n }\n\n public class NotBeInNamespace\n {\n [Fact]\n public void When_a_type_is_not_in_the_unexpected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespace));\n\n // Act / Assert\n types.Should().NotBeInNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n }\n\n [Fact]\n public void When_a_type_is_not_in_the_unexpected_parent_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act / Assert\n types.Should().NotBeInNamespace(nameof(DummyNamespace));\n }\n\n [Fact]\n public void When_a_type_is_in_the_unexpected_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act\n Action act = () =>\n types.Should().NotBeInNamespace(nameof(DummyNamespace), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected no types to be in namespace \\\"DummyNamespace\\\" *failure message*\" +\n \", but the following types are in the namespace:*DummyNamespace.ClassInDummyNamespace.\");\n }\n }\n\n public class BeUnderNamespace\n {\n [Fact]\n public void When_a_type_is_under_the_expected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespace));\n\n // Act / Assert\n types.Should().BeUnderNamespace(nameof(DummyNamespace));\n }\n\n [Fact]\n public void When_a_type_is_under_the_expected_nested_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act / Assert\n types.Should().BeUnderNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_expected_parent_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act / Assert\n types.Should().BeUnderNamespace(nameof(DummyNamespace));\n }\n\n [Fact]\n public void When_a_type_is_exactly_under_the_expected_global_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInGlobalNamespace));\n\n // Act / Assert\n types.Should().BeUnderNamespace(null);\n }\n\n [Fact]\n public void When_a_type_is_under_the_expected_global_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act / Assert\n types.Should().BeUnderNamespace(null);\n }\n\n [Fact]\n public void When_a_type_only_shares_a_prefix_with_the_expected_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespaceTwo));\n\n // Act\n Action act = () =>\n types.Should().BeUnderNamespace(nameof(DummyNamespace), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the namespaces of all types to start with \\\"DummyNamespace\\\" *failure message*\" +\n \", but the namespaces of the following types do not start with it:*.ClassInDummyNamespaceTwo.\");\n }\n\n [Fact]\n public void When_asserting_a_selection_of_types_not_under_a_namespace_is_under_that_namespace_it_fails()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassInInnerDummyNamespace)\n ]);\n\n // Act\n Action act = () =>\n types.Should().BeUnderNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to start with \\\"DummyNamespace.InnerDummyNamespace\\\"\" +\n \", but the namespaces of the following types do not start with it:*.ClassInDummyNamespace.\");\n }\n }\n\n public class NotBeUnderNamespace\n {\n [Fact]\n public void When_a_types_is_not_under_the_unexpected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act / Assert\n types.Should().NotBeUnderNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_namespace_it_shold_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespace));\n\n // Act\n Action act = () =>\n types.Should().NotBeUnderNamespace(nameof(DummyNamespace), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with \\\"DummyNamespace\\\" *failure message*\" +\n \", but the namespaces of the following types start with it:*.ClassInDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_nested_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act\n Action act = () =>\n types.Should().NotBeUnderNamespace($\"{nameof(DummyNamespace)}.{nameof(DummyNamespace.InnerDummyNamespace)}\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with \\\"DummyNamespace.InnerDummyNamespace\\\"\" +\n \", but the namespaces of the following types start with it:*.ClassInInnerDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_parent_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInInnerDummyNamespace));\n\n // Act\n Action act = () => types.Should().NotBeUnderNamespace(nameof(DummyNamespace));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with \\\"DummyNamespace\\\"\" +\n \", but the namespaces of the following types start with it:*.ClassInInnerDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_global_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInGlobalNamespace));\n\n // Act\n Action act = () => types.Should().NotBeUnderNamespace(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with \" +\n \", but the namespaces of the following types start with it:*ClassInGlobalNamespace.\");\n }\n\n [Fact]\n public void When_a_type_is_under_the_unexpected_parent_global_namespace_it_should_throw()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassInDummyNamespace),\n typeof(ClassNotInDummyNamespace),\n typeof(OtherClassNotInDummyNamespace)\n ]);\n\n // Act\n Action act = () => types.Should().NotBeUnderNamespace(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the namespaces of all types to not start with , but the namespaces of the following types \" +\n \"start with it:*.ClassInDummyNamespace*.ClassNotInDummyNamespace*.OtherClassNotInDummyNamespace.\");\n }\n\n [Fact]\n public void When_a_type_only_shares_a_prefix_with_the_unexpected_namespace_it_should_not_throw()\n {\n // Arrange\n var types = new TypeSelector(typeof(ClassInDummyNamespaceTwo));\n\n // Act / Assert\n types.Should().NotBeUnderNamespace(nameof(DummyNamespace));\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n var types = new TypeSelector(\n [\n typeof(ClassWithAttribute)\n ]);\n\n // Act\n var action = () => types.Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Equals is not part of Awesome Assertions. Did you mean BeInNamespace() or BeDecoratedWith() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveElementAt.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveElementAt specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveElementAt\n {\n [Fact]\n public void When_collection_has_expected_element_at_specific_index_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveElementAt(1, 2);\n }\n\n [Fact]\n public void Can_chain_another_assertion_on_the_selected_element()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n var act = () => collection.Should().HaveElementAt(index: 1, element: 2).Which.Should().Be(3);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection[1] to be 3, but found 2.\");\n }\n\n [Fact]\n public void When_collection_does_not_have_the_expected_element_at_specific_index_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveElementAt(1, 3, \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected 3 at index 1 because we put it there, but found 2.\");\n }\n\n [Fact]\n public void When_collection_does_not_have_an_element_at_the_specific_index_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveElementAt(4, 3, \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected 3 at index 4 because we put it there, but found no element.\");\n }\n\n [Fact]\n public void When_asserting_collection_has_element_at_specific_index_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveElementAt(1, 1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have element at index 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_element_at_specific_index_was_found_it_should_allow_chaining()\n {\n // Arrange\n var expectedElement = new\n {\n SomeProperty = \"hello\"\n };\n\n var collection = new[]\n {\n expectedElement\n };\n\n // Act\n Action act = () => collection.Should()\n .HaveElementAt(0, expectedElement)\n .Which\n .Should().BeAssignableTo();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*assignable*string*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/SimpleTimeSpanAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic class SimpleTimeSpanAssertionSpecs\n{\n [Fact]\n public void When_asserting_positive_value_to_be_positive_it_should_succeed()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds();\n\n // Act / Assert\n timeSpan.Should().BePositive();\n }\n\n [Fact]\n public void When_asserting_negative_value_to_be_positive_it_should_fail()\n {\n // Arrange\n TimeSpan negatedTimeSpan = 1.Seconds().Negate();\n\n // Act\n Action act = () => negatedTimeSpan.Should().BePositive();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_zero_value_to_be_positive_it_should_fail()\n {\n // Arrange\n TimeSpan negatedTimeSpan = 0.Seconds();\n\n // Act\n Action act = () => negatedTimeSpan.Should().BePositive();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_positive_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n\n // Act\n Action act = () => nullTimeSpan.Should().BePositive(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be positive because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_negative_value_to_be_positive_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds().Negate();\n\n // Act\n Action act = () => timeSpan.Should().BePositive(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected timeSpan to be positive because we want to test the failure message, but found -1s.\");\n }\n\n [Fact]\n public void When_asserting_negative_value_to_be_negative_it_should_succeed()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds().Negate();\n\n // Act / Assert\n timeSpan.Should().BeNegative();\n }\n\n [Fact]\n public void When_asserting_positive_value_to_be_negative_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n\n // Act\n Action act = () => actual.Should().BeNegative();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_zero_value_to_be_negative_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 0.Seconds();\n\n // Act\n Action act = () => actual.Should().BeNegative();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_negative_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n\n // Act\n Action act = () => nullTimeSpan.Should().BeNegative(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be negative because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_positive_value_to_be_negative_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds();\n\n // Act\n Action act = () => timeSpan.Should().BeNegative(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected timeSpan to be negative because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_equal_to_same_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n var expected = TimeSpan.FromSeconds(1);\n\n // Act / Assert\n actual.Should().Be(expected);\n }\n\n [Fact]\n public void When_asserting_value_to_be_equal_to_different_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan expected = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_null_is_not_equal_to_another_value()\n {\n // Arrange\n var subject = new SimpleTimeSpanAssertions(null, AssertionChain.GetOrCreate());\n TimeSpan expected = 2.Seconds();\n\n // Act\n Action act = () => subject.Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_equal_to_different_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => nullTimeSpan.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_equal_to_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan timeSpan = 1.Seconds();\n\n // Act\n Action act = () => timeSpan.Should().Be(2.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected 2s because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_not_equal_to_different_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan unexpected = 2.Seconds();\n\n // Act / Assert\n actual.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_not_equal_to_different_value_it_should_succeed()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act / Assert\n nullTimeSpan.Should().NotBe(expected);\n }\n\n [Fact]\n public void When_asserting_value_to_be_not_equal_to_the_same_value_it_should_fail()\n {\n // Arrange\n var oneSecond = 1.Seconds();\n\n // Act\n Action act = () => oneSecond.Should().NotBe(oneSecond);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_not_equal_to_the_same_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var oneSecond = 1.Seconds();\n\n // Act\n Action act = () => oneSecond.Should().NotBe(oneSecond, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect 1s because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_smaller_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n TimeSpan smaller = 1.Seconds();\n\n // Act / Assert\n actual.Should().BeGreaterThan(smaller);\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_greater_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan expected = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().BeGreaterThan(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_greater_than_other_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => nullTimeSpan.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be greater than 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_same_value_it_should_fail()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act\n Action act = () => twoSeconds.Should().BeGreaterThan(twoSeconds);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_greater_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n\n // Act\n Action act = () => actual.Should().BeGreaterThan(2.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be greater than 2s because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_or_equal_to_smaller_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n TimeSpan smaller = 1.Seconds();\n\n // Act / Assert\n actual.Should().BeGreaterThanOrEqualTo(smaller);\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_greater_than_or_equal_to_other_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () =>\n nullTimeSpan.Should().BeGreaterThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be greater than or equal to 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_or_equal_to_same_value_it_should_succeed()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act / Assert\n twoSeconds.Should().BeGreaterThanOrEqualTo(twoSeconds);\n }\n\n [Fact]\n public void Chaining_after_one_assertion_1()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act / Assert\n twoSeconds.Should().BeGreaterThanOrEqualTo(twoSeconds).And.Be(2.Seconds());\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_or_equal_to_greater_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan expected = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().BeGreaterThanOrEqualTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_greater_than_or_equal_to_greater_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n\n // Act\n Action act = () =>\n actual.Should().BeGreaterThanOrEqualTo(2.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be greater than or equal to 2s because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_greater_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan greater = 2.Seconds();\n\n // Act / Assert\n actual.Should().BeLessThan(greater);\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_smaller_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => actual.Should().BeLessThan(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_less_than_other_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => nullTimeSpan.Should().BeLessThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be less than 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_same_value_it_should_fail()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act\n Action act = () => twoSeconds.Should().BeLessThan(twoSeconds);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_smaller_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().BeLessThan(1.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be less than 1s because we want to test the failure message, but found 2s.\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_or_equal_to_greater_value_it_should_succeed()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan greater = 2.Seconds();\n\n // Act / Assert\n actual.Should().BeLessThanOrEqualTo(greater);\n }\n\n [Fact]\n public void Chaining_after_one_assertion_2()\n {\n // Arrange\n TimeSpan actual = 1.Seconds();\n TimeSpan greater = 2.Seconds();\n\n // Act / Assert\n actual.Should().BeLessThanOrEqualTo(greater).And.Be(1.Seconds());\n }\n\n [Fact]\n public void When_asserting_null_value_to_be_less_than_or_equal_to_other_value_it_should_fail()\n {\n // Arrange\n TimeSpan? nullTimeSpan = null;\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () =>\n nullTimeSpan.Should().BeLessThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullTimeSpan to be less than or equal to 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_or_equal_to_same_value_it_should_succeed()\n {\n // Arrange\n var twoSeconds = 2.Seconds();\n\n // Act / Assert\n twoSeconds.Should().BeLessThanOrEqualTo(twoSeconds);\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_or_equal_to_smaller_value_it_should_fail()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n TimeSpan expected = 1.Seconds();\n\n // Act\n Action act = () => actual.Should().BeLessThanOrEqualTo(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_value_to_be_less_than_or_equal_to_smaller_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n TimeSpan actual = 2.Seconds();\n\n // Act\n Action act = () => actual.Should().BeLessThanOrEqualTo(1.Seconds(), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be less than or equal to 1s because we want to test the failure message, but found 2s.\");\n }\n\n [Fact]\n public void When_accidentally_using_equals_it_should_throw_a_helpful_error()\n {\n // Arrange\n TimeSpan someTimeSpan = 2.Seconds();\n\n // Act\n Action act = () => someTimeSpan.Should().Equals(someTimeSpan);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n\n #region Be Close To\n\n [Fact]\n public void When_asserting_that_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 980);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_time_is_less_then_but_close_to_another_value_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 980);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_time_is_greater_then_but_close_to_another_value_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 020);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_time_is_less_then_and_not_close_to_another_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 979);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds(), \"we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from 1d, 12h, 15m and 31s because we want to test the error message, but found 1d, 12h, 15m, 30s and 979ms.\");\n }\n\n [Fact]\n public void When_time_is_greater_then_and_not_close_to_another_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 021);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds(), \"we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from 1d, 12h, 15m and 31s because we want to test the error message, but found 1d, 12h, 15m, 31s and 21ms.\");\n }\n\n [Fact]\n public void When_time_is_within_specified_number_of_milliseconds_from_another_value_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 035);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n }\n\n [Fact]\n public void When_a_null_time_is_asserted_to_be_close_to_another_it_should_throw()\n {\n // Arrange\n TimeSpan? time = null;\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n [Fact]\n public void When_time_away_from_another_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 979);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () =>\n time.Should().BeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20), \"we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from 1d, 12h, 15m and 31s because we want to test the error message, but found 1d, 12h, 15m, 30s and 979ms.\");\n }\n\n #endregion\n\n #region Not Be Close To\n\n [Fact]\n public void When_asserting_that_time_is_not_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 980);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_a_later_time_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 980);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected time to not be within 20ms from 1d, 12h, 15m and 31s, but found 1d, 12h, 15m, 30s and 980ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 020);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected time to not be within 20ms from 1d, 12h, 15m and 31s, but found 1d, 12h, 15m, 31s and 20ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_by_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 020);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected time to not be within 20ms from 1d, 12h, 15m and 31s, but found 1d, 12h, 15m, 31s and 20ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_another_value_that_is_later_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 30, 979);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 021);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_by_35ms_it_should_throw()\n {\n // Arrange\n var time = new TimeSpan(1, 12, 15, 31, 035);\n var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected time to not be within 35ms from 1d, 12h, 15m and 31s, but found 1d, 12h, 15m, 31s and 35ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_time_is_not_close_to_another_it_should_throw()\n {\n // Arrange\n TimeSpan? time = null;\n TimeSpan nearbyTime = TimeSpan.FromHours(1);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/CSharpAccessModifierExtensions.cs", "using System;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class CSharpAccessModifierExtensions\n{\n internal static CSharpAccessModifier GetCSharpAccessModifier(this MethodBase methodBase)\n {\n if (methodBase.IsPrivate)\n {\n return CSharpAccessModifier.Private;\n }\n\n if (methodBase.IsFamily)\n {\n return CSharpAccessModifier.Protected;\n }\n\n if (methodBase.IsAssembly)\n {\n return CSharpAccessModifier.Internal;\n }\n\n if (methodBase.IsPublic)\n {\n return CSharpAccessModifier.Public;\n }\n\n if (methodBase.IsFamilyOrAssembly)\n {\n return CSharpAccessModifier.ProtectedInternal;\n }\n\n if (methodBase.IsFamilyAndAssembly)\n {\n return CSharpAccessModifier.PrivateProtected;\n }\n\n return CSharpAccessModifier.InvalidForCSharp;\n }\n\n internal static CSharpAccessModifier GetCSharpAccessModifier(this FieldInfo fieldInfo)\n {\n if (fieldInfo.IsPrivate)\n {\n return CSharpAccessModifier.Private;\n }\n\n if (fieldInfo.IsFamily)\n {\n return CSharpAccessModifier.Protected;\n }\n\n if (fieldInfo.IsAssembly)\n {\n return CSharpAccessModifier.Internal;\n }\n\n if (fieldInfo.IsPublic)\n {\n return CSharpAccessModifier.Public;\n }\n\n if (fieldInfo.IsFamilyOrAssembly)\n {\n return CSharpAccessModifier.ProtectedInternal;\n }\n\n if (fieldInfo.IsFamilyAndAssembly)\n {\n return CSharpAccessModifier.PrivateProtected;\n }\n\n return CSharpAccessModifier.InvalidForCSharp;\n }\n\n internal static CSharpAccessModifier GetCSharpAccessModifier(this Type type)\n {\n if (type.IsNestedPrivate)\n {\n return CSharpAccessModifier.Private;\n }\n\n if (type.IsNestedFamily)\n {\n return CSharpAccessModifier.Protected;\n }\n\n if (type.IsNestedAssembly || type.IsNotPublic)\n {\n return CSharpAccessModifier.Internal;\n }\n\n if (type.IsPublic || type.IsNestedPublic)\n {\n return CSharpAccessModifier.Public;\n }\n\n if (type.IsNestedFamORAssem)\n {\n return CSharpAccessModifier.ProtectedInternal;\n }\n\n return CSharpAccessModifier.InvalidForCSharp;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericDifferenceAssertionsSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic class NumericDifferenceAssertionsSpecs\n{\n public class Be\n {\n [Theory]\n [InlineData(8, 5)]\n [InlineData(1, 9)]\n public void The_difference_between_small_ints_is_not_included_in_the_message(int value, int expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"Expected value to be {expected} because we want to test the failure message, but found {value}.\");\n }\n\n [Theory]\n [InlineData(50, 20, 30)]\n [InlineData(20, 50, -30)]\n [InlineData(123, -123, 246)]\n [InlineData(-123, 123, -246)]\n public void The_difference_between_ints_is_included_in_the_message(int value, int expected, int expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected} because we want to test the failure message, but found {value} (difference of {expectedDifference}).\");\n }\n\n [Theory]\n [InlineData(8, 5)]\n [InlineData(1, 9)]\n public void The_difference_between_small_nullable_ints_is_not_included_in_the_message(int? value, int expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"Expected value to be {expected} because we want to test the failure message, but found {value}.\");\n }\n\n [Fact]\n public void The_difference_between_int_and_null_is_not_included_in_the_message()\n {\n // Arrange\n int? value = null;\n const int expected = 12;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 12 because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void The_difference_between_null_and_int_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 12;\n int? nullableValue = null;\n\n // Act\n Action act = () =>\n value.Should().Be(nullableValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be because we want to test the failure message, but found 12.\");\n }\n\n [Theory]\n [InlineData(50, 20, 30)]\n [InlineData(20, 50, -30)]\n [InlineData(123, -123, 246)]\n [InlineData(-123, 123, -246)]\n public void The_difference_between_nullable_ints_is_included_in_the_message(int? value, int expected,\n int expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected} because we want to test the failure message, but found {value} (difference of {expectedDifference}).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_uints_is_included_in_the_message()\n {\n // Arrange\n uint? value = 29;\n const uint expected = 19;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 19u because we want to test the failure message, but found 29u (difference of 10).\");\n }\n\n [Theory]\n [InlineData(8, 5)]\n [InlineData(1, 9)]\n public void The_difference_between_small_longs_is_not_included_in_the_message(long value, long expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}L because we want to test the failure message, but found {value}L.\");\n }\n\n [Theory]\n [InlineData(50, 20, 30)]\n [InlineData(20, 50, -30)]\n public void The_difference_between_longs_is_included_in_the_message(long value, long expected, long expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}L because we want to test the failure message, but found {value}L (difference of {expectedDifference}).\");\n }\n\n [Theory]\n [InlineData(8L, 5)]\n [InlineData(1L, 9)]\n public void The_difference_between_small_nullable_longs_is_not_included_in_the_message(long? value, long expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}L because we want to test the failure message, but found {value}L.\");\n }\n\n [Theory]\n [InlineData(50L, 20, 30)]\n [InlineData(20L, 50, -30)]\n public void The_difference_between_nullable_longs_is_included_in_the_message(long? value, long expected,\n long expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}L because we want to test the failure message, but found {value}L (difference of {expectedDifference}).\");\n }\n\n [Theory]\n [InlineData(8, 5)]\n [InlineData(1, 9)]\n public void The_difference_between_small_shorts_is_not_included_in_the_message(short value, short expected)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}s because we want to test the failure message, but found {value}s.\");\n }\n\n [Theory]\n [InlineData(50, 20, 30)]\n [InlineData(20, 50, -30)]\n public void The_difference_between_shorts_is_included_in_the_message(short value, short expected,\n short expectedDifference)\n {\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n $\"Expected value to be {expected}s because we want to test the failure message, but found {value}s (difference of {expectedDifference}).\");\n }\n\n [Fact]\n public void The_difference_between_small_nullable_shorts_is_not_included_in_the_message()\n {\n // Arrange\n short? value = 2;\n const short expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 1s because we want to test the failure message, but found 2s.\");\n }\n\n [Fact]\n public void The_difference_between_nullable_shorts_is_included_in_the_message()\n {\n // Arrange\n short? value = 15;\n const short expected = 2;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 2s because we want to test the failure message, but found 15s (difference of 13).\");\n }\n\n [Fact]\n public void The_difference_between_small_ulongs_is_not_included_in_the_message()\n {\n // Arrange\n const ulong value = 9;\n const ulong expected = 4;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 4UL because we want to test the failure message, but found 9UL.\");\n }\n\n [Fact]\n public void The_difference_between_ulongs_is_included_in_the_message()\n {\n // Arrange\n const ulong value = 50;\n const ulong expected = 20;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 20UL because we want to test the failure message, but found 50UL (difference of 30).\");\n }\n\n [Fact]\n public void The_difference_between_small_nullable_ulongs_is_not_included_in_the_message()\n {\n // Arrange\n ulong? value = 7;\n const ulong expected = 4;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be 4UL because we want to test the failure message, but found 7UL.\");\n }\n\n [Fact]\n public void The_difference_between_nullable_ulongs_is_included_in_the_message()\n {\n // Arrange\n ulong? value = 50;\n const ulong expected = 20;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 20UL because we want to test the failure message, but found 50UL (difference of 30).\");\n }\n\n [Fact]\n public void The_difference_between_ushorts_is_included_in_the_message()\n {\n // Arrange\n ushort? value = 11;\n const ushort expected = 2;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 2us because we want to test the failure message, but found 11us (difference of 9).\");\n }\n\n [Fact]\n public void The_difference_between_doubles_is_included_in_the_message()\n {\n // Arrange\n const double value = 1.5;\n const double expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1.0 because we want to test the failure message, but found 1.5 (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_doubles_is_included_in_the_message()\n {\n // Arrange\n double? value = 1.5;\n const double expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1.0 because we want to test the failure message, but found 1.5 (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_floats_is_included_in_the_message()\n {\n // Arrange\n const float value = 1.5F;\n const float expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1F because we want to test the failure message, but found 1.5F (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_floats_is_included_in_the_message()\n {\n // Arrange\n float? value = 1.5F;\n const float expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1F because we want to test the failure message, but found 1.5F (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_decimals_is_included_in_the_message()\n {\n // Arrange\n const decimal value = 1.5m;\n const decimal expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1m because we want to test the failure message, but found 1.5m (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_decimals_is_included_in_the_message()\n {\n // Arrange\n decimal? value = 1.5m;\n const decimal expected = 1;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 1m because we want to test the failure message, but found 1.5m (difference of 0.5).\");\n }\n\n [Fact]\n public void The_difference_between_sbytes_is_included_in_the_message()\n {\n // Arrange\n const sbyte value = 1;\n const sbyte expected = 3;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 3y because we want to test the failure message, but found 1y (difference of -2).\");\n }\n\n [Fact]\n public void The_difference_between_nullable_sbytes_is_included_in_the_message()\n {\n // Arrange\n sbyte? value = 1;\n const sbyte expected = 3;\n\n // Act\n Action act = () =>\n value.Should().Be(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be 3y because we want to test the failure message, but found 1y (difference of -2).\");\n }\n }\n\n public class BeLessThan\n {\n [Fact]\n public void The_difference_between_equal_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 15;\n const int expected = 15;\n\n // Act\n Action act = () =>\n value.Should().BeLessThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be less than 15 because we want to test the failure message, but found 15.\");\n }\n\n [Fact]\n public void The_difference_between_small_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 4;\n const int expected = 2;\n\n // Act\n Action act = () =>\n value.Should().BeLessThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be less than 2 because we want to test the failure message, but found 4.\");\n }\n\n [Fact]\n public void The_difference_between_ints_is_included_in_the_message()\n {\n // Arrange\n const int value = 52;\n const int expected = 22;\n\n // Act\n Action act = () =>\n value.Should().BeLessThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be less than 22 because we want to test the failure message, but found 52 (difference of 30).\");\n }\n }\n\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void The_difference_between_small_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 4;\n const int expected = 2;\n\n // Act\n Action act = () =>\n value.Should().BeLessThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be less than or equal to 2 because we want to test the failure message, but found 4.\");\n }\n\n [Fact]\n public void The_difference_between_ints_is_included_in_the_message()\n {\n // Arrange\n const int value = 52;\n const int expected = 22;\n\n // Act\n Action act = () =>\n value.Should().BeLessThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be less than or equal to 22 because we want to test the failure message, but found 52 (difference of 30).\");\n }\n }\n\n public class BeGreaterThan\n {\n [Fact]\n public void The_difference_between_equal_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 15;\n const int expected = 15;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 15 because we want to test the failure message, but found 15.\");\n }\n\n [Fact]\n public void The_difference_between_small_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 2;\n const int expected = 4;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 4 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void The_difference_between_ints_is_included_in_the_message()\n {\n // Arrange\n const int value = 22;\n const int expected = 52;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than 52 because we want to test the failure message, but found 22 (difference of -30).\");\n }\n\n [Fact]\n public void The_difference_between_equal_nullable_uints_is_not_included_in_the_message()\n {\n // Arrange\n uint? value = 15;\n const uint expected = 15;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 15u because we want to test the failure message, but found 15u.\");\n }\n\n [Fact]\n public void The_difference_between_equal_doubles_is_not_included_in_the_message()\n {\n // Arrange\n const double value = 1.3;\n const double expected = 1.3;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 1.3 because we want to test the failure message, but found 1.3.\");\n }\n\n [Fact]\n public void The_difference_between_equal_floats_is_not_included_in_the_message()\n {\n // Arrange\n const float value = 2.3F;\n const float expected = 2.3F;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than 2.3F because we want to test the failure message, but found 2.3F.\");\n }\n\n [Fact]\n public void The_difference_between_equal_ushorts_is_not_included_in_the_message()\n {\n // Arrange\n ushort? value = 11;\n const ushort expected = 11;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than 11us because we want to test the failure message, but found 11us.\");\n }\n\n [Fact]\n public void The_difference_between_equal_sbytes_is_not_included_in_the_message()\n {\n // Arrange\n const sbyte value = 3;\n const sbyte expected = 3;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be greater than 3y because we want to test the failure message, but found 3y.\");\n }\n\n [Fact]\n public void The_difference_between_equal_nullable_ulongs_is_not_included_in_the_message()\n {\n // Arrange\n ulong? value = 15;\n const ulong expected = 15;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThan(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than 15UL because we want to test the failure message, but found 15UL.\");\n }\n }\n\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void The_difference_between_small_ints_is_not_included_in_the_message()\n {\n // Arrange\n const int value = 2;\n const int expected = 4;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than or equal to 4 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void The_difference_between_ints_is_included_in_the_message()\n {\n // Arrange\n const int value = 22;\n const int expected = 52;\n\n // Act\n Action act = () =>\n value.Should().BeGreaterThanOrEqualTo(expected, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than or equal to 52 because we want to test the failure message, but found 22 (difference of -30).\");\n }\n }\n\n public class Overflow\n {\n [Fact]\n public void The_difference_between_overflowed_ints_is_included_in_the_message()\n {\n // Act\n Action act = () =>\n int.MinValue.Should().Be(int.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected int.MinValue to be 2147483647*found -2147483648 (difference of -4294967295).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_ints_is_included_in_the_message()\n {\n // Arrange\n int? minValue = int.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(int.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected minValue to be 2147483647*found -2147483648 (difference of -4294967295).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_uints_is_included_in_the_message()\n {\n // Act\n Action act = () =>\n uint.MinValue.Should().Be(uint.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected uint.MinValue to be 4294967295u*found 0u (difference of -4294967295).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_uints_is_included_in_the_message()\n {\n // Arrange\n uint? minValue = uint.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(uint.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected minValue to be 4294967295u*found 0u (difference of -4294967295).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_longs_is_included_in_the_message()\n {\n // Act\n Action act = () =>\n long.MinValue.Should().Be(long.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected long.MinValue to be 9223372036854775807L*found -9223372036854775808L (difference of -18446744073709551615).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_longs_is_included_in_the_message()\n {\n // Arrange\n long? minValue = long.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(long.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected minValue to be 9223372036854775807L*found -9223372036854775808L (difference of -18446744073709551615).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_ulongs_is_included_in_the_message()\n {\n // Act\n Action act = () =>\n ulong.MinValue.Should().Be(ulong.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected ulong.MinValue to be 18446744073709551615UL*found 0UL (difference of -18446744073709551615).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_ulongs_is_included_in_the_message()\n {\n // Arrange\n ulong? minValue = ulong.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(ulong.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected minValue to be 18446744073709551615UL*found 0UL (difference of -18446744073709551615).\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_decimals_is_not_included_in_the_message()\n {\n // Act\n Action act = () =>\n decimal.MinValue.Should().Be(decimal.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected decimal.MinValue to be 79228162514264337593543950335M*found -79228162514264337593543950335M.\");\n }\n\n [Fact]\n public void The_difference_between_overflowed_nullable_decimals_is_not_included_in_the_message()\n {\n // Arrange\n decimal? minValue = decimal.MinValue;\n\n // Act\n Action act = () =>\n minValue.Should().Be(decimal.MaxValue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected minValue to be 79228162514264337593543950335M*found -79228162514264337593543950335M.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeEquivalentTo.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeEquivalentTo specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeEquivalentTo\n {\n [Fact]\n public void Succeed_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeEquivalentTo(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_comparing_strings_to_be_equivalent()\n {\n // Arrange\n string actual = \"test\";\n string expect = \"TEST\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_strings_to_be_equivalent()\n {\n // Arrange\n string actual = \" test\";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_strings_to_be_equivalent()\n {\n // Arrange\n string actual = \"test \";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_strings_to_be_equivalent()\n {\n // Arrange\n string actual = \"A\\nB\\r\\nC\";\n string expect = \"A\\r\\nB\\nC\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expect, o => o.IgnoringNewlineStyle());\n }\n\n [Fact]\n public void When_strings_are_the_same_while_ignoring_case_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedEquivalent = \"abc\";\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectedEquivalent);\n }\n\n [Fact]\n public void When_strings_differ_other_than_by_case_it_should_throw()\n {\n // Act\n Action act = () => \"ADC\".Should().BeEquivalentTo(\"abc\", \"we will test {0} + {1}\", 1, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent *because we will test 1 + 2, but*index 1*\\\"ADC\\\"*\\\"abc\\\"*.\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_non_null_string_is_expected_to_be_equivalent_to_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABCDEF\".Should().BeEquivalentTo(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent to , but found \\\"ABCDEF\\\".\");\n }\n\n [Fact]\n public void When_non_empty_string_is_expected_to_be_equivalent_to_empty_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().BeEquivalentTo(\"\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent * index 0*\\\"ABC\\\"*\\\"\\\"*.\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_is_equivalent_but_too_short_it_should_throw()\n {\n // Act\n Action act = () => \"AB\".Should().BeEquivalentTo(\"ABCD\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent *index 2*\\\"AB\\\"*\\\"ABCD\\\"*.\");\n }\n\n [Fact]\n public void When_string_equivalence_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().BeEquivalentTo(\"abc\", \"we will test {0} + {1}\", 1, 2);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someString to be equivalent to \\\"abc\\\" because we will test 1 + 2, but found .\");\n }\n\n [Fact]\n public void\n When_the_expected_string_is_equivalent_to_the_actual_string_but_with_trailing_spaces_it_should_throw_with_clear_error_message()\n {\n // Act\n Action act = () => \"ABC\".Should().BeEquivalentTo(\"abc \", \"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent to \\\"abc \\\" because I say so, but it misses some extra whitespace at the end.\");\n }\n\n [Fact]\n public void\n When_the_actual_string_equivalent_to_the_expected_but_with_trailing_spaces_it_should_throw_with_clear_error_message()\n {\n // Act\n Action act = () => \"ABC \".Should().BeEquivalentTo(\"abc\", \"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be equivalent to \\\"abc\\\" because I say so, but it has unexpected whitespace at the end.\");\n }\n }\n\n public class NotBeEquivalentTo\n {\n [Fact]\n public void Succeed_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act / Assert\n actual.Should().NotBeEquivalentTo(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_comparing_strings_to_not_be_equivalent()\n {\n // Arrange\n string actual = \"test\";\n string expect = \"TEST\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_strings_to_not_be_equivalent()\n {\n // Arrange\n string actual = \" test\";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_strings_to_not_be_equivalent()\n {\n // Arrange\n string actual = \"test \";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_strings_to_not_be_equivalent()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n\";\n string expect = \"\\nA\\r\\nB\\nC\\r\";\n\n // Act\n Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_strings_are_the_same_while_ignoring_case_it_should_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string unexpected = \"abc\";\n\n // Act\n Action action = () => actual.Should().NotBeEquivalentTo(unexpected, \"because I say {0}\", \"so\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected actual not to be equivalent to \\\"abc\\\" because I say so, but they are.\");\n }\n\n [Fact]\n public void When_strings_differ_other_than_by_case_it_should_not_throw()\n {\n // Act / Assert\n \"ADC\".Should().NotBeEquivalentTo(\"abc\");\n }\n\n [Fact]\n public void When_non_null_string_is_expected_to_be_equivalent_to_null_it_should_not_throw()\n {\n // Act / Assert\n \"ABCDEF\".Should().NotBeEquivalentTo(null);\n }\n\n [Fact]\n public void When_non_empty_string_is_expected_to_be_equivalent_to_empty_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().NotBeEquivalentTo(\"\");\n }\n\n [Fact]\n public void When_string_is_equivalent_but_too_short_it_should_not_throw()\n {\n // Act / Assert\n \"AB\".Should().NotBeEquivalentTo(\"ABCD\");\n }\n\n [Fact]\n public void When_string_equivalence_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string someString = null;\n\n // Act / Assert\n someString.Should().NotBeEquivalentTo(\"abc\");\n }\n\n [Fact]\n public void When_the_expected_string_is_equivalent_to_the_actual_string_but_with_trailing_spaces_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().NotBeEquivalentTo(\"abc \");\n }\n\n [Fact]\n public void When_the_actual_string_equivalent_to_the_expected_but_with_trailing_spaces_it_should_not_throw()\n {\n // Act / Assert\n \"ABC \".Should().NotBeEquivalentTo(\"abc\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/EnumAssertionsExtensions.cs", "using System;\nusing System.Diagnostics;\nusing System.Diagnostics.Contracts;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Primitives;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Contains an extension method for custom assertions in unit tests related to Enum objects.\n/// \n[DebuggerNonUserCode]\npublic static class EnumAssertionsExtensions\n{\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static EnumAssertions Should(this TEnum @enum)\n where TEnum : struct, Enum\n {\n return new EnumAssertions(@enum, AssertionChain.GetOrCreate());\n }\n\n /// \n /// Returns an object that can be used to assert the\n /// current .\n /// \n [Pure]\n public static NullableEnumAssertions Should(this TEnum? @enum)\n where TEnum : struct, Enum\n {\n return new NullableEnumAssertions(@enum, AssertionChain.GetOrCreate());\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.SatisfyRespectively.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The SatisfyRespectively specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class SatisfyRespectively\n {\n [Fact]\n public void When_collection_asserting_against_null_inspectors_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify against a collection of inspectors*\");\n }\n\n [Fact]\n public void When_collection_asserting_against_empty_inspectors_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify against an empty collection of inspectors*\");\n }\n\n [Fact]\n public void When_collection_which_is_asserting_against_inspectors_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n collection.Should().SatisfyRespectively(\n new Action[] { x => x.Should().Be(1) }, \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to satisfy all inspectors because we want to test the failure message, but collection is .\");\n }\n\n [Fact]\n public void When_collection_which_is_asserting_against_inspectors_is_empty_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(new Action[] { x => x.Should().Be(1) },\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to satisfy all inspectors because we want to test the failure message, but collection is empty.\");\n }\n\n [Fact]\n public void When_asserting_collection_satisfies_all_inspectors_it_should_succeed()\n {\n // Arrange\n Customer[] collection = [new Customer { Age = 21, Name = \"John\" }, new Customer { Age = 22, Name = \"Jane\" }];\n\n // Act / Assert\n collection.Should().SatisfyRespectively(\n value =>\n {\n value.Age.Should().Be(21);\n value.Name.Should().Be(\"John\");\n },\n value =>\n {\n value.Age.Should().Be(22);\n value.Name.Should().Be(\"Jane\");\n });\n }\n\n [Fact]\n public void When_asserting_collection_does_not_satisfy_any_inspector_it_should_throw()\n {\n // Arrange\n CustomerWithItems[] customers =\n [\n new CustomerWithItems { Age = 21, Items = [1, 2] },\n new CustomerWithItems { Age = 22, Items = [3] }\n ];\n\n // Act\n Action act = () => customers.Should().SatisfyRespectively(\n new Action[]\n {\n customer =>\n {\n customer.Age.Should().BeLessThan(21);\n\n customer.Items.Should().SatisfyRespectively(\n item => item.Should().Be(2),\n item => item.Should().Be(1));\n },\n customer =>\n {\n customer.Age.Should().BeLessThan(22);\n customer.Items.Should().SatisfyRespectively(item => item.Should().Be(2));\n }\n }, \"because we want to test {0}\", \"nested assertions\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected customers to satisfy all inspectors because we want to test nested assertions, but some inspectors are not satisfied:\n *At index 0:\n *Expected customer.Age to be less than 21, but found 21\n *Expected customer.Items to satisfy all inspectors, but some inspectors are not satisfied:\n *At index 0:\n *Expected item to be 2, but found 1\n *At index 1:\n *Expected item to be 1, but found 2\n *At index 1:\n *Expected customer.Age to be less than 22, but found 22\n *Expected customer.Items to satisfy all inspectors, but some inspectors are not satisfied:\n *At index 0:\n *Expected item to be 2, but found 3\n \"\"\");\n }\n\n [Fact]\n public void When_inspector_message_is_not_reformatable_it_should_not_throw()\n {\n // Arrange\n byte[][] subject = [[1]];\n\n // Act\n Action act = () => subject.Should().SatisfyRespectively(e => e.Should().BeEquivalentTo(new byte[] { 2, 3, 4 }));\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_inspectors_count_does_not_equal_asserting_collection_length_it_should_throw_with_a_useful_message()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(\n new Action[] { value => value.Should().Be(1), value => value.Should().Be(2) },\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain exactly 2 items*we want to test the failure message*, but it contains 3 items\");\n }\n\n [Fact]\n public void When_inspectors_count_does_not_equal_asserting_collection_length_it_should_fail_with_a_useful_message()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(\n new Action[] { value => value.Should().Be(1), }, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*because we want to test the failure*\");\n }\n }\n\n private class Customer\n {\n private string PrivateProperty { get; }\n\n protected string ProtectedProperty { get; set; }\n\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public DateTime Birthdate { get; set; }\n\n public long Id { get; set; }\n\n public void SetProtected(string value)\n {\n ProtectedProperty = value;\n }\n\n public Customer()\n {\n }\n\n public Customer(string privateProperty)\n {\n PrivateProperty = privateProperty;\n }\n }\n\n private class CustomerWithItems : Customer\n {\n public int[] Items { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCount.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]HaveCount specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCount\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCount(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_that_is_different_from_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCount(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_collection_has_a_count_that_is_different_from_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () => collection.Should().HaveCount(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain 4 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_has_a_count_larger_than_the_minimum_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCount(c => c >= 3);\n }\n\n [Fact]\n public void Even_with_an_assertion_scope_only_the_first_failure_in_a_chained_call_is_reported()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCount(c => c > 3).And.HaveCount(c => c < 3);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\"*count (c > 3), but count is 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_has_a_count_that_not_matches_the_predicate_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCount(c => c >= 4, \"a minimum of 4 is required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have a count (c >= 4) because a minimum of 4 is required, but count is 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_null_predicate_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCount(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare collection count against a predicate.*\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCount(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain 1 item(s) because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_predicate_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCount(c => c < 3, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain (c < 3) items because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_predicate_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCount(c => (c % 2) == 1);\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_predicate_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCount(c => (c % 2) == 0);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_counting_generic_enumerable_it_should_enumerate()\n {\n // Arrange\n var enumerable = new CountingGenericEnumerable([1, 2, 3]);\n\n // Act\n enumerable.Should().HaveCount(3);\n\n // Assert\n enumerable.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_counting_generic_collection_it_should_not_enumerate()\n {\n // Arrange\n var collection = new CountingGenericCollection([1, 2, 3]);\n\n // Act\n collection.Should().HaveCount(3);\n\n // Assert\n collection.GetCountCallCount.Should().Be(1);\n collection.GetEnumeratorCallCount.Should().Be(0);\n }\n }\n\n public class NotHaveCount\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_different_from_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotHaveCount(2);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotHaveCount(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_has_a_count_that_equals_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () => collection.Should().NotHaveCount(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*not contain*3*because we want to test the failure message*3*\");\n }\n\n [Fact]\n public void When_collection_count_is_same_than_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotHaveCount(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*not contain*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.AllSatisfy.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The AllSatisfy specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class AllSatisfy\n {\n [Fact]\n public void A_null_inspector_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().AllSatisfy(null);\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Cannot verify against a inspector*\");\n }\n\n [Fact]\n public void A_null_collection_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllSatisfy(x => x.Should().Be(1), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\n \"Expected collection to contain only items satisfying the inspector because we want to test the failure message, but collection is .\");\n }\n\n [Fact]\n public void An_empty_collection_should_succeed()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act / Assert\n collection.Should().AllSatisfy(x => x.Should().Be(1));\n }\n\n [Fact]\n public void All_items_satisfying_inspector_should_succeed()\n {\n // Arrange\n Customer[] collection = [new Customer { Age = 21, Name = \"John\" }, new Customer { Age = 21, Name = \"Jane\" }];\n\n // Act / Assert\n collection.Should().AllSatisfy(x => x.Age.Should().Be(21));\n }\n\n [Fact]\n public void Any_items_not_satisfying_inspector_should_throw()\n {\n // Arrange\n CustomerWithItems[] customers =\n [\n new CustomerWithItems { Age = 21, Items = [1, 2] },\n new CustomerWithItems { Age = 22, Items = [3] }\n ];\n\n // Act\n Action act = () => customers.Should()\n .AllSatisfy(\n customer =>\n {\n customer.Age.Should().BeLessThan(21);\n\n customer.Items.Should()\n .AllSatisfy(item => item.Should().Be(3));\n },\n \"because we want to test {0}\",\n \"nested assertions\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"\"\"\n Expected customers to contain only items satisfying the inspector because we want to test nested assertions:\n *At index 0:\n *Expected customer.Age to be less than 21, but found 21\n *Expected customer.Items to contain only items satisfying the inspector:\n *At index 0:\n *Expected item to be 3, but found 1\n *At index 1:\n *Expected item to be 3, but found 2\n *At index 1:\n *Expected customer.Age to be less than 21, but found 22 (difference of 1)\n \"\"\");\n }\n\n [Fact]\n public void Inspector_message_that_is_not_reformatable_should_not_throw()\n {\n // Arrange\n byte[][] subject = [[1]];\n\n // Act\n Action act = () => subject.Should().AllSatisfy(e => e.Should().BeEquivalentTo(new byte[] { 2, 3, 4 }));\n\n // Assert\n act.Should().NotThrow();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedFactAttributeDiscoverer.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedFactAttributeDiscoverer : IXunitTestCaseDiscoverer\n{\n private readonly IMessageSink diagnosticMessageSink;\n\n public CulturedFactAttributeDiscoverer(IMessageSink diagnosticMessageSink)\n {\n this.diagnosticMessageSink = diagnosticMessageSink;\n }\n\n public IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod,\n IAttributeInfo factAttribute)\n {\n var ctorArgs = factAttribute.GetConstructorArguments().ToArray();\n var cultures = Reflector.ConvertArguments(ctorArgs, [typeof(string[])]).Cast().Single();\n\n if (cultures is null || cultures.Length == 0)\n {\n cultures = [\"en-US\", \"fr-FR\"];\n }\n\n TestMethodDisplay methodDisplay = discoveryOptions.MethodDisplayOrDefault();\n TestMethodDisplayOptions methodDisplayOptions = discoveryOptions.MethodDisplayOptionsOrDefault();\n\n return cultures.Select(culture =>\n new CulturedXunitTestCase(diagnosticMessageSink, methodDisplay, methodDisplayOptions, testMethod, culture)).ToList();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/AwaitParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class AwaitParsingStrategy : IParsingStrategy\n{\n private const string KeywordToSkip = \"await \";\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (IsLongEnoughToContainOurKeyword(statement) && EndsWithOurKeyword(statement))\n {\n statement.Remove(statement.Length - KeywordToSkip.Length, KeywordToSkip.Length);\n }\n\n return ParsingState.InProgress;\n }\n\n private static bool EndsWithOurKeyword(StringBuilder statement)\n {\n var leftIndex = statement.Length - 1;\n var rightIndex = KeywordToSkip.Length - 1;\n\n for (var offset = 0; offset < KeywordToSkip.Length; offset++)\n {\n if (statement[leftIndex - offset] != KeywordToSkip[rightIndex - offset])\n {\n return false;\n }\n }\n\n return true;\n }\n\n private static bool IsLongEnoughToContainOurKeyword(StringBuilder statement) => statement.Length >= KeywordToSkip.Length;\n\n public bool IsWaitingForContextEnd()\n {\n return false;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/Clock.cs", "using System;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Default implementation for for production use.\n/// \ninternal class Clock : IClock\n{\n public void Delay(TimeSpan timeToDelay) => Task.Delay(timeToDelay).GetAwaiter().GetResult();\n\n public Task DelayAsync(TimeSpan delay, CancellationToken cancellationToken)\n {\n return Task.Delay(delay, cancellationToken);\n }\n\n public ITimer StartTimer() => new StopwatchTimer();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeApproximately.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeApproximately\n {\n [Fact]\n public void When_approximating_a_nullable_double_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_approximating_two_nullable_doubles_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 3.14;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_nullable_double_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act / Assert\n value.Should().BeApproximately(3.14, 0.1);\n }\n\n [Fact]\n public void When_nullable_double_is_indeed_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 3.142;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void When_nullable_double_is_null_approximating_a_nullable_null_value_it_should_not_throw()\n {\n // Arrange\n double? value = null;\n double? expected = null;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void When_nullable_double_with_value_is_not_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n double? value = 13;\n double? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*12.0*0.1*13.0*\");\n }\n\n [Fact]\n public void When_nullable_double_is_null_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n double? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 12.0 +/- 0.1, but it was .\");\n }\n\n [Fact]\n public void When_nullable_double_is_not_null_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n double? value = 12;\n double? expected = null;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate +/- 0.1, but it was 12.0.\");\n }\n\n [Fact]\n public void When_nullable_double_has_no_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n value.Should().BeApproximately(3.14, 0.001);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 3.14 +/- 0.001, but it was .\");\n }\n\n [Fact]\n public void When_nullable_double_is_not_approximating_a_value_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(1.0, 0.1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to approximate 1.0 +/- 0.1, but 3.14* differed by*\");\n }\n\n [Fact]\n public void A_double_cannot_approximate_NaN()\n {\n // Arrange\n double? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.NaN, 0.1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_approximating_a_nullable_float_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_approximating_two_nullable_floats_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = 3.14F;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_nullable_float_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act / Assert\n value.Should().BeApproximately(3.14F, 0.1F);\n }\n\n [Fact]\n public void When_nullable_float_is_indeed_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n float? value = 3.1415927f;\n float? expected = 3.142f;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1f);\n }\n\n [Fact]\n public void When_nullable_float_is_null_approximating_a_nullable_null_value_it_should_not_throw()\n {\n // Arrange\n float? value = null;\n float? expected = null;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1f);\n }\n\n [Fact]\n public void When_nullable_float_with_value_is_not_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n float? value = 13;\n float? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1f);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*12*0.1*13*\");\n }\n\n [Fact]\n public void When_nullable_float_is_null_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n float? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1f);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 12F +/- 0.1F, but it was .\");\n }\n\n [Fact]\n public void When_nullable_float_is_not_null_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n float? value = 12;\n float? expected = null;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1f);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate +/- 0.1F, but it was 12F.\");\n }\n\n [Fact]\n public void When_nullable_float_has_no_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n value.Should().BeApproximately(3.14F, 0.001F);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 3.14F +/- 0.001F, but it was .\");\n }\n\n [Fact]\n public void When_nullable_float_is_not_approximating_a_value_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(1.0F, 0.1F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to approximate *1* +/- *0.1* but 3.14* differed by*\");\n }\n\n [Fact]\n public void A_float_cannot_approximate_NaN()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.NaN, 0.1F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_approximating_a_nullable_decimal_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14m, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_approximating_two_nullable_decimals_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 3.14m;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_nullable_decimal_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act / Assert\n value.Should().BeApproximately(3.14m, 0.1m);\n }\n\n [Fact]\n public void When_nullable_decimal_is_indeed_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 3.142m;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void When_nullable_decimal_is_null_approximating_a_nullable_null_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = null;\n decimal? expected = null;\n\n // Act / Assert\n value.Should().BeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void When_nullable_decimal_with_value_is_not_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n decimal? value = 13;\n decimal? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*12*0.1*13*\");\n }\n\n [Fact]\n public void When_nullable_decimal_is_null_approximating_a_non_null_nullable_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n decimal? expected = 12;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate 12M +/- 0.1M, but it was .\");\n }\n\n [Fact]\n public void When_nullable_decimal_is_not_null_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n decimal? value = 12;\n decimal? expected = null;\n\n // Act\n Action act = () => value.Should().BeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate +/- 0.1M, but it was 12M.\");\n }\n\n [Fact]\n public void When_nullable_decimal_has_no_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n value.Should().BeApproximately(3.14m, 0.001m);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to approximate*3.14* +/-*0.001*, but it was .\");\n }\n\n [Fact]\n public void When_nullable_decimal_is_not_approximating_a_value_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().BeApproximately(1.0m, 0.1m);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to approximate*1.0* +/-*0.1*, but 3.14* differed by*\");\n }\n }\n\n public class NotBeApproximately\n {\n [Fact]\n public void When_not_approximating_a_nullable_double_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_not_approximating_two_nullable_doubles_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 3.14;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_is_not_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act / Assert\n value.Should().NotBeApproximately(1.0, 0.1);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_has_no_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14, 0.001);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_is_indeed_approximating_a_value_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, 0.1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to not approximate 3.14 +/- 0.1, but 3.14*only differed by*\");\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_nullable_double_is_not_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 1.0;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_is_not_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_null_double_is_not_approximating_a_nullable_double_value_it_should_throw()\n {\n // Arrange\n double? value = null;\n double? expected = 20.0;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_null_double_is_not_approximating_a_null_value_it_should_not_throw()\n {\n // Arrange\n double? value = null;\n double? expected = null;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*null*0.1*but*null*\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_double_is_approximating_a_nullable_value_it_should_throw()\n {\n // Arrange\n double? value = 3.1415927;\n double? expected = 3.1;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_double_cannot_approximate_NaN()\n {\n // Arrange\n double? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.NaN, 0.1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_not_approximating_a_nullable_float_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_not_approximating_two_nullable_floats_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = 3.14F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_is_not_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act / Assert\n value.Should().NotBeApproximately(1.0F, 0.1F);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_has_no_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14F, 0.001F);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_is_indeed_approximating_a_value_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, 0.1F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to not approximate *3.14F* +/- *0.1F* but 3.14* only differed by*\");\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_nullable_float_is_not_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = 1.0F;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1F);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_is_not_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1F);\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_null_float_is_not_approximating_a_nullable_float_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n float? expected = 20.0f;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1F);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_null_float_is_not_approximating_a_null_value_it_should_not_throw()\n {\n // Arrange\n float? value = null;\n float? expected = null;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1F);\n\n // Assert\n act.Should().Throw(\"Expected**+/-*0.1F**\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_float_is_approximating_a_nullable_value_it_should_throw()\n {\n // Arrange\n float? value = 3.1415927F;\n float? expected = 3.1F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_float_cannot_approximate_NaN()\n {\n // Arrange\n float? value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.NaN, 0.1F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_not_approximating_a_nullable_decimal_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14m, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_not_approximating_two_nullable_decimals_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 3.14m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_is_not_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act / Assert\n value.Should().NotBeApproximately(1.0m, 0.1m);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_has_no_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14m, 0.001m);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_is_indeed_approximating_a_value_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14m, 0.1m);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to not approximate*3.14* +/-*0.1*, but*3.14*only differed by*\");\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_nullable_decimal_is_not_approximating_a_nullable_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 1.0m;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_is_not_approximating_a_null_value_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void\n When_asserting_not_approximately_and_null_decimal_is_not_approximating_a_nullable_decimal_value_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n decimal? expected = 20.0m;\n\n // Act / Assert\n value.Should().NotBeApproximately(expected, 0.1m);\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_null_decimal_is_not_approximating_a_null_value_it_should_not_throw()\n {\n // Arrange\n decimal? value = null;\n decimal? expected = null;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected**0.1M**\");\n }\n\n [Fact]\n public void When_asserting_not_approximately_and_nullable_decimal_is_approximating_a_nullable_value_it_should_throw()\n {\n // Arrange\n decimal? value = 3.1415927m;\n decimal? expected = 3.1m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(expected, 0.1m);\n\n // Assert\n act.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/BeEquivalentToWithDeeplyNestedStructures.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions;\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Jobs;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\n[SimpleJob(RuntimeMoniker.Net472)]\n[SimpleJob(RuntimeMoniker.Net80)]\npublic class BeEquivalentToWithDeeplyNestedStructures\n{\n public class ComplexType\n {\n public int A { get; set; }\n\n public ComplexType B { get; set; }\n }\n\n [Params(1, 10, 100, 500)]\n public int N { get; set; }\n\n [Params(1, 2, 6)]\n public int Depth { get; set; }\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n subject = Enumerable.Range(0, N).Select(_ => CreateComplex(Depth)).ToList();\n expectation = Enumerable.Range(0, N).Select(_ => CreateComplex(Depth)).ToList();\n }\n\n private static ComplexType CreateComplex(int i)\n {\n if (i == 0)\n {\n return new ComplexType();\n }\n\n return new ComplexType\n {\n A = i,\n B = CreateComplex(i - 1)\n };\n }\n\n private List subject;\n private List expectation;\n\n [Benchmark]\n public void BeEquivalentTo()\n {\n subject.Should().BeEquivalentTo(expectation);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/IgnoringFailuresAssertionStrategy.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\ninternal class IgnoringFailuresAssertionStrategy : IAssertionStrategy\n{\n public IEnumerable FailureMessages => new string[0];\n\n public void HandleFailure(string message)\n {\n }\n\n public IEnumerable DiscardFailures() => new string[0];\n\n public void ThrowIfAny(IDictionary context)\n {\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/XmlAssertionExtensions.cs", "using System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Xml;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Xml;\n\nnamespace AwesomeAssertions;\n\n[DebuggerNonUserCode]\npublic static class XmlAssertionExtensions\n{\n public static XmlNodeAssertions Should([NotNull] this XmlNode actualValue)\n {\n return new XmlNodeAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n\n public static XmlElementAssertions Should([NotNull] this XmlElement actualValue)\n {\n return new XmlElementAssertions(actualValue, AssertionChain.GetOrCreate());\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/Program.cs", "using System.Globalization;\nusing BenchmarkDotNet.Configs;\nusing BenchmarkDotNet.Exporters.Csv;\nusing BenchmarkDotNet.Reports;\nusing BenchmarkDotNet.Running;\nusing Perfolizer.Horology;\nusing Perfolizer.Metrology;\n\nnamespace Benchmarks;\n\ninternal static class Program\n{\n public static void Main()\n {\n var exporter = new CsvExporter(\n CsvSeparator.CurrentCulture,\n new SummaryStyle(\n cultureInfo: CultureInfo.GetCultureInfo(\"nl-NL\"),\n printUnitsInHeader: true,\n sizeUnit: SizeUnit.KB,\n timeUnit: TimeUnit.Microsecond,\n printUnitsInContent: false\n ));\n\n var config = ManualConfig.CreateMinimumViable().AddExporter(exporter);\n\n _ = BenchmarkRunner.Run(config);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeSubsetOf.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeSubsetOf specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeSubsetOf\n {\n [Fact]\n public void When_collection_is_subset_of_a_specified_collection_it_should_not_throw()\n {\n // Arrange\n int[] subset = [1, 2];\n int[] superset = [1, 2, 3];\n\n // Act / Assert\n subset.Should().BeSubsetOf(superset);\n }\n\n [Fact]\n public void When_collection_is_not_a_subset_of_another_it_should_throw_with_the_reason()\n {\n // Arrange\n int[] subset = [1, 2, 3, 6];\n int[] superset = [1, 2, 4, 5];\n\n // Act\n Action act = () => subset.Should().BeSubsetOf(superset, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subset to be a subset of {1, 2, 4, 5} because we want to test the failure message, \" +\n \"but items {3, 6} are not part of the superset.\");\n }\n\n [Fact]\n public void When_an_empty_collection_is_tested_against_a_superset_it_should_succeed()\n {\n // Arrange\n int[] subset = [];\n int[] superset = [1, 2, 4, 5];\n\n // Act / Assert\n subset.Should().BeSubsetOf(superset);\n }\n\n [Fact]\n public void When_a_subset_is_tested_against_a_null_superset_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n int[] subset = [1, 2, 3];\n int[] superset = null;\n\n // Act\n Action act = () => subset.Should().BeSubsetOf(superset);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify a subset against a collection.*\");\n }\n\n [Fact]\n public void When_a_set_is_expected_to_be_not_a_subset_it_should_succeed()\n {\n // Arrange\n int[] subject = [1, 2, 4];\n int[] otherSet = [1, 2, 3];\n\n // Act / Assert\n subject.Should().NotBeSubsetOf(otherSet);\n }\n }\n\n public class NotBeSubsetOf\n {\n [Fact]\n public void When_an_empty_set_is_not_supposed_to_be_a_subset_of_another_set_it_should_throw()\n {\n // Arrange\n int[] subject = [];\n int[] otherSet = [1, 2, 3];\n\n // Act\n Action act = () => subject.Should().NotBeSubsetOf(otherSet);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect subject {empty} to be a subset of {1, 2, 3}.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_is_not_subset_of_a_superset_collection()\n {\n // Arrange\n int[] subject = [1, 2];\n int[] otherSet = [1, 2, 3];\n\n // Act\n Action act = () => subject.Should().NotBeSubsetOf(otherSet, \"because I'm {0}\", \"mistaken\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect subject {1, 2} to be a subset of {1, 2, 3} because I'm mistaken.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_subset_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().BeSubsetOf(collection1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be a subset of {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_subset_against_same_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n var collection1 = collection;\n\n // Act\n Action act = () => collection.Should().NotBeSubsetOf(collection1,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect*to be a subset of*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_subset_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotBeSubsetOf([1, 2, 3], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot assert a collection against a subset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeOneOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act\n Action act = () => value.Should().BeOneOf(new ClassWithCustomEqualMethod(4), new ClassWithCustomEqualMethod(5));\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be one of {ClassWithCustomEqualMethod(4), ClassWithCustomEqualMethod(5)}, but found ClassWithCustomEqualMethod(3).\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act\n Action act = () =>\n value.Should().BeOneOf([new ClassWithCustomEqualMethod(4), new ClassWithCustomEqualMethod(5)],\n \"because those are the valid values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be one of {ClassWithCustomEqualMethod(4), ClassWithCustomEqualMethod(5)} because those are the valid values, but found ClassWithCustomEqualMethod(3).\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(4);\n\n // Act / Assert\n value.Should().BeOneOf(new ClassWithCustomEqualMethod(4), new ClassWithCustomEqualMethod(5));\n }\n\n [Fact]\n public void An_untyped_value_is_one_of_the_specified_values()\n {\n // Arrange\n object value = new SomeClass(5);\n\n // Act / Assert\n value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)], new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void A_typed_value_is_one_of_the_specified_values()\n {\n // Arrange\n var value = new SomeClass(5);\n\n // Act / Assert\n value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)], new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void An_untyped_value_is_not_one_of_the_specified_values()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)],\n new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to be one of {SomeClass(4), SomeClass(5)}*I said so*SomeClass(3).\");\n }\n\n [Fact]\n public void An_untyped_value_is_not_one_of_no_values()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([], new SomeClassEqualityComparer());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_typed_value_is_not_one_of_the_specified_values()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)],\n new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to be one of {SomeClass(4), SomeClass(5)}*I said so*SomeClass(3).\");\n }\n\n [Fact]\n public void A_typed_value_is_not_one_of_no_values()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([], new SomeClassEqualityComparer());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_typed_value_is_not_the_same_type_as_the_specified_values()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([new SomeClass(4), new SomeClass(5)],\n new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to be one of {SomeClass(4), SomeClass(5)}*I said so*ClassWithCustomEqualMethod(3).\");\n }\n\n [Fact]\n public void An_untyped_value_requires_an_expectation()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf(null, new SomeClassEqualityComparer());\n\n // Assert\n act.Should().Throw().WithParameterName(\"validValues\");\n }\n\n [Fact]\n public void A_typed_value_requires_an_expectation()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf(null, new SomeClassEqualityComparer());\n\n // Assert\n act.Should().Throw().WithParameterName(\"validValues\");\n }\n\n [Fact]\n public void An_untyped_value_requires_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([], comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void A_typed_value_requires_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().BeOneOf([], comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act / Assert\n value.Should().BeOneOf(value).And.NotBeNull();\n }\n\n [Fact]\n public void Can_chain_multiple_assertions()\n {\n // Arrange\n var value = new object();\n\n // Act / Assert\n value.Should().BeOneOf([value], new DumbObjectEqualityComparer()).And.NotBeNull();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeStatic.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeStatic specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeStatic\n {\n [Fact]\n public void When_type_is_static_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(Static).Should().BeStatic();\n }\n\n [Theory]\n [InlineData(typeof(ClassWithoutMembers), \"Expected type *.ClassWithoutMembers to be static.\")]\n [InlineData(typeof(Sealed), \"Expected type *.Sealed to be static.\")]\n [InlineData(typeof(Abstract), \"Expected type *.Abstract to be static.\")]\n public void When_type_is_not_static_it_fails(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeStatic();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_type_is_not_static_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act\n Action act = () => type.Should().BeStatic(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.ClassWithoutMembers to be static *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_BeStatic_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeStatic();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_be_static_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().BeStatic(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be static *failure message*, but type is .\");\n }\n }\n\n public class NotBeStatic\n {\n [Theory]\n [InlineData(typeof(ClassWithoutMembers))]\n [InlineData(typeof(Sealed))]\n [InlineData(typeof(Abstract))]\n public void When_type_is_not_static_it_succeeds(Type type)\n {\n // Arrange / Act / Assert\n type.Should().NotBeStatic();\n }\n\n [Fact]\n public void When_type_is_static_it_fails()\n {\n // Arrange\n var type = typeof(Static);\n\n // Act\n Action act = () => type.Should().NotBeStatic();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Static not to be static.\");\n }\n\n [Fact]\n public void When_type_is_static_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(Static);\n\n // Act\n Action act = () => type.Should().NotBeStatic(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Static not to be static *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_NotBeStatic_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().NotBeStatic();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_not_be_static_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotBeStatic(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be static *failure message*, but type is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeAbstract.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeAbstract specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeAbstract\n {\n [Fact]\n public void When_type_is_abstract_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(Abstract).Should().BeAbstract();\n }\n\n [Theory]\n [InlineData(typeof(ClassWithoutMembers), \"Expected type *.ClassWithoutMembers to be abstract.\")]\n [InlineData(typeof(Sealed), \"Expected type *.Sealed to be abstract.\")]\n [InlineData(typeof(Static), \"Expected type *.Static to be abstract.\")]\n public void When_type_is_not_abstract_it_fails(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeAbstract();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_type_is_not_abstract_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act\n Action act = () => type.Should().BeAbstract(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.ClassWithoutMembers to be abstract *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_BeAbstract_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeAbstract();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_be_abstract_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().BeAbstract(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be abstract *failure message*, but type is .\");\n }\n }\n\n public class NotBeAbstract\n {\n [Theory]\n [InlineData(typeof(ClassWithoutMembers))]\n [InlineData(typeof(Sealed))]\n [InlineData(typeof(Static))]\n public void When_type_is_not_abstract_it_succeeds(Type type)\n {\n // Arrange / Act / Assert\n type.Should().NotBeAbstract();\n }\n\n [Fact]\n public void When_type_is_abstract_it_fails()\n {\n // Arrange\n var type = typeof(Abstract);\n\n // Act\n Action act = () => type.Should().NotBeAbstract();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Abstract not to be abstract.\");\n }\n\n [Fact]\n public void When_type_is_abstract_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(Abstract);\n\n // Act\n Action act = () => type.Should().NotBeAbstract(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Abstract not to be abstract *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_NotBeAbstract_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().NotBeAbstract();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_not_be_abstract_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotBeAbstract(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be abstract *failure message*, but type is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeSealed.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeSealed specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeSealed\n {\n [Fact]\n public void When_type_is_sealed_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(Sealed).Should().BeSealed();\n }\n\n [Theory]\n [InlineData(typeof(ClassWithoutMembers), \"Expected type *.ClassWithoutMembers to be sealed.\")]\n [InlineData(typeof(Abstract), \"Expected type *.Abstract to be sealed.\")]\n [InlineData(typeof(Static), \"Expected type *.Static to be sealed.\")]\n public void When_type_is_not_sealed_it_fails(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeSealed();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_type_is_not_sealed_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act\n Action act = () => type.Should().BeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.ClassWithoutMembers to be sealed *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_BeSealed_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().BeSealed();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_be_sealed_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().BeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be sealed *failure message*, but type is .\");\n }\n }\n\n public class NotBeSealed\n {\n [Theory]\n [InlineData(typeof(ClassWithoutMembers))]\n [InlineData(typeof(Abstract))]\n [InlineData(typeof(Static))]\n public void When_type_is_not_sealed_it_succeeds(Type type)\n {\n // Arrange / Act / Assert\n type.Should().NotBeSealed();\n }\n\n [Fact]\n public void When_type_is_sealed_it_fails()\n {\n // Arrange\n var type = typeof(Sealed);\n\n // Act\n Action act = () => type.Should().NotBeSealed();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Sealed not to be sealed.\");\n }\n\n [Fact]\n public void When_type_is_sealed_it_fails_with_a_meaningful_message()\n {\n // Arrange\n var type = typeof(Sealed);\n\n // Act\n Action act = () => type.Should().NotBeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type *.Sealed not to be sealed *failure message*.\");\n }\n\n [Theory]\n [InlineData(typeof(IDummyInterface), \"*.IDummyInterface must be a class.\")]\n [InlineData(typeof(Struct), \"*.Struct must be a class.\")]\n [InlineData(typeof(ExampleDelegate), \"*.ExampleDelegate must be a class.\")]\n public void When_type_is_not_valid_for_NotBeSealed_it_throws_exception(Type type, string exceptionMessage)\n {\n // Act\n Action act = () => type.Should().NotBeSealed();\n\n // Assert\n act.Should().Throw()\n .WithMessage(exceptionMessage);\n }\n\n [Fact]\n public void When_subject_is_null_not_be_sealed_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotBeSealed(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be sealed *failure message*, but type is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeIn.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeIn\n {\n [Fact]\n public void When_asserting_subject_datetime_represents_its_own_kind_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00, DateTimeKind.Local);\n\n // Act / Assert\n subject.Should().BeIn(DateTimeKind.Local);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_represents_a_different_kind_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00, DateTimeKind.Local);\n\n // Act\n Action act = () => subject.Should().BeIn(DateTimeKind.Utc);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be in Utc, but found Local.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_represents_a_specific_kind_it_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n\n // Act\n Action act = () => subject.Should().BeIn(DateTimeKind.Utc);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be in Utc, but found a DateTime.\");\n }\n }\n\n public class NotBeIn\n {\n [Fact]\n public void Date_is_not_in_kind()\n {\n // Arrange\n DateTime subject = 5.January(2024).AsLocal();\n\n // Act / Assert\n subject.Should().NotBeIn(DateTimeKind.Utc);\n }\n\n [Fact]\n public void Date_is_in_kind_but_should_not()\n {\n // Arrange\n DateTime subject = 5.January(2024).AsLocal();\n\n // Act\n Action act = () => subject.Should().NotBeIn(DateTimeKind.Local);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect subject to be in Local, but it was.\");\n }\n\n [Fact]\n public void Date_is_null_on_kind_check()\n {\n // Arrange\n DateTime? subject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().NotBeIn(DateTimeKind.Utc);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not**\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeApproximately.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeApproximately\n {\n [Fact]\n public void When_approximating_a_float_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_float_is_not_approximating_a_range_it_should_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, 0.001F, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to approximate *3.14* +/- *0.001* because rockets will crash otherwise, but *3.1415927* differed by *0.001592*\");\n }\n\n [Fact]\n public void When_float_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act / Assert\n value.Should().BeApproximately(3.14F, 0.1F);\n }\n\n [InlineData(9F)]\n [InlineData(11F)]\n [Theory]\n public void When_float_is_approximating_a_value_on_boundaries_it_should_not_throw(float value)\n {\n // Act / Assert\n value.Should().BeApproximately(10F, 1F);\n }\n\n [InlineData(9F)]\n [InlineData(11F)]\n [Theory]\n public void When_float_is_not_approximating_a_value_on_boundaries_it_should_throw(float value)\n {\n // Act\n Action act = () => value.Should().BeApproximately(10F, 0.9F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_approximating_a_float_towards_nan_it_should_not_throw()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_approximating_positive_infinity_float_towards_positive_infinity_it_should_not_throw()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act / Assert\n value.Should().BeApproximately(float.PositiveInfinity, 0.1F);\n }\n\n [Fact]\n public void When_approximating_negative_infinity_float_towards_negative_infinity_it_should_not_throw()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act / Assert\n value.Should().BeApproximately(float.NegativeInfinity, 0.1F);\n }\n\n [Fact]\n public void When_float_is_not_approximating_positive_infinity_it_should_throw()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.MaxValue, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_float_is_not_approximating_negative_infinity_it_should_throw()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void NaN_can_never_be_close_to_any_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_can_never_be_close_to_NaN()\n {\n // Arrange\n float value = float.MinValue;\n\n // Act\n Action act = () => value.Should().BeApproximately(float.NaN, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_a_nullable_float_has_no_value_it_should_throw()\n {\n // Arrange\n float? value = null;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, 0.001F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to approximate*3.14* +/-*0.001*, but it was .\");\n }\n\n [Fact]\n public void When_approximating_a_double_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_double_is_not_approximating_a_range_it_should_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14, 0.001, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to approximate 3.14 +/- 0.001 because rockets will crash otherwise, but 3.1415927 differed by 0.001592*\");\n }\n\n [Fact]\n public void When_double_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act / Assert\n value.Should().BeApproximately(3.14, 0.1);\n }\n\n [Fact]\n public void When_approximating_a_double_towards_nan_it_should_not_throw()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14F, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_approximating_positive_infinity_double_towards_positive_infinity_it_should_not_throw()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act / Assert\n value.Should().BeApproximately(double.PositiveInfinity, 0.1);\n }\n\n [Fact]\n public void When_approximating_negative_infinity_double_towards_negative_infinity_it_should_not_throw()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act / Assert\n value.Should().BeApproximately(double.NegativeInfinity, 0.1);\n }\n\n [Fact]\n public void When_double_is_not_approximating_positive_infinity_it_should_throw()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.MaxValue, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_double_is_not_approximating_negative_infinity_it_should_throw()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.MinValue, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [InlineData(9D)]\n [InlineData(11D)]\n [Theory]\n public void When_double_is_approximating_a_value_on_boundaries_it_should_not_throw(double value)\n {\n // Act / Assert\n value.Should().BeApproximately(10D, 1D);\n }\n\n [InlineData(9D)]\n [InlineData(11D)]\n [Theory]\n public void When_double_is_not_approximating_a_value_on_boundaries_it_should_throw(double value)\n {\n // Act\n Action act = () => value.Should().BeApproximately(10D, 0.9D);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void NaN_can_never_be_close_to_any_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_double_can_never_be_close_to_NaN()\n {\n // Arrange\n double value = double.MinValue;\n\n // Act\n Action act = () => value.Should().BeApproximately(double.NaN, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_approximating_a_decimal_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal value = 3.1415927M;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.14m, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_range_it_should_throw()\n {\n // Arrange\n decimal value = 3.5011m;\n\n // Act\n Action act = () => value.Should().BeApproximately(3.5m, 0.001m, \"rockets will crash otherwise\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected value to approximate*3.5* +/-*0.001* because rockets will crash otherwise, but *3.5011* differed by*0.0011*\");\n }\n\n [Fact]\n public void When_decimal_is_indeed_approximating_a_value_it_should_not_throw()\n {\n // Arrange\n decimal value = 3.5011m;\n\n // Act / Assert\n value.Should().BeApproximately(3.5m, 0.01m);\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_value_on_lower_boundary_it_should_not_throw()\n {\n // Act\n decimal value = 9m;\n\n // Act / Assert\n value.Should().BeApproximately(10m, 1m);\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_value_on_upper_boundary_it_should_not_throw()\n {\n // Act\n decimal value = 11m;\n\n // Act / Assert\n value.Should().BeApproximately(10m, 1m);\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_on_lower_boundary_it_should_throw()\n {\n // Act\n decimal value = 9m;\n\n // Act\n Action act = () => value.Should().BeApproximately(10m, 0.9m);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_on_upper_boundary_it_should_throw()\n {\n // Act\n decimal value = 11m;\n\n // Act\n Action act = () => value.Should().BeApproximately(10m, 0.9m);\n\n // Assert\n act.Should().Throw();\n }\n }\n\n public class NotBeApproximately\n {\n [Fact]\n public void When_not_approximating_a_float_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, -0.1F);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_float_is_approximating_a_range_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, 0.1F, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to not approximate *3.14* +/- *0.1* because rockets will crash otherwise, but *3.1415927* only differed by *0.001592*\");\n }\n\n [Fact]\n public void When_float_is_not_approximating_a_value_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n float value = 3.1415927F;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14F, 0.001F);\n }\n\n [Fact]\n public void When_approximating_a_float_towards_nan_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14F, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_not_approximating_a_float_towards_positive_infinity_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act / Assert\n value.Should().NotBeApproximately(float.MaxValue, 0.1F);\n }\n\n [Fact]\n public void When_not_approximating_a_float_towards_negative_infinity_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act / Assert\n value.Should().NotBeApproximately(float.MinValue, 0.1F);\n }\n\n [Fact]\n public void\n When_approximating_positive_infinity_float_towards_positive_infinity_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n float value = float.PositiveInfinity;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.PositiveInfinity, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_not_approximating_negative_infinity_float_towards_negative_infinity_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n float value = float.NegativeInfinity;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.NegativeInfinity, 0.1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [InlineData(9F)]\n [InlineData(11F)]\n [Theory]\n public void When_float_is_not_approximating_a_value_on_boundaries_it_should_not_throw(float value)\n {\n // Act / Assert\n value.Should().NotBeApproximately(10F, 0.9F);\n }\n\n [InlineData(9F)]\n [InlineData(11F)]\n [Theory]\n public void When_float_is_approximating_a_value_on_boundaries_it_should_throw(float value)\n {\n // Act\n Action act = () => value.Should().NotBeApproximately(10F, 1F);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_nullable_float_has_no_value_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n float? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14F, 0.001F);\n }\n\n [Fact]\n public void NaN_can_never_be_close_to_any_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_can_never_be_close_to_NaN()\n {\n // Arrange\n float value = float.MinValue;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(float.NaN, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_not_approximating_a_double_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, -0.1);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_double_is_approximating_a_range_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, 0.1, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to not approximate *3.14* +/- *0.1* because rockets will crash otherwise, but *3.1415927* only differed by *0.001592*\");\n }\n\n [Fact]\n public void When_double_is_not_approximating_a_value_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n double value = 3.1415927;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14, 0.001);\n }\n\n [Fact]\n public void When_approximating_a_double_towards_nan_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_not_approximating_a_double_towards_positive_infinity_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act / Assert\n value.Should().NotBeApproximately(double.MaxValue, 0.1);\n }\n\n [Fact]\n public void When_not_approximating_a_double_towards_negative_infinity_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act / Assert\n value.Should().NotBeApproximately(double.MinValue, 0.1);\n }\n\n [Fact]\n public void\n When_approximating_positive_infinity_double_towards_positive_infinity_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double value = double.PositiveInfinity;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.PositiveInfinity, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_not_approximating_negative_infinity_double_towards_negative_infinity_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double value = double.NegativeInfinity;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.NegativeInfinity, 0.1);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_nullable_double_has_no_value_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n double? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.14, 0.001);\n }\n\n [InlineData(9D)]\n [InlineData(11D)]\n [Theory]\n public void When_double_is_not_approximating_a_value_on_boundaries_it_should_not_throw(double value)\n {\n // Act / Assert\n value.Should().NotBeApproximately(10D, 0.9D);\n }\n\n [InlineData(9D)]\n [InlineData(11D)]\n [Theory]\n public void When_double_is_approximating_a_value_on_boundaries_it_should_throw(double value)\n {\n // Act\n Action act = () => value.Should().NotBeApproximately(10D, 1D);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void NaN_can_never_be_close_to_any_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.MinValue, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_close_to_NaN()\n {\n // Arrange\n double value = double.MinValue;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(double.NaN, 0.1F);\n\n // Assert\n act.Should().Throw().WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void When_not_approximating_a_decimal_with_a_negative_precision_it_should_throw()\n {\n // Arrange\n decimal value = 3.1415927m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.14m, -0.1m);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_range_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n decimal value = 3.5011m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(3.5m, 0.1m, \"rockets will crash otherwise\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to not approximate *3.5* +/- *0.1* because rockets will crash otherwise, but *3.5011* only differed by *0.0011*\");\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_and_should_not_approximate_it_should_not_throw()\n {\n // Arrange\n decimal value = 3.5011m;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.5m, 0.001m);\n }\n\n [Fact]\n public void When_a_nullable_decimal_has_no_value_and_should_not_approximate_it_should_throw()\n {\n // Arrange\n decimal? value = null;\n\n // Act / Assert\n value.Should().NotBeApproximately(3.5m, 0.001m);\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_on_lower_boundary_it_should_not_throw()\n {\n // Act\n decimal value = 9m;\n\n // Act / Assert\n value.Should().NotBeApproximately(10m, 0.9m);\n }\n\n [Fact]\n public void When_decimal_is_not_approximating_a_value_on_upper_boundary_it_should_not_throw()\n {\n // Act\n decimal value = 11m;\n\n // Act / Assert\n value.Should().NotBeApproximately(10m, 0.9m);\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_value_on_lower_boundary_it_should_throw()\n {\n // Act\n decimal value = 9m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(10m, 1m);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_decimal_is_approximating_a_value_on_upper_boundary_it_should_throw()\n {\n // Act\n decimal value = 11m;\n\n // Act\n Action act = () => value.Should().NotBeApproximately(10m, 1m);\n\n // Assert\n act.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/ExceptionAssertionsExtensions.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq.Expressions;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Specialized;\n\nnamespace AwesomeAssertions;\n\npublic static class ExceptionAssertionsExtensions\n{\n#pragma warning disable AV1755 // \"Name of async method ... should end with Async\"; Async suffix is too noisy in fluent API\n\n /// \n /// Asserts that the thrown exception has a message that matches .\n /// \n /// The containing the thrown exception.\n /// \n /// The wildcard pattern with which the exception message is matched, where * and ? have special meanings.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithMessage(\n this Task> task,\n string expectedWildcardPattern,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n return (await task).WithMessage(expectedWildcardPattern, because, becauseArgs);\n }\n\n /// \n /// Asserts that the exception matches a particular condition.\n /// \n /// The containing the thrown exception.\n /// \n /// The condition that the exception must match.\n /// \n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> Where(\n this Task> task,\n Expression> exceptionExpression,\n [StringSyntax(\"CompositeFormat\")] string because = \"\", params object[] becauseArgs)\n where TException : Exception\n {\n return (await task).Where(exceptionExpression, because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of type .\n /// \n /// The expected type of the exception.\n /// The expected type of the inner exception.\n /// The containing the thrown exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithInnerException(\n this Task> task,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n where TInnerException : Exception\n {\n return (await task).WithInnerException(because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of type .\n /// \n /// The expected type of the exception.\n /// The containing the thrown exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithInnerException(\n this Task> task,\n Type innerException,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n return (await task).WithInnerException(innerException, because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of the exact type (and not a derived exception type).\n /// \n /// The expected type of the exception.\n /// The expected type of the inner exception.\n /// The containing the thrown exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithInnerExceptionExactly(\n this Task> task,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n where TInnerException : Exception\n {\n return (await task).WithInnerExceptionExactly(because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception contains an inner exception of the exact type (and not a derived exception type).\n /// \n /// The expected type of the exception.\n /// The containing the thrown exception.\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithInnerExceptionExactly(\n this Task> task,\n Type innerException,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : Exception\n {\n return (await task).WithInnerExceptionExactly(innerException, because, becauseArgs);\n }\n\n /// \n /// Asserts that the thrown exception has a parameter which name matches .\n /// \n /// The containing the thrown exception.\n /// The expected name of the parameter\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static ExceptionAssertions WithParameterName(\n this ExceptionAssertions parent,\n string paramName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : ArgumentException\n {\n AssertionChain\n .GetOrCreate()\n .ForCondition(parent.Which.ParamName == paramName)\n .BecauseOf(because, becauseArgs)\n .FailWith(\"Expected exception with parameter name {0}{reason}, but found {1}.\", paramName, parent.Which.ParamName);\n\n return parent;\n }\n\n /// \n /// Asserts that the thrown exception has a parameter which name matches .\n /// \n /// The containing the thrown exception.\n /// The expected name of the parameter\n /// \n /// A formatted phrase as is supported by explaining why the assertion\n /// is needed. If the phrase does not start with the word because, it is prepended automatically.\n /// \n /// \n /// Zero or more objects to format using the placeholders in .\n /// \n public static async Task> WithParameterName(\n this Task> task,\n string paramName,\n [StringSyntax(\"CompositeFormat\")] string because = \"\",\n params object[] becauseArgs)\n where TException : ArgumentException\n {\n return (await task).WithParameterName(paramName, because, becauseArgs);\n }\n\n#pragma warning restore AV1755\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/DictionaryHelpers.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class DictionaryHelpers\n{\n public static IEnumerable GetKeys(this TCollection collection)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary.Keys,\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary.Keys,\n _ => collection.Select(kvp => kvp.Key).ToList(),\n };\n }\n\n public static IEnumerable GetValues(this TCollection collection)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary.Values,\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary.Values,\n _ => collection.Select(kvp => kvp.Value).ToList(),\n };\n }\n\n public static bool ContainsKey(this TCollection collection, TKey key)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary.ContainsKey(key),\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary.ContainsKey(key),\n _ => ContainsKey(collection, key),\n };\n\n static bool ContainsKey(TCollection collection, TKey key)\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n return collection.Any(kvp => areSameOrEqual(kvp.Key, key));\n }\n }\n\n public static bool TryGetValue(this TCollection collection, TKey key, out TValue value)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary.TryGetValue(key, out value),\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary.TryGetValue(key, out value),\n _ => TryGetValue(collection, key, out value),\n };\n\n static bool TryGetValue(TCollection collection, TKey key, out TValue value)\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n\n foreach (var kvp in collection)\n {\n if (areSameOrEqual(kvp.Key, key))\n {\n value = kvp.Value;\n return true;\n }\n }\n\n value = default;\n return false;\n }\n }\n\n public static TValue GetValue(this TCollection collection, TKey key)\n where TCollection : IEnumerable>\n {\n return collection switch\n {\n IDictionary dictionary => dictionary[key],\n IReadOnlyDictionary readOnlyDictionary => readOnlyDictionary[key],\n _ => GetValue(collection, key),\n };\n\n static TValue GetValue(TCollection collection, TKey key)\n {\n Func areSameOrEqual = ObjectExtensions.GetComparer();\n return collection.First(kvp => areSameOrEqual(kvp.Key, key)).Value;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.ContainKey.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class ContainKey\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_a_key_from_the_dictionary()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().ContainKey(1);\n }\n\n [Fact]\n public void When_a_dictionary_has_custom_equality_comparer_the_contains_key_assertion_should_work_accordingly()\n {\n // Arrange\n var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase)\n {\n [\"One\"] = \"One\",\n [\"Two\"] = \"Two\"\n };\n\n // Act\n\n // Assert\n dictionary.Should().ContainKey(\"One\");\n dictionary.Should().ContainKey(\"ONE\");\n dictionary.Should().ContainKey(\"one\");\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_single_key_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainKey(3, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain key 3 because we do.\");\n }\n\n [Fact]\n public void When_the_requested_key_exists_it_should_allow_continuation_with_the_value()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [\"Key\"] = new() { SomeProperty = 3 }\n };\n\n // Act\n Action act = () => dictionary.Should().ContainKey(\"Key\").WhoseValue.Should().Be(4);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*4*3*.\");\n }\n\n [Fact]\n public void When_an_assertion_fails_on_ContainKey_succeeding_message_should_be_included()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var values = new Dictionary();\n values.Should().ContainKey(0);\n values.Should().ContainKey(1);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to contain key 0*Expected*to contain key 1*\");\n }\n }\n\n public class NotContainKey\n {\n [Fact]\n public void When_dictionary_does_not_contain_a_key_that_is_not_in_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKey(4);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_dictionary_contains_an_unexpected_key_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKey(1, \"because we {0} like it\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} not to contain key 1 because we don't like it, but found it anyhow.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_does_not_contain_key_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContainKey(1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain key 1 because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.EndWithEquivalentOf.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]EndWithEquivalentOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class EndWithEquivalentOf\n {\n [Fact]\n public void Succeed_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act\n Action act = () => actual.Should().EndWithEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_end_with_another()\n {\n // Arrange\n string actual = \"prefix for test\";\n string expect = \"TEST\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_end_with_another()\n {\n // Arrange\n string actual = \" prefix for test\";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_end_with_another()\n {\n // Arrange\n string actual = \"prefix for test \";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_end_with_another()\n {\n // Arrange\n string actual = \"prefix for \\rA\\nB\\r\\nC\";\n string expect = \"A\\r\\nB\\nC\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n }\n\n [Fact]\n public void When_suffix_of_string_differs_by_case_only_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedSuffix = \"bC\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expectedSuffix);\n }\n\n [Fact]\n public void When_end_of_string_differs_by_case_only_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedSuffix = \"AbC\";\n\n // Act / Assert\n actual.Should().EndWithEquivalentOf(expectedSuffix);\n }\n\n [Fact]\n public void When_end_of_string_does_not_meet_equivalent_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWithEquivalentOf(\"ab\", \"because it should end\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to end with equivalent of \\\"ab\\\" because it should end, but \\\"ABC\\\" differs near \\\"ABC\\\" (index 0).\");\n }\n\n [Fact]\n public void When_end_of_string_is_compared_with_equivalent_of_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWithEquivalentOf(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare string end equivalence with .*\");\n }\n\n [Fact]\n public void When_end_of_string_is_compared_with_equivalent_of_empty_string_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().EndWithEquivalentOf(\"\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_equivalent_of_string_that_is_longer_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWithEquivalentOf(\"00abc\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to end with equivalent of \" +\n \"\\\"00abc\\\", but \" +\n \"\\\"ABC\\\" is too short.\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_equivalent_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someString.Should().EndWithEquivalentOf(\"abC\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString to end with equivalent of \\\"abC\\\", but found .\");\n }\n }\n\n public class NotEndWithEquivalentOf\n {\n [Fact]\n public void Succeed_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act / Assert\n actual.Should().NotEndWithEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_not_end_with_another()\n {\n // Arrange\n string actual = \"prefix for test\";\n string expect = \"TEST\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_not_end_with_another()\n {\n // Arrange\n string actual = \" prefix for test\";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_not_end_with_another()\n {\n // Arrange\n string actual = \"prefix for test \";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_not_end_with_another()\n {\n // Arrange\n string actual = \"prefix for \\rA\\nB\\r\\nC\\n\";\n string expect = \"A\\r\\nB\\nC\\r\";\n\n // Act\n Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_equivalent_of_a_value_and_it_does_not_it_should_succeed()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().NotEndWithEquivalentOf(\"aB\");\n }\n\n [Fact]\n public void\n When_asserting_string_does_not_end_with_equivalent_of_a_value_but_it_does_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWithEquivalentOf(\"Bc\", \"because of some {0}\", \"reason\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to end with equivalent of \\\"Bc\\\" because of some reason, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_equivalent_of_a_value_that_is_null_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWithEquivalentOf(null);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Cannot compare end of string with .*\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_equivalent_of_a_value_that_is_empty_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWithEquivalentOf(\"\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to end with equivalent of \\\"\\\", but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_equivalent_of_a_value_and_actual_value_is_null_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someString.Should().NotEndWithEquivalentOf(\"Abc\", \"some {0}\", \"reason\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to end with equivalent of \\\"Abc\\\"*some reason*, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.cs", "using System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class StringAssertionSpecs\n{\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_chaining_multiple_assertions_it_should_assert_all_conditions()\n {\n // Arrange\n string actual = \"ABCDEFGHI\";\n string prefix = \"AB\";\n string suffix = \"HI\";\n string substring = \"EF\";\n int length = 9;\n\n // Act / Assert\n actual.Should()\n .StartWith(prefix).And\n .EndWith(suffix).And\n .Contain(substring).And\n .HaveLength(length);\n }\n\n private sealed class AlwaysMatchingEqualityComparer : IEqualityComparer\n {\n public bool Equals(string x, string y)\n {\n return true;\n }\n\n public int GetHashCode(string obj)\n {\n return obj.GetHashCode();\n }\n }\n\n private sealed class NeverMatchingEqualityComparer : IEqualityComparer\n {\n public bool Equals(string x, string y)\n {\n return false;\n }\n\n public int GetHashCode(string obj)\n {\n return obj.GetHashCode();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeWithin.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeWithin\n {\n [Fact]\n public void When_date_is_not_within_50_hours_before_another_date_it_should_throw()\n {\n // Arrange\n var target = new DateTime(2010, 4, 10, 12, 0, 0);\n DateTime subject = target - 50.Hours() - 1.Seconds();\n\n // Act\n Action act =\n () => subject.Should().BeWithin(TimeSpan.FromHours(50)).Before(target, \"{0} hours is enough\", 50);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2010-04-08 09:59:59> to be within 2d and 2h before <2010-04-10 12:00:00> because 50 hours is enough, but it is behind by 2d, 2h and 1s.\");\n }\n\n [Fact]\n public void When_date_is_exactly_within_1d_before_another_date_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(2010, 4, 10);\n DateTime subject = target - 1.Days();\n\n // Act / Assert\n subject.Should().BeWithin(TimeSpan.FromHours(24)).Before(target);\n }\n\n [Fact]\n public void When_date_is_within_1d_before_another_date_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(2010, 4, 10);\n DateTime subject = target - 23.Hours();\n\n // Act / Assert\n subject.Should().BeWithin(TimeSpan.FromHours(24)).Before(target);\n }\n\n [Fact]\n public void When_a_utc_date_is_within_0s_before_itself_it_should_not_throw()\n {\n // Arrange\n var date = DateTime.UtcNow; // local timezone differs from UTC\n\n // Act / Assert\n date.Should().BeWithin(TimeSpan.Zero).Before(date);\n }\n\n [Fact]\n public void When_a_utc_date_is_within_0s_after_itself_it_should_not_throw()\n {\n // Arrange\n var date = DateTime.UtcNow; // local timezone differs from UTC\n\n // Act / Assert\n date.Should().BeWithin(TimeSpan.Zero).After(date);\n }\n\n [Theory]\n [InlineData(30, 20)] // edge case\n [InlineData(30, 25)]\n public void When_asserting_subject_be_within_10_seconds_after_target_but_subject_is_before_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds);\n var subject = 1.January(0001).At(0, 0, subjectSeconds);\n\n // Act\n Action action = () => subject.Should().BeWithin(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds}> to be within 10s after <00:00:30>, but it is behind by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Theory]\n [InlineData(30, 40)] // edge case\n [InlineData(30, 35)]\n public void When_asserting_subject_be_within_10_seconds_before_target_but_subject_is_after_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds);\n var subject = 1.January(0001).At(0, 0, subjectSeconds);\n\n // Act\n Action action = () => subject.Should().BeWithin(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds}> to be within 10s before <00:00:30>, but it is ahead by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Fact]\n public void Should_throw_because_of_assertion_failure_when_asserting_null_is_within_second_before_specific_date()\n {\n // Arrange\n DateTimeOffset? nullDateTime = null;\n DateTimeOffset target = new(2000, 1, 1, 12, 0, 0, TimeSpan.Zero);\n\n // Act\n Action action = () =>\n nullDateTime.Should()\n .BeWithin(TimeSpan.FromSeconds(1))\n .Before(target);\n\n // Assert\n action.Should().Throw()\n .Which.Message\n .Should().StartWith(\n \"Expected nullDateTime to be within 1s before <2000-01-01 12:00:00 +0h>, but found a DateTime\");\n }\n\n [Fact]\n public void Should_throw_because_of_assertion_failure_when_asserting_null_is_within_second_after_specific_date()\n {\n // Arrange\n DateTimeOffset? nullDateTime = null;\n DateTimeOffset target = new(2000, 1, 1, 12, 0, 0, TimeSpan.Zero);\n\n // Act\n Action action = () =>\n nullDateTime.Should()\n .BeWithin(TimeSpan.FromSeconds(1))\n .After(target);\n\n // Assert\n action.Should().Throw()\n .Which.Message\n .Should().StartWith(\n \"Expected nullDateTime to be within 1s after <2000-01-01 12:00:00 +0h>, but found a DateTime\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/DecimalAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class DecimalAssertions : NumericAssertions\n{\n internal DecimalAssertions(decimal value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(decimal subject, decimal expected)\n {\n try\n {\n decimal difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n catch (OverflowException)\n {\n return null;\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableDecimalAssertions.cs", "using System;\nusing System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableDecimalAssertions : NullableNumericAssertions\n{\n internal NullableDecimalAssertions(decimal? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(decimal subject, decimal expected)\n {\n try\n {\n decimal difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n catch (OverflowException)\n {\n return null;\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeOneOf.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n\n // Act\n Action action = () => value.Should().BeOneOf(value + 1.Days(), value + 4.Hours());\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value to be one of {<2017-01-01 +1h>, <2016-12-31 04:00:00 +1h>}, but it was <2016-12-31 +1h>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_param_values_follow_up_assertions_works()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n\n // Act / Assert\n value.Should().BeOneOf(value, value + 1.Hours())\n .And.Be(31.December(2016).WithOffset(1.Hours()));\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_nullable_params_values_follow_up_assertions_works()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n\n // Act / Assert\n value.Should().BeOneOf(null, value, value + 1.Hours())\n .And.Be(31.December(2016).WithOffset(1.Hours()));\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_enumerable_values_follow_up_assertions_works()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n IEnumerable expected = [value, value + 1.Hours()];\n\n // Act / Assert\n value.Should().BeOneOf(expected)\n .And.Be(31.December(2016).WithOffset(1.Hours()));\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_nullable_enumerable_follow_up_assertions_works()\n {\n // Arrange\n var value = new DateTimeOffset(31.December(2016), 1.Hours());\n IEnumerable expected = [null, value, value + 1.Hours()];\n\n // Act / Assert\n value.Should().BeOneOf(expected)\n .And.Be(31.December(2016).WithOffset(1.Hours()));\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n DateTimeOffset value = 31.December(2016).WithOffset(1.Hours());\n\n // Act\n Action action = () => value.Should().BeOneOf(new[] { value + 1.Days(), value + 2.Days() }, \"because it's true\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value to be one of {<2017-01-01 +1h>, <2017-01-02 +1h>} because it's true, but it was <2016-12-31 +1h>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n DateTimeOffset value = new(2016, 12, 30, 23, 58, 57, TimeSpan.FromHours(4));\n\n // Act / Assert\n value.Should().BeOneOf(new DateTimeOffset(2216, 1, 30, 0, 5, 7, TimeSpan.FromHours(2)),\n new DateTimeOffset(2016, 12, 30, 23, 58, 57, TimeSpan.FromHours(4)));\n }\n\n [Fact]\n public void When_a_null_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateTimeOffset? value = null;\n\n // Act\n Action action = () => value.Should().BeOneOf(new DateTimeOffset(2216, 1, 30, 0, 5, 7, TimeSpan.FromHours(1)),\n new DateTimeOffset(2016, 2, 10, 2, 45, 7, TimeSpan.FromHours(2)));\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value to be one of {<2216-01-30 00:05:07 +1h>, <2016-02-10 02:45:07 +2h>}, but it was .\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_datetimeoffset_is_null()\n {\n // Arrange\n DateTimeOffset? value = null;\n\n // Act / Assert\n value.Should().BeOneOf(new DateTimeOffset(2216, 1, 30, 0, 5, 7, TimeSpan.Zero), null);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeAtLeast.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeAtLeast\n {\n [Fact]\n public void When_date_is_not_at_least_one_day_before_another_it_should_throw()\n {\n // Arrange\n var target = new DateTime(2009, 10, 2);\n DateTime subject = target - 23.Hours();\n\n // Act\n Action act = () => subject.Should().BeAtLeast(TimeSpan.FromDays(1)).Before(target, \"we like {0}\", \"that\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2009-10-01 01:00:00> to be at least 1d before <2009-10-02> because we like that, but it is behind by 23h.\");\n }\n\n [Fact]\n public void When_date_is_at_least_one_day_before_another_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(2009, 10, 2);\n DateTime subject = target - 24.Hours();\n\n // Act / Assert\n subject.Should().BeAtLeast(TimeSpan.FromDays(1)).Before(target);\n }\n\n [Theory]\n [InlineData(30, 20)] // edge case\n [InlineData(30, 15)]\n public void When_asserting_subject_be_at_least_10_seconds_after_target_but_subject_is_before_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds);\n var subject = 1.January(0001).At(0, 0, subjectSeconds);\n\n // Act\n Action action = () => subject.Should().BeAtLeast(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds}> to be at least 10s after <00:00:30>, but it is behind by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Theory]\n [InlineData(30, 40)] // edge case\n [InlineData(30, 45)]\n public void When_asserting_subject_be_at_least_10_seconds_before_target_but_subject_is_after_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds);\n var subject = 1.January(0001).At(0, 0, subjectSeconds);\n\n // Act\n Action action = () => subject.Should().BeAtLeast(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds}> to be at least 10s before <00:00:30>, but it is ahead by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.Be.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_two_equal_object_are_expected_to_be_equal_it_should_not_fail()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var equalObject = new ClassWithCustomEqualMethod(1);\n\n // Act / Assert\n someObject.Should().Be(equalObject);\n }\n\n [Fact]\n public void When_two_different_objects_are_expected_to_be_equal_it_should_fail_with_a_clear_explanation()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var nonEqualObject = new ClassWithCustomEqualMethod(2);\n\n // Act\n Action act = () => someObject.Should().Be(nonEqualObject);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someObject to be ClassWithCustomEqualMethod(2), but found ClassWithCustomEqualMethod(1).\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_are_null_it_should_succeed()\n {\n // Arrange\n object someObject = null;\n object expectedObject = null;\n\n // Act / Assert\n someObject.Should().Be(expectedObject);\n }\n\n [Fact]\n public void When_the_subject_is_null_it_should_fail()\n {\n // Arrange\n object someObject = null;\n var nonEqualObject = new ClassWithCustomEqualMethod(2);\n\n // Act\n Action act = () => someObject.Should().Be(nonEqualObject);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someObject to be ClassWithCustomEqualMethod(2), but found .\");\n }\n\n [Fact]\n public void When_two_different_objects_are_expected_to_be_equal_it_should_fail_and_use_the_reason()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var nonEqualObject = new ClassWithCustomEqualMethod(2);\n\n // Act\n Action act = () => someObject.Should().Be(nonEqualObject, \"because it should use the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected someObject to be ClassWithCustomEqualMethod(2) because it should use the reason, but found ClassWithCustomEqualMethod(1).\");\n }\n\n [Fact]\n public void When_comparing_a_numeric_and_an_enum_for_equality_it_should_throw()\n {\n // Arrange\n object subject = 1;\n MyEnum expected = MyEnum.One;\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void An_untyped_value_is_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n object value = new SomeClass(5);\n\n // Act / Assert\n value.Should().Be(new SomeClass(5), new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void A_typed_value_is_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n var value = new SomeClass(5);\n\n // Act / Assert\n value.Should().Be(new SomeClass(5), new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void An_untyped_value_is_not_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(4), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected value to be SomeClass(4)*I said so*found SomeClass(3).\");\n }\n\n [Fact]\n public void A_typed_value_is_not_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(4), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected value to be SomeClass(4)*I said so*found SomeClass(3).\");\n }\n\n [Fact]\n public void A_typed_value_is_not_of_the_same_type()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(3), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to be SomeClass(3)*I said so*found ClassWithCustomEqualMethod(3).\");\n }\n\n [Fact]\n public void A_untyped_value_requires_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(3), comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void A_typed_value_requires_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().Be(new SomeClass(3), comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act / Assert\n value.Should().Be(value).And.NotBeNull();\n }\n\n [Fact]\n public void Can_chain_multiple_assertions()\n {\n // Arrange\n var value = new object();\n\n // Act / Assert\n value.Should().Be(value, new DumbObjectEqualityComparer()).And.NotBeNull();\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_non_equal_objects_are_expected_to_be_not_equal_it_should_not_fail()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var nonEqualObject = new ClassWithCustomEqualMethod(2);\n\n // Act / Assert\n someObject.Should().NotBe(nonEqualObject);\n }\n\n [Fact]\n public void When_two_equal_objects_are_expected_not_to_be_equal_it_should_fail_with_a_clear_explanation()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var equalObject = new ClassWithCustomEqualMethod(1);\n\n // Act\n Action act = () =>\n someObject.Should().NotBe(equalObject);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect someObject to be equal to ClassWithCustomEqualMethod(1).\");\n }\n\n [Fact]\n public void When_two_equal_objects_are_expected_not_to_be_equal_it_should_fail_and_use_the_reason()\n {\n // Arrange\n var someObject = new ClassWithCustomEqualMethod(1);\n var equalObject = new ClassWithCustomEqualMethod(1);\n\n // Act\n Action act = () =>\n someObject.Should().NotBe(equalObject, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect someObject to be equal to ClassWithCustomEqualMethod(1) \" +\n \"because we want to test the failure message.\");\n }\n\n [Fact]\n public void An_untyped_value_is_not_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n object value = new SomeClass(5);\n\n // Act / Assert\n value.Should().NotBe(new SomeClass(4), new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void A_typed_value_is_not_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n var value = new SomeClass(5);\n\n // Act / Assert\n value.Should().NotBe(new SomeClass(4), new SomeClassEqualityComparer());\n }\n\n [Fact]\n public void An_untyped_value_is_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().NotBe(new SomeClass(3), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not expect value to be equal to SomeClass(3)*I said so*\");\n }\n\n [Fact]\n public void A_typed_value_is_equal_to_another_according_to_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().NotBe(new SomeClass(3), new SomeClassEqualityComparer(), \"I said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Did not expect value to be equal to SomeClass(3)*I said so*\");\n }\n\n [Fact]\n public void A_typed_value_is_not_of_the_same_type()\n {\n // Arrange\n var value = new ClassWithCustomEqualMethod(3);\n\n // Act / Assert\n value.Should().NotBe(new SomeClass(3), new SomeClassEqualityComparer(), \"I said so\");\n }\n\n [Fact]\n public void An_untyped_value_requires_a_comparer()\n {\n // Arrange\n object value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().NotBe(new SomeClass(3), comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void A_typed_value_requires_a_comparer()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act\n Action act = () => value.Should().NotBe(new SomeClass(3), comparer: null);\n\n // Assert\n act.Should().Throw().WithParameterName(\"comparer\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n var value = new SomeClass(3);\n\n // Act / Assert\n value.Should().NotBe(new SomeClass(3)).And.NotBeNull();\n }\n\n [Fact]\n public void Can_chain_multiple_assertions()\n {\n // Arrange\n var value = new object();\n\n // Act / Assert\n value.Should().NotBe(new object(), new DumbObjectEqualityComparer()).And.NotBeNull();\n }\n }\n\n private enum MyEnum\n {\n One = 1,\n Two = 2\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.ContainValue.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class ContainValue\n {\n [Fact]\n public void When_dictionary_contains_expected_value_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().ContainValue(\"One\");\n }\n\n [Fact]\n public void Can_continue_asserting_on_a_single_matching_item()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValue(\"One\").Which.Should().Be(\"Two\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Expected dictionary[1] to be*\\\"One\\\"*\\\"Two\\\"*\");\n }\n\n [Fact]\n public void Null_dictionaries_do_not_contain_any_values()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().ContainValue(\"One\", \"because {0}\", \"we do\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dictionary to contain values {\\\"One\\\"} because we do, but found .\");\n }\n\n [Fact]\n public void When_dictionary_contains_expected_null_value_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = null\n };\n\n // Act / Assert\n dictionary.Should().ContainValue(null);\n }\n\n [Fact]\n public void When_the_specified_value_exists_it_should_allow_continuation_using_that_value()\n {\n // Arrange\n var myClass = new MyClass\n {\n SomeProperty = 0\n };\n\n var dictionary = new Dictionary\n {\n [1] = myClass\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValue(myClass).Which.SomeProperty.Should().BeGreaterThan(0);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*greater*0*0*\");\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_single_value_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValue(\"Three\", \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain value \\\"Three\\\" because we do.\");\n }\n }\n\n public class NotContainValue\n {\n [Fact]\n public void When_dictionary_does_not_contain_a_value_that_is_not_in_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValue(\"Three\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_dictionary_contains_an_unexpected_value_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValue(\"One\", \"because we {0} like it\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} not to contain value \\\"One\\\" because we don't like it, but found it anyhow.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_does_not_contain_value_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContainValue(\"One\", \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain value \\\"One\\\" because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeDataContractSerializable.cs", "using System;\nusing System.Runtime.Serialization;\nusing AwesomeAssertions.Extensions;\nusing JetBrains.Annotations;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeDataContractSerializable\n {\n [Fact]\n public void When_an_object_is_data_contract_serializable_it_should_succeed()\n {\n // Arrange\n var subject = new DataContractSerializableClass\n {\n Name = \"John\",\n Id = 1\n };\n\n // Act / Assert\n subject.Should().BeDataContractSerializable();\n }\n\n [Fact]\n public void When_an_object_is_not_data_contract_serializable_it_should_fail()\n {\n // Arrange\n var subject = new NonDataContractSerializableClass();\n\n // Act\n Action act = () => subject.Should().BeDataContractSerializable(\"we need to store it on {0}\", \"disk\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*we need to store it on disk*EnumMemberAttribute*\");\n }\n\n [Fact]\n public void When_an_object_is_data_contract_serializable_but_doesnt_restore_all_properties_it_should_fail()\n {\n // Arrange\n var subject = new DataContractSerializableClassNotRestoringAllProperties\n {\n Name = \"John\",\n BirthDay = 20.September(1973)\n };\n\n // Act\n Action act = () => subject.Should().BeDataContractSerializable();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be serializable, but serialization failed with:*property subject.Name*to be*\");\n }\n\n [Fact]\n public void When_a_data_contract_serializable_object_doesnt_restore_an_ignored_property_it_should_succeed()\n {\n // Arrange\n var subject = new DataContractSerializableClassNotRestoringAllProperties\n {\n Name = \"John\",\n BirthDay = 20.September(1973)\n };\n\n // Act / Assert\n subject.Should()\n .BeDataContractSerializable(\n options => options.Excluding(x => x.Name));\n }\n\n [Fact]\n public void When_injecting_null_options_to_BeDataContractSerializable_it_should_throw()\n {\n // Arrange\n var subject = new DataContractSerializableClassNotRestoringAllProperties();\n\n // Act\n Action act = () => subject.Should()\n .BeDataContractSerializable(\n options: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"options\");\n }\n }\n\n public class NonDataContractSerializableClass\n {\n public Color Color { get; set; }\n }\n\n public class DataContractSerializableClass\n {\n [UsedImplicitly]\n public string Name { get; set; }\n\n public int Id;\n }\n\n [DataContract]\n public class DataContractSerializableClassNotRestoringAllProperties\n {\n public string Name { get; set; }\n\n [DataMember]\n public DateTime BirthDay { get; set; }\n }\n\n public enum Color\n {\n Red = 1,\n Yellow = 2\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/TypeEnumerableExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Types;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Extension methods for filtering a collection of types.\n/// \npublic static class TypeEnumerableExtensions\n{\n /// \n /// Filters to only include types decorated with a particular attribute.\n /// \n public static IEnumerable ThatAreDecoratedWith(this IEnumerable types)\n where TAttribute : Attribute\n {\n return new TypeSelector(types).ThatAreDecoratedWith();\n }\n\n /// \n /// Filters to only include types decorated with, or inherits from a parent class, a particular attribute.\n /// \n public static IEnumerable ThatAreDecoratedWithOrInherit(this IEnumerable types)\n where TAttribute : Attribute\n {\n return new TypeSelector(types).ThatAreDecoratedWithOrInherit();\n }\n\n /// \n /// Filters to only include types not decorated with a particular attribute.\n /// \n public static IEnumerable ThatAreNotDecoratedWith(this IEnumerable types)\n where TAttribute : Attribute\n {\n return new TypeSelector(types).ThatAreNotDecoratedWith();\n }\n\n /// \n /// Filters to only include types not decorated with and does not inherit from a parent class, a particular attribute.\n /// \n public static IEnumerable ThatAreNotDecoratedWithOrInherit(this IEnumerable types)\n where TAttribute : Attribute\n {\n return new TypeSelector(types).ThatAreNotDecoratedWithOrInherit();\n }\n\n /// \n /// Filters to only include types where the namespace of type is exactly .\n /// \n public static IEnumerable ThatAreInNamespace(this IEnumerable types, string @namespace)\n {\n return new TypeSelector(types).ThatAreInNamespace(@namespace);\n }\n\n /// \n /// Filters to only include types where the namespace of type is starts with .\n /// \n public static IEnumerable ThatAreUnderNamespace(this IEnumerable types, string @namespace)\n {\n return new TypeSelector(types).ThatAreUnderNamespace(@namespace);\n }\n\n /// \n /// Filters to only include types that subclass the specified type, but NOT the same type.\n /// \n public static IEnumerable ThatDeriveFrom(this IEnumerable types)\n {\n return new TypeSelector(types).ThatDeriveFrom();\n }\n\n /// \n /// Determines whether a type implements an interface (but is not the interface itself).\n /// \n public static IEnumerable ThatImplement(this IEnumerable types)\n {\n return new TypeSelector(types).ThatImplement();\n }\n\n /// \n /// Filters to only include types that are classes.\n /// \n public static IEnumerable ThatAreClasses(this IEnumerable types)\n {\n return new TypeSelector(types).ThatAreClasses();\n }\n\n /// \n /// Filters to only include types that are not classes.\n /// \n public static IEnumerable ThatAreNotClasses(this IEnumerable types)\n {\n return new TypeSelector(types).ThatAreNotClasses();\n }\n\n /// \n /// Filters to only include types that are static.\n /// \n public static IEnumerable ThatAreStatic(this IEnumerable types)\n {\n return new TypeSelector(types).ThatAreStatic();\n }\n\n /// \n /// Filters to only include types that are not static.\n /// \n public static IEnumerable ThatAreNotStatic(this IEnumerable types)\n {\n return new TypeSelector(types).ThatAreNotStatic();\n }\n\n /// \n /// Filters to only include types that satisfies the passed.\n /// \n public static IEnumerable ThatSatisfy(this IEnumerable types, Func predicate)\n {\n return new TypeSelector(types).ThatSatisfy(predicate);\n }\n\n /// \n /// Returns T for the types which are or ; the type itself otherwise\n /// \n public static IEnumerable UnwrapTaskTypes(this IEnumerable types)\n {\n return new TypeSelector(types).UnwrapTaskTypes();\n }\n\n /// \n /// Returns T for the types which are or implement the ; the type itself otherwise\n /// \n public static IEnumerable UnwrapEnumerableTypes(this IEnumerable types)\n {\n return new TypeSelector(types).UnwrapEnumerableTypes();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeWithin.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeWithin\n {\n [Fact]\n public void When_date_is_not_within_50_hours_before_another_date_it_should_throw()\n {\n // Arrange\n var target = 10.April(2010).At(12, 0).WithOffset(0.Hours());\n DateTimeOffset subject = target - 50.Hours() - 1.Seconds();\n\n // Act\n Action act =\n () => subject.Should().BeWithin(TimeSpan.FromHours(50)).Before(target, \"{0} hours is enough\", 50);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2010-04-08 09:59:59 +0h> to be within 2d and 2h before <2010-04-10 12:00:00 +0h> because 50 hours is enough, but it is behind by 2d, 2h and 1s.\");\n }\n\n [Fact]\n public void When_date_is_exactly_within_1d_before_another_date_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(10.April(2010));\n DateTimeOffset subject = target - 1.Days();\n\n // Act / Assert\n subject.Should().BeWithin(TimeSpan.FromHours(24)).Before(target);\n }\n\n [Fact]\n public void When_date_is_within_1d_before_another_date_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(10.April(2010));\n DateTimeOffset subject = target - 23.Hours();\n\n // Act / Assert\n subject.Should().BeWithin(TimeSpan.FromHours(24)).Before(target);\n }\n\n [Fact]\n public void When_a_utc_date_is_within_0s_before_itself_it_should_not_throw()\n {\n // Arrange\n var date = DateTimeOffset.UtcNow; // local timezone differs from +0h\n\n // Act / Assert\n date.Should().BeWithin(TimeSpan.Zero).Before(date);\n }\n\n [Fact]\n public void When_a_utc_date_is_within_0s_after_itself_it_should_not_throw()\n {\n // Arrange\n var date = DateTimeOffset.UtcNow; // local timezone differs from +0h\n\n // Act / Assert\n date.Should().BeWithin(TimeSpan.Zero).After(date);\n }\n\n [Theory]\n [InlineData(30, 20)] // edge case\n [InlineData(30, 25)]\n public void When_asserting_subject_be_within_10_seconds_after_target_but_subject_is_before_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, subjectSeconds).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeWithin(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds} +0h> to be within 10s after <00:00:30 +0h>, but it is behind by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Theory]\n [InlineData(30, 40)] // edge case\n [InlineData(30, 35)]\n public void When_asserting_subject_be_within_10_seconds_before_target_but_subject_is_after_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, subjectSeconds).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeWithin(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds} +0h> to be within 10s before <00:00:30 +0h>, but it is ahead by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeAtLeast.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeAtLeast\n {\n [Fact]\n public void When_date_is_not_at_least_one_day_before_another_it_should_throw()\n {\n // Arrange\n var target = new DateTimeOffset(2.October(2009), 0.Hours());\n DateTimeOffset subject = target - 23.Hours();\n\n // Act\n Action act = () => subject.Should().BeAtLeast(TimeSpan.FromDays(1)).Before(target, \"we like {0}\", \"that\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2009-10-01 01:00:00 +0h> to be at least 1d before <2009-10-02 +0h> because we like that, but it is behind by 23h.\");\n }\n\n [Fact]\n public void When_date_is_at_least_one_day_before_another_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(2.October(2009));\n DateTimeOffset subject = target - 24.Hours();\n\n // Act / Assert\n subject.Should().BeAtLeast(TimeSpan.FromDays(1)).Before(target);\n }\n\n [Theory]\n [InlineData(30, 20)] // edge case\n [InlineData(30, 15)]\n public void When_asserting_subject_be_at_least_10_seconds_after_target_but_subject_is_before_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, subjectSeconds).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeAtLeast(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds} +0h> to be at least 10s after <00:00:30 +0h>, but it is behind by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n\n [Theory]\n [InlineData(30, 40)] // edge case\n [InlineData(30, 45)]\n public void When_asserting_subject_be_at_least_10_seconds_before_target_but_subject_is_after_target_it_should_throw(\n int targetSeconds, int subjectSeconds)\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, targetSeconds).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, subjectSeconds).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeAtLeast(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n $\"Expected subject <00:00:{subjectSeconds} +0h> to be at least 10s before <00:00:30 +0h>, but it is ahead by {Math.Abs(subjectSeconds - targetSeconds)}s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/MiscellaneousExceptionSpecs.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class MiscellaneousExceptionSpecs\n{\n [Fact]\n public void When_getting_value_of_property_of_thrown_exception_it_should_return_value_of_property()\n {\n // Arrange\n const string SomeParamNameValue = \"param\";\n Does target = Does.Throw(new ExceptionWithProperties(SomeParamNameValue));\n\n // Act\n Action act = target.Do;\n\n // Assert\n act.Should().Throw().And.Property.Should().Be(SomeParamNameValue);\n }\n\n [Fact]\n public void When_validating_a_subject_against_multiple_conditions_it_should_support_chaining()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"message\", new ArgumentException(\"inner message\")));\n\n // Act / Assert\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException()\n .WithMessage(\"inner message\");\n }\n\n [Fact]\n public void When_a_yielding_enumerable_throws_an_expected_exception_it_should_not_throw()\n {\n // Act\n Func> act = () => MethodThatUsesYield(\"aaa!aaa\");\n\n // Assert\n act.Enumerating().Should().Throw();\n }\n\n private static IEnumerable MethodThatUsesYield(string bar)\n {\n foreach (var character in bar)\n {\n if (character.Equals('!'))\n {\n throw new Exception(\"No exclamation marks allowed.\");\n }\n\n yield return char.ToUpperInvariant(character);\n }\n }\n\n [Fact]\n public void When_custom_condition_is_not_met_it_should_throw()\n {\n // Arrange\n Action act = () => throw new ArgumentException(\"\");\n\n try\n {\n // Act\n act\n .Should().Throw()\n .Where(e => e.Message.Length > 0, \"an exception must have a message\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException exc)\n {\n // Assert\n exc.Message.Should().StartWith(\n \"Expected exception where (e.Message.Length > 0) because an exception must have a message, but the condition was not met\");\n }\n }\n\n [Fact]\n public void When_a_2nd_condition_is_not_met_it_should_throw()\n {\n // Arrange\n Action act = () => throw new ArgumentException(\"Fail\");\n\n try\n {\n // Act\n act\n .Should().Throw()\n .Where(e => e.Message.Length > 0)\n .Where(e => e.Message == \"Error\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException exc)\n {\n // Assert\n exc.Message.Should().StartWith(\n \"Expected exception where (e.Message == \\\"Error\\\"), but the condition was not met\");\n }\n catch (Exception exc)\n {\n exc.Message.Should().StartWith(\n \"Expected exception where (e.Message == \\\"Error\\\"), but the condition was not met\");\n }\n }\n\n [Fact]\n public void When_custom_condition_is_met_it_should_not_throw()\n {\n // Arrange / Act\n Action act = () => throw new ArgumentException(\"\");\n\n // Assert\n act\n .Should().Throw()\n .Where(e => e.Message.Length == 0);\n }\n\n [Fact]\n public void When_two_exceptions_are_thrown_and_the_assertion_assumes_there_can_only_be_one_it_should_fail()\n {\n // Arrange\n Does testSubject = Does.Throw(new AggregateException(new Exception(), new Exception()));\n Action throwingMethod = testSubject.Do;\n\n // Act\n Action action = () => throwingMethod.Should().Throw().And.Message.Should();\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void When_an_exception_of_a_different_type_is_thrown_it_should_include_the_type_of_the_thrown_exception()\n {\n // Arrange\n Action throwException = () => throw new ExceptionWithEmptyToString();\n\n // Act\n Action act =\n () => throwException.Should().Throw();\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*System.ArgumentNullException*{typeof(ExceptionWithEmptyToString)}*\");\n }\n\n [Fact]\n public void When_a_method_throws_with_a_matching_parameter_name_it_should_succeed()\n {\n // Arrange\n Action throwException = () => throw new ArgumentNullException(\"someParameter\");\n\n // Act / Assert\n throwException.Should().Throw()\n .WithParameterName(\"someParameter\");\n }\n\n [Fact]\n public void When_a_method_throws_with_a_non_matching_parameter_name_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n Action throwException = () => throw new ArgumentNullException(\"someOtherParameter\");\n\n // Act\n Action act = () =>\n throwException.Should().Throw()\n .WithParameterName(\"someParameter\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*with parameter name \\\"someParameter\\\"*we want to test the failure message*\\\"someOtherParameter\\\"*\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.Be.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]Be specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_both_values_are_the_same_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().Be(\"ABC\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_are_null_it_should_succeed()\n {\n // Arrange\n string actualString = null;\n string expectedString = null;\n\n // Act / Assert\n actualString.Should().Be(expectedString);\n }\n\n [Fact]\n public void When_two_strings_differ_unexpectedly_it_should_throw()\n {\n // Act\n Action act = () => \"ADC\".Should().Be(\"ABC\", \"because we {0}\", \"do\");\n\n // Assert\n // we want one assertion with the full message.\n act.Should().Throw().Which.Message.Should().Be(\"\"\"\n Expected string to be the same string because we do, but they differ at index 1:\n ↓ (actual)\n \"ADC\"\n \"ABC\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_two_strings_differ_unexpectedly_containing_double_curly_closing_braces_it_should_throw()\n {\n const string expect = \"}}\";\n const string actual = \"}}}}\";\n\n // Act\n Action act = () => actual.Should().Be(expect);\n\n // Assert\n act.Should().Throw().WithMessage(\"*differ at index 2*}}}}\\\"*\\\"}}\\\"*\");\n }\n\n [Fact]\n public void When_two_strings_differ_unexpectedly_containing_double_curly_opening_braces_it_should_throw()\n {\n const string expect = \"{{\";\n const string actual = \"{{{{\";\n\n // Act\n Action act = () => actual.Should().Be(expect);\n\n // Assert\n act.Should().Throw().WithMessage(\"*differ at index 2*{{{{\\\"*\\\"{{\\\"*\");\n }\n\n [Fact]\n public void When_the_expected_string_is_shorter_than_the_actual_string_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().Be(\"AB\");\n\n // Assert\n act.Should().Throw().Which.Message.Should().Be(\"\"\"\n Expected string to be the same string, but they differ at index 2:\n ↓ (actual)\n \"ABC\"\n \"AB\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_the_expected_string_is_longer_than_the_actual_string_it_should_throw()\n {\n // Act\n Action act = () => \"AB\".Should().Be(\"ABC\");\n\n // Assert\n act.Should().Throw().Which.Message.Should().Be(\"\"\"\n Expected string to be the same string, but they differ at index 2:\n ↓ (actual)\n \"AB\"\n \"ABC\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_the_expected_string_is_empty_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().Be(\"\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*index 0*\");\n }\n\n [Fact]\n public void When_the_subject_string_is_empty_it_should_throw()\n {\n // Act\n Action act = () => \"\".Should().Be(\"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*index 0*\");\n }\n\n [Fact]\n public void When_string_is_expected_to_equal_null_it_should_throw()\n {\n // Act\n Action act = () => \"AB\".Should().Be(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be , but found \\\"AB\\\".\");\n }\n\n [Fact]\n public void When_string_is_expected_to_be_null_it_should_throw()\n {\n // Act\n Action act = () => \"AB\".Should().BeNull(\"we like {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be because we like null, but found \\\"AB\\\".\");\n }\n\n [Fact]\n public void When_the_expected_string_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().Be(\"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString to be \\\"ABC\\\", but found .\");\n }\n\n [Fact]\n public void When_the_expected_string_is_the_same_but_with_trailing_spaces_it_should_throw_with_clear_error_message()\n {\n // Act\n Action act = () => \"ABC\".Should().Be(\"ABC \", \"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be \\\"ABC \\\" because I say so, but it misses some extra whitespace at the end.\");\n }\n\n [Fact]\n public void\n When_the_actual_string_is_the_same_as_the_expected_but_with_trailing_spaces_it_should_throw_with_clear_error_message()\n {\n // Act\n Action act = () => \"ABC \".Should().Be(\"ABC\", \"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to be \\\"ABC\\\" because I say so, but it has unexpected whitespace at the end.\");\n }\n\n [Fact]\n public void When_two_strings_differ_and_one_of_them_is_long_it_should_display_both_strings_on_separate_line()\n {\n // Act\n Action act = () => \"1234567890\".Should().Be(\"0987654321\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected string to be the same string, but they differ at index 0:\n ↓ (actual)\n \"1234567890\"\n \"0987654321\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_two_strings_differ_and_one_of_them_is_multiline_it_should_display_both_strings_on_separate_line()\n {\n // Act\n Action act = () => \"A\\r\\nB\".Should().Be(\"A\\r\\nC\");\n\n // Assert\n act.Should().Throw().Which.Message.Should().Be(\"\"\"\n Expected string to be the same string, but they differ on line 2 and column 1 (index 3):\n ↓ (actual)\n \"A\\r\\nB\"\n \"A\\r\\nC\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void Use_arrows_for_text_longer_than_8_characters()\n {\n const string subject = \"this is a long text that differs in between two words\";\n const string expected = \"this is a long text which differs in between two words\";\n\n // Act\n Action act = () => subject.Should().Be(expected, \"because we use arrows now\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected subject to be the same string because we use arrows now, but they differ at index 20:\n ↓ (actual)\n \"…is a long text that differs in between two words\"\n \"…is a long text which differs in between two words\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void Only_add_ellipsis_for_long_text()\n {\n const string subject = \"this is a long text that has more than 60 characters so it requires ellipsis\";\n const string expected = \"this was too short\";\n\n // Act\n Action act = () => subject.Should().Be(expected, \"because we use arrows now\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected subject to be the same string because we use arrows now, but they differ at index 5:\n ↓ (actual)\n \"this is a long text that has more than 60 characters so it…\"\n \"this was too short\"\n ↑ (expected).\n \"\"\");\n }\n\n [Theory]\n [InlineData(\"ThisIsUsedTo Check a difference after 5 characters\")]\n [InlineData(\"ThisIsUsedTo CheckADifferenc e after 15 characters\")]\n public void Will_look_for_a_word_boundary_between_5_and_15_characters_before_the_mismatching_index_to_highlight_the_mismatch(string expected)\n {\n const string subject = \"ThisIsUsedTo CheckADifferenceInThe WordBoundaryAlgorithm\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"…CheckADifferenceInThe*\");\n }\n\n [Theory]\n [InlineData(\"ThisIsUsedTo Chec k a difference after 4 characters\", \"\\\"…sedTo CheckADifferen\")]\n [InlineData(\"ThisIsUsedTo CheckADifference after 16 characters\", \"\\\"…Difference\")]\n public void Will_fallback_to_10_characters_if_no_word_boundary_can_be_found_before_the_mismatching_index(\n string expected, string expectedMessagePart)\n {\n const string subject = \"ThisIsUsedTo CheckADifferenceInThe WordBoundaryAlgorithm\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage($\"*{expectedMessagePart}*\");\n }\n\n [Theory]\n [InlineData(\"This Is A LongTextWithMoreThan60CharactersWhichIs after 10 + 35 characters\")]\n [InlineData(\"This Is A LongTextWithMoreThan60Ch after 10 + 50 characters\")]\n public void Will_look_for_a_word_boundary_between_45_and_60_characters_after_the_mismatching_index_to_highlight_the_mismatch(string expected)\n {\n const string subject = \"This Is A LongTextWithMoreThan60CharactersWhichIsUsedToCheckADifferenceAtTheEndOfThe WordBoundaryAlgorithm\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage(\"*AtTheEndOfThe…\\\"*\");\n }\n\n [Fact]\n public void An_empty_string_is_always_shorter_than_a_long_text()\n {\n // Act\n Action act = () => \"\".Should().Be(\"ThisIsALongText\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*differ at index 0*\\\"\\\"*\\\"ThisIsALongText\\\"**\");\n }\n\n [Fact]\n public void A_mismatch_below_index_11_includes_all_text_preceding_the_index_in_the_failure()\n {\n // Act\n Action act = () => \"This is a long text\".Should().Be(\"This is a text that differs at index 10\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*\\\"This is a long*\");\n }\n\n [Theory]\n [InlineData(\"This Is A LongTextWithMoreThan60C that differs with 60 characters remaining\", \"oreThan60CharactersWhichIsUsedToCheckADifferenceAt…\\\"\")]\n [InlineData(\"This Is A LongTextWithMoreThan60Ch IsALongTextIsUsedToCheckADiffere after 10 + 16 characters\", \"reThan60CharactersWhichIsUsedToCheckADifferenceAtTheEndOfThe…\\\"\")]\n public void Will_fallback_to_50_characters_if_no_word_boundary_can_be_found_after_the_mismatching_index(\n string expected, string expectedMessagePart)\n {\n const string subject = \"This Is A LongTextWithMoreThan60CharactersWhichIsUsedToCheckADifferenceAtTheEndOfThe WordBoundaryAlgorithm\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage($\"*{expectedMessagePart}*\");\n }\n\n [Fact]\n public void Mismatches_in_multiline_text_includes_the_line_number()\n {\n var expectedIndex = 100 + (4 * Environment.NewLine.Length);\n\n var subject = \"\"\"\n @startuml\n Alice -> Bob : Authentication Request\n Bob --> Alice : Authentication Response\n\n Alice -> Bob : Another authentication Request\n Alice <-- Bob : Another authentication Response\n @enduml\n \"\"\";\n\n var expected = \"\"\"\n @startuml\n Alice -> Bob : Authentication Request\n Bob --> Alice : Authentication Response\n\n Alice -> Bob : Invalid authentication Request\n Alice <-- Bob : Another authentication Response\n @enduml\n \"\"\";\n\n // Act\n Action act = () => subject.Should().Be(expected);\n\n // Assert\n act.Should().Throw().WithMessage($\"\"\"\n Expected subject to be the same string, but they differ on line 5 and column 16 (index {expectedIndex}):\n ↓ (actual)\n \"…-> Bob : Another authentication Request*\\nAlice <-- Bob :…\"\n \"…-> Bob : Invalid authentication Request*\\nAlice <-- Bob :…\"\n ↑ (expected).\n \"\"\");\n }\n\n [Fact]\n public void When_differing_actual_and_expected_string_contain_braces_they_are_formatted_correctly()\n {\n // Act\n Action act = () => \"public class Foo { }\".Should().Be(\"public class Bar { }\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*Foo { }*Bar { }*↑ (expected).\", \"because no formatting warning must be appended\");\n }\n\n [Fact]\n public void When_the_longer_expected_string_and_actual_string_contain_braces_they_are_formatted_correctly()\n {\n // Act\n Action act = () => \"public class Foo { }\".Should().Be(\"public class Foo { };\");\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Match(\"\"\"\n *\"…class Foo { }\"\n *\"…class Foo { };\"\n *(expected).\n \"\"\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_different_strings_are_expected_to_differ_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string unexpected = \"DEF\";\n\n // Act / Assert\n actual.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void When_equal_strings_are_expected_to_differ_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().NotBe(\"ABC\", \"because we don't like {0}\", \"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string not to be \\\"ABC\\\" because we don't like ABC.\");\n }\n\n [Fact]\n public void When_non_empty_string_is_not_equal_to_empty_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string unexpected = \"\";\n\n // Act / Assert\n actual.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void When_empty_string_is_not_supposed_to_be_equal_to_empty_it_should_throw()\n {\n // Arrange\n string actual = \"\";\n string unexpected = \"\";\n\n // Act\n Action act = () => actual.Should().NotBe(unexpected);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual not to be \\\"\\\".\");\n }\n\n [Fact]\n public void When_valid_string_is_not_supposed_to_be_null_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string unexpected = null;\n\n // Act / Assert\n actual.Should().NotBe(unexpected);\n }\n\n [Fact]\n public void When_null_string_is_not_supposed_to_be_equal_to_null_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().NotBe(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to be .\");\n }\n\n [Fact]\n public void When_null_string_is_not_supposed_to_be_null_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().NotBeNull(\"we don't like {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to be because we don't like null.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.Parsable.cs", "#if NET8_0_OR_GREATER\nusing System;\nusing System.Globalization;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class StringAssertionSpecs\n{\n public class BeParsableInto\n {\n [Fact]\n public void Anything_which_is_no_int_is_not_parsable_into_an_int()\n {\n // Arrange\n string sut = \"aaa\";\n\n // Act\n Action act = () => sut.Should().BeParsableInto(\"we want to test the {0}\", \"failure message\")\n .Which.Should().Be(0);\n\n // Assert\n act.Should().Throw().WithMessage(\"*aaa*int*we want*failure message*could not*\");\n }\n\n [Theory]\n [InlineData(\"de-AT\", \"12,34\")]\n [InlineData(\"en-US\", \"12.34\")]\n public void A_floating_point_string_is_parsable_into_a_floating_point_value_in_various_cultures(\n string cultureName,\n string subject)\n {\n // Arrange\n\n // Act / Assert\n subject.Should().BeParsableInto(new CultureInfo(cultureName))\n .Which.Should().Be(12.34M);\n }\n\n [Fact]\n public void A_string_is_not_parsable_into_an_int_even_with_a_culture_defined()\n {\n // Arrange\n string sut = \"aaa\";\n\n // Act\n Action act = () =>\n sut.Should().BeParsableInto(new CultureInfo(\"de-AT\"));\n\n // Assert\n act.Should().Throw().WithMessage(\"*aaa*int*the input string*was not in a correct format*\");\n }\n\n [Theory]\n [InlineData(\"de-AT\", \"12.34\")]\n [InlineData(\"en-US\", \"12,34\")]\n public void A_floating_point_string_is_not_parsable_into_a_floating_point_value_in_various_cultures(\n string cultureName,\n string subject)\n {\n // Arrange\n\n // Act / Assert\n Action act = () => subject.Should().BeParsableInto(new CultureInfo(cultureName))\n .Which.Should().Be(12.34M);\n\n act.Should().Throw();\n }\n }\n\n public class NotBeParsableInto\n {\n [Fact]\n public void An_invalid_guid_string_is_not_parsable_into_a_guid()\n {\n // Arrange\n string sut = \"95e117d5bb0d4b16a1c7a11eea0284a\";\n\n // Act / Assert\n sut.Should().NotBeParsableInto();\n }\n\n [Fact]\n public void An_integer_string_is_parsable_into_an_int_but_throws_when_not_expected_to()\n {\n // Arrange\n string sut = \"1\";\n\n // Act\n Action act = () => sut.Should().NotBeParsableInto(\"we want to test the {0}\", \"failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*1*int*we want*failure message*could*\");\n }\n\n [Fact]\n public void A_string_is_not_parsable_into_an_int_even_with_culture_info_defined()\n {\n // Arrange\n string sut = \"aaa\";\n\n // Act / Assert\n sut.Should().NotBeParsableInto(new CultureInfo(\"de-DE\"));\n }\n\n [Fact]\n public void An_integer_string_is_parsable_into_an_int_but_throws_when_not_expected_to_with_culture_defined()\n {\n // Arrange\n string sut = \"1\";\n\n // Act\n Action act = () => sut.Should().NotBeParsableInto(new CultureInfo(\"de-DE\"));\n\n // Assert\n act.Should().Throw().WithMessage(\"*1*int*but it could*\");\n }\n }\n}\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeDecoratedWith.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeDecoratedWith specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeDecoratedWith\n {\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_it_succeeds()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithAttribute.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_it_should_allow_chaining()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithAttribute.Should().BeDecoratedWith()\n .Which.IsEnabled.Should().BeTrue();\n }\n\n [Fact]\n public void When_type_is_not_decorated_with_expected_attribute_it_fails()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithoutAttribute);\n\n // Act\n Action act = () =>\n typeWithoutAttribute.Should().BeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithoutAttribute to be decorated with *.DummyClassAttribute *failure message*\" +\n \", but the attribute was not found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_BeDecoratedWith_it_should_throw()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should().BeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithAttribute.Should()\n .BeDecoratedWith(a => a.Name == \"Expected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_with_the_expected_properties_it_should_allow_chaining()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithAttribute.Should()\n .BeDecoratedWith(a => a.Name == \"Expected\")\n .Which.IsEnabled.Should().BeTrue();\n }\n\n [Fact]\n public void When_type_is_decorated_with_expected_attribute_that_has_an_unexpected_property_it_fails()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should()\n .BeDecoratedWith(a => a.Name == \"Unexpected\" && a.IsEnabled);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithAttribute to be decorated with *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Unexpected\\\")*a.IsEnabled, but no matching attribute was found.\");\n }\n }\n\n public class NotBeDecoratedWith\n {\n [Fact]\n public void When_type_is_not_decorated_with_unexpected_attribute_it_succeeds()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithoutAttribute);\n\n // Act / Assert\n typeWithoutAttribute.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_type_is_decorated_with_unexpected_attribute_it_fails()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should().NotBeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithAttribute to not be decorated with *.DummyClassAttribute* *failure message*\" +\n \", but the attribute was found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotBeDecoratedWith_it_should_throw()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () => typeWithoutAttribute.Should()\n .NotBeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_type_is_not_decorated_with_unexpected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithAttribute);\n\n // Act / Assert\n typeWithoutAttribute.Should()\n .NotBeDecoratedWith(a => a.Name == \"Unexpected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_type_is_not_decorated_with_expected_attribute_that_has_an_unexpected_property_it_fails()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n typeWithoutAttribute.Should()\n .NotBeDecoratedWith(a => a.Name == \"Expected\" && a.IsEnabled);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithAttribute to not be decorated with *.DummyClassAttribute that matches \" +\n \"(a.Name == \\\"Expected\\\") * a.IsEnabled, but a matching attribute was found.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeOneOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n int value = 3;\n\n // Act\n Action act = () => value.Should().BeOneOf(4, 5);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be one of {4, 5}, but found 3.\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 3;\n\n // Act\n Action act = () => value.Should().BeOneOf([4, 5], \"because those are the valid values\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be one of {4, 5} because those are the valid values, but found 3.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n int value = 4;\n\n // Act / Assert\n value.Should().BeOneOf(4, 5);\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_one_of_to_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeOneOf(0, 1);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void Two_floats_that_are_NaN_can_be_compared()\n {\n // Arrange\n float value = float.NaN;\n\n // Act / Assert\n value.Should().BeOneOf(float.NaN, 4.5F);\n }\n\n [Fact]\n public void Floats_are_never_equal_to_NaN()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeOneOf(1.5F, 4.5F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*1.5F*found*NaN*\");\n }\n\n [Fact]\n public void Two_doubles_that_are_NaN_can_be_compared()\n {\n // Arrange\n double value = double.NaN;\n\n // Act / Assert\n value.Should().BeOneOf(double.NaN, 4.5F);\n }\n\n [Fact]\n public void Doubles_are_never_equal_to_NaN()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeOneOf(1.5D, 4.5D);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected*1.5*found NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.AllBeOfType.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The AllBeOfType specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class AllBeOfType\n {\n [Fact]\n public void When_the_types_in_a_collection_is_matched_against_a_null_type_exactly_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().AllBeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expectedType\");\n }\n\n [Fact]\n public void All_items_in_an_empty_collection_are_of_a_generic_type()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().AllBeOfType();\n }\n\n [Fact]\n public void All_items_in_an_empty_collection_are_of_a_type()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().AllBeOfType(typeof(int));\n }\n\n [Fact]\n public void When_collection_is_null_then_all_be_of_type_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllBeOfType(typeof(object), \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be object *failure message*, but found collection is .\");\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_expected_type_exactly_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeOfType(typeof(int));\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_expected_generic_type_exactly_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeOfType();\n }\n\n [Fact]\n public void When_matching_a_collection_against_an_exact_type_it_should_return_the_casted_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeOfType()\n .Which.Should().Equal(1, 2, 3);\n }\n\n [Fact]\n public void When_one_of_the_types_does_not_match_exactly_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { new Exception(), new ArgumentException(\"foo\") };\n\n // Act\n Action act = () => collection.Should().AllBeOfType(typeof(Exception), \"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be System.Exception because they are of different type, but found {System.Exception, System.ArgumentException}.\");\n }\n\n [Fact]\n public void When_one_of_the_types_does_not_match_exactly_the_generic_type_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { new Exception(), new ArgumentException(\"foo\") };\n\n // Act\n Action act = () => collection.Should().AllBeOfType(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be System.Exception because they are of different type, but found {System.Exception, System.ArgumentException}.\");\n }\n\n [Fact]\n public void When_one_of_the_elements_is_null_for_an_exact_match_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { 1, null, 3 };\n\n // Act\n Action act = () => collection.Should().AllBeOfType(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found a null element.\");\n }\n\n [Fact]\n public void When_collection_of_types_match_expected_type_exactly_it_should_succeed()\n {\n // Arrange\n Type[] collection = [typeof(int), typeof(int), typeof(int)];\n\n // Act / Assert\n collection.Should().AllBeOfType();\n }\n\n [Fact]\n public void When_collection_of_types_and_objects_match_type_exactly_it_should_succeed()\n {\n // Arrange\n var collection = new object[] { typeof(ArgumentException), new ArgumentException(\"foo\") };\n\n // Act / Assert\n collection.Should().AllBeOfType();\n }\n\n [Fact]\n public void When_collection_of_types_and_objects_do_not_match_type_exactly_it_should_throw()\n {\n // Arrange\n var collection = new object[] { typeof(Exception), new ArgumentException(\"foo\") };\n\n // Act\n Action act = () => collection.Should().AllBeOfType();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be System.ArgumentException, but found {System.Exception, System.ArgumentException}.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_all_be_of_typeOfT_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllBeOfType(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be object *failure message*, but found collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventRecorder.cs", "using System;\nusing System.Collections;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Reflection;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Records activity for a single event.\n/// \n[DebuggerNonUserCode]\ninternal sealed class EventRecorder : IEventRecording, IDisposable\n{\n private readonly Func utcNow;\n private readonly BlockingCollection raisedEvents = [];\n private readonly object lockable = new();\n private Action cleanup;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The object events are recorded from\n /// The name of the event that's recorded\n /// A delegate to get the current date and time in UTC format.\n /// Class used to generate a sequence in a thread-safe manner.\n public EventRecorder(object eventRaiser, string eventName, Func utcNow,\n ThreadSafeSequenceGenerator sequenceGenerator)\n {\n this.utcNow = utcNow;\n EventObject = eventRaiser;\n EventName = eventName;\n this.sequenceGenerator = sequenceGenerator;\n }\n\n /// \n /// The object events are recorded from\n /// \n public object EventObject { get; private set; }\n\n /// \n public string EventName { get; }\n\n private readonly ThreadSafeSequenceGenerator sequenceGenerator;\n\n public Type EventHandlerType { get; private set; }\n\n public void Attach(WeakReference subject, EventInfo eventInfo)\n {\n EventHandlerType = eventInfo.EventHandlerType;\n\n Delegate handler = EventHandlerFactory.GenerateHandler(eventInfo.EventHandlerType, this);\n eventInfo.AddEventHandler(subject.Target, handler);\n\n cleanup = () =>\n {\n if (subject.Target is not null)\n {\n eventInfo.RemoveEventHandler(subject.Target, handler);\n }\n };\n }\n\n public void Dispose()\n {\n Action localCleanup = cleanup;\n if (localCleanup is not null)\n {\n localCleanup();\n cleanup = null;\n EventObject = null;\n raisedEvents.Dispose();\n }\n }\n\n /// \n /// Called by the auto-generated IL, to record information about a raised event.\n /// \n [UsedImplicitly]\n public void RecordEvent(params object[] parameters)\n {\n lock (lockable)\n {\n raisedEvents.Add(new RecordedEvent(utcNow(), sequenceGenerator.Increment(), parameters));\n }\n }\n\n /// \n /// Resets recorder to clear records of events raised so far.\n /// \n public void Reset()\n {\n lock (lockable)\n {\n while (raisedEvents.Count > 0)\n {\n raisedEvents.TryTake(out _);\n }\n }\n }\n\n IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n\n public IEnumerator GetEnumerator()\n {\n foreach (RecordedEvent @event in raisedEvents.ToArray())\n {\n yield return new OccurredEvent\n {\n EventName = EventName,\n Parameters = @event.Parameters,\n TimestampUtc = @event.TimestampUtc,\n Sequence = @event.Sequence\n };\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeAssignableTo.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeAssignableTo\n {\n [Fact]\n public void When_object_type_is_matched_against_null_type_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeAssignableTo(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"type\");\n }\n\n [Fact]\n public void When_its_own_type_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_its_base_type_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_an_implemented_interface_type_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_an_unrelated_type_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n Action act = () => someObject.Should().BeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to {typeof(DateTime)}*failure message*{typeof(DummyImplementingClass)} is not*\");\n }\n\n [Fact]\n public void When_to_the_expected_type_it_should_cast_the_returned_object_for_chaining()\n {\n // Arrange\n var someObject = new Exception(\"Actual Message\");\n\n // Act\n Action act = () => someObject.Should().BeAssignableTo().Which.Message.Should().Be(\"Other Message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Expected*Actual*Other*\");\n }\n\n [Fact]\n public void When_a_null_instance_is_asserted_to_be_assignableOfT_it_should_fail()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someObject.Should().BeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to {typeof(DateTime)}*failure message*found *\");\n }\n\n [Fact]\n public void When_its_own_type_instance_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo(typeof(DummyImplementingClass));\n }\n\n [Fact]\n public void When_its_base_type_instance_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo(typeof(DummyBaseClass));\n }\n\n [Fact]\n public void When_an_implemented_interface_type_instance_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().BeAssignableTo(typeof(IDisposable));\n }\n\n [Fact]\n public void When_an_implemented_open_generic_interface_type_instance_it_should_succeed()\n {\n // Arrange\n var someObject = new List();\n\n // Act / Assert\n someObject.Should().BeAssignableTo(typeof(IList<>));\n }\n\n [Fact]\n public void When_a_null_instance_is_asserted_to_be_assignable_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someObject.Should().BeAssignableTo(typeof(DateTime), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to {typeof(DateTime)}*failure message*found *\");\n }\n\n [Fact]\n public void When_an_unrelated_type_instance_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().BeAssignableTo(typeof(DateTime), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to {typeof(DateTime)}*failure message*{typeof(DummyImplementingClass)} is not*\");\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_type_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().BeAssignableTo(typeof(IList<>), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*assignable to System.Collections.Generic.IList*failure message*{typeof(DummyImplementingClass)} is not*\");\n }\n\n [Fact]\n public void When_an_assertion_fails_on_BeAssignableTo_succeeding_message_should_be_included()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var item = string.Empty;\n item.Should().BeAssignableTo();\n item.Should().BeAssignableTo();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * to be assignable to int, but string is not.*\" +\n \"Expected * to be assignable to long, but string is not.\");\n }\n }\n\n public class NotBeAssignableTo\n {\n [Fact]\n public void When_object_type_is_matched_negatively_against_null_type_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().NotBeAssignableTo(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"type\");\n }\n\n [Fact]\n public void When_its_own_type_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should()\n .NotBeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n $\"*not be assignable to {typeof(DummyImplementingClass)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void When_its_base_type_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n $\"*not be assignable to {typeof(DummyBaseClass)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void When_an_implemented_interface_type_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(\"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*not be assignable to {typeof(IDisposable)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void When_an_unrelated_type_and_asserting_not_assignable_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().NotBeAssignableTo();\n }\n\n [Fact]\n public void\n When_not_to_the_unexpected_type_and_asserting_not_assignable_it_should_not_cast_the_returned_object_for_chaining()\n {\n // Arrange\n var someObject = new Exception(\"Actual Message\");\n\n // Act\n Action act = () => someObject.Should().NotBeAssignableTo()\n .And.Subject.Should().BeOfType()\n .Which.Message.Should().Be(\"Other Message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Expected*Actual*Other*\");\n }\n\n [Fact]\n public void When_its_own_type_instance_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(typeof(DummyImplementingClass), \"because we want to test the failure {0}\",\n \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n $\"*not be assignable to {typeof(DummyImplementingClass)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void When_its_base_type_instance_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should()\n .NotBeAssignableTo(typeof(DummyBaseClass), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n $\"*not be assignable to {typeof(DummyBaseClass)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void\n When_an_implemented_interface_type_instance_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(typeof(IDisposable), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage($\"*not be assignable to {typeof(IDisposable)}*failure message*{typeof(DummyImplementingClass)} is*\");\n }\n\n [Fact]\n public void\n When_an_implemented_open_generic_interface_type_instance_and_asserting_not_assignable_it_should_fail_with_a_useful_message()\n {\n // Arrange\n var someObject = new List();\n\n Action act = () =>\n someObject.Should().NotBeAssignableTo(typeof(IList<>), \"because we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\"*not be assignable to System.Collections.Generic.IList*failure message*System.Collections.Generic.List is*\");\n }\n\n [Fact]\n public void When_a_null_instance_is_asserted_to_not_be_assignable_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someObject.Should().NotBeAssignableTo(typeof(DateTime), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"*not be assignable to {typeof(DateTime)}*failure message*found *\");\n }\n\n [Fact]\n public void When_an_unrelated_type_instance_and_asserting_not_assignable_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().NotBeAssignableTo(typeof(DateTime), \"because we want to test the failure {0}\", \"message\");\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_type_and_asserting_not_assignable_it_should_succeed()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act / Assert\n someObject.Should().NotBeAssignableTo(typeof(IList<>), \"because we want to test the failure {0}\", \"message\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.Satisfy.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The Satisfy specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class Satisfy\n {\n [Fact]\n public void When_collection_element_at_each_position_matches_predicate_at_same_position_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 1,\n element => element == 2,\n element => element == 3);\n }\n\n [Fact]\n public void When_collection_element_at_each_position_matches_predicate_at_reverse_position_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 3,\n element => element == 2,\n element => element == 1);\n }\n\n [Fact]\n public void When_one_element_does_not_have_matching_predicate_Satisfy_should_throw()\n {\n // Arrange\n int[] collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().Satisfy(\n element => element == 3,\n element => element == 1,\n element => element == 2);\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected collection to satisfy all predicates, but:\n *The following predicates did not have matching elements:\n *(element == 3)\n \"\"\");\n }\n\n [Fact]\n public void\n When_some_predicates_have_multiple_matching_elements_and_most_restricitve_predicates_are_last_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 4];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 1 || element == 2 || element == 3 || element == 4,\n element => element == 1 || element == 2 || element == 3,\n element => element == 1 || element == 2,\n element => element == 1);\n }\n\n [Fact]\n public void\n When_some_predicates_have_multiple_matching_elements_and_most_restricitve_predicates_are_first_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 4];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 1,\n element => element == 1 || element == 2,\n element => element == 1 || element == 2 || element == 3,\n element => element == 1 || element == 2 || element == 3 || element == 4);\n }\n\n [Fact]\n public void When_second_predicate_matches_first_and_last_element_and_solution_exists_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Satisfy(\n element => element == 1,\n element => element == 1 || element == 3,\n element => element == 2);\n }\n\n [Fact]\n public void\n When_assertion_fails_then_failure_message_must_contain_predicates_without_matching_elements_and_elements_without_matching_predicates()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\", Number = 1 },\n new SomeClass { Text = \"two\", Number = 3 },\n new SomeClass { Text = \"three\", Number = 3 },\n new SomeClass { Text = \"four\", Number = 4 },\n ];\n\n // Act\n Action act = () => collection.Should().Satisfy(\n new Expression>[]\n {\n element => element.Text == \"four\" && element.Number == 4,\n element => element.Text == \"two\" && element.Number == 2,\n },\n because: \"we want to test formatting ({0})\",\n becauseArgs: \"args\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected collection to satisfy all predicates because we want to test formatting (args), but:\n *The following predicates did not have matching elements:\n *(element.Text == \"two\") AndAlso (element.Number == 2)\n *The following elements did not match any predicate:\n *Index: 0, Element:*AwesomeAssertions.Specs.Collections.CollectionAssertionSpecs+SomeClass*{*Number = 1*Text = \"one\"*}\n *Index: 1, Element:*AwesomeAssertions.Specs.Collections.CollectionAssertionSpecs+SomeClass*{*Number = 3*Text = \"two\"*}\n *Index: 2, Element:*AwesomeAssertions.Specs.Collections.CollectionAssertionSpecs+SomeClass*{*Number = 3*Text = \"three\"*}\n \"\"\");\n }\n\n [Fact]\n public void When_Satisfy_asserting_against_null_inspectors_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().Satisfy(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify against a collection of predicates*\");\n }\n\n [Fact]\n public void When_asserting_against_empty_inspectors_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().Satisfy();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify against an empty collection of predicates*\");\n }\n\n [Fact]\n public void When_asserting_collection_which_is_null_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n collection.Should().Satisfy(\n new Expression>[]\n {\n element => element == 1,\n element => element == 2,\n },\n because: \"we want to test the failure message ({0})\",\n becauseArgs: \"args\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to satisfy all predicates because we want to test the failure message (args), but collection is .\");\n }\n\n [Fact]\n public void When_asserting_collection_which_is_empty_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().Satisfy(\n new Expression>[]\n {\n element => element == 1,\n element => element == 2,\n },\n because: \"we want to test the failure message ({0})\",\n becauseArgs: \"args\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to satisfy all predicates because we want to test the failure message (args), but collection is empty.\");\n }\n\n [Fact]\n public void When_elements_are_integers_assertion_fails_then_failure_message_must_be_readable()\n {\n // Arrange\n var collection = new List { 1, 2, 3 };\n\n // Act\n Action act = () => collection.Should().Satisfy(\n element => element == 2);\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected collection to satisfy all predicates, but:\n *The following elements did not match any predicate:\n *Index: 0, Element: 1\n *Index: 2, Element: 3\n \"\"\");\n }\n }\n\n private class SomeClass\n {\n public string Text { get; set; }\n\n public int Number { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/DictionaryExtensions.cs", "using System;\nusing System.Collections.Generic;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\ninternal static class DictionaryExtensions\n{\n public static void Add(this IDictionary> dictionary, TKey key, TValue value) =>\n dictionary.GetOrAdd(key).Add(value);\n\n public static TValue GetOrAdd(this IDictionary dictionary, TKey key)\n where TValue : new() =>\n dictionary.GetOrAdd(key, static () => new TValue());\n\n public static TValue GetOrAdd(this IDictionary dictionary, TKey key, Func newValue)\n {\n if (!dictionary.TryGetValue(key, out TValue result))\n {\n result = newValue();\n dictionary[key] = result;\n }\n\n return result;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeDecoratedWithOrInherit.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeDecoratedWithOrInherit specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeDecoratedWithOrInherit\n {\n [Fact]\n public void When_type_inherits_expected_attribute_it_succeeds()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithAttribute.Should().BeDecoratedWithOrInherit();\n }\n\n [Fact]\n public void When_type_inherits_expected_attribute_it_should_allow_chaining()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithAttribute.Should().BeDecoratedWithOrInherit()\n .Which.IsEnabled.Should().BeTrue();\n }\n\n [Fact]\n public void When_type_does_not_inherit_expected_attribute_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithoutAttribute);\n\n // Act\n Action act = () =>\n type.Should().BeDecoratedWithOrInherit(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithoutAttribute to be decorated with or inherit *.DummyClassAttribute \" +\n \"*failure message*, but the attribute was not found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_BeDecoratedWithOrInherit_it_should_throw()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () => typeWithAttribute.Should()\n .BeDecoratedWithOrInherit(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_type_inherits_expected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithAttribute.Should()\n .BeDecoratedWithOrInherit(a => a.Name == \"Expected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_type_inherits_expected_attribute_with_the_expected_properties_it_should_allow_chaining()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithAttribute.Should()\n .BeDecoratedWithOrInherit(a => a.Name == \"Expected\")\n .Which.IsEnabled.Should().BeTrue();\n }\n\n [Fact]\n public void When_type_inherits_expected_attribute_that_has_an_unexpected_property_it_fails()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should()\n .BeDecoratedWithOrInherit(a => a.Name == \"Unexpected\" && a.IsEnabled);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithInheritedAttribute to be decorated with or inherit *.DummyClassAttribute \" +\n \"that matches (a.Name == \\\"Unexpected\\\")*a.IsEnabled, but no matching attribute was found.\");\n }\n }\n\n public class NotBeDecoratedWithOrInherit\n {\n [Fact]\n public void When_type_does_not_inherit_unexpected_attribute_it_succeeds()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithoutAttribute);\n\n // Act / Assert\n typeWithoutAttribute.Should().NotBeDecoratedWithOrInherit();\n }\n\n [Fact]\n public void When_type_inherits_unexpected_attribute_it_fails()\n {\n // Arrange\n Type typeWithAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () =>\n typeWithAttribute.Should()\n .NotBeDecoratedWithOrInherit(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithInheritedAttribute to not be decorated with or inherit *.DummyClassAttribute \" +\n \"*failure message* attribute was found.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotBeDecoratedWithOrInherit_it_should_throw()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () => typeWithoutAttribute.Should()\n .NotBeDecoratedWithOrInherit(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_type_does_not_inherit_unexpected_attribute_with_the_expected_properties_it_succeeds()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act / Assert\n typeWithoutAttribute.Should()\n .NotBeDecoratedWithOrInherit(a => a.Name == \"Unexpected\" && a.IsEnabled);\n }\n\n [Fact]\n public void When_type_does_not_inherit_expected_attribute_that_has_an_unexpected_property_it_fails()\n {\n // Arrange\n Type typeWithoutAttribute = typeof(ClassWithInheritedAttribute);\n\n // Act\n Action act = () =>\n typeWithoutAttribute.Should()\n .NotBeDecoratedWithOrInherit(a => a.Name == \"Expected\" && a.IsEnabled);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithInheritedAttribute to not be decorated with or inherit *.DummyClassAttribute \" +\n \"that matches (a.Name == \\\"Expected\\\") * a.IsEnabled, but a matching attribute was found.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.BeAfter.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class BeAfter\n {\n [Fact]\n public void When_asserting_subject_timeonly_is_after_earlier_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 123);\n TimeOnly expectation = new(15, 06, 03, 45);\n\n // Act/Assert\n subject.Should().BeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_after_earlier_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <15:06:03.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_after_later_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <15:06:05.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_after_later_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 05);\n\n // Act/Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_after_the_same_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 145);\n TimeOnly expectation = new(15, 06, 04, 145);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <15:06:04.145>, but found <15:06:04.145>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_after_the_same_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 123);\n TimeOnly expectation = new(15, 06, 04, 123);\n\n // Act/Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_after_earlier_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 07);\n TimeOnly expectation = new(15, 06);\n\n // Act/Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_after_earlier_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <15:06:03.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_after_the_same_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 04);\n\n // Act/Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_after_the_same_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06);\n TimeOnly expectation = new(15, 06);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <15:06:00.000>, but found <15:06:00.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_after_later_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or after <15:06:05.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_after_later_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 05);\n\n // Act/Assert\n subject.Should().NotBeOnOrAfter(expectation);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/ShouldCallParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class ShouldCallParsingStrategy : IParsingStrategy\n{\n private const string ShouldCall = \".Should\";\n\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (statement.Length >= ShouldCall.Length + 1)\n {\n var leftIndex = statement.Length - 2;\n var rightIndex = ShouldCall.Length - 1;\n\n for (var i = 0; i < ShouldCall.Length; i++)\n {\n if (statement[leftIndex - i] != ShouldCall[rightIndex - i])\n {\n return ParsingState.InProgress;\n }\n }\n\n if (statement[^1] is not ('(' or '.'))\n {\n return ParsingState.InProgress;\n }\n\n statement.Remove(statement.Length - (ShouldCall.Length + 1), ShouldCall.Length + 1);\n return ParsingState.Done;\n }\n\n return ParsingState.InProgress;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return false;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.BeAfter.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class BeAfter\n {\n [Fact]\n public void When_asserting_subject_dateonly_is_after_earlier_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act/Assert\n subject.Should().BeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_after_earlier_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_after_later_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_after_later_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act/Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_after_the_same_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_after_the_same_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_after_earlier_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act/Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_after_earlier_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_after_the_same_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_after_the_same_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_after_later_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_after_later_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act/Assert\n subject.Should().NotBeOnOrAfter(expectation);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeExactly.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeExactly\n {\n [Fact]\n public void Should_succeed_when_asserting_value_is_exactly_equal_to_the_same_value()\n {\n // Arrange\n DateTimeOffset dateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset sameDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().BeExactly(sameDateTime);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_value_is_exactly_equal_to_the_same_nullable_value()\n {\n // Arrange\n DateTimeOffset dateTime = 4.June(2016).ToDateTimeOffset();\n DateTimeOffset? sameDateTime = 4.June(2016).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().BeExactly(sameDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_value_is_exactly_equal_to_a_different_value()\n {\n // Arrange\n var dateTime = 10.March(2012).WithOffset(1.Hours());\n var otherDateTime = dateTime.ToUniversalTime();\n\n // Act\n Action act = () => dateTime.Should().BeExactly(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dateTime to be exactly <2012-03-09 23:00:00 +0h>*failure message, but it was <2012-03-10 +1h>.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_value_is_exactly_equal_to_a_different_nullable_value()\n {\n // Arrange\n DateTimeOffset dateTime = 10.March(2012).WithOffset(1.Hours());\n DateTimeOffset? otherDateTime = dateTime.ToUniversalTime();\n\n // Act\n Action act = () => dateTime.Should().BeExactly(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dateTime to be exactly <2012-03-09 23:00:00 +0h>*failure message, but it was <2012-03-10 +1h>.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_value_is_exactly_equal_to_the_same_nullable_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset? nullableDateTimeB = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTimeA.Should().BeExactly(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_null_value_exactly_equals_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = null;\n DateTimeOffset? nullableDateTimeB = null;\n\n // Act / Assert\n nullableDateTimeA.Should().BeExactly(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_value_exactly_equals_a_different_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset? nullableDateTimeB = new DateTime(2016, 06, 06).ToDateTimeOffset();\n\n // Act\n Action action = () =>\n nullableDateTimeA.Should().BeExactly(nullableDateTimeB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_null_value_is_exactly_equal_to_another_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n DateTimeOffset expectation = 27.March(2016).ToDateTimeOffset(1.Hours());\n\n // Act\n Action action = () =>\n nullableDateTime.Should().BeExactly(expectation, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateTime to be exactly <2016-03-27 +1h> because we want to test the failure message, but found a DateTimeOffset.\");\n }\n }\n\n public class NotBeExactly\n {\n [Fact]\n public void Should_succeed_when_asserting_value_is_not_exactly_equal_to_a_different_value()\n {\n // Arrange\n DateTimeOffset dateTime = 10.March(2012).WithOffset(1.Hours());\n DateTimeOffset otherDateTime = dateTime.ToUniversalTime();\n\n // Act / Assert\n dateTime.Should().NotBeExactly(otherDateTime);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_value_is_not_exactly_equal_to_a_different_nullable_value()\n {\n // Arrange\n DateTimeOffset dateTime = 10.March(2012).WithOffset(1.Hours());\n DateTimeOffset? otherDateTime = dateTime.ToUniversalTime();\n\n // Act / Assert\n dateTime.Should().NotBeExactly(otherDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_value_is_not_exactly_equal_to_the_same_value()\n {\n // Arrange\n var dateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n var sameDateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n\n // Act\n Action act =\n () => dateTime.Should().NotBeExactly(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dateTime to be exactly <2012-03-10 +1h> because we want to test the failure message, but it was.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_value_is_not_exactly_equal_to_the_same_nullable_value()\n {\n // Arrange\n DateTimeOffset dateTime = new(10.March(2012), 1.Hours());\n DateTimeOffset? sameDateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n\n // Act\n Action act =\n () => dateTime.Should().NotBeExactly(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dateTime to be exactly <2012-03-10 +1h> because we want to test the failure message, but it was.\");\n }\n\n [Fact]\n public void When_time_is_not_at_exactly_20_minutes_before_another_time_it_should_throw()\n {\n // Arrange\n DateTimeOffset target = 1.January(0001).At(12, 55).ToDateTimeOffset();\n DateTimeOffset subject = 1.January(0001).At(12, 36).ToDateTimeOffset();\n\n // Act\n Action act =\n () => subject.Should().BeExactly(TimeSpan.FromMinutes(20)).Before(target, \"{0} minutes is enough\", 20);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <12:36:00 +0h> to be exactly 20m before <12:55:00 +0h> because 20 minutes is enough, but it is behind by 19m.\");\n }\n\n [Fact]\n public void When_time_is_exactly_90_seconds_before_another_time_it_should_not_throw()\n {\n // Arrange\n DateTimeOffset target = 1.January(0001).At(12, 55).ToDateTimeOffset();\n DateTimeOffset subject = 1.January(0001).At(12, 53, 30).ToDateTimeOffset();\n\n // Act / Assert\n subject.Should().BeExactly(TimeSpan.FromSeconds(90)).Before(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_exactly_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 20).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeExactly(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:20 +0h> to be exactly 10s after <00:00:30 +0h>, but it is behind by 10s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_exactly_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 40).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeExactly(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:40 +0h> to be exactly 10s before <00:00:30 +0h>, but it is ahead by 10s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeGreaterThanOrEqualTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void When_a_value_is_greater_than_or_equal_to_smaller_value_it_should_not_throw()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act / Assert\n value.Should().BeGreaterThanOrEqualTo(smallerValue);\n }\n\n [Fact]\n public void When_a_value_is_greater_than_or_equal_to_same_value_it_should_not_throw()\n {\n // Arrange\n int value = 2;\n int sameValue = 2;\n\n // Act / Assert\n value.Should().BeGreaterThanOrEqualTo(sameValue);\n }\n\n [Fact]\n public void When_a_value_is_greater_than_or_equal_to_greater_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(greaterValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_greater_than_or_equal_to_greater_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n\n // Act\n Action act =\n () => value.Should()\n .BeGreaterThanOrEqualTo(greaterValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be greater than or equal to 3 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_greater_than_or_equal_to_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_or_equal_to_another_float()\n {\n // Act\n Action act = () => float.NaN.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_cannot_be_greater_than_or_equal_to_NaN()\n {\n // Act\n Action act = () => 3.4F.Should().BeGreaterThanOrEqualTo(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_or_equal_to_another_double()\n {\n // Act\n Action act = () => double.NaN.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_greater_or_equal_to_NaN()\n {\n // Act\n Action act = () => 3.4D.Should().BeGreaterThanOrEqualTo(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act / Assert\n value.Should().BeGreaterThanOrEqualTo(smallerValue).And.Be(2);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ExpressionExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class ExpressionExtensions\n{\n /// \n /// Gets the of an returning a property.\n /// \n /// is .\n public static PropertyInfo GetPropertyInfo(this Expression> expression)\n {\n Guard.ThrowIfArgumentIsNull(expression, nameof(expression), \"Expected a property expression, but found .\");\n\n MemberInfo memberInfo = AttemptToGetMemberInfoFromExpression(expression);\n\n if (memberInfo is not PropertyInfo propertyInfo)\n {\n throw new ArgumentException($\"Cannot use <{expression.Body}> when a property expression is expected.\",\n nameof(expression));\n }\n\n return propertyInfo;\n }\n\n private static MemberInfo AttemptToGetMemberInfoFromExpression(Expression> expression) =>\n (((expression.Body as UnaryExpression)?.Operand ?? expression.Body) as MemberExpression)?.Member;\n\n /// \n /// Gets one or more dotted paths of property names representing the property expression, including the declaring type.\n /// \n /// \n /// E.g. [\"Parent.Child.Sibling.Name\"] or [\"A.Dotted.Path1\", \"A.Dotted.Path2\"].\n /// \n /// is .\n#pragma warning disable MA0051\n public static IEnumerable GetMemberPaths(\n this Expression> expression)\n#pragma warning restore MA0051\n {\n Guard.ThrowIfArgumentIsNull(expression, nameof(expression), \"Expected an expression, but found .\");\n\n string singlePath = null;\n List selectors = [];\n List declaringTypes = [];\n Expression node = expression;\n\n while (node is not null)\n {\n#pragma warning disable IDE0010 // System.Linq.Expressions.ExpressionType has many members we do not care about\n switch (node.NodeType)\n#pragma warning restore IDE0010\n {\n case ExpressionType.Lambda:\n node = ((LambdaExpression)node).Body;\n break;\n\n case ExpressionType.Convert:\n case ExpressionType.ConvertChecked:\n var unaryExpression = (UnaryExpression)node;\n node = unaryExpression.Operand;\n break;\n\n case ExpressionType.MemberAccess:\n var memberExpression = (MemberExpression)node;\n node = memberExpression.Expression;\n\n singlePath = $\"{memberExpression.Member.Name}.{singlePath}\";\n declaringTypes.Add(memberExpression.Member.DeclaringType);\n break;\n\n case ExpressionType.ArrayIndex:\n var binaryExpression = (BinaryExpression)node;\n var indexExpression = (ConstantExpression)binaryExpression.Right;\n node = binaryExpression.Left;\n\n singlePath = $\"[{indexExpression.Value}].{singlePath}\";\n break;\n\n case ExpressionType.Parameter:\n node = null;\n break;\n\n case ExpressionType.Call:\n var methodCallExpression = (MethodCallExpression)node;\n\n if (methodCallExpression is not\n { Method.Name: \"get_Item\", Arguments: [ConstantExpression argumentExpression] })\n {\n throw new ArgumentException(GetUnsupportedExpressionMessage(expression.Body), nameof(expression));\n }\n\n node = methodCallExpression.Object;\n singlePath = $\"[{argumentExpression.Value}].{singlePath}\";\n break;\n case ExpressionType.New:\n var newExpression = (NewExpression)node;\n\n foreach (Expression member in newExpression.Arguments)\n {\n var expr = member.ToString();\n selectors.Add(expr[expr.IndexOf('.', StringComparison.Ordinal)..]);\n declaringTypes.Add(((MemberExpression)member).Member.DeclaringType);\n }\n\n node = null;\n break;\n\n default:\n throw new ArgumentException(GetUnsupportedExpressionMessage(expression.Body), nameof(expression));\n }\n }\n\n Type declaringType = declaringTypes.FirstOrDefault() ?? typeof(TDeclaringType);\n\n if (singlePath is null)\n {\n#if NET47 || NETSTANDARD2_0\n return selectors.Select(selector =>\n GetNewInstance(declaringType, selector)).ToList();\n#else\n return selectors.ConvertAll(selector =>\n GetNewInstance(declaringType, selector));\n#endif\n }\n\n return [GetNewInstance(declaringType, singlePath)];\n }\n\n private static MemberPath GetNewInstance(Type declaringType, string dottedPath) =>\n new(typeof(TReflectedType), declaringType, dottedPath.Trim('.').Replace(\".[\", \"[\", StringComparison.Ordinal));\n\n /// \n /// Gets the first dotted path of property names collected by \n /// from a given property expression, including the declaring type.\n /// \n /// \n /// E.g. Parent.Child.Sibling.Name.\n /// \n /// is .\n public static MemberPath GetMemberPath(\n this Expression> expression)\n {\n return expression.GetMemberPaths().FirstOrDefault() ?? new MemberPath(\"\");\n }\n\n /// \n /// Validates that the expression can be used to construct a .\n /// \n /// is .\n public static void ValidateMemberPath(\n this Expression> expression)\n {\n Guard.ThrowIfArgumentIsNull(expression, nameof(expression), \"Expected an expression, but found .\");\n\n Expression node = expression;\n\n while (node is not null)\n {\n#pragma warning disable IDE0010 // System.Linq.Expressions.ExpressionType has many members we do not care about\n switch (node.NodeType)\n#pragma warning restore IDE0010\n {\n case ExpressionType.Lambda:\n node = ((LambdaExpression)node).Body;\n break;\n\n case ExpressionType.Convert:\n case ExpressionType.ConvertChecked:\n var unaryExpression = (UnaryExpression)node;\n node = unaryExpression.Operand;\n break;\n\n case ExpressionType.MemberAccess:\n var memberExpression = (MemberExpression)node;\n node = memberExpression.Expression;\n\n break;\n\n case ExpressionType.ArrayIndex:\n var binaryExpression = (BinaryExpression)node;\n node = binaryExpression.Left;\n\n break;\n\n case ExpressionType.Parameter:\n node = null;\n break;\n\n case ExpressionType.Call:\n var methodCallExpression = (MethodCallExpression)node;\n\n if (methodCallExpression is not { Method.Name: \"get_Item\", Arguments: [ConstantExpression] })\n {\n throw new ArgumentException(GetUnsupportedExpressionMessage(expression.Body), nameof(expression));\n }\n\n node = methodCallExpression.Object;\n break;\n\n default:\n throw new ArgumentException(GetUnsupportedExpressionMessage(expression.Body), nameof(expression));\n }\n }\n }\n\n private static string GetUnsupportedExpressionMessage(Expression expression) =>\n $\"Expression <{expression}> cannot be used to select a member.\";\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Streams/BufferedStreamAssertionSpecs.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing System.IO;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Streams;\n\npublic class BufferedStreamAssertionSpecs\n{\n public class HaveBufferSize\n {\n [Fact]\n public void When_a_stream_has_the_expected_buffer_size_it_should_succeed()\n {\n // Arrange\n using var stream = new BufferedStream(new MemoryStream(), 10);\n\n // Act / Assert\n stream.Should().HaveBufferSize(10);\n }\n\n [Fact]\n public void When_a_stream_has_an_unexpected_buffer_size_should_fail()\n {\n // Arrange\n using var stream = new BufferedStream(new MemoryStream(), 1);\n\n // Act\n Action act = () =>\n stream.Should().HaveBufferSize(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the buffer size of stream to be 10 *failure message*, but it was 1.\");\n }\n\n [Fact]\n public void When_null_have_buffer_size_should_fail()\n {\n // Arrange\n BufferedStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().HaveBufferSize(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the buffer size of stream to be 10 *failure message*, but found a reference.\");\n }\n }\n\n public class NotHaveBufferSize\n {\n [Fact]\n public void When_a_stream_does_not_have_an_unexpected_buffer_size_it_should_succeed()\n {\n // Arrange\n using var stream = new BufferedStream(new MemoryStream(), 1);\n\n // Act / Assert\n stream.Should().NotHaveBufferSize(10);\n }\n\n [Fact]\n public void When_a_stream_does_have_the_unexpected_buffer_size_it_should_fail()\n {\n // Arrange\n using var stream = new BufferedStream(new MemoryStream(), 10);\n\n // Act\n Action act = () =>\n stream.Should().NotHaveBufferSize(10, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the buffer size of stream not to be 10 *failure message*, but it was.\");\n }\n\n [Fact]\n public void When_null_not_have_buffer_size_should_fail()\n {\n // Arrange\n BufferedStream stream = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n stream.Should().NotHaveBufferSize(10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the buffer size of stream not to be 10 *failure message*, but found a reference.\");\n }\n }\n}\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeAfter.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeAfter\n {\n [Fact]\n public void When_asserting_subject_datetime_is_after_earlier_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act / Assert\n subject.Should().BeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_after_later_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_after_the_same_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04>, but found <2016-06-04>.\");\n }\n }\n\n public class NotBeAfter\n {\n [Fact]\n public void When_asserting_subject_datetime_is_not_after_earlier_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_after_later_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act / Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_after_the_same_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().NotBeAfter(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeLessThanOrEqualTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void When_a_value_is_less_than_or_equal_to_greater_value_it_should_not_throw()\n {\n // Arrange\n int value = 1;\n int greaterValue = 2;\n\n // Act / Assert\n value.Should().BeLessThanOrEqualTo(greaterValue);\n }\n\n [Fact]\n public void When_a_value_is_less_than_or_equal_to_same_value_it_should_not_throw()\n {\n // Arrange\n int value = 2;\n int sameValue = 2;\n\n // Act / Assert\n value.Should().BeLessThanOrEqualTo(sameValue);\n }\n\n [Fact]\n public void When_a_value_is_less_than_or_equal_to_smaller_value_it_should_throw()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(smallerValue);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_value_is_less_than_or_equal_to_smaller_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 2;\n int smallerValue = 1;\n\n // Act\n Action act = () =>\n value.Should().BeLessThanOrEqualTo(smallerValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be less than or equal to 1 because we want to test the failure message, but found 2.\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_less_than_or_equal_to_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_or_equal_to_another_float()\n {\n // Act\n Action act = () => float.NaN.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_float_can_never_be_less_than_or_equal_to_NaN()\n {\n // Act\n Action act = () => 3.4F.Should().BeLessThanOrEqualTo(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_or_equal_to_another_double()\n {\n // Act\n Action act = () => double.NaN.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_less_than_or_equal_to_NaN()\n {\n // Act\n Action act = () => 3.4D.Should().BeLessThanOrEqualTo(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void Chaining_after_one_assertion()\n {\n // Arrange\n int value = 1;\n int greaterValue = 2;\n\n // Act / Assert\n value.Should().BeLessThanOrEqualTo(greaterValue).And.Be(1);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.AllBeAssignableTo.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The AllBeAssignableTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class AllBeAssignableTo\n {\n [Fact]\n public void When_the_types_in_a_collection_is_matched_against_a_null_type_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expectedType\");\n }\n\n [Fact]\n public void All_items_in_an_empty_collection_are_assignable_to_a_generic_type()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_collection_is_null_then_all_be_assignable_to_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllBeAssignableTo(typeof(object), \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be object *failure message*, but found collection is .\");\n }\n\n [Fact]\n public void All_items_in_an_empty_collection_are_assignable_to_a_type()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo(typeof(int));\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_expected_type_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo(typeof(int));\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_expected_generic_type_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_matching_a_collection_against_a_type_it_should_return_the_casted_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo()\n .Which.Should().Equal(1, 2, 3);\n }\n\n [Fact]\n public void When_all_of_the_types_in_a_collection_match_the_type_or_subtype_it_should_succeed()\n {\n // Arrange\n var collection = new object[] { new Exception(), new ArgumentException(\"foo\") };\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_one_of_the_types_does_not_match_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { 1, \"2\", 3 };\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(typeof(int), \"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found {int, string, int}.\");\n }\n\n [Fact]\n public void When_one_of_the_types_does_not_match_the_generic_type_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { 1, \"2\", 3 };\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found {int, string, int}.\");\n }\n\n [Fact]\n public void When_one_of_the_elements_is_null_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n var collection = new object[] { 1, null, 3 };\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found a null element.\");\n }\n\n [Fact]\n public void When_collection_is_of_matching_types_it_should_succeed()\n {\n // Arrange\n Type[] collection = [typeof(Exception), typeof(ArgumentException)];\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_collection_of_types_contains_one_type_that_does_not_match_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n Type[] collection = [typeof(int), typeof(string), typeof(int)];\n\n // Act\n Action act = () => collection.Should().AllBeAssignableTo(\"because they are of different type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found {int, string, int}.\");\n }\n\n [Fact]\n public void When_collection_of_types_and_objects_are_all_of_matching_types_it_should_succeed()\n {\n // Arrange\n var collection = new object[] { typeof(int), 2, typeof(int) };\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_collection_of_different_types_and_objects_are_all_assignable_to_type_it_should_succeed()\n {\n // Arrange\n var collection = new object[] { typeof(Exception), new ArgumentException(\"foo\") };\n\n // Act / Assert\n collection.Should().AllBeAssignableTo();\n }\n\n [Fact]\n public void When_collection_is_null_then_all_be_assignable_toOfT_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().AllBeAssignableTo(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be object *failure message*, but found collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeOnOrAfter.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeOnOrAfter\n {\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_after_earlier_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act / Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_after_the_same_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_after_later_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().BeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or after <2016-06-05>, but found <2016-06-04>.\");\n }\n }\n\n public class NotBeOnOrAfter\n {\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_after_earlier_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_after_the_same_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_after_later_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act / Assert\n subject.Should().NotBeOnOrAfter(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeOnOrBefore.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeOnOrBefore\n {\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_before_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act / Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_before_the_same_date_as_the_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_before_earlier_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().BeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03>, but found <2016-06-04>.\");\n }\n }\n\n public class NotBeOnOrBefore\n {\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_before_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_on_or_before_the_same_date_as_the_expected_datetime_should_throw()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_on_or_before_earlier_expected_datetime_should_succeed()\n {\n // Arrange\n DateTime subject = new(2016, 06, 04);\n DateTime expectation = new(2016, 06, 03);\n\n // Act / Assert\n subject.Should().NotBeOnOrBefore(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.StartWithEquivalentOf.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]StartWithEquivalentOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class StartWithEquivalentOf\n {\n [Fact]\n public void Succeed_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act\n Action act = () => actual.Should().StartWithEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_start_with_another()\n {\n // Arrange\n string actual = \"test with suffix\";\n string expect = \"TEST\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_start_with_another()\n {\n // Arrange\n string actual = \" test with suffix\";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_start_with_another()\n {\n // Arrange\n string actual = \"test with suffix \";\n string expect = \"test\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_start_with_another()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n with suffix\";\n string expect = \"\\r\\nA\\rB\\nC\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n }\n\n [Fact]\n public void When_start_of_string_differs_by_case_only_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedPrefix = \"Ab\";\n\n // Act / Assert\n actual.Should().StartWithEquivalentOf(expectedPrefix);\n }\n\n [Fact]\n public void When_start_of_string_does_not_meet_equivalent_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWithEquivalentOf(\"bc\", \"because it should start\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with equivalent of \\\"bc\\\" because it should start, but \\\"ABC\\\" differs near \\\"ABC\\\" (index 0).\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void\n When_start_of_string_does_not_meet_equivalent_and_one_of_them_is_long_it_should_display_both_strings_on_separate_line()\n {\n // Act\n Action act = () => \"ABCDEFGHI\".Should().StartWithEquivalentOf(\"abcddfghi\", \"it should {0}\", \"start\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with equivalent of \" +\n \"*\\\"abcddfghi\\\" because it should start, but \" +\n \"*\\\"ABCDEFGHI\\\" differs near \\\"EFG\\\" (index 4).\");\n }\n\n [Fact]\n public void When_start_of_string_is_compared_with_equivalent_of_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWithEquivalentOf(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare string start equivalence with .*\");\n }\n\n [Fact]\n public void When_start_of_string_is_compared_with_equivalent_of_empty_string_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().StartWithEquivalentOf(\"\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_start_of_string_is_compared_with_equivalent_of_string_that_is_longer_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWithEquivalentOf(\"abcdef\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with equivalent of \" +\n \"\\\"abcdef\\\", but \" +\n \"\\\"ABC\\\" is too short.\");\n }\n\n [Fact]\n public void When_string_start_is_compared_with_equivalent_and_actual_value_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().StartWithEquivalentOf(\"AbC\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someString to start with equivalent of \\\"AbC\\\", but found .\");\n }\n }\n\n public class NotStartWithEquivalentOf\n {\n [Fact]\n public void Succeed_for_same_strings_using_custom_not_matching_comparer()\n {\n // Arrange\n var comparer = new NeverMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"ABC\";\n\n // Act / Assert\n actual.Should().NotStartWithEquivalentOf(expect, o => o.Using(comparer));\n }\n\n [Fact]\n public void Fail_for_different_strings_using_custom_matching_comparer()\n {\n // Arrange\n var comparer = new AlwaysMatchingEqualityComparer();\n string actual = \"ABC\";\n string expect = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.Using(comparer));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_not_start_with_another()\n {\n // Arrange\n string actual = \"test with suffix\";\n string expect = \"TEST\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_not_start_with_another()\n {\n // Arrange\n string actual = \" test with suffix\";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_not_start_with_another()\n {\n // Arrange\n string actual = \"test with suffix \";\n string expect = \"test\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_not_start_with_another()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n with suffix\";\n string expect = \"\\nA\\r\\nB\\rC\";\n\n // Act\n Action act = () => actual.Should().NotStartWithEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_equivalent_of_a_value_and_it_does_not_it_should_succeed()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().NotStartWithEquivalentOf(\"Bc\");\n }\n\n [Fact]\n public void\n When_asserting_string_does_not_start_with_equivalent_of_a_value_but_it_does_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWithEquivalentOf(\"aB\", \"because of some reason\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to start with equivalent of \\\"aB\\\" because of some reason, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_equivalent_of_a_value_that_is_null_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWithEquivalentOf(null);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Cannot compare start of string with .*\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_equivalent_of_a_value_that_is_empty_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWithEquivalentOf(\"\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to start with equivalent of \\\"\\\", but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_equivalent_of_a_value_and_actual_value_is_null_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () => someString.Should().NotStartWithEquivalentOf(\"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to start with equivalent of \\\"ABC\\\", but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.BeEmpty.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_without_items_is_empty()\n {\n // Arrange\n var dictionary = new Dictionary();\n\n // Act / Assert\n dictionary.Should().BeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_with_items_is_empty()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\"\n };\n\n // Act\n Action act = () => dictionary.Should().BeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_dictionary_with_items_is_empty()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\"\n };\n\n // Act\n Action act = () => dictionary.Should().BeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected dictionary to be empty because we want to test the failure message, but found at least one item {[1, One]}.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_to_be_empty_but_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().BeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void When_asserting_dictionary_with_items_is_not_empty_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\"\n };\n\n // Act / Assert\n dictionary.Should().NotBeEmpty();\n }\n\n#if !NET5_0_OR_GREATER\n [Fact]\n public void When_asserting_dictionary_with_items_is_not_empty_it_should_enumerate_the_dictionary_only_once()\n {\n // Arrange\n var trackingDictionary = new TrackingTestDictionary(new KeyValuePair(1, \"One\"));\n\n // Act\n trackingDictionary.Should().NotBeEmpty();\n\n // Assert\n trackingDictionary.Enumerator.LoopCount.Should().Be(1);\n }\n\n#endif\n\n [Fact]\n public void When_asserting_dictionary_without_items_is_not_empty_it_should_fail()\n {\n // Arrange\n var dictionary = new Dictionary();\n\n // Act\n Action act = () => dictionary.Should().NotBeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_dictionary_without_items_is_not_empty_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary();\n\n // Act\n Action act = () => dictionary.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dictionary not to be empty because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_to_be_not_empty_but_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().NotBeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.Equal.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]Equal specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class Equal\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_equal_to_the_same_collection()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3];\n\n // Act / Assert\n collection1.Should().Equal(collection2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_is_equal_to_the_same_list_of_elements()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Equal(1, 2, 3);\n }\n\n [Fact]\n public void When_both_collections_are_null_it_should_succeed()\n {\n // Arrange\n int[] nullColl = null;\n\n // Act / Assert\n nullColl.Should().Equal(null);\n }\n\n [Fact]\n public void When_two_collections_containing_nulls_are_equal_it_should_not_throw()\n {\n // Arrange\n var subject = new List { \"aaa\", null };\n var expected = new List { \"aaa\", null };\n\n // Act / Assert\n subject.Should().Equal(expected);\n }\n\n [Fact]\n public void When_two_collections_are_not_equal_because_one_item_differs_it_should_throw_using_the_reason()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 5];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {1, 2, 5} because we want to test the failure message, but {1, 2, 3} differs at index 2.\");\n }\n\n [Fact]\n public void\n When_two_collections_are_not_equal_because_the_actual_collection_contains_more_items_it_should_throw_using_the_reason()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {1, 2} because we want to test the failure message, but {1, 2, 3} contains 1 item(s) too many.\");\n }\n\n [Fact]\n public void\n When_two_collections_are_not_equal_because_the_actual_collection_contains_less_items_it_should_throw_using_the_reason()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3, 4];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {1, 2, 3, 4} because we want to test the failure message, but {1, 2, 3} contains 1 item(s) less.\");\n }\n\n [Fact]\n public void When_two_multidimensional_collections_are_not_equal_and_it_should_format_the_collections_properly()\n {\n // Arrange\n object[][] collection1 = [[1, 2], [3, 4]];\n object[][] collection2 = [[5, 6], [7, 8]];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {{5, 6}, {7, 8}}, but {{1, 2}, {3, 4}} differs at index 0.\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equal_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n collection.Should().Equal(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be equal to {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equal_but_expected_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] collection1 = null;\n\n // Act\n Action act = () =>\n collection.Should().Equal(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare collection with .*\")\n .WithParameterName(\"expectation\");\n }\n\n [Fact]\n public void When_an_empty_collection_is_compared_for_equality_to_a_non_empty_collection_it_should_throw()\n {\n // Arrange\n int[] collection1 = [];\n int[] collection2 = [1, 2, 3];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {1, 2, 3}, but found empty collection.\");\n }\n\n [Fact]\n public void When_a_non_empty_collection_is_compared_for_equality_to_an_empty_collection_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {empty}, but found {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_all_items_match_according_to_a_predicate_it_should_succeed()\n {\n // Arrange\n var actual = new List { \"ONE\", \"TWO\", \"THREE\", \"FOUR\" };\n\n var expected = new[]\n {\n new { Value = \"One\" },\n new { Value = \"Two\" },\n new { Value = \"Three\" },\n new { Value = \"Four\" }\n };\n\n // Act / Assert\n actual.Should().Equal(expected,\n (a, e) => string.Equals(a, e.Value, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_any_item_does_not_match_according_to_a_predicate_it_should_throw()\n {\n // Arrange\n var actual = new List { \"ONE\", \"TWO\", \"THREE\", \"FOUR\" };\n\n var expected = new[]\n {\n new { Value = \"One\" },\n new { Value = \"Two\" },\n new { Value = \"Three\" },\n new { Value = \"Five\" }\n };\n\n // Act\n Action action = () => actual.Should().Equal(expected,\n (a, e) => string.Equals(a, e.Value, StringComparison.OrdinalIgnoreCase));\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"*Expected*equal to*, but*differs at index 3.*\");\n }\n\n [Fact]\n public void When_both_collections_are_empty_it_should_them_as_equal()\n {\n // Arrange\n var actual = new List();\n var expected = new List();\n\n // Act / Assert\n actual.Should().Equal(expected);\n }\n\n [Fact]\n public void When_asserting_identical_collections_to_be_equal_it_should_enumerate_the_subject_only_once()\n {\n // Arrange\n var actual = new CountingGenericEnumerable([1, 2, 3]);\n int[] expected = [1, 2, 3];\n\n // Act\n actual.Should().Equal(expected);\n\n // Assert\n actual.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_identical_collections_to_not_be_equal_it_should_enumerate_the_subject_only_once()\n {\n // Arrange\n var actual = new CountingGenericEnumerable([1, 2, 3]);\n int[] expected = [1, 2, 3];\n\n // Act\n try\n {\n actual.Should().NotEqual(expected);\n }\n catch\n {\n /* we don't care about the exception, we just need to check the enumeration count */\n }\n\n // Assert\n actual.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_different_collections_to_be_equal_it_should_enumerate_the_subject_once()\n {\n // Arrange\n var actual = new CountingGenericEnumerable([1, 2, 3]);\n int[] expected = [1, 2, 4];\n\n // Act\n try\n {\n actual.Should().Equal(expected);\n }\n catch\n {\n /* we don't care about the exception, we just need to check the enumeration count */\n }\n\n // Assert\n actual.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_different_collections_to_not_be_equal_it_should_enumerate_the_subject_only_once()\n {\n // Arrange\n var actual = new CountingGenericEnumerable([1, 2, 3]);\n int[] expected = [1, 2, 4];\n\n // Act\n actual.Should().NotEqual(expected);\n\n // Assert\n actual.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void\n When_asserting_equality_with_a_collection_built_from_params_arguments_that_are_assignable_to_the_subjects_type_parameter_it_should_succeed_by_treating_the_arguments_as_of_that_type()\n {\n // Arrange\n byte[] byteArray = [0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10];\n\n // Act / Assert\n byteArray.Should().Equal(0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10);\n }\n }\n\n public class NotEqual\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_not_equal_to_a_different_collection()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [3, 1, 2];\n\n // Act / Assert\n collection1.Should()\n .NotEqual(collection2);\n }\n\n [Fact]\n public void When_two_equal_collections_are_not_expected_to_be_equal_it_should_throw()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3];\n\n // Act\n Action act = () => collection1.Should().NotEqual(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect collections {1, 2, 3} and {1, 2, 3} to be equal.\");\n }\n\n [Fact]\n public void When_two_equal_collections_are_not_expected_to_be_equal_it_should_report_a_clear_explanation()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3];\n\n // Act\n Action act = () => collection1.Should().NotEqual(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect collections {1, 2, 3} and {1, 2, 3} to be equal because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_subject_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotEqual(collection1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collections not to be equal because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_but_expected_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] collection1 = null;\n\n // Act\n Action act =\n () => collection.Should().NotEqual(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare collection with .*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_but_both_collections_reference_the_same_object_it_should_throw()\n {\n string[] collection1 = [\"one\", \"two\", \"three\"];\n var collection2 = collection1;\n\n // Act\n Action act = () =>\n collection1.Should().NotEqual(collection2, \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collections not to be equal because we want to test the behaviour with same objects, but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_two_collections_not_to_be_equal_because_the_actual_collection_contains_more_items_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2];\n\n // Act / Assert\n collection1.Should().NotEqual(collection2);\n }\n\n [Fact]\n public void When_asserting_two_collections_not_to_be_equal_because_the_actual_collection_contains_less_items_it_should_succeed()\n {\n // Arrange\n int[] collection1 = [1, 2, 3];\n int[] collection2 = [1, 2, 3, 4];\n\n // Act / Assert\n collection1.Should().NotEqual(collection2);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeSameDateAs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeSameDateAs\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_be_same_date_as_another_with_the_same_date_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeSameDateAs(expectation);\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_should_be_same_as_another_with_same_date_but_different_time_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31, 11, 15, 11), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeSameDateAs(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_to_be_same_date_as_another_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected the date part of subject to be <2009-12-31>, but found a DateTimeOffset.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_same_date_as_another_but_it_doesnt_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 30), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected the date part of subject to be <2009-12-30>, but it was <2009-12-31>.\");\n }\n\n [Fact]\n public void Can_chain_follow_up_assertions()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeSameDateAs(expectation).And.Be(subject);\n }\n }\n\n public class NotBeSameDateAs\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_be_same_date_as_another_with_the_same_date_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void Can_chain_follow_up_assertions()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(expectation).And.Be(subject);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_should_not_be_same_as_another_with_same_date_but_different_time_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 4, 5, 6), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31, 11, 15, 11), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_to_not_be_same_date_as_another_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n DateTimeOffset expectation = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect the date part of subject to be <2009-12-31>, but found a DateTimeOffset.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_same_date_as_another_but_it_doesnt_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2009, 12, 30), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeSameDateAs(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.HaveLength.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The HaveLength specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class HaveLength\n {\n [Fact]\n public void Should_succeed_when_asserting_string_length_to_be_equal_to_the_same_value()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act / Assert\n actual.Should().HaveLength(3);\n }\n\n [Fact]\n public void When_asserting_string_length_on_null_string_it_should_fail()\n {\n // Arrange\n string actual = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n actual.Should().HaveLength(0, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual with length 0 *failure message*, but found .\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_string_length_to_be_equal_to_different_value()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n actual.Should().HaveLength(1, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected actual with length 1 *failure message*, but found string \\\"ABC\\\" with length 3.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.BeBefore.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class BeBefore\n {\n [Fact]\n public void When_asserting_subject_is_not_before_earlier_expected_timeonly_it_should_succeed()\n {\n // Arrange\n TimeOnly expected = new(15, 06, 03);\n TimeOnly subject = new(15, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_before_the_same_timeonly_it_should_throw()\n {\n // Arrange\n TimeOnly expected = new(15, 06, 04);\n TimeOnly subject = new(15, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <15:06:04.000>, but found <15:06:04.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_before_the_same_timeonly_it_should_succeed()\n {\n // Arrange\n TimeOnly expected = new(15, 06, 04);\n TimeOnly subject = new(15, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_before_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 175);\n TimeOnly expectation = new(15, 06, 05, 23);\n\n // Act/Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_before_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 150);\n TimeOnly expectation = new(15, 06, 05, 340);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <15:06:05.340>, but found <15:06:04.150>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_timeonly_is_on_or_before_the_same_time_as_the_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 04);\n\n // Act/Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_on_or_before_the_same_time_as_the_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04, 123);\n TimeOnly expectation = new(15, 06, 04, 123);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <15:06:04.123>, but found <15:06:04.123>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_before_earlier_expected_timeonly_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 07);\n TimeOnly expectation = new(15, 06);\n\n // Act\n Action act = () => subject.Should().BeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <15:06:00.000>, but found <15:07:00.000>.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_is_not_on_or_before_earlier_expected_timeonly_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 06, 04);\n TimeOnly expectation = new(15, 06, 03);\n\n // Act/Assert\n subject.Should().NotBeOnOrBefore(expectation);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.BeBefore.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class BeBefore\n {\n [Fact]\n public void When_asserting_subject_is_not_before_earlier_expected_dateonly_it_should_succeed()\n {\n // Arrange\n DateOnly expected = new(2016, 06, 03);\n DateOnly subject = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_before_the_same_dateonly_it_should_throw()\n {\n // Arrange\n DateOnly expected = new(2016, 06, 04);\n DateOnly subject = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_before_the_same_dateonly_it_should_succeed()\n {\n // Arrange\n DateOnly expected = new(2016, 06, 04);\n DateOnly subject = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_before_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act/Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_before_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 05);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_dateonly_is_on_or_before_the_same_date_as_the_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act/Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_on_or_before_the_same_date_as_the_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_before_earlier_expected_dateonly_should_throw()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act\n Action act = () => subject.Should().BeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_is_not_on_or_before_earlier_expected_dateonly_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2016, 06, 04);\n DateOnly expectation = new(2016, 06, 03);\n\n // Act/Assert\n subject.Should().NotBeOnOrBefore(expectation);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.Contain.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]Contain specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class Contain\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_contains_an_item_from_the_collection()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Contain(1);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_contains_multiple_items_from_the_collection_in_any_order()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Contain([2, 1]);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_single_item_it_should_throw_with_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain(4, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain 4 because we do.\");\n }\n\n [Fact]\n public void When_asserting_collection_does_contain_item_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().Contain(1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_another_collection_it_should_throw_with_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain([3, 4, 5], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain {3, 4, 5} because we do, but could not find {4, 5}.\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_single_element_collection_it_should_throw_with_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain([4], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain 4 because we do.\");\n }\n\n [Fact]\n public void\n When_a_collection_does_not_contain_other_collection_with_assertion_scope_it_should_throw_with_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().Contain([4]);\n collection.Should().Contain([5, 6]);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*to contain 4*to contain {5, 6}*\");\n }\n\n [Fact]\n public void When_the_contents_of_a_collection_are_checked_against_an_empty_collection_it_should_throw_clear_explanation()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain([]);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify containment against an empty collection*\");\n }\n\n [Fact]\n public void When_asserting_collection_does_contain_a_list_of_items_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().Contain([1, 2], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to contain {1, 2} *failure message*, but found .\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_Contain_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().Contain(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_an_expected_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain(item => item > 3, \"at least {0} item should be larger than 3\", 1);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to have an item matching (item > 3) because at least 1 item should be larger than 3.\");\n }\n\n [Fact]\n public void When_collection_does_contain_an_expected_item_matching_a_predicate_it_should_allow_chaining_it()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain(item => item == 2).Which.Should().BeGreaterThan(4);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*greater*4*2*\");\n }\n\n [Fact]\n public void Can_chain_another_assertion_on_the_single_result()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().Contain(item => item == 2).Which.Should().BeGreaterThan(4);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection[1]*greater*4*2*\");\n }\n\n [Fact]\n public void When_collection_does_contain_an_expected_item_matching_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().Contain(item => item == 2);\n }\n\n [Fact]\n public void When_a_collection_of_strings_contains_the_expected_string_it_should_not_throw()\n {\n // Arrange\n IEnumerable strings = [\"string1\", \"string2\", \"string3\"];\n\n // Act / Assert\n strings.Should().Contain(\"string2\");\n }\n\n [Fact]\n public void When_a_collection_of_strings_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n IEnumerable strings = [\"string1\", \"string2\", \"string3\"];\n\n // Act\n Action act = () => strings.Should().Contain(\"string4\", \"because {0} is required\", \"4\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings {\\\"string1\\\", \\\"string2\\\", \\\"string3\\\"} to contain \\\"string4\\\" because 4 is required.\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_some_values_but_collection_is_null_it_should_throw()\n {\n // Arrange\n const IEnumerable strings = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n strings.Should().Contain(\"string4\", \"because we're checking how it reacts to a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings to contain \\\"string4\\\" because we're checking how it reacts to a null subject, but found .\");\n }\n\n [Fact]\n public void When_the_multiple_matching_objects_exists_it_continuation_using_the_matched_value_should_fail()\n {\n // Arrange\n DateTime now = DateTime.Now;\n\n IEnumerable collection = [now, DateTime.SpecifyKind(now, DateTimeKind.Unspecified)];\n\n // Act\n Action act = () => collection.Should().Contain(now).Which.Kind.Should().Be(DateTimeKind.Local);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_collection_contains_values_according_to_predicate_but_collection_is_null_it_should_throw()\n {\n // Arrange\n const IEnumerable strings = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n strings.Should().Contain(x => x == \"xxx\", \"because we're checking how it reacts to a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings to contain (x == \\\"xxx\\\") because we're checking how it reacts to a null subject, but found .\");\n }\n }\n\n public class NotContain\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_does_not_contain_an_item_that_is_not_in_the_collection()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContain(4);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_does_not_contain_any_items_that_is_not_in_the_collection()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContain([4, 5]);\n }\n\n [Fact]\n public void When_collection_contains_an_unexpected_item_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContain(1, \"because we {0} like it, but found it anyhow\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to not contain 1 because we don't like it, but found it anyhow.\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotContain_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotContain(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_collection_does_contain_an_unexpected_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContain(item => item == 2, \"because {0}s are evil\", 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to not have any items matching (item == 2) because 2s are evil,*{2}*\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_an_unexpected_item_matching_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContain(item => item == 4);\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_item_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContain(1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to not contain 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_contains_unexpected_item_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should()\n .NotContain([2], \"because we {0} like them\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to not contain 2 because we don't like them.\");\n }\n\n [Fact]\n public void When_collection_contains_unexpected_items_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should()\n .NotContain([1, 2, 4], \"because we {0} like them\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to not contain {1, 2, 4} because we don't like them, but found {1, 2}.\");\n }\n\n [Fact]\n public void Assertion_scopes_do_not_affect_chained_calls()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContain([1, 2]).And.NotContain([3]);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but found {1, 2}.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_an_empty_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContain([]);\n\n // Assert\n act.Should().Throw().WithMessage(\"Cannot verify*\");\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_predicate_item_against_null_collection_it_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContain(item => item == 4, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to contain (item == 4) *failure message*, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_a_list_of_items_against_null_collection_it_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContain([1, 2, 4], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to not contain {1, 2, 4} *failure message*, but found .\");\n }\n\n [Fact]\n public void\n When_asserting_collection_doesnt_contain_values_according_to_predicate_but_collection_is_null_it_should_throw()\n {\n // Arrange\n const IEnumerable strings = null;\n\n // Act\n Action act =\n () => strings.Should().NotContain(x => x == \"xxx\", \"because we're checking how it reacts to a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings not to contain (x == \\\"xxx\\\") because we're checking how it reacts to a null subject, but found .\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_the_expected_item_it_should_not_be_enumerated_twice()\n {\n // Arrange\n var collection = new OneTimeEnumerable(1, 2, 3);\n\n // Act\n Action act = () => collection.Should().Contain(4);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection*to contain 4.\");\n }\n\n [Fact]\n public void When_a_collection_contains_the_unexpected_item_it_should_not_be_enumerated_twice()\n {\n // Arrange\n var collection = new OneTimeEnumerable(1, 2, 3);\n\n // Act\n Action act = () => collection.Should().NotContain(2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection*to not contain 2.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeOnOrAfter.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeOnOrAfter\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_after_earlier_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_after_the_same_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeOnOrAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_after_later_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or after <2016-06-05 +0h>, but it was <2016-06-04 +0h>.\");\n }\n }\n\n public class NotBeOnOrAfter\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_after_earlier_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_after_the_same_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrAfter(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_after_later_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeOnOrAfter(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainSingle.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The ContainSingle specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n [Fact]\n public void When_injecting_a_null_predicate_into_ContainSingle_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().ContainSingle(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_a_collection_contains_a_single_item_matching_a_predicate_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n Expression> expression = item => item == 2;\n\n // Act / Assert\n collection.Should().ContainSingle(expression);\n }\n\n [Fact]\n public void When_asserting_an_empty_collection_contains_a_single_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n Expression> expression = item => item == 2;\n\n // Act\n Action act = () => collection.Should().ContainSingle(expression);\n\n // Assert\n string expectedMessage =\n \"Expected collection to contain a single item matching (item == 2), but the collection is empty.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_asserting_a_null_collection_contains_a_single_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n Expression> expression = item => item == 2;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainSingle(expression);\n };\n\n // Assert\n string expectedMessage =\n \"Expected collection to contain a single item matching (item == 2), but found .\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_non_empty_collection_does_not_contain_a_single_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 3];\n Expression> expression = item => item == 2;\n\n // Act\n Action act = () => collection.Should().ContainSingle(expression);\n\n // Assert\n string expectedMessage =\n \"Expected collection to contain a single item matching (item == 2), but no such item was found.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_non_empty_collection_contains_more_than_a_single_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2, 2, 2, 3];\n Expression> expression = item => item == 2;\n\n // Act\n Action act = () => collection.Should().ContainSingle(expression);\n\n // Assert\n string expectedMessage =\n \"Expected collection to contain a single item matching (item == 2), but 3 such items were found.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_single_item_matching_a_predicate_is_found_it_should_allow_continuation()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().ContainSingle(item => item == 2).Which.Should().BeGreaterThan(4);\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected collection[0]*greater*4*2*\");\n }\n\n [Fact]\n public void Chained_assertions_are_never_called_when_the_initial_assertion_failed()\n {\n // Arrange\n IEnumerable collection = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainSingle(item => item == 4).Which.Should().BeGreaterThan(4);\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to contain a single item matching (item == 4), but no such item was found.\");\n }\n\n [Fact]\n public void When_single_item_contains_brackets_it_should_format_them_properly()\n {\n // Arrange\n IEnumerable collection = [\"\"];\n\n // Act\n Action act = () => collection.Should().ContainSingle(item => item == \"{123}\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain a single item matching (item == \\\"{123}\\\"), but no such item was found.\");\n }\n\n [Fact]\n public void When_single_item_contains_string_interpolation_it_should_format_brackets_properly()\n {\n // Arrange\n IEnumerable collection = [\"\"];\n\n // Act\n Action act = () => collection.Should().ContainSingle(item => item == $\"{123}\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain a single item matching (item == \\\"123\\\"), but no such item was found.\");\n }\n\n [Fact]\n public void When_a_collection_contains_a_single_item_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [1];\n\n // Act / Assert\n collection.Should().ContainSingle();\n }\n\n [Fact]\n public void When_asserting_an_empty_collection_contains_a_single_item_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().ContainSingle(\"more is not allowed\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to contain a single item because more is not allowed, but the collection is empty.\");\n }\n\n [Fact]\n public void When_asserting_a_null_collection_contains_a_single_item_it_should_throw()\n {\n // Arrange\n const IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainSingle(\"more is not allowed\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to contain a single item because more is not allowed, but found .\");\n }\n\n [Fact]\n public void When_non_empty_collection_does_not_contain_a_single_item_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 3];\n\n // Act\n Action act = () => collection.Should().ContainSingle();\n\n // Assert\n const string expectedMessage = \"Expected collection to contain a single item, but found {1, 3}.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_non_empty_collection_contains_more_than_a_single_item_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [1, 2];\n\n // Act\n Action act = () => collection.Should().ContainSingle();\n\n // Assert\n const string expectedMessage = \"Expected collection to contain a single item, but found {1, 2}.\";\n\n act.Should().Throw().WithMessage(expectedMessage);\n }\n\n [Fact]\n public void When_single_item_is_found_it_should_allow_continuation()\n {\n // Arrange\n IEnumerable collection = [3];\n\n // Act\n Action act = () => collection.Should().ContainSingle().Which.Should().BeGreaterThan(4);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection[0] to be greater than 4, but found 3.\");\n }\n\n [Fact]\n public void When_collection_is_IEnumerable_it_should_be_evaluated_only_once_with_predicate()\n {\n // Arrange\n IEnumerable collection = new OneTimeEnumerable(1);\n\n // Act / Assert\n collection.Should().ContainSingle(_ => true);\n }\n\n [Fact]\n public void When_collection_is_IEnumerable_it_should_be_evaluated_only_once()\n {\n // Arrange\n IEnumerable collection = new OneTimeEnumerable(1);\n\n // Act / Assert\n collection.Should().ContainSingle();\n }\n\n [Fact]\n public void When_an_assertion_fails_on_ContainSingle_succeeding_message_should_be_included()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n var values = new List();\n values.Should().ContainSingle();\n values.Should().ContainSingle();\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*to contain a single item, but the collection is empty*\" +\n \"Expected*to contain a single item, but the collection is empty*\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.BeCloseTo.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing AwesomeAssertions.Execution;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class BeCloseTo\n {\n [Fact]\n public void When_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().BeCloseTo(time, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_time_is_close_to_a_later_time_by_one_tick_it_should_succeed()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(time, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_time_is_close_to_an_earlier_time_by_one_tick_it_should_succeed()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks + 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(time, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_subject_time_is_close_to_the_minimum_time_it_should_succeed()\n {\n // Arrange\n TimeOnly time = TimeOnly.MinValue.Add(50.Milliseconds());\n TimeOnly nearbyTime = TimeOnly.MinValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n\n [Fact]\n public void When_subject_time_is_close_to_the_maximum_time_it_should_succeed()\n {\n // Arrange\n TimeOnly time = TimeOnly.MaxValue.Add(-50.Milliseconds());\n TimeOnly nearbyTime = TimeOnly.MaxValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n\n [Fact]\n public void When_subject_time_is_close_to_another_value_that_is_later_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 30, 979);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <12:15:31.000>, but <12:15:30.979> was off by 21ms.\");\n }\n\n [Fact]\n public void When_subject_time_is_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 021);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <12:15:31.000>, but <12:15:31.021> was off by 21ms.\");\n }\n\n [Fact]\n public void When_subject_time_is_close_to_an_earlier_time_by_35ms_it_should_succeed()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 035);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n }\n\n [Fact]\n public void A_time_is_close_to_a_later_time_when_passing_midnight()\n {\n // Arrange\n TimeOnly time = new(23, 59, 0);\n TimeOnly nearbyTime = new(0, 1, 0);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 2.Minutes());\n }\n\n [Fact]\n public void A_time_is_close_to_an_earlier_time_when_passing_midnight()\n {\n // Arrange\n TimeOnly time = new(0, 1, 0);\n TimeOnly nearbyTime = new(23, 59, 0);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 2.Minutes());\n }\n\n [Fact]\n public void A_time_outside_of_the_precision_to_a_later_time_when_passing_midnight_fails()\n {\n // Arrange\n TimeOnly time = new(23, 58, 59);\n TimeOnly nearbyTime = new(0, 1, 0);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 2.Minutes());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to be within 2m from <00:01:00.000>*, but <23:58:59.000> was off by 2m and 1s*\");\n }\n\n [Fact]\n public void A_time_outside_of_the_precision_to_an_earlier_time_when_passing_midnight_fails()\n {\n // Arrange\n TimeOnly time = new(0, 1, 0);\n TimeOnly nearbyTime = new(23, 58, 59);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 2.Minutes());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to be within 2m from <23:58:59.000>*, but <00:01:00.000> was off by 2m and 1s*\");\n }\n\n [Fact]\n public void When_subject_nulltime_is_close_to_another_it_should_throw()\n {\n // Arrange\n TimeOnly? time = null;\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n [Fact]\n public void A_null_time_inside_an_assertion_scope_fails()\n {\n // Arrange\n TimeOnly? time = null;\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n }\n\n public class NotBeCloseTo\n {\n [Fact]\n public void A_null_time_is_never_unclose_to_an_other_time()\n {\n // Arrange\n TimeOnly? time = null;\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*, but found .\");\n }\n\n [Fact]\n public void A_null_time_inside_an_assertion_scope_is_never_unclose_to_an_other_time()\n {\n // Arrange\n TimeOnly? time = null;\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*, but found .\");\n }\n\n [Fact]\n public void When_time_is_not_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_time_is_close_to_a_later_time_by_one_tick_it_should_fail()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_time_is_close_to_an_earlier_time_by_one_tick_it_should_fail()\n {\n // Arrange\n var time = TimeOnly.FromDateTime(DateTime.UtcNow);\n var actual = new TimeOnly(time.Ticks + 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_time_is_close_to_a_min_value_by_one_tick_it_should_fail()\n {\n // Arrange\n var time = TimeOnly.MinValue;\n var actual = new TimeOnly(time.Ticks + 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_time_is_close_to_a_max_value_by_one_tick_it_should_fail()\n {\n // Arrange\n var time = TimeOnly.MaxValue;\n var actual = new TimeOnly(time.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(time, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 020);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 20ms from <12:15:31.000>, but it was <12:15:31.020>.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_an_earlier_time_by_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 020);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 20ms from <12:15:31.000>, but it was <12:15:31.020>.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_another_value_that_is_later_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n TimeOnly time = new(12, 15, 30, 979);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void\n When_asserting_subject_time_is_not_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 021);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_an_earlier_datetime_by_35ms_it_should_throw()\n {\n // Arrange\n TimeOnly time = new(12, 15, 31, 035);\n TimeOnly nearbyTime = new(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 35ms from <12:15:31.000>, but it was <12:15:31.035>.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_the_minimum_time_it_should_throw()\n {\n // Arrange\n TimeOnly time = TimeOnly.MinValue.Add(50.Milliseconds());\n TimeOnly nearbyTime = TimeOnly.MinValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 100ms from <00:00:00.000>, but it was <00:00:00.050>.\");\n }\n\n [Fact]\n public void When_asserting_subject_time_is_not_close_to_the_maximum_time_it_should_throw()\n {\n // Arrange\n TimeOnly time = TimeOnly.MaxValue.Add(-50.Milliseconds());\n TimeOnly nearbyTime = TimeOnly.MaxValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 100ms from <23:59:59.999>, but it was <23:59:59.949>.\");\n }\n\n [Fact]\n public void A_time_is_not_close_to_a_later_time_when_passing_midnight()\n {\n // Arrange\n TimeOnly time = new(23, 58, 0);\n TimeOnly nearbyTime = new(0, 1, 0);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 2.Minutes());\n }\n\n [Fact]\n public void A_time_is_not_close_to_an_earlier_time_when_passing_midnight()\n {\n // Arrange\n TimeOnly time = new(0, 2, 0);\n TimeOnly nearbyTime = new(23, 59, 0);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 2.Minutes());\n }\n\n [Fact]\n public void A_time_inside_of_the_precision_to_a_later_time_when_passing_midnight_fails()\n {\n // Arrange\n TimeOnly time = new(23, 59, 0);\n TimeOnly nearbyTime = new(0, 1, 0);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 2.Minutes());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect * to be within 2m from <00:01:00.000>*, but it was <23:59:00.000>*\");\n }\n\n [Fact]\n public void A_time_inside_of_the_precision_to_an_earlier_time_when_passing_midnight_fails()\n {\n // Arrange\n TimeOnly time = new(0, 1, 0);\n TimeOnly nearbyTime = new(23, 59, 0);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 2.Minutes());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect * to be within 2m from <23:59:00.000>*, but it was <00:01:00.000>*\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeOnOrBefore.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeOnOrBefore\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_before_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_on_or_before_the_same_date_as_the_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeOnOrBefore(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_before_earlier_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be on or before <2016-06-03 +0h>, but it was <2016-06-04 +0h>.\");\n }\n }\n\n public class NotBeOnOrBefore\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_on_or_before_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-05 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_on_or_before_the_same_date_as_the_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeOnOrBefore(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be after <2016-06-04 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_on_or_before_earlier_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeOnOrBefore(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainInOrder.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]ContainInOrder specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class ContainInOrder\n {\n [Fact]\n public void When_two_collections_contain_the_same_items_in_the_same_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n collection.Should().ContainInOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_collection_contains_null_value_it_should_not_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act / Assert\n collection.Should().ContainInOrder(1, null, \"string\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act / Assert\n collection.Should().ContainInOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act / Assert\n collection.Should().ContainInOrder(1, 2, 1, 2, 12, 2, 2);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 3, 12, 2, 2];\n\n // Act\n Action act = () => collection.Should().ContainInOrder(1, 2, 1, 1, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 3, 12, 2, 2} to contain items {1, 2, 1, 1, 2} in order, but 1 (index 3) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInOrder([3, 1], \"because we said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain items {3, 1} in order because we said so, but 1 (index 1) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInOrder([4, 1], \"we failed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain items {4, 1} in order because we failed, \" +\n \"but 4 (index 0) did not appear (in the right order).\");\n }\n\n [Fact]\n public void Even_with_an_assertion_scope_only_the_first_failure_in_a_chained_assertion_is_reported()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n new[] { 1, 2, 3 }.Should().ContainInOrder(4).And.ContainInOrder(5);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\"*but 4 (index 0) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_ordered_containment_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify ordered containment against a collection.*\");\n }\n\n [Fact]\n public void Collections_contain_the_empty_sequence()\n {\n // Assert\n new[] { 1 }.Should().ContainInOrder();\n }\n\n [Fact]\n public void Collections_do_not_not_contain_the_empty_sequence()\n {\n // Assert\n new[] { 1 }.Should().NotContainInOrder();\n }\n\n [Fact]\n public void When_asserting_collection_contains_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] ints = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n ints.Should().ContainInOrder([4], \"because we're checking how it reacts to a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected ints to contain {4} in order because we're checking how it reacts to a null subject, but found .\");\n }\n }\n\n public class NotContainInOrder\n {\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInOrder(2, 1);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInOrder(4, 1);\n }\n\n [Fact]\n public void When_a_collection_contains_less_items_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2];\n\n // Act / Assert\n collection.Should().NotContainInOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 3, 12, 2, 2];\n\n // Act / Assert\n collection.Should().NotContainInOrder(1, 2, 1, 1, 2);\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(4);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder([1, 2, 3], \"that's what we expect\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 2, 3} to not contain items {1, 2, 3} in order because that's what we expect, \" +\n \"but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_not_contain_in_order_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainInOrder([1, 2, 3], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_collection_contains_contain_the_same_items_in_the_same_order_with_null_value_it_should_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(1, null, \"string\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, , 2, \\\"string\\\"} to not contain items {1, , \\\"string\\\"} in order, \" +\n \"but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3, 2} to not contain items {1, 2, 3} in order, \" +\n \"but items appeared in order ending at index 2.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(1, 2, 1, 2, 12, 2, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 2, 12, 2, 2} to not contain items {1, 2, 1, 2, 12, 2, 2} in order, \" +\n \"but items appeared in order ending at index 6.\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_absence_of_ordered_containment_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment against a collection.*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/BooleanAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n// ReSharper disable ConditionIsAlwaysTrueOrFalse\npublic class BooleanAssertionSpecs\n{\n public class BeTrue\n {\n [Fact]\n public void Should_succeed_when_asserting_boolean_value_true_is_true()\n {\n // Arrange\n bool boolean = true;\n\n // Act / Assert\n boolean.Should().BeTrue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_boolean_value_false_is_true()\n {\n // Arrange\n bool boolean = false;\n\n // Act\n Action action = () => boolean.Should().BeTrue();\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_boolean_value_false_is_true()\n {\n // Act\n Action action = () =>\n false.Should().BeTrue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Expected boolean to be True because we want to test the failure message, but found False.\");\n }\n }\n\n public class BeFalse\n {\n [Fact]\n public void Should_succeed_when_asserting_boolean_value_false_is_false()\n {\n // Act / Assert\n false.Should().BeFalse();\n }\n\n [Fact]\n public void Should_fail_when_asserting_boolean_value_true_is_false()\n {\n // Act\n Action action = () =>\n true.Should().BeFalse();\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_boolean_value_true_is_false()\n {\n // Act\n Action action = () =>\n true.Should().BeFalse(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected boolean to be False because we want to test the failure message, but found True.\");\n }\n }\n\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_boolean_value_to_be_equal_to_the_same_value()\n {\n // Act / Assert\n false.Should().Be(false);\n }\n\n [Fact]\n public void Should_fail_when_asserting_boolean_value_to_be_equal_to_a_different_value()\n {\n // Act\n Action action = () =>\n false.Should().Be(true);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_boolean_value_to_be_equal_to_a_different_value()\n {\n // Act\n Action action = () =>\n false.Should().Be(true, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*Expected*boolean*True*because we want to test the failure message, but found False.*\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Should_succeed_when_asserting_boolean_value_not_to_be_equal_to_the_same_value()\n {\n // Act / Assert\n true.Should().NotBe(false);\n }\n\n [Fact]\n public void Should_fail_when_asserting_boolean_value_not_to_be_equal_to_a_different_value()\n {\n // Act\n Action action = () =>\n true.Should().NotBe(true);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_boolean_value_not_to_be_equal_to_a_different_value()\n {\n // Act\n Action action = () =>\n true.Should().NotBe(true, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*Expected*boolean*True*because we want to test the failure message, but found True.*\");\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Act\n Action action = () => true.Should().Equals(true);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n }\n\n public class Imply\n {\n [Theory]\n [InlineData(false, false)]\n [InlineData(false, true)]\n [InlineData(true, true)]\n public void Antecedent_implies_consequent(bool? antecedent, bool consequent)\n {\n // Act / Assert\n antecedent.Should().Imply(consequent);\n }\n\n [Theory]\n [InlineData(null, true)]\n [InlineData(null, false)]\n [InlineData(true, false)]\n public void Antecedent_does_not_imply_consequent(bool? antecedent, bool consequent)\n {\n // Act\n Action act = () => antecedent.Should().Imply(consequent, \"because we want to test the {0}\", \"failure\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected antecedent*to imply consequent*test the failure*but*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.Be.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_datetimeoffset_value_is_equal_to_the_same_value()\n {\n // Arrange\n DateTimeOffset dateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset sameDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_datetimeoffset_value_is_equal_to_the_same_nullable_value_be_should_succeed()\n {\n // Arrange\n DateTimeOffset dateTime = 4.June(2016).ToDateTimeOffset();\n DateTimeOffset? sameDateTime = 4.June(2016).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_both_values_are_at_their_minimum_then_it_should_succeed()\n {\n // Arrange\n DateTimeOffset dateTime = DateTimeOffset.MinValue;\n DateTimeOffset sameDateTime = DateTimeOffset.MinValue;\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_both_values_are_at_their_maximum_then_it_should_succeed()\n {\n // Arrange\n DateTimeOffset dateTime = DateTimeOffset.MaxValue;\n DateTimeOffset sameDateTime = DateTimeOffset.MaxValue;\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_datetimeoffset_value_is_equal_to_the_different_value()\n {\n // Arrange\n var dateTime = 10.March(2012).WithOffset(1.Hours());\n var otherDateTime = 11.March(2012).WithOffset(1.Hours());\n\n // Act\n Action act = () => dateTime.Should().Be(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dateTime to represent the same point in time as <2012-03-11 +1h>*failure message, but <2012-03-10 +1h> does not.\");\n }\n\n [Fact]\n public void When_datetimeoffset_value_is_equal_to_the_different_nullable_value_be_should_failed()\n {\n // Arrange\n DateTimeOffset dateTime = 10.March(2012).WithOffset(1.Hours());\n DateTimeOffset? otherDateTime = 11.March(2012).WithOffset(1.Hours());\n\n // Act\n Action act = () => dateTime.Should().Be(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dateTime to represent the same point in time as <2012-03-11 +1h>*failure message, but <2012-03-10 +1h> does not.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetimeoffset_value_equals_the_same_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset? nullableDateTimeB = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetimeoffset_null_value_equals_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = null;\n DateTimeOffset? nullableDateTimeB = null;\n\n // Act / Assert\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_equals_a_different_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTimeA = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset? nullableDateTimeB = new DateTime(2016, 06, 06).ToDateTimeOffset();\n\n // Act\n Action action = () =>\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_datetimeoffset_null_value_is_equal_to_another_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n DateTimeOffset expectation = 27.March(2016).ToDateTimeOffset(1.Hours());\n\n // Act\n Action action = () =>\n nullableDateTime.Should().Be(expectation, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateTime to represent the same point in time as <2016-03-27 +1h> because we want to test the failure message, but found a DateTimeOffset.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_non_null_value_is_equal_to_null_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = 27.March(2016).ToDateTimeOffset(1.Hours());\n DateTimeOffset? expectation = null;\n\n // Act\n Action action = () =>\n nullableDateTime.Should().Be(expectation, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateTime to be because we want to test the failure message, but it was <2016-03-27 +1h>.\");\n }\n\n [Fact]\n public void\n When_asserting_different_date_time_offsets_representing_the_same_world_time_it_should_succeed()\n {\n // Arrange\n var specificDate = 1.May(2008).At(6, 32);\n\n var dateWithFiveHourOffset = new DateTimeOffset(specificDate - 5.Hours(), -5.Hours());\n\n var dateWithSixHourOffset = new DateTimeOffset(specificDate - 6.Hours(), -6.Hours());\n\n // Act / Assert\n dateWithFiveHourOffset.Should().Be(dateWithSixHourOffset);\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Should_succeed_when_asserting_datetimeoffset_value_is_not_equal_to_a_different_value()\n {\n // Arrange\n DateTimeOffset dateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n DateTimeOffset otherDateTime = new DateTime(2016, 06, 05).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().NotBe(otherDateTime);\n }\n\n [Fact]\n public void When_datetimeoffset_value_is_not_equal_to_a_nullable_different_value_notbe_should_succeed()\n {\n // Arrange\n DateTimeOffset dateTime = 4.June(2016).ToDateTimeOffset();\n DateTimeOffset? otherDateTime = 5.June(2016).ToDateTimeOffset();\n\n // Act / Assert\n dateTime.Should().NotBe(otherDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_datetimeoffset_value_is_not_equal_to_the_same_value()\n {\n // Arrange\n var dateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n var sameDateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n\n // Act\n Action act =\n () => dateTime.Should().NotBe(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dateTime to represent the same point in time as <2012-03-10 +1h> because we want to test the failure message, but it did.\");\n }\n\n [Fact]\n public void When_datetimeoffset_value_is_not_equal_to_the_same_nullable_value_notbe_should_failed()\n {\n // Arrange\n DateTimeOffset dateTime = new(10.March(2012), 1.Hours());\n DateTimeOffset? sameDateTime = new DateTimeOffset(10.March(2012), 1.Hours());\n\n // Act\n Action act =\n () => dateTime.Should().NotBe(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dateTime to represent the same point in time as <2012-03-10 +1h> because we want to test the failure message, but it did.\");\n }\n\n [Fact]\n public void\n When_asserting_different_date_time_offsets_representing_different_world_times_it_should_not_succeed()\n {\n // Arrange\n var specificDate = 1.May(2008).At(6, 32);\n\n var dateWithZeroHourOffset = new DateTimeOffset(specificDate, TimeSpan.Zero);\n var dateWithOneHourOffset = new DateTimeOffset(specificDate, 1.Hours());\n\n // Act / Assert\n dateWithZeroHourOffset.Should().NotBe(dateWithOneHourOffset);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveProperty.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveProperty specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveProperty\n {\n [Fact]\n public void When_asserting_a_type_has_a_property_of_expected_type_and_name_which_it_does_then_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveProperty(typeof(string), \"PrivateWriteProtectedReadProperty\")\n .Which.Should()\n .BeWritable(CSharpAccessModifier.Private)\n .And.BeReadable(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_of_expected_name_which_it_does_then_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveProperty(\"PrivateWriteProtectedReadProperty\")\n .Which.Should()\n .BeWritable(CSharpAccessModifier.Private)\n .And.BeReadable(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void The_name_of_the_property_is_passed_to_the_chained_assertion()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () => type\n .Should().HaveProperty(typeof(string), \"PrivateWriteProtectedReadProperty\")\n .Which.Should().NotBeWritable();\n\n // Assert\n act.Should().Throw(\"Expected property PrivateWriteProtectedReadProperty not to have a setter.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_which_it_does_not_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(typeof(string), \"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected AwesomeAssertions.*ClassWithNoMembers to have a property PublicProperty of type String because we want to test the failure message, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_expected_name_which_it_does_not_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(\"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected AwesomeAssertions.*ClassWithNoMembers to have a property PublicProperty because we want to test the failure message, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_which_it_has_with_a_different_type_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveProperty(typeof(int), \"PrivateWriteProtectedReadProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property PrivateWriteProtectedReadProperty \" +\n \"to be of type int because we want to test the failure message, but it is not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_property_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(typeof(string), \"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot determine if a type has a property named PublicProperty if the type is .\");\n }\n\n [Fact]\n public void When_subject_is_null_have_property_by_name_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(\"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot determine if a type has a property named PublicProperty if the type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_of_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty((Type)null, \"PublicProperty\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"propertyType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_valid_type_and_a_null_name_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(typeof(string), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_valid_type_and_an_empty_name_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(typeof(string), string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n\n public class HavePropertyOfT\n {\n [Fact]\n public void When_asserting_a_type_has_a_propertyOfT_which_it_does_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveProperty(\"PrivateWriteProtectedReadProperty\")\n .Which.Should()\n .BeWritable(CSharpAccessModifier.Private)\n .And.BeReadable(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_propertyOfT_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_propertyOfT_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n\n public class NotHaveProperty\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_a_property_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act / Assert\n type.Should().NotHaveProperty(\"Property\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_property_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveProperty(\"PrivateWriteProtectedReadProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect AwesomeAssertions.*.ClassWithMembers to have a property PrivateWriteProtectedReadProperty because we want to test the failure message, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_property_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveProperty(\"PublicProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot determine if a type has an unexpected property named PublicProperty if the type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.IntersectWith.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]IntersectWith specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class IntersectWith\n {\n [Fact]\n public void When_asserting_the_items_in_an_two_intersecting_collections_intersect_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = [3, 4, 5];\n\n // Act / Assert\n collection.Should().IntersectWith(otherCollection);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_non_intersecting_collections_intersect_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = [4, 5];\n\n // Act\n Action action = () => collection.Should().IntersectWith(otherCollection, \"they should share items\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to intersect with {4, 5} because they should share items,\" +\n \" but {1, 2, 3} does not contain any shared items.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_intersect_with_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().IntersectWith([4, 5], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection to intersect with {4, 5} *failure message*, but found .\");\n }\n }\n\n public class NotIntersectWith\n {\n [Fact]\n public void When_asserting_the_items_in_an_two_non_intersecting_collections_do_not_intersect_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = [4, 5];\n\n // Act / Assert\n collection.Should().NotIntersectWith(otherCollection);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_intersecting_collections_do_not_intersect_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = [2, 3, 4];\n\n // Act\n Action action = () => collection.Should().NotIntersectWith(otherCollection, \"they should not share items\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to intersect with {2, 3, 4} because they should not share items,\" +\n \" but found the following shared items {2, 3}.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_intersect_with_same_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n var otherCollection = collection;\n\n // Act\n Action act = () => collection.Should().NotIntersectWith(otherCollection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect*to intersect with*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_not_intersect_with_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotIntersectWith([4, 5], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to intersect with {4, 5} *failure message*, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeCloseTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeCloseTo\n {\n [InlineData(sbyte.MinValue, sbyte.MinValue, 0)]\n [InlineData(sbyte.MinValue, sbyte.MinValue, 1)]\n [InlineData(sbyte.MinValue, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, sbyte.MinValue + 1, 1)]\n [InlineData(sbyte.MinValue, sbyte.MinValue + 1, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, -1, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue + 1, sbyte.MinValue, 1)]\n [InlineData(sbyte.MinValue + 1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue + 1, 0, sbyte.MaxValue)]\n [InlineData(-1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, sbyte.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, sbyte.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, sbyte.MaxValue)]\n [InlineData(0, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(0, sbyte.MinValue + 1, sbyte.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, sbyte.MaxValue)]\n [InlineData(1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue - 1, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MaxValue - 1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, 0, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, 1, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, 0)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue - 1, 1)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue - 1, sbyte.MaxValue)]\n [Theory]\n public void When_a_sbyte_value_is_close_to_expected_value_it_should_succeed(sbyte actual, sbyte nearbyValue,\n byte delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(sbyte.MinValue, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MinValue, 0, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, 1, sbyte.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(0, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MinValue, 1)]\n [InlineData(sbyte.MaxValue, -1, sbyte.MaxValue)]\n [Theory]\n public void When_a_sbyte_value_is_not_close_to_expected_value_it_should_fail(sbyte actual, sbyte nearbyValue,\n byte delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_sbyte_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n sbyte actual = 1;\n sbyte nearbyValue = 4;\n byte delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_a_sbyte_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n sbyte actual = sbyte.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(short.MinValue, short.MinValue, 0)]\n [InlineData(short.MinValue, short.MinValue, 1)]\n [InlineData(short.MinValue, short.MinValue, short.MaxValue)]\n [InlineData(short.MinValue, short.MinValue + 1, 1)]\n [InlineData(short.MinValue, short.MinValue + 1, short.MaxValue)]\n [InlineData(short.MinValue, -1, short.MaxValue)]\n [InlineData(short.MinValue + 1, short.MinValue, 1)]\n [InlineData(short.MinValue + 1, short.MinValue, short.MaxValue)]\n [InlineData(short.MinValue + 1, 0, short.MaxValue)]\n [InlineData(-1, short.MinValue, short.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, short.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, short.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, short.MaxValue)]\n [InlineData(0, short.MaxValue, short.MaxValue)]\n [InlineData(0, short.MinValue + 1, short.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, short.MaxValue)]\n [InlineData(1, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue - 1, short.MaxValue, 1)]\n [InlineData(short.MaxValue - 1, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue, 0, short.MaxValue)]\n [InlineData(short.MaxValue, 1, short.MaxValue)]\n [InlineData(short.MaxValue, short.MaxValue, 0)]\n [InlineData(short.MaxValue, short.MaxValue, 1)]\n [InlineData(short.MaxValue, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue, short.MaxValue - 1, 1)]\n [InlineData(short.MaxValue, short.MaxValue - 1, short.MaxValue)]\n [Theory]\n public void When_a_short_value_is_close_to_expected_value_it_should_succeed(short actual, short nearbyValue,\n ushort delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(short.MinValue, short.MaxValue, 1)]\n [InlineData(short.MinValue, 0, short.MaxValue)]\n [InlineData(short.MinValue, 1, short.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, short.MaxValue, short.MaxValue)]\n [InlineData(0, short.MinValue, short.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, short.MinValue, short.MaxValue)]\n [InlineData(short.MaxValue, short.MinValue, 1)]\n [InlineData(short.MaxValue, -1, short.MaxValue)]\n [Theory]\n public void When_a_short_value_is_not_close_to_expected_value_it_should_fail(short actual, short nearbyValue,\n ushort delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_short_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n short actual = 1;\n short nearbyValue = 4;\n ushort delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_a_short_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n short actual = short.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(int.MinValue, int.MinValue, 0)]\n [InlineData(int.MinValue, int.MinValue, 1)]\n [InlineData(int.MinValue, int.MinValue, int.MaxValue)]\n [InlineData(int.MinValue, int.MinValue + 1, 1)]\n [InlineData(int.MinValue, int.MinValue + 1, int.MaxValue)]\n [InlineData(int.MinValue, -1, int.MaxValue)]\n [InlineData(int.MinValue + 1, int.MinValue, 1)]\n [InlineData(int.MinValue + 1, int.MinValue, int.MaxValue)]\n [InlineData(int.MinValue + 1, 0, int.MaxValue)]\n [InlineData(-1, int.MinValue, int.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, int.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, int.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, int.MaxValue)]\n [InlineData(0, int.MaxValue, int.MaxValue)]\n [InlineData(0, int.MinValue + 1, int.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, int.MaxValue)]\n [InlineData(1, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue - 1, int.MaxValue, 1)]\n [InlineData(int.MaxValue - 1, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue, 0, int.MaxValue)]\n [InlineData(int.MaxValue, 1, int.MaxValue)]\n [InlineData(int.MaxValue, int.MaxValue, 0)]\n [InlineData(int.MaxValue, int.MaxValue, 1)]\n [InlineData(int.MaxValue, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue, int.MaxValue - 1, 1)]\n [InlineData(int.MaxValue, int.MaxValue - 1, int.MaxValue)]\n [Theory]\n public void When_an_int_value_is_close_to_expected_value_it_should_succeed(int actual, int nearbyValue, uint delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(int.MinValue, int.MaxValue, 1)]\n [InlineData(int.MinValue, 0, int.MaxValue)]\n [InlineData(int.MinValue, 1, int.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, int.MaxValue, int.MaxValue)]\n [InlineData(0, int.MinValue, int.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, int.MinValue, int.MaxValue)]\n [InlineData(int.MaxValue, int.MinValue, 1)]\n [InlineData(int.MaxValue, -1, int.MaxValue)]\n [Theory]\n public void When_an_int_value_is_not_close_to_expected_value_it_should_fail(int actual, int nearbyValue, uint delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_int_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n int actual = 1;\n int nearbyValue = 4;\n uint delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_an_int_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n int actual = int.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(long.MinValue, long.MinValue, 0)]\n [InlineData(long.MinValue, long.MinValue, 1)]\n [InlineData(long.MinValue, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(long.MinValue, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue, long.MinValue, ulong.MaxValue)]\n [InlineData(long.MinValue, long.MinValue + 1, 1)]\n [InlineData(long.MinValue, long.MinValue + 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MinValue + 1, ulong.MaxValue / 2)]\n [InlineData(long.MinValue, long.MinValue + 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue, long.MinValue + 1, ulong.MaxValue)]\n [InlineData(long.MinValue, -1, long.MaxValue)]\n [InlineData(long.MinValue + 1, long.MinValue, 1)]\n [InlineData(long.MinValue + 1, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue + 1, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(long.MinValue + 1, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue + 1, long.MinValue, ulong.MaxValue)]\n [InlineData(long.MinValue + 1, 0, ulong.MaxValue / 2)]\n [InlineData(long.MinValue + 1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue + 1, 0, ulong.MaxValue)]\n [InlineData(long.MinValue, long.MaxValue, ulong.MaxValue)]\n [InlineData(-1, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(-1, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(-1, long.MinValue, ulong.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(-1, 0, ulong.MaxValue / 2)]\n [InlineData(-1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(-1, 0, ulong.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, -1, ulong.MaxValue / 2)]\n [InlineData(0, -1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, -1, ulong.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, 1, ulong.MaxValue / 2)]\n [InlineData(0, 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, 1, ulong.MaxValue)]\n [InlineData(0, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(0, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, long.MaxValue, ulong.MaxValue)]\n [InlineData(0, long.MinValue + 1, ulong.MaxValue / 2)]\n [InlineData(0, long.MinValue + 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, long.MinValue + 1, ulong.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(1, 0, ulong.MaxValue / 2)]\n [InlineData(1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(1, 0, ulong.MaxValue)]\n [InlineData(1, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(1, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(1, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(1, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue - 1, long.MaxValue, 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue - 1, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue, 0, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, 0, ulong.MaxValue)]\n [InlineData(long.MaxValue, 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, 1, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, 1, ulong.MaxValue)]\n [InlineData(long.MaxValue, long.MaxValue, 0)]\n [InlineData(long.MaxValue, long.MaxValue, 1)]\n [InlineData(long.MaxValue, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue, long.MaxValue - 1, 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, long.MaxValue - 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, ulong.MaxValue)]\n [Theory]\n public void When_a_long_value_is_close_to_expected_value_it_should_succeed(long actual, long nearbyValue, ulong delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(long.MinValue, long.MaxValue, 1)]\n [InlineData(long.MinValue, 0, long.MaxValue)]\n [InlineData(long.MinValue, 1, long.MaxValue)]\n [InlineData(long.MinValue + 1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, long.MaxValue, long.MaxValue)]\n [InlineData(-1, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, long.MinValue, long.MaxValue)]\n [InlineData(0, long.MinValue + 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, long.MinValue, long.MaxValue)]\n [InlineData(long.MaxValue, long.MinValue, 1)]\n [InlineData(long.MaxValue, -1, long.MaxValue)]\n [InlineData(long.MaxValue, 0, (ulong.MaxValue / 2) - 1)]\n [Theory]\n public void When_a_long_value_is_not_close_to_expected_value_it_should_fail(long actual, long nearbyValue,\n ulong delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_long_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n long actual = 1;\n long nearbyValue = 4;\n ulong delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_a_long_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n long actual = long.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, byte.MaxValue, byte.MaxValue)]\n [InlineData(byte.MinValue, byte.MinValue + 1, byte.MaxValue)]\n [InlineData(byte.MinValue + 1, 0, byte.MaxValue)]\n [InlineData(byte.MinValue + 1, byte.MinValue, 1)]\n [InlineData(byte.MinValue + 1, byte.MinValue, byte.MaxValue)]\n [InlineData(byte.MaxValue - 1, byte.MaxValue, 1)]\n [InlineData(byte.MaxValue - 1, byte.MaxValue, byte.MaxValue)]\n [InlineData(byte.MaxValue, 0, byte.MaxValue)]\n [InlineData(byte.MaxValue, 1, byte.MaxValue)]\n [InlineData(byte.MaxValue, byte.MaxValue - 1, 1)]\n [InlineData(byte.MaxValue, byte.MaxValue - 1, byte.MaxValue)]\n [InlineData(byte.MaxValue, byte.MaxValue, 0)]\n [InlineData(byte.MaxValue, byte.MaxValue, 1)]\n [Theory]\n public void When_a_byte_value_is_close_to_expected_value_it_should_succeed(byte actual, byte nearbyValue, byte delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(byte.MinValue, byte.MaxValue, 1)]\n [InlineData(byte.MaxValue, byte.MinValue, 1)]\n [Theory]\n public void When_a_byte_value_is_not_close_to_expected_value_it_should_fail(byte actual, byte nearbyValue, byte delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_byte_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n byte actual = 1;\n byte nearbyValue = 4;\n byte delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_a_byte_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n byte actual = byte.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, ushort.MaxValue, ushort.MaxValue)]\n [InlineData(ushort.MinValue, ushort.MinValue + 1, ushort.MaxValue)]\n [InlineData(ushort.MinValue + 1, 0, ushort.MaxValue)]\n [InlineData(ushort.MinValue + 1, ushort.MinValue, 1)]\n [InlineData(ushort.MinValue + 1, ushort.MinValue, ushort.MaxValue)]\n [InlineData(ushort.MaxValue - 1, ushort.MaxValue, 1)]\n [InlineData(ushort.MaxValue - 1, ushort.MaxValue, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, 0, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, 1, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, ushort.MaxValue - 1, 1)]\n [InlineData(ushort.MaxValue, ushort.MaxValue - 1, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, ushort.MaxValue, 0)]\n [InlineData(ushort.MaxValue, ushort.MaxValue, 1)]\n [Theory]\n public void When_an_ushort_value_is_close_to_expected_value_it_should_succeed(ushort actual, ushort nearbyValue,\n ushort delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(ushort.MinValue, ushort.MaxValue, 1)]\n [InlineData(ushort.MaxValue, ushort.MinValue, 1)]\n [Theory]\n public void When_an_ushort_value_is_not_close_to_expected_value_it_should_fail(ushort actual, ushort nearbyValue,\n ushort delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_ushort_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n ushort actual = 1;\n ushort nearbyValue = 4;\n ushort delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_an_ushort_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n ushort actual = ushort.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, uint.MaxValue, uint.MaxValue)]\n [InlineData(uint.MinValue, uint.MinValue + 1, uint.MaxValue)]\n [InlineData(uint.MinValue + 1, 0, uint.MaxValue)]\n [InlineData(uint.MinValue + 1, uint.MinValue, 1)]\n [InlineData(uint.MinValue + 1, uint.MinValue, uint.MaxValue)]\n [InlineData(uint.MaxValue - 1, uint.MaxValue, 1)]\n [InlineData(uint.MaxValue - 1, uint.MaxValue, uint.MaxValue)]\n [InlineData(uint.MaxValue, 0, uint.MaxValue)]\n [InlineData(uint.MaxValue, 1, uint.MaxValue)]\n [InlineData(uint.MaxValue, uint.MaxValue - 1, 1)]\n [InlineData(uint.MaxValue, uint.MaxValue - 1, uint.MaxValue)]\n [InlineData(uint.MaxValue, uint.MaxValue, 0)]\n [InlineData(uint.MaxValue, uint.MaxValue, 1)]\n [Theory]\n public void When_an_uint_value_is_close_to_expected_value_it_should_succeed(uint actual, uint nearbyValue, uint delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(uint.MinValue, uint.MaxValue, 1)]\n [InlineData(uint.MaxValue, uint.MinValue, 1)]\n [Theory]\n public void When_an_uint_value_is_not_close_to_expected_value_it_should_fail(uint actual, uint nearbyValue,\n uint delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_uint_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n uint actual = 1;\n uint nearbyValue = 4;\n uint delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_an_uint_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n uint actual = uint.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, ulong.MaxValue, ulong.MaxValue)]\n [InlineData(ulong.MinValue, ulong.MinValue + 1, ulong.MaxValue)]\n [InlineData(ulong.MinValue + 1, 0, ulong.MaxValue)]\n [InlineData(ulong.MinValue + 1, ulong.MinValue, 1)]\n [InlineData(ulong.MinValue + 1, ulong.MinValue, ulong.MaxValue)]\n [InlineData(ulong.MaxValue - 1, ulong.MaxValue, 1)]\n [InlineData(ulong.MaxValue - 1, ulong.MaxValue, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, 0, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, 1, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, ulong.MaxValue - 1, 1)]\n [InlineData(ulong.MaxValue, ulong.MaxValue - 1, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, ulong.MaxValue, 0)]\n [InlineData(ulong.MaxValue, ulong.MaxValue, 1)]\n [Theory]\n public void When_an_ulong_value_is_close_to_expected_value_it_should_succeed(ulong actual, ulong nearbyValue,\n ulong delta)\n {\n // Act / Assert\n actual.Should().BeCloseTo(nearbyValue, delta);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(ulong.MinValue, ulong.MaxValue, 1)]\n [InlineData(ulong.MaxValue, ulong.MinValue, 1)]\n [Theory]\n public void When_an_ulong_value_is_not_close_to_expected_value_it_should_fail(ulong actual, ulong nearbyValue,\n ulong delta)\n {\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_ulong_value_is_not_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n ulong actual = 1;\n ulong nearbyValue = 4;\n ulong delta = 2;\n\n // Act\n Action act = () => actual.Should().BeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*4*but found*1*\");\n }\n\n [Fact]\n public void When_an_ulong_value_is_returned_from_BeCloseTo_it_should_chain()\n {\n // Arrange\n ulong actual = ulong.MaxValue;\n\n // Act / Assert\n actual.Should().BeCloseTo(actual, 0)\n .And.Be(actual);\n }\n }\n\n public class NotBeCloseTo\n {\n [InlineData(sbyte.MinValue, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MinValue, 0, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, 1, sbyte.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(0, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MinValue, 1)]\n [InlineData(sbyte.MaxValue, -1, sbyte.MaxValue)]\n [Theory]\n public void When_a_sbyte_value_is_not_close_to_expected_value_it_should_succeed(sbyte actual, sbyte distantValue,\n byte delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(sbyte.MinValue, sbyte.MinValue, 0)]\n [InlineData(sbyte.MinValue, sbyte.MinValue, 1)]\n [InlineData(sbyte.MinValue, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, sbyte.MinValue + 1, 1)]\n [InlineData(sbyte.MinValue, sbyte.MinValue + 1, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue, -1, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue + 1, sbyte.MinValue, 1)]\n [InlineData(sbyte.MinValue + 1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(sbyte.MinValue + 1, 0, sbyte.MaxValue)]\n [InlineData(-1, sbyte.MinValue, sbyte.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, sbyte.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, sbyte.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, sbyte.MaxValue)]\n [InlineData(0, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(0, sbyte.MinValue + 1, sbyte.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, sbyte.MaxValue)]\n [InlineData(1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue - 1, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MaxValue - 1, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, 0, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, 1, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, 0)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, 1)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue, sbyte.MaxValue)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue - 1, 1)]\n [InlineData(sbyte.MaxValue, sbyte.MaxValue - 1, sbyte.MaxValue)]\n [Theory]\n public void When_a_sbyte_value_is_close_to_expected_value_it_should_fail(sbyte actual, sbyte distantValue, byte delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_sbyte_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n sbyte actual = 1;\n sbyte nearbyValue = 3;\n byte delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_a_sbyte_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n sbyte actual = sbyte.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(short.MinValue, short.MaxValue, 1)]\n [InlineData(short.MinValue, 0, short.MaxValue)]\n [InlineData(short.MinValue, 1, short.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, short.MaxValue, short.MaxValue)]\n [InlineData(0, short.MinValue, short.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, short.MinValue, short.MaxValue)]\n [InlineData(short.MaxValue, short.MinValue, 1)]\n [InlineData(short.MaxValue, -1, short.MaxValue)]\n [Theory]\n public void When_a_short_value_is_not_close_to_expected_value_it_should_succeed(short actual, short distantValue,\n ushort delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(short.MinValue, short.MinValue, 0)]\n [InlineData(short.MinValue, short.MinValue, 1)]\n [InlineData(short.MinValue, short.MinValue, short.MaxValue)]\n [InlineData(short.MinValue, short.MinValue + 1, 1)]\n [InlineData(short.MinValue, short.MinValue + 1, short.MaxValue)]\n [InlineData(short.MinValue, -1, short.MaxValue)]\n [InlineData(short.MinValue + 1, short.MinValue, 1)]\n [InlineData(short.MinValue + 1, short.MinValue, short.MaxValue)]\n [InlineData(short.MinValue + 1, 0, short.MaxValue)]\n [InlineData(-1, short.MinValue, short.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, short.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, short.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, short.MaxValue)]\n [InlineData(0, short.MaxValue, short.MaxValue)]\n [InlineData(0, short.MinValue + 1, short.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, short.MaxValue)]\n [InlineData(1, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue - 1, short.MaxValue, 1)]\n [InlineData(short.MaxValue - 1, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue, 0, short.MaxValue)]\n [InlineData(short.MaxValue, 1, short.MaxValue)]\n [InlineData(short.MaxValue, short.MaxValue, 0)]\n [InlineData(short.MaxValue, short.MaxValue, 1)]\n [InlineData(short.MaxValue, short.MaxValue, short.MaxValue)]\n [InlineData(short.MaxValue, short.MaxValue - 1, 1)]\n [InlineData(short.MaxValue, short.MaxValue - 1, short.MaxValue)]\n [Theory]\n public void When_a_short_value_is_close_to_expected_value_it_should_fail(short actual, short distantValue,\n ushort delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_short_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n short actual = 1;\n short nearbyValue = 3;\n ushort delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_a_short_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n short actual = short.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(int.MinValue, int.MaxValue, 1)]\n [InlineData(int.MinValue, 0, int.MaxValue)]\n [InlineData(int.MinValue, 1, int.MaxValue)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, int.MaxValue, int.MaxValue)]\n [InlineData(0, int.MinValue, int.MaxValue)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, int.MinValue, int.MaxValue)]\n [InlineData(int.MaxValue, int.MinValue, 1)]\n [InlineData(int.MaxValue, -1, int.MaxValue)]\n [Theory]\n public void When_an_int_value_is_not_close_to_expected_value_it_should_succeed(int actual, int distantValue,\n uint delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(int.MinValue, int.MinValue, 0)]\n [InlineData(int.MinValue, int.MinValue, 1)]\n [InlineData(int.MinValue, int.MinValue, int.MaxValue)]\n [InlineData(int.MinValue, int.MinValue + 1, 1)]\n [InlineData(int.MinValue, int.MinValue + 1, int.MaxValue)]\n [InlineData(int.MinValue, -1, int.MaxValue)]\n [InlineData(int.MinValue + 1, int.MinValue, 1)]\n [InlineData(int.MinValue + 1, int.MinValue, int.MaxValue)]\n [InlineData(int.MinValue + 1, 0, int.MaxValue)]\n [InlineData(-1, int.MinValue, int.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, int.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, int.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, int.MaxValue)]\n [InlineData(0, int.MaxValue, int.MaxValue)]\n [InlineData(0, int.MinValue + 1, int.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, int.MaxValue)]\n [InlineData(1, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue - 1, int.MaxValue, 1)]\n [InlineData(int.MaxValue - 1, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue, 0, int.MaxValue)]\n [InlineData(int.MaxValue, 1, int.MaxValue)]\n [InlineData(int.MaxValue, int.MaxValue, 0)]\n [InlineData(int.MaxValue, int.MaxValue, 1)]\n [InlineData(int.MaxValue, int.MaxValue, int.MaxValue)]\n [InlineData(int.MaxValue, int.MaxValue - 1, 1)]\n [InlineData(int.MaxValue, int.MaxValue - 1, int.MaxValue)]\n [Theory]\n public void When_an_int_value_is_close_to_expected_value_it_should_fail(int actual, int distantValue, uint delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_int_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n int actual = 1;\n int nearbyValue = 3;\n uint delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_an_int_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n int actual = int.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(long.MinValue, long.MaxValue, 1)]\n [InlineData(long.MinValue, 0, long.MaxValue)]\n [InlineData(long.MinValue, 1, long.MaxValue)]\n [InlineData(long.MinValue + 1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(-1, 0, 0)]\n [InlineData(-1, 1, 1)]\n [InlineData(-1, long.MaxValue, long.MaxValue)]\n [InlineData(-1, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, long.MinValue, long.MaxValue)]\n [InlineData(0, long.MinValue + 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, -1, 0)]\n [InlineData(0, 1, 0)]\n [InlineData(1, -1, 1)]\n [InlineData(1, 0, 0)]\n [InlineData(1, long.MinValue, long.MaxValue)]\n [InlineData(long.MaxValue, long.MinValue, 1)]\n [InlineData(long.MaxValue, -1, long.MaxValue)]\n [InlineData(long.MaxValue, 0, (ulong.MaxValue / 2) - 1)]\n [Theory]\n public void When_a_long_value_is_not_close_to_expected_value_it_should_succeed(long actual, long distantValue,\n ulong delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(long.MinValue, long.MinValue, 0)]\n [InlineData(long.MinValue, long.MinValue, 1)]\n [InlineData(long.MinValue, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(long.MinValue, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue, long.MinValue, ulong.MaxValue)]\n [InlineData(long.MinValue, long.MinValue + 1, 1)]\n [InlineData(long.MinValue, long.MinValue + 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue, long.MinValue + 1, ulong.MaxValue / 2)]\n [InlineData(long.MinValue, long.MinValue + 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue, long.MinValue + 1, ulong.MaxValue)]\n [InlineData(long.MinValue, -1, long.MaxValue)]\n [InlineData(long.MinValue + 1, long.MinValue, 1)]\n [InlineData(long.MinValue + 1, long.MinValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MinValue + 1, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(long.MinValue + 1, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue + 1, long.MinValue, ulong.MaxValue)]\n [InlineData(long.MinValue + 1, 0, ulong.MaxValue / 2)]\n [InlineData(long.MinValue + 1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MinValue + 1, 0, ulong.MaxValue)]\n [InlineData(long.MinValue, long.MaxValue, ulong.MaxValue)]\n [InlineData(-1, long.MinValue, ulong.MaxValue / 2)]\n [InlineData(-1, long.MinValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(-1, long.MinValue, ulong.MaxValue)]\n [InlineData(-1, 0, 1)]\n [InlineData(-1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(-1, 0, ulong.MaxValue / 2)]\n [InlineData(-1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(-1, 0, ulong.MaxValue)]\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, -1, 1)]\n [InlineData(0, -1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, -1, ulong.MaxValue / 2)]\n [InlineData(0, -1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, -1, ulong.MaxValue)]\n [InlineData(0, 1, 1)]\n [InlineData(0, 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(0, 1, ulong.MaxValue / 2)]\n [InlineData(0, 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, 1, ulong.MaxValue)]\n [InlineData(0, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(0, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, long.MaxValue, ulong.MaxValue)]\n [InlineData(0, long.MinValue + 1, ulong.MaxValue / 2)]\n [InlineData(0, long.MinValue + 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(0, long.MinValue + 1, ulong.MaxValue)]\n [InlineData(1, 0, 1)]\n [InlineData(1, 0, (ulong.MaxValue / 2) - 1)]\n [InlineData(1, 0, ulong.MaxValue / 2)]\n [InlineData(1, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(1, 0, ulong.MaxValue)]\n [InlineData(1, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(1, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(1, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(1, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue - 1, long.MaxValue, 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue - 1, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue - 1, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue, 0, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, 0, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, 0, ulong.MaxValue)]\n [InlineData(long.MaxValue, 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, 1, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, 1, ulong.MaxValue)]\n [InlineData(long.MaxValue, long.MaxValue, 0)]\n [InlineData(long.MaxValue, long.MaxValue, 1)]\n [InlineData(long.MaxValue, long.MaxValue, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, long.MaxValue, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, long.MaxValue, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, long.MaxValue, ulong.MaxValue)]\n [InlineData(long.MaxValue, long.MaxValue - 1, 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, (ulong.MaxValue / 2) - 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, ulong.MaxValue / 2)]\n [InlineData(long.MaxValue, long.MaxValue - 1, (ulong.MaxValue / 2) + 1)]\n [InlineData(long.MaxValue, long.MaxValue - 1, ulong.MaxValue)]\n [Theory]\n public void When_a_long_value_is_close_to_expected_value_it_should_fail(long actual, long distantValue, ulong delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_long_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n long actual = 1;\n long nearbyValue = 3;\n ulong delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_a_long_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n long actual = long.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(byte.MinValue, byte.MaxValue, 1)]\n [InlineData(byte.MaxValue, byte.MinValue, 1)]\n [Theory]\n public void When_a_byte_value_is_not_close_to_expected_value_it_should_succeed(byte actual, byte distantValue,\n byte delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, byte.MaxValue, byte.MaxValue)]\n [InlineData(byte.MinValue, byte.MinValue + 1, byte.MaxValue)]\n [InlineData(byte.MinValue + 1, 0, byte.MaxValue)]\n [InlineData(byte.MinValue + 1, byte.MinValue, 1)]\n [InlineData(byte.MinValue + 1, byte.MinValue, byte.MaxValue)]\n [InlineData(byte.MaxValue - 1, byte.MaxValue, 1)]\n [InlineData(byte.MaxValue - 1, byte.MaxValue, byte.MaxValue)]\n [InlineData(byte.MaxValue, 0, byte.MaxValue)]\n [InlineData(byte.MaxValue, 1, byte.MaxValue)]\n [InlineData(byte.MaxValue, byte.MaxValue - 1, 1)]\n [InlineData(byte.MaxValue, byte.MaxValue - 1, byte.MaxValue)]\n [InlineData(byte.MaxValue, byte.MaxValue, 0)]\n [InlineData(byte.MaxValue, byte.MaxValue, 1)]\n [Theory]\n public void When_a_byte_value_is_close_to_expected_value_it_should_fail(byte actual, byte distantValue, byte delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_byte_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n byte actual = 1;\n byte nearbyValue = 3;\n byte delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_a_byte_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n byte actual = byte.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(ushort.MinValue, ushort.MaxValue, 1)]\n [InlineData(ushort.MaxValue, ushort.MinValue, 1)]\n [Theory]\n public void When_an_ushort_value_is_not_close_to_expected_value_it_should_succeed(ushort actual, ushort distantValue,\n ushort delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, ushort.MaxValue, ushort.MaxValue)]\n [InlineData(ushort.MinValue, ushort.MinValue + 1, ushort.MaxValue)]\n [InlineData(ushort.MinValue + 1, 0, ushort.MaxValue)]\n [InlineData(ushort.MinValue + 1, ushort.MinValue, 1)]\n [InlineData(ushort.MinValue + 1, ushort.MinValue, ushort.MaxValue)]\n [InlineData(ushort.MaxValue - 1, ushort.MaxValue, 1)]\n [InlineData(ushort.MaxValue - 1, ushort.MaxValue, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, 0, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, 1, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, ushort.MaxValue - 1, 1)]\n [InlineData(ushort.MaxValue, ushort.MaxValue - 1, ushort.MaxValue)]\n [InlineData(ushort.MaxValue, ushort.MaxValue, 0)]\n [InlineData(ushort.MaxValue, ushort.MaxValue, 1)]\n [Theory]\n public void When_an_ushort_value_is_close_to_expected_value_it_should_fail(ushort actual, ushort distantValue,\n ushort delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_ushort_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n ushort actual = 1;\n ushort nearbyValue = 3;\n ushort delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_an_ushort_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n ushort actual = ushort.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(uint.MinValue, uint.MaxValue, 1)]\n [InlineData(uint.MaxValue, uint.MinValue, 1)]\n [Theory]\n public void When_an_uint_value_is_not_close_to_expected_value_it_should_succeed(uint actual, uint distantValue,\n uint delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, uint.MaxValue, uint.MaxValue)]\n [InlineData(uint.MinValue, uint.MinValue + 1, uint.MaxValue)]\n [InlineData(uint.MinValue + 1, 0, uint.MaxValue)]\n [InlineData(uint.MinValue + 1, uint.MinValue, 1)]\n [InlineData(uint.MinValue + 1, uint.MinValue, uint.MaxValue)]\n [InlineData(uint.MaxValue - 1, uint.MaxValue, 1)]\n [InlineData(uint.MaxValue - 1, uint.MaxValue, uint.MaxValue)]\n [InlineData(uint.MaxValue, 0, uint.MaxValue)]\n [InlineData(uint.MaxValue, 1, uint.MaxValue)]\n [InlineData(uint.MaxValue, uint.MaxValue - 1, 1)]\n [InlineData(uint.MaxValue, uint.MaxValue - 1, uint.MaxValue)]\n [InlineData(uint.MaxValue, uint.MaxValue, 0)]\n [InlineData(uint.MaxValue, uint.MaxValue, 1)]\n [Theory]\n public void When_an_uint_value_is_close_to_expected_value_it_should_fail(uint actual, uint distantValue, uint delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_uint_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n uint actual = 1;\n uint nearbyValue = 3;\n uint delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_an_uint_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n uint actual = uint.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n\n [InlineData(0, 1, 0)]\n [InlineData(1, 0, 0)]\n [InlineData(ulong.MinValue, ulong.MaxValue, 1)]\n [InlineData(ulong.MaxValue, ulong.MinValue, 1)]\n [Theory]\n public void When_an_ulong_value_is_not_close_to_expected_value_it_should_succeed(ulong actual, ulong distantValue,\n ulong delta)\n {\n // Act / Assert\n actual.Should().NotBeCloseTo(distantValue, delta);\n }\n\n [InlineData(0, 0, 0)]\n [InlineData(0, 0, 1)]\n [InlineData(0, 1, 1)]\n [InlineData(1, 0, 1)]\n [InlineData(1, ulong.MaxValue, ulong.MaxValue)]\n [InlineData(ulong.MinValue, ulong.MinValue + 1, ulong.MaxValue)]\n [InlineData(ulong.MinValue + 1, 0, ulong.MaxValue)]\n [InlineData(ulong.MinValue + 1, ulong.MinValue, 1)]\n [InlineData(ulong.MinValue + 1, ulong.MinValue, ulong.MaxValue)]\n [InlineData(ulong.MaxValue - 1, ulong.MaxValue, 1)]\n [InlineData(ulong.MaxValue - 1, ulong.MaxValue, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, 0, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, 1, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, ulong.MaxValue - 1, 1)]\n [InlineData(ulong.MaxValue, ulong.MaxValue - 1, ulong.MaxValue)]\n [InlineData(ulong.MaxValue, ulong.MaxValue, 0)]\n [InlineData(ulong.MaxValue, ulong.MaxValue, 1)]\n [Theory]\n public void When_an_ulong_value_is_close_to_expected_value_it_should_fail(ulong actual, ulong distantValue,\n ulong delta)\n {\n // Act\n Action act = () => actual.Should().NotBeCloseTo(distantValue, delta);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_an_ulong_value_is_close_to_expected_value_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n ulong actual = 1;\n ulong nearbyValue = 3;\n ulong delta = 2;\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(nearbyValue, delta);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*be within*2*from*3*but found*1*\");\n }\n\n [Fact]\n public void When_an_ulong_value_is_returned_from_NotBeCloseTo_it_should_chain()\n {\n // Arrange\n ulong actual = ulong.MaxValue;\n\n // Act / Assert\n actual.Should().NotBeCloseTo(0, 0)\n .And.Be(actual);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/MethodBaseAssertionSpecs.cs", "using System;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class MethodBaseAssertionSpecs\n{\n public class Return\n {\n [Fact]\n public void When_asserting_an_int_method_returns_int_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().Return(typeof(int));\n }\n\n [Fact]\n public void When_asserting_an_int_method_returns_string_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(typeof(string), \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method IntMethod to be string because we want to test the \" +\n \"error message, but it is int.\");\n }\n\n [Fact]\n public void When_asserting_a_void_method_returns_string_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"VoidMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(typeof(string), \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method VoidMethod to be string because we want to test the \" +\n \"error message, but it is void.\");\n }\n\n [Fact]\n public void When_subject_is_null_return_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the return type of method to be string *failure message*, but methodInfo is .\");\n }\n\n [Fact]\n public void When_asserting_method_return_type_is_null_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"returnType\");\n }\n }\n\n public class NotReturn\n {\n [Fact]\n public void When_asserting_an_int_method_does_not_return_string_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().NotReturn(typeof(string));\n }\n\n [Fact]\n public void When_asserting_an_int_method_does_not_return_int_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(typeof(int), \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of*IntMethod*not to be int*because we want to test the \" +\n \"error message, but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_return_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the return type of method not to be string *failure message*, but methodInfo is .\");\n }\n\n [Fact]\n public void When_asserting_method_return_type_is_not_null_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"returnType\");\n }\n }\n\n public class ReturnOfT\n {\n [Fact]\n public void When_asserting_an_int_method_returnsOfT_int_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().Return();\n }\n\n [Fact]\n public void When_asserting_an_int_method_returnsOfT_string_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method IntMethod to be string because we want to test the \" +\n \"error message, but it is int.\");\n }\n\n [Fact]\n public void When_subject_is_null_returnOfT_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().Return(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method to be string *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotReturnOfT\n {\n [Fact]\n public void When_asserting_an_int_method_does_not_returnsOfT_string_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().NotReturn();\n }\n\n [Fact]\n public void When_asserting_an_int_method_does_not_returnsOfT_int_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of*IntMethod*not to be int*because we want to test the \" +\n \"error message, but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_returnOfT_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturn(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the return type of method not to be string *failure message*, but methodInfo is .\");\n }\n }\n\n public class ReturnVoid\n {\n [Fact]\n public void When_asserting_a_void_method_returns_void_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"VoidMethod\");\n\n // Act / Assert\n methodInfo.Should().ReturnVoid();\n }\n\n [Fact]\n public void When_asserting_an_int_method_returns_void_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().ReturnVoid(\"because we want to test the error message {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected the return type of method IntMethod to be void because we want to test the error message \" +\n \"message, but it is int.\");\n }\n\n [Fact]\n public void When_subject_is_null_return_void_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().ReturnVoid(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method to be void *failure message*, but methodInfo is .\");\n }\n }\n\n public class NotReturnVoid\n {\n [Fact]\n public void When_asserting_an_int_method_does_not_return_void_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"IntMethod\");\n\n // Act / Assert\n methodInfo.Should().NotReturnVoid();\n }\n\n [Fact]\n public void When_asserting_a_void_method_does_not_return_void_it_fails_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"VoidMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturnVoid(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of*VoidMethod*not to be void*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_subject_is_null_not_return_void_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotReturnVoid(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the return type of method not to be void *failure message*, but methodInfo is .\");\n }\n }\n\n public class HaveAccessModifier\n {\n [Fact]\n public void When_asserting_a_private_member_is_private_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act / Assert\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_private_protected_member_is_private_protected_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateProtectedMethod\");\n\n // Act / Assert\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.PrivateProtected);\n }\n\n [Fact]\n public void When_asserting_a_private_member_is_protected_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should()\n .HaveAccessModifier(CSharpAccessModifier.Protected, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.PrivateMethod to be Protected because we want to test the error message\" +\n \", but it is Private.\");\n }\n\n [Fact]\n public void When_asserting_a_protected_member_is_protected_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"ProtectedSetProperty\");\n\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act / Assert\n setMethod.Should().HaveAccessModifier(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_protected_member_is_public_it_throws_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"ProtectedSetProperty\");\n\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act\n Action act = () =>\n setMethod\n .Should()\n .HaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.set_ProtectedSetProperty to be Public because we want to test the error message\" +\n \", but it is Protected.\");\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_public_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetProperty\");\n\n MethodInfo getMethod = propertyInfo.GetMethod;\n\n // Act / Assert\n getMethod.Should().HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_internal_it_throws_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetProperty\");\n\n MethodInfo getMethod = propertyInfo.GetMethod;\n\n // Act\n Action act = () =>\n getMethod\n .Should()\n .HaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.get_PublicGetProperty to be Internal because we want to test the error message, but it\" +\n \" is Public.\");\n }\n\n [Fact]\n public void When_asserting_an_internal_member_is_internal_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"InternalMethod\");\n\n // Act / Assert\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void When_asserting_an_internal_member_is_protectedInternal_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"InternalMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.ProtectedInternal, \"because we want to test the\" +\n \" error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.InternalMethod to be ProtectedInternal because we want to test the error message, but\" +\n \" it is Internal.\");\n }\n\n [Fact]\n public void When_asserting_a_protected_internal_member_is_protected_internal_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"ProtectedInternalMethod\");\n\n // Act / Assert\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_a_protected_internal_member_is_private_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"ProtectedInternalMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.Private, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.ProtectedInternalMethod to be Private because we want to test the error message, but it is \" +\n \"ProtectedInternal.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_access_modifier_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().HaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method to be Public *failure message*, but methodInfo is .\");\n }\n\n [Fact]\n public void When_asserting_method_has_access_modifier_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().HaveAccessModifier((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n\n public class NotHaveAccessModifier\n {\n [Fact]\n public void When_asserting_a_private_member_is_not_protected_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act / Assert\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_private_member_is_not_private_protected_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act / Assert\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.PrivateProtected);\n }\n\n [Fact]\n public void When_asserting_a_private_member_is_not_private_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Private, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method TestClass.PrivateMethod not to be Private*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_asserting_a_protected_member_is_not_internal_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"ProtectedSetProperty\");\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act / Assert\n setMethod.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void When_asserting_a_protected_member_is_not_protected_it_throws_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"ProtectedSetProperty\");\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act\n Action act = () =>\n setMethod\n .Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Protected, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.set_ProtectedSetProperty not to be Protected*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_not_private_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetProperty\");\n MethodInfo getMethod = propertyInfo.GetMethod;\n\n // Act / Assert\n getMethod.Should().NotHaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_private_protected_member_is_not_private_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetPrivateProtectedSet\");\n MethodInfo setMethod = propertyInfo.SetMethod;\n\n // Act / Assert\n setMethod.Should().NotHaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_not_public_it_throws_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(TestClass).FindPropertyByName(\"PublicGetProperty\");\n MethodInfo getMethod = propertyInfo.GetMethod;\n\n // Act\n Action act = () =>\n getMethod\n .Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method TestClass.get_PublicGetProperty not to be Public*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_asserting_an_internal_member_is_not_protectedInternal_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"InternalMethod\");\n\n // Act / Assert\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_an_internal_member_is_not_internal_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"InternalMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal, \"because we want to test the\" +\n \" error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method TestClass.InternalMethod not to be Internal*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_asserting_a_protected_internal_member_is_not_public_it_succeeds()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"ProtectedInternalMethod\");\n\n // Act / Assert\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_protected_internal_member_is_not_protected_internal_it_throws_with_a_useful_message()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"ProtectedInternalMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotHaveAccessModifier(CSharpAccessModifier.ProtectedInternal, \"we want to test the error {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method TestClass.ProtectedInternalMethod not to be ProtectedInternal*because we want to test the error message*\");\n }\n\n [Fact]\n public void When_subject_is_not_null_have_access_modifier_should_fail()\n {\n // Arrange\n MethodInfo methodInfo = null;\n\n // Act\n Action act = () =>\n methodInfo.Should().NotHaveAccessModifier(\n CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method not to be Public *failure message*, but methodInfo is .\");\n }\n\n [Fact]\n public void When_asserting_method_does_not_have_access_modifier_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n MethodInfo methodInfo = typeof(TestClass).GetParameterlessMethod(\"PrivateMethod\");\n\n // Act\n Action act = () =>\n methodInfo.Should().NotHaveAccessModifier((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n}\n\n#region Internal classes used in unit tests\n\ninternal class TestClass\n{\n public void VoidMethod() { }\n\n public int IntMethod() { return 0; }\n\n private void PrivateMethod() { }\n\n public string PublicGetProperty { get; private set; }\n\n protected string ProtectedSetProperty { private get; set; }\n\n public string PublicGetPrivateProtectedSet { get; private protected set; }\n\n internal string InternalMethod() { return null; }\n\n protected internal void ProtectedInternalMethod() { }\n\n private protected void PrivateProtectedMethod() { }\n}\n\n#endregion\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.Be.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_equals_an_equal_value()\n {\n // Arrange\n int? nullableIntegerA = 1;\n int? nullableIntegerB = 1;\n\n // Act / Assert\n nullableIntegerA.Should().Be(nullableIntegerB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_null_value_equals_null()\n {\n // Arrange\n int? nullableIntegerA = null;\n int? nullableIntegerB = null;\n\n // Act / Assert\n nullableIntegerA.Should().Be(nullableIntegerB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n int? nullableIntegerA = 1;\n int? nullableIntegerB = 2;\n\n // Act\n Action act = () => nullableIntegerA.Should().Be(nullableIntegerB);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n int? nullableIntegerA = 1;\n int? nullableIntegerB = 2;\n\n // Act\n Action act = () =>\n nullableIntegerA.Should().Be(nullableIntegerB, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*2 because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void Nan_is_never_equal_to_a_normal_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().Be(3.4F);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected value to be *3.4F, but found NaN*\");\n }\n\n [Fact]\n public void NaN_can_be_compared_to_NaN_when_its_a_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n value.Should().Be(float.NaN);\n }\n\n [Fact]\n public void Nan_is_never_equal_to_a_normal_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().Be(3.4D);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be *3.4, but found NaN*\");\n }\n\n [Fact]\n public void NaN_can_be_compared_to_NaN_when_its_a_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n value.Should().Be(double.NaN);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/IParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\n/// \n/// Represents a stateful parsing strategy that is used to help identify the \"caller\" to use in an assertion message.\n/// \n/// \n/// The strategies will be instantiated at the beginning of a \"caller identification\" task, and will live until\n/// the statement can be identified (and thus some are stateful).\n/// \ninternal interface IParsingStrategy\n{\n /// \n /// Given a symbol, the parsing strategy should add/remove from the statement if needed, and then return\n /// - InProgress if the symbol isn't relevant to the strategies (so other strategies can be tried)\n /// - Handled if an action has been taken (and no other strategies should be used for this symbol)\n /// - Done if the statement is complete, and thus further symbols should be read.\n /// \n ParsingState Parse(char symbol, StringBuilder statement);\n\n /// \n /// Returns true if strategy is in the middle of a context (ex: strategy read \"/*\" and is waiting for \"*/\"\n /// \n bool IsWaitingForContextEnd();\n\n /// \n /// Used to notify the strategy that we have reached the end of the line (very useful to detect the end of\n /// a single line comment).\n /// \n void NotifyEndOfLineReached();\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.MatchRegex.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Text.RegularExpressions;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]MatchRegex specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class MatchRegex\n {\n [Fact]\n public void When_a_string_matches_a_regular_expression_string_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n // ReSharper disable once StringLiteralTypo\n subject.Should().MatchRegex(\"h.*\\\\sworld.$\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_a_string_does_not_match_a_regular_expression_string_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(\"h.*\\\\sworld?$\", \"that's the universal greeting\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected subject to match regex*\\\"h.*\\\\sworld?$\\\" because that's the universal greeting, but*\\\"hello world!\\\" does not match.\");\n }\n\n [Fact]\n public void When_a_null_string_is_matched_against_a_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () => subject.Should().MatchRegex(\".*\", \"because it should be a string\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match regex*\\\".*\\\" because it should be a string, but it was .\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_a_null_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchRegex((string)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the BeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_invalid_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n string invalidRegex = \".**\"; // Use local variable for this invalid regex to avoid static R# analysis errors\n\n // Act\n Action act = () => subject.Should().MatchRegex(invalidRegex);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match subject against \\\".**\\\" because it is not a valid regular expression.*\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_invalid_regex_string_it_should_only_have_one_failure_message()\n {\n // Arrange\n string subject = \"hello world!\";\n string invalidRegex = \".**\"; // Use local variable for this invalid regex to avoid static R# analysis errors\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(invalidRegex);\n };\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Contain(\"is not a valid regular expression\")\n .And.NotContain(\"does not match\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_empty_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_matches_a_regular_expression_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n // ReSharper disable once StringLiteralTypo\n subject.Should().MatchRegex(new Regex(\"h.*\\\\sworld.$\"));\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_a_string_does_not_match_a_regular_expression_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(new Regex(\"h.*\\\\sworld?$\"), \"that's the universal greeting\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected subject to match regex*\\\"h.*\\\\sworld?$\\\" because that's the universal greeting, but*\\\"hello world!\\\" does not match.\");\n }\n\n [Fact]\n public void When_a_null_string_is_matched_against_a_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(new Regex(\".*\"), \"because it should be a string\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match regex*\\\".*\\\" because it should be a string, but it was .\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_a_null_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchRegex((Regex)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the BeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_empty_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(new Regex(string.Empty));\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_matched_and_the_count_of_matches_fits_into_the_expected_it_passes()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act / Assert\n subject.Should().MatchRegex(new Regex(\"hello.*\"), AtLeast.Once());\n }\n\n [Fact]\n public void When_a_string_is_matched_and_the_count_of_matches_do_not_fit_the_expected_it_fails()\n {\n // Arrange\n string subject = \"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt \" +\n \"ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et \" +\n \"ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(\"Lorem.*\", Exactly.Twice());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject*Lorem*to match regex*\\\"Lorem.*\\\" exactly 2 times, but found it 1 time*\");\n }\n\n [Fact]\n public void When_a_string_is_matched_and_the_expected_count_is_zero_and_string_not_matches_it_passes()\n {\n // Arrange\n string subject = \"a\";\n\n // Act / Assert\n subject.Should().MatchRegex(\"b\", Exactly.Times(0));\n }\n\n [Fact]\n public void When_a_string_is_matched_and_the_expected_count_is_zero_and_string_matches_it_fails()\n {\n // Arrange\n string subject = \"a\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(\"a\", Exactly.Times(0));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject*a*to match regex*\\\"a\\\" exactly 0 times, but found it 1 time*\");\n }\n\n [Fact]\n public void When_the_subject_is_null_it_fails()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(\".*\", Exactly.Times(0), \"because it should be a string\");\n };\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Expected subject to match regex*\\\".*\\\" because it should be a string, but it was .\");\n }\n\n [Fact]\n public void When_the_subject_is_empty_and_expected_count_is_zero_it_passes()\n {\n // Arrange\n string subject = string.Empty;\n\n // Act / Assert\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(\"a\", Exactly.Times(0));\n }\n\n [Fact]\n public void When_the_subject_is_empty_and_expected_count_is_more_than_zero_it_fails()\n {\n // Arrange\n string subject = string.Empty;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().MatchRegex(\".+\", AtLeast.Once());\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject*to match regex* at least 1 time, but found it 0 times*\");\n }\n\n [Fact]\n public void When_regex_is_null_it_fails_and_ignores_occurrences()\n {\n // Arrange\n string subject = \"a\";\n\n // Act\n Action act = () => subject.Should().MatchRegex((Regex)null, Exactly.Times(0));\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the BeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_regex_is_empty_it_fails_and_ignores_occurrences()\n {\n // Arrange\n string subject = \"a\";\n\n // Act\n Action act = () => subject.Should().MatchRegex(string.Empty, Exactly.Times(0));\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against an empty string. Provide a regex pattern or use the BeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_regex_is_invalid_it_fails_and_ignores_occurrences()\n {\n // Arrange\n string subject = \"a\";\n\n // Act\n#pragma warning disable RE0001 // Invalid regex pattern\n Action act = () => subject.Should().MatchRegex(\".**\", Exactly.Times(0));\n#pragma warning restore RE0001 // Invalid regex pattern\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match subject against \\\".**\\\" because it is not a valid regular expression.*\");\n }\n }\n\n public class NotMatchRegex\n {\n [Fact]\n public void When_a_string_does_not_match_a_regular_expression_string_and_it_shouldnt_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n subject.Should().NotMatchRegex(\".*earth.*\");\n }\n\n [Fact]\n public void When_a_string_matches_a_regular_expression_string_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(\".*world.*\", \"because that's illegal\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect subject to match regex*\\\".*world.*\\\" because that's illegal, but*\\\"hello world!\\\" matches.\");\n }\n\n [Fact]\n public void When_a_null_string_is_negatively_matched_against_a_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(\".*\", \"because it should not be a string\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to not match regex*\\\".*\\\" because it should not be a string, but it was .\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_a_null_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex((string)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the NotBeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_invalid_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n string invalidRegex = \".**\"; // Use local variable for this invalid regex to avoid static R# analysis errors\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(invalidRegex);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match subject against \\\".**\\\" because it is not a valid regular expression.*\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_invalid_regex_string_it_only_contain_one_failure_message()\n {\n // Arrange\n string subject = \"hello world!\";\n string invalidRegex = \".**\"; // Use local variable for this invalid regex to avoid static R# analysis errors\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().NotMatchRegex(invalidRegex);\n };\n\n // Assert\n act.Should().Throw()\n .Which.Message.Should().Contain(\"is not a valid regular expression\")\n .And.NotContain(\"matches\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_empty_regex_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty regex pattern. Provide a regex pattern or use the NotBeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_does_not_match_a_regular_expression_and_it_shouldnt_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n subject.Should().NotMatchRegex(new Regex(\".*earth.*\"));\n }\n\n [Fact]\n public void When_a_string_matches_a_regular_expression_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(new Regex(\".*world.*\"), \"because that's illegal\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect subject to match regex*\\\".*world.*\\\" because that's illegal, but*\\\"hello world!\\\" matches.\");\n }\n\n [Fact]\n public void When_a_null_string_is_negatively_matched_against_a_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n subject.Should().NotMatchRegex(new Regex(\".*\"), \"because it should not be a string\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to not match regex*\\\".*\\\" because it should not be a string, but it was .\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_a_null_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex((Regex)null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot match string against . Provide a regex pattern or use the NotBeNull method.*\")\n .WithParameterName(\"regularExpression\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_empty_regex_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatchRegex(new Regex(string.Empty));\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty regex pattern. Provide a regex pattern or use the NotBeEmpty method.*\")\n .WithParameterName(\"regularExpression\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.Contain.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class Contain\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_single_key_value_pair()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\")\n };\n\n // Act / Assert\n dictionary.Should().Contain(keyValuePairs);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_multiple_key_value_pair()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\",\n [4] = \"Four\"\n };\n\n var expectedKeyValuePair1 = new KeyValuePair(2, \"Two\");\n var expectedKeyValuePair2 = new KeyValuePair(3, \"Three\");\n\n // Act / Assert\n dictionary.Should().Contain(expectedKeyValuePair1, expectedKeyValuePair2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_multiple_key_value_pairs()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\"),\n new(2, \"Two\")\n };\n\n // Act / Assert\n dictionary.Should().Contain(keyValuePairs);\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_single_value_for_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\"),\n new(2, \"Three\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"Three\\\" at key 2 because we do, but found \\\"Two\\\".\");\n }\n\n [Fact]\n public void\n When_a_dictionary_does_not_contain_multiple_values_for_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"Two\"),\n new(2, \"Three\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain {[1, Two], [2, Three]} because we do, but dictionary differs at keys {1, 2}.\");\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_single_key_for_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(3, \"Three\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain key 3 because we do.\");\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_multiple_keys_for_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\"),\n new(3, \"Three\"),\n new(4, \"Four\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain key(s) {1, 3, 4} because we do, but could not find keys {3, 4}.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_contains_key_value_pairs_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n List> keyValuePairs =\n [\n new KeyValuePair(1, \"One\"),\n new KeyValuePair(1, \"Two\")\n ];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().Contain(keyValuePairs, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain key/value pairs {[1, One], [1, Two]} because we want to test the behaviour with a null subject, but dictionary is .\");\n }\n\n [Fact]\n public void When_asserting_dictionary_contains_key_value_pairs_but_expected_key_value_pairs_are_empty_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n List> keyValuePairs = [];\n\n // Act\n Action act = () => dictionary1.Should().Contain(keyValuePairs,\n \"because we want to test the behaviour with an empty set of key/value pairs\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify key containment against an empty collection of key/value pairs*\");\n }\n\n [Fact]\n public void When_asserting_dictionary_contains_key_value_pairs_but_expected_key_value_pairs_are_null_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n List> keyValuePairs = null;\n\n // Act\n Action act = () =>\n dictionary1.Should().Contain(keyValuePairs, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare dictionary with .*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_dictionary_contains_expected_value_at_specific_key_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().Contain(1, \"One\");\n }\n\n [Fact]\n public void When_dictionary_contains_expected_null_at_specific_key_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = null\n };\n\n // Act / Assert\n dictionary.Should().Contain(1, null);\n }\n\n [Fact]\n public void When_dictionary_contains_expected_key_value_pairs_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n var items = new List>\n {\n new(1, \"One\"),\n new(2, \"Two\")\n };\n\n dictionary.Should().Contain(items);\n }\n\n [Fact]\n public void When_dictionary_contains_expected_key_value_pair_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n var item = new KeyValuePair(1, \"One\");\n dictionary.Should().Contain(item);\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_the_expected_value_at_specific_key_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n var item = new KeyValuePair(1, \"Two\");\n Action act = () => dictionary.Should().Contain(item, \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"Two\\\" at key 1 because we put it there, but found \\\"One\\\".\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_the_key_value_pairs_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var items = new List>\n {\n new(1, \"Two\"),\n new(2, \"Three\")\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(items, \"we put them {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain {[1, Two], [2, Three]} because we put them there, but dictionary differs at keys {1, 2}.\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_the_key_value_pair_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(1, \"Two\", \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"Two\\\" at key 1 because we put it there, but found \\\"One\\\".\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_an_value_at_the_specific_key_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().Contain(3, \"Two\", \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"Two\\\" at key 3 because we put it there, but the key was not found.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_contains_value_at_specific_key_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().Contain(1, \"One\", \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain value \\\"One\\\" at key 1 because we want to test the behaviour with a null subject, but dictionary is .\");\n }\n\n [Fact]\n public void When_a_dictionary_like_collection_contains_the_default_key_it_should_succeed()\n {\n // Arrange\n var subject = new List>\n { new(0, 0) };\n\n // Act / Assert\n subject.Should().Contain(0, 0);\n }\n }\n\n public class NotContain\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_does_not_contain_single_key_value_pair()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(3, \"Three\")\n };\n\n // Act / Assert\n dictionary.Should().NotContain(keyValuePairs);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_does_not_contain_multiple_key_value_pair()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var unexpectedKeyValuePair1 = new KeyValuePair(3, \"Three\");\n var unexpectedKeyValuePair2 = new KeyValuePair(4, \"Four\");\n\n // Act / Assert\n dictionary.Should().NotContain(unexpectedKeyValuePair1, unexpectedKeyValuePair2);\n }\n\n [Fact]\n public void\n Should_succeed_when_asserting_dictionary_does_not_contain_single_key_value_pair_with_existing_key_but_different_value()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"Two\")\n };\n\n // Act / Assert\n dictionary.Should().NotContain(keyValuePairs);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_does_not_contain_multiple_key_value_pairs()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(3, \"Three\"),\n new(4, \"Four\")\n };\n\n // Act / Assert\n dictionary.Should().NotContain(keyValuePairs);\n }\n\n [Fact]\n public void\n Should_succeed_when_asserting_dictionary_does_not_contain_multiple_key_value_pairs_with_existing_keys_but_different_values()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"Three\"),\n new(2, \"Four\")\n };\n\n // Act / Assert\n dictionary.Should().NotContain(keyValuePairs);\n }\n\n [Fact]\n public void When_a_dictionary_does_contain_single_key_value_pair_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\")\n };\n\n // Act\n Action act = () => dictionary.Should().NotContain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain value \\\"One\\\" at key 1 because we do, but found it anyhow.\");\n }\n\n [Fact]\n public void When_a_dictionary_does_contain_multiple_key_value_pairs_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var keyValuePairs = new List>\n {\n new(1, \"One\"),\n new(2, \"Two\")\n };\n\n // Act\n Action act = () => dictionary.Should().NotContain(keyValuePairs, \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain key/value pairs {[1, One], [2, Two]} because we do, but found them anyhow.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_does_not_contain_key_value_pairs_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n List> keyValuePairs =\n [\n new KeyValuePair(1, \"One\"),\n new KeyValuePair(1, \"Two\")\n ];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContain(keyValuePairs, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain key/value pairs {[1, One], [1, Two]} because we want to test the behaviour with a null subject, but dictionary is .\");\n }\n\n [Fact]\n public void\n When_asserting_dictionary_does_not_contain_key_value_pairs_but_expected_key_value_pairs_are_empty_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n List> keyValuePair = [];\n\n // Act\n Action act = () => dictionary1.Should().NotContain(keyValuePair,\n \"because we want to test the behaviour with an empty set of key/value pairs\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify key containment against an empty collection of key/value pairs*\");\n }\n\n [Fact]\n public void\n When_asserting_dictionary_does_not_contain_key_value_pairs_but_expected_key_value_pairs_are_null_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n List> keyValuePairs = null;\n\n // Act\n Action act = () =>\n dictionary1.Should().NotContain(keyValuePairs, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare dictionary with .*\")\n .WithParameterName(\"items\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_unexpected_value_or_key_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().NotContain(3, \"Three\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_unexpected_value_at_existing_key_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().NotContain(2, \"Three\");\n }\n\n [Fact]\n public void When_dictionary_does_not_have_the_unexpected_value_but_null_at_existing_key_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = null\n };\n\n // Act / Assert\n dictionary.Should().NotContain(1, \"other\");\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_unexpected_key_value_pairs_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n var items = new List>\n {\n new(3, \"Three\"),\n new(4, \"Four\")\n };\n\n dictionary.Should().NotContain(items);\n }\n\n [Fact]\n public void When_dictionary_does_not_contain_unexpected_key_value_pair_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n var item = new KeyValuePair(3, \"Three\");\n dictionary.Should().NotContain(item);\n }\n\n [Fact]\n public void When_dictionary_contains_the_unexpected_value_at_specific_key_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n var item = new KeyValuePair(1, \"One\");\n Action act = () => dictionary.Should().NotContain(item, \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain value \\\"One\\\" at key 1 because we put it there, but found it anyhow.\");\n }\n\n [Fact]\n public void When_dictionary_contains_the_key_value_pairs_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n var items = new List>\n {\n new(1, \"One\"),\n new(2, \"Two\")\n };\n\n Action act = () => dictionary.Should().NotContain(items, \"we did not put them {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain key/value pairs {[1, One], [2, Two]} because we did not put them there, but found them anyhow.\");\n }\n\n [Fact]\n public void When_dictionary_contains_the_key_value_pair_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContain(1, \"One\", \"we did not put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain value \\\"One\\\" at key 1 because we did not put it there, but found it anyhow.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_does_not_contain_value_at_specific_key_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContain(1, \"One\", \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary not to contain value \\\"One\\\" at key 1 because we want to test the behaviour with a null subject, but dictionary is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeInDescendingOrder.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeInDescendingOrder specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeInDescendingOrder\n {\n [Fact]\n public void When_asserting_the_items_in_an_descendingly_ordered_collection_are_ordered_descending_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"z\", \"y\", \"x\"];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder();\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_unordered_collection_are_ordered_descending_it_should_throw()\n {\n // Arrange\n string[] collection = [\"z\", \"x\", \"y\"];\n\n // Act\n Action action = () => collection.Should().BeInDescendingOrder(\"because letters are ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to be in descending order because letters are ordered,\" +\n \" but found {\\\"z\\\", \\\"x\\\", \\\"y\\\"} where item at index 1 is in wrong order.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_by_property_expression_ordered_in_descending_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(o => o.Number);\n }\n\n [Fact]\n public void When_asserting_empty_collection_with_no_parameters_ordered_in_descending_it_should_succeed()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder();\n }\n\n [Fact]\n public void When_asserting_single_element_collection_with_no_parameters_ordered_in_descending_it_should_succeed()\n {\n // Arrange\n int[] collection = [42];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder();\n }\n\n [Fact]\n public void When_asserting_single_element_collection_by_property_expression_ordered_in_descending_it_should_succeed()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(o => o.Number);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_descending_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n string[] collection = [\"z\", \"x\", \"y\"];\n\n // Act\n Action action = () =>\n collection.Should().BeInDescendingOrder(Comparer.Default, \"because letters are ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to be in descending order because letters are ordered,\" +\n \" but found {\\\"z\\\", \\\"x\\\", \\\"y\\\"} where item at index 1 is in wrong order.\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_descendingly_ordered_collection_are_ordered_descending_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"z\", \"y\", \"x\"];\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_descending_using_the_specified_property_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act\n Action act = () => collection.Should().BeInDescendingOrder(o => o.Text, \"it should be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*ordered*Text*should be sorted*c*b*a*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_ordered_descending_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act\n Action act = () =>\n collection.Should().BeInDescendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase, \"it should be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*ordered*Text*should be sorted*c*b*a*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_descendingly_ordered_collection_are_ordered_descending_using_the_specified_property_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 3 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 1 }\n };\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(o => o.Numeric);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_descendingly_ordered_collection_are_ordered_descending_using_the_specified_property_and_the_given_comparer_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 3 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 1 }\n };\n\n // Act / Assert\n collection.Should().BeInDescendingOrder(o => o.Numeric, Comparer.Default);\n }\n\n [Fact]\n public void When_strings_are_in_descending_order_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"theta\", \"beta\", \"alpha\"];\n\n // Act / Assert\n strings.Should().BeInDescendingOrder();\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_it_should_throw()\n {\n // Arrange\n string[] strings = [\"theta\", \"alpha\", \"beta\"];\n\n // Act\n Action act = () => strings.Should().BeInDescendingOrder(\"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*descending*of reasons*index 1*\");\n }\n\n [Fact]\n public void When_strings_are_in_descending_order_based_on_a_custom_comparer_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"barbara\"];\n\n // Act / Assert\n strings.Should().BeInDescendingOrder(new ByLastCharacterComparer());\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_based_on_a_custom_comparer_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"barbara\"];\n\n // Act\n Action act = () => strings.Should().BeInDescendingOrder(new ByLastCharacterComparer(), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*descending*of reasons*index 0*\");\n }\n\n [Fact]\n public void When_strings_are_in_descending_order_based_on_a_custom_lambda_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"barbara\"];\n\n // Act / Assert\n strings.Should().BeInDescendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]));\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_based_on_a_custom_lambda_it_should_throw()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"barbara\"];\n\n // Act\n Action act = () =>\n strings.Should().BeInDescendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Expected*descending*of reasons*index 0*\");\n }\n }\n\n public class NotBeInDescendingOrder\n {\n [Fact]\n public void When_asserting_the_items_in_an_unordered_collection_are_not_in_descending_order_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"x\", \"y\", \"x\"];\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_unordered_collection_are_not_in_descending_order_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"x\", \"y\", \"x\"];\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void When_asserting_the_items_in_a_descending_ordered_collection_are_not_in_descending_order_it_should_throw()\n {\n // Arrange\n string[] collection = [\"c\", \"b\", \"a\"];\n\n // Act\n Action action = () => collection.Should().NotBeInDescendingOrder(\"because numbers are not ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order because numbers are not ordered,\" +\n \" but found {\\\"c\\\", \\\"b\\\", \\\"a\\\"}.\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_descending_ordered_collection_are_not_in_descending_order_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n string[] collection = [\"c\", \"b\", \"a\"];\n\n // Act\n Action action = () =>\n collection.Should().NotBeInDescendingOrder(Comparer.Default, \"because numbers are not ordered\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order because numbers are not ordered,\" +\n \" but found {\\\"c\\\", \\\"b\\\", \\\"a\\\"}.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_by_property_expression_to_not_be_ordered_in_descending_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(o => o.Number);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection {empty} to not be ordered \\\"by Number\\\" and not result in {empty}.\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_with_no_parameters_not_be_ordered_in_descending_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(\"because I say {0}\", \"so\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order because I say so, but found {empty}.\");\n }\n\n [Fact]\n public void When_asserting_single_element_collection_with_no_parameters_not_be_ordered_in_descending_it_should_throw()\n {\n // Arrange\n int[] collection = [42];\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order, but found {42}.\");\n }\n\n [Fact]\n public void\n When_asserting_single_element_collection_by_property_expression_to_not_be_ordered_in_descending_it_should_throw()\n {\n // Arrange\n var collection = new SomeClass[]\n {\n new() { Text = \"a\", Number = 1 }\n };\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(o => o.Number);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_descending_ordered_collection_are_not_ordered_descending_using_the_given_comparer_it_should_throw()\n {\n // Arrange\n int[] collection = [3, 2, 1];\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(Comparer.Default, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect collection to be in descending order*should not be sorted*3*2*1*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_descendingly_ordered_collection_are_not_ordered_descending_using_the_given_comparer_it_should_succeed()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder(Comparer.Default);\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_a_descending_ordered_collection_are_not_ordered_descending_using_the_specified_property_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"c\", Numeric = 3 },\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"a\", Numeric = 2 }\n };\n\n // Act\n Action act = () => collection.Should().NotBeInDescendingOrder(o => o.Text, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*b*c*a*not be ordered*Text*should not be sorted*c*b*a*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_in_an_ordered_collection_are_not_ordered_descending_using_the_specified_property_and_the_given_comparer_it_should_throw()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"C\", Numeric = 1 },\n new { Text = \"b\", Numeric = 2 },\n new { Text = \"A\", Numeric = 3 }\n };\n\n // Act\n Action act = () =>\n collection.Should()\n .NotBeInDescendingOrder(o => o.Text, StringComparer.OrdinalIgnoreCase, \"it should not be sorted\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection*C*b*A*not be ordered*Text*should not be sorted*C*b*A*\");\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_descendingly_ordered_collection_are_not_ordered_descending_using_the_specified_property_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder(o => o.Numeric);\n }\n\n [Fact]\n public void\n When_asserting_the_items_not_in_an_descendingly_ordered_collection_are_not_ordered_descending_using_the_specified_property_and_the_given_comparer_it_should_succeed()\n {\n // Arrange\n var collection = new[]\n {\n new { Text = \"b\", Numeric = 1 },\n new { Text = \"c\", Numeric = 2 },\n new { Text = \"a\", Numeric = 3 }\n };\n\n // Act / Assert\n collection.Should().NotBeInDescendingOrder(o => o.Numeric, Comparer.Default);\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"beta\", \"theta\", \"alpha\"];\n\n // Act / Assert\n strings.Should().NotBeInDescendingOrder();\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_descending_order_it_should_throw()\n {\n // Arrange\n string[] strings = [\"theta\", \"beta\", \"alpha\"];\n\n // Act\n Action act = () => strings.Should().NotBeInDescendingOrder(\"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*descending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_based_on_a_custom_comparer_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"roy\", \"barbara\", \"dennis\"];\n\n // Act / Assert\n strings.Should().NotBeInDescendingOrder(new ByLastCharacterComparer());\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_descending_order_based_on_a_custom_comparer_it_should_throw()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"barbara\"];\n\n // Act\n Action act = () => strings.Should().NotBeInDescendingOrder(new ByLastCharacterComparer(), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*descending*of reasons*but found*\");\n }\n\n [Fact]\n public void When_strings_are_not_in_descending_order_based_on_a_custom_lambda_it_should_succeed()\n {\n // Arrange\n string[] strings = [\"dennis\", \"roy\", \"barbara\"];\n\n // Act / Assert\n strings.Should().NotBeInDescendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]));\n }\n\n [Fact]\n public void When_strings_are_unexpectedly_in_descending_order_based_on_a_custom_lambda_it_should_throw()\n {\n // Arrange\n string[] strings = [\"roy\", \"dennis\", \"barbara\"];\n\n // Act\n Action act = () =>\n strings.Should().NotBeInDescendingOrder((sut, exp) => sut[^1].CompareTo(exp[^1]), \"of {0}\", \"reasons\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\"Did not expect*descending*of reasons*but found*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Execution/FallbackTestFrameworkTests.cs", "using AwesomeAssertions.Execution;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Execution;\n\npublic class FallbackTestFrameworkTests\n{\n [Fact]\n public void The_fallback_test_framework_is_available()\n {\n var sut = new FallbackTestFramework();\n\n sut.IsAvailable.Should().BeTrue();\n }\n\n [Fact]\n public void Throwing_with_messages_throws_the_exception()\n {\n var sut = new FallbackTestFramework();\n\n sut.Invoking(x => x.Throw(\"test message\")).Should().ThrowExactly()\n .WithMessage(\"test message\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeNullOrWhiteSpace.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeNullOrWhiteSpace specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeNullOrWhitespace\n {\n [InlineData(null)]\n [InlineData(\"\")]\n [InlineData(\" \")]\n [InlineData(\"\\n\\r\")]\n [Theory]\n public void When_correctly_asserting_null_or_whitespace_it_should_not_throw(string actual)\n {\n // Assert\n actual.Should().BeNullOrWhiteSpace();\n }\n\n [InlineData(\"a\")]\n [InlineData(\" a \")]\n [Theory]\n public void When_correctly_asserting_not_null_or_whitespace_it_should_not_throw(string actual)\n {\n // Assert\n actual.Should().NotBeNullOrWhiteSpace();\n }\n\n [Fact]\n public void When_a_valid_string_is_expected_to_be_null_or_whitespace_it_should_throw()\n {\n // Act\n Action act = () =>\n \" abc \".Should().BeNullOrWhiteSpace();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string to be or whitespace, but found \\\" abc \\\".\");\n }\n }\n\n public class NotBeNullOrWhitespace\n {\n [Fact]\n public void When_a_null_string_is_expected_to_not_be_null_or_whitespace_it_should_throw()\n {\n // Arrange\n string nullString = null;\n\n // Act\n Action act = () =>\n nullString.Should().NotBeNullOrWhiteSpace();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected nullString not to be or whitespace, but found .\");\n }\n\n [Fact]\n public void When_an_empty_string_is_expected_to_not_be_null_or_whitespace_it_should_throw()\n {\n // Act\n Action act = () =>\n \"\".Should().NotBeNullOrWhiteSpace();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string not to be or whitespace, but found \\\"\\\".\");\n }\n\n [Fact]\n public void When_a_whitespace_string_is_expected_to_not_be_null_or_whitespace_it_should_throw()\n {\n // Act\n Action act = () =>\n \" \".Should().NotBeNullOrWhiteSpace();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string not to be or whitespace, but found \\\" \\\".\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/MultidimensionalArrayFormatterSpecs.cs", "using System;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class MultidimensionalArrayFormatterSpecs\n{\n [Theory]\n [MemberData(nameof(MultiDimensionalArrayData))]\n public void When_formatting_a_multi_dimensional_array_it_should_show_structure(object value, string expected)\n {\n // Arrange\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Match(expected);\n }\n\n public static TheoryData MultiDimensionalArrayData => new()\n {\n {\n new int[0, 0],\n \"{empty}\"\n },\n {\n new[,]\n {\n { 1, 2 },\n { 3, 4 }\n },\n \"{{1, 2}, {3, 4}}\"\n },\n {\n new[,,]\n {\n {\n { 1, 2, 3 },\n { 4, 5, 6 }\n },\n {\n { 7, 8, 9 },\n { 10, 11, 12 }\n }\n },\n \"{{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}}\"\n },\n };\n\n [Fact]\n public void When_formatting_a_multi_dimensional_array_with_bounds_it_should_show_structure()\n {\n // Arrange\n int[] lengthsArray = [2, 3, 4];\n int[] boundsArray = [1, 5, 7];\n var value = Array.CreateInstance(typeof(string), lengthsArray, boundsArray);\n\n for (int i = value.GetLowerBound(0); i <= value.GetUpperBound(0); i++)\n {\n for (int j = value.GetLowerBound(1); j <= value.GetUpperBound(1); j++)\n {\n for (int k = value.GetLowerBound(2); k <= value.GetUpperBound(2); k++)\n {\n int[] indices = [i, j, k];\n value.SetValue($\"{i}-{j}-{k}\", indices);\n }\n }\n }\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Match(\n \"{{{'1-5-7', '1-5-8', '1-5-9', '1-5-10'}, {'1-6-7', '1-6-8', '1-6-9', '1-6-10'}, {'1-7-7', '1-7-8', '1-7-9', '1-7-10'}}, {{'2-5-7', '2-5-8', '2-5-9', '2-5-10'}, {'2-6-7', '2-6-8', '2-6-9', '2-6-10'}, {'2-7-7', '2-7-8', '2-7-9', '2-7-10'}}}\"\n .Replace(\"'\", \"\\\"\"));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeLessThan.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeLessThan\n {\n [Fact]\n public void When_time_is_not_less_than_30s_after_another_time_it_should_throw()\n {\n // Arrange\n var target = new DateTime(1, 1, 1, 12, 0, 30);\n DateTime subject = target + 30.Seconds();\n\n // Act\n Action act =\n () => subject.Should().BeLessThan(TimeSpan.FromSeconds(30)).After(target, \"{0}s is the max\", 30);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <12:01:00> to be less than 30s after <12:00:30> because 30s is the max, but it is ahead by 30s.\");\n }\n\n [Fact]\n public void When_time_is_less_than_30s_after_another_time_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(1, 1, 1, 12, 0, 30);\n DateTime subject = target + 20.Seconds();\n\n // Act / Assert\n subject.Should().BeLessThan(TimeSpan.FromSeconds(30)).After(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_less_than_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 25);\n\n // Act\n Action action = () => subject.Should().BeLessThan(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:25> to be less than 10s after <00:00:30>, but it is behind by 5s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_less_than_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 45);\n\n // Act\n Action action = () => subject.Should().BeLessThan(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:45> to be less than 10s before <00:00:30>, but it is ahead by 15s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.StartWith.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The StartWith specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class StartWith\n {\n [Fact]\n public void When_collection_does_not_start_with_a_specific_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().StartWith(\"ryan\", \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*ryan*because of some reason*but*john*\");\n }\n\n [Fact]\n public void When_collection_does_not_start_with_a_null_sequence_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\"];\n\n // Act\n Action act = () => collection.Should().StartWith((IEnumerable)null);\n\n // Assert\n act.Should().Throw()\n .Which.ParamName.Should().Be(\"expectation\");\n }\n\n [Fact]\n public void When_collection_does_not_start_with_a_null_sequence_using_a_comparer_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\"];\n\n // Act\n Action act = () => collection.Should().StartWith((IEnumerable)null, (_, _) => true);\n\n // Assert\n act.Should().Throw()\n .Which.ParamName.Should().Be(\"expectation\");\n }\n\n [Fact]\n public void When_collection_does_not_start_with_a_specific_element_in_a_sequence_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().StartWith([\"john\", \"ryan\", \"jane\"], \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*ryan*because of some reason*but*differs at index 1*\");\n }\n\n [Fact]\n public void\n When_collection_does_not_start_with_a_specific_element_in_a_sequence_using_custom_equality_comparison_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().StartWith([\"john\", \"ryan\", \"jane\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.Ordinal), \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*ryan*because of some reason*but*differs at index 1*\");\n }\n\n [Fact]\n public void When_collection_starts_with_the_specific_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith(\"john\");\n }\n\n [Fact]\n public void When_collection_starts_with_the_specific_sequence_of_elements_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith([\"john\", \"bill\"]);\n }\n\n [Fact]\n public void\n When_collection_starts_with_the_specific_sequence_of_elements_using_custom_equality_comparison_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith([\"JoHn\", \"bIlL\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_collection_starts_with_the_specific_null_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [null, \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith((string)null);\n }\n\n [Fact]\n public void When_non_empty_collection_starts_with_the_empty_sequence_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith(new string[] { });\n }\n\n [Fact]\n public void When_empty_collection_starts_with_the_empty_sequence_it_should_not_throw()\n {\n // Arrange\n string[] collection = [];\n\n // Act / Assert\n collection.Should().StartWith(new string[] { });\n }\n\n [Fact]\n public void When_collection_starts_with_the_specific_sequence_with_null_elements_it_should_not_throw()\n {\n // Arrange\n string[] collection = [null, \"john\", null, \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith([null, \"john\", null, \"bill\"]);\n }\n\n [Fact]\n public void\n When_collection_starts_with_the_specific_sequence_with_null_elements_using_custom_equality_comparison_it_should_not_throw()\n {\n // Arrange\n string[] collection = [null, \"john\", null, \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().StartWith([null, \"JoHn\", null, \"bIlL\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_collection_starts_with_null_but_that_wasnt_expected_it_should_throw()\n {\n // Arrange\n string[] collection = [null, \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().StartWith(\"john\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*john*but*null*\");\n }\n\n [Fact]\n public void When_null_collection_is_expected_to_start_with_an_element_it_should_throw()\n {\n // Arrange\n string[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().StartWith(\"john\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*start*john*but*collection*null*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeExactly.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeExactly\n {\n [Fact]\n public void When_time_is_not_at_exactly_20_minutes_before_another_time_it_should_throw()\n {\n // Arrange\n DateTime target = 1.January(0001).At(12, 55);\n DateTime subject = 1.January(0001).At(12, 36);\n\n // Act\n Action act =\n () => subject.Should().BeExactly(TimeSpan.FromMinutes(20)).Before(target, \"{0} minutes is enough\", 20);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <12:36:00> to be exactly 20m before <12:55:00> because 20 minutes is enough, but it is behind by 19m.\");\n }\n\n [Fact]\n public void When_time_is_exactly_90_seconds_before_another_time_it_should_not_throw()\n {\n // Arrange\n DateTime target = 1.January(0001).At(12, 55);\n DateTime subject = 1.January(0001).At(12, 53, 30);\n\n // Act / Assert\n subject.Should().BeExactly(TimeSpan.FromSeconds(90)).Before(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_exactly_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 20);\n\n // Ac\n Action action = () => subject.Should().BeExactly(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:20> to be exactly 10s after <00:00:30>, but it is behind by 10s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_exactly_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 40);\n\n // Act\n Action action = () => subject.Should().BeExactly(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:40> to be exactly 10s before <00:00:30>, but it is ahead by 10s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeMoreThan.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeMoreThan\n {\n [Fact]\n public void When_date_is_not_more_than_the_required_one_day_before_another_it_should_throw()\n {\n // Arrange\n var target = new DateTime(2009, 10, 2);\n DateTime subject = target - 1.Days();\n\n // Act\n Action act = () => subject.Should().BeMoreThan(TimeSpan.FromDays(1)).Before(target, \"we like {0}\", \"that\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2009-10-01> to be more than 1d before <2009-10-02> because we like that, but it is behind by 1d.\");\n }\n\n [Fact]\n public void When_date_is_more_than_the_required_one_day_before_another_it_should_not_throw()\n {\n // Arrange\n var target = new DateTime(2009, 10, 2);\n DateTime subject = target - 25.Hours();\n\n // Act / Assert\n subject.Should().BeMoreThan(TimeSpan.FromDays(1)).Before(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_more_than_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 15);\n\n // Act\n Action action = () => subject.Should().BeMoreThan(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:15> to be more than 10s after <00:00:30>, but it is behind by 15s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_more_than_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30);\n var subject = 1.January(0001).At(0, 0, 45);\n\n // Act\n Action action = () => subject.Should().BeMoreThan(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:45> to be more than 10s before <00:00:30>, but it is ahead by 15s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeLessThan.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeLessThan\n {\n [Fact]\n public void When_time_is_not_less_than_30s_after_another_time_it_should_throw()\n {\n // Arrange\n var target = 1.January(1).At(12, 0, 30).WithOffset(1.Hours());\n DateTimeOffset subject = target + 30.Seconds();\n\n // Act\n Action act =\n () => subject.Should().BeLessThan(TimeSpan.FromSeconds(30)).After(target, \"{0}s is the max\", 30);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <12:01:00 +1h> to be less than 30s after <12:00:30 +1h> because 30s is the max, but it is ahead by 30s.\");\n }\n\n [Fact]\n public void When_time_is_less_than_30s_after_another_time_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(1.January(1).At(12, 0, 30));\n DateTimeOffset subject = target + 20.Seconds();\n\n // Act / Assert\n subject.Should().BeLessThan(TimeSpan.FromSeconds(30)).After(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_less_than_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 25).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeLessThan(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected subject <00:00:25 +0h> to be less than 10s after <00:00:30 +0h>, but it is behind by 5s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_less_than_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 45).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeLessThan(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject <00:00:45 +0h> to be less than 10s before <00:00:30 +0h>, but it is ahead by 15s.\");\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals_with_a_range()\n {\n // Arrange\n DateTimeOffset someDateTimeOffset = new(2022, 9, 25, 13, 48, 42, 0, TimeSpan.Zero);\n\n // Act\n var action = () => someDateTimeOffset.Should().BeLessThan(0.Seconds()).Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Before() or After() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.BeOneOf.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateOnly value = new(2016, 12, 20);\n\n // Act\n Action action = () => value.Should().BeOneOf(value.AddDays(1), value.AddMonths(-1));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<2016-12-21>, <2016-11-20>}, but found <2016-12-20>.\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n DateOnly value = new(2016, 12, 20);\n\n // Act\n Action action = () =>\n value.Should().BeOneOf(new[] { value.AddDays(1), value.AddDays(2) }, \"because it's true\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected value to be one of {<2016-12-21>, <2016-12-22>} because it's true, but found <2016-12-20>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n DateOnly value = new(2016, 12, 30);\n\n // Act/Assert\n value.Should().BeOneOf(new DateOnly(2216, 1, 30), new DateOnly(2016, 12, 30));\n }\n\n [Fact]\n public void When_a_null_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateOnly? value = null;\n\n // Act\n Action action = () => value.Should().BeOneOf(new DateOnly(2216, 1, 30), new DateOnly(1116, 4, 10));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<2216-01-30>, <1116-04-10>}, but found .\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_dateonly_is_null()\n {\n // Arrange\n DateOnly? value = null;\n\n // Act/Assert\n value.Should().BeOneOf(new DateOnly(2216, 1, 30), null);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCountGreaterThan.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveCountGreaterThan specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCountGreaterThan\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_greater_than_less_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountGreaterThan(2);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_greater_than_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCountGreaterThan(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_has_a_count_greater_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () =>\n collection.Should().HaveCountGreaterThan(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain more than 3 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_greater_than_and_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCountGreaterThan(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*more than*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/ByteAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class ByteAssertions : NumericAssertions\n{\n internal ByteAssertions(byte value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(byte subject, byte expected)\n {\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableByteAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableByteAssertions : NullableNumericAssertions\n{\n internal NullableByteAssertions(byte? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(byte subject, byte expected)\n {\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/SByteAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class SByteAssertions : NumericAssertions\n{\n internal SByteAssertions(sbyte value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(sbyte subject, sbyte expected)\n {\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveCountLessThan.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveCountLessThan specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveCountLessThan\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_less_than_less_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().HaveCountLessThan(4);\n }\n\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_less_than_the_number_of_items()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().HaveCountLessThan(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_collection_has_a_count_less_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action action = () => collection.Should().HaveCountLessThan(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain fewer than 3 item(s) because we want to test the failure message, but found 3: {1, 2, 3}.\");\n }\n\n [Fact]\n public void When_collection_count_is_less_than_and_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveCountLessThan(1, \"we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*fewer than*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NullableSByteAssertions.cs", "using System.Diagnostics;\nusing System.Globalization;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that a nullable is in the expected state.\n/// \n[DebuggerNonUserCode]\ninternal class NullableSByteAssertions : NullableNumericAssertions\n{\n internal NullableSByteAssertions(sbyte? value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n\n private protected override string CalculateDifferenceForFailureMessage(sbyte subject, sbyte expected)\n {\n int difference = subject - expected;\n return difference != 0 ? difference.ToString(CultureInfo.InvariantCulture) : null;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.EndWith.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The EndWith specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class EndWith\n {\n [Fact]\n public void When_collection_does_not_end_with_a_specific_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().EndWith(\"ryan\", \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*ryan*because of some reason*but*mike*\");\n }\n\n [Fact]\n public void When_collection_does_end_with_a_specific_element_and_because_format_is_incorrect_it_should_not_fail()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act / Assert\n#pragma warning disable CA2241\n // ReSharper disable FormatStringProblem\n collection.Should().EndWith(\"mike\", \"of some reason {0,abc}\", 1, 2);\n\n // ReSharper restore FormatStringProblem\n#pragma warning restore CA2241\n }\n\n [Fact]\n public void When_collection_does_not_end_with_a_specific_element_in_a_sequence_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().EndWith([\"bill\", \"ryan\", \"mike\"], \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*ryan*because of some reason*but*differs at index 2*\");\n }\n\n [Fact]\n public void When_collection_does_not_end_with_a_null_sequence_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\"];\n\n // Act\n Action act = () => collection.Should().EndWith((IEnumerable)null);\n\n // Assert\n act.Should().Throw()\n .Which.ParamName.Should().Be(\"expectation\");\n }\n\n [Fact]\n public void When_collection_does_not_end_with_a_null_sequence_using_a_comparer_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\"];\n\n // Act\n Action act = () => collection.Should().EndWith((IEnumerable)null, (_, _) => true);\n\n // Assert\n act.Should().Throw()\n .Which.ParamName.Should().Be(\"expectation\");\n }\n\n [Fact]\n public void\n When_collection_does_not_end_with_a_specific_element_in_a_sequence_using_custom_equality_comparison_it_should_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act\n Action act = () => collection.Should().EndWith([\"bill\", \"ryan\", \"mike\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.Ordinal), \"of some reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*ryan*because of some reason*but*differs at index 2*\");\n }\n\n [Fact]\n public void When_collection_ends_with_the_specific_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().EndWith(\"mike\");\n }\n\n [Fact]\n public void When_collection_ends_with_the_specific_sequence_of_elements_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().EndWith([\"jane\", \"mike\"]);\n }\n\n [Fact]\n public void\n When_collection_ends_with_the_specific_sequence_of_elements_using_custom_equality_comparison_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().EndWith([\"JaNe\", \"mIkE\"],\n (s1, s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_collection_ends_with_the_specific_null_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"jane\", \"mike\", null];\n\n // Act / Assert\n collection.Should().EndWith((string)null);\n }\n\n [Fact]\n public void When_collection_ends_with_the_specific_sequence_with_null_elements_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", null, \"mike\", null];\n\n // Act / Assert\n collection.Should().EndWith([\"jane\", null, \"mike\", null]);\n }\n\n [Fact]\n public void\n When_collection_ends_with_the_specific_sequence_with_null_elements_using_custom_equality_comparison_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"john\", \"bill\", \"jane\", null, \"mike\", null];\n\n // Act / Assert\n collection.Should().EndWith([\"JaNe\", null, \"mIkE\", null],\n (s1, s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_collection_ends_with_null_but_that_wasnt_expected_it_should_throw()\n {\n // Arrange\n string[] collection = [\"jane\", \"mike\", null];\n\n // Act\n Action act = () => collection.Should().EndWith(\"john\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*john*but*null*\");\n }\n\n [Fact]\n public void When_null_collection_is_expected_to_end_with_an_element_it_should_throw()\n {\n // Arrange\n string[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().EndWith(\"john\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected*end*john*but*collection*null*\");\n }\n\n [Fact]\n public void When_non_empty_collection_ends_with_the_empty_sequence_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"jane\", \"mike\"];\n\n // Act / Assert\n collection.Should().EndWith(new string[] { });\n }\n\n [Fact]\n public void When_empty_collection_ends_with_the_empty_sequence_it_should_not_throw()\n {\n // Arrange\n string[] collection = [];\n\n // Act / Assert\n collection.Should().EndWith(new string[] { });\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Common/TimeSpanExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Specs.Common;\n\n/// \n/// Implements extensions to \n/// \npublic static class TimeSpanExtensions\n{\n public static TimeSpan Multiply(this TimeSpan timeSpan, double factor)\n {\n if (double.IsNaN(factor))\n {\n throw new ArgumentException(\"Argument cannot be NaN\", nameof(factor));\n }\n\n // Rounding to the nearest tick is as close to the result we would have with unlimited\n // precision as possible, and so likely to have the least potential to surprise.\n double ticks = Math.Round(timeSpan.Ticks * factor);\n\n if (ticks is > long.MaxValue or < long.MinValue)\n {\n throw new OverflowException(\"TimeSpan overflowed because the duration is too long.\");\n }\n\n return TimeSpan.FromTicks((long)ticks);\n }\n\n public static TimeSpan Divide(this TimeSpan timeSpan, double divisor)\n {\n if (double.IsNaN(divisor))\n {\n throw new ArgumentException(\"Argument cannot be NaN\", nameof(divisor));\n }\n\n double ticks = Math.Round(timeSpan.Ticks / divisor);\n\n if (ticks > long.MaxValue || ticks < long.MinValue || double.IsNaN(ticks))\n {\n throw new OverflowException(\"TimeSpan overflowed because the duration is too long.\");\n }\n\n return TimeSpan.FromTicks((long)ticks);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeOneOf.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateTime value = new(2016, 12, 30, 23, 58, 57);\n\n // Act\n Action action = () => value.Should().BeOneOf(value + 1.Days(), value + 1.Milliseconds());\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected value to be one of {<2016-12-31 23:58:57>, <2016-12-30 23:58:57.001>}, but found <2016-12-30 23:58:57>.\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n DateTime value = new(2016, 12, 30, 23, 58, 57);\n\n // Act\n Action action = () =>\n value.Should().BeOneOf(new[] { value + 1.Days(), value + 1.Milliseconds() }, \"because it's true\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected value to be one of {<2016-12-31 23:58:57>, <2016-12-30 23:58:57.001>} because it's true, but found <2016-12-30 23:58:57>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n DateTime value = new(2016, 12, 30, 23, 58, 57);\n\n // Act / Assert\n value.Should().BeOneOf(new DateTime(2216, 1, 30, 0, 5, 7),\n new DateTime(2016, 12, 30, 23, 58, 57), new DateTime(2012, 3, 3));\n }\n\n [Fact]\n public void When_a_null_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n DateTime? value = null;\n\n // Act\n Action action = () => value.Should().BeOneOf(new DateTime(2216, 1, 30, 0, 5, 7), new DateTime(1116, 4, 10, 2, 45, 7));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<2216-01-30 00:05:07>, <1116-04-10 02:45:07>}, but found .\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_datetime_is_null()\n {\n // Arrange\n DateTime? value = null;\n\n // Act / Assert\n value.Should().BeOneOf(new DateTime(2216, 1, 30, 0, 5, 7), null);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeMoreThan.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeMoreThan\n {\n [Fact]\n public void When_date_is_not_more_than_the_required_one_day_before_another_it_should_throw()\n {\n // Arrange\n var target = new DateTimeOffset(2.October(2009), 0.Hours());\n DateTimeOffset subject = target - 1.Days();\n\n // Act\n Action act = () => subject.Should().BeMoreThan(TimeSpan.FromDays(1)).Before(target, \"we like {0}\", \"that\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject <2009-10-01 +0h> to be more than 1d before <2009-10-02 +0h> because we like that, but it is behind by 1d.\");\n }\n\n [Fact]\n public void When_date_is_more_than_the_required_one_day_before_another_it_should_not_throw()\n {\n // Arrange\n var target = new DateTimeOffset(2.October(2009));\n DateTimeOffset subject = target - 25.Hours();\n\n // Act / Assert\n subject.Should().BeMoreThan(TimeSpan.FromDays(1)).Before(target);\n }\n\n [Fact]\n public void When_asserting_subject_be_more_than_10_seconds_after_target_but_subject_is_before_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 15).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeMoreThan(10.Seconds()).After(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject <00:00:15 +0h> to be more than 10s after <00:00:30 +0h>, but it is behind by 15s.\");\n }\n\n [Fact]\n public void When_asserting_subject_be_more_than_10_seconds_before_target_but_subject_is_after_target_it_should_throw()\n {\n // Arrange\n var expectation = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());\n var subject = 1.January(0001).At(0, 0, 45).WithOffset(0.Hours());\n\n // Act\n Action action = () => subject.Should().BeMoreThan(10.Seconds()).Before(expectation);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected subject <00:00:45 +0h> to be more than 10s before <00:00:30 +0h>, but it is ahead by 15s.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveDay.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveDay\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_day_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 31;\n\n // Act / Assert\n subject.Should().HaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_day_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 30;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 30, but found 31.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_day_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 22, but found a DateTime.\");\n }\n }\n\n public class NotHaveDay\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_day_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 31;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 31, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_day_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 30;\n\n // Act / Assert\n subject.Should().NotHaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_day_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 22, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveMonth.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveMonth\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_month_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 12;\n\n // Act / Assert\n subject.Should().HaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_a_month_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 11;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 11, but found 12.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_month_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 12, but found a DateTime.\");\n }\n }\n\n public class NotHaveMonth\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_month_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_a_month_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 11;\n\n // Act / Assert\n subject.Should().NotHaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_month_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveYear.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveYear\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_year_with_the_same_value_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 2009;\n\n // Act / Assert\n subject.Should().HaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_year_with_a_different_value_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found 2009.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_year_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found .\");\n }\n }\n\n public class NotHaveYear\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_year_with_the_same_value_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 2009;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2009, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_year_with_a_different_value_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31);\n int expectation = 2008;\n\n // Act / Assert\n subject.Should().NotHaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_year_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2008, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveOffset.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveOffset\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_offset_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.FromHours(7));\n TimeSpan expectation = TimeSpan.FromHours(7);\n\n // Act / Assert\n subject.Should().HaveOffset(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_offset_with_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 10), TimeSpan.Zero);\n TimeSpan expectation = TimeSpan.FromHours(3);\n\n // Act\n Action act = () => subject.Should().HaveOffset(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the offset of subject to be 3h, but it was default.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_offset_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n TimeSpan expectation = TimeSpan.FromHours(3);\n\n // Act\n Action act = () => subject.Should().HaveOffset(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the offset of subject to be 3h, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveOffset\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_offset_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.FromHours(7));\n TimeSpan expectation = TimeSpan.FromHours(7);\n\n // Act\n Action act = () => subject.Should().NotHaveOffset(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the offset of subject to be 7h, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_offset_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n TimeSpan expectation = TimeSpan.FromHours(3);\n\n // Act / Assert\n subject.Should().NotHaveOffset(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_offset_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n TimeSpan expectation = TimeSpan.FromHours(3);\n\n // Act\n Action act = () => subject.Should().NotHaveOffset(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the offset of subject to be 3h, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XmlElementAssertionSpecs.cs", "using System;\nusing System.Xml;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XmlElementAssertionSpecs\n{\n public class BeEquivalent\n {\n [Fact]\n public void When_asserting_xml_element_is_equivalent_to_another_xml_element_with_same_contents_it_should_succeed()\n {\n // This test is basically just a check that the BeEquivalent method\n // is available on XmlElementAssertions, which it should be if\n // XmlElementAssertions inherits XmlNodeAssertions.\n\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"grega\");\n var element = xmlDoc.DocumentElement;\n var expectedDoc = new XmlDocument();\n expectedDoc.LoadXml(\"grega\");\n var expected = expectedDoc.DocumentElement;\n\n // Act / Assert\n element.Should().BeEquivalentTo(expected);\n }\n }\n\n public class HaveInnerText\n {\n [Fact]\n public void When_asserting_xml_element_has_a_specific_inner_text_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"grega\");\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveInnerText(\"grega\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_a_specific_inner_text_but_it_has_a_different_inner_text_it_should_throw()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"grega\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveInnerText(\"stamac\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_a_specific_inner_text_but_it_has_a_different_inner_text_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"grega\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveInnerText(\"stamac\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have value \\\"stamac\\\" because we want to test the failure message, but found \\\"grega\\\".\");\n }\n }\n\n public class HaveAttribute\n {\n [Fact]\n public void When_asserting_xml_element_has_attribute_with_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\"\"\"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveAttribute(\"name\", \"martin\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_attribute_with_specific_value_but_attribute_does_not_exist_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\"\"\"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveAttribute(\"age\", \"36\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_specific_value_but_attribute_does_not_exist_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"\"\"\"\"\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(\"age\", \"36\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theElement to have attribute \\\"age\\\" with value \\\"36\\\"\" +\n \" because we want to test the failure message\" +\n \", but found no such attribute in \"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveAttribute(\"name\", \"dennis\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_specific_value_but_attribute_has_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"\"\"\"\"\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttribute(\"name\", \"dennis\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected attribute \\\"name\\\" in theElement to have value \\\"dennis\\\"\" +\n \" because we want to test the failure message\" +\n \", but found \\\"martin\\\".\");\n }\n }\n\n public class HaveAttributeWithNamespace\n {\n [Fact]\n public void When_asserting_xml_element_has_attribute_with_ns_and_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\"\"\"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveAttributeWithNamespace(\"name\", \"http://www.example.com/2012/test\", \"martin\");\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_ns_and_specific_value_but_attribute_does_not_exist_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(\"\"\"\"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveAttributeWithNamespace(\"age\", \"http://www.example.com/2012/test\", \"36\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_ns_and_specific_value_but_attribute_does_not_exist_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"\"\"\"\"\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n theElement.Should().HaveAttributeWithNamespace(\"age\", \"http://www.example.com/2012/test\", \"36\",\n \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected theElement to have attribute \\\"{http://www.example.com/2012/test}age\\\" with value \\\"36\\\"\" +\n \" because we want to test the failure message\" +\n \", but found no such attribute in \"\"\");\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveAttributeWithNamespace(\"name\", \"http://www.example.com/2012/test\", \"dennis\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_xml_element_has_attribute_with_ns_and_specific_value_but_attribute_has_different_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n document.LoadXml(\"\"\"\"\"\");\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveAttributeWithNamespace(\"name\", \"http://www.example.com/2012/test\", \"dennis\",\n \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected attribute \\\"{http://www.example.com/2012/test}name\\\" in theElement to have value \\\"dennis\\\"\" +\n \" because we want to test the failure message\" +\n \", but found \\\"martin\\\".\");\n }\n }\n\n public class HaveElement\n {\n [Fact]\n public void When_asserting_xml_element_has_child_element_and_it_does_it_should_succeed()\n {\n // Arrange\n var xml = new XmlDocument();\n\n xml.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xml.DocumentElement;\n\n // Act / Assert\n element.Should().HaveElement(\"child\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_but_it_does_not_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveElement(\"unknown\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n\n document.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveElement(\"unknown\", \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"unknown\\\"\"\n + \" because we want to test the failure message\"\n + \", but no such child element was found.\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_it_should_return_the_matched_element_in_the_which_property()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act\n var matchedElement = element.Should().HaveElement(\"child\").Subject;\n\n // Assert\n matchedElement.Should().BeOfType()\n .And.HaveAttribute(\"attr\", \"1\");\n\n matchedElement.Name.Should().Be(\"child\");\n }\n\n [Fact]\n public void When_asserting_xml_element_with_ns_has_child_element_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n value\n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveElement(\"child\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_and_it_does_with_ns_it_should_succeed2()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n value\n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveElement(\"child\");\n }\n }\n\n public class HaveElementWithNamespace\n {\n [Fact]\n public void When_asserting_xml_element_has_child_element_with_ns_and_it_does_it_should_succeed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act / Assert\n element.Should().HaveElementWithNamespace(\"child\", \"http://www.example.com/2012/test\");\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_with_ns_but_it_does_not_it_should_fail()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n\n xmlDoc.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var element = xmlDoc.DocumentElement;\n\n // Act\n Action act = () =>\n element.Should().HaveElementWithNamespace(\"unknown\", \"http://www.example.com/2012/test\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_xml_element_has_child_element_with_ns_but_it_does_not_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var document = new XmlDocument();\n\n document.LoadXml(\n \"\"\"\n \n \n \n \"\"\");\n\n var theElement = document.DocumentElement;\n\n // Act\n Action act = () =>\n theElement.Should().HaveElementWithNamespace(\"unknown\", \"http://www.example.com/2012/test\",\n \"because we want to test the failure message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theElement to have child element \\\"{{http://www.example.com/2012/test}}unknown\\\"\"\n + \" because we want to test the failure message\"\n + \", but no such child element was found.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveSecond.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveSecond\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_seconds_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 0;\n\n // Act / Assert\n subject.Should().HaveSecond(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_seconds_with_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 1;\n\n // Act\n Action act = () => subject.Should().HaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 1, but found 0.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_second_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 22, but found a DateTime.\");\n }\n }\n\n public class NotHaveSecond\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_seconds_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 0;\n\n // Act\n Action act = () => subject.Should().NotHaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 0, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_seconds_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 1;\n\n // Act / Assert\n subject.Should().NotHaveSecond(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_second_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 22, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveDay.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveDay\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_day_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 31;\n\n // Act / Assert\n subject.Should().HaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_day_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 30;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 30, but it was 31.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_day_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveDay\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_day_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 31;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 31, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_day_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 30;\n\n // Act / Assert\n subject.Should().NotHaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_day_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveMonth.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveMonth\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_month_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 12;\n\n // Act / Assert\n subject.Should().HaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_a_month_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 11;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 11, but it was 12.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_month_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 12, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveMonth\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_month_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_a_month_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31), TimeSpan.Zero);\n int expectation = 11;\n\n // Act / Assert\n subject.Should().NotHaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_month_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveMinute.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveMinute\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_minutes_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 59;\n\n // Act / Assert\n subject.Should().HaveMinute(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_minutes_with_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 58;\n\n // Act\n Action act = () => subject.Should().HaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minute part of subject to be 58, but found 59.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_minute_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minute part of subject to be 22, but found a DateTime.\");\n }\n }\n\n public class NotHaveMinute\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_minutes_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 59;\n\n // Act\n Action act = () => subject.Should().NotHaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minute part of subject to be 59, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_minutes_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 58;\n\n // Act / Assert\n subject.Should().NotHaveMinute(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_minute_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minute part of subject to be 22, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveHour.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveHour\n {\n [Fact]\n public void When_asserting_subject_datetime_should_have_hour_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 23;\n\n // Act / Assert\n subject.Should().HaveHour(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_hour_with_different_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hour part of subject to be 22, but found 23.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_have_hour_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hour part of subject to be 22, but found a DateTime.\");\n }\n }\n\n public class NotHaveHour\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_hour_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 23;\n\n // Act\n Action act = () => subject.Should().NotHaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hour part of subject to be 23, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_hour_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTime subject = new(2009, 12, 31, 23, 59, 00);\n int expectation = 22;\n\n // Act / Assert\n subject.Should().NotHaveHour(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_should_not_have_hour_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hour part of subject to be 22, but found a DateTime.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveYear.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveYear\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_year_with_the_same_value_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 06, 04), TimeSpan.Zero);\n int expectation = 2009;\n\n // Act / Assert\n subject.Should().HaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_year_with_a_different_value_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 06, 04), TimeSpan.Zero);\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but it was 2009.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_year_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveYear\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_year_with_the_same_value_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 06, 04), TimeSpan.Zero);\n int expectation = 2009;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2009, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_year_with_a_different_value_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 06, 04), TimeSpan.Zero);\n int expectation = 2008;\n\n // Act / Assert\n subject.Should().NotHaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_year_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2008, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveSecond.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveSecond\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_seconds_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 0;\n\n // Act / Assert\n subject.Should().HaveSecond(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_seconds_with_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 1;\n\n // Act\n Action act = () => subject.Should().HaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 1, but it was 0.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_second_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveSecond\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_seconds_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 0;\n\n // Act\n Action act = () => subject.Should().NotHaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 0, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_seconds_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 1;\n\n // Act / Assert\n subject.Should().NotHaveSecond(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_second_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveSecond(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/StringValidatorSupportingNull.cs", "using System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\ninternal class StringValidatorSupportingNull\n{\n private readonly IStringComparisonStrategy comparisonStrategy;\n private AssertionChain assertionChain;\n\n public StringValidatorSupportingNull(AssertionChain assertionChain, IStringComparisonStrategy comparisonStrategy,\n [StringSyntax(\"CompositeFormat\")] string because, object[] becauseArgs)\n {\n this.comparisonStrategy = comparisonStrategy;\n this.assertionChain = assertionChain.BecauseOf(because, becauseArgs);\n }\n\n public void Validate(string subject, string expected)\n {\n if (expected?.IsLongOrMultiline() == true ||\n subject?.IsLongOrMultiline() == true)\n {\n assertionChain = assertionChain.UsingLineBreaks;\n }\n\n comparisonStrategy.ValidateAgainstMismatch(assertionChain, subject, expected);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveMinute.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveMinute\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_minutes_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 59;\n\n // Act / Assert\n subject.Should().HaveMinute(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_minutes_with_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 58;\n\n // Act\n Action act = () => subject.Should().HaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minute part of subject to be 58, but it was 59.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_minute_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minute part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveMinute\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_minutes_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 59;\n\n // Act\n Action act = () => subject.Should().NotHaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minute part of subject to be 59, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_minutes_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 58;\n\n // Act / Assert\n subject.Should().NotHaveMinute(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_minute_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveMinute(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minute part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveHour.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveHour\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_hour_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 23;\n\n // Act / Assert\n subject.Should().HaveHour(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_have_hour_with_different_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hour part of subject to be 22, but it was 23.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_have_hour_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hour part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n\n public class NotHaveHour\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_hour_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 23;\n\n // Act\n Action act = () => subject.Should().NotHaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hour part of subject to be 23, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_should_not_have_hour_with_different_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);\n int expectation = 22;\n\n // Act / Assert\n subject.Should().NotHaveHour(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_should_not_have_hour_should_throw()\n {\n // Arrange\n DateTimeOffset? subject = null;\n int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveHour(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hour part of subject to be 22, but found a DateTimeOffset.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/PropertyInfoAssertionSpecs.cs", "using System;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class PropertyInfoAssertionSpecs\n{\n public class BeVirtual\n {\n [Fact]\n public void When_asserting_that_a_property_is_virtual_and_it_is_then_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithAllPropertiesVirtual).GetRuntimeProperty(\"PublicVirtualProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeVirtual();\n }\n\n [Fact]\n public void When_asserting_that_a_property_is_virtual_and_it_is_not_then_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithNonVirtualPublicProperties).GetRuntimeProperty(\"PublicNonVirtualProperty\");\n\n // Act\n Action act = () => propertyInfo.Should().BeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property ClassWithNonVirtualPublicProperties.PublicNonVirtualProperty\" +\n \" to be virtual because we want to test the error message,\" +\n \" but it is not.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_virtual_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeVirtual(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property to be virtual *failure message*, but propertyInfo is .\");\n }\n }\n\n public class NotBeVirtual\n {\n [Fact]\n public void When_asserting_that_a_property_is_not_virtual_and_it_is_not_then_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithNonVirtualPublicProperties).GetRuntimeProperty(\"PublicNonVirtualProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotBeVirtual();\n }\n\n [Fact]\n public void When_asserting_that_a_property_is_not_virtual_and_it_is_then_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithAllPropertiesVirtual).GetRuntimeProperty(\"PublicVirtualProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property *ClassWithAllPropertiesVirtual.PublicVirtualProperty\" +\n \" not to be virtual because we want to test the error message,\" +\n \" but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_virtual_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeVirtual(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property not to be virtual *failure message*, but propertyInfo is .\");\n }\n }\n\n public class BeDecortatedWithOfT\n {\n [Fact]\n public void When_asserting_a_property_is_decorated_with_attribute_and_it_is_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_a_property_is_decorated_with_an_attribute_it_allow_chaining_assertions()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith().Which.Value.Should().Be(\"OtherValue\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*Value*OtherValue*\");\n }\n\n [Fact]\n public void\n When_a_property_is_decorated_with_an_attribute_and_multiple_attributes_match_continuation_using_the_matched_value_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\n \"PublicPropertyWithSameAttributeTwice\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith().Which.Value.Should().Be(\"OtherValue\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_a_property_is_decorated_with_attribute_and_it_is_not_it_throw_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith(\"because we want to test the error message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property \" +\n \"ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.PublicProperty to be decorated with \" +\n \"AwesomeAssertions*DummyPropertyAttribute because we want to test the error message, but that attribute was not found.\");\n }\n\n [Fact]\n public void\n When_asserting_a_property_is_decorated_with_an_attribute_matching_a_predicate_but_it_is_not_it_throw_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith(d => d.Value == \"NotARealValue\",\n \"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property ClassWithPropertiesThatAreNotDecoratedWithDummyAttribute.PublicProperty to be decorated with \" +\n \"AwesomeAssertions*DummyPropertyAttribute because we want to test the error message,\" +\n \" but that attribute was not found.\");\n }\n\n [Fact]\n public void When_asserting_a_property_is_decorated_with_attribute_matching_a_predicate_and_it_is_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeDecoratedWith(d => d.Value == \"Value\");\n }\n\n [Fact]\n public void When_subject_is_null_be_decorated_withOfT_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property to be decorated with *.DummyPropertyAttribute *failure message*, but propertyInfo is .\");\n }\n\n [Fact]\n public void When_asserting_property_is_decorated_with_null_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo =\n typeof(ClassWithAllPropertiesDecoratedWithDummyAttribute).GetRuntimeProperty(\"PublicProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeDecoratedWith((Expression>)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n }\n\n public class NotBeDecoratedWithOfT\n {\n [Fact]\n public void When_subject_is_null_not_be_decorated_withOfT_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeDecoratedWith(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected property to not be decorated with *.DummyPropertyAttribute *failure message*, but propertyInfo is .\");\n }\n\n [Fact]\n public void When_asserting_property_is_not_decorated_with_null_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeDecoratedWith((Expression>)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n }\n\n public class BeWritable\n {\n [Fact]\n public void When_asserting_a_readonly_property_is_writable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().BeWritable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\n \"Expected property ClassWithProperties.ReadOnlyProperty to have a setter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_asserting_a_readwrite_property_is_writable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadWriteProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeWritable(\"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_writeonly_property_is_writable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeWritable(\"that's required\");\n }\n\n [Fact]\n public void When_subject_is_null_be_writable_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeWritable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property to have a setter *failure message*, but propertyInfo is .\");\n }\n }\n\n public class BeReadable\n {\n [Fact]\n public void When_asserting_a_readonly_property_is_readable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeReadable(\"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_readwrite_property_is_readable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadWriteProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeReadable(\"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_writeonly_property_is_readable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().BeReadable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\n \"Expected property *WriteOnlyProperty to have a getter because we want to test the error message, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_readable_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeReadable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property to have a getter *failure message*, but propertyInfo is .\");\n }\n }\n\n public class NotBeWritable\n {\n [Fact]\n public void When_asserting_a_readonly_property_is_not_writable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotBeWritable(\"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_readwrite_property_is_not_writable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadWriteProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotBeWritable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect property ClassWithReadOnlyProperties.ReadWriteProperty\" +\n \" to have a setter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_asserting_a_writeonly_property_is_not_writable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotBeWritable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect property ClassWithProperties.WriteOnlyProperty\" +\n \" to have a setter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_writable_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeWritable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected propertyInfo not to have a setter *failure message*, but it is .\");\n }\n }\n\n public class NotBeReadable\n {\n [Fact]\n public void When_asserting_a_readonly_property_is_not_readable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotBeReadable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect property ClassWithReadOnlyProperties.ReadOnlyProperty \" +\n \"to have a getter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_asserting_a_readwrite_property_is_not_readable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithReadOnlyProperties).GetRuntimeProperty(\"ReadWriteProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotBeReadable(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect property ClassWithReadOnlyProperties.ReadWriteProperty \" +\n \"to have a getter because we want to test the error message.\");\n }\n\n [Fact]\n public void When_asserting_a_writeonly_property_is_not_readable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotBeReadable(\"that's required\");\n }\n\n [Fact]\n public void When_subject_is_null_not_be_readable_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotBeReadable(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected property not to have a getter *failure message*, but propertyInfo is .\");\n }\n }\n\n public class BeReadableAccessModifier\n {\n [Fact]\n public void When_asserting_a_public_read_private_write_property_is_public_readable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadPrivateWriteProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeReadable(CSharpAccessModifier.Public, \"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_private_read_public_write_property_is_public_readable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WritePrivateReadProperty\");\n\n // Act\n Action action = () =>\n propertyInfo.Should().BeReadable(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected getter of property ClassWithProperties.WritePrivateReadProperty \" +\n \"to be Public because we want to test the error message, but it is Private*\");\n }\n\n [Fact]\n public void Do_not_the_check_access_modifier_when_the_property_is_not_readable()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WriteOnlyProperty\");\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n propertyInfo.Should().BeReadable(CSharpAccessModifier.Private);\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected property ClassWithProperties.WriteOnlyProperty to have a getter, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_readable_with_accessmodifier_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeReadable(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected propertyInfo to be Public *failure message*, but it is .\");\n }\n\n [Fact]\n public void When_asserting_is_readable_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeReadable((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n\n public class BeWritableAccessModifier\n {\n [Fact]\n public void When_asserting_a_public_write_private_read_property_is_public_writable_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"WritePrivateReadProperty\");\n\n // Act / Assert\n propertyInfo.Should().BeWritable(CSharpAccessModifier.Public, \"that's required\");\n }\n\n [Fact]\n public void When_asserting_a_private_write_public_read_property_is_public_writable_it_fails_with_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadPrivateWriteProperty\");\n\n // Act\n Action action = () =>\n propertyInfo.Should().BeWritable(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected setter of property ClassWithProperties.ReadPrivateWriteProperty \" +\n \"to be Public because we want to test the error message, but it is Private.\");\n }\n\n [Fact]\n public void Do_not_the_check_access_modifier_when_the_property_is_not_writable()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"ReadOnlyProperty\");\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n propertyInfo.Should().BeWritable(CSharpAccessModifier.Private);\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected property ClassWithProperties.ReadOnlyProperty to have a setter.\");\n }\n\n [Fact]\n public void When_subject_is_null_be_writable_with_accessmodifier_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeWritable(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected propertyInfo to be Public *failure message*, but it is .\");\n }\n\n [Fact]\n public void When_asserting_is_writable_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().BeWritable((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n\n public class Return\n {\n [Fact]\n public void When_asserting_a_String_property_returns_a_String_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act / Assert\n propertyInfo.Should().Return(typeof(string));\n }\n\n [Fact]\n public void When_asserting_a_String_property_returns_an_Int32_it_throw_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().Return(typeof(int), \"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type of property ClassWithProperties.StringProperty\" +\n \" to be int because we want to test the error message, but it is string.\");\n }\n\n [Fact]\n public void When_subject_is_null_return_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().Return(typeof(int), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type of property to be int *failure message*, but propertyInfo is .\");\n }\n\n [Fact]\n public void When_asserting_property_type_is_null_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().Return(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"propertyType\");\n }\n }\n\n public class ReturnOfT\n {\n [Fact]\n public void When_asserting_a_String_property_returnsOfT_a_String_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act / Assert\n propertyInfo.Should().Return();\n }\n\n [Fact]\n public void When_asserting_a_String_property_returnsOfT_an_Int32_it_throw_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().Return(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type of property ClassWithProperties.StringProperty to be int because we want to test the error \" +\n \"message, but it is string.\");\n }\n }\n\n public class NotReturn\n {\n [Fact]\n public void When_asserting_a_String_property_does_not_returns_an_Int32_it_succeeds()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotReturn(typeof(int));\n }\n\n [Fact]\n public void When_asserting_a_String_property_does_not_return_a_String_it_throw_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotReturn(typeof(string), \"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type of property ClassWithProperties.StringProperty\" +\n \" not to be string because we want to test the error message, but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_return_should_fail()\n {\n // Arrange\n PropertyInfo propertyInfo = null;\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotReturn(typeof(int), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type of property not to be int *failure message*, but propertyInfo is .\");\n }\n\n [Fact]\n public void When_asserting_property_type_is_not_null_it_should_throw()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action act = () =>\n propertyInfo.Should().NotReturn(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"propertyType\");\n }\n }\n\n public class NotReturnOfT\n {\n [Fact]\n public void Can_validate_the_type_of_a_property()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act / Assert\n propertyInfo.Should().NotReturn();\n }\n\n [Fact]\n public void When_asserting_a_string_property_does_not_returnsOfT_a_String_it_throw_with_a_useful_message()\n {\n // Arrange\n PropertyInfo propertyInfo = typeof(ClassWithProperties).GetRuntimeProperty(\"StringProperty\");\n\n // Act\n Action action = () => propertyInfo.Should().NotReturn(\"we want to test the error {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected type of property ClassWithProperties.StringProperty not to be*String*because we want to test the error \" +\n \"message, but it is.\");\n }\n }\n\n #region Internal classes used in unit tests\n\n private class ClassWithProperties\n {\n public string ReadOnlyProperty { get { return \"\"; } }\n\n public string ReadPrivateWriteProperty { get; private set; }\n\n public string ReadWriteProperty { get; set; }\n\n public string WritePrivateReadProperty { private get; set; }\n\n public string WriteOnlyProperty { set { } }\n\n public string StringProperty { get; set; }\n }\n\n #endregion\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainItemsAssignableTo.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The ContainItemsAssignableTo specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class ContainItemsAssignableTo\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_with_all_items_of_same_type_only_contains_item_of_one_type()\n {\n // Arrange\n string[] collection = [\"1\", \"2\", \"3\"];\n\n // Act / Assert\n collection.Should().ContainItemsAssignableTo();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_with_items_of_different_types_contains_item_of_expected_type()\n {\n // Arrange\n var collection = new List\n {\n 1,\n \"2\"\n };\n\n // Act / Assert\n collection.Should().ContainItemsAssignableTo();\n }\n\n [Fact]\n public void When_asserting_collection_contains_item_assignable_to_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainItemsAssignableTo(\"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain at least one element assignable to type string because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_a_collection_is_empty_an_exception_should_be_thrown()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().ContainItemsAssignableTo();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to contain at least one element assignable to type int, but found {empty}.\");\n }\n\n [Fact]\n public void Should_throw_exception_when_asserting_collection_for_missing_item_type()\n {\n var collection = new object[] { \"1\", 1.0m };\n\n Action act = () => collection.Should().ContainItemsAssignableTo();\n\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to contain at least one element assignable to type int, but found {string, decimal}.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.BeOneOf.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n TimeOnly value = new(15, 12, 20);\n\n // Act\n Action action = () => value.Should().BeOneOf(value.AddHours(1), value.AddMinutes(-1));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<16:12:20.000>, <15:11:20.000>}, but found <15:12:20.000>.\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n TimeOnly value = new(15, 12, 30);\n\n // Act/Assert\n value.Should().BeOneOf(new TimeOnly(4, 1, 30), new TimeOnly(15, 12, 30));\n }\n\n [Fact]\n public void When_a_null_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n TimeOnly? value = null;\n\n // Act\n Action action = () => value.Should().BeOneOf(new TimeOnly(15, 1, 30), new TimeOnly(5, 4, 10, 123));\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {<15:01:30.000>, <05:04:10.123>}, but found .\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_timeonly_is_null()\n {\n // Arrange\n TimeOnly? value = null;\n\n // Act/Assert\n value.Should().BeOneOf(new TimeOnly(15, 1, 30), null);\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.HaveHours.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class HaveHours\n {\n [Fact]\n public void When_asserting_subject_timeonly_should_have_hours_with_the_same_value_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 15;\n\n // Act/Assert\n subject.Should().HaveHours(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_hours_with_the_same_value_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 15;\n\n // Act\n Action act = () => subject.Should().NotHaveHours(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hours part of subject to be 15, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_have_hours_with_a_different_value_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 14;\n\n // Act\n Action act = () => subject.Should().HaveHours(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hours part of subject to be 14, but found 15.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_hours_with_a_different_value_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(21, 12, 31);\n const int expectation = 23;\n\n // Act/Assert\n subject.Should().NotHaveHours(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_have_hours_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 21;\n\n // Act\n Action act = () => subject.Should().HaveHours(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the hours part of subject to be 21, but found .\");\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_not_have_hours_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 19;\n\n // Act\n Action act = () => subject.Should().NotHaveHours(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the hours part of subject to be 19, but found a TimeOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BeNegative.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BeNegative\n {\n [Fact]\n public void When_a_negative_value_is_negative_it_should_not_throw()\n {\n // Arrange\n int value = -1;\n\n // Act / Assert\n value.Should().BeNegative();\n }\n\n [Fact]\n public void When_a_positive_value_is_negative_it_should_throw()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_zero_value_is_negative_it_should_throw()\n {\n // Arrange\n int value = 0;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_positive_value_is_negative_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action act = () => value.Should().BeNegative(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be negative because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_negative_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n\n [Fact]\n public void NaN_is_never_a_negative_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_a_negative_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.HaveSeconds.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class HaveSeconds\n {\n [Fact]\n public void When_asserting_subject_timeonly_should_have_seconds_with_the_same_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(14, 12, 31);\n const int expectation = 31;\n\n // Act/Assert\n subject.Should().HaveSeconds(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_seconds_with_the_same_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(14, 12, 31);\n const int expectation = 31;\n\n // Act\n Action act = () => subject.Should().NotHaveSeconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 31, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_have_seconds_with_a_different_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 30;\n\n // Act\n Action act = () => subject.Should().HaveSeconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 30, but found 31.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_seconds_with_a_different_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 30;\n\n // Act/Assert\n subject.Should().NotHaveSeconds(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_have_seconds_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveSeconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the seconds part of subject to be 22, but found a TimeOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_not_have_seconds_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveSeconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the seconds part of subject to be 22, but found a TimeOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.BePositive.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class BePositive\n {\n [Fact]\n public void When_a_positive_value_is_positive_it_should_not_throw()\n {\n // Arrange\n float value = 1F;\n\n // Act / Assert\n value.Should().BePositive();\n }\n\n [Fact]\n public void When_a_negative_value_is_positive_it_should_throw()\n {\n // Arrange\n double value = -1D;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_zero_value_is_positive_it_should_throw()\n {\n // Arrange\n int value = 0;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void NaN_is_never_a_positive_float()\n {\n // Arrange\n float value = float.NaN;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_a_positive_double()\n {\n // Arrange\n double value = double.NaN;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void When_a_negative_value_is_positive_it_should_throw_with_descriptive_message()\n {\n // Arrange\n int value = -1;\n\n // Act\n Action act = () => value.Should().BePositive(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Expected value to be positive because we want to test the failure message, but found -1.\");\n }\n\n [Fact]\n public void When_a_nullable_numeric_null_value_is_not_positive_it_should_throw()\n {\n // Arrange\n int? value = null;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*null*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.HaveMinutes.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class HaveMinutes\n {\n [Fact]\n public void When_asserting_subject_timeonly_should_have_minutes_with_the_same_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(21, 12, 31);\n const int expectation = 12;\n\n // Act/Assert\n subject.Should().HaveMinutes(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_minutes_with_the_same_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(21, 12, 31);\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMinutes(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minutes part of subject to be 12, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_have_a_minute_with_a_different_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 11;\n\n // Act\n Action act = () => subject.Should().HaveMinutes(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minutes part of subject to be 11, but found 12.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_a_minute_with_a_different_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31);\n const int expectation = 11;\n\n // Act/Assert\n subject.Should().NotHaveMinutes(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_have_minutes_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMinutes(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the minutes part of subject to be 12, but found a TimeOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_not_have_minutes_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMinutes(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the minutes part of subject to be 12, but found a TimeOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeOfType.cs", "using System;\nusing AssemblyA;\nusing AssemblyB;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeOfType\n {\n [Fact]\n public void When_object_type_is_matched_against_null_type_exactly_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expectedType\");\n }\n\n [Fact]\n public void When_object_type_is_exactly_equal_to_the_specified_type_it_should_not_fail()\n {\n // Arrange\n var someObject = new Exception();\n\n // Act / Assert\n someObject.Should().BeOfType();\n }\n\n [Fact]\n public void When_object_type_is_value_type_and_matches_received_type_should_not_fail_and_assert_correctly()\n {\n // Arrange\n int valueTypeObject = 42;\n\n // Act / Assert\n valueTypeObject.Should().BeOfType(typeof(int));\n }\n\n [Fact]\n public void When_object_is_matched_against_a_null_type_it_should_throw()\n {\n // Arrange\n int valueTypeObject = 42;\n\n // Act\n Action act = () => valueTypeObject.Should().BeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expectedType\");\n }\n\n [Fact]\n public void When_null_object_is_matched_against_a_type_it_should_throw()\n {\n // Arrange\n int? valueTypeObject = null;\n\n // Act\n Action act = () =>\n valueTypeObject.Should().BeOfType(typeof(int), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*type to be int*because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_object_type_is_value_type_and_doesnt_match_received_type_should_fail()\n {\n // Arrange\n int valueTypeObject = 42;\n Type doubleType = typeof(double);\n\n // Act\n Action act = () => valueTypeObject.Should().BeOfType(doubleType);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be double, but found int.\");\n }\n\n [Fact]\n public void When_object_is_of_the_expected_type_it_should_cast_the_returned_object_for_chaining()\n {\n // Arrange\n var someObject = new Exception(\"Actual Message\");\n\n // Act\n Action act = () => someObject.Should().BeOfType().Which.Message.Should().Be(\"Other Message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"*Expected*Actual*Other*\");\n }\n\n [Fact]\n public void When_object_type_is_different_than_expected_type_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeOfType(\"because they are {0} {1}\", \"of different\", \"type\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be int because they are of different type, but found object.\");\n }\n\n [Fact]\n public void When_asserting_the_type_of_a_null_object_it_should_throw()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () => someObject.Should().BeOfType();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someObject to be int, but found .\");\n }\n\n [Fact]\n public void\n When_object_type_is_same_as_expected_type_but_in_different_assembly_it_should_fail_with_assembly_qualified_name()\n {\n // Arrange\n var typeFromOtherAssembly =\n new ClassA().ReturnClassC();\n\n // Act\n#pragma warning disable 436 // disable the warning on conflicting types, as this is the intention for the spec\n\n Action act = () =>\n typeFromOtherAssembly.Should().BeOfType();\n\n#pragma warning restore 436\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to be [AssemblyB.ClassC, AwesomeAssertions.Specs*], but found [AssemblyB.ClassC, AssemblyB*].\");\n }\n\n [Fact]\n public void When_object_type_is_a_subclass_of_the_expected_type_it_should_fail()\n {\n // Arrange\n var someObject = new DummyImplementingClass();\n\n // Act\n Action act = () => someObject.Should().BeOfType();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected type to be AwesomeAssertions*DummyBaseClass, but found AwesomeAssertions*DummyImplementingClass.\");\n }\n }\n\n public class NotBeOfType\n {\n [Fact]\n public void When_object_type_is_matched_negatively_against_null_type_exactly_it_should_throw()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().NotBeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"unexpectedType\");\n }\n\n [Fact]\n public void When_object_is_matched_negatively_against_a_null_type_it_should_throw()\n {\n // Arrange\n int valueTypeObject = 42;\n\n // Act\n Action act = () => valueTypeObject.Should().NotBeOfType(null);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"unexpectedType\");\n }\n\n [Fact]\n public void\n When_object_type_is_value_type_and_doesnt_match_received_type_as_expected_should_not_fail_and_assert_correctly()\n {\n // Arrange\n int valueTypeObject = 42;\n\n // Act / Assert\n valueTypeObject.Should().NotBeOfType(typeof(double));\n }\n\n [Fact]\n public void When_null_object_is_matched_negatively_against_a_type_it_should_throw()\n {\n // Arrange\n int? valueTypeObject = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n valueTypeObject.Should().NotBeOfType(typeof(int), \"because we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*type not to be int *because we want to test the failure message*\");\n }\n\n [Fact]\n public void When_object_type_is_value_type_and_matches_received_type_not_as_expected_should_fail()\n {\n // Arrange\n int valueTypeObject = 42;\n var expectedType = typeof(int);\n\n // Act\n Action act = () => valueTypeObject.Should().NotBeOfType(expectedType);\n\n // Assert\n act.Should().Throw()\n .WithMessage($\"Expected type not to be [{expectedType.AssemblyQualifiedName}], but it is.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.HaveDay.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class HaveDay\n {\n [Fact]\n public void When_asserting_subject_dateonly_should_have_day_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 31;\n\n // Act/Assert\n subject.Should().HaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_day_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 31;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 31, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_have_day_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 30;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 30, but found 31.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_day_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 30;\n\n // Act/Assert\n subject.Should().NotHaveDay(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_have_day_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the day part of subject to be 22, but found a DateOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_not_have_day_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveDay(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the day part of subject to be 22, but found a DateOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.HaveMonth.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class HaveMonth\n {\n [Fact]\n public void When_asserting_subject_dateonly_should_have_month_with_the_same_value_it_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 12;\n\n // Act/Assert\n subject.Should().HaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_month_with_the_same_value_it_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_have_a_month_with_a_different_value_it_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 11;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 11, but found 12.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_a_month_with_a_different_value_it_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 11;\n\n // Act/Assert\n subject.Should().NotHaveMonth(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_have_month_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the month part of subject to be 12, but found a DateOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_not_have_month_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().NotHaveMonth(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the month part of subject to be 12, but found a DateOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.EndWith.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]EndWith specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class EndWith\n {\n [Fact]\n public void When_asserting_string_ends_with_a_suffix_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedSuffix = \"BC\";\n\n // Act / Assert\n actual.Should().EndWith(expectedSuffix);\n }\n\n [Fact]\n public void When_asserting_string_ends_with_the_same_value_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABC\";\n string expectedSuffix = \"ABC\";\n\n // Act / Assert\n actual.Should().EndWith(expectedSuffix);\n }\n\n [Fact]\n public void When_string_does_not_end_with_expected_phrase_it_should_throw()\n {\n // Act\n Action act = () =>\n {\n using var a = new AssertionScope();\n \"ABC\".Should().EndWith(\"AB\", \"it should\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to end with \\\"AB\\\" because it should, but \\\"ABC\\\" differs near \\\"ABC\\\" (index 0).\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWith(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare string end with .*\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_empty_string_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().EndWith(\"\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_with_string_that_is_longer_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().EndWith(\"00ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to end with \" +\n \"\\\"00ABC\\\", but \" +\n \"\\\"ABC\\\" is too short.\");\n }\n\n [Fact]\n public void Correctly_stop_further_execution_when_inside_assertion_scope()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n \"ABC\".Should().EndWith(\"00ABC\").And.EndWith(\"CBA00\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*\\\"00ABC\\\"*\");\n }\n\n [Fact]\n public void When_string_ending_is_compared_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someString.Should().EndWith(\"ABC\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString to end with \\\"ABC\\\", but found .\");\n }\n }\n\n public class NotEndWith\n {\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_and_it_does_not_it_should_succeed()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().NotEndWith(\"AB\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_but_it_does_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWith(\"BC\", \"because of some {0}\", \"reason\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to end with \\\"BC\\\" because of some reason, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_that_is_null_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWith(null);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Cannot compare end of string with .*\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_that_is_empty_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotEndWith(\"\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to end with \\\"\\\", but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_end_with_a_value_and_actual_value_is_null_it_should_throw()\n {\n // Arrange\n string someString = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n someString.Should().NotEndWith(\"ABC\", \"some {0}\", \"reason\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to end with \\\"ABC\\\"*some reason*, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.HaveMilliseconds.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class HaveMilliseconds\n {\n [Fact]\n public void When_asserting_subject_timeonly_should_have_milliseconds_with_the_same_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(14, 12, 31, 123);\n const int expectation = 123;\n\n // Act/Assert\n subject.Should().HaveMilliseconds(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_milliseconds_with_the_same_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(14, 12, 31, 445);\n const int expectation = 445;\n\n // Act\n Action act = () => subject.Should().NotHaveMilliseconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the milliseconds part of subject to be 445, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_have_milliseconds_with_a_different_value_it_should_throw()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31, 555);\n const int expectation = 12;\n\n // Act\n Action act = () => subject.Should().HaveMilliseconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the milliseconds part of subject to be 12, but found 555.\");\n }\n\n [Fact]\n public void When_asserting_subject_timeonly_should_not_have_milliseconds_with_a_different_value_it_should_succeed()\n {\n // Arrange\n TimeOnly subject = new(15, 12, 31, 445);\n const int expectation = 31;\n\n // Act/Assert\n subject.Should().NotHaveMilliseconds(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_have_milliseconds_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().HaveMilliseconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the milliseconds part of subject to be 22, but found a TimeOnly.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_timeonly_should_not_have_milliseconds_should_throw()\n {\n // Arrange\n TimeOnly? subject = null;\n const int expectation = 22;\n\n // Act\n Action act = () => subject.Should().NotHaveMilliseconds(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the milliseconds part of subject to be 22, but found a TimeOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.HaveYear.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class HaveYear\n {\n [Fact]\n public void When_asserting_subject_dateonly_should_have_year_with_the_same_value_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 2009;\n\n // Act/Assert\n subject.Should().HaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_year_with_the_same_value_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 2009;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2009, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_have_year_with_a_different_value_should_throw()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found 2009.\");\n }\n\n [Fact]\n public void When_asserting_subject_dateonly_should_not_have_year_with_a_different_value_should_succeed()\n {\n // Arrange\n DateOnly subject = new(2009, 12, 31);\n const int expectation = 2008;\n\n // Act/Assert\n subject.Should().NotHaveYear(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_have_year_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().HaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the year part of subject to be 2008, but found .\");\n }\n\n [Fact]\n public void When_asserting_subject_null_dateonly_should_not_have_year_should_throw()\n {\n // Arrange\n DateOnly? subject = null;\n const int expectation = 2008;\n\n // Act\n Action act = () => subject.Should().NotHaveYear(expectation);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the year part of subject to be 2008, but found a DateOnly.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeGreaterThanOrEqualTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeGreaterThanOrEqualTo\n {\n [Fact]\n public void A_float_can_never_be_greater_than_or_equal_to_NaN()\n {\n // Arrange\n float? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_or_equal_to_another_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_greater_than_or_equal_to_NaN()\n {\n // Arrange\n double? value = 3.4;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_greater_than_or_equal_to_another_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeGreaterThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeLessThanOrEqualTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeLessThanOrEqualTo\n {\n [Fact]\n public void A_float_can_never_be_less_than_or_equal_to_NaN()\n {\n // Arrange\n float? value = 3.4F;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(float.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_or_equal_to_another_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void A_double_can_never_be_less_than_or_equal_to_NaN()\n {\n // Arrange\n double? value = 3.4;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(double.NaN);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_less_than_or_equal_to_another_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeLessThanOrEqualTo(0);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"*NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensions/FluentDateTimeExtensions.cs", "using System;\nusing System.Diagnostics;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Extensions;\n\n/// \n/// Extension methods on to allow for a more fluent way of specifying a .\n/// \n/// \n/// Instead of
\n///
\n/// new DateTime(2011, 3, 10)
\n///
\n/// you can write 3.March(2011)
\n///
\n/// Or even
\n///
\n/// 3.March(2011).At(09, 30)\n///
\n/// \n[DebuggerNonUserCode]\npublic static class FluentDateTimeExtensions\n{\n /// \n /// Returns a new value for the specified and \n /// in the month January.\n /// \n public static DateTime January(this int day, int year)\n {\n return new DateTime(year, 1, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month February.\n /// \n public static DateTime February(this int day, int year)\n {\n return new DateTime(year, 2, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month March.\n /// \n public static DateTime March(this int day, int year)\n {\n return new DateTime(year, 3, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month April.\n /// \n public static DateTime April(this int day, int year)\n {\n return new DateTime(year, 4, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month May.\n /// \n public static DateTime May(this int day, int year)\n {\n return new DateTime(year, 5, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month June.\n /// \n public static DateTime June(this int day, int year)\n {\n return new DateTime(year, 6, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month July.\n /// \n public static DateTime July(this int day, int year)\n {\n return new DateTime(year, 7, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month August.\n /// \n public static DateTime August(this int day, int year)\n {\n return new DateTime(year, 8, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month September.\n /// \n public static DateTime September(this int day, int year)\n {\n return new DateTime(year, 9, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month October.\n /// \n public static DateTime October(this int day, int year)\n {\n return new DateTime(year, 10, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month November.\n /// \n public static DateTime November(this int day, int year)\n {\n return new DateTime(year, 11, day);\n }\n\n /// \n /// Returns a new value for the specified and \n /// in the month December.\n /// \n public static DateTime December(this int day, int year)\n {\n return new DateTime(year, 12, day);\n }\n\n /// \n /// Returns a new value for the specified and .\n /// \n public static DateTime At(this DateTime date, TimeSpan time)\n {\n return date.Date + time;\n }\n\n /// \n /// Returns a new value for the specified and time with the specified\n /// , and optionally .\n /// \n public static DateTime At(this DateTime date, int hours, int minutes, int seconds = 0, int milliseconds = 0,\n int microseconds = 0, int nanoseconds = 0)\n {\n if (microseconds is < 0 or > 999)\n {\n throw new ArgumentOutOfRangeException(nameof(microseconds), \"Valid values are between 0 and 999\");\n }\n\n if (nanoseconds is < 0 or > 999)\n {\n throw new ArgumentOutOfRangeException(nameof(nanoseconds), \"Valid values are between 0 and 999\");\n }\n\n var value = new DateTime(date.Year, date.Month, date.Day, hours, minutes, seconds, milliseconds, date.Kind);\n\n if (microseconds != 0)\n {\n value += microseconds.Microseconds();\n }\n\n if (nanoseconds != 0)\n {\n value += nanoseconds.Nanoseconds();\n }\n\n return value;\n }\n\n /// \n /// Returns a new value for the specified and time with the specified\n /// , and optionally .\n /// \n public static DateTimeOffset At(this DateTimeOffset date, int hours, int minutes, int seconds = 0, int milliseconds = 0,\n int microseconds = 0, int nanoseconds = 0)\n {\n if (microseconds is < 0 or > 999)\n {\n throw new ArgumentOutOfRangeException(nameof(microseconds), \"Valid values are between 0 and 999\");\n }\n\n if (nanoseconds is < 0 or > 999)\n {\n throw new ArgumentOutOfRangeException(nameof(nanoseconds), \"Valid values are between 0 and 999\");\n }\n\n var value = new DateTimeOffset(date.Year, date.Month, date.Day, hours, minutes, seconds, milliseconds, date.Offset);\n\n if (microseconds != 0)\n {\n value += microseconds.Microseconds();\n }\n\n if (nanoseconds != 0)\n {\n value += nanoseconds.Nanoseconds();\n }\n\n return value;\n }\n\n /// \n /// Returns a new value for the specified and time with\n /// the kind set to .\n /// \n public static DateTime AsUtc(this DateTime dateTime)\n {\n return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);\n }\n\n /// \n /// Returns a new value for the specified and time with\n /// the kind set to .\n /// \n public static DateTime AsLocal(this DateTime dateTime)\n {\n return DateTime.SpecifyKind(dateTime, DateTimeKind.Local);\n }\n\n /// \n /// Returns a new value that is the current before the\n /// specified .\n /// \n public static DateTime Before(this TimeSpan timeDifference, DateTime sourceDateTime)\n {\n return sourceDateTime - timeDifference;\n }\n\n /// \n /// Returns a new value that is the current after the\n /// specified .\n /// \n public static DateTime After(this TimeSpan timeDifference, DateTime sourceDateTime)\n {\n return sourceDateTime + timeDifference;\n }\n\n /// \n /// Gets the nanoseconds component of the date represented by the current structure.\n /// \n public static int Nanosecond(this DateTime self)\n {\n return self.Ticks.Ticks().Nanoseconds();\n }\n\n /// \n /// Gets the nanoseconds component of the date represented by the current structure.\n /// \n public static int Nanosecond(this DateTimeOffset self)\n {\n return self.Ticks.Ticks().Nanoseconds();\n }\n\n /// \n /// Returns a new that adds the specified number of nanoseconds to the value of this instance.\n /// \n public static DateTime AddNanoseconds(this DateTime self, long nanoseconds)\n {\n return self + nanoseconds.Nanoseconds();\n }\n\n /// \n /// Returns a new that adds the specified number of nanoseconds to the value of this instance.\n /// \n public static DateTimeOffset AddNanoseconds(this DateTimeOffset self, long nanoseconds)\n {\n return self + nanoseconds.Nanoseconds();\n }\n\n /// \n /// Gets the microseconds component of the date represented by the current structure.\n /// \n public static int Microsecond(this DateTime self)\n {\n return self.Ticks.Ticks().Microseconds();\n }\n\n /// \n /// Gets the microseconds component of the date represented by the current structure.\n /// \n public static int Microsecond(this DateTimeOffset self)\n {\n return self.Ticks.Ticks().Microseconds();\n }\n\n /// \n /// Returns a new that adds the specified number of microseconds to the value of this instance.\n /// \n public static DateTime AddMicroseconds(this DateTime self, long microseconds)\n {\n return self + microseconds.Microseconds();\n }\n\n /// \n /// Returns a new that adds the specified number of microseconds to the value of this instance.\n /// \n public static DateTimeOffset AddMicroseconds(this DateTimeOffset self, long microseconds)\n {\n return self + microseconds.Microseconds();\n }\n\n /// \n /// Returns new that uses \n /// as its datetime and as its offset.\n /// \n public static DateTimeOffset WithOffset(this DateTime self, TimeSpan offset)\n {\n return self.ToDateTimeOffset(offset);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.ContainKeys.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class ContainKeys\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_contains_multiple_keys_from_the_dictionary()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary.Should().ContainKeys(2, 1);\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_a_list_of_keys_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainKeys([2, 3], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain keys {2, 3} because we do, but could not find {3}.\");\n }\n\n [Fact]\n public void Null_dictionaries_do_not_contain_any_keys()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().ContainKeys([2, 3], \"because {0}\", \"we do\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain keys {2, 3} because we do, but found .\");\n }\n\n [Fact]\n public void\n When_the_contents_of_a_dictionary_are_checked_against_an_empty_list_of_keys_it_should_throw_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainKeys();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify key containment against an empty sequence*\");\n }\n }\n\n public class NotContainKeys\n {\n [Fact]\n public void When_dictionary_does_not_contain_multiple_keys_from_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys(3, 4);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_dictionary_contains_a_list_of_keys_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys([2, 3], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to not contain keys {2, 3} because we do, but found {2}.\");\n }\n\n [Fact]\n public void When_a_dictionary_contains_exactly_one_of_the_keys_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys([2], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to not contain key 2 because we do.\");\n }\n\n [Fact]\n public void Null_dictionaries_do_not_contain_any_keys()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContainKeys([2], \"because {0}\", \"we do\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain keys {2} because we do, but found .\");\n }\n\n [Fact]\n public void\n When_the_noncontents_of_a_dictionary_are_checked_against_an_empty_list_of_keys_it_should_throw_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify key containment against an empty sequence*\");\n }\n\n [Fact]\n public void\n When_a_dictionary_checks_a_list_of_keys_not_to_be_present_it_will_honor_the_case_sensitive_equality_comparer_of_the_dictionary()\n {\n // Arrange\n var dictionary = new Dictionary(StringComparer.Ordinal)\n {\n [\"ONE\"] = \"One\",\n [\"TWO\"] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys(\"One\", \"Two\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void\n When_a_dictionary_checks_a_list_of_keys_not_to_be_present_it_will_honor_the_case_insensitive_equality_comparer_of_the_dictionary()\n {\n // Arrange\n var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase)\n {\n [\"ONE\"] = \"One\",\n [\"TWO\"] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainKeys(\"One\", \"Two\");\n\n // Assert\n act.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeCloseTo.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeCloseTo\n {\n [Fact]\n public void When_asserting_that_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().BeCloseTo(dateTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_later_datetime_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_an_earlier_datetime_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks + 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_MinValue_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTime.MinValue;\n var actual = new DateTime(dateTime.Ticks + 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_MaxValue_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTime.MaxValue;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_a_later_datetime_it_should_succeed()\n {\n // Arrange\n DateTime time = DateTime.SpecifyKind(new DateTime(2016, 06, 04).At(12, 15, 30, 980), DateTimeKind.Unspecified);\n DateTime nearbyTime = DateTime.SpecifyKind(new DateTime(2016, 06, 04).At(12, 15, 31), DateTimeKind.Utc);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_an_earlier_datetime_it_should_succeed()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 020);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_another_value_that_is_later_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 30, 979);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31>, but <2012-03-13 12:15:30.979> was off by 21ms.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_is_close_to_another_value_that_is_later_by_more_than_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 30, 979);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31>, but <2012-03-13 12:15:30.979> was off by 21ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 31, 021);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31>, but <2012-03-13 12:15:31.021> was off by 21ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_an_earlier_datetime_by_35ms_it_should_succeed()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 035);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_is_close_to_another_it_should_throw()\n {\n // Arrange\n DateTime? time = null;\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_the_minimum_datetime_it_should_succeed()\n {\n // Arrange\n DateTime time = DateTime.MinValue + 50.Milliseconds();\n DateTime nearbyTime = DateTime.MinValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_close_to_the_maximum_datetime_it_should_succeed()\n {\n // Arrange\n DateTime time = DateTime.MaxValue - 50.Milliseconds();\n DateTime nearbyTime = DateTime.MaxValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n }\n\n public class NotBeCloseTo\n {\n [Fact]\n public void When_asserting_that_time_is_not_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_later_datetime_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_an_earlier_datetime_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTime.UtcNow;\n var actual = new DateTime(dateTime.Ticks + 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_MinValue_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTime.MinValue;\n var actual = new DateTime(dateTime.Ticks + 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetime_is_close_to_a_MaxValue_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTime.MaxValue;\n var actual = new DateTime(dateTime.Ticks - 1);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_a_later_datetime_it_should_throw()\n {\n // Arrange\n DateTime time = DateTime.SpecifyKind(new DateTime(2016, 06, 04).At(12, 15, 30, 980), DateTimeKind.Unspecified);\n DateTime nearbyTime = DateTime.SpecifyKind(new DateTime(2016, 06, 04).At(12, 15, 31), DateTimeKind.Utc);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31>, but it was <2016-06-04 12:15:30.980>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_an_earlier_datetime_it_should_throw()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 020);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31>, but it was <2016-06-04 12:15:31.020>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_an_earlier_datetime_by_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 020);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31>, but it was <2016-06-04 12:15:31.020>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_is_not_close_to_another_value_that_is_later_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 30, 979);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_is_not_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n DateTime time = 13.March(2012).At(12, 15, 31, 021);\n DateTime nearbyTime = 13.March(2012).At(12, 15, 31);\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_an_earlier_datetime_by_35ms_it_should_throw()\n {\n // Arrange\n DateTime time = new DateTime(2016, 06, 04).At(12, 15, 31, 035);\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 35ms from <2016-06-04 12:15:31>, but it was <2016-06-04 12:15:31.035>.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_is_not_close_to_another_it_should_throw()\n {\n // Arrange\n DateTime? time = null;\n DateTime nearbyTime = new DateTime(2016, 06, 04).At(12, 15, 31);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*, but it was .\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_the_minimum_datetime_it_should_throw()\n {\n // Arrange\n DateTime time = DateTime.MinValue + 50.Milliseconds();\n DateTime nearbyTime = DateTime.MinValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect time to be within 100ms from <0001-01-01 00:00:00.000>, but it was <00:00:00.050>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_close_to_the_maximum_datetime_it_should_throw()\n {\n // Arrange\n DateTime time = DateTime.MaxValue - 50.Milliseconds();\n DateTime nearbyTime = DateTime.MaxValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 100ms from <9999-12-31 23:59:59.9999999>, but it was <9999-12-31 23:59:59.9499999>.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/SemicolonParsingStrategy.cs", "using System.Text;\n\nnamespace AwesomeAssertions.CallerIdentification;\n\ninternal class SemicolonParsingStrategy : IParsingStrategy\n{\n public ParsingState Parse(char symbol, StringBuilder statement)\n {\n if (symbol is ';')\n {\n statement.Clear();\n return ParsingState.Done;\n }\n\n return ParsingState.InProgress;\n }\n\n public bool IsWaitingForContextEnd()\n {\n return false;\n }\n\n public void NotifyEndOfLineReached()\n {\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.Match.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class Match\n {\n [Fact]\n public void When_nullable_value_satisfies_predicate_it_should_not_throw()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act / Assert\n nullableInteger.Should().Match(o => o.HasValue);\n }\n\n [Fact]\n public void When_nullable_value_does_not_match_the_predicate_it_should_throw()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () =>\n nullableInteger.Should().Match(o => !o.HasValue, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected value to match Not(o.HasValue) because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void When_nullable_value_is_matched_against_a_null_it_should_throw()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () => nullableInteger.Should().Match(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XAttributeAssertionSpecs.cs", "using System;\nusing System.Xml.Linq;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XAttributeAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_asserting_an_xml_attribute_is_equal_to_the_same_xml_attribute_it_should_succeed()\n {\n // Arrange\n var attribute = new XAttribute(\"name\", \"value\");\n var sameXAttribute = new XAttribute(\"name\", \"value\");\n\n // Act / Assert\n attribute.Should().Be(sameXAttribute);\n }\n\n [Fact]\n public void\n When_asserting_an_xml_attribute_is_equal_to_a_different_xml_attribute_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n var otherAttribute = new XAttribute(\"name2\", \"value\");\n\n // Act\n Action act = () =>\n theAttribute.Should().Be(otherAttribute, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"Expected theAttribute to be {otherAttribute} because we want to test the failure message, but found {theAttribute}.\");\n }\n\n [Fact]\n public void When_both_subject_and_expected_are_null_it_succeeds()\n {\n XAttribute theAttribute = null;\n\n // Act / Assert\n theAttribute.Should().Be(null);\n }\n\n [Fact]\n public void When_the_expected_attribute_is_null_then_it_fails()\n {\n XAttribute theAttribute = null;\n\n // Act\n Action act = () =>\n theAttribute.Should().Be(new XAttribute(\"name\", \"value\"), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theAttribute to be name=\\\"value\\\" *failure message*, but found .\");\n }\n\n [Fact]\n public void When_the_attribute_is_expected_to_equal_null_it_fails()\n {\n XAttribute theAttribute = new(\"name\", \"value\");\n\n // Act\n Action act = () => theAttribute.Should().Be(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected theAttribute to be *failure message*, but found name=\\\"value\\\".\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_asserting_an_xml_attribute_is_not_equal_to_a_different_xml_attribute_it_should_succeed()\n {\n // Arrange\n var attribute = new XAttribute(\"name\", \"value\");\n var otherXAttribute = new XAttribute(\"name2\", \"value\");\n\n // Act / Assert\n attribute.Should().NotBe(otherXAttribute);\n }\n\n [Fact]\n public void When_asserting_an_xml_attribute_is_not_equal_to_the_same_xml_attribute_it_should_throw()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n var sameXAttribute = theAttribute;\n\n // Act\n Action act = () =>\n theAttribute.Should().NotBe(sameXAttribute);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect theAttribute to be name=\\\"value\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_an_xml_attribute_is_not_equal_to_the_same_xml_attribute_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n var sameAttribute = theAttribute;\n\n // Act\n Action act = () =>\n theAttribute.Should().NotBe(sameAttribute, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"Did not expect theAttribute to be {sameAttribute} because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_a_null_attribute_is_not_supposed_to_be_an_attribute_it_succeeds()\n {\n // Arrange\n XAttribute theAttribute = null;\n\n // Act / Assert\n theAttribute.Should().NotBe(new XAttribute(\"name\", \"value\"));\n }\n\n [Fact]\n public void When_an_attribute_is_not_supposed_to_be_null_it_succeeds()\n {\n // Arrange\n XAttribute theAttribute = new(\"name\", \"value\");\n\n // Act / Assert\n theAttribute.Should().NotBe(null);\n }\n\n [Fact]\n public void When_a_null_attribute_is_not_supposed_to_be_null_it_fails()\n {\n // Arrange\n XAttribute theAttribute = null;\n\n // Act\n Action act = () => theAttribute.Should().NotBe(null, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect theAttribute to be *failure message*.\");\n }\n }\n\n public class BeNull\n {\n [Fact]\n public void When_asserting_a_null_xml_attribute_is_null_it_should_succeed()\n {\n // Arrange\n XAttribute attribute = null;\n\n // Act / Assert\n attribute.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_a_non_null_xml_attribute_is_null_it_should_fail()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n\n // Act\n Action act = () =>\n theAttribute.Should().BeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute to be , but found name=\\\"value\\\".\");\n }\n\n [Fact]\n public void When_asserting_a_non_null_xml_attribute_is_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n var theAttribute = new XAttribute(\"name\", \"value\");\n\n // Act\n Action act = () =>\n theAttribute.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n $\"Expected theAttribute to be because we want to test the failure message, but found {theAttribute}.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_asserting_a_non_null_xml_attribute_is_not_null_it_should_succeed()\n {\n // Arrange\n var attribute = new XAttribute(\"name\", \"value\");\n\n // Act / Assert\n attribute.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_null_xml_attribute_is_not_null_it_should_fail()\n {\n // Arrange\n XAttribute theAttribute = null;\n\n // Act\n Action act = () =>\n theAttribute.Should().NotBeNull();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute not to be .\");\n }\n\n [Fact]\n public void When_asserting_a_null_xml_attribute_is_not_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n XAttribute theAttribute = null;\n\n // Act\n Action act = () =>\n theAttribute.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute not to be because we want to test the failure message.\");\n }\n }\n\n public class HaveValue\n {\n [Fact]\n public void When_asserting_attribute_has_a_specific_value_and_it_does_it_should_succeed()\n {\n // Arrange\n var attribute = new XAttribute(\"age\", \"36\");\n\n // Act / Assert\n attribute.Should().HaveValue(\"36\");\n }\n\n [Fact]\n public void When_asserting_attribute_has_a_specific_value_but_it_has_a_different_value_it_should_throw()\n {\n // Arrange\n var theAttribute = new XAttribute(\"age\", \"36\");\n\n // Act\n Action act = () =>\n theAttribute.Should().HaveValue(\"16\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute \\\"age\\\" to have value \\\"16\\\", but found \\\"36\\\".\");\n }\n\n [Fact]\n public void\n When_asserting_attribute_has_a_specific_value_but_it_has_a_different_value_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var theAttribute = new XAttribute(\"age\", \"36\");\n\n // Act\n Action act = () =>\n theAttribute.Should().HaveValue(\"16\", \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected theAttribute \\\"age\\\" to have value \\\"16\\\" because we want to test the failure message, but found \\\"36\\\".\");\n }\n\n [Fact]\n public void When_an_attribute_is_null_then_have_value_should_fail()\n {\n XAttribute theAttribute = null;\n\n // Act\n Action act = () =>\n theAttribute.Should().HaveValue(\"value\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected the attribute to have value \\\"value\\\" *failure message*, but theAttribute is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.StartWith.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]StartWith specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class StartWith\n {\n [Fact]\n public void When_asserting_string_starts_with_the_same_value_it_should_not_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().StartWith(\"AB\");\n }\n\n [Fact]\n public void When_expected_string_is_the_same_value_it_should_not_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().StartWith(value);\n }\n\n [Fact]\n public void When_string_does_not_start_with_expected_phrase_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWith(\"ABB\", \"it should {0}\", \"start\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with \\\"ABB\\\" because it should start,\" +\n \" but \\\"ABC\\\" differs near \\\"C\\\" (index 2).\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void\n When_string_does_not_start_with_expected_phrase_and_one_of_them_is_long_it_should_display_both_strings_on_separate_line()\n {\n // Act\n Action act = () => \"ABCDEFGHI\".Should().StartWith(\"ABCDDFGHI\", \"it should {0}\", \"start\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with \" +\n \"*\\\"ABCDDFGHI\\\" because it should start, but \" +\n \"*\\\"ABCDEFGHI\\\" differs near \\\"EFG\\\" (index 4).\");\n }\n\n [Fact]\n public void When_string_start_is_compared_with_null_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWith(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare start of string with .*\");\n }\n\n [Fact]\n public void When_string_start_is_compared_with_empty_string_it_should_not_throw()\n {\n // Act / Assert\n \"ABC\".Should().StartWith(\"\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_start_is_compared_with_string_that_is_longer_it_should_throw()\n {\n // Act\n Action act = () => \"ABC\".Should().StartWith(\"ABCDEF\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string to start with \\\"ABCDEF\\\", but \\\"ABC\\\" is too short.\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void Correctly_stop_further_execution_when_inside_assertion_scope()\n {\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n \"ABC\".Should().StartWith(\"ABCDEF\").And.StartWith(\"FEDCBA\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*\\\"ABCDEF\\\"*\");\n }\n\n [Fact]\n public void When_string_start_is_compared_and_actual_value_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().StartWith(\"ABC\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected someString to start with \\\"ABC\\\", but found .\");\n }\n }\n\n public class NotStartWith\n {\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_and_it_does_not_it_should_succeed()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act / Assert\n value.Should().NotStartWith(\"DE\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_but_it_does_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWith(\"AB\", \"because of some reason\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to start with \\\"AB\\\" because of some reason, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_that_is_null_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWith(null);\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Cannot compare start of string with .*\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_that_is_empty_it_should_throw()\n {\n // Arrange\n string value = \"ABC\";\n\n // Act\n Action action = () =>\n value.Should().NotStartWith(\"\");\n\n // Assert\n action.Should().Throw().WithMessage(\n \"Expected value not to start with \\\"\\\", but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_asserting_string_does_not_start_with_a_value_and_actual_value_is_null_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().NotStartWith(\"ABC\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString not to start with \\\"ABC\\\", but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.BeSubsetOf.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class BeSubsetOf\n {\n [Fact]\n public void When_a_subset_is_tested_against_a_null_superset_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n IEnumerable subset = [\"one\", \"two\", \"three\"];\n IEnumerable superset = null;\n\n // Act\n Action act = () => subset.Should().BeSubsetOf(superset);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify a subset against a collection.*\");\n }\n\n [Fact]\n public void When_an_empty_collection_is_tested_against_a_superset_it_should_succeed()\n {\n // Arrange\n IEnumerable subset = new string[0];\n IEnumerable superset = [\"one\", \"two\", \"four\", \"five\"];\n\n // Act / Assert\n subset.Should().BeSubsetOf(superset);\n }\n\n [Fact]\n public void When_asserting_collection_to_be_subset_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act =\n () => collection.Should().BeSubsetOf(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be a subset of {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_is_not_a_subset_of_another_it_should_throw_with_the_reason()\n {\n // Arrange\n IEnumerable subset = [\"one\", \"two\", \"three\", \"six\"];\n IEnumerable superset = [\"one\", \"two\", \"four\", \"five\"];\n\n // Act\n Action act = () => subset.Should().BeSubsetOf(superset, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subset to be a subset of {\\\"one\\\", \\\"two\\\", \\\"four\\\", \\\"five\\\"} because we want to test the failure message, \" +\n \"but items {\\\"three\\\", \\\"six\\\"} are not part of the superset.\");\n }\n\n [Fact]\n public void When_collection_is_subset_of_a_specified_collection_it_should_not_throw()\n {\n // Arrange\n IEnumerable subset = [\"one\", \"two\"];\n IEnumerable superset = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n subset.Should().BeSubsetOf(superset);\n }\n }\n\n public class NotBeSubsetOf\n {\n [Fact]\n public void Should_fail_when_asserting_collection_is_not_subset_of_a_superset_collection()\n {\n // Arrange\n IEnumerable subject = [\"one\", \"two\"];\n IEnumerable otherSet = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => subject.Should().NotBeSubsetOf(otherSet, \"because I'm {0}\", \"mistaken\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect subject {\\\"one\\\", \\\"two\\\"} to be a subset of {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because I'm mistaken.\");\n }\n\n [Fact]\n public void When_a_set_is_expected_to_be_not_a_subset_it_should_succeed()\n {\n // Arrange\n IEnumerable subject = [\"one\", \"two\", \"four\"];\n IEnumerable otherSet = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n subject.Should().NotBeSubsetOf(otherSet);\n }\n\n [Fact]\n public void When_an_empty_set_is_not_supposed_to_be_a_subset_of_another_set_it_should_throw()\n {\n // Arrange\n IEnumerable subject = [];\n IEnumerable otherSet = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => subject.Should().NotBeSubsetOf(otherSet);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect subject {empty} to be a subset of {\\\"one\\\", \\\"two\\\", \\\"three\\\"}.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_subset_against_same_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = collection;\n\n // Act\n Action act = () => collection.Should().NotBeSubsetOf(otherCollection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect*to be a subset of*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeCloseTo.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeCloseTo\n {\n [Fact]\n public void When_asserting_that_time_is_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().BeCloseTo(dateTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_later_datetimeoffset_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_an_earlier_datetimeoffset_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks + 1, TimeSpan.Zero);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_MinValue_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTimeOffset.MinValue;\n var actual = new DateTimeOffset(dateTime.Ticks + 1, TimeSpan.Zero);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_MaxValue_by_one_tick_it_should_succeed()\n {\n // Arrange\n var dateTime = DateTimeOffset.MaxValue;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act / Assert\n actual.Should().BeCloseTo(dateTime, TimeSpan.FromTicks(1));\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_a_later_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 30, 980, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_an_earlier_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 31, 020, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_close_to_another_value_that_is_later_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 30, 979).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31 +1H>, but <2012-03-13 12:15:30.979 +1H> was off by 21ms.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 021).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 20ms from <2012-03-13 12:15:31 +1h>, but <2012-03-13 12:15:31.021 +1h> was off by 21ms.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_close_to_another_value_that_is_earlier_by_more_than_a_35ms_timespan_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 036).WithOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).WithOffset(1.Hours());\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(35));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time to be within 35ms from <2012-03-13 12:15:31 +1h>, but <2012-03-13 12:15:31.036 +1h> was off by 36ms.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_an_earlier_datetimeoffset_by_35ms_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 035).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_is_close_to_another_it_should_throw()\n {\n // Arrange\n DateTimeOffset? time = null;\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(5.Hours());\n\n // Act\n Action act = () => time.Should().BeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*, but found .\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_the_maximum_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = DateTimeOffset.MaxValue - 50.Milliseconds();\n DateTimeOffset nearbyTime = DateTimeOffset.MaxValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_close_to_the_minimum_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = DateTimeOffset.MinValue + 50.Milliseconds();\n DateTimeOffset nearbyTime = DateTimeOffset.MinValue;\n\n // Act / Assert\n time.Should().BeCloseTo(nearbyTime, 100.Milliseconds());\n }\n }\n\n public class NotBeCloseTo\n {\n [Fact]\n public void When_asserting_that_time_is_not_close_to_a_negative_precision_it_should_throw()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, -1.Ticks());\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"precision\")\n .WithMessage(\"*must be non-negative*\");\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_later_datetimeoffset_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_an_earlier_datetimeoffset_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTimeOffset.UtcNow;\n var actual = new DateTimeOffset(dateTime.Ticks + 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_MinValue_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTimeOffset.MinValue;\n var actual = new DateTimeOffset(dateTime.Ticks + 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_datetimeoffset_is_close_to_a_MaxValue_by_one_tick_it_should_fail()\n {\n // Arrange\n var dateTime = DateTimeOffset.MaxValue;\n var actual = new DateTimeOffset(dateTime.Ticks - 1, TimeSpan.Zero);\n\n // Act\n Action act = () => actual.Should().NotBeCloseTo(dateTime, TimeSpan.FromTicks(1));\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_a_later_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 30, 980, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31 +0h>, but it was <2016-06-04 12:15:30.980 +0h>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_not_close_to_a_later_datetimeoffset_by_a_20ms_timespan_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 30, 980, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, TimeSpan.FromMilliseconds(20));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31 +0h>, but it was <2016-06-04 12:15:30.980 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_an_earlier_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = new(2016, 06, 04, 12, 15, 31, 020, TimeSpan.Zero);\n DateTimeOffset nearbyTime = new(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 20ms from <2016-06-04 12:15:31 +0h>, but it was <2016-06-04 12:15:31.020 +0h>.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_not_close_to_another_value_that_is_later_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 30, 979).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void\n When_asserting_subject_datetimeoffset_is_not_close_to_another_value_that_is_earlier_by_more_than_20ms_it_should_succeed()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 021).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act / Assert\n time.Should().NotBeCloseTo(nearbyTime, 20.Milliseconds());\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_an_earlier_datetimeoffset_by_35ms_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = 13.March(2012).At(12, 15, 31, 035).ToDateTimeOffset(1.Hours());\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(1.Hours());\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 35ms from <2012-03-13 12:15:31 +1h>, but it was <2012-03-13 12:15:31.035 +1h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetimeoffset_is_not_close_to_another_it_should_throw()\n {\n // Arrange\n DateTimeOffset? time = null;\n DateTimeOffset nearbyTime = 13.March(2012).At(12, 15, 31).ToDateTimeOffset(5.Hours());\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 35.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect*, but it was .\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_the_minimum_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = DateTimeOffset.MinValue + 50.Milliseconds();\n DateTimeOffset nearbyTime = DateTimeOffset.MinValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 100ms from <0001-01-01 00:00:00.000>, but it was <00:00:00.050 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_close_to_the_maximum_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset time = DateTimeOffset.MaxValue - 50.Milliseconds();\n DateTimeOffset nearbyTime = DateTimeOffset.MaxValue;\n\n // Act\n Action act = () => time.Should().NotBeCloseTo(nearbyTime, 100.Milliseconds());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect time to be within 100ms from <9999-12-31 23:59:59.9999999 +0h>, but it was <9999-12-31 23:59:59.9499999 +0h>.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/Approval.Tests/ApiApproval.cs", "using System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Threading.Tasks;\nusing System.Xml.Linq;\nusing System.Xml.XPath;\nusing PublicApiGenerator;\nusing VerifyTests;\nusing VerifyTests.DiffPlex;\nusing VerifyXunit;\nusing Xunit;\n\nnamespace Approval.Tests;\n\npublic class ApiApproval\n{\n static ApiApproval() => VerifyDiffPlex.Initialize(OutputType.Minimal);\n\n [Theory]\n [ClassData(typeof(TargetFrameworksTheoryData))]\n public Task ApproveApi(string framework)\n {\n var configuration = typeof(ApiApproval).Assembly.GetCustomAttribute()!.Configuration;\n var assemblyFile = CombinedPaths(\"Src\", \"AwesomeAssertions\", \"bin\", configuration, framework, \"AwesomeAssertions.dll\");\n var assembly = Assembly.LoadFile(assemblyFile);\n var publicApi = assembly.GeneratePublicApi(options: null);\n\n return Verifier\n .Verify(publicApi)\n .ScrubLinesContaining(\"FrameworkDisplayName\")\n .UseDirectory(Path.Combine(\"ApprovedApi\", \"AwesomeAssertions\"))\n .UseFileName(framework)\n .DisableDiff();\n }\n\n private class TargetFrameworksTheoryData : TheoryData\n {\n public TargetFrameworksTheoryData()\n {\n var csproj = CombinedPaths(\"Src\", \"AwesomeAssertions\", \"AwesomeAssertions.csproj\");\n var project = XDocument.Load(csproj);\n var targetFrameworks = project.XPathSelectElement(\"/Project/PropertyGroup/TargetFrameworks\");\n AddRange(targetFrameworks!.Value.Split(';'));\n }\n }\n\n private static string GetSolutionDirectory([CallerFilePath] string path = \"\") =>\n Path.Combine(Path.GetDirectoryName(path)!, \"..\", \"..\");\n\n private static string CombinedPaths(params string[] paths) =>\n Path.GetFullPath(Path.Combine(paths.Prepend(GetSolutionDirectory()).ToArray()));\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n [Fact]\n public void When_chaining_constraints_with_and_should_not_throw()\n {\n // Arrange\n int value = 2;\n int greaterValue = 3;\n int smallerValue = 1;\n\n // Act / Assert\n value.Should()\n .BePositive()\n .And\n .BeGreaterThan(smallerValue)\n .And\n .BeLessThan(greaterValue);\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action action = () => value.Should().Equals(1);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeAfter.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeAfter\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_after_earlier_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().BeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_after_later_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be after <2016-06-05 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_after_the_same_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeAfter(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be after <2016-06-04 +0h>, but it was <2016-06-04 +0h>.\");\n }\n }\n\n public class NotBeAfter\n {\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_after_earlier_expected_datetimeoffset_should_throw()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().NotBeAfter(expectation);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to be on or before <2016-06-03 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_after_later_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 05), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeAfter(expectation);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_after_the_same_expected_datetimeoffset_should_succeed()\n {\n // Arrange\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset expectation = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeAfter(expectation);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/InnerExceptionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class InnerExceptionSpecs\n{\n [Fact]\n public void When_subject_throws_an_exception_with_the_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw(new Exception(\"\", new ArgumentException()));\n\n // Act / Assert\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException();\n }\n\n [Fact]\n public void When_subject_throws_an_exception_with_the_expected_inner_base_exception_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw(new Exception(\"\", new ArgumentNullException()));\n\n // Act / Assert\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException();\n }\n\n [Fact]\n public void When_subject_throws_an_exception_with_the_expected_inner_exception_from_argument_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw(new Exception(\"\", new ArgumentException()));\n\n // Act / Assert\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException(typeof(ArgumentException));\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_no_parameters_when_subject_throws_subclass_of_expected_inner_exception_it_should_throw_with_clear_description()\n {\n // Arrange\n var innerException = new ArgumentNullException(\"InnerExceptionMessage\", (Exception)null);\n\n Action act = () => throw new BadImageFormatException(\"\", innerException);\n\n try\n {\n // Act\n act.Should().Throw()\n .WithInnerExceptionExactly();\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\"Expected*ArgumentException*found*ArgumentNullException*InnerExceptionMessage*\");\n }\n }\n\n [Fact]\n public void WithInnerExceptionExactly_no_parameters_when_subject_throws_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new BadImageFormatException(\"\", new ArgumentNullException());\n\n // Act / Assert\n act.Should().Throw()\n .WithInnerExceptionExactly();\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_when_subject_throws_subclass_of_expected_inner_exception_it_should_throw_with_clear_description()\n {\n // Arrange\n var innerException = new ArgumentNullException(\"InnerExceptionMessage\", (Exception)null);\n\n Action act = () => throw new BadImageFormatException(\"\", innerException);\n\n try\n {\n // Act\n act.Should().Throw()\n .WithInnerExceptionExactly(\"because {0} should do just that\", \"the action\");\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should()\n .Match(\"Expected*ArgumentException*the action should do just that*ArgumentNullException*InnerExceptionMessage*\");\n }\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_with_type_exception_when_subject_throws_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new BadImageFormatException(\"\", new ArgumentNullException());\n\n // Act / Assert\n act.Should().Throw()\n .WithInnerExceptionExactly(typeof(ArgumentNullException), \"because {0} should do just that\", \"the action\");\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_with_type_exception_no_parameters_when_subject_throws_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new BadImageFormatException(\"\", new ArgumentNullException());\n\n // Act / Assert\n act.Should().Throw()\n .WithInnerExceptionExactly(typeof(ArgumentNullException));\n }\n\n [Fact]\n public void\n WithInnerExceptionExactly_with_type_exception_when_subject_throws_subclass_of_expected_inner_exception_it_should_throw_with_clear_description()\n {\n // Arrange\n var innerException = new ArgumentNullException(\"InnerExceptionMessage\", (Exception)null);\n\n Action act = () => throw new BadImageFormatException(\"\", innerException);\n\n try\n {\n // Act\n act.Should().Throw()\n .WithInnerExceptionExactly(typeof(ArgumentException), \"because {0} should do just that\", \"the action\");\n\n throw new XunitException(\"This point should not be reached.\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should()\n .Match(\"Expected*ArgumentException*the action should do just that*ArgumentNullException*InnerExceptionMessage*\");\n }\n }\n\n [Fact]\n public void WithInnerExceptionExactly_when_subject_throws_expected_inner_exception_it_should_not_do_anything()\n {\n // Arrange\n Action act = () => throw new BadImageFormatException(\"\", new ArgumentNullException());\n\n // Act / Assert\n act.Should().Throw()\n .WithInnerExceptionExactly(\"because {0} should do just that\", \"the action\");\n }\n\n [Fact]\n public void An_exception_without_the_expected_inner_exception_has_a_descriptive_message()\n {\n // Arrange\n Action subject = () => throw new BadImageFormatException(\"\");\n\n // Act\n Action act = () => subject.Should().Throw()\n .WithInnerExceptionExactly(\"some {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*some message*no inner exception*\");\n }\n\n [Fact]\n public void When_subject_throws_an_exception_with_an_unexpected_inner_exception_it_should_throw_with_clear_description()\n {\n // Arrange\n var innerException = new NullReferenceException(\"InnerExceptionMessage\");\n\n Does testSubject = Does.Throw(new Exception(\"\", innerException));\n\n try\n {\n // Act\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithInnerException(\"because {0} should do just that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException exc)\n {\n // Assert\n exc.Message.Should().Match(\n \"Expected*ArgumentException*Does.Do should do just that*NullReferenceException*InnerExceptionMessage*\");\n }\n }\n\n [Fact]\n public void When_subject_throws_an_exception_without_expected_inner_exception_it_should_throw_with_clear_description()\n {\n try\n {\n Does testSubject = Does.Throw();\n\n testSubject.Invoking(x => x.Do()).Should().Throw()\n .WithInnerException(\"because {0} should do that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n ex.Message.Should().Be(\n \"Expected inner System.InvalidOperationException because Does.Do should do that, but the thrown exception has no inner exception.\");\n }\n }\n\n [Fact]\n public void When_an_inner_exception_matches_exactly_it_should_allow_chaining_more_asserts_on_that_exception_type()\n {\n // Act\n Action act = () =>\n throw new ArgumentException(\"OuterMessage\", new InvalidOperationException(\"InnerMessage\"));\n\n // Assert\n act\n .Should().ThrowExactly()\n .WithInnerExceptionExactly()\n .Where(i => i.Message == \"InnerMessage\");\n }\n\n [Fact]\n public void\n When_an_inner_exception_matches_exactly_it_should_allow_chaining_more_asserts_on_that_exception_type_from_argument()\n {\n // Act\n Action act = () =>\n throw new ArgumentException(\"OuterMessage\", new InvalidOperationException(\"InnerMessage\"));\n\n // Assert\n act\n .Should().ThrowExactly()\n .WithInnerExceptionExactly(typeof(InvalidOperationException))\n .Where(i => i.Message == \"InnerMessage\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_it_should_throw()\n {\n // Arrange\n Action act = () => throw new Exception();\n\n // Act\n Action act2 = () => act.Should().Throw()\n .Where(exceptionExpression: null);\n\n // Act\n act2.Should().ThrowExactly()\n .WithParameterName(\"exceptionExpression\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/TimeOnlyExtensions.cs", "#if NET6_0_OR_GREATER\nusing System;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class TimeOnlyExtensions\n{\n /// \n /// Determines if is close to within a given .\n /// \n /// The time to check\n /// The time to be close to\n /// The precision that may differ from \n /// \n /// checks the right-open interval, whereas this method checks the closed interval.\n /// \n public static bool IsCloseTo(this TimeOnly subject, TimeOnly other, TimeSpan precision)\n {\n long startTicks = other.Add(-precision).Ticks;\n long endTicks = other.Add(precision).Ticks;\n long ticks = subject.Ticks;\n\n return startTicks <= endTicks\n ? startTicks <= ticks && endTicks >= ticks\n : startTicks <= ticks || endTicks >= ticks;\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeNullOrEmpty.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeNullOrEmpty specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeNullOrEmpty\n {\n [Fact]\n public void\n When_asserting_a_null_collection_to_be_null_or_empty_it_should_succeed()\n {\n // Arrange\n int[] collection = null;\n\n // Act / Assert\n collection.Should().BeNullOrEmpty();\n }\n\n [Fact]\n public void\n When_asserting_an_empty_collection_to_be_null_or_empty_it_should_succeed()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().BeNullOrEmpty();\n }\n\n [Fact]\n public void\n When_asserting_non_empty_collection_to_be_null_or_empty_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().BeNullOrEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to be null or empty because we want to test the failure message, but found at least one item {1}.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_be_null_or_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([]);\n\n // Act\n collection.Should().BeNullOrEmpty();\n\n // Assert\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n\n [Fact]\n public void When_asserting_non_empty_collection_is_null_or_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([1, 2, 3]);\n\n // Act\n Action act = () => collection.Should().BeNullOrEmpty();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*to be null or empty, but found at least one item {1}.\");\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n }\n\n public class NotBeNullOrEmpty\n {\n [Fact]\n public void\n When_asserting_non_empty_collection_to_not_be_null_or_empty_it_should_succeed()\n {\n // Arrange\n object[] collection = [new object()];\n\n // Act / Assert\n collection.Should().NotBeNullOrEmpty();\n }\n\n [Fact]\n public void\n When_asserting_null_collection_to_not_be_null_or_empty_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotBeNullOrEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_empty_collection_to_not_be_null_or_empty_it_should_throw()\n {\n // Arrange\n int[] collection = [];\n\n // Act\n Action act = () => collection.Should().NotBeNullOrEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_collection_to_not_be_null_or_empty_it_should_enumerate_only_once()\n {\n // Arrange\n var collection = new CountingGenericEnumerable([42]);\n\n // Act\n collection.Should().NotBeNullOrEmpty();\n\n // Assert\n collection.GetEnumeratorCallCount.Should().Be(1);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/NullableSimpleTimeSpanAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic class NullableSimpleTimeSpanAssertionSpecs\n{\n [Fact]\n public void Should_succeed_when_asserting_nullable_TimeSpan_value_with_a_value_to_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act / Assert\n nullableTimeSpan.Should().HaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_TimeSpan_value_with_a_value_to_not_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act / Assert\n nullableTimeSpan.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_TimeSpan_value_without_a_value_to_not_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act\n Action act = () => nullableTimeSpan.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_TimeSpan_value_without_a_value_to_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act\n Action act = () => nullableTimeSpan.Should().HaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_TimeSpan_value_without_a_value_to_not_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act\n Action act = () => nullableTimeSpan.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_TimeSpan_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act / Assert\n nullableTimeSpan.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_TimeSpan_value_without_a_value_to_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = null;\n\n // Act / Assert\n nullableTimeSpan.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_TimeSpan_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act\n Action act = () => nullableTimeSpan.Should().NotHaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_TimeSpan_value_with_a_value_to_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act\n Action act = () => nullableTimeSpan.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_TimeSpan_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = 1.Seconds();\n\n // Act\n Action act = () => nullableTimeSpan.Should().NotHaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_TimeSpan_value_with_a_value_to_be_null()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = 1.Seconds();\n\n // Act\n Action act = () => nullableTimeSpan.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found 1s.\");\n }\n\n [Fact]\n public void\n When_asserting_a_nullable_TimeSpan_is_equal_to_a_different_nullable_TimeSpan_it_should_should_throw_appropriately()\n {\n // Arrange\n TimeSpan? nullableTimeSpanA = 1.Seconds();\n TimeSpan? nullableTimeSpanB = 2.Seconds();\n\n // Act\n Action action = () => nullableTimeSpanA.Should().Be(nullableTimeSpanB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_a_nullable_TimeSpan_is_equal_to_another_a_nullable_TimeSpan_but_it_is_null_it_should_fail_with_a_descriptive_message()\n {\n // Arrange\n TimeSpan? nullableTimeSpanA = null;\n TimeSpan? nullableTimeSpanB = 1.Seconds();\n\n // Act\n Action action =\n () =>\n nullableTimeSpanA.Should()\n .Be(nullableTimeSpanB, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected 1s because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_a_nullable_TimeSpan_is_equal_to_another_a_nullable_TimeSpan_and_both_are_null_it_should_succeed()\n {\n // Arrange\n TimeSpan? nullableTimeSpanA = null;\n TimeSpan? nullableTimeSpanB = null;\n\n // Act / Assert\n nullableTimeSpanA.Should().Be(nullableTimeSpanB);\n }\n\n [Fact]\n public void When_asserting_a_nullable_TimeSpan_is_equal_to_the_same_nullable_TimeSpan_it_should_succeed()\n {\n // Arrange\n TimeSpan? nullableTimeSpanA = default(TimeSpan);\n TimeSpan? nullableTimeSpanB = default(TimeSpan);\n\n // Act / Assert\n nullableTimeSpanA.Should().Be(nullableTimeSpanB);\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n TimeSpan? nullableTimeSpan = default(TimeSpan);\n\n // Act / Assert\n nullableTimeSpan.Should()\n .HaveValue()\n .And\n .Be(default(TimeSpan));\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveExplicitConversionOperator.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveExplicitConversionOperator specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveExplicitConversionOperator\n {\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operator_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(byte);\n\n // Act / Assert\n type.Should()\n .HaveExplicitConversionOperator(sourceType, targetType)\n .Which.Should()\n .NotBeNull();\n }\n\n [Fact]\n public void Can_chain_an_additional_assertion_on_the_implicit_conversion_operator()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(byte);\n\n // Act\n Action act = () => type\n .Should().HaveExplicitConversionOperator(sourceType, targetType)\n .Which.Should().HaveAccessModifier(CSharpAccessModifier.Private);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method explicit operator byte(TypeWithConversionOperators) to be Private, but it is Public.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operator_which_it_does_not_it_fails_with_a_useful_message()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(string);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(\n sourceType, targetType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_conversion_operator_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(\n typeof(TypeWithConversionOperators), typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operator_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(null, typeof(string));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"sourceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operator_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(typeof(TypeWithConversionOperators), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"targetType\");\n }\n }\n\n public class HaveExplicitConversionOperatorOfT\n {\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operatorOfT_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act / Assert\n type.Should()\n .HaveExplicitConversionOperator()\n .Which.Should()\n .NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_conversion_operatorOfT_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_conversion_operatorOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but type is .\");\n }\n }\n\n public class NotHaveExplicitConversionOperator\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operator_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(string);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitConversionOperator(sourceType, targetType);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operator_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(byte);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(\n sourceType, targetType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit byte(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_conversion_operator_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(\n typeof(TypeWithConversionOperators), typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit string(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operator_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(null, typeof(string));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"sourceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operator_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(typeof(TypeWithConversionOperators), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"targetType\");\n }\n }\n\n public class NotHaveExplicitConversionOperatorOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operatorOfT_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitConversionOperator();\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_conversion_operatorOfT_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static explicit byte(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but it does.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/ConstructorInfoAssertions.cs", "using System.Diagnostics;\nusing System.Reflection;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Contains a number of methods to assert that a is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class ConstructorInfoAssertions : MethodBaseAssertions\n{\n /// \n /// Initializes a new instance of the class.\n /// \n /// The constructorInfo from which to select properties.\n /// \n public ConstructorInfoAssertions(ConstructorInfo constructorInfo, AssertionChain assertionChain)\n : base(constructorInfo, assertionChain)\n {\n }\n\n private protected override string SubjectDescription => GetDescriptionFor(Subject);\n\n protected override string Identifier => \"constructor\";\n\n private static string GetDescriptionFor(ConstructorInfo constructorInfo)\n {\n return $\"{constructorInfo.DeclaringType}({GetParameterString(constructorInfo)})\";\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class ChainingConstraint\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n DateTimeOffset yesterday = new DateTime(2016, 06, 03).ToDateTimeOffset();\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTime.Should()\n .HaveValue()\n .And\n .BeAfter(yesterday);\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n DateTimeOffset someDateTimeOffset = new(2022, 9, 25, 13, 48, 42, 0, TimeSpan.Zero);\n\n // Act\n var action = () => someDateTimeOffset.Should().Equals(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/OuterExceptionSpecs.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class OuterExceptionSpecs\n{\n [Fact]\n public void When_subject_throws_expected_exception_with_an_expected_message_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"some message\"));\n\n // Act / Assert\n testSubject.Invoking(x => x.Do()).Should().Throw().WithMessage(\"some message\");\n }\n\n [Fact]\n public void When_subject_throws_expected_exception_but_with_unexpected_message_it_should_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"some\"));\n\n try\n {\n // Act\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithMessage(\"some message\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of*\\\"some message\\\", but*\\\"some\\\" does not*\");\n }\n }\n\n [Fact]\n public void When_subject_throws_expected_exception_with_message_starting_with_expected_message_it_should_not_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"expected message\"));\n\n // Act\n Action action = testSubject.Do;\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"expected mes*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_subject_throws_expected_exception_with_message_that_does_not_start_with_expected_message_it_should_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"OxpectOd message\"));\n\n // Act\n Action action = () => testSubject\n .Invoking(s => s.Do())\n .Should().Throw()\n .WithMessage(\"Expected mes\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected exception message to match the equivalent of*\\\"Expected mes*\\\", but*\\\"OxpectOd message\\\" does not*\");\n }\n\n [Fact]\n public void\n When_subject_throws_expected_exception_with_message_starting_with_expected_equivalent_message_it_should_not_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"Expected Message\"));\n\n // Act\n Action action = testSubject.Do;\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"expected mes*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_subject_throws_expected_exception_with_message_that_does_not_start_with_equivalent_message_it_should_throw()\n {\n // Arrange\n Does testSubject = Does.Throw(new InvalidOperationException(\"OxpectOd message\"));\n\n // Act\n Action action = () => testSubject\n .Invoking(s => s.Do())\n .Should().Throw()\n .WithMessage(\"expected mes\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected exception message to match the equivalent of*\\\"expected mes*\\\", but*\\\"OxpectOd message\\\" does not*\");\n }\n\n [Fact]\n public void When_subject_throws_some_exception_with_unexpected_message_it_should_throw_with_clear_description()\n {\n // Arrange\n Does subjectThatThrows = Does.Throw(new InvalidOperationException(\"message1\"));\n\n try\n {\n // Act\n subjectThatThrows\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithMessage(\"message2\", \"because we want to test the failure {0}\", \"message\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of \\\"message2\\\" because we want to test the failure message, but \\\"message1\\\" does not*\");\n }\n }\n\n [Fact]\n public void When_subject_throws_some_exception_with_an_empty_message_it_should_throw_with_clear_description()\n {\n // Arrange\n Does subjectThatThrows = Does.Throw(new InvalidOperationException(\"\"));\n\n try\n {\n // Act\n subjectThatThrows\n .Invoking(x => x.Do())\n .Should().Throw()\n .WithMessage(\"message2\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of \\\"message2\\\"*, but \\\"\\\"*\");\n }\n }\n\n [Fact]\n public void\n When_subject_throws_some_exception_with_message_which_contains_complete_expected_exception_and_more_it_should_throw()\n {\n // Arrange\n Does subjectThatThrows = Does.Throw(new ArgumentNullException(\"someParam\", \"message2\"));\n\n try\n {\n // Act\n subjectThatThrows\n .Invoking(x => x.Do(\"something\"))\n .Should().Throw()\n .WithMessage(\"message2\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of*\\\"message2\\\", but*message2*someParam*\");\n }\n }\n\n [Fact]\n public void When_no_exception_was_thrown_but_one_was_expected_it_should_clearly_report_that()\n {\n try\n {\n // Arrange\n Does testSubject = Does.NotThrow();\n\n // Act\n testSubject.Invoking(x => x.Do()).Should().Throw(\"because {0} should do that\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Be(\n \"Expected a to be thrown because Does.Do should do that, but no exception was thrown.\");\n }\n }\n\n [Fact]\n public void When_subject_throws_another_exception_than_expected_it_should_include_details_of_that_exception()\n {\n // Arrange\n var actualException = new ArgumentException();\n\n Does testSubject = Does.Throw(actualException);\n\n try\n {\n // Act\n testSubject\n .Invoking(x => x.Do())\n .Should().Throw(\"because {0} should throw that one\", \"Does.Do\");\n\n throw new XunitException(\"This point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().StartWith(\n \"Expected a to be thrown because Does.Do should throw that one, but found :\");\n\n ex.Message.Should().Contain(actualException.Message);\n }\n }\n\n [Fact]\n public void When_subject_throws_exception_with_message_with_braces_but_a_different_message_is_expected_it_should_report_that()\n {\n // Arrange\n Does subjectThatThrows = Does.Throw(new Exception(\"message with {}\"));\n\n try\n {\n // Act\n subjectThatThrows\n .Invoking(x => x.Do(\"something\"))\n .Should().Throw()\n .WithMessage(\"message without\");\n\n throw new XunitException(\"this point should not be reached\");\n }\n catch (XunitException ex)\n {\n // Assert\n ex.Message.Should().Match(\n \"Expected exception message to match the equivalent of*\\\"message without\\\"*, but*\\\"message with {}*\");\n }\n }\n\n [Fact]\n public void When_asserting_with_an_aggregate_exception_type_the_asserts_should_occur_against_the_aggregate_exception()\n {\n // Arrange\n Does testSubject = Does.Throw(new AggregateException(\"Outer Message\", new Exception(\"Inner Message\")));\n\n // Act\n Action act = testSubject.Do;\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Outer Message*\")\n .WithInnerException()\n .WithMessage(\"Inner Message\");\n }\n\n [Fact]\n public void\n When_asserting_with_an_aggregate_exception_and_inner_exception_type_from_argument_the_asserts_should_occur_against_the_aggregate_exception()\n {\n // Arrange\n Does testSubject = Does.Throw(new AggregateException(\"Outer Message\", new Exception(\"Inner Message\")));\n\n // Act\n Action act = testSubject.Do;\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Outer Message*\")\n .WithInnerException(typeof(Exception))\n .WithMessage(\"Inner Message\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.OnlyHaveUniqueItems.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The OnlyHaveUniqueItems specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class OnlyHaveUniqueItems\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_with_unique_items_contains_only_unique_items()\n {\n // Arrange\n int[] collection = [1, 2, 3, 4];\n\n // Act / Assert\n collection.Should().OnlyHaveUniqueItems();\n }\n\n [Fact]\n public void When_a_collection_contains_duplicate_items_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 3];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(\"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we don't like duplicates, but item 3 is not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_duplicate_items_it_supports_chaining()\n {\n // Arrange\n int[] collection = [1, 2, 3, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems().And.HaveCount(c => c > 1);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but item 3 is not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_multiple_duplicate_items_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3, 3];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(\"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we don't like duplicates, but items {2, 3} are not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_multiple_duplicate_items_it_supports_chaining()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems().And.HaveCount(c => c > 1);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but items {2, 3} are not unique.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_only_have_unique_items_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems(\"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_OnlyHaveUniqueItems_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_with_a_predicate_a_collection_with_unique_items_contains_only_unique_items()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"three\" },\n new SomeClass { Text = \"four\" }\n ];\n\n // Act / Assert\n collection.Should().OnlyHaveUniqueItems(e => e.Text);\n }\n\n [Fact]\n public void When_a_collection_contains_duplicate_items_with_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"three\" },\n new SomeClass { Text = \"three\" }\n ];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(e => e.Text, \"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items*on e.Text*because we don't like duplicates, but item*three*is not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_multiple_duplicate_items_with_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"three\" },\n new SomeClass { Text = \"three\" }\n ];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(e => e.Text, \"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items*on e.Text*because we don't like duplicates, but items*two*two*three*three*are not unique.\");\n }\n\n [Fact]\n public void Only_the_first_failing_assertion_in_a_chain_is_reported()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\", Number = 1 },\n new SomeClass { Text = \"two\", Number = 2 },\n new SomeClass { Text = \"two\", Number = 2 },\n new SomeClass { Text = \"three\", Number = 3 },\n new SomeClass { Text = \"three\", Number = 4 }\n ];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems(e => e.Text).And.OnlyHaveUniqueItems(e => e.Number);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*have unique items on e.Text*\");\n }\n\n [Fact]\n public void\n When_asserting_with_a_predicate_a_collection_to_only_have_unique_items_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyHaveUniqueItems(e => e.Text, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.NotContainNulls.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The NotContainNulls specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class NotContainNulls\n {\n [Fact]\n public void When_collection_does_not_contain_nulls_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainNulls();\n }\n\n [Fact]\n public void When_collection_contains_nulls_that_are_unexpected_it_should_throw()\n {\n // Arrange\n object[] collection = [new object(), null];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because they are evil, but found one at index 1.\");\n }\n\n [Fact]\n public void When_collection_contains_nulls_that_are_unexpected_it_supports_chaining()\n {\n // Arrange\n object[] collection = [new object(), null];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainNulls().And.HaveCount(c => c > 1);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but found one*\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_nulls_that_are_unexpected_it_should_throw()\n {\n // Arrange\n object[] collection = [new object(), null, new object(), null];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s*because they are evil*{1, 3}*\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_nulls_that_are_unexpected_it_supports_chaining()\n {\n // Arrange\n object[] collection = [new object(), null, new object(), null];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainNulls().And.HaveCount(c => c > 1);\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*but found several*\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_nulls_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because we want to test the behaviour with a null subject, but collection is .\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_NotContainNulls_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_nulls_with_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"one\" },\n new SomeClass { Text = \"two\" },\n new SomeClass { Text = \"three\" }\n ];\n\n // Act / Assert\n collection.Should().NotContainNulls(e => e.Text);\n }\n\n [Fact]\n public void When_collection_contains_nulls_that_are_unexpected_with_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"\" },\n new SomeClass { Text = null }\n ];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(e => e.Text, \"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s*on e.Text*because they are evil*Text = *\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_nulls_that_are_unexpected_with_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection =\n [\n new SomeClass { Text = \"\" },\n new SomeClass { Text = null },\n new SomeClass { Text = \"\" },\n new SomeClass { Text = null }\n ];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(e => e.Text, \"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s*on e.Text*because they are evil*Text = *Text = *\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_nulls_but_collection_is_null_it_should_fail()\n {\n // Arrange\n SomeClass[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainNulls(\"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s *failure message*, but collection is .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_contain_nulls_with_predicate_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainNulls(e => e.Text, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because we want to test the behaviour with a null subject, but collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class ChainingConstraint\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n DateTime earlierDateTime = new(2016, 06, 03);\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act / Assert\n nullableDateTime.Should()\n .HaveValue()\n .And\n .BeAfter(earlierDateTime);\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n DateTime someDateTime = new(2022, 9, 25, 13, 38, 42, DateTimeKind.Utc);\n\n // Act\n Action action = () => someDateTime.Should().Equals(someDateTime);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals_with_a_range()\n {\n // Arrange\n DateTime someDateTime = new(2022, 9, 25, 13, 38, 42, DateTimeKind.Utc);\n\n // Act\n Action action = () => someDateTime.Should().BeLessThan(0.Seconds()).Equals(someDateTime);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Before() or After() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.OnlyContain.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The OnlyContain specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class OnlyContain\n {\n [Fact]\n public void When_a_collection_does_not_contain_the_unexpected_items_it_should_not_be_enumerated_twice()\n {\n // Arrange\n var collection = new OneTimeEnumerable(1, 2, 3);\n\n // Act\n Action act = () => collection.Should().OnlyContain(i => i > 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain only items matching*\");\n }\n\n [Fact]\n public void When_injecting_a_null_predicate_into_OnlyContain_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action act = () => collection.Should().OnlyContain(predicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n\n [Fact]\n public void When_a_collection_contains_items_not_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [2, 12, 3, 11, 2];\n\n // Act\n Action act = () => collection.Should().OnlyContain(i => i <= 10, \"10 is the maximum\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain only items matching (i <= 10) because 10 is the maximum, but {12, 11} do(es) not match.\");\n }\n\n [Fact]\n public void When_a_collection_is_empty_and_should_contain_only_items_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable strings = [];\n\n // Act / Assert\n strings.Should().OnlyContain(e => e.Length > 0);\n }\n\n [Fact]\n public void When_a_collection_contains_only_items_matching_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [2, 9, 3, 8, 2];\n\n // Act / Assert\n collection.Should().OnlyContain(i => i <= 10);\n }\n\n [Fact]\n public void When_a_collection_is_null_then_only_contains_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().OnlyContain(i => i <= 10, \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to contain only items matching (i <= 10) *failure message*,\" +\n \" but the collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/FilteredEventRecording.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Events;\n\ninternal class FilteredEventRecording : IEventRecording\n{\n private readonly OccurredEvent[] occurredEvents;\n\n public FilteredEventRecording(IEventRecording eventRecorder, IEnumerable events)\n {\n EventObject = eventRecorder.EventObject;\n EventName = eventRecorder.EventName;\n EventHandlerType = eventRecorder.EventHandlerType;\n\n occurredEvents = events.ToArray();\n }\n\n public object EventObject { get; }\n\n public string EventName { get; }\n\n public Type EventHandlerType { get; }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n public IEnumerator GetEnumerator()\n {\n foreach (var occurredEvent in occurredEvents)\n {\n yield return new OccurredEvent\n {\n EventName = EventName,\n Parameters = occurredEvent.Parameters,\n TimestampUtc = occurredEvent.TimestampUtc\n };\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/NullableBooleanAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n// ReSharper disable ConditionIsAlwaysTrueOrFalse\npublic class NullableBooleanAssertionSpecs\n{\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_have_a_value_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act / Assert\n nullableBoolean.Should().HaveValue();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_not_be_null_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act / Assert\n nullableBoolean.Should().NotBeNull();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_have_a_value_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action act = () => nullableBoolean.Should().HaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_not_be_null_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action act = () => nullableBoolean.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_have_a_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action act = () => nullableBoolean.Should().HaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_not_be_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action act = () => nullableBoolean.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_not_have_a_value_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act / Assert\n nullableBoolean.Should().NotHaveValue();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_without_a_value_to_be_null_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act / Assert\n nullableBoolean.Should().BeNull();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_not_have_a_value_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act\n Action act = () => nullableBoolean.Should().NotHaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_be_null_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act\n Action act = () => nullableBoolean.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_nullable_boolean_value_with_a_value_to_be_not_have_a_value_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act\n Action act = () => nullableBoolean.Should().NotHaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found True.\");\n }\n\n [Fact]\n public void When_asserting_nullable_boolean_value_with_a_value_to_be_null_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act\n Action act = () => nullableBoolean.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found True.\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_is_false_it_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action action = () =>\n nullableBoolean.Should().BeFalse(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected nullableBoolean to be false because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_is_true_it_sShould_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n\n // Act\n Action action = () =>\n nullableBoolean.Should().BeTrue(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected nullableBoolean to be true because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_to_be_equal_to_different_nullable_boolean_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n bool? differentNullableBoolean = false;\n\n // Act\n Action action = () =>\n nullableBoolean.Should().Be(differentNullableBoolean, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected False because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_not_to_be_equal_to_same_value_should_fail()\n {\n // Arrange\n bool? nullableBoolean = null;\n bool? differentNullableBoolean = null;\n\n // Act\n Action action = () =>\n nullableBoolean.Should().NotBe(differentNullableBoolean, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableBoolean not to be because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_to_be_equal_to_null_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = null;\n bool? otherNullableBoolean = null;\n\n // Act / Assert\n nullableBoolean.Should().Be(otherNullableBoolean);\n }\n\n [Fact]\n public void When_asserting_boolean_null_value_not_to_be_equal_to_different_value_it_should_succeed()\n {\n // Arrange\n bool? nullableBoolean = true;\n bool? otherNullableBoolean = null;\n\n // Act / Assert\n nullableBoolean.Should().NotBe(otherNullableBoolean);\n }\n\n [Fact]\n public void When_asserting_true_is_not_false_it_should_succeed()\n {\n // Arrange\n bool? trueBoolean = true;\n\n // Act / Assert\n trueBoolean.Should().NotBeFalse();\n }\n\n [Fact]\n public void When_asserting_null_is_not_false_it_should_succeed()\n {\n // Arrange\n bool? nullValue = null;\n\n // Act / Assert\n nullValue.Should().NotBeFalse();\n }\n\n [Fact]\n public void When_asserting_false_is_not_false_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? falseBoolean = false;\n\n // Act\n Action action = () =>\n falseBoolean.Should().NotBeFalse(\"we want to test the failure message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*falseBoolean*not*False*because we want to test the failure message, but found False.\");\n }\n\n [Fact]\n public void When_asserting_false_is_not_true_it_should_succeed()\n {\n // Arrange\n bool? trueBoolean = false;\n\n // Act / Assert\n trueBoolean.Should().NotBeTrue();\n }\n\n [Fact]\n public void When_asserting_null_is_not_true_it_should_succeed()\n {\n // Arrange\n bool? nullValue = null;\n\n // Act / Assert\n nullValue.Should().NotBeTrue();\n }\n\n [Fact]\n public void When_asserting_true_is_not_true_it_should_fail_with_descriptive_message()\n {\n // Arrange\n bool? falseBoolean = true;\n\n // Act\n Action action = () =>\n falseBoolean.Should().NotBeTrue(\"we want to test the failure message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected*falseBoolean*not*True*because we want to test the failure message, but found True.\");\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n bool? nullableBoolean = true;\n\n // Act / Assert\n nullableBoolean.Should()\n .HaveValue()\n .And\n .BeTrue();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.Be.cs", "using System;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_datetime_value_is_equal_to_the_same_value()\n {\n // Arrange\n DateTime dateTime = new(2016, 06, 04);\n DateTime sameDateTime = new(2016, 06, 04);\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_datetime_value_is_equal_to_the_same_nullable_value_be_should_succeed()\n {\n // Arrange\n DateTime dateTime = 4.June(2016);\n DateTime? sameDateTime = 4.June(2016);\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_both_values_are_at_their_minimum_then_it_should_succeed()\n {\n // Arrange\n DateTime dateTime = DateTime.MinValue;\n DateTime sameDateTime = DateTime.MinValue;\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void When_both_values_are_at_their_maximum_then_it_should_succeed()\n {\n // Arrange\n DateTime dateTime = DateTime.MaxValue;\n DateTime sameDateTime = DateTime.MaxValue;\n\n // Act / Assert\n dateTime.Should().Be(sameDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_datetime_value_is_equal_to_the_different_value()\n {\n // Arrange\n var dateTime = new DateTime(2012, 03, 10);\n var otherDateTime = new DateTime(2012, 03, 11);\n\n // Act\n Action act = () => dateTime.Should().Be(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dateTime to be <2012-03-11>*failure message, but found <2012-03-10>.\");\n }\n\n [Fact]\n public void When_datetime_value_is_equal_to_the_different_nullable_value_be_should_failed()\n {\n // Arrange\n DateTime dateTime = 10.March(2012);\n DateTime? otherDateTime = 11.March(2012);\n\n // Act\n Action act = () => dateTime.Should().Be(otherDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dateTime to be <2012-03-11>*failure message, but found <2012-03-10>.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_equals_the_same_value()\n {\n // Arrange\n DateTime? nullableDateTimeA = new DateTime(2016, 06, 04);\n DateTime? nullableDateTimeB = new DateTime(2016, 06, 04);\n\n // Act / Assert\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n }\n\n [Fact]\n public void When_a_nullable_date_time_is_equal_to_a_normal_date_time_but_the_kinds_differ_it_should_still_succeed()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2014, 4, 20, 9, 11, 0, DateTimeKind.Unspecified);\n DateTime normalDateTime = new(2014, 4, 20, 9, 11, 0, DateTimeKind.Utc);\n\n // Act / Assert\n nullableDateTime.Should().Be(normalDateTime);\n }\n\n [Fact]\n public void When_two_date_times_are_equal_but_the_kinds_differ_it_should_still_succeed()\n {\n // Arrange\n DateTime dateTimeA = new(2014, 4, 20, 9, 11, 0, DateTimeKind.Unspecified);\n DateTime dateTimeB = new(2014, 4, 20, 9, 11, 0, DateTimeKind.Utc);\n\n // Act / Assert\n dateTimeA.Should().Be(dateTimeB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_null_value_equals_null()\n {\n // Arrange\n DateTime? nullableDateTimeA = null;\n DateTime? nullableDateTimeB = null;\n\n // Act / Assert\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n DateTime? nullableDateTimeA = new DateTime(2016, 06, 04);\n DateTime? nullableDateTimeB = new DateTime(2016, 06, 06);\n\n // Act\n Action action = () =>\n nullableDateTimeA.Should().Be(nullableDateTimeB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_datetime_null_value_is_equal_to_another_value()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act\n Action action = () =>\n nullableDateTime.Should().Be(new DateTime(2016, 06, 04), \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateTime to be <2016-06-04> because we want to test the failure message, but found .\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Should_succeed_when_asserting_datetime_value_is_not_equal_to_a_different_value()\n {\n // Arrange\n DateTime dateTime = new(2016, 06, 04);\n DateTime otherDateTime = new(2016, 06, 05);\n\n // Act / Assert\n dateTime.Should().NotBe(otherDateTime);\n }\n\n [Fact]\n public void When_datetime_value_is_not_equal_to_a_different_nullable_value_notbe_should_succeed()\n {\n // Arrange\n DateTime dateTime = 4.June(2016);\n DateTime? otherDateTime = 5.June(2016);\n\n // Act / Assert\n dateTime.Should().NotBe(otherDateTime);\n }\n\n [Fact]\n public void Should_fail_when_asserting_datetime_value_is_not_equal_to_the_same_value()\n {\n // Arrange\n var dateTime = DateTime.SpecifyKind(10.March(2012).At(10, 00), DateTimeKind.Local);\n var sameDateTime = DateTime.SpecifyKind(10.March(2012).At(10, 00), DateTimeKind.Utc);\n\n // Act\n Action act =\n () => dateTime.Should().NotBe(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected dateTime not to be <2012-03-10 10:00:00> because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void When_datetime_value_is_not_equal_to_the_same_nullable_value_notbe_should_failed()\n {\n // Arrange\n DateTime dateTime = DateTime.SpecifyKind(10.March(2012).At(10, 00), DateTimeKind.Local);\n DateTime? sameDateTime = DateTime.SpecifyKind(10.March(2012).At(10, 00), DateTimeKind.Utc);\n\n // Act\n Action act =\n () => dateTime.Should().NotBe(sameDateTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected dateTime not to be <2012-03-10 10:00:00> because we want to test the failure message, but it is.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.Be.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_timeonly_value_is_equal_to_the_same_value()\n {\n // Arrange\n TimeOnly timeOnly = new(15, 06, 04, 146);\n TimeOnly sameTimeOnly = new(15, 06, 04, 146);\n\n // Act/Assert\n timeOnly.Should().Be(sameTimeOnly);\n }\n\n [Fact]\n public void When_timeonly_value_is_equal_to_the_same_nullable_value_be_should_succeed()\n {\n // Arrange\n TimeOnly timeOnly = new(15, 06, 04, 146);\n TimeOnly? sameTimeOnly = new(15, 06, 04, 146);\n\n // Act/Assert\n timeOnly.Should().Be(sameTimeOnly);\n }\n\n [Fact]\n public void When_both_values_are_at_their_minimum_then_it_should_succeed()\n {\n // Arrange\n TimeOnly timeOnly = TimeOnly.MinValue;\n TimeOnly sameTimeOnly = TimeOnly.MinValue;\n\n // Act/Assert\n timeOnly.Should().Be(sameTimeOnly);\n }\n\n [Fact]\n public void When_both_values_are_at_their_maximum_then_it_should_succeed()\n {\n // Arrange\n TimeOnly timeOnly = TimeOnly.MaxValue;\n TimeOnly sameTimeOnly = TimeOnly.MaxValue;\n\n // Act/Assert\n timeOnly.Should().Be(sameTimeOnly);\n }\n\n [Fact]\n public void Should_fail_when_asserting_timeonly_value_is_equal_to_the_different_value()\n {\n // Arrange\n var timeOnly = new TimeOnly(15, 03, 10);\n var otherTimeOnly = new TimeOnly(15, 03, 11);\n\n // Act\n Action act = () => timeOnly.Should().Be(otherTimeOnly, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected timeOnly to be <15:03:11.000>*failure message, but found <15:03:10.000>.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_timeonly_value_is_equal_to_the_different_value_by_milliseconds()\n {\n // Arrange\n var timeOnly = new TimeOnly(15, 03, 10, 556);\n var otherTimeOnly = new TimeOnly(15, 03, 10, 175);\n\n // Act\n Action act = () => timeOnly.Should().Be(otherTimeOnly, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected timeOnly to be <15:03:10.175>*failure message, but found <15:03:10.556>.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_equals_the_same_value()\n {\n // Arrange\n TimeOnly? nullableTimeOnlyA = new TimeOnly(15, 06, 04, 123);\n TimeOnly? nullableTimeOnlyB = new TimeOnly(15, 06, 04, 123);\n\n // Act/Assert\n nullableTimeOnlyA.Should().Be(nullableTimeOnlyB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_null_value_equals_null()\n {\n // Arrange\n TimeOnly? nullableTimeOnlyA = null;\n TimeOnly? nullableTimeOnlyB = null;\n\n // Act/Assert\n nullableTimeOnlyA.Should().Be(nullableTimeOnlyB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n TimeOnly? nullableTimeOnlyA = new TimeOnly(15, 06, 04);\n TimeOnly? nullableTimeOnlyB = new TimeOnly(15, 06, 06);\n\n // Act\n Action action = () =>\n nullableTimeOnlyA.Should().Be(nullableTimeOnlyB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_timeonly_null_value_is_equal_to_another_value()\n {\n // Arrange\n TimeOnly? nullableTimeOnly = null;\n\n // Act\n Action action = () =>\n nullableTimeOnly.Should().Be(new TimeOnly(15, 06, 04), \"because we want to test the failure {0}\",\n \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableTimeOnly to be <15:06:04.000> because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_timeonly_value_is_not_equal_to_a_different_value()\n {\n // Arrange\n TimeOnly timeOnly = new(15, 06, 04);\n TimeOnly otherTimeOnly = new(15, 06, 05);\n\n // Act/Assert\n timeOnly.Should().NotBe(otherTimeOnly);\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Different_timeonly_values_are_valid()\n {\n // Arrange\n TimeOnly time = new(19, 06, 04);\n TimeOnly otherTime = new(20, 06, 05);\n\n // Act & Assert\n time.Should().NotBe(otherTime);\n }\n\n [Fact]\n public void Different_timeonly_values_with_different_nullability_are_valid()\n {\n // Arrange\n TimeOnly time = new(19, 06, 04);\n TimeOnly? otherTime = new(19, 07, 05);\n\n // Act & Assert\n time.Should().NotBe(otherTime);\n }\n\n [Fact]\n public void Same_timeonly_values_are_invalid()\n {\n // Arrange\n TimeOnly time = new(19, 06, 04);\n TimeOnly sameTime = new(19, 06, 04);\n\n // Act\n Action act =\n () => time.Should().NotBe(sameTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time not to be <19:06:04.000> because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void Same_timeonly_values_with_different_nullability_are_invalid()\n {\n // Arrange\n TimeOnly time = new(19, 06, 04);\n TimeOnly? sameTime = new(19, 06, 04);\n\n // Act\n Action act =\n () => time.Should().NotBe(sameTime, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected time not to be <19:06:04.000> because we want to test the failure message, but it is.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveElementSucceeding.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveElementSucceeding specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveElementSucceeding\n {\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_collection_has_the_correct_element_succeeding_another_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementSucceeding(\"cris\", \"mick\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_collection_has_the_wrong_element_succeeding_another_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(\"mick\", \"cris\", \"because of some reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*succeed*mick*because*reason*found*john*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_nothing_is_succeeding_an_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(\"john\", \"jane\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*jane*succeed*john*found*nothing*\");\n }\n\n [Fact]\n public void When_expecting_an_element_to_succeed_another_but_the_collection_is_empty_it_should_throw()\n {\n // Arrange\n var collection = new string[0];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(\"mick\", \"cris\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*succeed*mick*collection*empty*\");\n }\n\n [Fact]\n public void When_a_null_element_is_succeeding_another_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementSucceeding(\"mick\", null);\n }\n\n [Fact]\n public void When_a_null_element_is_not_succeeding_another_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(\"mick\", null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*null*succeed*mick*but found*john*\");\n }\n\n [Fact]\n public void When_an_element_is_succeeding_a_null_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementSucceeding(null, \"john\");\n }\n\n [Fact]\n public void When_an_element_is_not_succeeding_a_null_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementSucceeding(null, \"cris\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*succeed*null*but found*john*\");\n }\n\n [Fact]\n public void When_collection_is_null_then_have_element_succeeding_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveElementSucceeding(\"mick\", \"cris\", \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to have \\\"cris\\\" succeed \\\"mick\\\" *failure message*, but the collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.HaveCount.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class HaveCount\n {\n [Fact]\n public void Should_fail_when_asserting_collection_has_a_count_that_is_different_from_the_number_of_items()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveCount(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().HaveCount(3);\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should()\n .HaveCount(3)\n .And\n .HaveElementAt(1, \"two\")\n .And.NotContain(\"four\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_null_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveCount(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare collection count against a predicate.*\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_against_a_predicate_and_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act =\n () => collection.Should().HaveCount(c => c < 3, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain (c < 3) items because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_count_is_matched_and_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().HaveCount(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain 1 item(s) because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_has_a_count_larger_than_the_minimum_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().HaveCount(c => c >= 3);\n }\n\n [Fact]\n public void\n When_collection_has_a_count_that_is_different_from_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action action = () => collection.Should().HaveCount(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection to contain 4 item(s) because we want to test the failure message, but found 3: {\\\"one\\\", \\\"two\\\", \\\"three\\\"}.\");\n }\n\n [Fact]\n public void When_collection_has_a_count_that_not_matches_the_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveCount(c => c >= 4, \"a minimum of 4 is required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have a count (c >= 4) because a minimum of 4 is required, but count is 3: {\\\"one\\\", \\\"two\\\", \\\"three\\\"}.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveElementPreceding.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The HaveElementPreceding specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveElementPreceding\n {\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_collection_has_the_correct_element_preceding_another_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementPreceding(\"mick\", \"cris\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_collection_has_the_wrong_element_preceding_another_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(\"john\", \"cris\", \"because of some reason\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*precede*john*because*reason*found*mick*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_nothing_is_preceding_an_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(\"cris\", \"jane\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*jane*precede*cris*found*nothing*\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_expecting_an_element_to_precede_another_but_collection_is_empty_it_should_throw()\n {\n // Arrange\n var collection = new string[0];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(\"mick\", \"cris\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*precede*mick*collection*empty*\");\n }\n\n [Fact]\n public void When_a_null_element_is_preceding_another_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [null, \"mick\", \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementPreceding(\"mick\", null);\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_a_null_element_is_not_preceding_another_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"cris\", \"mick\", \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(\"mick\", null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*null*precede*mick*but found*cris*\");\n }\n\n [Fact]\n public void When_an_element_is_preceding_a_null_element_it_should_not_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act / Assert\n collection.Should().HaveElementPreceding(null, \"mick\");\n }\n\n [Fact]\n public void When_an_element_is_not_preceding_a_null_element_it_should_throw()\n {\n // Arrange\n string[] collection = [\"mick\", null, \"john\"];\n\n // Act\n Action act = () => collection.Should().HaveElementPreceding(null, \"cris\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected*cris*precede*null*but found*mick*\");\n }\n\n [Fact]\n public void When_collection_is_null_then_have_element_preceding_should_fail()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveElementPreceding(\"mick\", \"cris\", \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected collection to have \\\"cris\\\" precede \\\"mick\\\" *failure message*, but the collection is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeBefore.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeBefore\n {\n [Fact]\n public void When_asserting_a_point_of_time_is_before_a_later_point_it_should_succeed()\n {\n // Arrange\n DateTime earlierDate = DateTime.SpecifyKind(new DateTime(2016, 06, 04), DateTimeKind.Unspecified);\n DateTime laterDate = DateTime.SpecifyKind(new DateTime(2016, 06, 04, 0, 5, 0), DateTimeKind.Utc);\n\n // Act / Assert\n earlierDate.Should().BeBefore(laterDate);\n }\n\n [Fact]\n public void When_asserting_subject_is_before_earlier_expected_datetime_it_should_throw()\n {\n // Arrange\n DateTime expected = new(2016, 06, 03);\n DateTime subject = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_before_the_same_datetime_it_should_throw()\n {\n // Arrange\n DateTime expected = new(2016, 06, 04);\n DateTime subject = new(2016, 06, 04);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04>, but found <2016-06-04>.\");\n }\n }\n\n public class NotBeBefore\n {\n [Fact]\n public void When_asserting_a_point_of_time_is_not_before_another_it_should_throw()\n {\n // Arrange\n DateTime earlierDate = DateTime.SpecifyKind(new DateTime(2016, 06, 04), DateTimeKind.Unspecified);\n DateTime laterDate = DateTime.SpecifyKind(new DateTime(2016, 06, 04, 0, 5, 0), DateTimeKind.Utc);\n\n // Act\n Action act = () => earlierDate.Should().NotBeBefore(laterDate);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected earlierDate to be on or after <2016-06-04 00:05:00>, but found <2016-06-04>.\");\n }\n\n [Fact]\n public void When_asserting_subject_is_not_before_earlier_expected_datetime_it_should_succeed()\n {\n // Arrange\n DateTime expected = new(2016, 06, 03);\n DateTime subject = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_datetime_is_not_before_the_same_datetime_it_should_succeed()\n {\n // Arrange\n DateTime expected = new(2016, 06, 04);\n DateTime subject = new(2016, 06, 04);\n\n // Act / Assert\n subject.Should().NotBeBefore(expected);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.Be.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_dateonly_value_is_equal_to_the_same_value()\n {\n // Arrange\n DateOnly dateOnly = new(2016, 06, 04);\n DateOnly sameDateOnly = new(2016, 06, 04);\n\n // Act/Assert\n dateOnly.Should().Be(sameDateOnly);\n }\n\n [Fact]\n public void When_dateonly_value_is_equal_to_the_same_nullable_value_be_should_succeed()\n {\n // Arrange\n DateOnly dateOnly = new(2016, 06, 04);\n DateOnly? sameDateOnly = new(2016, 06, 04);\n\n // Act/Assert\n dateOnly.Should().Be(sameDateOnly);\n }\n\n [Fact]\n public void When_both_values_are_at_their_minimum_then_it_should_succeed()\n {\n // Arrange\n DateOnly dateOnly = DateOnly.MinValue;\n DateOnly sameDateOnly = DateOnly.MinValue;\n\n // Act/Assert\n dateOnly.Should().Be(sameDateOnly);\n }\n\n [Fact]\n public void When_both_values_are_at_their_maximum_then_it_should_succeed()\n {\n // Arrange\n DateOnly dateOnly = DateOnly.MaxValue;\n DateOnly sameDateOnly = DateOnly.MaxValue;\n\n // Act/Assert\n dateOnly.Should().Be(sameDateOnly);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dateonly_value_is_equal_to_the_different_value()\n {\n // Arrange\n var dateOnly = new DateOnly(2012, 03, 10);\n var otherDateOnly = new DateOnly(2012, 03, 11);\n\n // Act\n Action act = () => dateOnly.Should().Be(otherDateOnly, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected dateOnly to be <2012-03-11>*failure message, but found <2012-03-10>.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_equals_the_same_value()\n {\n // Arrange\n DateOnly? nullableDateOnlyA = new DateOnly(2016, 06, 04);\n DateOnly? nullableDateOnlyB = new DateOnly(2016, 06, 04);\n\n // Act/Assert\n nullableDateOnlyA.Should().Be(nullableDateOnlyB);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_null_value_equals_null()\n {\n // Arrange\n DateOnly? nullableDateOnlyA = null;\n DateOnly? nullableDateOnlyB = null;\n\n // Act/Assert\n nullableDateOnlyA.Should().Be(nullableDateOnlyB);\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_equals_a_different_value()\n {\n // Arrange\n DateOnly? nullableDateOnlyA = new DateOnly(2016, 06, 04);\n DateOnly? nullableDateOnlyB = new DateOnly(2016, 06, 06);\n\n // Act\n Action action = () =>\n nullableDateOnlyA.Should().Be(nullableDateOnlyB);\n\n // Assert\n action.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_dateonly_null_value_is_equal_to_another_value()\n {\n // Arrange\n DateOnly? nullableDateOnly = null;\n\n // Act\n Action action = () =>\n nullableDateOnly.Should().Be(new DateOnly(2016, 06, 04), \"because we want to test the failure {0}\",\n \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected nullableDateOnly to be <2016-06-04> because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dateonly_value_is_not_equal_to_a_different_value()\n {\n // Arrange\n DateOnly dateOnly = new(2016, 06, 04);\n DateOnly otherDateOnly = new(2016, 06, 05);\n\n // Act/Assert\n dateOnly.Should().NotBe(otherDateOnly);\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Different_dateonly_values_are_valid()\n {\n // Arrange\n DateOnly date = new(2020, 06, 04);\n DateOnly otherDate = new(2020, 06, 05);\n\n // Act & Assert\n date.Should().NotBe(otherDate);\n }\n\n [Fact]\n public void Different_dateonly_values_with_different_nullability_are_valid()\n {\n // Arrange\n DateOnly date = new(2020, 06, 04);\n DateOnly? otherDate = new(2020, 07, 05);\n\n // Act & Assert\n date.Should().NotBe(otherDate);\n }\n\n [Fact]\n public void Same_dateonly_values_are_invalid()\n {\n // Arrange\n DateOnly date = new(2020, 06, 04);\n DateOnly sameDate = new(2020, 06, 04);\n\n // Act\n Action act =\n () => date.Should().NotBe(sameDate, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected date not to be <2020-06-04> because we want to test the failure message, but it is.\");\n }\n\n [Fact]\n public void Same_dateonly_values_with_different_nullability_are_invalid()\n {\n // Arrange\n DateOnly date = new(2020, 06, 04);\n DateOnly? sameDate = new(2020, 06, 04);\n\n // Act\n Action act =\n () => date.Should().NotBe(sameDate, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected date not to be <2020-06-04> because we want to test the failure message, but it is.\");\n }\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveExplicitProperty.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveExplicitProperty specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveExplicitProperty\n {\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_property_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitProperty(interfaceType, \"ExplicitStringProperty\");\n }\n\n [Fact]\n public void\n When_asserting_a_type_explicitly_implements_a_property_which_it_implements_implicitly_and_explicitly_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitProperty(interfaceType, \"ExplicitImplicitStringProperty\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_property_which_it_implements_implicitly_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitProperty(interfaceType, \"ImplicitStringProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to explicitly implement \" +\n \"*.IExplicitInterface.ImplicitStringProperty, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_property_which_it_does_not_implement_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitProperty(interfaceType, \"NonExistentProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to explicitly implement \" +\n \"*.IExplicitInterface.NonExistentProperty, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_property_from_an_unimplemented_interface_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitProperty(interfaceType, \"NonExistentProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassExplicitlyImplementingInterface to implement interface *.IDummyInterface\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_property_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(\n typeof(IExplicitInterface), \"ExplicitStringProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to explicitly implement *.IExplicitInterface.ExplicitStringProperty *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_property_inherited_by_null_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(null, \"ExplicitStringProperty\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(typeof(IExplicitInterface), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(typeof(IExplicitInterface), string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void Does_not_continue_assertion_on_explicit_interface_implementation_if_not_implemented_at_all()\n {\n var act = () =>\n {\n using var _ = new AssertionScope();\n typeof(int).Should().HaveExplicitProperty(typeof(IExplicitInterface), \"Foo\");\n };\n\n act.Should().Throw()\n .WithMessage(\"Expected type int to*implement *IExplicitInterface, but it does not.\");\n }\n }\n\n public class HaveExplicitPropertyOfT\n {\n [Fact]\n public void When_asserting_a_type_explicitlyOfT_implements_a_property_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitProperty(\"ExplicitStringProperty\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicitlyOfT_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicitlyOfT_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_propertyOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitProperty(\n \"ExplicitStringProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to explicitly implement *.IExplicitInterface.ExplicitStringProperty *failure message*\" +\n \", but type is .\");\n }\n }\n\n public class NotHaveExplicitProperty\n {\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_property_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"ExplicitStringProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitStringProperty, but it does.\");\n }\n\n [Fact]\n public void\n When_asserting_a_type_does_not_explicitly_implement_a_property_which_it_implements_implicitly_and_explicitly_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"ExplicitImplicitStringProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitImplicitStringProperty, but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_property_which_it_implements_implicitly_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"ImplicitStringProperty\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_property_which_it_does_not_implement_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"NonExistentProperty\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_property_from_an_unimplemented_interface_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitProperty(interfaceType, \"NonExistentProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassExplicitlyImplementingInterface to implement interface *.IDummyInterface\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_property_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(\n typeof(IExplicitInterface), \"ExplicitStringProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to not explicitly implement *IExplicitInterface.ExplicitStringProperty *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_property_inherited_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(null, \"ExplicitStringProperty\");\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(typeof(IExplicitInterface), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(typeof(IExplicitInterface), string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void Does_not_continue_assertion_on_explicit_interface_implementation_if_implemented()\n {\n var act = () =>\n {\n using var _ = new AssertionScope();\n typeof(ClassExplicitlyImplementingInterface)\n .Should().NotHaveExplicitProperty(typeof(IExplicitInterface), \"ExplicitStringProperty\");\n };\n\n act.Should().Throw()\n .WithMessage(\"Expected *ClassExplicitlyImplementingInterface* to*implement \" +\n \"*IExplicitInterface.ExplicitStringProperty, but it does.\");\n }\n }\n\n public class NotHaveExplicitPropertyOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_explicitlyOfT_implement_a_property_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitProperty(\"ExplicitStringProperty\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitStringProperty, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_propertyOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(\n \"ExplicitStringProperty\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to not explicitly implement *.IExplicitInterface.ExplicitStringProperty *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicitlyOfT_property_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicitlyOfT_property_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitProperty(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Numeric/NumericAssertions.cs", "using System;\nusing System.Diagnostics;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Numeric;\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NumericAssertions : NumericAssertions>\n where T : struct, IComparable\n{\n public NumericAssertions(T value, AssertionChain assertionChain)\n : base(value, assertionChain)\n {\n }\n}\n\n/// \n/// Contains a number of methods to assert that an is in the expected state.\n/// \n[DebuggerNonUserCode]\npublic class NumericAssertions : NumericAssertionsBase\n where T : struct, IComparable\n where TAssertions : NumericAssertions\n{\n public NumericAssertions(T value, AssertionChain assertionChain)\n : base(assertionChain)\n {\n Subject = value;\n }\n\n public override T Subject { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/NullableGuidAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic class NullableGuidAssertionSpecs\n{\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_value_with_a_value_to_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act / Assert\n nullableGuid.Should().HaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_value_with_a_value_to_not_be_null()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act / Assert\n nullableGuid.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_guid_value_without_a_value_to_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act\n Action act = () => nullableGuid.Should().HaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_guid_value_without_a_value_to_not_be_null()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act\n Action act = () => nullableGuid.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_without_a_value_to_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act\n Action act = () => nullableGuid.Should().HaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_without_a_value_to_not_be_null()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act\n Action act = () => nullableGuid.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act / Assert\n nullableGuid.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_value_without_a_value_to_be_null()\n {\n // Arrange\n Guid? nullableGuid = null;\n\n // Act / Assert\n nullableGuid.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_guid_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act\n Action act = () => nullableGuid.Should().NotHaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_guid_value_with_a_value_to_be_null()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act\n Action act = () => nullableGuid.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_when_guid_is_null_while_asserting_guid_equals_another_guid()\n {\n // Arrange\n Guid? guid = null;\n var someGuid = new Guid(\"55555555-ffff-eeee-dddd-444444444444\");\n\n // Act\n Action act = () =>\n guid.Should().Be(someGuid, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Guid to be {55555555-ffff-eeee-dddd-444444444444} because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_guid_null_equals_null()\n {\n // Arrange\n Guid? nullGuid = null;\n Guid? otherNullGuid = null;\n\n // Act / Assert\n nullGuid.Should().Be(otherNullGuid);\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n Guid? nullableGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => nullableGuid.Should().NotHaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect a value because we want to test the failure message, but found {11111111-aaaa-bbbb-cccc-999999999999}.\");\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_guid_value_with_a_value_to_be_null()\n {\n // Arrange\n Guid? nullableGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => nullableGuid.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Did not expect a value because we want to test the failure message, but found {11111111-aaaa-bbbb-cccc-999999999999}.\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_null_equals_some_guid()\n {\n // Arrange\n Guid? nullableGuid = null;\n var someGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () =>\n nullableGuid.Should().Be(someGuid, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullableGuid to be {11111111-aaaa-bbbb-cccc-999999999999} because we want to test the failure message, but found .\");\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n Guid? nullableGuid = Guid.NewGuid();\n\n // Act / Assert\n nullableGuid.Should()\n .HaveValue()\n .And\n .NotBeEmpty();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveImplicitConversionOperator.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveImplicitConversionOperator specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveImplicitConversionOperator\n {\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operator_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(int);\n\n // Act / Assert\n type.Should()\n .HaveImplicitConversionOperator(sourceType, targetType)\n .Which.Should()\n .NotBeNull();\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operator_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(string);\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(\n sourceType, targetType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_implicit_conversion_operator_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(\n typeof(TypeWithConversionOperators), typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operator_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(null, typeof(string));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"sourceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operator_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(typeof(TypeWithConversionOperators), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"targetType\");\n }\n }\n\n public class HaveImplicitConversionOperatorOfT\n {\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operatorOfT_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act / Assert\n type.Should()\n .HaveImplicitConversionOperator()\n .Which.Should()\n .NotBeNull();\n }\n\n [Fact]\n public void Can_chain_an_additional_assertion_on_the_implicit_conversion_operator()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveImplicitConversionOperator()\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.Internal);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method implicit operator int(TypeWithConversionOperators) to be Internal, but it is Public.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_implicit_conversion_operatorOfT_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_implicit_conversion_operatorOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveImplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to exist *failure message*\" +\n \", but type is .\");\n }\n }\n\n public class NotHaveImplicitConversionOperator\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operator_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(string);\n\n // Act / Assert\n type.Should()\n .NotHaveImplicitConversionOperator(sourceType, targetType);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operator_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n var sourceType = typeof(TypeWithConversionOperators);\n var targetType = typeof(int);\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(\n sourceType, targetType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit int(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_implicit_conversion_operator_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(\n typeof(TypeWithConversionOperators), typeof(string), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operator_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(null, typeof(string));\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"sourceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operator_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(typeof(TypeWithConversionOperators), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"targetType\");\n }\n }\n\n public class NotHaveImplicitConversionOperatorOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operatorOfT_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act / Assert\n type.Should()\n .NotHaveImplicitConversionOperator();\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_implicit_conversion_operatorOfT_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(TypeWithConversionOperators);\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit int(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_implicit_conversion_operatorOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveImplicitConversionOperator(\n \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected public static implicit string(*.TypeWithConversionOperators) to not exist *failure message*\" +\n \", but type is .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/FluentActionsSpecs.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Xunit;\nusing static AwesomeAssertions.FluentActions;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class FluentActionsSpecs\n{\n [Fact]\n public void Invoking_works_with_action()\n {\n // Arrange / Act / Assert\n Invoking(() => Throws()).Should().Throw();\n }\n\n [Fact]\n public void Invoking_works_with_func()\n {\n // Arrange / Act / Assert\n Invoking(() => Throws(0)).Should().Throw();\n }\n\n [Fact]\n public async Task Awaiting_works_with_action()\n {\n // Arrange / Act / Assert\n await Awaiting(() => ThrowsAsync()).Should().ThrowAsync();\n }\n\n [Fact]\n public async Task Awaiting_works_with_func()\n {\n // Arrange / Act / Assert\n await Awaiting(() => ThrowsAsync(0)).Should().ThrowAsync();\n }\n\n [Fact]\n public void Enumerating_works_with_general()\n {\n // Arrange / Act / Assert\n Enumerating(() => ThrowsAfterFirst()).Should().Throw();\n }\n\n [Fact]\n public void Enumerating_works_with_specialized()\n {\n // Arrange / Act / Assert\n Enumerating(() => ThrowsAfterFirst(0)).Should().Throw();\n }\n\n [Fact]\n public void Enumerating_works_with_enumerable_func()\n {\n // Arrange\n var actual = new Example();\n\n // Act / Assert\n actual.Enumerating(x => x.DoSomething()).Should().Throw();\n }\n\n private class Example\n {\n public IEnumerable DoSomething()\n {\n var range = Enumerable.Range(0, 10);\n\n return range.Select(Twice);\n }\n\n private int Twice(int arg)\n {\n if (arg == 5)\n {\n throw new InvalidOperationException();\n }\n\n return 2 * arg;\n }\n }\n\n private static void Throws()\n {\n throw new InvalidOperationException();\n }\n\n private static int Throws(int _)\n {\n throw new InvalidOperationException();\n }\n\n private static async Task ThrowsAsync()\n {\n await Task.Yield();\n throw new InvalidOperationException();\n }\n\n private static async Task ThrowsAsync(int _)\n {\n await Task.Yield();\n throw new InvalidOperationException();\n }\n\n private static IEnumerable ThrowsAfterFirst()\n {\n yield return 0;\n throw new InvalidOperationException();\n }\n\n private static IEnumerable ThrowsAfterFirst(int number)\n {\n yield return number;\n throw new InvalidOperationException();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/MethodInfoSelectorAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Types;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\npublic class MethodInfoSelectorAssertionSpecs\n{\n public class BeVirtual\n {\n [Fact]\n public void When_asserting_methods_are_virtual_and_they_are_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsVirtual));\n\n // Act / Assert\n methodSelector.Should().BeVirtual();\n }\n\n [Fact]\n public void When_asserting_methods_are_virtual_but_non_virtual_methods_are_found_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonVirtualPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().BeVirtual();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_methods_are_virtual_but_non_virtual_methods_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonVirtualPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().BeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods\" +\n \" to be virtual because we want to test the error message,\" +\n \" but the following methods are not virtual:*\" +\n \"Void AwesomeAssertions*ClassWithNonVirtualPublicMethods.PublicDoNothing*\" +\n \"Void AwesomeAssertions*ClassWithNonVirtualPublicMethods.InternalDoNothing*\" +\n \"Void AwesomeAssertions*ClassWithNonVirtualPublicMethods.ProtectedDoNothing\");\n }\n }\n\n public class NotBeVirtual\n {\n [Fact]\n public void When_asserting_methods_are_not_virtual_and_they_are_not_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonVirtualPublicMethods));\n\n // Act / Assert\n methodSelector.Should().NotBeVirtual();\n }\n\n [Fact]\n public void When_asserting_methods_are_not_virtual_but_virtual_methods_are_found_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsVirtual));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBeVirtual();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_methods_are_not_virtual_but_virtual_methods_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsVirtual));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBeVirtual(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods\" +\n \" not to be virtual because we want to test the error message,\" +\n \" but the following methods are virtual\" +\n \"*ClassWithAllMethodsVirtual.PublicVirtualDoNothing\" +\n \"*ClassWithAllMethodsVirtual.InternalVirtualDoNothing\" +\n \"*ClassWithAllMethodsVirtual.ProtectedVirtualDoNothing*\");\n }\n }\n\n public class BeDecoratedWith\n {\n [Fact]\n public void When_injecting_a_null_predicate_into_BeDecoratedWith_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n methodSelector.Should().BeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_methods_are_decorated_with_attribute_and_they_are_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsDecoratedWithDummyAttribute));\n\n // Act / Assert\n methodSelector.Should().BeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_methods_are_decorated_with_attribute_but_they_are_not_it_should_throw()\n {\n // Arrange\n MethodInfoSelector methodSelector =\n new MethodInfoSelector(typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute))\n .ThatArePublicOrInternal;\n\n // Act\n Action act = () =>\n methodSelector.Should().BeDecoratedWith();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_methods_are_decorated_with_attribute_but_they_are_not_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n methodSelector.Should().BeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to be decorated with\" +\n \" AwesomeAssertions*DummyMethodAttribute because we want to test the error message,\" +\n \" but the following methods are not:*\" +\n \"Void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.PublicDoNothing*\" +\n \"Void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.ProtectedDoNothing*\" +\n \"Void AwesomeAssertions*ClassWithMethodsThatAreNotDecoratedWithDummyAttribute.PrivateDoNothing\");\n }\n }\n\n public class NotBeDecoratedWith\n {\n [Fact]\n public void When_injecting_a_null_predicate_into_NotBeDecoratedWith_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBeDecoratedWith(isMatchingAttributePredicate: null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"isMatchingAttributePredicate\");\n }\n\n [Fact]\n public void When_asserting_methods_are_not_decorated_with_attribute_and_they_are_not_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithMethodsThatAreNotDecoratedWithDummyAttribute));\n\n // Act / Assert\n methodSelector.Should().NotBeDecoratedWith();\n }\n\n [Fact]\n public void When_asserting_methods_are_not_decorated_with_attribute_but_they_are_it_should_throw()\n {\n // Arrange\n MethodInfoSelector methodSelector =\n new MethodInfoSelector(typeof(ClassWithAllMethodsDecoratedWithDummyAttribute))\n .ThatArePublicOrInternal;\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBeDecoratedWith();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_asserting_methods_are_not_decorated_with_attribute_but_they_are_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsDecoratedWithDummyAttribute));\n\n // Act\n Action act = () => methodSelector.Should()\n .NotBeDecoratedWith(\"because we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected all selected methods to not be decorated*DummyMethodAttribute*because we want to test the error message\" +\n \"*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothing*\" +\n \"*ClassWithAllMethodsDecoratedWithDummyAttribute.PublicDoNothingWithSameAttributeTwice*\" +\n \"*ClassWithAllMethodsDecoratedWithDummyAttribute.ProtectedDoNothing*\" +\n \"*ClassWithAllMethodsDecoratedWithDummyAttribute.PrivateDoNothing\");\n }\n }\n\n public class Be\n {\n [Fact]\n public void When_all_methods_have_specified_accessor_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithPublicMethods));\n\n // Act / Assert\n methodSelector.Should().Be(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_not_all_methods_have_specified_accessor_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(GenericClassWithNonPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().Be(CSharpAccessModifier.Public);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to be Public\" +\n \", but the following methods are not:*\" +\n \"void AwesomeAssertions*.GenericClassWithNonPublicMethods.PublicDoNothing*\" +\n \"void AwesomeAssertions*.GenericClassWithNonPublicMethods.DoNothingWithParameter*\" +\n \"void AwesomeAssertions*.GenericClassWithNonPublicMethods.DoNothingWithAnotherParameter\");\n }\n\n [Fact]\n public void When_not_all_methods_have_specified_accessor_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(GenericClassWithNonPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().Be(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to be Public\" +\n \" because we want to test the error message\" +\n \", but the following methods are not:*\" +\n \"Void AwesomeAssertions*.GenericClassWithNonPublicMethods.PublicDoNothing*\" +\n \"Void AwesomeAssertions*.GenericClassWithNonPublicMethods.DoNothingWithParameter*\" +\n \"Void AwesomeAssertions*.GenericClassWithNonPublicMethods.DoNothingWithAnotherParameter\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_all_methods_does_not_have_specified_accessor_it_should_succeed()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(GenericClassWithNonPublicMethods));\n\n // Act / Assert\n methodSelector.Should().NotBe(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_any_method_have_specified_accessor_it_should_throw()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBe(CSharpAccessModifier.Public);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to not be Public\" +\n \", but the following methods are:*\" +\n \"Void AwesomeAssertions*ClassWithPublicMethods.PublicDoNothing*\");\n }\n\n [Fact]\n public void When_any_method_have_specified_accessor_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithPublicMethods));\n\n // Act\n Action act = () =>\n methodSelector.Should().NotBe(CSharpAccessModifier.Public, \"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected all selected methods to not be Public\" +\n \" because we want to test the error message\" +\n \", but the following methods are:*\" +\n \"Void AwesomeAssertions*ClassWithPublicMethods.PublicDoNothing*\");\n }\n }\n\n public class BeAsync\n {\n [Fact]\n public void When_asserting_methods_are_async_and_they_are_then_it_succeeds()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsAsync));\n\n // Act / Assert\n methodSelector.Should().BeAsync();\n }\n\n [Fact]\n public void When_asserting_methods_are_async_but_non_async_methods_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonAsyncMethods));\n\n // Act\n Action act = () => methodSelector.Should().BeAsync(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"\"\"\n Expected all selected methods to be async because we want to test the error message, but the following methods are not:\n Task AwesomeAssertions.Specs.Types.ClassWithNonAsyncMethods.PublicDoNothing\n Task AwesomeAssertions.Specs.Types.ClassWithNonAsyncMethods.InternalDoNothing\n Task AwesomeAssertions.Specs.Types.ClassWithNonAsyncMethods.ProtectedDoNothing\n \"\"\");\n }\n }\n\n public class NotBeAsync\n {\n [Fact]\n public void When_asserting_methods_are_not_async_and_they_are_not_then_it_succeeds()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithNonAsyncMethods));\n\n // Act / Assert\n methodSelector.Should().NotBeAsync();\n }\n\n [Fact]\n public void When_asserting_methods_are_not_async_but_async_methods_are_found_it_should_throw_with_descriptive_message()\n {\n // Arrange\n var methodSelector = new MethodInfoSelector(typeof(ClassWithAllMethodsAsync));\n\n // Act\n Action act = () => methodSelector.Should().NotBeAsync(\"we want to test the error {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"\"\"\n Expected all selected methods not to be async because we want to test the error message, but the following methods are:\n Task AwesomeAssertions.Specs.Types.ClassWithAllMethodsAsync.PublicAsyncDoNothing\n Task AwesomeAssertions.Specs.Types.ClassWithAllMethodsAsync.InternalAsyncDoNothing\n Task AwesomeAssertions.Specs.Types.ClassWithAllMethodsAsync.ProtectedAsyncDoNothing\n \"\"\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.ContainInConsecutiveOrder.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]ContainInOrder specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class ContainInConsecutiveOrder\n {\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_explicit_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_the_second_collection_contains_just_1_item_included_in_the_first_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(2);\n }\n\n [Fact]\n public void\n When_the_first_collection_contains_a_partial_duplicate_sequence_at_the_start_without_affecting_the_explicit_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 3, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_explicit_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(1, 2, 1, 2, 12, 2, 2);\n }\n\n [Fact]\n public void When_checking_for_an_empty_list_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder();\n }\n\n [Fact]\n public void When_collection_contains_null_value_it_should_not_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act / Assert\n collection.Should().ContainInConsecutiveOrder(1, null, 2, \"string\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_but_not_in_the_same_explicit_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n Action act = () => collection.Should().ContainInConsecutiveOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 2, 3} to contain items {1, 2, 3} in order, but 3 (index 2) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_the_second_collection_contains_just_1_item_not_included_in_the_first_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 2, 3];\n\n // Act / Assert\n Action act = () => collection.Should().ContainInConsecutiveOrder(4);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 2, 3} to contain items {4} in order, but 4 (index 0) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_end_of_first_collection_is_a_partial_match_of_second_at_end_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 3, 1, 2];\n\n // Act / Assert\n Action act = () => collection.Should().ContainInConsecutiveOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 3, 1, 2} to contain items {1, 2, 3} in order, but 3 (index 2) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 3, 12, 2, 2];\n\n // Act\n Action act = () => collection.Should().ContainInConsecutiveOrder(1, 2, 1, 1, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 2, 3, 12, 2, 2} to contain items {1, 2, 1, 1, 2} in order, but 1 (index 3) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInConsecutiveOrder([3, 1], \"because we said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain items {3, 1} in order because we said so, but 1 (index 1) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInConsecutiveOrder([4, 1], \"we failed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3} to contain items {4, 1} in order because we failed, \" +\n \"but 4 (index 0) did not appear (in the right consecutive order).\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_ordered_containment_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { 1, 2, 3 }.Should().ContainInConsecutiveOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify ordered containment against a collection.*\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n\n collection.Should()\n .ContainInConsecutiveOrder([4], \"because we're checking how it reacts to a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to contain {4} in order because we're checking how it reacts to a null subject, but found .\");\n }\n }\n\n public class NotContainInConsecutiveOrder\n {\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(2, 1);\n }\n\n [Fact]\n public void When_the_second_collection_contains_just_1_item_not_included_in_the_first_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(4);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(4, 1);\n }\n\n [Fact]\n public void When_checking_for_an_empty_list_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder();\n }\n\n [Fact]\n public void When_a_collection_contains_less_items_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(1, 2, 3);\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 3, 12, 2, 2];\n\n // Act / Assert\n collection.Should().NotContainInConsecutiveOrder(1, 2, 1, 1, 2);\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_not_in_the_same_explicit_order_it_should_not_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 2, 3];\n\n // Act\n collection.Should().NotContainInConsecutiveOrder([1, 2, 3], \"that's what we expect\");\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(4);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_collection_is_null_then_not_contain_in_order_should_fail()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainInConsecutiveOrder([1, 2, 3], \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_collection_and_contains_contain_the_same_items_in_the_same_order_with_null_value_it_should_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(1, null, 2, \"string\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, , 2, \\\"string\\\"} to not contain items {1, , 2, \\\"string\\\"} in consecutive order, \" +\n \"but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_the_second_collection_contains_just_1_item_included_in_the_first_it_should_throw()\n {\n // Arrange\n var collection = new object[] { 1, null, 2, \"string\" };\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, , 2, \\\"string\\\"} to not contain items {2} in consecutive order, \" +\n \"but items appeared in order ending at index 2.\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 3, 2} to not contain items {1, 2, 3} in consecutive order, \" +\n \"but items appeared in order ending at index 2.\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_not_at_start_without_affecting_the_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 3, 4, 5, 1, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(1, 2, 3);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 2, 3, 4, 5, 1, 2} to not contain items {1, 2, 3} in consecutive order, \" +\n \"but items appeared in order ending at index 4.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 1, 2, 12, 2, 2];\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(1, 2, 1, 2, 12, 2, 2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {1, 2, 1, 2, 12, 2, 2} to not contain items {1, 2, 1, 2, 12, 2, 2} in consecutive order, \" +\n \"but items appeared in order ending at index 6.\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_absence_of_ordered_containment_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => collection.Should().NotContainInConsecutiveOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment against a collection.*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveIndexer.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveIndexer specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveIndexer\n {\n [Fact]\n public void When_asserting_a_type_has_an_indexer_which_it_does_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveIndexer(typeof(string), [typeof(string)])\n .Which.Should()\n .BeWritable(CSharpAccessModifier.Internal)\n .And.BeReadable(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_indexer_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(\n typeof(string), [typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected string *ClassWithNoMembers[int, System.Type] to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_indexer_with_different_parameters_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(\n typeof(string), [typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected string *.ClassWithMembers[int, System.Type] to exist *failure message*, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_indexer_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(typeof(string), [typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected string type[string] to exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_indexer_for_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(null, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"indexerType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_indexer_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveIndexer(typeof(string), null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n\n public class NotHaveIndexer\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_an_indexer_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act / Assert\n type.Should().NotHaveIndexer([typeof(string)]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_indexer_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveIndexer([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected indexer *.ClassWithMembers[string] to not exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_indexer_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveIndexer([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected indexer type[string] to not exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_indexer_for_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveIndexer(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeBefore.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeBefore\n {\n [Fact]\n public void When_asserting_a_point_of_time_is_before_a_later_point_it_should_succeed()\n {\n // Arrange\n DateTimeOffset earlierDate = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset laterDate = new(new DateTime(2016, 06, 04, 0, 5, 0), TimeSpan.Zero);\n\n // Act / Assert\n earlierDate.Should().BeBefore(laterDate);\n }\n\n [Fact]\n public void When_asserting_subject_is_before_earlier_expected_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset expected = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-03 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_before_the_same_datetimeoffset_it_should_throw()\n {\n // Arrange\n DateTimeOffset expected = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act\n Action act = () => subject.Should().BeBefore(expected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to be before <2016-06-04 +0h>, but it was <2016-06-04 +0h>.\");\n }\n }\n\n public class NotBeBefore\n {\n [Fact]\n public void When_asserting_a_point_of_time_is_not_before_another_it_should_throw()\n {\n // Arrange\n DateTimeOffset earlierDate = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset laterDate = new(new DateTime(2016, 06, 04, 0, 5, 0), TimeSpan.Zero);\n\n // Act\n Action act = () => earlierDate.Should().NotBeBefore(laterDate);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected earlierDate to be on or after <2016-06-04 00:05:00 +0h>, but it was <2016-06-04 +0h>.\");\n }\n\n [Fact]\n public void When_asserting_subject_is_not_before_earlier_expected_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset expected = new(new DateTime(2016, 06, 03), TimeSpan.Zero);\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeBefore(expected);\n }\n\n [Fact]\n public void When_asserting_subject_datetimeoffset_is_not_before_the_same_datetimeoffset_it_should_succeed()\n {\n // Arrange\n DateTimeOffset expected = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n DateTimeOffset subject = new(new DateTime(2016, 06, 04), TimeSpan.Zero);\n\n // Act / Assert\n subject.Should().NotBeBefore(expected);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveExplicitMethod.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveExplicitMethod specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveExplicitMethod\n {\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_method_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitMethod(interfaceType, \"ExplicitMethod\", new Type[0]);\n }\n\n [Fact]\n public void\n When_asserting_a_type_explicitly_implements_a_method_which_it_implements_implicitly_and_explicitly_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitMethod(interfaceType, \"ExplicitImplicitMethod\", new Type[0]);\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_method_which_it_implements_implicitly_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitMethod(interfaceType, \"ImplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to explicitly implement \" +\n \"*.IExplicitInterface.ImplicitMethod(), but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_method_which_it_does_not_implement_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitMethod(interfaceType, \"NonExistentMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to explicitly implement \" +\n \"*.IExplicitInterface.NonExistentMethod(), but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_explicitly_implements_a_method_from_an_unimplemented_interface_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .HaveExplicitMethod(interfaceType, \"NonExistentProperty\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassExplicitlyImplementingInterface to implement interface \" +\n \"*.IDummyInterface, but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_method_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(\n typeof(IExplicitInterface), \"ExplicitMethod\", new Type[0], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to explicitly implement *.IExplicitInterface.ExplicitMethod() *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_method_with_a_null_interface_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(null, \"ExplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_method_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(typeof(IExplicitInterface), \"ExplicitMethod\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_method_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(typeof(IExplicitInterface), null, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_method_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(typeof(IExplicitInterface), string.Empty, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void Does_not_continue_assertion_on_explicit_interface_implementation_if_not_implemented_at_all()\n {\n var act = () =>\n {\n using var _ = new AssertionScope();\n typeof(ClassWithMembers).Should().HaveExplicitMethod(typeof(IExplicitInterface), \"Foo\", new Type[0]);\n };\n\n act.Should().Throw()\n .WithMessage(\"Expected type *ClassWithMembers* to*implement *IExplicitInterface, but it does not.\");\n }\n }\n\n public class HaveExplicitMethodOfT\n {\n [Fact]\n public void When_asserting_a_type_explicitly_implementsOfT_a_method_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act / Assert\n type.Should()\n .HaveExplicitMethod(\"ExplicitMethod\", new Type[0]);\n }\n\n [Fact]\n public void When_subject_is_null_have_explicit_methodOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(\n \"ExplicitMethod\", new Type[0], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to explicitly implement *.IExplicitInterface.ExplicitMethod() *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_methodOfT_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(\"ExplicitMethod\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_methodOfT_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(null, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_explicit_methodOfT_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveExplicitMethod(string.Empty, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n\n public class NotHaveExplicitMethod\n {\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_method_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"ExplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitMethod(), but it does.\");\n }\n\n [Fact]\n public void\n When_asserting_a_type_does_not_explicitly_implement_a_method_which_it_implements_implicitly_and_explicitly_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"ExplicitImplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitImplicitMethod(), but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_method_which_it_implements_implicitly_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"ImplicitMethod\", new Type[0]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_method_which_it_does_not_implement_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IExplicitInterface);\n\n // Act / Assert\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"NonExistentMethod\", new Type[0]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implement_a_method_from_an_unimplemented_interface_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n var interfaceType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitMethod(interfaceType, \"NonExistentMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassExplicitlyImplementingInterface to implement interface *.IDummyInterface\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_method_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(\n typeof(IExplicitInterface), \"ExplicitMethod\", new Type[0], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to not explicitly implement *.IExplicitInterface.ExplicitMethod() *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_method_inherited_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(null, \"ExplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_method_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(typeof(IExplicitInterface), \"ExplicitMethod\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_method_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(typeof(IExplicitInterface), null, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_method_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(typeof(IExplicitInterface), string.Empty, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void Does_not_continue_assertion_on_explicit_interface_implementation_if_implemented()\n {\n var act = () =>\n {\n using var _ = new AssertionScope();\n typeof(ClassExplicitlyImplementingInterface)\n .Should().NotHaveExplicitMethod(typeof(IExplicitInterface), \"ExplicitMethod\", new Type[0]);\n };\n\n act.Should().Throw()\n .WithMessage(\"Expected *ClassExplicitlyImplementingInterface* to not*implement \" +\n \"*IExplicitInterface.ExplicitMethod(), but it does.\");\n }\n }\n\n public class NotHaveExplicitMethodOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_explicitly_implementOfT_a_method_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveExplicitMethod(\"ExplicitMethod\", new Type[0]);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected *.ClassExplicitlyImplementingInterface to not explicitly implement \" +\n \"*.IExplicitInterface.ExplicitMethod(), but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_explicit_methodOfT_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(\n \"ExplicitMethod\", new Type[0], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to not explicitly implement *.IExplicitInterface.ExplicitMethod() *failure message*\" +\n \", but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_methodOfT_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(\"ExplicitMethod\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_methodOfT_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(null, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_explicit_methodOfT_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassExplicitlyImplementingInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveExplicitMethod(string.Empty, new Type[0]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.Be.cs", "using System;\nusing AssemblyA;\nusing AssemblyB;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]Be specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class Be\n {\n [Fact]\n public void When_type_is_equal_to_the_same_type_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n Type sameType = typeof(ClassWithAttribute);\n\n // Act / Assert\n type.Should().Be(sameType);\n }\n\n [Fact]\n public void When_type_is_equal_to_another_type_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n Type differentType = typeof(ClassWithoutAttribute);\n\n // Act\n Action act = () =>\n type.Should().Be(differentType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be *.ClassWithoutAttribute *failure message*, but found *.ClassWithAttribute.\");\n }\n\n [Fact]\n public void When_asserting_equality_of_two_null_types_it_succeeds()\n {\n // Arrange\n Type nullType = null;\n Type someType = null;\n\n // Act / Assert\n nullType.Should().Be(someType);\n }\n\n [Fact]\n public void When_asserting_equality_of_a_type_but_the_type_is_null_it_fails()\n {\n // Arrange\n Type nullType = null;\n Type someType = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n nullType.Should().Be(someType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be *.ClassWithAttribute *failure message*, but found .\");\n }\n\n [Fact]\n public void When_asserting_equality_of_a_type_with_null_it_fails()\n {\n // Arrange\n Type someType = typeof(ClassWithAttribute);\n Type nullType = null;\n\n // Act\n Action act = () =>\n someType.Should().Be(nullType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be *failure message*, but found *.ClassWithAttribute.\");\n }\n\n [Fact]\n public void When_type_is_equal_to_same_type_from_different_assembly_it_fails_with_assembly_qualified_name()\n {\n // Arrange\n#pragma warning disable 436 // disable the warning on conflicting types, as this is the intention for the spec\n\n Type typeFromThisAssembly = typeof(ClassC);\n\n Type typeFromOtherAssembly =\n new ClassA().ReturnClassC().GetType();\n\n#pragma warning restore 436\n\n // Act\n Action act = () =>\n typeFromThisAssembly.Should().Be(typeFromOtherAssembly, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type to be [AssemblyB.ClassC, AssemblyB*] *failure message*, but found [AssemblyB.ClassC, AwesomeAssertions.Specs*].\");\n }\n\n [Fact]\n public void When_type_is_equal_to_the_same_type_using_generics_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n\n // Act / Assert\n type.Should().Be();\n }\n\n [Fact]\n public void When_type_is_equal_to_another_type_using_generics_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n type.Should().Be(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be *.ClassWithoutAttribute *failure message*, but found *.ClassWithAttribute.\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void When_type_is_not_equal_to_the_another_type_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n Type otherType = typeof(ClassWithoutAttribute);\n\n // Act / Assert\n type.Should().NotBe(otherType);\n }\n\n [Fact]\n public void When_type_is_not_equal_to_the_same_type_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n Type sameType = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n type.Should().NotBe(sameType, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be [*.ClassWithAttribute*] *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_type_is_not_equal_to_the_same_null_type_it_fails()\n {\n // Arrange\n Type type = null;\n Type sameType = null;\n\n // Act\n Action act = () =>\n type.Should().NotBe(sameType);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_type_is_not_equal_to_another_type_using_generics_it_succeeds()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n\n // Act / Assert\n type.Should().NotBe();\n }\n\n [Fact]\n public void When_type_is_not_equal_to_the_same_type_using_generics_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithAttribute);\n\n // Act\n Action act = () =>\n type.Should().NotBe(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be [*.ClassWithAttribute*] *failure message*, but it is.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.HaveSameCount.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]HaveSameCount specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class HaveSameCount\n {\n [Fact]\n public void When_both_collections_have_the_same_number_elements_it_should_succeed()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 5, 6];\n\n // Act / Assert\n firstCollection.Should().HaveSameCount(secondCollection);\n }\n\n [Fact]\n public void When_both_collections_do_not_have_the_same_number_of_elements_it_should_fail()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 6];\n\n // Act\n Action act = () => firstCollection.Should().HaveSameCount(secondCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to have 2 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_comparing_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 6];\n\n // Act\n Action act = () => firstCollection.Should().HaveSameCount(secondCollection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to have 2 item(s) because we want to test the reason, but found 3.\");\n }\n\n [Fact]\n public void When_asserting_collections_to_have_same_count_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().HaveSameCount(collection1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have the same count as {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collections_to_have_same_count_against_an_other_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = null;\n\n // Act\n Action act = () => collection.Should().HaveSameCount(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n }\n\n public class NotHaveSameCount\n {\n [Fact]\n public void When_asserting_not_same_count_and_collections_have_different_number_elements_it_should_succeed()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 6];\n\n // Act / Assert\n firstCollection.Should().NotHaveSameCount(secondCollection);\n }\n\n [Fact]\n public void When_asserting_not_same_count_and_both_collections_have_the_same_number_elements_it_should_fail()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 5, 6];\n\n // Act\n Action act = () => firstCollection.Should().NotHaveSameCount(secondCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to not have 3 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_comparing_not_same_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n int[] firstCollection = [1, 2, 3];\n int[] secondCollection = [4, 5, 6];\n\n // Act\n Action act = () => firstCollection.Should().NotHaveSameCount(secondCollection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to not have 3 item(s) because we want to test the reason, but found 3.\");\n }\n\n [Fact]\n public void When_asserting_collections_to_not_have_same_count_against_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = null;\n int[] collection1 = [1, 2, 3];\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotHaveSameCount(collection1, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to not have the same count as {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collections_to_not_have_same_count_against_an_other_null_collection_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n int[] otherCollection = null;\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n\n [Fact]\n public void\n When_asserting_collections_to_not_have_same_count_but_both_collections_references_the_same_object_it_should_throw()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n var collection1 = collection;\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(collection1,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not have the same count*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.ContainMatch.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class ContainMatch\n {\n [Fact]\n public void When_collection_contains_a_match_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act / Assert\n collection.Should().ContainMatch(\"* failed\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_matches_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\", \"pack failed\"];\n\n // Act / Assert\n collection.Should().ContainMatch(\"* failed\");\n }\n\n [Fact]\n public void Can_chain_another_assertion_if_a_single_string_matches_the_pattern()\n {\n // Arrange\n IEnumerable collection = [\"build succeeded\", \"test succeeded\", \"pack failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(\"*failed*\").Which.Should().StartWith(\"test\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection[2] to start with*test*pack failed*\");\n }\n\n [Fact]\n public void Cannot_chain_another_assertion_if_multiple_strings_match_the_pattern()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\", \"pack failed\"];\n\n // Act\n Action action = () => _ = collection.Should().ContainMatch(\"* failed\").Which;\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"More than one object found. AwesomeAssertions cannot determine which object is meant.*\")\n .WithMessage(\"*Found objects:*\\\"test failed\\\"*\\\"pack failed\\\"\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_a_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(\"* stopped\", \"because {0}\", \"we do\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected collection {\\\"build succeded\\\", \\\"test failed\\\"} to contain a match of \\\"* stopped\\\" because we do.\");\n }\n\n [Fact]\n public void When_collection_contains_a_match_that_differs_in_casing_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(\"* Failed\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection {\\\"build succeded\\\", \\\"test failed\\\"} to contain a match of \\\"* Failed\\\".\");\n }\n\n [Fact]\n public void When_asserting_empty_collection_for_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [];\n\n // Act\n Action action = () => collection.Should().ContainMatch(\"* failed\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection {empty} to contain a match of \\\"* failed\\\".\");\n }\n\n [Fact]\n public void When_asserting_null_collection_for_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().ContainMatch(\"* failed\", \"because {0}\", \"we do\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to contain a match of \\\"* failed\\\" because we do, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_to_have_null_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Cannot match strings in collection against . Provide a wildcard pattern or use the Contain method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_asserting_collection_to_have_empty_string_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().ContainMatch(string.Empty);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Cannot match strings in collection against an empty string. Provide a wildcard pattern or use the Contain method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n }\n\n public class NotContainMatch\n {\n [Fact]\n public void When_collection_doesnt_contain_a_match_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test\"];\n\n // Act / Assert\n collection.Should().NotContainMatch(\"* failed\");\n }\n\n [Fact]\n public void When_collection_doesnt_contain_multiple_matches_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test\", \"pack\"];\n\n // Act / Assert\n collection.Should().NotContainMatch(\"* failed\");\n }\n\n [Fact]\n public void When_collection_contains_a_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(\"* failed\", \"because {0}\", \"it shouldn't\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Did not expect collection {\\\"build succeded\\\", \\\"test failed\\\"} to contain a match of \\\"* failed\\\" because it shouldn't.\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_matches_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build failed\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(\"* failed\", \"because {0}\", \"it shouldn't\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Did not expect collection {\\\"build failed\\\", \\\"test failed\\\"} to contain a match of \\\"* failed\\\" because it shouldn't.\");\n }\n\n [Fact]\n public void When_collection_contains_a_match_with_different_casing_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(\"* Failed\");\n\n // Assert\n action.Should().NotThrow();\n }\n\n [Fact]\n public void When_asserting_collection_to_not_have_null_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(null);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Cannot match strings in collection against . Provide a wildcard pattern or use the NotContain method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_asserting_collection_to_not_have_empty_string_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"build succeded\", \"test failed\"];\n\n // Act\n Action action = () => collection.Should().NotContainMatch(string.Empty);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Cannot match strings in collection against an empty string. Provide a wildcard pattern or use the NotContain method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_asserting_null_collection_to_not_have_null_match_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action action = () =>\n {\n using var _ = new AssertionScope();\n collection.Should().NotContainMatch(\"* Failed\", \"we want to test the failure {0}\", \"message\");\n };\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Did not expect collection to contain a match of \\\"* failed\\\" *failure message*, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/DelegateAssertionSpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class DelegateAssertionSpecs\n{\n [Fact]\n public void Null_clock_throws_exception()\n {\n // Arrange\n Func subject = () => 1;\n\n // Act\n var act = void () => subject.Should(clock: null).NotThrow();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"clock\");\n }\n\n public class Throw\n {\n [Fact]\n public void Allow_additional_assertions_on_return_value()\n {\n // Arrange\n var exception = new Exception(\"foo\");\n Action subject = () => throw exception;\n\n // Act / Assert\n subject.Should().Throw()\n .Which.Message.Should().Be(\"foo\");\n }\n }\n\n public class ThrowExactly\n {\n [Fact]\n public void Does_not_continue_assertion_on_exact_exception_type()\n {\n // Arrange\n var a = () => { };\n\n // Act\n using var scope = new AssertionScope();\n a.Should().ThrowExactly();\n\n // Assert\n scope.Discard().Should().ContainSingle()\n .Which.Should().Match(\"*InvalidOperationException*no exception*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.Equal.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class Equal\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_is_equal_to_the_same_dictionary()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary1.Should().Equal(dictionary2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_with_null_value_is_equal_to_the_same_dictionary()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = null\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = null\n };\n\n // Act / Assert\n dictionary1.Should().Equal(dictionary2);\n }\n\n [Fact]\n public void When_asserting_dictionaries_to_be_equal_but_subject_dictionary_misses_a_value_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [22] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().Equal(dictionary2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [22] = \\\"Two\\\"} because we want to test the failure message, but could not find keys {22}.\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_to_be_equal_but_subject_dictionary_has_extra_key_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().Equal(dictionary2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [2] = \\\"Two\\\"} because we want to test the failure message, but found additional keys {3}.\");\n }\n\n [Fact]\n public void When_two_dictionaries_are_not_equal_by_values_it_should_throw_using_the_reason()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary1.Should().Equal(dictionary2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [2] = \\\"Three\\\"} because we want to test the failure message, but {[1] = \\\"One\\\", [2] = \\\"Two\\\"} differs at key 2.\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_to_be_equal_but_subject_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary1 = null;\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary1.Should().Equal(dictionary2, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [2] = \\\"Two\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_to_be_equal_but_expected_dictionary_is_null_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n Dictionary dictionary2 = null;\n\n // Act\n Action act = () =>\n dictionary1.Should().Equal(dictionary2, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare dictionary with .*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_an_empty_dictionary_is_compared_for_equality_to_a_non_empty_dictionary_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary();\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().Equal(dictionary2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary1 to be equal to {[1] = \\\"One\\\", [2] = \\\"Two\\\"}, but could not find keys {1, 2}.\");\n }\n }\n\n public class NotEqual\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_is_not_equal_to_a_dictionary_with_different_key()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [22] = \"Two\"\n };\n\n // Act / Assert\n dictionary1.Should().NotEqual(dictionary2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_dictionary_is_not_equal_to_a_dictionary_with_different_value()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = null\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act / Assert\n dictionary1.Should().NotEqual(dictionary2);\n }\n\n [Fact]\n public void When_two_equal_dictionaries_are_not_expected_to_be_equal_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().NotEqual(dictionary2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dictionaries {[1] = \\\"One\\\", [2] = \\\"Two\\\"} and {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to be equal.\");\n }\n\n [Fact]\n public void When_two_equal_dictionaries_are_not_expected_to_be_equal_it_should_report_a_clear_explanation()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary1.Should().NotEqual(dictionary2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect dictionaries {[1] = \\\"One\\\", [2] = \\\"Two\\\"} and {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to be equal because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_not_to_be_equal_subject_but_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary1 = null;\n\n var dictionary2 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary1.Should().NotEqual(dictionary2, \"because we want to test the behaviour with a null subject\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionaries not to be equal because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_dictionaries_not_to_be_equal_but_expected_dictionary_is_null_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n Dictionary dictionary2 = null;\n\n // Act\n Action act =\n () => dictionary1.Should().NotEqual(dictionary2, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare dictionary with .*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void\n When_asserting_dictionaries_not_to_be_equal_subject_but_both_dictionaries_reference_the_same_object_it_should_throw()\n {\n // Arrange\n var dictionary1 = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n var dictionary2 = dictionary1;\n\n // Act\n Action act =\n () => dictionary1.Should().NotEqual(dictionary2, \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionaries not to be equal because we want to test the behaviour with same objects, but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeOneOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The BeOneOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeOneOf\n {\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()\n {\n // Arrange\n string value = \"abc\";\n\n // Act\n Action action = () => value.Should().BeOneOf(\"def\", \"xyz\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected value to be one of {\\\"def\\\", \\\"xyz\\\"}, but found \\\"abc\\\".\");\n }\n\n [Fact]\n public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()\n {\n // Arrange\n string value = \"abc\";\n\n // Act\n Action action = () => value.Should().BeOneOf([\"def\", \"xyz\"], \"because those are the valid values\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected value to be one of {\\\"def\\\", \\\"xyz\\\"} because those are the valid values, but found \\\"abc\\\".\");\n }\n\n [Fact]\n public void When_a_value_is_one_of_the_specified_values_it_should_succeed()\n {\n // Arrange\n string value = \"abc\";\n\n // Act / Assert\n value.Should().BeOneOf(\"abc\", \"def\", \"xyz\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/FluentDateTimeSpecs.cs", "using System;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class FluentDateTimeSpecs\n{\n [Fact]\n public void When_fluently_specifying_a_date_in_january_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.January(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 1, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_february_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.February(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 2, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_march_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.March(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 3, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_april_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.April(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 4, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_may_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.May(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 5, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_june_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.June(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 6, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_july_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.July(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 7, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_august_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.August(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 8, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_september_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.September(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 9, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_october_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.October(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 10, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_november_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.November(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 11, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_in_december_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime date = 10.December(2011);\n\n // Assert\n date.Should().Be(new DateTime(2011, 12, 10));\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_and_time_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTime dateTime = 10.December(2011).At(09, 30, 45, 123, 456, 700);\n\n // Assert\n dateTime.Should().Be(new DateTime(2011, 12, 10, 9, 30, 45, 123).AddMicroseconds(456).AddNanoseconds(700));\n dateTime.Microsecond().Should().Be(456);\n dateTime.Nanosecond().Should().Be(700);\n dateTime.Should().BeIn(DateTimeKind.Unspecified);\n }\n\n [Fact]\n public void When_fluently_specifying_a_datetimeoffset_and_time_it_should_return_the_correct_date_time_value()\n {\n // Act\n DateTimeOffset dateTime = 10.December(2011).ToDateTimeOffset().At(09, 30, 45, 123, 456, 700);\n\n // Assert\n dateTime.Should().Be(new DateTimeOffset(2011, 12, 10, 9, 30, 45, 123, TimeSpan.Zero).AddMicroseconds(456)\n .AddNanoseconds(700));\n\n dateTime.Microsecond().Should().Be(456);\n dateTime.Nanosecond().Should().Be(700);\n }\n\n [InlineData(-1)]\n [InlineData(1000)]\n [Theory]\n public void When_fluently_specifying_a_datetime_with_out_of_range_microseconds_it_should_throw(int microseconds)\n {\n // Act\n string expectedParameterName = \"microseconds\";\n Action act = () => 10.December(2011).At(0, 0, 0, 0, microseconds);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(expectedParameterName);\n }\n\n [InlineData(0)]\n [InlineData(999)]\n [Theory]\n public void When_fluently_specifying_a_datetime_with_inrange_microseconds_it_should_not_throw(int microseconds)\n {\n // Act\n Action act = () => 10.December(2011).At(0, 0, 0, 0, microseconds);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [InlineData(-1)]\n [InlineData(1000)]\n [Theory]\n public void When_fluently_specifying_a_datetime_with_out_of_range_nanoseconds_it_should_throw(int nanoseconds)\n {\n // Act\n var expectedParameterName = \"nanoseconds\";\n Action act = () => 10.December(2011).At(0, 0, 0, 0, 0, nanoseconds);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(expectedParameterName);\n }\n\n [InlineData(0)]\n [InlineData(999)]\n [Theory]\n public void When_fluently_specifying_a_datetime_with_inrange_nanoseconds_it_should_not_throw(int nanoseconds)\n {\n // Act\n Action act = () => 10.December(2011).At(0, 0, 0, 0, 0, nanoseconds);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [InlineData(-1)]\n [InlineData(1000)]\n [Theory]\n public void When_fluently_specifying_a_datetimeoffset_with_out_of_range_microseconds_it_should_throw(int microseconds)\n {\n // Act\n var expectedParameterName = \"microseconds\";\n Action act = () => 10.December(2011).ToDateTimeOffset().At(0, 0, 0, 0, microseconds);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(expectedParameterName);\n }\n\n [InlineData(0)]\n [InlineData(999)]\n [Theory]\n public void When_fluently_specifying_a_datetimeoffset_with_inrange_microseconds_it_should_not_throw(int microseconds)\n {\n // Act\n Action act = () => 10.December(2011).ToDateTimeOffset().At(0, 0, 0, 0, microseconds);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [InlineData(-1)]\n [InlineData(1000)]\n [Theory]\n public void When_fluently_specifying_a_datetimeoffset_with_out_of_range_nanoseconds_it_should_throw(int nanoseconds)\n {\n // Act\n var expectedParameterName = \"nanoseconds\";\n Action act = () => 10.December(2011).ToDateTimeOffset().At(0, 0, 0, 0, 0, nanoseconds);\n\n // Assert\n act.Should().Throw()\n .WithParameterName(expectedParameterName);\n }\n\n [InlineData(0)]\n [InlineData(999)]\n [Theory]\n public void When_fluently_specifying_a_datetimeoffset_with_inrange_nanoseconds_it_should_not_throw(int nanoseconds)\n {\n // Act\n Action act = () => 10.December(2011).ToDateTimeOffset().At(0, 0, 0, 0, 0, nanoseconds);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_and_time_as_utc_it_should_return_the_date_time_value_with_utc_kind()\n {\n // Act\n DateTime dateTime = 10.December(2011).At(09, 30, 45, 123, 456, 700).AsUtc();\n\n // Assert\n dateTime.Should().Be(new DateTime(2011, 12, 10, 9, 30, 45, 123).AddMicroseconds(456).AddNanoseconds(700));\n dateTime.Microsecond().Should().Be(456);\n dateTime.Nanosecond().Should().Be(700);\n dateTime.Should().BeIn(DateTimeKind.Utc);\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_and_time_as_local_it_should_return_the_date_time_value_with_local_kind()\n {\n // Act\n DateTime dateTime = 10.December(2011).At(09, 30, 45, 123, 456, 700).AsLocal();\n\n // Assert\n dateTime.Should().Be(new DateTime(2011, 12, 10, 9, 30, 45, 123).AddMicroseconds(456).AddNanoseconds(700));\n dateTime.Microsecond().Should().Be(456);\n dateTime.Nanosecond().Should().Be(700);\n dateTime.Should().BeIn(DateTimeKind.Local);\n }\n\n [Fact]\n public void When_fluently_specifying_a_date_and_timespan_it_should_return_the_correct_date_time_value()\n {\n // Act\n var time = 9.Hours().And(30.Minutes()).And(45.Seconds());\n DateTime dateTime = 10.December(2011).At(time);\n\n // Assert\n dateTime.Should().Be(new DateTime(2011, 12, 10, 9, 30, 45));\n }\n\n [Fact]\n public void Specyfing_the_time_of_day_retains_the_full_precision()\n {\n // Act\n DateTime subject = 10.December(2011).At(1.Ticks());\n DateTime expected = 10.December(2011) + 1.Ticks();\n\n // Assert\n subject.Should().Be(expected);\n }\n\n [Fact]\n public void Specifying_the_time_of_day_retains_the_datetime_kind()\n {\n // Act\n DateTime dateTime = 10.December(2011).AsUtc().At(TimeSpan.Zero);\n\n // Assert\n dateTime.Should().BeIn(DateTimeKind.Utc);\n }\n\n [Fact]\n public void Specifying_the_time_of_day_in_hours_and_minutes_retains_the_datetime_kind()\n {\n // Act\n DateTime dateTime = 10.December(2011).AsUtc().At(0, 0);\n\n // Assert\n dateTime.Should().BeIn(DateTimeKind.Utc);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedXunitTheoryTestCase.cs", "using System;\nusing System.ComponentModel;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Xunit.Abstractions;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\npublic class CulturedXunitTheoryTestCase : XunitTheoryTestCase\n{\n [EditorBrowsable(EditorBrowsableState.Never)]\n [Obsolete(\"Called by the de-serializer; should only be called by deriving classes for de-serialization purposes\")]\n public CulturedXunitTheoryTestCase() { }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The message sink used to send diagnostic messages\n /// Default method display to use (when not customized).\n /// Default method display options to use (when not customized).\n /// The method under test.\n public CulturedXunitTheoryTestCase(IMessageSink diagnosticMessageSink,\n TestMethodDisplay defaultMethodDisplay,\n TestMethodDisplayOptions defaultMethodDisplayOptions,\n ITestMethod testMethod,\n string culture)\n : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod)\n {\n Initialize(culture);\n }\n\n public string Culture { get; private set; }\n\n public override void Deserialize(IXunitSerializationInfo data)\n {\n base.Deserialize(data);\n\n Initialize(data.GetValue(\"Culture\"));\n }\n\n protected override string GetUniqueID() => $\"{base.GetUniqueID()}[{Culture}]\";\n\n private void Initialize(string culture)\n {\n Culture = culture;\n\n Traits.Add(\"Culture\", culture);\n\n DisplayName += $\"[{culture}]\";\n }\n\n public override Task RunAsync(IMessageSink diagnosticMessageSink,\n IMessageBus messageBus,\n object[] constructorArguments,\n ExceptionAggregator aggregator,\n CancellationTokenSource cancellationTokenSource) =>\n new CulturedXunitTheoryTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, diagnosticMessageSink,\n messageBus, aggregator, cancellationTokenSource).RunAsync();\n\n public override void Serialize(IXunitSerializationInfo data)\n {\n base.Serialize(data);\n\n data.AddValue(\"Culture\", Culture);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.Equal.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class Equal\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_equal_to_the_same_collection()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection1.Should().Equal(collection2);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_is_equal_to_the_same_list_of_elements()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().Equal(\"one\", \"two\", \"three\");\n }\n\n [Fact]\n public void When_all_items_match_according_to_a_predicate_it_should_succeed()\n {\n // Arrange\n var actual = new List { \"ONE\", \"TWO\", \"THREE\", \"FOUR\" };\n var expected = new List { \"One\", \"Two\", \"Three\", \"Four\" };\n\n // Act / Assert\n actual.Should().Equal(expected,\n (a, e) => string.Equals(a, e, StringComparison.OrdinalIgnoreCase));\n }\n\n [Fact]\n public void When_an_empty_collection_is_compared_for_equality_to_a_non_empty_collection_it_should_throw()\n {\n // Arrange\n var collection1 = new string[0];\n IEnumerable collection2 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {\\\"one\\\", \\\"two\\\", \\\"three\\\"}, but found empty collection.\");\n }\n\n [Fact]\n public void When_any_item_does_not_match_according_to_a_predicate_it_should_throw()\n {\n // Arrange\n var actual = new List { \"ONE\", \"TWO\", \"THREE\", \"FOUR\" };\n var expected = new List { \"One\", \"Two\", \"Three\", \"Five\" };\n\n // Act\n Action action = () => actual.Should().Equal(expected,\n (a, e) => string.Equals(a, e, StringComparison.OrdinalIgnoreCase));\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Expected*equal to*, but*differs at index 3.\");\n }\n\n [Fact]\n public void When_injecting_a_null_comparer_it_should_throw()\n {\n // Arrange\n var actual = new List();\n var expected = new List();\n\n // Act\n Action action = () => actual.Should().Equal(expected, equalityComparison: null);\n\n // Assert\n action\n .Should().ThrowExactly()\n .WithParameterName(\"equalityComparison\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equal_but_expected_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable collection1 = null;\n\n // Act\n Action act = () =>\n collection.Should().Equal(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare collection with .*\")\n .WithParameterName(\"expectation\");\n }\n\n [Fact]\n public void When_asserting_collections_to_be_equal_but_subject_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () =>\n collection.Should().Equal(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be equal to {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_both_collections_are_null_it_should_succeed()\n {\n // Arrange\n IEnumerable nullColl = null;\n\n // Act / Assert\n nullColl.Should().Equal(null);\n }\n\n [Fact]\n public void When_two_collections_are_not_equal_because_one_item_differs_it_should_throw_using_the_reason()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"five\"];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {\\\"one\\\", \\\"two\\\", \\\"five\\\"} because we want to test the failure message, but {\\\"one\\\", \\\"two\\\", \\\"three\\\"} differs at index 2.\");\n }\n\n [Fact]\n public void\n When_two_collections_are_not_equal_because_the_actual_collection_contains_less_items_it_should_throw_using_the_reason()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\", \"four\"];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {\\\"one\\\", \\\"two\\\", \\\"three\\\", \\\"four\\\"} because we want to test the failure message, but {\\\"one\\\", \\\"two\\\", \\\"three\\\"} contains 1 item(s) less.\");\n }\n\n [Fact]\n public void\n When_two_collections_are_not_equal_because_the_actual_collection_contains_more_items_it_should_throw_using_the_reason()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\"];\n\n // Act\n Action act = () => collection1.Should().Equal(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection1 to be equal to {\\\"one\\\", \\\"two\\\"} because we want to test the failure message, but {\\\"one\\\", \\\"two\\\", \\\"three\\\"} contains 1 item(s) too many.\");\n }\n\n [Fact]\n public void When_two_collections_containing_nulls_are_equal_it_should_not_throw()\n {\n // Arrange\n var subject = new List { \"aaa\", null };\n var expected = new List { \"aaa\", null };\n\n // Act / Assert\n subject.Should().Equal(expected);\n }\n }\n\n public class NotEqual\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_is_not_equal_to_a_different_collection()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"three\", \"one\", \"two\"];\n\n // Act / Assert\n collection1.Should()\n .NotEqual(collection2);\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_but_both_collections_reference_the_same_object_it_should_throw()\n {\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = collection1;\n\n // Act\n Action act = () =>\n collection1.Should().NotEqual(collection2, \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collections not to be equal because we want to test the behaviour with same objects, but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_but_expected_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable collection1 = null;\n\n // Act\n Action act =\n () => collection.Should().NotEqual(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot compare collection with .*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void When_asserting_collections_not_to_be_equal_subject_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act =\n () => collection.Should().NotEqual(collection1, \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collections not to be equal because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_two_equal_collections_are_not_expected_to_be_equal_it_should_report_a_clear_explanation()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection1.Should().NotEqual(collection2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect collections {\\\"one\\\", \\\"two\\\", \\\"three\\\"} and {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to be equal because we want to test the failure message.\");\n }\n\n [Fact]\n public void When_two_equal_collections_are_not_expected_to_be_equal_it_should_throw()\n {\n // Arrange\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n IEnumerable collection2 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection1.Should().NotEqual(collection2);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect collections {\\\"one\\\", \\\"two\\\", \\\"three\\\"} and {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to be equal.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/GuidAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic class GuidAssertionSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_empty_guid_is_empty()\n {\n // Arrange\n Guid guid = Guid.Empty;\n\n // Act / Assert\n guid.Should().BeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_non_empty_guid_is_empty()\n {\n // Arrange\n var guid = new Guid(\"12345678-1234-1234-1234-123456789012\");\n\n // Act\n Action act = () => guid.Should().BeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Guid to be empty because we want to test the failure message, but found {12345678-1234-1234-1234-123456789012}.\");\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_non_empty_guid_is_not_empty()\n {\n // Arrange\n var guid = new Guid(\"12345678-1234-1234-1234-123456789012\");\n\n // Act / Assert\n guid.Should().NotBeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_empty_guid_is_not_empty()\n {\n // Act\n Action act = () => Guid.Empty.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect Guid.Empty to be empty because we want to test the failure message.\");\n }\n }\n\n public class Be\n {\n [Fact]\n public void Should_succeed_when_asserting_guid_equals_the_same_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n var sameGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act / Assert\n guid.Should().Be(sameGuid);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_guid_equals_the_same_guid_in_string_format()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act / Assert\n guid.Should().Be(\"11111111-aaaa-bbbb-cccc-999999999999\");\n }\n\n [Fact]\n public void Should_fail_when_asserting_guid_equals_a_different_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n var differentGuid = new Guid(\"55555555-ffff-eeee-dddd-444444444444\");\n\n // Act\n Action act = () => guid.Should().Be(differentGuid, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected Guid to be {55555555-ffff-eeee-dddd-444444444444} because we want to test the failure message, but found {11111111-aaaa-bbbb-cccc-999999999999}.\");\n }\n\n [Fact]\n public void Should_throw_when_asserting_guid_equals_a_string_that_is_not_a_valid_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => guid.Should().Be(string.Empty, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"expected\");\n }\n }\n\n public class NotBe\n {\n [Fact]\n public void Should_succeed_when_asserting_guid_does_not_equal_a_different_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n var differentGuid = new Guid(\"55555555-ffff-eeee-dddd-444444444444\");\n\n // Act / Assert\n guid.Should().NotBe(differentGuid);\n }\n\n [Fact]\n public void Should_succeed_when_asserting_guid_does_not_equal_the_same_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n var sameGuid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => guid.Should().NotBe(sameGuid, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect Guid to be {11111111-aaaa-bbbb-cccc-999999999999} because we want to test the failure message.\");\n }\n\n [Fact]\n public void Should_throw_when_asserting_guid_does_not_equal_a_string_that_is_not_a_valid_guid()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () => guid.Should().NotBe(string.Empty, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_guid_does_not_equal_a_different_guid_in_string_format()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act / Assert\n guid.Should().NotBe(\"55555555-ffff-eeee-dddd-444444444444\");\n }\n\n [Fact]\n public void Should_succeed_when_asserting_guid_does_not_equal_the_same_guid_in_string_format()\n {\n // Arrange\n var guid = new Guid(\"11111111-aaaa-bbbb-cccc-999999999999\");\n\n // Act\n Action act = () =>\n guid.Should().NotBe(\"11111111-aaaa-bbbb-cccc-999999999999\", \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect Guid to be {11111111-aaaa-bbbb-cccc-999999999999} *failure message*.\");\n }\n }\n\n public class ChainingConstraint\n {\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n Guid guid = Guid.NewGuid();\n\n // Act / Assert\n guid.Should()\n .NotBeEmpty()\n .And.Be(guid);\n }\n }\n\n public class Miscellaneous\n {\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n Guid subject = Guid.Empty;\n\n // Act\n Action action = () => subject.Should().Equals(subject);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() or BeOneOf() instead?\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/IAssertionStrategy.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Defines a strategy for handling failures in a .\n/// \npublic interface IAssertionStrategy\n{\n /// \n /// Returns the messages for the assertion failures that happened until now.\n /// \n IEnumerable FailureMessages { get; }\n\n /// \n /// Instructs the strategy to handle a assertion failure.\n /// \n void HandleFailure(string message);\n\n /// \n /// Discards and returns the failure messages that happened up to now.\n /// \n IEnumerable DiscardFailures();\n\n /// \n /// Will throw a combined exception for any failures have been collected.\n /// \n void ThrowIfAny(IDictionary context);\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.BeEmpty.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void Should_fail_when_asserting_collection_with_items_is_empty()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().BeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_collection_without_items_is_empty()\n {\n // Arrange\n IEnumerable collection = new string[0];\n\n // Act / Assert\n collection.Should().BeEmpty();\n }\n\n [Fact]\n public void When_asserting_collection_to_be_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().BeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_the_collection_is_not_empty_unexpectedly_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().BeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\n \"Expected collection to be empty because we want to test the failure message, but found at least one item*one*\");\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void When_asserting_collection_to_be_not_empty_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().NotBeEmpty(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to be empty because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_collection_with_items_is_not_empty_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotBeEmpty();\n }\n\n [Fact]\n public void When_asserting_collection_without_items_is_not_empty_it_should_fail()\n {\n // Arrange\n IEnumerable collection = new string[0];\n\n // Act\n Action act = () => collection.Should().NotBeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_asserting_collection_without_items_is_not_empty_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n IEnumerable collection = new string[0];\n\n // Act\n Action act = () => collection.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected collection not to be empty because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/Issue1657.cs", "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Collections;\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Jobs;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\n[SimpleJob(RuntimeMoniker.Net472)]\n[SimpleJob(RuntimeMoniker.Net80)]\npublic class Issue1657\n{\n private List list;\n private List list2;\n\n [Params(1, 10, 50)]\n public int N { get; set; }\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n list = Enumerable.Range(0, N).Select(i => GetObject(i)).ToList();\n list2 = Enumerable.Range(0, N).Select(i => GetObject(N - 1 - i)).ToList();\n }\n\n [Benchmark]\n public AndConstraint> BeEquivalentTo() =>\n list.Should().BeEquivalentTo(list2);\n\n private static ExampleObject GetObject(int i)\n {\n string iToString = i.ToString(\"D2\", CultureInfo.InvariantCulture);\n return new ExampleObject\n {\n Id = iToString,\n Value1 = iToString,\n Value2 = iToString,\n Value3 = iToString,\n Value4 = iToString,\n Value5 = iToString,\n Value6 = iToString,\n Value7 = iToString,\n Value8 = iToString,\n Value9 = iToString,\n Value10 = iToString,\n Value11 = iToString,\n Value12 = iToString,\n };\n }\n}\n\npublic class ExampleObject\n{\n public string Id { get; set; }\n\n public string Value1 { get; set; }\n\n public string Value2 { get; set; }\n\n public string Value3 { get; set; }\n\n public string Value4 { get; set; }\n\n public string Value5 { get; set; }\n\n public string Value6 { get; set; }\n\n public string Value7 { get; set; }\n\n public string Value8 { get; set; }\n\n public string Value9 { get; set; }\n\n public string Value10 { get; set; }\n\n public string Value11 { get; set; }\n\n public string Value12 { get; set; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.ContainValues.cs", "using System;\nusing System.Collections.Generic;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class ContainValues\n {\n [Fact]\n public void When_dictionary_contains_multiple_values_from_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValues(\"Two\", \"One\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_dictionary_does_not_contain_a_number_of_values_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValues([\"Two\", \"Three\"], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to contain values {\\\"Two\\\", \\\"Three\\\"} because we do, but could not find \\\"Three\\\".\");\n }\n\n [Fact]\n public void\n When_the_contents_of_a_dictionary_are_checked_against_an_empty_list_of_values_it_should_throw_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValues();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify value containment against an empty sequence*\");\n }\n }\n\n [Fact]\n public void Can_run_another_assertion_on_the_result()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().ContainValues(\"Two\", \"One\").Which.Should().Contain(\"Three\");\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected dictionary[1 and 2]*to contain*Three*\");\n }\n\n public class NotContainValues\n {\n [Fact]\n public void When_dictionary_does_not_contain_multiple_values_that_is_not_in_the_dictionary_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValues(\"Three\", \"Four\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_a_dictionary_contains_a_exactly_one_of_the_values_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValues([\"Two\"], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to not contain value \\\"Two\\\" because we do.\");\n }\n\n [Fact]\n public void When_a_dictionary_contains_a_number_of_values_it_should_throw_with_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValues([\"Two\", \"Three\"], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary {[1] = \\\"One\\\", [2] = \\\"Two\\\"} to not contain value {\\\"Two\\\", \\\"Three\\\"} because we do, but found {\\\"Two\\\"}.\");\n }\n\n [Fact]\n public void\n When_the_noncontents_of_a_dictionary_are_checked_against_an_empty_list_of_values_it_should_throw_clear_explanation()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotContainValues();\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify value containment with an empty sequence*\");\n }\n\n [Fact]\n public void Null_dictionaries_do_not_contain_any_values()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n {\n using var _ = new AssertionScope();\n dictionary.Should().NotContainValues([\"Two\", \"Three\"], \"because {0}\", \"we do\");\n };\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not contain values {\\\"Two\\\", \\\"Three\\\"} because we do, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeSameDateAs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeSameDateAs\n {\n [Fact]\n public void When_asserting_subject_datetime_should_be_same_date_as_another_with_the_same_date_it_should_succeed()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31, 4, 5, 6);\n\n // Act / Assert\n subject.Should().BeSameDateAs(new DateTime(2009, 12, 31));\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_should_be_same_as_another_with_same_date_but_different_time_it_should_succeed()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31, 4, 5, 6);\n\n // Act / Assert\n subject.Should().BeSameDateAs(new DateTime(2009, 12, 31, 11, 15, 11));\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_to_be_same_date_as_another_datetime_it_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n\n // Act\n Action act = () => subject.Should().BeSameDateAs(new DateTime(2009, 12, 31));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected the date part of subject to be <2009-12-31>, but found a DateTime.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_have_same_date_as_another_but_it_doesnt_it_should_throw()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31);\n\n // Act\n Action act = () => subject.Should().BeSameDateAs(new DateTime(2009, 12, 30));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected the date part of subject to be <2009-12-30>, but found <2009-12-31>.\");\n }\n }\n\n public class NotBeSameDateAs\n {\n [Fact]\n public void When_asserting_subject_datetime_should_not_be_same_date_as_another_with_the_same_date_it_should_throw()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31, 4, 5, 6);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(new DateTime(2009, 12, 31));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void\n When_asserting_subject_datetime_should_not_be_same_as_another_with_same_date_but_different_time_it_should_throw()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31, 4, 5, 6);\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(new DateTime(2009, 12, 31, 11, 15, 11));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect the date part of subject to be <2009-12-31>, but it was.\");\n }\n\n [Fact]\n public void When_asserting_subject_null_datetime_to_not_be_same_date_as_another_datetime_it_should_throw()\n {\n // Arrange\n DateTime? subject = null;\n\n // Act\n Action act = () => subject.Should().NotBeSameDateAs(new DateTime(2009, 12, 31));\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect the date part of subject to be <2009-12-31>, but found a DateTime.\");\n }\n\n [Fact]\n public void When_asserting_subject_datetime_should_not_have_same_date_as_another_but_it_doesnt_it_should_succeed()\n {\n // Arrange\n var subject = new DateTime(2009, 12, 31);\n\n // Act / Assert\n subject.Should().NotBeSameDateAs(new DateTime(2009, 12, 30));\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/UWP.Specs/App.xaml.cs", "using Microsoft.VisualStudio.TestPlatform.TestExecutor;\nusing Windows.ApplicationModel;\nusing Windows.ApplicationModel.Activation;\nusing Windows.UI.Xaml;\n\nnamespace UWP.Specs;\n\ninternal sealed partial class App : Application\n{\n public App()\n {\n InitializeComponent();\n Suspending += OnSuspending;\n }\n\n protected override void OnLaunched(LaunchActivatedEventArgs args)\n {\n UnitTestClient.Run(args.Arguments);\n }\n\n private void OnSuspending(object sender, SuspendingEventArgs e) =>\n e.SuspendingOperation.GetDeferral().Complete();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/StopwatchTimer.cs", "using System;\nusing System.Diagnostics;\n\nnamespace AwesomeAssertions.Common;\n\ninternal sealed class StopwatchTimer : ITimer\n{\n private readonly Stopwatch stopwatch = Stopwatch.StartNew();\n\n public TimeSpan Elapsed => stopwatch.Elapsed;\n\n public void Dispose()\n {\n if (stopwatch.IsRunning)\n {\n // We want to keep the elapsed time available after the timer is disposed, so disposing\n // just stops it.\n stopwatch.Stop();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveMethod.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveMethod specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveMethod\n {\n [Fact]\n public void When_asserting_a_type_has_a_method_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveMethod(\"VoidMethod\", [])\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.Private)\n .And.ReturnVoid();\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(\n \"NonExistentMethod\", [typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method *ClassWithNoMembers.NonExistentMethod(int, System.Type) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_with_different_parameter_types_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(\n \"VoidMethod\", [typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected method *.ClassWithMembers.VoidMethod(int, System.Type) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_method_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(\"Name\", [typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method type.Name(string) to exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(null, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(string.Empty, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_method_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveMethod(\"Name\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n\n public class NotHaveMethod\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithoutMembers);\n\n // Act / Assert\n type.Should().NotHaveMethod(\"NonExistentMethod\", []);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_which_it_has_with_different_parameter_types_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should().NotHaveMethod(\"VoidMethod\", [typeof(int)]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_that_method_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(\"VoidMethod\", [], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method Void *.ClassWithMembers.VoidMethod() to not exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_method_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(\"Name\", [typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected method type.Name(string) to not exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_with_a_null_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(null, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_with_an_empty_name_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(string.Empty, [typeof(string)]);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"name\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_method_with_a_null_parameter_type_list_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveMethod(\"Name\", null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/FindAssembly.cs", "using System;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Specs;\n\npublic static class FindAssembly\n{\n public static Assembly Containing() => typeof(T).Assembly;\n\n public static Assembly Stub(string publicKey) => new AssemblyStub(publicKey);\n\n private sealed class AssemblyStub : Assembly\n {\n private readonly AssemblyName assemblyName = new();\n\n public override string FullName => nameof(AssemblyStub);\n\n public AssemblyStub(string publicKey)\n {\n assemblyName.SetPublicKey(FromHexString(publicKey));\n }\n\n public override AssemblyName GetName() => assemblyName;\n\n#if NET6_0_OR_GREATER\n private static byte[] FromHexString(string chars)\n => chars is null\n ? null\n : Convert.FromHexString(chars);\n#else\n private static byte[] FromHexString(string chars)\n {\n if (chars is null)\n {\n return null;\n }\n\n var bytes = new byte[chars.Length / 2];\n\n for (var i = 0; i < bytes.Length; i++)\n {\n var bits = chars.Substring(i * 2, 2);\n bytes[i] = Convert.ToByte(bits, 16);\n }\n\n return bytes;\n }\n#endif\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/ThrowAssertionsSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class ThrowAssertionsSpecs\n{\n [Fact]\n public void When_subject_throws_expected_exception_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw();\n\n // Act / Assert\n testSubject.Invoking(x => x.Do()).Should().Throw();\n }\n\n [Fact]\n public void When_func_throws_expected_exception_it_should_not_do_anything()\n {\n // Arrange\n Does testSubject = Does.Throw();\n\n // Act / Assert\n testSubject.Invoking(x => x.Return()).Should().Throw();\n }\n\n [Fact]\n public void When_action_throws_expected_exception_it_should_not_do_anything()\n {\n // Arrange\n var act = new Action(() => throw new InvalidOperationException(\"Some exception\"));\n\n // Act / Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_subject_does_not_throw_exception_but_one_was_expected_it_should_throw_with_clear_description()\n {\n try\n {\n Does testSubject = Does.NotThrow();\n\n testSubject.Invoking(x => x.Do()).Should().Throw();\n\n throw new XunitException(\"Should().Throw() did not throw\");\n }\n catch (XunitException ex)\n {\n ex.Message.Should().Be(\n \"Expected a to be thrown, but no exception was thrown.\");\n }\n }\n\n [Fact]\n public void When_func_does_not_throw_exception_but_one_was_expected_it_should_throw_with_clear_description()\n {\n try\n {\n Does testSubject = Does.NotThrow();\n\n testSubject.Invoking(x => x.Return()).Should().Throw();\n\n throw new XunitException(\"Should().Throw() did not throw\");\n }\n catch (XunitException ex)\n {\n ex.Message.Should().Be(\n \"Expected a to be thrown, but no exception was thrown.\");\n }\n }\n\n [Fact]\n public void When_func_does_not_throw_it_should_be_chainable()\n {\n // Arrange\n Does testSubject = Does.NotThrow();\n\n // Act / Assert\n testSubject.Invoking(x => x.Return()).Should().NotThrow()\n .Which.Should().Be(42);\n }\n\n [Fact]\n public void When_action_does_not_throw_exception_but_one_was_expected_it_should_throw_with_clear_description()\n {\n try\n {\n var act = new Action(() => { });\n\n act.Should().Throw();\n\n throw new XunitException(\"Should().Throw() did not throw\");\n }\n catch (XunitException ex)\n {\n ex.Message.Should().Be(\n \"Expected a to be thrown, but no exception was thrown.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Extensibility.Specs/ExtensionAssemblyAttributeSpecs.cs", "namespace AwesomeAssertions.Extensibility.Specs;\n\npublic class ExtensionAssemblyAttributeSpecs\n{\n [Fact]\n public void Calls_assembly_initialization_code_only_once()\n {\n for (int i = 0; i < 10; i++)\n {\n var act = () => AssertionEngineInitializer.ShouldBeCalledOnlyOnce.Should().Be(1);\n\n act.Should().NotThrow();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.HaveValue.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class HaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_with_value_to_have_a_value()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act / Assert\n nullableInteger.Should().HaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_without_a_value_to_have_a_value()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act\n Action act = () => nullableInteger.Should().HaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n Should_fail_with_descriptive_message_when_asserting_nullable_numeric_value_without_a_value_to_have_a_value()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act\n Action act = () => nullableInteger.Should().HaveValue(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n }\n\n public class NotHaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act / Assert\n nullableInteger.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () => nullableInteger.Should().NotHaveValue();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_nullable_value_with_unexpected_value_is_found_it_should_throw_with_message()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action action = () => nullableInteger.Should().NotHaveValue(\"it was {0} expected\", \"not\");\n\n // Assert\n action\n .Should().Throw()\n .WithMessage(\"Did not expect a value because it was not expected, but found 1.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveAccessModifier.cs", "using System;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveAccessModifier specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveAccessModifier\n {\n [Fact]\n public void When_asserting_a_public_type_is_public_it_succeeds()\n {\n // Arrange\n Type type = typeof(IPublicInterface);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_internal_it_throws()\n {\n // Arrange\n Type type = typeof(IPublicInterface);\n\n // Act\n Action act = () =>\n type\n .Should()\n .HaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.IPublicInterface to be Internal *failure message*, but it is Public.\");\n }\n\n [Fact]\n public void An_internal_class_has_an_internal_access_modifier()\n {\n // Arrange\n Type type = typeof(InternalClass);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void An_internal_interface_has_an_internal_access_modifier()\n {\n // Arrange\n Type type = typeof(IInternalInterface);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void An_internal_struct_has_an_internal_access_modifier()\n {\n // Arrange\n Type type = typeof(InternalStruct);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void An_internal_enum_has_an_internal_access_modifier()\n {\n // Arrange\n Type type = typeof(InternalEnum);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void An_internal_class_does_not_have_a_protected_internal_modifier()\n {\n // Arrange\n Type type = typeof(InternalClass);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.InternalClass to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void A_failing_check_for_a_modifier_of_a_generic_class_includes_the_type_definition_in_the_failure_message()\n {\n // Arrange\n Type type = typeof(GenericClass);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.Private, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.GenericClass to be Private *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void An_internal_interface_does_not_have_a_protected_internal_modifier()\n {\n // Arrange\n Type type = typeof(IInternalInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type AwesomeAssertions.Specs.Types.IInternalInterface to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void An_internal_struct_does_not_have_a_protected_internal_modifier()\n {\n // Arrange\n Type type = typeof(InternalStruct);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.InternalStruct to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void An_internal_enum_does_not_have_a_protected_internal_modifier()\n {\n // Arrange\n Type type = typeof(InternalEnum);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.InternalEnum to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_private_type_is_private_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"PrivateClass\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_nested_private_type_is_protected_it_throws()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"PrivateClass\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(CSharpAccessModifier.Protected, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+PrivateClass to be Protected *failure message*, but it is Private.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_type_is_protected_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"ProtectedEnum\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_type_is_public_it_throws()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"ProtectedEnum\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(CSharpAccessModifier.Public);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+ProtectedEnum to be Public, but it is Protected.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_public_type_is_public_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.IPublicInterface);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_nested_public_member_is_internal_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.IPublicInterface);\n\n // Act\n Action act = () =>\n type\n .Should()\n .HaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+IPublicInterface to be Internal *failure message*, but it is Public.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_internal_type_is_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.InternalClass);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void When_asserting_a_nested_internal_type_is_protected_internal_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.InternalClass);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+InternalClass to be ProtectedInternal *failure message*, but it is Internal.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_internal_member_is_protected_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.IProtectedInternalInterface);\n\n // Act / Assert\n type.Should().HaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_internal_member_is_private_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.IProtectedInternalInterface);\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(CSharpAccessModifier.Private, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type AwesomeAssertions.Specs.Types.Nested+IProtectedInternalInterface to be Private *failure message*, but it is ProtectedInternal.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_access_modifier_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type to be Public *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_an_access_modifier_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveAccessModifier((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n\n public class NotHaveAccessModifier\n {\n [Fact]\n public void When_asserting_a_public_type_is_not_private_it_succeeds()\n {\n // Arrange\n Type type = typeof(IPublicInterface);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_public_member_is_not_public_it_throws()\n {\n // Arrange\n Type type = typeof(IPublicInterface);\n\n // Act\n Action act = () =>\n type\n .Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.IPublicInterface not to be Public *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_an_internal_type_is_not_protected_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(InternalClass);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_an_internal_type_is_not_internal_it_throws()\n {\n // Arrange\n Type type = typeof(InternalClass);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.InternalClass not to be Internal *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_private_type_is_not_protected_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"PrivateClass\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Protected);\n }\n\n [Fact]\n public void When_asserting_a_nested_private_type_is_not_private_it_throws()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"PrivateClass\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Private, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+PrivateClass not to be Private *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_type_is_not_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"ProtectedEnum\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal);\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_type_is_not_protected_it_throws()\n {\n // Arrange\n Type type = typeof(Nested).GetNestedType(\"ProtectedEnum\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Protected);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+ProtectedEnum not to be Protected, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_public_type_is_not_private_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.IPublicInterface);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_nested_public_member_is_not_public_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.IPublicInterface);\n\n // Act\n Action act = () =>\n type\n .Should()\n .NotHaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+IPublicInterface not to be Public *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_internal_type_is_not_protected_internal_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.InternalClass);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_a_nested_internal_type_is_not_internal_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.InternalClass);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Internal, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type AwesomeAssertions.Specs.Types.Nested+InternalClass not to be Internal *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_internal_member_is_not_public_it_succeeds()\n {\n // Arrange\n Type type = typeof(Nested.IProtectedInternalInterface);\n\n // Act / Assert\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_nested_protected_internal_member_is_not_protected_internal_it_throws()\n {\n // Arrange\n Type type = typeof(Nested.IProtectedInternalInterface);\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(\n CSharpAccessModifier.ProtectedInternal, \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type AwesomeAssertions.Specs.Types.Nested+IProtectedInternalInterface not to be ProtectedInternal *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_access_modifier_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier(CSharpAccessModifier.Public, \"we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected type not to be Public *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_an_access_modifier_with_an_invalid_enum_value_it_should_throw()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveAccessModifier((CSharpAccessModifier)int.MaxValue);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"accessModifier\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.Contain.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]Contain specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class Contain\n {\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_contains_the_expected_string_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring);\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_does_not_contain_an_expected_string_it_should_throw()\n {\n // Act\n Action act = () => \"ABCDEF\".Should().Contain(\"XYZ\", \"that is {0}\", \"required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected string \\\"ABCDEF\\\" to contain \\\"XYZ\\\" because that is required.\");\n }\n\n [Fact]\n public void When_containment_is_asserted_against_null_it_should_throw()\n {\n // Act\n Action act = () => \"a\".Should().Contain(null);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_containment_is_asserted_against_an_empty_string_it_should_throw()\n {\n // Act\n Action act = () => \"a\".Should().Contain(\"\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against an empty string.*\")\n .WithParameterName(\"expected\");\n }\n\n [Fact]\n public void When_string_containment_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Act\n string someString = null;\n Action act = () => someString.Should().Contain(\"XYZ\", \"that is {0}\", \"required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someString to contain \\\"XYZ\\\" because that is required.\");\n }\n\n public class ContainExactly\n {\n [Fact]\n public void\n When_string_containment_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Once(), \"that is {0}\", \"required\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected * \\\"ABCDEF\\\" to contain \\\"XYS\\\" exactly 1 time because that is required, but found it 0 times.\");\n }\n\n [Fact]\n public void When_containment_once_is_asserted_against_null_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"a\";\n string expectedSubstring = null;\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Once());\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\");\n }\n\n [Fact]\n public void When_string_containment_once_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain \\\"XYZ\\\" exactly 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void When_string_containment_exactly_is_asserted_and_expected_value_is_negative_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Times(-1));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected count cannot be negative.*\");\n }\n\n [Fact]\n public void\n When_string_containment_exactly_is_asserted_and_actual_value_contains_the_expected_string_exactly_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, Exactly.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_exactly_is_asserted_and_actual_value_contains_the_expected_string_but_not_exactly_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, Exactly.Times(3));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" exactly 3 times, but found it 2 times.\");\n }\n }\n\n public class ContainAtLeast\n {\n [Fact]\n public void\n When_string_containment_at_least_is_asserted_and_actual_value_contains_the_expected_string_at_least_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, AtLeast.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_at_least_is_asserted_and_actual_value_contains_the_expected_string_but_not_at_least_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, AtLeast.Times(3));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" at least 3 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_at_least_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw_earlier()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, AtLeast.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEF\\\" to contain \\\"XYS\\\" at least 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void When_string_containment_at_least_once_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, AtLeast.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain \\\"XYZ\\\" at least 1 time, but found it 0 times.\");\n }\n }\n\n public class ContainMoreThan\n {\n [Fact]\n public void\n When_string_containment_more_than_is_asserted_and_actual_value_contains_the_expected_string_more_than_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, MoreThan.Times(1));\n }\n\n [Fact]\n public void\n When_string_containment_more_than_is_asserted_and_actual_value_contains_the_expected_string_but_not_more_than_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, MoreThan.Times(2));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" more than 2 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_more_than_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, MoreThan.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEF\\\" to contain \\\"XYS\\\" more than 1 time, but found it 0 times.\");\n }\n\n [Fact]\n public void When_string_containment_more_than_once_is_asserted_and_actual_value_is_null_then_it_should_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, MoreThan.Once());\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * to contain \\\"XYZ\\\" more than 1 time, but found it 0 times.\");\n }\n }\n\n public class ContainAtMost\n {\n [Fact]\n public void\n When_string_containment_at_most_is_asserted_and_actual_value_contains_the_expected_string_at_most_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, AtMost.Times(2));\n }\n\n [Fact]\n public void\n When_string_containment_at_most_is_asserted_and_actual_value_contains_the_expected_string_but_not_at_most_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, AtMost.Times(1));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" at most 1 time, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_at_most_once_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, AtMost.Once());\n }\n\n [Fact]\n public void When_string_containment_at_most_once_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, AtMost.Once());\n }\n }\n\n public class ContainsLessThan\n {\n [Fact]\n public void\n When_string_containment_less_than_is_asserted_and_actual_value_contains_the_expected_string_less_than_expected_times_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, LessThan.Times(3));\n }\n\n [Fact]\n public void\n When_string_containment_less_than_is_asserted_and_actual_value_contains_the_expected_string_but_not_less_than_expected_times_it_should_throw()\n {\n // Arrange\n string actual = \"ABCDEBCDF\";\n string expectedSubstring = \"BCD\";\n\n // Act\n Action act = () => actual.Should().Contain(expectedSubstring, LessThan.Times(2));\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected * \\\"ABCDEBCDF\\\" to contain \\\"BCD\\\" less than 2 times, but found it 2 times.\");\n }\n\n [Fact]\n public void\n When_string_containment_less_than_twice_is_asserted_and_actual_value_does_not_contain_the_expected_string_it_should_not_throw()\n {\n // Arrange\n string actual = \"ABCDEF\";\n string expectedSubstring = \"XYS\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, LessThan.Twice());\n }\n\n [Fact]\n public void When_string_containment_less_than_twice_is_asserted_and_actual_value_is_null_then_it_should_not_throw()\n {\n // Arrange\n string actual = null;\n string expectedSubstring = \"XYZ\";\n\n // Act / Assert\n actual.Should().Contain(expectedSubstring, LessThan.Twice());\n }\n }\n }\n\n public class NotContain\n {\n [Fact]\n public void When_string_does_not_contain_the_unexpected_string_it_should_succeed()\n {\n // Act / Assert\n \"a\".Should().NotContain(\"A\");\n }\n\n [Fact]\n [SuppressMessage(\"ReSharper\", \"StringLiteralTypo\")]\n public void When_string_contains_unexpected_fragment_it_should_throw()\n {\n // Act\n Action act = () => \"abcd\".Should().NotContain(\"bc\", \"it was not expected {0}\", \"today\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect string \\\"abcd\\\" to contain \\\"bc\\\" because it was not expected today.\");\n }\n\n [Fact]\n public void When_exclusion_is_asserted_against_null_it_should_throw()\n {\n // Act\n Action act = () => \"a\".Should().NotContain(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert string containment against .*\")\n .WithParameterName(\"unexpected\");\n }\n\n [Fact]\n public void When_exclusion_is_asserted_against_an_empty_string_it_should_throw()\n {\n // Act\n Action act = () => \"a\".Should().NotContain(\"\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot assert string containment against an empty string.*\")\n .WithParameterName(\"unexpected\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.AllSatisfy.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class AllSatisfy\n {\n [Fact]\n public void All_items_satisfying_inspector_should_succeed()\n {\n // Arrange\n string[] collection = [\"John\", \"John\"];\n\n // Act / Assert\n collection.Should().AllSatisfy(value => value.Should().Be(\"John\"));\n }\n\n [Fact]\n public void Any_items_not_satisfying_inspector_should_throw()\n {\n // Arrange\n string[] collection = [\"Jack\", \"Jessica\"];\n\n // Act\n Action act = () => collection.Should()\n .AllSatisfy(\n value => value.Should().Be(\"John\"),\n \"because we want to test the failure {0}\",\n \"message\");\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\n \"Expected collection to contain only items satisfying the inspector because we want to test the failure message:\"\n + \"*Jack*John\"\n + \"*Jessica*John*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NumericAssertionSpecs.Match.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NumericAssertionSpecs\n{\n public class Match\n {\n [Fact]\n public void When_value_satisfies_predicate_it_should_not_throw()\n {\n // Arrange\n int value = 1;\n\n // Act / Assert\n value.Should().Match(o => o > 0);\n }\n\n [Fact]\n public void When_value_does_not_match_the_predicate_it_should_throw()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action act = () => value.Should().Match(o => o == 0, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected value to match (o == 0) because we want to test the failure message, but found 1.\");\n }\n\n [Fact]\n public void When_value_is_matched_against_a_null_it_should_throw()\n {\n // Arrange\n int value = 1;\n\n // Act\n Action act = () => value.Should().Match(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"predicate\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/TimeOnlyAssertionSpecs.cs", "#if NET6_0_OR_GREATER\nusing System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class TimeOnlyAssertionSpecs\n{\n [Fact]\n public void Should_succeed_when_asserting_nullable_timeonly_value_with_value_to_have_a_value()\n {\n // Arrange\n TimeOnly? timeOnly = new(15, 06, 04);\n\n // Act/Assert\n timeOnly.Should().HaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_timeonly_value_with_value_to_not_be_null()\n {\n // Arrange\n TimeOnly? timeOnly = new(15, 06, 04);\n\n // Act/Assert\n timeOnly.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_timeonly_value_with_null_to_be_null()\n {\n // Arrange\n TimeOnly? timeOnly = null;\n\n // Act/Assert\n timeOnly.Should().BeNull();\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n TimeOnly earlierTimeOnly = new(15, 06, 03);\n TimeOnly? nullableTimeOnly = new(15, 06, 04);\n\n // Act/Assert\n nullableTimeOnly.Should()\n .HaveValue()\n .And\n .BeAfter(earlierTimeOnly);\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n TimeOnly someTimeOnly = new(21, 1);\n\n // Act\n var act = () => someTimeOnly.Should().Equals(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeNull.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_without_a_value_to_be_null()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act / Assert\n nullableInteger.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_with_a_value_to_be_null()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () => nullableInteger.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_nullable_numeric_value_with_a_value_to_be_null()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act\n Action act = () => nullableInteger.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Did not expect a value because we want to test the failure message, but found 1.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_numeric_value_with_value_to_not_be_null()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act / Assert\n nullableInteger.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_numeric_value_without_a_value_to_not_be_null()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act\n Action act = () => nullableInteger.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n Should_fail_with_descriptive_message_when_asserting_nullable_numeric_value_without_a_value_to_not_be_null()\n {\n // Arrange\n int? nullableInteger = null;\n\n // Act\n Action act = () => nullableInteger.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected a value because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateOnlyAssertionSpecs.cs", "#if NET6_0_OR_GREATER\n\nusing System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateOnlyAssertionSpecs\n{\n [Fact]\n public void Should_succeed_when_asserting_nullable_dateonly_value_with_value_to_have_a_value()\n {\n // Arrange\n DateOnly? dateOnly = new(2016, 06, 04);\n\n // Act/Assert\n dateOnly.Should().HaveValue();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_dateonly_value_with_value_to_not_be_null()\n {\n // Arrange\n DateOnly? dateOnly = new(2016, 06, 04);\n\n // Act/Assert\n dateOnly.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_succeed_when_asserting_nullable_dateonly_value_with_null_to_be_null()\n {\n // Arrange\n DateOnly? dateOnly = null;\n\n // Act/Assert\n dateOnly.Should().BeNull();\n }\n\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n DateOnly earlierDateOnly = new(2016, 06, 03);\n DateOnly? nullableDateOnly = new(2016, 06, 04);\n\n // Act/Assert\n nullableDateOnly.Should()\n .HaveValue()\n .And\n .BeAfter(earlierDateOnly);\n }\n\n [Fact]\n public void Should_throw_a_helpful_error_when_accidentally_using_equals()\n {\n // Arrange\n DateOnly someDateOnly = new(2022, 9, 25);\n\n // Act\n Action action = () => someDateOnly.Should().Equals(someDateOnly);\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Equals is not part of Awesome Assertions. Did you mean Be() instead?\");\n }\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCount.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCount\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCount(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_that_is_different_from_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCount(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_dictionary_has_a_count_that_is_different_from_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () => dictionary.Should().HaveCount(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain 4 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_has_a_count_larger_than_the_minimum_it_should_not_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCount(c => c >= 3);\n }\n\n [Fact]\n public void When_dictionary_has_a_count_that_not_matches_the_predicate_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCount(c => c >= 4, \"a minimum of 4 is required\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to have a count (c >= 4) because a minimum of 4 is required, but count is 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_matched_against_a_null_predicate_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCount(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot compare collection count against a predicate.*\");\n }\n\n [Fact]\n public void When_dictionary_count_is_matched_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().HaveCount(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain 1 item(s) because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_dictionary_count_is_matched_against_a_predicate_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().HaveCount(c => c < 3, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to contain (c < 3) items because we want to test the behaviour with a null subject, but found .\");\n }\n }\n\n public class NotHaveCount\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_different_from_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().NotHaveCount(2);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_that_equals_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().NotHaveCount(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_dictionary_has_a_count_that_equals_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () => dictionary.Should().NotHaveCount(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"*not contain*3*because we want to test the failure message*3*\");\n }\n\n [Fact]\n public void When_dictionary_count_is_same_than_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().NotHaveCount(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*not contain*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/MemberPathSegmentEqualityComparer.cs", "#if NET6_0_OR_GREATER || NETSTANDARD2_1\nusing System;\n#endif\nusing System.Collections.Generic;\nusing System.Text.RegularExpressions;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Compares two segments of a .\n/// Sets the equal with any numeric index qualifier.\n/// All other comparisons are default string equality.\n/// \ninternal class MemberPathSegmentEqualityComparer : IEqualityComparer\n{\n private const string AnyIndexQualifier = \"*\";\n private static readonly Regex IndexQualifierRegex = new(\"^[0-9]+$\");\n\n /// \n /// Compares two segments of a .\n /// \n /// Left part of the comparison.\n /// Right part of the comparison.\n /// True if segments are equal, false if not.\n public bool Equals(string x, string y)\n {\n if (x == AnyIndexQualifier)\n {\n return IsIndexQualifier(y);\n }\n\n if (y == AnyIndexQualifier)\n {\n return IsIndexQualifier(x);\n }\n\n return x == y;\n }\n\n private static bool IsIndexQualifier(string segment) =>\n segment == AnyIndexQualifier || IndexQualifierRegex.IsMatch(segment);\n\n public int GetHashCode(string obj)\n {\n#if NET6_0_OR_GREATER || NETSTANDARD2_1\n return obj.GetHashCode(StringComparison.Ordinal);\n#else\n return obj.GetHashCode();\n#endif\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/FormattingOptions.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Formatting;\n\npublic class FormattingOptions\n{\n internal List ScopedFormatters { get; set; } = [];\n\n /// \n /// Indicates whether the formatter should use line breaks when the supports it.\n /// \n /// \n /// This property is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n public bool UseLineBreaks { get; set; }\n\n /// \n /// Determines the depth until which the library should try to render an object graph.\n /// \n /// \n /// This property is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n /// \n /// A depth of 1 will only the display the members of the root object.\n /// \n public int MaxDepth { get; set; } = 5;\n\n /// \n /// Sets the maximum number of lines of the failure message.\n /// \n /// \n /// \n /// Because of technical reasons, the actual output may be one or two lines longer.\n /// \n /// \n /// This property is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n /// \n public int MaxLines { get; set; } = 100;\n\n /// \n /// Sets the default number of characters shown when printing the difference of two strings.\n /// \n /// \n /// \n /// The actual number of shown characters depends on the word-boundary-algorithm.
\n /// This algorithm searches for a word boundary (a blank) in the range from 5 characters previous and 10 characters after the\n /// . If found it displays a full word, otherwise it falls back to the .\n ///
\n /// \n /// This property is not thread-safe and should not be modified through from within a unit test.\n /// See the docs on how to safely use it.\n /// \n ///
\n public int StringPrintLength { get; set; } = 50;\n\n /// \n /// Removes a scoped formatter that was previously added through .\n /// \n /// A custom implementation of \n public void RemoveFormatter(IValueFormatter formatter)\n {\n ScopedFormatters.Remove(formatter);\n }\n\n /// \n /// Ensures a scoped formatter is included in the chain, which is executed before the static custom formatters and the default formatters.\n /// This also lasts only for the current until disposal.\n /// \n /// A custom implementation of \n public void AddFormatter(IValueFormatter formatter)\n {\n if (!ScopedFormatters.Contains(formatter))\n {\n ScopedFormatters.Insert(0, formatter);\n }\n }\n\n internal FormattingOptions Clone()\n {\n return new FormattingOptions\n {\n UseLineBreaks = UseLineBreaks,\n MaxDepth = MaxDepth,\n MaxLines = MaxLines,\n StringPrintLength = StringPrintLength,\n ScopedFormatters = [.. ScopedFormatters],\n };\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveDefaultConstructor.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveDefaultConstructor specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveDefaultConstructor\n {\n [Fact]\n public void When_asserting_a_type_has_a_default_constructor_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveDefaultConstructor()\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.ProtectedInternal);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_default_constructor_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act / Assert\n type.Should()\n .HaveDefaultConstructor()\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_default_constructor_which_it_does_not_and_a_cctor_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithCctor);\n\n // Act / Assert\n type.Should()\n .HaveDefaultConstructor()\n .Which.Should()\n .HaveAccessModifier(CSharpAccessModifier.Public);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_default_constructor_which_it_does_not_and_a_cctor_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithCctorAndNonDefaultConstructor);\n\n // Act\n Action act = () =>\n type.Should().HaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected constructor *ClassWithCctorAndNonDefaultConstructor() to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_default_constructor_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor type() to exist *failure message*, but type is .\");\n }\n }\n\n public class NotHaveDefaultConstructor\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_a_default_constructor_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithCctorAndNonDefaultConstructor);\n\n // Act / Assert\n type.Should()\n .NotHaveDefaultConstructor();\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_default_constructor_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should()\n .NotHaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor *.ClassWithMembers() not to exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_default_constructor_which_it_does_and_a_cctor_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithCctor);\n\n // Act\n Action act = () =>\n type.Should().NotHaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor *ClassWithCctor*() not to exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_default_constructor_which_it_does_not_and_a_cctor_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithCctorAndNonDefaultConstructor);\n\n // Act / Assert\n type.Should().NotHaveDefaultConstructor();\n }\n\n [Fact]\n public void When_subject_is_null_not_have_default_constructor_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveDefaultConstructor(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor type() not to exist *failure message*, but type is .\");\n }\n }\n\n internal class ClassWithNoMembers;\n\n internal class ClassWithCctor;\n\n internal class ClassWithCctorAndNonDefaultConstructor\n {\n public ClassWithCctorAndNonDefaultConstructor(int _) { }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCountGreaterThan.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCountGreaterThan\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_greater_than_less_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCountGreaterThan(2);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_greater_than_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCountGreaterThan(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_dictionary_has_a_count_greater_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () =>\n dictionary.Should().HaveCountGreaterThan(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain more than 3 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_greater_than_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().HaveCountGreaterThan(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*more than*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.IntersectWith.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class IntersectWith\n {\n [Fact]\n public void When_asserting_the_items_in_an_two_intersecting_collections_intersect_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = [\"three\", \"four\", \"five\"];\n\n // Act / Assert\n collection.Should().IntersectWith(otherCollection);\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_non_intersecting_collections_intersect_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = [\"four\", \"five\"];\n\n // Act\n Action action = () => collection.Should().IntersectWith(otherCollection, \"they should share items\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\"Expected collection to intersect with {\\\"four\\\", \\\"five\\\"} because they should share items,\" +\n \" but {\\\"one\\\", \\\"two\\\", \\\"three\\\"} does not contain any shared items.\");\n }\n }\n\n public class NotIntersectWith\n {\n [Fact]\n public void When_asserting_collection_to_not_intersect_with_same_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = collection;\n\n // Act\n Action act = () => collection.Should().NotIntersectWith(otherCollection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*to intersect with*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_intersecting_collections_do_not_intersect_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = [\"two\", \"three\", \"four\"];\n\n // Act\n Action action = () => collection.Should().NotIntersectWith(otherCollection, \"they should not share items\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Did not expect collection to intersect with {\\\"two\\\", \\\"three\\\", \\\"four\\\"} because they should not share items,\" +\n \" but found the following shared items {\\\"two\\\", \\\"three\\\"}.\");\n }\n\n [Fact]\n public void When_asserting_the_items_in_an_two_non_intersecting_collections_do_not_intersect_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = [\"four\", \"five\"];\n\n // Act / Assert\n collection.Should().NotIntersectWith(otherCollection);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCountLessThan.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCountLessThan\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_less_than_less_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCountLessThan(4);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_less_than_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCountLessThan(3);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_dictionary_has_a_count_less_than_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () => dictionary.Should().HaveCountLessThan(3, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain fewer than 3 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_less_than_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () => dictionary.Should().HaveCountLessThan(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*fewer than*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCountLessThanOrEqualTo.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCountLessThanOrEqualTo\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_less_than_or_equal_to_less_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCountLessThanOrEqualTo(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_less_than_or_equal_to_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCountLessThanOrEqualTo(2);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_dictionary_has_a_count_less_than_or_equal_to_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () =>\n dictionary.Should().HaveCountLessThanOrEqualTo(2, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain at most 2 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_less_than_or_equal_to_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n dictionary.Should().HaveCountLessThanOrEqualTo(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*at most*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveCountGreaterThanOrEqualTo.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveCountGreaterThanOrEqualTo\n {\n [Fact]\n public void Should_succeed_when_asserting_dictionary_has_a_count_greater_than_or_equal_to_less_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act / Assert\n dictionary.Should().HaveCountGreaterThanOrEqualTo(3);\n }\n\n [Fact]\n public void Should_fail_when_asserting_dictionary_has_a_count_greater_than_or_equal_to_the_number_of_items()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action act = () => dictionary.Should().HaveCountGreaterThanOrEqualTo(4);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_dictionary_has_a_count_greater_than_or_equal_to_the_number_of_items_it_should_fail_with_descriptive_message_()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n // Act\n Action action = () =>\n dictionary.Should().HaveCountGreaterThanOrEqualTo(4, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n action.Should().Throw()\n .WithMessage(\n \"Expected dictionary to contain at least 4 item(s) because we want to test the failure message, but found 3: {[1] = \\\"One\\\", [2] = \\\"Two\\\", [3] = \\\"Three\\\"}.\");\n }\n\n [Fact]\n public void When_dictionary_count_is_greater_than_or_equal_to_and_dictionary_is_null_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n\n // Act\n Action act = () =>\n dictionary.Should().HaveCountGreaterThanOrEqualTo(1, \"we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*at least*1*we want to test the behaviour with a null subject*found *\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeAssignableTo.cs", "using System;\nusing AwesomeAssertions.Specs.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeAssignableTo specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeAssignableTo\n {\n [Fact]\n public void When_its_own_type_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_its_base_type_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_implemented_interface_type_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo();\n }\n\n [Fact]\n public void When_an_unrelated_type_it_fails()\n {\n // Arrange\n Type someType = typeof(DummyImplementingClass);\n Action act = () => someType.Should().BeAssignableTo(\"we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected someType *.DummyImplementingClass to be assignable to *.DateTime *failure message*\" +\n \", but it is not.\");\n }\n\n [Fact]\n public void When_its_own_type_instance_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo(typeof(DummyImplementingClass));\n }\n\n [Fact]\n public void When_its_base_type_instance_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo(typeof(DummyBaseClass));\n }\n\n [Fact]\n public void When_an_implemented_interface_type_instance_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().BeAssignableTo(typeof(IDisposable));\n }\n\n [Fact]\n public void When_an_unrelated_type_instance_it_fails()\n {\n // Arrange\n Type someType = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n someType.Should().BeAssignableTo(typeof(DateTime), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*.DummyImplementingClass to be assignable to *.DateTime *failure message*\");\n }\n\n [Fact]\n public void When_constructed_of_open_generic_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(IDummyInterface).Should().BeAssignableTo(typeof(IDummyInterface<>));\n }\n\n [Fact]\n public void When_implementation_of_open_generic_interface_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(ClassWithGenericBaseType).Should().BeAssignableTo(typeof(IDummyInterface<>));\n }\n\n [Fact]\n public void When_derived_of_open_generic_class_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(ClassWithGenericBaseType).Should().BeAssignableTo(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_interface_it_fails()\n {\n // Arrange\n Type someType = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n someType.Should().BeAssignableTo(typeof(IDummyInterface<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected someType *.IDummyInterface to be assignable to *.IDummyInterface *failure message*\" +\n \", but it is not.\");\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_type_it_fails()\n {\n // Arrange\n Type someType = typeof(ClassWithAttribute);\n\n Action act = () =>\n someType.Should().BeAssignableTo(typeof(DummyBaseType<>), \"we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\"*.ClassWithAttribute to be assignable to *.DummyBaseType* *failure message*\");\n }\n\n [Fact]\n public void When_asserting_an_open_generic_class_is_assignable_to_itself_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyBaseType<>).Should().BeAssignableTo(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_a_type_to_be_assignable_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act = () =>\n type.Should().BeAssignableTo(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"type\");\n }\n }\n\n public class NotBeAssignableTo\n {\n [Fact]\n public void When_its_own_type_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.DummyImplementingClass *failure message*\");\n }\n\n [Fact]\n public void When_its_base_type_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.DummyBaseClass *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_implemented_interface_type_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(\"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.IDisposable *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_an_unrelated_type_and_asserting_not_assignable_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().NotBeAssignableTo();\n }\n\n [Fact]\n public void When_its_own_type_instance_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(DummyImplementingClass), \"we want to test the failure {0}\", \"message\");\n\n // Act / Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.DummyImplementingClass *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_its_base_type_instance_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(DummyBaseClass), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.DummyBaseClass *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_an_implemented_interface_type_instance_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(IDisposable), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass to not be assignable to *.IDisposable *failure message*, but it is.\");\n }\n\n [Fact]\n public void When_an_unrelated_type_instance_and_asserting_not_assignable_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(DummyImplementingClass).Should().NotBeAssignableTo(typeof(DateTime));\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_interface_and_asserting_not_assignable_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(ClassWithAttribute).Should().NotBeAssignableTo(typeof(IDummyInterface<>));\n }\n\n [Fact]\n public void When_unrelated_to_open_generic_class_and_asserting_not_assignable_it_succeeds()\n {\n // Arrange / Act / Assert\n typeof(ClassWithAttribute).Should().NotBeAssignableTo(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_implementation_of_open_generic_interface_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithGenericBaseType);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(IDummyInterface<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithGenericBaseType to not be assignable to *.IDummyInterface *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_derived_from_open_generic_class_and_asserting_not_assignable_it_fails()\n {\n // Arrange\n Type type = typeof(ClassWithGenericBaseType);\n\n // Act\n Action act = () =>\n type.Should().NotBeAssignableTo(typeof(IDummyInterface<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithGenericBaseType to not be assignable to *.IDummyInterface *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_type_not_to_be_assignable_to_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act =\n () => type.Should().NotBeAssignableTo(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"type\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.Match.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]Match specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class Match\n {\n [Fact]\n public void When_a_string_does_not_match_a_wildcard_pattern_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().Match(\"h*earth!\", \"that's the universal greeting\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected subject to match*\\\"h*earth!\\\" because that's the universal greeting, but*\\\"hello world!\\\" does not.\");\n }\n\n [Fact]\n public void When_a_string_does_match_a_wildcard_pattern_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n subject.Should().Match(\"h*world?\");\n }\n\n [Fact]\n public void When_a_string_does_not_match_a_wildcard_pattern_with_escaped_markers_it_should_throw()\n {\n // Arrange\n string subject = \"What! Are you deaf!\";\n\n // Act\n Action act = () => subject.Should().Match(@\"What\\? Are you deaf\\?\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match*\\\"What\\\\? Are you deaf\\\\?\\\", but*\\\"What! Are you deaf!\\\" does not.\");\n }\n\n [Fact]\n public void When_a_string_does_match_a_wildcard_pattern_but_differs_in_casing_it_should_throw()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().Match(\"*World*\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match*\\\"*World*\\\", but*\\\"hello world\\\" does not.\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_null_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().Match(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a wildcard pattern or use the BeNull method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void Null_does_not_match_to_any_string()\n {\n // Arrange\n string subject = null;\n\n // Act\n Action act = () => subject.Should().Match(\"*\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected subject to match *, but found .\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_an_empty_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().Match(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n }\n\n public class NotMatch\n {\n [Fact]\n public void When_a_string_does_not_match_a_pattern_and_it_shouldnt_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act / Assert\n subject.Should().NotMatch(\"*World*\");\n }\n\n [Fact]\n public void When_a_string_does_match_a_pattern_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatch(\"*world*\", \"because that's illegal\");\n\n // Assert\n act\n .Should().Throw().WithMessage(\n \"Did not expect subject to match*\\\"*world*\\\" because that's illegal, but*\\\"hello world\\\" matches.\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_null_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatch(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_a_string_is_negatively_matched_against_an_empty_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatch(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.BeDerivedFrom.cs", "using System;\nusing AwesomeAssertions.Specs.Primitives;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]BeDerivedFrom specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class BeDerivedFrom\n {\n [Fact]\n public void When_asserting_a_type_is_derived_from_its_base_class_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act / Assert\n type.Should().BeDerivedFrom(typeof(DummyBaseClass));\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_unrelated_class_it_fails()\n {\n // Arrange\n var type = typeof(DummyBaseClass);\n\n // Act\n Action act = () =>\n type.Should().BeDerivedFrom(typeof(ClassWithMembers), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyBaseClass to be derived from *.ClassWithMembers *failure message*, but it is not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_interface_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act\n Action act = () =>\n type.Should().BeDerivedFrom(typeof(IDummyInterface), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatImplementsInterface to be derived from *.IDummyInterface *failure message*\" +\n \", but *.IDummyInterface is an interface.\");\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_open_generic_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyBaseType);\n\n // Act / Assert\n type.Should().BeDerivedFrom(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_open_generic_base_class_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithGenericBaseType);\n\n // Act / Assert\n type.Should().BeDerivedFrom(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_a_type_is_derived_from_an_unrelated_open_generic_class_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().BeDerivedFrom(typeof(DummyBaseType<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassWithMembers to be derived from *.DummyBaseType* *failure message*, but it is not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_to_be_derived_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act =\n () => type.Should().BeDerivedFrom(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"baseType\");\n }\n }\n\n public class BeDerivedFromOfT\n {\n [Fact]\n public void When_asserting_a_type_is_DerivedFromOfT_its_base_class_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act / Assert\n type.Should().BeDerivedFrom();\n }\n }\n\n public class NotBeDerivedFrom\n {\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_an_unrelated_class_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyBaseClass);\n\n // Act / Assert\n type.Should().NotBeDerivedFrom(typeof(ClassWithMembers));\n }\n\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_its_base_class_it_fails()\n {\n // Arrange\n var type = typeof(DummyImplementingClass);\n\n // Act\n Action act = () =>\n type.Should().NotBeDerivedFrom(typeof(DummyBaseClass), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyImplementingClass not to be derived from *.DummyBaseClass *failure message*\" +\n \", but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_an_interface_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act\n Action act = () =>\n type.Should().NotBeDerivedFrom(typeof(IDummyInterface), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatImplementsInterface not to be derived from *.IDummyInterface *failure message*\" +\n \", but *.IDummyInterface is an interface.\");\n }\n\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_an_unrelated_open_generic_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should().NotBeDerivedFrom(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_an_open_generic_type_is_not_derived_from_itself_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act / Assert\n type.Should().NotBeDerivedFrom(typeof(DummyBaseType<>));\n }\n\n [Fact]\n public void When_asserting_a_type_is_not_derived_from_its_open_generic_it_fails()\n {\n // Arrange\n var type = typeof(DummyBaseType);\n\n // Act\n Action act = () =>\n type.Should().NotBeDerivedFrom(typeof(DummyBaseType<>), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.DummyBaseType<*.ClassWithGenericBaseType> not to be derived from *.DummyBaseType \" +\n \"*failure message*, but it is.\");\n }\n\n [Fact]\n public void When_asserting_a_type_not_to_be_derived_from_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act =\n () => type.Should().NotBeDerivedFrom(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"baseType\");\n }\n }\n\n public class NotBeDerivedFromOfT\n {\n [Fact]\n public void When_asserting_a_type_is_not_DerivedFromOfT_an_unrelated_class_it_succeeds()\n {\n // Arrange\n var type = typeof(DummyBaseClass);\n\n // Act / Assert\n type.Should().NotBeDerivedFrom();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/TestFrameworkFactorySpecs.cs", "using System;\nusing AwesomeAssertions.Execution;\nusing Xunit;\nusing Xunit.Sdk;\nusing TestFramework = AwesomeAssertions.Configuration.TestFramework;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\npublic class TestFrameworkFactorySpecs\n{\n [Fact]\n public void When_running_xunit_test_implicitly_it_should_be_detected()\n {\n // Arrange\n var testFramework = TestFrameworkFactory.GetFramework(null);\n\n // Act\n Action act = () => testFramework.Throw(\"MyMessage\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_running_xunit_test_explicitly_it_should_be_detected()\n {\n // Arrange\n var testFramework = TestFrameworkFactory.GetFramework(TestFramework.XUnit2);\n\n // Act\n Action act = () => testFramework.Throw(\"MyMessage\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_running_test_with_unknown_test_framework_it_should_throw()\n {\n // Act\n Action act = () => TestFrameworkFactory.GetFramework((TestFramework)42);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*the test framework '42' but this is not supported*\");\n }\n\n [Fact]\n public void When_running_test_with_late_bound_but_unavailable_test_framework_it_should_throw()\n {\n // Act\n Action act = () => TestFrameworkFactory.GetFramework(TestFramework.NUnit);\n\n act.Should().Throw()\n .WithMessage(\"*test framework 'nunit' but the required assembly 'nunit.framework' could not be found*\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.ContainAll.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]ContainAll specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class ContainAll\n {\n [Fact]\n public void When_containment_of_all_strings_in_a_null_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().ContainAll(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*null*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_containment_of_all_strings_in_an_empty_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().ContainAll();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*empty*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_containment_of_all_strings_in_a_collection_is_asserted_and_all_strings_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act / Assert\n testString.Should().ContainAll(red, green, yellow);\n }\n\n [Fact]\n public void\n When_containment_of_all_strings_in_a_collection_is_asserted_and_equivalent_but_not_exact_matches_exist_for_all_it_should_throw()\n {\n // Arrange\n const string redLowerCase = \"red\";\n const string redUpperCase = \"RED\";\n const string greenWithoutWhitespace = \"green\";\n const string greenWithWhitespace = \" green \";\n var testString = $\"{redLowerCase} {greenWithoutWhitespace}\";\n\n // Act\n Action act = () => testString.Should().ContainAll(redUpperCase, greenWithWhitespace);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain*{redUpperCase}*{greenWithWhitespace}*\");\n }\n\n [Fact]\n public void\n When_containment_of_all_strings_in_a_collection_is_asserted_and_none_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string blue = \"blue\";\n var testString = $\"{red} {green}\";\n\n // Act\n Action act = () => testString.Should().ContainAll(yellow, blue);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain*{yellow}*{blue}*\");\n }\n\n [Fact]\n public void\n When_containment_of_all_strings_in_a_collection_is_asserted_with_reason_and_assertion_fails_then_failure_message_should_contain_reason()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string blue = \"blue\";\n var testString = $\"{red} {green}\";\n\n // Act\n Action act = () => testString.Should().ContainAll([yellow, blue], \"some {0} reason\", \"special\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain*{yellow}*{blue}*because some special reason*\");\n }\n\n [Fact]\n public void\n When_containment_of_all_strings_in_a_collection_is_asserted_and_only_some_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string blue = \"blue\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().ContainAll(red, blue, green);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain*{blue}*\");\n }\n }\n\n public class NotContainAll\n {\n [Fact]\n public void When_exclusion_of_all_strings_in_null_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().NotContainAll(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*null*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_exclusion_of_all_strings_in_an_empty_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().NotContainAll();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*empty*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void\n When_exclusion_of_all_strings_in_a_collection_is_asserted_and_all_strings_in_collection_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAll(red, green, yellow);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain all*{red}*{green}*{yellow}*\");\n }\n\n [Fact]\n public void When_exclusion_of_all_strings_is_asserted_with_reason_and_assertion_fails_then_error_message_contains_reason()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAll([red, green, yellow], \"some {0} reason\", \"special\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain all*{red}*{green}*{yellow}*because*some special reason*\");\n }\n\n [Fact]\n public void\n When_exclusion_of_all_strings_in_a_collection_is_asserted_and_only_some_of_the_strings_in_collection_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string purple = \"purple\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act / Assert\n testString.Should().NotContainAll(red, green, yellow, purple);\n }\n\n [Fact]\n public void\n When_exclusion_of_all_strings_in_a_collection_is_asserted_and_none_of_the_strings_in_the_collection_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string purple = \"purple\";\n var testString = $\"{red} {green}\";\n\n // Act / Assert\n testString.Should().NotContainAll(yellow, purple);\n }\n\n [Fact]\n public void\n When_exclusion_of_all_strings_in_a_collection_is_asserted_and_equivalent_but_not_exact_strings_are_present_in_collection_it_should_succeed()\n {\n // Arrange\n const string redWithoutWhitespace = \"red\";\n const string redWithWhitespace = \" red \";\n const string lowerCaseGreen = \"green\";\n const string upperCaseGreen = \"GREEN\";\n var testString = $\"{redWithoutWhitespace} {lowerCaseGreen}\";\n\n // Act / Assert\n testString.Should().NotContainAll(redWithWhitespace, upperCaseGreen);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.ContainAny.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]ContainAny specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class ContainAny\n {\n [Fact]\n public void When_containment_of_any_string_in_a_null_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().ContainAny(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*null*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_containment_of_any_string_in_an_empty_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().ContainAny();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*empty*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_and_all_of_the_strings_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act / Assert\n testString.Should().ContainAny(red, green, yellow);\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_and_only_some_of_the_strings_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string blue = \"blue\";\n var testString = $\"{red} {green}\";\n\n // Act / Assert\n testString.Should().ContainAny(red, blue, green);\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_and_none_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string blue = \"blue\";\n const string purple = \"purple\";\n var testString = $\"{red} {green}\";\n\n // Act\n Action act = () => testString.Should().ContainAny(blue, purple);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain at least one of*{blue}*{purple}*\");\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_and_there_are_equivalent_but_not_exact_matches_it_should_throw()\n {\n // Arrange\n const string redLowerCase = \"red\";\n const string redUpperCase = \"RED\";\n const string greenWithoutWhitespace = \"green\";\n const string greenWithWhitespace = \" green\";\n var testString = $\"{redLowerCase} {greenWithoutWhitespace}\";\n\n // Act\n Action act = () => testString.Should().ContainAny(redUpperCase, greenWithWhitespace);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain at least one of*{redUpperCase}*{greenWithWhitespace}*\");\n }\n\n [Fact]\n public void\n When_containment_of_any_string_in_a_collection_is_asserted_with_reason_and_assertion_fails_then_failure_message_contains_reason()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string blue = \"blue\";\n const string purple = \"purple\";\n var testString = $\"{red} {green}\";\n\n // Act\n Action act = () => testString.Should().ContainAny([blue, purple], \"some {0} reason\", \"special\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*{testString}*contain at least one of*{blue}*{purple}*because some special reason*\");\n }\n }\n\n public class NotContainAny\n {\n [Fact]\n public void When_exclusion_of_any_string_in_null_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().NotContainAny(null);\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*null*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_exclusion_of_any_string_in_an_empty_collection_is_asserted_it_should_throw_an_argument_exception()\n {\n // Act\n Action act = () => \"a\".Should().NotContainAny();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot*containment*empty*\")\n .WithParameterName(\"values\");\n }\n\n [Fact]\n public void When_exclusion_of_any_string_in_a_collection_is_asserted_and_all_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAny(red, green, yellow);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain any*{red}*{green}*{yellow}*\");\n }\n\n [Fact]\n public void\n When_exclusion_of_any_string_in_a_collection_is_asserted_and_only_some_of_the_strings_are_present_it_should_throw()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string purple = \"purple\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAny(red, purple, green);\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain any*{red}*{green}*\");\n }\n\n [Fact]\n public void When_exclusion_of_any_strings_is_asserted_with_reason_and_assertion_fails_then_error_message_contains_reason()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n var testString = $\"{red} {green} {yellow}\";\n\n // Act\n Action act = () => testString.Should().NotContainAny([red], \"some {0} reason\", \"special\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage($\"*not*{testString}*contain any*{red}*because*some special reason*\");\n }\n\n [Fact]\n public void\n When_exclusion_of_any_string_in_a_collection_is_asserted_and_there_are_equivalent_but_not_exact_matches_it_should_succeed()\n {\n // Arrange\n const string redLowerCase = \"red\";\n const string redUpperCase = \"RED\";\n const string greenWithoutWhitespace = \"green\";\n const string greenWithWhitespace = \" green \";\n var testString = $\"{redLowerCase} {greenWithoutWhitespace}\";\n\n // Act / Assert\n testString.Should().NotContainAny(redUpperCase, greenWithWhitespace);\n }\n\n [Fact]\n public void\n When_exclusion_of_any_string_in_a_collection_is_asserted_and_none_of_the_strings_are_present_it_should_succeed()\n {\n // Arrange\n const string red = \"red\";\n const string green = \"green\";\n const string yellow = \"yellow\";\n const string purple = \"purple\";\n var testString = $\"{red} {green}\";\n\n // Act / Assert\n testString.Should().NotContainAny(yellow, purple);\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AggregateExceptionExtractor.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Specialized;\n\nnamespace AwesomeAssertions;\n\npublic class AggregateExceptionExtractor : IExtractExceptions\n{\n public IEnumerable OfType(Exception actualException)\n where T : Exception\n {\n if (typeof(T).IsSameOrInherits(typeof(AggregateException)))\n {\n return actualException is T exception ? [exception] : [];\n }\n\n return GetExtractedExceptions(actualException);\n }\n\n private static List GetExtractedExceptions(Exception actualException)\n where T : Exception\n {\n var exceptions = new List();\n\n if (actualException is AggregateException aggregateException)\n {\n AggregateException flattenedExceptions = aggregateException.Flatten();\n\n exceptions.AddRange(flattenedExceptions.InnerExceptions.OfType());\n }\n else if (actualException is T genericException)\n {\n exceptions.Add(genericException);\n }\n\n return exceptions;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.SatisfyRespectively.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class SatisfyRespectively\n {\n [Fact]\n public void When_string_collection_satisfies_all_inspectors_it_should_succeed()\n {\n // Arrange\n string[] collection = [\"John\", \"Jane\"];\n\n // Act / Assert\n collection.Should().SatisfyRespectively(\n value => value.Should().Be(\"John\"),\n value => value.Should().Be(\"Jane\")\n );\n }\n\n [Fact]\n public void When_string_collection_does_not_satisfy_all_inspectors_it_should_throw()\n {\n // Arrange\n string[] collection = [\"Jack\", \"Jessica\"];\n\n // Act\n Action act = () => collection.Should().SatisfyRespectively(new Action[]\n {\n value => value.Should().Be(\"John\"),\n value => value.Should().Be(\"Jane\")\n }, \"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\"\"\"\n Expected collection to satisfy all inspectors because we want to test the failure message, but some inspectors are not satisfied\n *Jack*John\n *Jessica*Jane*\n \"\"\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.MatchEquivalentOf.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]MatchEquivalentOf specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class MatchEquivalentOf\n {\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_match_another()\n {\n // Arrange\n string actual = \"test\";\n string expect = \"T*T\";\n\n // Act / Assert\n actual.Should().MatchEquivalentOf(expect, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_match_another()\n {\n // Arrange\n string actual = \" test\";\n string expect = \"t*t\";\n\n // Act / Assert\n actual.Should().MatchEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_match_another()\n {\n // Arrange\n string actual = \"test \";\n string expect = \"t*t\";\n\n // Act / Assert\n actual.Should().MatchEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_match_another()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n\";\n string expect = \"\\nA\\r\\n?\\nC\\r\";\n\n // Act / Assert\n actual.Should().MatchEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n }\n\n [Fact]\n public void When_a_string_does_not_match_the_equivalent_of_a_wildcard_pattern_it_should_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act\n Action act = () => subject.Should().MatchEquivalentOf(\"h*earth!\", \"that's the universal greeting\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected subject to match the equivalent of*\\\"h*earth!\\\" \" +\n \"because that's the universal greeting, but*\\\"hello world!\\\" does not.\");\n }\n\n [Fact]\n public void When_a_string_does_match_the_equivalent_of_a_wildcard_pattern_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello world!\";\n\n // Act / Assert\n subject.Should().MatchEquivalentOf(\"h*WORLD?\");\n }\n\n [Fact]\n public void When_a_string_with_newline_matches_the_equivalent_of_a_wildcard_pattern_it_should_not_throw()\n {\n // Arrange\n string subject = \"hello\\r\\nworld!\";\n\n // Act / Assert\n subject.Should().MatchEquivalentOf(\"helloworld!\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_the_equivalent_of_null_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().MatchEquivalentOf(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a wildcard pattern or use the BeNull method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void When_a_string_is_matched_against_the_equivalent_of_an_empty_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().MatchEquivalentOf(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the BeEmpty method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n }\n\n public class NotMatchEquivalentOf\n {\n [Fact]\n public void Can_ignore_casing_while_checking_a_string_to_not_match_another()\n {\n // Arrange\n string actual = \"test\";\n string expect = \"T*T\";\n\n // Act\n Action act = () => actual.Should().NotMatchEquivalentOf(expect, o => o.IgnoringCase());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_checking_a_string_to_not_match_another()\n {\n // Arrange\n string actual = \" test\";\n string expect = \"t*t\";\n\n // Act\n Action act = () => actual.Should().NotMatchEquivalentOf(expect, o => o.IgnoringLeadingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_checking_a_string_to_not_match_another()\n {\n // Arrange\n string actual = \"test \";\n string expect = \"t*t\";\n\n // Act\n Action act = () => actual.Should().NotMatchEquivalentOf(expect, o => o.IgnoringTrailingWhitespace());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_checking_a_string_to_not_match_another()\n {\n // Arrange\n string actual = \"\\rA\\nB\\r\\nC\\n\";\n string expect = \"\\nA\\r\\n?\\nC\\r\";\n\n // Act\n Action act = () => actual.Should().NotMatchEquivalentOf(expect, o => o.IgnoringNewlineStyle());\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_string_is_not_equivalent_to_a_pattern_and_that_is_expected_it_should_not_throw()\n {\n // Arrange\n string subject = \"Hello Earth\";\n\n // Act / Assert\n subject.Should().NotMatchEquivalentOf(\"*World*\");\n }\n\n [Fact]\n public void When_a_string_does_match_the_equivalent_of_a_pattern_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello WORLD\";\n\n // Act\n Action act = () => subject.Should().NotMatchEquivalentOf(\"*world*\", \"because that's illegal\");\n\n // Assert\n act\n .Should().Throw()\n .WithMessage(\"Did not expect subject to match the equivalent of*\\\"*world*\\\" because that's illegal, \" +\n \"but*\\\"hello WORLD\\\" matches.\");\n }\n\n [Fact]\n public void When_a_string_with_newlines_does_match_the_equivalent_of_a_pattern_but_it_shouldnt_it_should_throw()\n {\n // Arrange\n string subject = \"hello\\r\\nworld!\";\n\n // Act\n Action act = () => subject.Should().NotMatchEquivalentOf(\"helloworld!\");\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void\n When_a_string_is_negatively_matched_against_the_equivalent_of_null_pattern_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatchEquivalentOf(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\"Cannot match string against . Provide a wildcard pattern or use the NotBeNull method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void\n When_a_string_is_negatively_matched_against_the_equivalent_of_an_empty_string_it_should_throw_with_a_clear_explanation()\n {\n // Arrange\n string subject = \"hello world\";\n\n // Act\n Action act = () => subject.Should().NotMatchEquivalentOf(string.Empty);\n\n // Assert\n act.Should().ThrowExactly()\n .WithMessage(\n \"Cannot match string against an empty string. Provide a wildcard pattern or use the NotBeEmpty method.*\")\n .WithParameterName(\"wildcardPattern\");\n }\n\n [Fact]\n public void Does_not_treat_escaped_newlines_as_newlines()\n {\n // Arrange\n string actual = \"te\\r\\nst\";\n string expect = \"te\\\\r\\\\nst\";\n\n // Act / Assert\n actual.Should().NotMatchEquivalentOf(expect);\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/AggregateExceptionAssertionSpecs.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class AggregateExceptionAssertionSpecs\n{\n [Fact]\n public void When_the_expected_exception_is_wrapped_it_should_succeed()\n {\n // Arrange\n var exception = new AggregateException(\n new InvalidOperationException(\"Ignored\"),\n new XunitException(\"Background\"));\n\n // Act\n Action act = () => throw exception;\n\n // Assert\n act.Should().Throw().WithMessage(\"Background\");\n }\n\n [Fact]\n public void When_the_expected_exception_was_not_thrown_it_should_report_the_actual_exceptions()\n {\n // Arrange\n Action throwingOperation = () =>\n {\n throw new AggregateException(\n new InvalidOperationException(\"You can't do this\"),\n new NullReferenceException(\"Found a null\"));\n };\n\n // Act\n Action act = () => throwingOperation\n .Should().Throw()\n .WithMessage(\"Something I expected\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*InvalidOperation*You can't do this*\")\n .WithMessage(\"*NullReferenceException*Found a null*\");\n }\n\n [Fact]\n public void When_no_exception_was_expected_it_should_report_the_actual_exceptions()\n {\n // Arrange\n Action throwingOperation = () =>\n {\n throw new AggregateException(\n new InvalidOperationException(\"You can't do this\"),\n new NullReferenceException(\"Found a null\"));\n };\n\n // Act\n Action act = () => throwingOperation.Should().NotThrow();\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"*InvalidOperation*You can't do this*\")\n .WithMessage(\"*NullReferenceException*Found a null*\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeNullOrEmpty.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeNullOrEmpty specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeNullOrEmpty\n {\n [Fact]\n public void When_a_null_string_is_expected_to_be_null_or_empty_it_should_not_throw()\n {\n // Arrange\n string str = null;\n\n // Act / Assert\n str.Should().BeNullOrEmpty();\n }\n\n [Fact]\n public void When_an_empty_string_is_expected_to_be_null_or_empty_it_should_not_throw()\n {\n // Arrange\n string str = \"\";\n\n // Act / Assert\n str.Should().BeNullOrEmpty();\n }\n\n [Fact]\n public void When_a_valid_string_is_expected_to_be_null_or_empty_it_should_throw()\n {\n // Arrange\n string str = \"hello\";\n\n // Act\n Action act = () => str.Should().BeNullOrEmpty(\"it was not initialized {0}\", \"yet\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected str to be or empty because it was not initialized yet, but found \\\"hello\\\".\");\n }\n }\n\n public class NotBeNullOrEmpty\n {\n [Fact]\n public void When_a_valid_string_is_expected_to_be_not_null_or_empty_it_should_not_throw()\n {\n // Arrange\n string str = \"Hello World\";\n\n // Act / Assert\n str.Should().NotBeNullOrEmpty();\n }\n\n [Fact]\n public void When_an_empty_string_is_not_expected_to_be_null_or_empty_it_should_throw()\n {\n // Arrange\n string str = \"\";\n\n // Act\n Action act = () => str.Should().NotBeNullOrEmpty(\"a valid string is expected for {0}\", \"str\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected str not to be or empty because a valid string is expected for str, but found \\\"\\\".\");\n }\n\n [Fact]\n public void When_a_null_string_is_not_expected_to_be_null_or_empty_it_should_throw()\n {\n // Arrange\n string str = null;\n\n // Act\n Action act = () => str.Should().NotBeNullOrEmpty(\"a valid string is expected for {0}\", \"str\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected str not to be or empty because a valid string is expected for str, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.HaveConstructor.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]HaveConstructor specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class HaveConstructor\n {\n [Fact]\n public void When_asserting_a_type_has_a_constructor_which_it_does_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act / Assert\n type.Should()\n .HaveConstructor([typeof(string)])\n .Which.Should().HaveAccessModifier(CSharpAccessModifier.Private);\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_constructor_which_it_does_not_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveConstructor([typeof(int), typeof(Type)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected constructor *ClassWithNoMembers(int, System.Type) to exist *failure message*\" +\n \", but it does not.\");\n }\n\n [Fact]\n public void When_subject_is_null_have_constructor_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().HaveConstructor([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor type(string) to exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_has_a_constructor_of_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().HaveConstructor(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n\n public class NotHaveConstructor\n {\n [Fact]\n public void When_asserting_a_type_does_not_have_a_constructor_which_it_does_not_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassWithNoMembers);\n\n // Act / Assert\n type.Should()\n .NotHaveConstructor([typeof(string)]);\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_constructor_which_it_does_it_fails()\n {\n // Arrange\n var type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveConstructor([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected constructor *.ClassWithMembers(string) not to exist *failure message*, but it does.\");\n }\n\n [Fact]\n public void When_subject_is_null_not_have_constructor_should_fail()\n {\n // Arrange\n Type type = null;\n\n // Act\n Action act = () =>\n type.Should().NotHaveConstructor([typeof(string)], \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Expected constructor type(string) not to exist *failure message*, but type is .\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_have_a_constructor_of_null_it_should_throw()\n {\n // Arrange\n Type type = typeof(ClassWithMembers);\n\n // Act\n Action act = () =>\n type.Should().NotHaveConstructor(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"parameterTypes\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeEmpty.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeEmpty specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_empty_string_to_be_empty()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().BeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_non_empty_string_to_be_empty()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_non_empty_string_to_be_empty()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected actual to be empty because we want to test the failure message, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void When_checking_for_an_empty_string_and_it_is_null_it_should_throw()\n {\n // Arrange\n string nullString = null;\n\n // Act\n Action act = () => nullString.Should().BeEmpty(\"because strings should never be {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected nullString to be empty because strings should never be null, but found .\");\n }\n }\n\n public class NotBeEmpty\n {\n [Fact]\n public void Should_succeed_when_asserting_non_empty_string_to_be_filled()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act / Assert\n actual.Should().NotBeEmpty();\n }\n\n [Fact]\n public void When_asserting_null_string_to_not_be_empty_it_should_succeed()\n {\n // Arrange\n string actual = null;\n\n // Act / Assert\n actual.Should().NotBeEmpty();\n }\n\n [Fact]\n public void Should_fail_when_asserting_empty_string_to_be_filled()\n {\n // Arrange\n string actual = \"\";\n\n // Act\n Action act = () => actual.Should().NotBeEmpty();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_empty_string_to_be_filled()\n {\n // Arrange\n string actual = \"\";\n\n // Act\n Action act = () => actual.Should().NotBeEmpty(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Did not expect actual to be empty because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensions/FluentTimeSpanExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Extensions;\n\n/// \n/// Extension methods on to allow for a more fluent way of specifying a .\n/// \n/// \n/// Instead of
\n///
\n/// TimeSpan.FromHours(12)
\n///
\n/// you can write
\n///
\n/// 12.Hours()
\n///
\n/// Or even
\n///
\n/// 12.Hours().And(30.Minutes()).\n///
\n/// \npublic static class FluentTimeSpanExtensions\n{\n /// \n /// Represents the number of ticks that are in 1 microsecond.\n /// \n public const long TicksPerMicrosecond = TimeSpan.TicksPerMillisecond / 1000;\n\n /// \n /// Represents the number of ticks that are in 1 nanosecond.\n /// \n public const double TicksPerNanosecond = TicksPerMicrosecond / 1000d;\n\n /// \n /// Returns a based on a number of ticks.\n /// \n public static TimeSpan Ticks(this int ticks)\n {\n return TimeSpan.FromTicks(ticks);\n }\n\n /// \n /// Returns a based on a number of ticks.\n /// \n public static TimeSpan Ticks(this long ticks)\n {\n return TimeSpan.FromTicks(ticks);\n }\n\n /// \n /// Gets the nanoseconds component of the time interval represented by the current structure.\n /// \n public static int Nanoseconds(this TimeSpan self)\n {\n return (int)((self.Ticks % TicksPerMicrosecond) * (1d / TicksPerNanosecond));\n }\n\n /// \n /// Returns a based on a number of nanoseconds.\n /// \n /// \n /// .NET's smallest resolutions is 100 nanoseconds. Any nanoseconds passed in\n /// lower than .NET's resolution will be rounded using the default rounding\n /// algorithm in Math.Round().\n /// \n public static TimeSpan Nanoseconds(this int nanoseconds)\n {\n return ((long)Math.Round(nanoseconds * TicksPerNanosecond)).Ticks();\n }\n\n /// \n /// Returns a based on a number of nanoseconds.\n /// \n /// \n /// .NET's smallest resolutions is 100 nanoseconds. Any nanoseconds passed in\n /// lower than .NET's resolution will be rounded using the default rounding\n /// algorithm in Math.Round().\n /// \n public static TimeSpan Nanoseconds(this long nanoseconds)\n {\n return ((long)Math.Round(nanoseconds * TicksPerNanosecond)).Ticks();\n }\n\n /// \n /// Gets the value of the current structure expressed in whole and fractional nanoseconds.\n /// \n public static double TotalNanoseconds(this TimeSpan self)\n {\n return self.Ticks * (1d / TicksPerNanosecond);\n }\n\n /// \n /// Gets the microseconds component of the time interval represented by the current structure.\n /// \n public static int Microseconds(this TimeSpan self)\n {\n return (int)((self.Ticks % TimeSpan.TicksPerMillisecond) * (1d / TicksPerMicrosecond));\n }\n\n /// \n /// Returns a based on a number of microseconds.\n /// \n public static TimeSpan Microseconds(this int microseconds)\n {\n return (microseconds * TicksPerMicrosecond).Ticks();\n }\n\n /// \n /// Returns a based on a number of microseconds.\n /// \n public static TimeSpan Microseconds(this long microseconds)\n {\n return (microseconds * TicksPerMicrosecond).Ticks();\n }\n\n /// \n /// Gets the value of the current structure expressed in whole and fractional microseconds.\n /// \n public static double TotalMicroseconds(this TimeSpan self)\n {\n return self.Ticks * (1d / TicksPerMicrosecond);\n }\n\n /// \n /// Returns a based on a number of milliseconds.\n /// \n public static TimeSpan Milliseconds(this int milliseconds)\n {\n return TimeSpan.FromMilliseconds(milliseconds);\n }\n\n /// \n /// Returns a based on a number of milliseconds.\n /// \n public static TimeSpan Milliseconds(this double milliseconds)\n {\n return TimeSpan.FromMilliseconds(milliseconds);\n }\n\n /// \n /// Returns a based on a number of seconds.\n /// \n public static TimeSpan Seconds(this int seconds)\n {\n return TimeSpan.FromSeconds(seconds);\n }\n\n /// \n /// Returns a based on a number of seconds.\n /// \n public static TimeSpan Seconds(this double seconds)\n {\n return TimeSpan.FromSeconds(seconds);\n }\n\n /// \n /// Returns a based on a number of seconds, and add the specified\n /// .\n /// \n public static TimeSpan Seconds(this int seconds, TimeSpan offset)\n {\n return TimeSpan.FromSeconds(seconds).Add(offset);\n }\n\n /// \n /// Returns a based on a number of minutes.\n /// \n public static TimeSpan Minutes(this int minutes)\n {\n return TimeSpan.FromMinutes(minutes);\n }\n\n /// \n /// Returns a based on a number of minutes.\n /// \n public static TimeSpan Minutes(this double minutes)\n {\n return TimeSpan.FromMinutes(minutes);\n }\n\n /// \n /// Returns a based on a number of minutes, and add the specified\n /// .\n /// \n public static TimeSpan Minutes(this int minutes, TimeSpan offset)\n {\n return TimeSpan.FromMinutes(minutes).Add(offset);\n }\n\n /// \n /// Returns a based on a number of hours.\n /// \n public static TimeSpan Hours(this int hours)\n {\n return TimeSpan.FromHours(hours);\n }\n\n /// \n /// Returns a based on a number of hours.\n /// \n public static TimeSpan Hours(this double hours)\n {\n return TimeSpan.FromHours(hours);\n }\n\n /// \n /// Returns a based on a number of hours, and add the specified\n /// .\n /// \n public static TimeSpan Hours(this int hours, TimeSpan offset)\n {\n return TimeSpan.FromHours(hours).Add(offset);\n }\n\n /// \n /// Returns a based on a number of days.\n /// \n public static TimeSpan Days(this int days)\n {\n return TimeSpan.FromDays(days);\n }\n\n /// \n /// Returns a based on a number of days.\n /// \n public static TimeSpan Days(this double days)\n {\n return TimeSpan.FromDays(days);\n }\n\n /// \n /// Returns a based on a number of days, and add the specified\n /// .\n /// \n public static TimeSpan Days(this int days, TimeSpan offset)\n {\n return TimeSpan.FromDays(days).Add(offset);\n }\n\n /// \n /// Convenience method for chaining multiple calls to the methods provided by this class.\n /// \n /// \n /// 23.Hours().And(59.Minutes())\n /// \n public static TimeSpan And(this TimeSpan sourceTime, TimeSpan offset)\n {\n return sourceTime.Add(offset);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeUpperCased.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeUpperCased specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeUpperCased\n {\n [Fact]\n public void Upper_case_characters_are_okay()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act / Assert\n actual.Should().BeUpperCased();\n }\n\n [Fact]\n public void The_empty_string_is_okay()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().BeUpperCased();\n }\n\n [Fact]\n public void A_lower_case_string_is_not_okay()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act\n Action act = () => actual.Should().BeUpperCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Upper_case_and_caseless_characters_are_ok()\n {\n // Arrange\n string actual = \"A1!\";\n\n // Act / Assert\n actual.Should().BeUpperCased();\n }\n\n [Fact]\n public void Caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"1!漢字\";\n\n // Act / Assert\n actual.Should().BeUpperCased();\n }\n\n [Fact]\n public void The_assertion_fails_with_a_descriptive_message()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act\n Action act = () => actual.Should().BeUpperCased(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected all alphabetic characters in actual to be upper-case because we want to test the failure message, but found \\\"abc\\\".\");\n }\n\n [Fact]\n public void The_null_string_is_not_okay()\n {\n // Arrange\n string nullString = null;\n\n // Act\n Action act = () => nullString.Should().BeUpperCased(\"because strings should never be {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected all alphabetic characters in nullString to be upper-case because strings should never be null, but found .\");\n }\n }\n\n public class NotBeUpperCased\n {\n [Fact]\n public void A_mixed_case_string_is_okay()\n {\n // Arrange\n string actual = \"aBc\";\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void The_null_string_is_okay()\n {\n // Arrange\n string actual = null;\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void The_empty_string_is_okay()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void A_string_of_all_upper_case_characters_is_not_okay()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().NotBeUpperCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Upper_case_characters_with_lower_case_characters_are_okay()\n {\n // Arrange\n string actual = \"Ab1!\";\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void All_cased_characters_being_upper_case_is_not_okay()\n {\n // Arrange\n string actual = \"A1B!\";\n\n // Act\n Action act = () => actual.Should().NotBeUpperCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"1!漢字\";\n\n // Act / Assert\n actual.Should().NotBeUpperCased();\n }\n\n [Fact]\n public void The_assertion_fails_with_a_descriptive_message()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().NotBeUpperCased(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected some characters in actual to be lower-case because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/StringAssertionSpecs.BeLowerCased.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\n/// \n/// The [Not]BeLowerCased specs.\n/// \npublic partial class StringAssertionSpecs\n{\n public class BeLowerCased\n {\n [Fact]\n public void Lower_case_characters_are_okay()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act / Assert\n actual.Should().BeLowerCased();\n }\n\n [Fact]\n public void The_empty_string_is_okay()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().BeLowerCased();\n }\n\n [Fact]\n public void Upper_case_characters_are_not_okay()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeLowerCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void A_mixed_case_string_is_not_okay()\n {\n // Arrange\n string actual = \"AbC\";\n\n // Act\n Action act = () => actual.Should().BeLowerCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Lower_case_and_caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"a1!\";\n\n // Act / Assert\n actual.Should().BeLowerCased();\n }\n\n [Fact]\n public void Caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"1!漢字\";\n\n // Act / Assert\n actual.Should().BeLowerCased();\n }\n\n [Fact]\n public void The_assertion_fails_with_a_descriptive_message()\n {\n // Arrange\n string actual = \"ABC\";\n\n // Act\n Action act = () => actual.Should().BeLowerCased(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected all alphabetic characters in actual to be lower cased because we want to test the failure message, but found \\\"ABC\\\".\");\n }\n\n [Fact]\n public void The_null_string_is_not_okay()\n {\n // Arrange\n string nullString = null;\n\n // Act\n Action act = () => nullString.Should().BeLowerCased(\"because strings should never be {0}\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected all alphabetic characters in nullString to be lower cased because strings should never be null, but found .\");\n }\n }\n\n public class NotBeLowerCased\n {\n [Fact]\n public void A_mixed_case_string_is_okay()\n {\n // Arrange\n string actual = \"AbC\";\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void The_null_string_is_okay()\n {\n // Arrange\n string actual = null;\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void The_empty_string_is_okay()\n {\n // Arrange\n string actual = \"\";\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void A_lower_case_string_is_not_okay()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act\n Action act = () => actual.Should().NotBeLowerCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Lower_case_characters_with_upper_case_characters_are_okay()\n {\n // Arrange\n string actual = \"Ab1!\";\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void All_cased_characters_being_lower_case_is_not_okay()\n {\n // Arrange\n string actual = \"a1b!\";\n\n // Act\n Action act = () => actual.Should().NotBeLowerCased();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Caseless_characters_are_okay()\n {\n // Arrange\n string actual = \"1!漢字\";\n\n // Act / Assert\n actual.Should().NotBeLowerCased();\n }\n\n [Fact]\n public void The_assertion_fails_with_a_descriptive_message()\n {\n // Arrange\n string actual = \"abc\";\n\n // Act\n Action act = () => actual.Should().NotBeLowerCased(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected some characters in actual to be upper-case because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.HaveSameCount.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class HaveSameCount\n {\n [Fact]\n public void When_dictionary_and_collection_have_the_same_number_elements_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 5, 6];\n\n // Act / Assert\n dictionary.Should().HaveSameCount(collection);\n }\n\n [Fact]\n public void When_dictionary_and_collection_do_not_have_the_same_number_of_elements_it_should_fail()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 6];\n\n // Act\n Action act = () => dictionary.Should().HaveSameCount(collection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to have 2 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_comparing_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 6];\n\n // Act\n Action act = () => dictionary.Should().HaveSameCount(collection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to have 2 item(s) because we want to test the reason, but found 3.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_and_collection_have_same_count_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => dictionary.Should().HaveSameCount(collection,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to have the same count as {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_dictionary_and_collection_have_same_count_against_a_null_collection_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = null;\n\n // Act\n Action act = () => dictionary.Should().HaveSameCount(collection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n }\n\n public class NotHaveSameCount\n {\n [Fact]\n public void When_asserting_not_same_count_and_collections_have_different_number_elements_it_should_succeed()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 6];\n\n // Act / Assert\n dictionary.Should().NotHaveSameCount(collection);\n }\n\n [Fact]\n public void When_asserting_not_same_count_and_both_collections_have_the_same_number_elements_it_should_fail()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 5, 6];\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not have 3 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_comparing_not_same_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = [4, 5, 6];\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not have 3 item(s) because we want to test the reason, but found 3.\");\n }\n\n [Fact]\n public void When_asserting_dictionary_and_collection_to_not_have_same_count_against_null_dictionary_it_should_throw()\n {\n // Arrange\n Dictionary dictionary = null;\n int[] collection = [1, 2, 3];\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected dictionary to not have the same count as {1, 2, 3} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_asserting_dictionary_and_collection_to_not_have_same_count_against_a_null_collection_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n int[] collection = null;\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n\n [Fact]\n public void\n When_asserting_dictionary_and_collection_to_not_have_same_count_but_both_reference_the_same_object_it_should_throw()\n {\n // Arrange\n var dictionary = new Dictionary\n {\n [1] = \"One\",\n [2] = \"Two\",\n [3] = \"Three\"\n };\n\n var collection = dictionary;\n\n // Act\n Action act = () => dictionary.Should().NotHaveSameCount(collection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not have the same count*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/Nested.cs", "namespace Benchmarks;\n\npublic sealed class Nested\n{\n public int A { get; set; }\n\n public Nested B { get; set; }\n\n public Nested C { get; set; }\n\n#pragma warning disable AV1562 // Don't use `ref` or `out` parameters: Keep benchmark as it was\n public static Nested Create(int i, ref int objectCount)\n#pragma warning restore AV1562\n {\n if (i < 0)\n {\n return null;\n }\n\n if (i == 0)\n {\n return new Nested();\n }\n\n return new Nested\n {\n A = ++objectCount,\n B = Create(i - 1, ref objectCount),\n C = Create(i - 2, ref objectCount),\n };\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.HaveSameCount.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class HaveSameCount\n {\n [Fact]\n public void When_asserting_collections_to_have_same_count_against_an_other_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = null;\n\n // Act\n Action act = () => collection.Should().HaveSameCount(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n\n [Fact]\n public void When_asserting_collections_to_have_same_count_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveSameCount(collection1,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have the same count as {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_both_collections_do_not_have_the_same_number_of_elements_it_should_fail()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"six\"];\n\n // Act\n Action act = () => firstCollection.Should().HaveSameCount(secondCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to have 2 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_both_collections_have_the_same_number_elements_it_should_succeed()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"five\", \"six\"];\n\n // Act / Assert\n firstCollection.Should().HaveSameCount(secondCollection);\n }\n\n [Fact]\n public void When_comparing_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"six\"];\n\n // Act\n Action act = () => firstCollection.Should().HaveSameCount(secondCollection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to have 2 item(s) because we want to test the reason, but found 3.\");\n }\n }\n\n public class NotHaveSameCount\n {\n [Fact]\n public void When_asserting_collections_to_not_have_same_count_against_an_other_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = null;\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(otherCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify count against a collection.*\");\n }\n\n [Fact]\n public void When_asserting_collections_to_not_have_same_count_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n IEnumerable collection1 = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(collection1,\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to not have the same count as {\\\"one\\\", \\\"two\\\", \\\"three\\\"} because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void\n When_asserting_collections_to_not_have_same_count_but_both_collections_references_the_same_object_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n IEnumerable otherCollection = collection;\n\n // Act\n Action act = () => collection.Should().NotHaveSameCount(otherCollection,\n \"because we want to test the behaviour with same objects\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"*not have the same count*because we want to test the behaviour with same objects*but they both reference the same object.\");\n }\n\n [Fact]\n public void When_asserting_not_same_count_and_both_collections_have_the_same_number_elements_it_should_fail()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"five\", \"six\"];\n\n // Act\n Action act = () => firstCollection.Should().NotHaveSameCount(secondCollection);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to not have 3 item(s), but found 3.\");\n }\n\n [Fact]\n public void When_asserting_not_same_count_and_collections_have_different_number_elements_it_should_succeed()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"six\"];\n\n // Act / Assert\n firstCollection.Should().NotHaveSameCount(secondCollection);\n }\n\n [Fact]\n public void When_comparing_not_same_item_counts_and_a_reason_is_specified_it_should_it_in_the_exception()\n {\n // Arrange\n IEnumerable firstCollection = [\"one\", \"two\", \"three\"];\n IEnumerable secondCollection = [\"four\", \"five\", \"six\"];\n\n // Act\n Action act = () => firstCollection.Should().NotHaveSameCount(secondCollection, \"we want to test the {0}\", \"reason\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected firstCollection to not have 3 item(s) because we want to test the reason, but found 3.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.NotContainItemsAssignableTo.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class CollectionAssertionSpecs\n{\n public class NotContainItemsAssignableTo\n {\n [Fact]\n public void Succeeds_when_the_collection_does_not_contain_items_of_the_unexpected_type()\n {\n // Arrange\n string[] collection = [\"1\", \"2\", \"3\"];\n\n // Act / Assert\n collection.Should().NotContainItemsAssignableTo();\n }\n\n [Fact]\n public void Throws_when_the_collection_contains_an_item_of_the_unexpected_type()\n {\n // Arrange\n var collection = new object[] { 1, \"2\", \"3\" };\n\n // Act\n var act = () => collection\n .Should()\n .NotContainItemsAssignableTo(\n \"because we want test that collection does not contain object of {0} type\", typeof(int));\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\n \"Expected collection to not contain any elements assignable to type int \" +\n \"because we want test that collection does not contain object of System.Int32 type, \" +\n \"but found {int, string, string}.\");\n }\n\n [Fact]\n public void Succeeds_when_collection_is_empty()\n {\n // Arrange\n int[] collection = [];\n\n // Act / Assert\n collection.Should().NotContainItemsAssignableTo();\n }\n\n [Fact]\n public void Throws_when_the_passed_type_argument_is_null()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act\n var act = () => collection.Should().NotContainItemsAssignableTo(null);\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Succeed_when_type_as_parameter_is_valid_type()\n {\n // Arrange\n int[] collection = [1, 2, 3];\n\n // Act / Assert\n collection.Should().NotContainItemsAssignableTo(typeof(string));\n }\n\n [Fact]\n public void Throws_when_the_collection_is_null()\n {\n // Arrange\n int[] collection = null;\n\n // Act\n var act = () => collection.Should().NotContainItemsAssignableTo();\n\n // Assert\n act.Should()\n .Throw()\n .WithMessage(\n \"Expected collection to not contain any elements assignable to type int, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeNull.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_null_object_to_be_null()\n {\n // Arrange\n object someObject = null;\n\n // Act / Assert\n someObject.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_non_null_object_to_be_null()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void When_a_non_null_object_is_expected_to_be_null_it_should_fail()\n {\n // Arrange\n var someObject = new object();\n\n // Act\n Action act = () => someObject.Should().BeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act\n .Should().Throw()\n .Where(e => e.Message.StartsWith(\n \"Expected someObject to be because we want to test the failure message, but found System.Object\",\n StringComparison.Ordinal));\n }\n }\n\n public class BeNotNull\n {\n [Fact]\n public void Should_succeed_when_asserting_non_null_object_not_to_be_null()\n {\n // Arrange\n var someObject = new object();\n\n // Act / Assert\n someObject.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_null_object_not_to_be_null()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () => someObject.Should().NotBeNull();\n\n // Assert\n act.Should().Throw();\n }\n\n [Fact]\n public void Should_fail_with_descriptive_message_when_asserting_null_object_not_to_be_null()\n {\n // Arrange\n object someObject = null;\n\n // Act\n Action act = () => someObject.Should().NotBeNull(\"because we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someObject not to be because we want to test the failure message.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Specialized/ActionAssertionSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Specialized;\n\npublic class ActionAssertionSpecs\n{\n [Fact]\n public void Null_clock_throws_exception()\n {\n // Arrange\n Action subject = () => { };\n\n // Act\n var act = void () => subject.Should(clock: null).NotThrow();\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"clock\");\n }\n\n public class Throw\n {\n [Fact]\n public void Allow_additional_assertions_on_return_value()\n {\n // Arrange\n var exception = new Exception(\"foo\");\n Action subject = () => throw exception;\n\n // Act / Assert\n subject.Should().Throw()\n .Which.Message.Should().Be(\"foo\");\n }\n }\n\n public class NotThrow\n {\n [Fact]\n public void Allow_additional_assertions_on_return_value()\n {\n // Arrange\n Action subject = () => { };\n\n // Act / Assert\n subject.Should().NotThrow()\n .And.NotBeNull();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.cs", "using System;\nusing System.Globalization;\n\nnamespace AwesomeAssertions.Specs.Types\n{\n /// \n /// Type assertion specs.\n /// \n public partial class TypeAssertionSpecs;\n\n #region Internal classes used in unit tests\n\n [DummyClass(\"Expected\", true)]\n public class ClassWithAttribute;\n\n public class ClassWithInheritedAttribute : ClassWithAttribute;\n\n public class ClassWithoutAttribute;\n\n public class OtherClassWithoutAttribute;\n\n [AttributeUsage(AttributeTargets.Class)]\n public class DummyClassAttribute : Attribute\n {\n public string Name { get; }\n\n public bool IsEnabled { get; }\n\n public DummyClassAttribute(string name, bool isEnabled)\n {\n Name = name;\n IsEnabled = isEnabled;\n }\n }\n\n public interface IDummyInterface;\n\n public interface IDummyInterface;\n\n public class ClassThatImplementsInterface : IDummyInterface, IDummyInterface;\n\n public class ClassThatDoesNotImplementInterface;\n\n public class DummyBaseType : IDummyInterface;\n\n public class ClassWithGenericBaseType : DummyBaseType;\n\n public class ClassWithMembers\n {\n protected internal ClassWithMembers() { }\n\n private ClassWithMembers(string _) { }\n\n protected string PrivateWriteProtectedReadProperty { get => null; private set { } }\n\n internal string this[string str] { private get => str; set { } }\n\n protected internal string this[int i] { get => i.ToString(CultureInfo.InvariantCulture); private set { } }\n\n private void VoidMethod() { }\n\n private void VoidMethod(string _) { }\n }\n\n public class ClassExplicitlyImplementingInterface : IExplicitInterface\n {\n public string ImplicitStringProperty { get => null; private set { } }\n\n string IExplicitInterface.ExplicitStringProperty { set { } }\n\n public string ExplicitImplicitStringProperty { get; set; }\n\n string IExplicitInterface.ExplicitImplicitStringProperty { get; set; }\n\n public void ImplicitMethod() { }\n\n public void ImplicitMethod(string overload) { }\n\n void IExplicitInterface.ExplicitMethod() { }\n\n void IExplicitInterface.ExplicitMethod(string overload) { }\n\n public void ExplicitImplicitMethod() { }\n\n public void ExplicitImplicitMethod(string _) { }\n\n void IExplicitInterface.ExplicitImplicitMethod() { }\n\n void IExplicitInterface.ExplicitImplicitMethod(string overload) { }\n }\n\n public interface IExplicitInterface\n {\n string ImplicitStringProperty { get; }\n\n string ExplicitStringProperty { set; }\n\n string ExplicitImplicitStringProperty { get; set; }\n\n void ImplicitMethod();\n\n void ImplicitMethod(string overload);\n\n void ExplicitMethod();\n\n void ExplicitMethod(string overload);\n\n void ExplicitImplicitMethod();\n\n void ExplicitImplicitMethod(string overload);\n }\n\n public class ClassWithoutMembers;\n\n public interface IPublicInterface;\n\n internal interface IInternalInterface;\n\n internal class InternalClass;\n\n internal struct InternalStruct;\n\n internal enum InternalEnum\n {\n Value1,\n Value2\n }\n\n internal class Nested\n {\n private class PrivateClass;\n\n protected enum ProtectedEnum;\n\n public interface IPublicInterface;\n\n internal class InternalClass;\n\n protected internal interface IProtectedInternalInterface;\n }\n\n internal readonly struct TypeWithConversionOperators\n {\n private readonly int value;\n\n private TypeWithConversionOperators(int value)\n {\n this.value = value;\n }\n\n public static implicit operator int(TypeWithConversionOperators typeWithConversionOperators) =>\n typeWithConversionOperators.value;\n\n public static explicit operator byte(TypeWithConversionOperators typeWithConversionOperators) =>\n (byte)typeWithConversionOperators.value;\n }\n\n internal sealed class Sealed;\n\n internal abstract class Abstract;\n\n internal static class Static;\n\n internal struct Struct;\n\n public delegate void ExampleDelegate();\n\n internal class ClassNotInDummyNamespace;\n\n internal class OtherClassNotInDummyNamespace;\n\n internal class GenericClass;\n\n #endregion\n}\n\nnamespace AssemblyB\n{\n#pragma warning disable 436 // disable the warning on conflicting types, as this is the intention for the spec\n\n /// \n /// A class that intentionally has the exact same name and namespace as the ClassC from the AssemblyB\n /// assembly. This class is used to test the behavior of comparisons on such types.\n /// \n internal class ClassC;\n\n#pragma warning restore 436\n}\n\n#region Internal classes used in unit tests\n\nnamespace DummyNamespace\n{\n internal class ClassInDummyNamespace;\n\n namespace InnerDummyNamespace\n {\n internal class ClassInInnerDummyNamespace;\n }\n}\n\nnamespace DummyNamespaceTwo\n{\n internal class ClassInDummyNamespaceTwo;\n}\n\n#endregion\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/TaskCompletionSourceAssertionsBase.cs", "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Specialized;\n\n#pragma warning disable CS0659, S1206 // Ignore not overriding Object.GetHashCode()\n/// \n/// Implements base functionality for assertions on TaskCompletionSource.\n/// \npublic class TaskCompletionSourceAssertionsBase\n{\n protected TaskCompletionSourceAssertionsBase(IClock clock)\n {\n Clock = clock ?? throw new ArgumentNullException(nameof(clock));\n }\n\n private protected IClock Clock { get; }\n\n /// \n [SuppressMessage(\"Design\", \"CA1065:Do not raise exceptions in unexpected locations\")]\n public override bool Equals(object obj) =>\n throw new NotSupportedException(\"Equals is not part of Awesome Assertions. Did you mean CompleteWithinAsync() instead?\");\n\n /// \n /// Monitors the specified task whether it completes withing the remaining time span.\n /// \n private protected async Task CompletesWithinTimeoutAsync(Task target, TimeSpan remainingTime)\n {\n using var timeoutCancellationTokenSource = new CancellationTokenSource();\n\n Task completedTask =\n await Task.WhenAny(target, Clock.DelayAsync(remainingTime, timeoutCancellationTokenSource.Token));\n\n if (completedTask != target)\n {\n return false;\n }\n\n // cancel the clock\n#pragma warning disable CA1849 // Call async methods when in an async method: Is not a drop-in replacement in this case, but may cause problems.\n timeoutCancellationTokenSource.Cancel();\n#pragma warning restore CA1849 // Call async methods when in an async method\n return true;\n }\n}\n"], ["/AwesomeAssertions/Tests/ExampleExtensions/StringAssertionExtensions.cs", "using AwesomeAssertions;\nusing AwesomeAssertions.Primitives;\n\nnamespace ExampleExtensions;\n\npublic static class StringAssertionExtensions\n{\n public static void BePalindromic(this StringAssertions assertions)\n {\n char[] charArray = assertions.Subject.ToCharArray();\n Array.Reverse(charArray);\n string reversedSubject = new string(charArray);\n\n assertions.Subject.Should().Be(reversedSubject);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/EnumerableExtensions.cs", "using System.Collections.Generic;\nusing System.Text;\n\nnamespace AwesomeAssertions.Formatting;\n\ninternal static class EnumerableExtensions\n{\n internal static string JoinUsingWritingStyle(this IEnumerable items)\n {\n var buffer = new StringBuilder();\n\n T lastItem = default;\n bool first = true;\n\n foreach (var item in items)\n {\n if (first)\n {\n first = false;\n }\n else\n {\n if (buffer.Length > 0)\n {\n buffer.Append(\", \");\n }\n\n buffer.Append(lastItem);\n }\n\n lastItem = item;\n }\n\n if (buffer.Length > 0)\n {\n buffer.Append(\" and \");\n }\n\n buffer.Append(lastItem);\n\n return buffer.ToString();\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/CheckIfMemberIsBrowsableBenchmarks.cs", "using System.ComponentModel;\nusing System.Reflection;\nusing BenchmarkDotNet.Attributes;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\npublic class CheckIfMemberIsBrowsableBenchmarks\n{\n [Params(true, false)]\n public bool IsBrowsable { get; set; }\n\n public int BrowsableField;\n\n [EditorBrowsable(EditorBrowsableState.Never)]\n public int NonBrowsableField;\n\n public FieldInfo SubjectField => typeof(CheckIfMemberIsBrowsableBenchmarks)\n .GetField(IsBrowsable ? nameof(BrowsableField) : nameof(NonBrowsableField));\n\n [Benchmark]\n public bool CheckIfMemberIsBrowsable()\n {\n return SubjectField.GetCustomAttribute() is not { State: EditorBrowsableState.Never };\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.Contain.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class Contain\n {\n [Fact]\n public void When_a_collection_does_not_contain_another_collection_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain([\"three\", \"four\", \"five\"], \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to contain {\\\"three\\\", \\\"four\\\", \\\"five\\\"} because we do, but could not find {\\\"four\\\", \\\"five\\\"}.\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_single_item_it_should_throw_with_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain(\"four\", \"because {0}\", \"we do\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to contain \\\"four\\\" because we do.\");\n }\n\n [Fact]\n public void\n When_asserting_a_string_collection_contains_an_element_it_should_allow_specifying_the_reason_via_named_parameter()\n {\n // Arrange\n var expected = new List { \"hello\", \"world\" };\n var actual = new List { \"hello\", \"world\" };\n\n // Act / Assert\n actual.Should().Contain(expected, \"they are in the collection\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_an_item_from_the_collection_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().Contain(\"one\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_multiple_items_from_the_collection_in_any_order_it_should_succeed()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain([\"two\", \"one\"]);\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_the_contents_of_a_collection_are_checked_against_an_empty_collection_it_should_throw_clear_explanation()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain(new string[0]);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify containment against an empty collection*\");\n }\n\n [Fact]\n public void When_the_expected_object_exists_it_should_allow_chaining_additional_assertions()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().Contain(\"one\").Which.Should().HaveLength(4);\n\n // Assert\n act.Should().Throw().WithMessage(\"Expected*length*4*3*\");\n }\n }\n\n public class NotContain\n {\n [Fact]\n public void When_asserting_collection_does_not_contain_item_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should()\n .NotContain(\"one\", \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to not contain \\\"one\\\" because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_contains_an_unexpected_item_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContain(\"one\", \"because we {0} like it, but found it anyhow\", \"don't\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to not contain \\\"one\\\" because we don't like it, but found it anyhow.\");\n }\n\n [Fact]\n public void When_collection_does_contain_an_unexpected_item_matching_a_predicate_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContain(item => item == \"two\", \"because {0}s are evil\", \"two\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to not have any items matching (item == \\\"two\\\") because twos are evil,*{\\\"two\\\"}*\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_an_item_that_is_not_in_the_collection_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContain(\"four\");\n\n // Assert\n act.Should().NotThrow();\n }\n\n [Fact]\n public void When_collection_does_not_contain_an_unexpected_item_matching_a_predicate_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotContain(item => item == \"four\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Common/MemberInfoExtensions.cs", "using System;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Specs.Common;\n\ninternal static class MemberInfoExtensions\n{\n public static Type GetUnderlyingType(this MemberInfo member)\n {\n return member.MemberType switch\n {\n MemberTypes.Event => ((EventInfo)member).EventHandlerType,\n MemberTypes.Field => ((FieldInfo)member).FieldType,\n MemberTypes.Method => ((MethodInfo)member).ReturnType,\n MemberTypes.Property => ((PropertyInfo)member).PropertyType,\n _ => throw new ArgumentException(\n \"Input MemberInfo must be if type EventInfo, FieldInfo, MethodInfo, or PropertyInfo\")\n };\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Types/TypeAssertionSpecs.Implement.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Types;\n\n/// \n/// The [Not]Implement specs.\n/// \npublic partial class TypeAssertionSpecs\n{\n public class Implement\n {\n [Fact]\n public void When_asserting_a_type_implements_an_interface_which_it_does_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act / Assert\n type.Should().Implement(typeof(IDummyInterface));\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_implement_an_interface_which_it_does_then_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act\n Action act = () =>\n type.Should().Implement(typeof(IDummyInterface), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatDoesNotImplementInterface to implement interface *.IDummyInterface \" +\n \"*failure message*, but it does not.\");\n }\n\n [Fact]\n public void When_asserting_a_type_implements_a_NonInterface_type_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act\n Action act = () =>\n type.Should().Implement(typeof(DateTime), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatDoesNotImplementInterface to implement interface *.DateTime *failure message*\" +\n \", but *.DateTime is not an interface.\");\n }\n\n [Fact]\n public void When_asserting_a_type_to_implement_null_it_should_throw()\n {\n // Arrange\n var type = typeof(DummyBaseType<>);\n\n // Act\n Action act = () =>\n type.Should().Implement(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void An_interface_does_not_implement_itself()\n {\n // Arrange\n var type = typeof(IDummyInterface);\n\n // Act\n Action act = () =>\n type.Should().Implement(typeof(IDummyInterface));\n\n // Assert\n act.Should().Throw();\n }\n }\n\n public class ImplementOfT\n {\n [Fact]\n public void When_asserting_a_type_implementsOfT_an_interface_which_it_does_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act / Assert\n type.Should().Implement();\n }\n }\n\n public class NotImplement\n {\n [Fact]\n public void When_asserting_a_type_does_not_implement_an_interface_which_it_does_not_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act / Assert\n type.Should().NotImplement(typeof(IDummyInterface));\n }\n\n [Fact]\n public void When_asserting_a_type_implements_an_interface_which_it_does_not_then_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatImplementsInterface);\n\n // Act\n Action act = () =>\n type.Should().NotImplement(typeof(IDummyInterface), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatImplementsInterface to not implement interface *.IDummyInterface \" +\n \"*failure message*, but it does.\");\n }\n\n [Fact]\n public void When_asserting_a_type_does_not_implement_a_NonInterface_type_it_fails()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act\n Action act = () =>\n type.Should().NotImplement(typeof(DateTime), \"we want to test the failure {0}\", \"message\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"Expected type *.ClassThatDoesNotImplementInterface to not implement interface *.DateTime *failure message*\" +\n \", but *.DateTime is not an interface.\");\n }\n\n [Fact]\n public void When_asserting_a_type_not_to_implement_null_it_should_throw()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act\n Action act = () =>\n type.Should().NotImplement(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"interfaceType\");\n }\n\n [Fact]\n public void An_interface_does_not_implement_itself()\n {\n // Arrange\n var type = typeof(IDummyInterface);\n\n // Act / Assert\n type.Should().NotImplement(typeof(IDummyInterface));\n }\n }\n\n public class NotImplementOfT\n {\n [Fact]\n public void When_asserting_a_type_does_not_implementOfT_an_interface_which_it_does_not_then_it_succeeds()\n {\n // Arrange\n var type = typeof(ClassThatDoesNotImplementInterface);\n\n // Act / Assert\n type.Should().NotImplement();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.HaveElementAt.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class HaveElementAt\n {\n [Fact]\n public void When_asserting_collection_has_element_at_specific_index_against_null_collection_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().HaveElementAt(1, \"one\",\n \"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to have element at index 1 because we want to test the behaviour with a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_does_not_have_an_element_at_the_specific_index_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveElementAt(4, \"three\", \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected \\\"three\\\" at index 4 because we put it there, but found no element.\");\n }\n\n [Fact]\n public void When_collection_does_not_have_the_expected_element_at_specific_index_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().HaveElementAt(1, \"three\", \"we put it {0}\", \"there\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected \\\"three\\\" at index 1 because we put it there, but found \\\"two\\\".\");\n }\n\n [Fact]\n public void When_collection_has_expected_element_at_specific_index_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().HaveElementAt(1, \"two\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.ContainInOrder.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class ContainInOrder\n {\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"one\", \"three\", \"twelve\", \"two\", \"two\"];\n\n // Act\n Action act = () => collection.Should().ContainInOrder(\"one\", \"two\", \"one\", \"one\", \"two\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"one\\\", \\\"three\\\", \\\"twelve\\\", \\\"two\\\", \\\"two\\\"} to contain items {\\\"one\\\", \\\"two\\\", \\\"one\\\", \\\"one\\\", \\\"two\\\"} in order, but \\\"one\\\" (index 3) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { \"one\", \"two\", \"three\" }.Should().ContainInOrder([\"four\", \"one\"], \"we failed\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to contain items {\\\"four\\\", \\\"one\\\"} in order because we failed, \" +\n \"but \\\"four\\\" (index 0) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_asserting_collection_contains_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable strings = null;\n\n // Act\n Action act =\n () => strings.Should()\n .ContainInOrder([\"string4\"], \"because we're checking how it reacts to a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected strings to contain {\\\"string4\\\"} in order because we're checking how it reacts to a null subject, but found .\");\n }\n\n [Fact]\n public void When_collection_contains_null_value_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", null, \"two\", \"string\"];\n\n // Act / Assert\n collection.Should().ContainInOrder(\"one\", null, \"string\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_ordered_containment_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () => new[] { \"one\", \"two\", \"three\" }.Should().ContainInOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify ordered containment against a collection.*\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\", \"two\"];\n\n // Act / Assert\n collection.Should().ContainInOrder(\"one\", \"two\", \"three\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"one\", \"two\", \"twelve\", \"two\", \"two\"];\n\n // Act / Assert\n collection.Should().ContainInOrder(\"one\", \"two\", \"one\", \"two\", \"twelve\", \"two\", \"two\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_throw_with_a_clear_explanation()\n {\n // Act\n Action act = () =>\n new[] { \"one\", \"two\", \"three\" }.Should().ContainInOrder([\"three\", \"one\"], \"because we said so\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\"} to contain items {\\\"three\\\", \\\"one\\\"} in order because we said so, but \\\"one\\\" (index 1) did not appear (in the right order).\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_in_the_same_order_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().ContainInOrder(\"one\", \"two\", \"three\");\n }\n }\n\n public class NotContainInOrder\n {\n [Fact]\n public void When_two_collections_contain_the_same_items_but_in_different_order_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotContainInOrder(\"two\", \"one\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_an_ordered_item_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotContainInOrder(\"four\", \"one\");\n }\n\n [Fact]\n public void When_a_collection_contains_less_items_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\"];\n\n // Act / Assert\n collection.Should().NotContainInOrder(\"one\", \"two\", \"three\");\n }\n\n [Fact]\n public void When_a_collection_does_not_contain_a_range_twice_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"one\", \"three\", \"twelve\", \"two\", \"two\"];\n\n // Act / Assert\n collection.Should().NotContainInOrder(\"one\", \"two\", \"one\", \"one\", \"two\");\n }\n\n [Fact]\n public void When_asserting_collection_does_not_contain_some_values_in_order_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(\"four\");\n\n // Assert\n act.Should().Throw()\n .WithMessage(\"Cannot verify absence of ordered containment in a collection.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder([\"one\", \"two\", \"three\"], \"that's what we expect\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"two\\\", \\\"three\\\"} to not contain items {\\\"one\\\", \\\"two\\\", \\\"three\\\"} \" +\n \"in order because that's what we expect, but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_collection_contains_contain_the_same_items_in_the_same_order_with_null_value_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", null, \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(\"one\", null, \"three\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", , \\\"two\\\", \\\"three\\\"} to not contain items {\\\"one\\\", , \\\"three\\\"} in order, \" +\n \"but items appeared in order ending at index 3.\");\n }\n\n [Fact]\n public void When_the_first_collection_contains_a_duplicate_item_without_affecting_the_order_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\", \"two\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(\"one\", \"two\", \"three\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"three\\\", \\\"two\\\"} to not contain items {\\\"one\\\", \\\"two\\\", \\\"three\\\"} in order, \" +\n \"but items appeared in order ending at index 2.\");\n }\n\n [Fact]\n public void When_two_collections_contain_the_same_duplicate_items_in_the_same_order_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"one\", \"twelve\", \"two\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(\"one\", \"two\", \"one\", \"twelve\", \"two\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection {\\\"one\\\", \\\"two\\\", \\\"one\\\", \\\"twelve\\\", \\\"two\\\"} to not contain items \" +\n \"{\\\"one\\\", \\\"two\\\", \\\"one\\\", \\\"twelve\\\", \\\"two\\\"} in order, but items appeared in order ending at index 4.\");\n }\n\n [Fact]\n public void When_passing_in_null_while_checking_for_absence_of_ordered_containment_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act\n Action act = () => collection.Should().NotContainInOrder(null);\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Cannot verify absence of ordered containment against a collection.*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericDictionaryAssertionSpecs.BeNull.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericDictionaryAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void When_dictionary_is_expected_to_be_null_and_it_is_it_should_not_throw()\n {\n // Arrange\n IDictionary someDictionary = null;\n\n // Act / Assert\n someDictionary.Should().BeNull();\n }\n\n [Fact]\n public void When_dictionary_is_expected_to_be_null_and_it_isnt_it_should_throw()\n {\n // Arrange\n var someDictionary = new Dictionary();\n\n // Act\n Action act = () => someDictionary.Should().BeNull(\"because {0} is valid\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someDictionary to be because null is valid, but found {empty}.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_a_custom_dictionary_implementation_is_expected_not_to_be_null_and_it_is_it_should_not_throw()\n {\n // Arrange\n var dictionary = new TrackingTestDictionary();\n\n // Act / Assert\n dictionary.Should().NotBeNull();\n }\n\n [Fact]\n public void When_dictionary_is_not_expected_to_be_null_and_it_isnt_it_should_not_throw()\n {\n // Arrange\n IDictionary someDictionary = new Dictionary();\n\n // Act / Assert\n someDictionary.Should().NotBeNull();\n }\n\n [Fact]\n public void When_dictionary_is_not_expected_to_be_null_and_it_is_it_should_throw()\n {\n // Arrange\n IDictionary someDictionary = null;\n\n // Act\n Action act = () => someDictionary.Should().NotBeNull(\"because {0} should not\", \"someDictionary\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someDictionary not to be because someDictionary should not.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.NotContainNulls.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class NotContainNulls\n {\n [Fact]\n public void When_asserting_collection_to_not_contain_nulls_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because we want to test the behaviour with a null subject, but collection is .\");\n }\n\n [Fact]\n public void When_collection_contains_multiple_nulls_that_are_unexpected_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"\", null, \"\", null];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s*because they are evil*{1, 3}*\");\n }\n\n [Fact]\n public void When_collection_contains_nulls_that_are_unexpected_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"\", null];\n\n // Act\n Action act = () => collection.Should().NotContainNulls(\"because they are {0}\", \"evil\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection not to contain s because they are evil, but found one at index 1.\");\n }\n\n [Fact]\n public void When_collection_does_not_contain_nulls_it_should_not_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\"];\n\n // Act / Assert\n collection.Should().NotContainNulls();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.OnlyHaveUniqueItems.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class OnlyHaveUniqueItems\n {\n [Fact]\n public void Should_succeed_when_asserting_collection_with_unique_items_contains_only_unique_items()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\", \"four\"];\n\n // Act / Assert\n collection.Should().OnlyHaveUniqueItems();\n }\n\n [Fact]\n public void When_a_collection_contains_duplicate_items_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"three\", \"three\"];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(\"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we don't like duplicates, but item \\\"three\\\" is not unique.\");\n }\n\n [Fact]\n public void When_a_collection_contains_multiple_duplicate_items_it_should_throw()\n {\n // Arrange\n IEnumerable collection = [\"one\", \"two\", \"two\", \"three\", \"three\"];\n\n // Act\n Action act = () => collection.Should().OnlyHaveUniqueItems(\"{0} don't like {1}\", \"we\", \"duplicates\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we don't like duplicates, but items {\\\"two\\\", \\\"three\\\"} are not unique.\");\n }\n\n [Fact]\n public void When_asserting_collection_to_only_have_unique_items_but_collection_is_null_it_should_throw()\n {\n // Arrange\n IEnumerable collection = null;\n\n // Act\n Action act =\n () => collection.Should().OnlyHaveUniqueItems(\"because we want to test the behaviour with a null subject\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected collection to only have unique items because we want to test the behaviour with a null subject, but found .\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.BeNull.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class GenericCollectionAssertionOfStringSpecs\n{\n public class BeNull\n {\n [Fact]\n public void When_collection_is_expected_to_be_null_and_it_is_it_should_not_throw()\n {\n // Arrange\n IEnumerable someCollection = null;\n\n // Act / Assert\n someCollection.Should().BeNull();\n }\n\n [Fact]\n public void When_collection_is_expected_to_be_null_and_it_isnt_it_should_throw()\n {\n // Arrange\n IEnumerable someCollection = new string[0];\n\n // Act\n Action act = () => someCollection.Should().BeNull(\"because {0} is valid\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someCollection to be because null is valid, but found {empty}.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_collection_is_not_expected_to_be_null_and_it_is_it_should_throw()\n {\n // Arrange\n IEnumerable someCollection = null;\n\n // Act\n Action act = () => someCollection.Should().NotBeNull(\"because {0} should not\", \"someCollection\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someCollection not to be because someCollection should not.\");\n }\n\n [Fact]\n public void When_collection_is_not_expected_to_be_null_and_it_isnt_it_should_not_throw()\n {\n // Arrange\n IEnumerable someCollection = new string[0];\n\n // Act / Assert\n someCollection.Should().NotBeNull();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Types/AllTypes.cs", "using System.Reflection;\n\nnamespace AwesomeAssertions.Types;\n\n/// \n/// Static class that allows for a 'fluent' selection of the types from an .\n/// \n/// \n/// AllTypes.From(myAssembly)
\n/// .ThatImplement<ISomeInterface>
\n/// .Should()
\n/// .BeDecoratedWith<SomeAttribute>()\n///
\npublic static class AllTypes\n{\n /// \n /// Returns a for selecting the types that are visible outside the\n /// specified .\n /// \n /// The assembly from which to select the types.\n public static TypeSelector From(Assembly assembly)\n {\n return assembly.Types();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.BeNull.cs", "using System;\nusing System.Collections.Generic;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\n/// \n/// The [Not]BeNull specs.\n/// \npublic partial class CollectionAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void When_collection_is_expected_to_be_null_and_it_is_it_should_not_throw()\n {\n // Arrange\n IEnumerable someCollection = null;\n\n // Act / Assert\n someCollection.Should().BeNull();\n }\n\n [Fact]\n public void When_collection_is_expected_to_be_null_and_it_isnt_it_should_throw()\n {\n // Arrange\n IEnumerable someCollection = new string[0];\n\n // Act\n Action act = () => someCollection.Should().BeNull(\"because {0} is valid\", \"null\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someCollection to be because null is valid, but found {empty}.\");\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_collection_is_not_expected_to_be_null_and_it_isnt_it_should_not_throw()\n {\n // Arrange\n IEnumerable someCollection = new string[0];\n\n // Act / Assert\n someCollection.Should().NotBeNull();\n }\n\n [Fact]\n public void When_collection_is_not_expected_to_be_null_and_it_is_it_should_throw()\n {\n // Arrange\n IEnumerable someCollection = null;\n\n // Act\n Action act = () => someCollection.Should().NotBeNull(\"because {0} should not\", \"someCollection\");\n\n // Assert\n act.Should().Throw().WithMessage(\n \"Expected someCollection not to be because someCollection should not.\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Extensibility.Specs/AssertionEngineInitializer.cs", "using System;\nusing System.Threading;\n\n// With specific initialization code to invoke before the first assertion happens\n[assembly: AwesomeAssertions.Extensibility.AssertionEngineInitializer(\n typeof(AwesomeAssertions.Extensibility.Specs.AssertionEngineInitializer),\n nameof(AwesomeAssertions.Extensibility.Specs.AssertionEngineInitializer.InitializeBeforeFirstAssertion))]\n\n[assembly: AwesomeAssertions.Extensibility.AssertionEngineInitializer(\n typeof(AwesomeAssertions.Extensibility.Specs.AssertionEngineInitializer),\n nameof(AwesomeAssertions.Extensibility.Specs.AssertionEngineInitializer.InitializeBeforeFirstAssertionButThrow))]\n\nnamespace AwesomeAssertions.Extensibility.Specs;\n\npublic static class AssertionEngineInitializer\n{\n private static int shouldBeCalledOnlyOnce;\n\n public static int ShouldBeCalledOnlyOnce => shouldBeCalledOnlyOnce;\n\n public static void InitializeBeforeFirstAssertion()\n {\n Interlocked.Increment(ref shouldBeCalledOnlyOnce);\n }\n\n public static void InitializeBeforeFirstAssertionButThrow()\n {\n throw new InvalidOperationException(\"Bogus exception to make sure the engine ignores them\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BeNegative.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BeNegative\n {\n [Fact]\n public void NaN_is_never_a_negative_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_a_negative_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BeNegative();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.BePositive.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n public class BePositive\n {\n [Fact]\n public void NaN_is_never_a_positive_float()\n {\n // Arrange\n float? value = float.NaN;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n\n [Fact]\n public void NaN_is_never_a_positive_double()\n {\n // Arrange\n double? value = double.NaN;\n\n // Act\n Action act = () => value.Should().BePositive();\n\n // Assert\n act.Should().Throw().WithMessage(\"*but found NaN*\");\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/FormatChild.cs", "namespace AwesomeAssertions.Formatting;\n\n/// \n/// Represents a method that can be used to format child values from inside an .\n/// \n/// \n/// Represents the path from the current location to the child value.\n/// \n/// \n/// The child value to format with the configured s.\n/// \npublic delegate void FormatChild(string childPath, object value, FormattedObjectGraph formattedGraph);\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/AndWhichConstraintSpecs.cs", "using System;\nusing AwesomeAssertions.Collections;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs;\n\npublic class AndWhichConstraintSpecs\n{\n [Fact]\n public void When_many_objects_are_provided_accessing_which_should_throw_a_descriptive_exception()\n {\n // Arrange\n var continuation = new AndWhichConstraint(null, [\"hello\", \"world\"]);\n\n // Act\n Action act = () => _ = continuation.Which;\n\n // Assert\n act.Should().Throw()\n .WithMessage(\n \"More than one object found. AwesomeAssertions cannot determine which object is meant.*\")\n .WithMessage(\"*Found objects:*\\\"hello\\\"*\\\"world\\\"\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventMonitorOptions.cs", "using System;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Settings for the EventMonitor.\n/// \npublic class EventMonitorOptions\n{\n /// \n /// Will ignore the events, if they throw an exception on any custom event accessor implementation. default: false.\n /// \n internal bool ShouldIgnoreEventAccessorExceptions { get; private set; }\n\n /// \n /// This will record the event, even if the event accessor add event threw an exception. To ignore exceptions in the event add accessor, call property to set it to true. default: false.\n /// \n internal bool ShouldRecordEventsWithBrokenAccessor { get; private set; }\n\n /// \n /// Func used to generate the timestamp.\n /// \n internal Func TimestampProvider { get; private set; } = () => DateTime.UtcNow;\n\n /// \n /// When called it will ignore event accessor Exceptions.\n /// \n public EventMonitorOptions IgnoringEventAccessorExceptions()\n {\n ShouldIgnoreEventAccessorExceptions = true;\n return this;\n }\n\n /// \n /// When called it will record the event even when the accessor threw an exception.\n /// \n public EventMonitorOptions RecordingEventsWithBrokenAccessor()\n {\n ShouldRecordEventsWithBrokenAccessor = true;\n return this;\n }\n\n /// \n /// Sets the timestamp provider. By default it is .\n /// \n /// The timestamp provider.\n internal EventMonitorOptions ConfigureTimestampProvider(Func timestampProvider)\n {\n if (timestampProvider != null)\n {\n TimestampProvider = timestampProvider;\n }\n\n return this;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/EnumerableExtensionsSpecs.cs", "using AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class EnumerableExtensionsSpecs\n{\n public static TheoryData JoinUsingWritingStyleTestCases => new()\n {\n { [], \"\" },\n { [\"test\"], \"test\" },\n { [\"test\", \"test2\"], \"test and test2\" },\n { [\"test\", \"test2\", \"test3\"], \"test, test2 and test3\" },\n { [\"test\", \"test2\", \"test3\", \"test4\"], \"test, test2, test3 and test4\" }\n };\n\n [Theory]\n [MemberData(nameof(JoinUsingWritingStyleTestCases))]\n public void JoinUsingWritingStyle_should_format_correctly(string[] input, string expectation)\n {\n // Act\n var result = input.JoinUsingWritingStyle();\n\n // Assert\n result.Should().Be(expectation);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/DateTimeOffsetValueFormatterSpecs.cs", "using System;\nusing System.Globalization;\nusing AwesomeAssertions.Extensions;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class DateTimeOffsetValueFormatterSpecs\n{\n [Fact]\n public void When_time_is_not_relevant_it_should_not_be_included_in_the_output()\n {\n // Act\n string result = Formatter.ToString(new DateTime(1973, 9, 20));\n\n // Assert\n result.Should().Be(\"<1973-09-20>\");\n }\n\n [Fact]\n public void When_the_offset_is_not_relevant_it_should_not_be_included_in_the_output()\n {\n // Act\n string result = Formatter.ToString(new DateTime(1973, 9, 20, 12, 59, 59));\n\n // Assert\n result.Should().Be(\"<1973-09-20 12:59:59>\");\n }\n\n [Fact]\n public void When_the_offset_is_negative_it_should_include_it_in_the_output()\n {\n // Arrange\n DateTimeOffset date = new(1973, 9, 20, 12, 59, 59, -3.Hours());\n\n // Act\n string result = Formatter.ToString(date);\n\n // Assert\n result.Should().Be(\"<1973-09-20 12:59:59 -3h>\");\n }\n\n [Fact]\n public void When_the_offset_is_positive_it_should_include_it_in_the_output()\n {\n // Arrange / Act\n string result = Formatter.ToString(new DateTimeOffset(1973, 9, 20, 12, 59, 59, 3.Hours()));\n\n // Assert\n result.Should().Be(\"<1973-09-20 12:59:59 +3h>\");\n }\n\n [Fact]\n public void When_date_is_not_relevant_it_should_not_be_included_in_the_output()\n {\n // Act\n DateTime emptyDate = 1.January(0001);\n var dateTime = emptyDate.At(08, 20, 01);\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<08:20:01>\");\n }\n\n [InlineData(\"0001-01-02 04:05:06\", \"<0001-01-02 04:05:06>\")]\n [InlineData(\"0001-02-01 04:05:06\", \"<0001-02-01 04:05:06>\")]\n [InlineData(\"0002-01-01 04:05:06\", \"<0002-01-01 04:05:06>\")]\n [InlineData(\"0001-02-02 04:05:06\", \"<0001-02-02 04:05:06>\")]\n [InlineData(\"0002-01-02 04:05:06\", \"<0002-01-02 04:05:06>\")]\n [InlineData(\"0002-02-01 04:05:06\", \"<0002-02-01 04:05:06>\")]\n [InlineData(\"0002-02-02 04:05:06\", \"<0002-02-02 04:05:06>\")]\n [Theory]\n public void When_date_is_relevant_it_should_be_included_in_the_output(string actual, string expected)\n {\n // Arrange\n var value = DateTime.Parse(actual, CultureInfo.InvariantCulture);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Fact]\n public void When_a_full_date_and_time_is_specified_all_parts_should_be_included_in_the_output()\n {\n // Act\n var dateTime = 1.May(2012).At(20, 15, 30, 318);\n string result = Formatter.ToString(dateTime);\n\n // Assert\n result.Should().Be(\"<2012-05-01 20:15:30.318>\");\n }\n\n [Theory]\n [InlineData(\"0001-02-03\", \"<0001-02-03>\")]\n [InlineData(\"0001-02-03 04:05:06\", \"<0001-02-03 04:05:06>\")]\n [InlineData(\"0001-02-03 04:05:06.123\", \"<0001-02-03 04:05:06.123>\")]\n [InlineData(\"0001-02-03 04:05:06.123456\", \"<0001-02-03 04:05:06.123456>\")]\n [InlineData(\"0001-02-03 04:05:06.1234567\", \"<0001-02-03 04:05:06.1234567>\")]\n [InlineData(\"0001-02-03 00:00:01\", \"<0001-02-03 00:00:01>\")]\n [InlineData(\"0001-02-03 00:01:00\", \"<0001-02-03 00:01:00>\")]\n [InlineData(\"0001-02-03 01:00:00\", \"<0001-02-03 01:00:00>\")]\n [InlineData(\"0001-02-03 00:00:00.1000000\", \"<0001-02-03 00:00:00.100>\")]\n [InlineData(\"0001-02-03 00:00:00.0100000\", \"<0001-02-03 00:00:00.010>\")]\n [InlineData(\"0001-02-03 00:00:00.0010000\", \"<0001-02-03 00:00:00.001>\")]\n [InlineData(\"0001-02-03 00:00:00.0001000\", \"<0001-02-03 00:00:00.000100>\")]\n [InlineData(\"0001-02-03 00:00:00.0000100\", \"<0001-02-03 00:00:00.000010>\")]\n [InlineData(\"0001-02-03 00:00:00.0000010\", \"<0001-02-03 00:00:00.000001>\")]\n [InlineData(\"0001-02-03 00:00:00.0000001\", \"<0001-02-03 00:00:00.0000001>\")]\n public void When_datetime_components_are_not_relevant_they_should_not_be_included_in_the_output(string actual,\n string expected)\n {\n // Arrange\n var value = DateTime.Parse(actual, CultureInfo.InvariantCulture);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(expected);\n }\n\n [Theory]\n [InlineData(\"0001-02-03 +1\", \"<0001-02-03 +1h>\")]\n [InlineData(\"0001-02-03 04:05:06 +1\", \"<0001-02-03 04:05:06 +1h>\")]\n [InlineData(\"0001-02-03 04:05:06.123 +1\", \"<0001-02-03 04:05:06.123 +1h>\")]\n [InlineData(\"0001-02-03 04:05:06.123456 +1\", \"<0001-02-03 04:05:06.123456 +1h>\")]\n [InlineData(\"0001-02-03 04:05:06.1234567 +1\", \"<0001-02-03 04:05:06.1234567 +1h>\")]\n [InlineData(\"0001-02-03 00:00:01 +1\", \"<0001-02-03 00:00:01 +1h>\")]\n [InlineData(\"0001-02-03 00:01:00 +1\", \"<0001-02-03 00:01:00 +1h>\")]\n [InlineData(\"0001-02-03 01:00:00 +1\", \"<0001-02-03 01:00:00 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.1000000 +1\", \"<0001-02-03 00:00:00.100 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0100000 +1\", \"<0001-02-03 00:00:00.010 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0010000 +1\", \"<0001-02-03 00:00:00.001 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0001000 +1\", \"<0001-02-03 00:00:00.000100 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0000100 +1\", \"<0001-02-03 00:00:00.000010 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0000010 +1\", \"<0001-02-03 00:00:00.000001 +1h>\")]\n [InlineData(\"0001-02-03 00:00:00.0000001 +1\", \"<0001-02-03 00:00:00.0000001 +1h>\")]\n public void When_datetimeoffset_components_are_not_relevant_they_should_not_be_included_in_the_output(string actual,\n string expected)\n {\n // Arrange\n var value = DateTimeOffset.Parse(actual, CultureInfo.InvariantCulture);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(expected);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.BeNull.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetimeoffset_value_without_a_value_to_be_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n\n // Act / Assert\n nullableDateTime.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_with_a_value_to_be_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act\n Action action = () =>\n nullableDateTime.Should().BeNull();\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void When_nullable_datetimeoffset_value_with_a_value_not_be_null_it_should_succeed()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTime.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_without_a_value_to_not_be_null()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n\n // Act\n Action action = () => nullableDateTime.Should().NotBeNull();\n\n // Assert\n action.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Configuration/GlobalFormattingOptions.cs", "using AwesomeAssertions.Common;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Configuration;\n\npublic class GlobalFormattingOptions : FormattingOptions\n{\n private string valueFormatterAssembly;\n\n public string ValueFormatterAssembly\n {\n get => valueFormatterAssembly;\n set\n {\n valueFormatterAssembly = value;\n ValueFormatterDetectionMode = ValueFormatterDetectionMode.Specific;\n }\n }\n\n public ValueFormatterDetectionMode ValueFormatterDetectionMode { get; set; }\n\n internal new GlobalFormattingOptions Clone()\n {\n return new GlobalFormattingOptions\n {\n UseLineBreaks = UseLineBreaks,\n MaxDepth = MaxDepth,\n MaxLines = MaxLines,\n StringPrintLength = StringPrintLength,\n ScopedFormatters = [.. ScopedFormatters],\n ValueFormatterAssembly = ValueFormatterAssembly,\n ValueFormatterDetectionMode = ValueFormatterDetectionMode\n };\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.BeNull.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class BeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetime_value_without_a_value_to_be_null()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act / Assert\n nullableDateTime.Should().BeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetime_value_with_a_value_to_be_null()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act\n Action action = () =>\n nullableDateTime.Should().BeNull();\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class NotBeNull\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetime_value_with_a_value_to_not_be_null()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act / Assert\n nullableDateTime.Should().NotBeNull();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetime_value_without_a_value_to_not_be_null()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act\n Action action = () => nullableDateTime.Should().NotBeNull();\n\n // Assert\n action.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeOffsetAssertionSpecs.HaveValue.cs", "using System;\nusing AwesomeAssertions.Common;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeOffsetAssertionSpecs\n{\n public class HaveValue\n {\n [Fact]\n public void When_nullable_datetimeoffset_value_with_a_value_to_have_a_value_it_should_succeed()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act / Assert\n nullableDateTime.Should().HaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_without_a_value_to_have_a_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n\n // Act\n Action action = () => nullableDateTime.Should().HaveValue();\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class NotHaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetimeoffset_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = null;\n\n // Act / Assert\n nullableDateTime.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetimeoffset_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n DateTimeOffset? nullableDateTime = new DateTime(2016, 06, 04).ToDateTimeOffset();\n\n // Act\n Action action = () =>\n nullableDateTime.Should().NotHaveValue();\n\n // Assert\n action.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/DateTimeAssertionSpecs.HaveValue.cs", "using System;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class DateTimeAssertionSpecs\n{\n public class HaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetime_value_with_a_value_to_have_a_value()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act / Assert\n nullableDateTime.Should().HaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetime_value_without_a_value_to_have_a_value()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act\n Action action = () => nullableDateTime.Should().HaveValue();\n\n // Assert\n action.Should().Throw();\n }\n }\n\n public class NotHaveValue\n {\n [Fact]\n public void Should_succeed_when_asserting_nullable_datetime_value_without_a_value_to_not_have_a_value()\n {\n // Arrange\n DateTime? nullableDateTime = null;\n\n // Act / Assert\n nullableDateTime.Should().NotHaveValue();\n }\n\n [Fact]\n public void Should_fail_when_asserting_nullable_datetime_value_with_a_value_to_not_have_a_value()\n {\n // Arrange\n DateTime? nullableDateTime = new DateTime(2016, 06, 04);\n\n // Act\n Action action = () =>\n nullableDateTime.Should().NotHaveValue();\n\n // Assert\n action.Should().Throw();\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Primitives/ObjectAssertionSpecs.BeEquivalentTo.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Primitives;\n\npublic partial class ObjectAssertionSpecs\n{\n public class BeEquivalentTo\n {\n [Fact]\n public void Can_ignore_casing_while_comparing_objects_with_string_properties()\n {\n // Arrange\n var actual = new { foo = \"test\" };\n var expectation = new { foo = \"TEST\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_objects_with_string_properties()\n {\n // Arrange\n var actual = new { foo = \" test\" };\n var expectation = new { foo = \"test\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_objects_with_string_properties()\n {\n // Arrange\n var actual = new { foo = \"test \" };\n var expectation = new { foo = \"test\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_objects_with_string_properties()\n {\n // Arrange\n var actual = new { foo = \"A\\nB\\r\\nC\" };\n var expectation = new { foo = \"A\\r\\nB\\nC\" };\n\n // Act / Assert\n actual.Should().BeEquivalentTo(expectation, o => o.IgnoringNewlineStyle());\n }\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Collections/CollectionAssertionSpecs.AllBeEquivalentTo.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Collections;\n\npublic partial class CollectionAssertionSpecs\n{\n public class AllBeEquivalentTo\n {\n [Fact]\n public void Can_ignore_casing_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"test\", \"tEst\", \"Test\", \"TEst\", \"teST\" };\n var expectation = \"test\";\n\n // Act / Assert\n actual.Should().AllBeEquivalentTo(expectation, o => o.IgnoringCase());\n }\n\n [Fact]\n public void Can_ignore_leading_whitespace_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \" test\", \"test\", \"\\ttest\", \"\\ntest\", \" \\t \\n test\" };\n var expectation = \"test\";\n\n // Act / Assert\n actual.Should().AllBeEquivalentTo(expectation, o => o.IgnoringLeadingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_trailing_whitespace_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"test \", \"test\", \"test\\t\", \"test\\n\", \"test \\t \\n \" };\n var expectation = \"test\";\n\n // Act / Assert\n actual.Should().AllBeEquivalentTo(expectation, o => o.IgnoringTrailingWhitespace());\n }\n\n [Fact]\n public void Can_ignore_newline_style_while_comparing_collections_of_strings()\n {\n // Arrange\n var actual = new[] { \"A\\nB\\nC\", \"A\\r\\nB\\r\\nC\", \"A\\r\\nB\\nC\", \"A\\nB\\r\\nC\" };\n var expectation = \"A\\nB\\nC\";\n\n // Act / Assert\n actual.Should().AllBeEquivalentTo(expectation, o => o.IgnoringNewlineStyle());\n }\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/ExecutionTime.cs", "using System;\nusing System.Threading.Tasks;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Specialized;\n\npublic class ExecutionTime\n{\n private ITimer timer;\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The action of which the execution time must be asserted.\n /// is .\n public ExecutionTime(Action action, StartTimer createTimer)\n : this(action, \"the action\", createTimer)\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The action of which the execution time must be asserted.\n /// is .\n public ExecutionTime(Func action, StartTimer createTimer)\n : this(action, \"the action\", createTimer)\n {\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The action of which the execution time must be asserted.\n /// The description of the action to be asserted.\n /// is .\n protected ExecutionTime(Action action, string actionDescription, StartTimer createTimer)\n {\n Guard.ThrowIfArgumentIsNull(action);\n\n ActionDescription = actionDescription;\n IsRunning = true;\n\n Task = Task.Run(() =>\n {\n // move stopwatch as close to action start as possible\n // so that we have to get correct time readings\n try\n {\n using (timer = createTimer())\n {\n action();\n }\n }\n catch (Exception exception)\n {\n Exception = exception;\n }\n finally\n {\n // ensures that we stop the stopwatch even on exceptions\n IsRunning = false;\n }\n });\n }\n\n /// \n /// Initializes a new instance of the class.\n /// \n /// The action of which the execution time must be asserted.\n /// The description of the action to be asserted.\n /// \n /// This constructor is almost exact copy of the one accepting .\n /// The original constructor shall stay in place in order to keep backward-compatibility\n /// and to avoid unnecessary wrapping action in .\n /// \n /// is .\n protected ExecutionTime(Func action, string actionDescription, StartTimer createTimer)\n {\n Guard.ThrowIfArgumentIsNull(action);\n\n ActionDescription = actionDescription;\n IsRunning = true;\n\n Task = Task.Run(async () =>\n {\n // move stopwatch as close to action start as possible\n // so that we have to get correct time readings\n try\n {\n using (timer = createTimer())\n {\n await action();\n }\n }\n catch (Exception exception)\n {\n Exception = exception;\n }\n finally\n {\n IsRunning = false;\n }\n });\n }\n\n internal TimeSpan ElapsedTime => timer?.Elapsed ?? TimeSpan.Zero;\n\n internal bool IsRunning { get; private set; }\n\n internal string ActionDescription { get; }\n\n internal Task Task { get; }\n\n internal Exception Exception { get; private set; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/TimeSpanConversionExtensionSpecs.cs", "using System;\nusing System.Globalization;\nusing AwesomeAssertions.Extensions;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class TimeSpanConversionExtensionSpecs\n{\n [Fact]\n public void When_getting_the_number_of_days_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Days();\n\n // Assert\n time.Should().Be(TimeSpan.FromDays(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_days_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Days();\n\n // Assert\n time.Should().Be(TimeSpan.FromDays(4.5));\n }\n\n [Fact]\n public void When_getting_the_number_of_hours_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Hours();\n\n // Assert\n time.Should().Be(TimeSpan.FromHours(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_hours_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Hours();\n\n // Assert\n time.Should().Be(TimeSpan.FromHours(4.5));\n }\n\n [Fact]\n public void When_getting_the_number_of_minutes_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Minutes();\n\n // Assert\n time.Should().Be(TimeSpan.FromMinutes(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_minutes_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Minutes();\n\n // Assert\n time.Should().Be(TimeSpan.FromMinutes(4.5));\n }\n\n [Fact]\n public void When_getting_the_number_of_seconds_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Seconds();\n\n // Assert\n time.Should().Be(TimeSpan.FromSeconds(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_seconds_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Seconds();\n\n // Assert\n time.Should().Be(TimeSpan.FromSeconds(4.5));\n }\n\n [Fact]\n public void Add_time_span_to_given_seconds()\n {\n // Act\n TimeSpan time = 4.Seconds(TimeSpan.FromSeconds(1));\n\n // Assert\n time.Should().Be(TimeSpan.FromSeconds(5));\n }\n\n [Fact]\n public void Subtract_time_span_from_given_seconds()\n {\n // Act\n TimeSpan time = 4.Seconds(TimeSpan.FromSeconds(-1));\n\n // Assert\n time.Should().Be(TimeSpan.FromSeconds(3));\n }\n\n [Fact]\n public void When_getting_the_nanoseconds_component_it_should_return_the_correct_value()\n {\n // Arrange\n var time = TimeSpan.Parse(\"01:02:03.1234567\", CultureInfo.InvariantCulture);\n\n // Act\n var value = time.Nanoseconds();\n\n // Assert\n value.Should().Be(700);\n }\n\n [Fact]\n public void When_getting_the_number_of_nanoseconds_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 200.Nanoseconds();\n\n // Assert\n time.Should().Be(TimeSpan.Parse(\"00:00:00.0000002\", CultureInfo.InvariantCulture));\n }\n\n [Fact]\n public void When_getting_the_number_of_nanoseconds_from_a_long_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 200L.Nanoseconds();\n\n // Assert\n time.Should().Be(TimeSpan.Parse(\"00:00:00.0000002\", CultureInfo.InvariantCulture));\n }\n\n [Fact]\n public void When_getting_the_total_number_of_nanoseconds_should_return_the_correct_double_value()\n {\n // Arrange\n TimeSpan time = 1.Milliseconds();\n\n // Act\n double total = time.TotalNanoseconds();\n\n // Assert\n total.Should().Be(1_000_000);\n }\n\n [Fact]\n public void When_getting_the_microseconds_component_it_should_return_the_correct_value()\n {\n // Arrange\n var time = TimeSpan.Parse(\"01:02:03.1234567\", CultureInfo.InvariantCulture);\n\n // Act\n var value = time.Microseconds();\n\n // Assert\n value.Should().Be(456);\n }\n\n [Fact]\n public void When_getting_the_number_of_microseconds_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Microseconds();\n\n // Assert\n time.Should().Be(TimeSpan.Parse(\"00:00:00.000004\", CultureInfo.InvariantCulture));\n }\n\n [Fact]\n public void When_getting_the_number_of_microseconds_from_a_long_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4L.Microseconds();\n\n // Assert\n time.Should().Be(TimeSpan.Parse(\"00:00:00.000004\", CultureInfo.InvariantCulture));\n }\n\n [Fact]\n public void When_getting_the_total_number_of_microseconds_should_return_the_correct_double_value()\n {\n // Arrange\n TimeSpan time = 1.Milliseconds();\n\n // Act\n double total = time.TotalMicroseconds();\n\n // Assert\n total.Should().Be(1_000);\n }\n\n [Fact]\n public void When_getting_the_number_of_milliseconds_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Milliseconds();\n\n // Assert\n time.Should().Be(TimeSpan.FromMilliseconds(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_milliseconds_from_a_double_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.5.Milliseconds();\n\n // Assert\n time.Should().Be(TimeSpan.FromMilliseconds(4.5));\n }\n\n [Fact]\n public void When_getting_the_number_of_ticks_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4.Ticks();\n\n // Assert\n time.Should().Be(TimeSpan.FromTicks(4));\n }\n\n [Fact]\n public void When_getting_the_number_of_ticks_from_a_long_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time = 4L.Ticks();\n\n // Assert\n time.Should().Be(TimeSpan.FromTicks(4));\n }\n\n [Fact]\n public void When_combining_fluent_time_methods_it_should_return_the_correct_time_span_value()\n {\n // Act\n TimeSpan time1 = 23.Hours().And(59.Minutes());\n TimeSpan time2 = 23.Hours(59.Minutes()).And(20.Seconds());\n TimeSpan time3 = 1.Days(2.Hours(33.Minutes(44.Seconds()))).And(99.Milliseconds());\n\n // Assert\n time1.Should().Be(new TimeSpan(23, 59, 0));\n time2.Should().Be(new TimeSpan(23, 59, 20));\n time3.Should().Be(new TimeSpan(1, 2, 33, 44, 99));\n }\n\n [Fact]\n public void When_specifying_a_time_before_another_time_it_should_return_the_correct_time()\n {\n // Act\n DateTime now = 21.September(2011).At(07, 35);\n\n DateTime twoHoursAgo = 2.Hours().Before(now);\n\n // Assert\n twoHoursAgo.Should().Be(new DateTime(2011, 9, 21, 05, 35, 00));\n }\n\n [Fact]\n public void When_specifying_a_time_after_another_time_it_should_return_the_correct_time()\n {\n // Act\n DateTime now = 21.September(2011).At(07, 35);\n\n DateTime twoHoursLater = 2.Hours().After(now);\n\n // Assert\n twoHoursLater.Should().Be(new DateTime(2011, 9, 21, 09, 35, 00));\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/FallbackTestFramework.cs", "using System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Throws a generic exception in case no other test harness is detected.\n/// \ninternal class FallbackTestFramework : ITestFramework\n{\n /// \n /// Gets a value indicating whether the corresponding test framework is currently available.\n /// \n public bool IsAvailable => true;\n\n /// \n /// Throws a framework-specific exception to indicate a failing unit test.\n /// \n [DoesNotReturn]\n public void Throw(string message)\n {\n throw new AssertionFailedException(message);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/TypeExtensions.cs", "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Reflection;\nusing AwesomeAssertions.Common;\nusing AwesomeAssertions.Types;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Extension methods for getting method and property selectors for a type.\n/// \n[DebuggerNonUserCode]\npublic static class TypeExtensions\n{\n /// \n /// Returns the types that are visible outside the specified .\n /// \n public static TypeSelector Types(this Assembly assembly)\n {\n return new TypeSelector(assembly.GetTypes());\n }\n\n /// \n /// Returns a type selector for the current .\n /// \n public static TypeSelector Types(this Type type)\n {\n return new TypeSelector(type);\n }\n\n /// \n /// Returns a type selector for the current .\n /// \n public static TypeSelector Types(this IEnumerable types)\n {\n return new TypeSelector(types);\n }\n\n /// \n /// Returns a method selector for the current .\n /// \n /// is .\n public static MethodInfoSelector Methods(this Type type)\n {\n return new MethodInfoSelector(type);\n }\n\n /// \n /// Returns a method selector for the current .\n /// \n /// is .\n public static MethodInfoSelector Methods(this TypeSelector typeSelector)\n {\n Guard.ThrowIfArgumentIsNull(typeSelector);\n\n return new MethodInfoSelector(typeSelector.ToList());\n }\n\n /// \n /// Returns a property selector for the current .\n /// \n /// is .\n public static PropertyInfoSelector Properties(this Type type)\n {\n return new PropertyInfoSelector(type);\n }\n\n /// \n /// Returns a property selector for the current .\n /// \n /// is .\n public static PropertyInfoSelector Properties(this TypeSelector typeSelector)\n {\n Guard.ThrowIfArgumentIsNull(typeSelector);\n\n return new PropertyInfoSelector(typeSelector.ToList());\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/Continuation.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// Enables chaining multiple assertions on an .\n/// \npublic class Continuation\n{\n internal Continuation(AssertionChain parent)\n {\n Then = parent;\n }\n\n /// \n /// Continues the assertion chain if the previous assertion was successful.\n /// \n public AssertionChain Then { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/TimeSpanFormatterSpecs.cs", "using System;\nusing System.Globalization;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\npublic class TimeSpanFormatterSpecs\n{\n [Fact]\n public void When_zero_time_span_it_should_return_a_literal()\n {\n // Act\n string result = Formatter.ToString(TimeSpan.Zero);\n\n // Assert\n result.Should().Be(\"default\");\n }\n\n [Fact]\n public void When_max_time_span_it_should_return_a_literal()\n {\n // Act\n string result = Formatter.ToString(TimeSpan.MaxValue);\n\n // Assert\n result.Should().Be(\"max time span\");\n }\n\n [Fact]\n public void When_min_time_span_it_should_return_a_literal()\n {\n // Act\n string result = Formatter.ToString(TimeSpan.MinValue);\n\n // Assert\n result.Should().Be(\"min time span\");\n }\n\n [Theory]\n [InlineData(\"00:00:00.0000007\", \"0.7µs\")]\n [InlineData(\"-00:00:00.0000007\", \"-0.7µs\")]\n [InlineData(\"00:00:00.000456\", \"456.0µs\")]\n [InlineData(\"-00:00:00.000456\", \"-456.0µs\")]\n [InlineData(\"00:00:00.0004567\", \"456.7µs\")]\n [InlineData(\"-00:00:00.0004567\", \"-456.7µs\")]\n [InlineData(\"00:00:00.123\", \"123ms\")]\n [InlineData(\"-00:00:00.123\", \"-123ms\")]\n [InlineData(\"00:00:00.123456\", \"123ms and 456.0µs\")]\n [InlineData(\"-00:00:00.123456\", \"-123ms and 456.0µs\")]\n [InlineData(\"00:00:00.1234567\", \"123ms and 456.7µs\")]\n [InlineData(\"-00:00:00.1234567\", \"-123ms and 456.7µs\")]\n [InlineData(\"00:00:04\", \"4s\")]\n [InlineData(\"-00:00:04\", \"-4s\")]\n [InlineData(\"00:03:04\", \"3m and 4s\")]\n [InlineData(\"-00:03:04\", \"-3m and 4s\")]\n [InlineData(\"1.02:03:04\", \"1d, 2h, 3m and 4s\")]\n [InlineData(\"-1.02:03:04\", \"-1d, 2h, 3m and 4s\")]\n [InlineData(\"01:02:03\", \"1h, 2m and 3s\")]\n [InlineData(\"-01:02:03\", \"-1h, 2m and 3s\")]\n [InlineData(\"01:02:03.123\", \"1h, 2m, 3s and 123ms\")]\n [InlineData(\"-01:02:03.123\", \"-1h, 2m, 3s and 123ms\")]\n [InlineData(\"01:02:03.123456\", \"1h, 2m, 3s, 123ms and 456.0µs\")]\n [InlineData(\"-01:02:03.123456\", \"-1h, 2m, 3s, 123ms and 456.0µs\")]\n [InlineData(\"01:02:03.1234567\", \"1h, 2m, 3s, 123ms and 456.7µs\")]\n [InlineData(\"-01:02:03.1234567\", \"-1h, 2m, 3s, 123ms and 456.7µs\")]\n public void When_timespan_components_are_not_relevant_they_should_not_be_included_in_the_output(string actual,\n string expected)\n {\n // Arrange\n var value = TimeSpan.Parse(actual, CultureInfo.InvariantCulture);\n\n // Act\n string result = Formatter.ToString(value);\n\n // Assert\n result.Should().Be(expected);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/OccurrenceConstraint.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions;\n\npublic abstract class OccurrenceConstraint\n{\n protected OccurrenceConstraint(int expectedCount)\n {\n if (expectedCount < 0)\n {\n throw new ArgumentOutOfRangeException(nameof(expectedCount), \"Expected count cannot be negative.\");\n }\n\n ExpectedCount = expectedCount;\n }\n\n internal int ExpectedCount { get; }\n\n internal abstract string Mode { get; }\n\n internal abstract bool Assert(int actual);\n\n internal void RegisterContextData(Action register)\n {\n register(\"expectedOccurrence\", $\"{Mode} {ExpectedCount.Times()}\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/IStringComparisonStrategy.cs", "using AwesomeAssertions.Execution;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// The strategy used for comparing two s.\n/// \ninternal interface IStringComparisonStrategy\n{\n /// \n /// The prefix for the message when the assertion fails.\n /// \n string ExpectationDescription { get; }\n\n /// \n /// Asserts that the matches the value.\n /// \n void ValidateAgainstMismatch(AssertionChain assertionChain, string subject, string expected);\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/CollectionEqualBenchmarks.cs", "using System.Collections.Generic;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Common;\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Jobs;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\n[SimpleJob(RuntimeMoniker.Net472)]\n[SimpleJob(RuntimeMoniker.Net80)]\npublic class CollectionEqualBenchmarks\n{\n private IEnumerable collection1;\n private IEnumerable collection2;\n\n [Params(10, 100, 1_000, 5_000, 10_000)]\n public int N { get; set; }\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n collection1 = new int[N];\n collection2 = new int[N];\n }\n\n [Benchmark(Baseline = true)]\n public void CollectionEqual_Generic()\n {\n collection1.Should().Equal(collection2);\n }\n\n [Benchmark]\n public void CollectionEqual_Optimized()\n {\n collection1.Should().Equal(collection2, ObjectExtensions.GetComparer());\n }\n\n [Benchmark]\n public void CollectionEqual_CustomComparer()\n {\n collection1.Should().Equal(collection2, (a, b) => a == b);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/InvokingFunctionSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class InvokingFunctionSpecs\n{\n [Fact]\n public void Invoking_on_null_is_not_allowed()\n {\n // Arrange\n Does someClass = null;\n\n // Act\n Action act = () => someClass.Invoking(d => d.Return());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"subject\");\n }\n\n [Fact]\n public void Invoking_with_null_is_not_allowed()\n {\n // Arrange\n Does someClass = Does.NotThrow();\n\n // Act\n Action act = () => someClass.Invoking((Func)null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/OccurredEvent.cs", "using System;\nusing System.ComponentModel;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Represents an occurrence of a particular event.\n/// \npublic class OccurredEvent\n{\n /// \n /// The name of the event as defined on the monitored object.\n /// \n public string EventName { get; set; }\n\n /// \n /// The parameters that were passed to the event handler.\n /// \n public object[] Parameters { get; set; }\n\n /// \n /// The exact date and time of the occurrence in .\n /// \n public DateTime TimestampUtc { get; set; }\n\n /// \n /// The order in which this event was raised on the monitored object.\n /// \n public int Sequence { get; set; }\n\n /// \n /// Verifies if a property changed event is affecting a particular property.\n /// \n /// \n /// The property name for which the property changed event should have been raised.\n /// \n /// \n /// Returns if the event is affecting the property specified, otherwise.\n /// \n internal bool IsAffectingPropertyName(string propertyName)\n {\n return Parameters.OfType()\n .Any(e => string.IsNullOrEmpty(e.PropertyName) || e.PropertyName == propertyName);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/TimeSpanPredicate.cs", "using System;\n\nnamespace AwesomeAssertions.Primitives;\n\n/// \n/// Provides the logic and the display text for a .\n/// \ninternal class TimeSpanPredicate\n{\n private readonly Func lambda;\n\n public TimeSpanPredicate(Func lambda, string displayText)\n {\n this.lambda = lambda;\n DisplayText = displayText;\n }\n\n public string DisplayText { get; }\n\n public bool IsMatchedBy(TimeSpan actual, TimeSpan expected)\n {\n return lambda(actual, expected) && actual >= TimeSpan.Zero;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Numeric/NullableNumericAssertionSpecs.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Numeric;\n\npublic partial class NullableNumericAssertionSpecs\n{\n [Fact]\n public void Should_support_chaining_constraints_with_and()\n {\n // Arrange\n int? nullableInteger = 1;\n\n // Act / Assert\n nullableInteger.Should()\n .HaveValue()\n .And\n .BePositive();\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/NUnit4.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing NUnit.Framework;\n\nnamespace NUnit4.Specs;\n\n[TestFixture]\npublic class FrameworkSpecs\n{\n [Test]\n public void Throw_nunit_framework_exception_for_nunit4_tests()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"NUnit.Framework.AssertionException\");\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/XUnit2.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing Xunit;\n\nnamespace XUnit2.Specs;\n\npublic class FrameworkSpecs\n{\n [Fact]\n public void When_xunit2_is_used_it_should_throw_xunit_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"Xunit.Sdk.XunitException\");\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/NUnit3.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing NUnit.Framework;\n\nnamespace NUnit3.Specs;\n\n[TestFixture]\npublic class FrameworkSpecs\n{\n [Test]\n public void When_nunit3_is_used_it_should_throw_nunit_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"NUnit.Framework.AssertionException\");\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/XUnit3.Specs/FrameworkSpecs.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions;\nusing Xunit;\n\nnamespace XUnit3.Specs;\n\npublic class FrameworkSpecs\n{\n [Fact]\n public void When_xunit3_is_used_it_should_throw_xunit_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().GetInterfaces().Select(e => e.Name).Should().Contain(\"IAssertionException\");\n exception.GetType().FullName.Should().Be(\"Xunit.Sdk.XunitException\");\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/TUnit.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\n\nnamespace TUnit.Specs;\n\npublic class FrameworkSpecs\n{\n [Test]\n public void When_tunit_is_used_it_should_throw_tunit_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"TUnit.Assertions.Exceptions.AssertionException\");\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/MSTestV2.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\n\nnamespace MSTestV2.Specs;\n\n[TestClass]\npublic class FrameworkSpecs\n{\n [TestMethod]\n public void When_mstestv2_is_used_it_should_throw_mstest_exceptions_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n\n // Don't reference the exception type explicitly like this: act.Should().Throw()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n exception.GetType().FullName.Should().Be(\"Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException\");\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/MaximumMatchingSolution.cs", "using System.Collections.Generic;\nusing System.Linq;\n\nnamespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// The class defines the solution (output) for the maximum matching problem.\n/// See documentation of for more details.\n/// \n/// The type of elements which must be matched with predicates.\ninternal class MaximumMatchingSolution\n{\n private readonly Dictionary, Element> elementsByMatchedPredicate;\n private readonly MaximumMatchingProblem problem;\n\n public MaximumMatchingSolution(\n MaximumMatchingProblem problem,\n Dictionary, Element> elementsByMatchedPredicate)\n {\n this.problem = problem;\n this.elementsByMatchedPredicate = elementsByMatchedPredicate;\n }\n\n public bool UnmatchedPredicatesExist => problem.Predicates.Count != elementsByMatchedPredicate.Count;\n\n public bool UnmatchedElementsExist => problem.Elements.Count != elementsByMatchedPredicate.Count;\n\n public List> GetUnmatchedPredicates()\n {\n return problem.Predicates.Except(elementsByMatchedPredicate.Keys).ToList();\n }\n\n public List> GetUnmatchedElements()\n {\n return problem.Elements.Except(elementsByMatchedPredicate.Values).ToList();\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Exceptions/InvokingActionSpecs.cs", "using System;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Exceptions;\n\npublic class InvokingActionSpecs\n{\n [Fact]\n public void Invoking_on_null_is_not_allowed()\n {\n // Arrange\n Does someClass = null;\n\n // Act\n Action act = () => someClass.Invoking(d => d.Do());\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"subject\");\n }\n\n [Fact]\n public void Invoking_with_null_is_not_allowed()\n {\n // Arrange\n Does someClass = Does.NotThrow();\n\n // Act\n Action act = () => someClass.Invoking(null);\n\n // Assert\n act.Should().ThrowExactly()\n .WithParameterName(\"action\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XElementFormatterSpecs.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XElementFormatterSpecs\n{\n [Fact]\n public void When_element_has_attributes_it_should_include_them_in_the_output()\n {\n // Act\n var element = XElement.Parse(@\"\");\n string result = Formatter.ToString(element);\n\n // Assert\n result.Should().Be(@\"\");\n }\n\n [Fact]\n public void When_element_has_child_element_it_should_not_include_them_in_the_output()\n {\n // Act\n var element = XElement.Parse(\"\"\"\n \n \n \n \"\"\");\n\n string result = Formatter.ToString(element);\n\n // Assert\n result.Should().Be(@\"\");\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/BeEquivalentToBenchmarks.cs", "using System.Collections.Generic;\nusing System.Linq;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Collections;\nusing BenchmarkDotNet.Attributes;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\n[RyuJitX86Job]\npublic class BeEquivalentToBenchmarks\n{\n private List list;\n private List list2;\n\n [Params(10, 100, 1_000, 5_000, 10_000)]\n public int N { get; set; }\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n int objectCount = 0;\n\n list = Enumerable.Range(0, N).Select(_ => Nested.Create(1, ref objectCount)).ToList();\n\n objectCount = 0;\n\n list2 = Enumerable.Range(0, N).Select(_ => Nested.Create(1, ref objectCount)).ToList();\n }\n\n [Benchmark]\n public AndConstraint> BeEquivalentTo() => list.Should().BeEquivalentTo(list2);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensibility/AssertionEngineInitializerAttribute.cs", "using System;\nusing System.Reflection;\n\nnamespace AwesomeAssertions.Extensibility;\n\n/// \n/// Can be added to an assembly so it gets a change to initialize Awesome Assertions before the first assertion happens.\n/// \n[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\npublic sealed class AssertionEngineInitializerAttribute : Attribute\n{\n private readonly string methodName;\n private readonly Type type;\n\n /// \n /// Defines the static void-returning and parameterless method that should be invoked before the first assertion happens.\n /// \n#pragma warning disable CA1019\n public AssertionEngineInitializerAttribute(Type type, string methodName)\n#pragma warning restore CA1019\n {\n this.type = type;\n this.methodName = methodName;\n }\n\n internal void Initialize()\n {\n type?.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static)?.Invoke(obj: null, parameters: null);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/WhoseValueConstraint.cs", "using System.Collections.Generic;\n\nnamespace AwesomeAssertions.Collections;\n\npublic class WhoseValueConstraint : AndConstraint\n where TCollection : IEnumerable>\n where TAssertions : GenericDictionaryAssertions\n{\n /// \n /// Initializes a new instance of the class.\n /// \n public WhoseValueConstraint(TAssertions parentConstraint, TValue value)\n : base(parentConstraint)\n {\n WhoseValue = value;\n }\n\n /// \n /// Gets the value of the object referred to by the key.\n /// \n public TValue WhoseValue { get; }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XmlNodeFormatterSpecs.cs", "using System;\nusing System.Xml;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XmlNodeFormatterSpecs\n{\n [Fact]\n public void When_a_node_is_20_chars_long_it_should_not_be_trimmed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(@\"\");\n\n // Act\n string result = Formatter.ToString(xmlDoc);\n\n // Assert\n result.Should().Be(@\"\" + Environment.NewLine);\n }\n\n [Fact]\n public void When_a_node_is_longer_then_20_chars_it_should_be_trimmed()\n {\n // Arrange\n var xmlDoc = new XmlDocument();\n xmlDoc.LoadXml(@\"\");\n\n // Act\n string result = Formatter.ToString(xmlDoc);\n\n // Assert\n result.Should().Be(@\"\n/// Enables chaining multiple assertions from a call.\n/// \npublic class ContinuationOfGiven\n{\n internal ContinuationOfGiven(GivenSelector parent)\n {\n Then = parent;\n }\n\n /// \n /// Continues the assertion chain if the previous assertion was successful.\n /// \n public GivenSelector Then { get; }\n\n public bool Succeeded => Then.Succeeded;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ExceptionExtensions.cs", "using System;\nusing System.Reflection;\nusing System.Runtime.ExceptionServices;\n\nnamespace AwesomeAssertions.Common;\n\ninternal static class ExceptionExtensions\n{\n public static ExceptionDispatchInfo Unwrap(this TargetInvocationException exception)\n {\n Exception result = exception;\n\n while (result is TargetInvocationException)\n {\n result = result.InnerException;\n }\n\n return ExceptionDispatchInfo.Capture(result);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/DateTimeExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Common;\n\npublic static class DateTimeExtensions\n{\n /// \n /// Converts an existing to a but normalizes the \n /// so that comparisons of converted instances retain the UTC/local agnostic behavior.\n /// \n public static DateTimeOffset ToDateTimeOffset(this DateTime dateTime)\n {\n return dateTime.ToDateTimeOffset(TimeSpan.Zero);\n }\n\n public static DateTimeOffset ToDateTimeOffset(this DateTime dateTime, TimeSpan offset)\n {\n return new DateTimeOffset(DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified), offset);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Exactly.cs", "namespace AwesomeAssertions;\n\npublic static class Exactly\n{\n public static OccurrenceConstraint Once() => new ExactlyTimesConstraint(1);\n\n public static OccurrenceConstraint Twice() => new ExactlyTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new ExactlyTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new ExactlyTimesConstraint(expected);\n\n private sealed class ExactlyTimesConstraint : OccurrenceConstraint\n {\n internal ExactlyTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"exactly\";\n\n internal override bool Assert(int actual) => actual == ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AtLeast.cs", "namespace AwesomeAssertions;\n\npublic static class AtLeast\n{\n public static OccurrenceConstraint Once() => new AtLeastTimesConstraint(1);\n\n public static OccurrenceConstraint Twice() => new AtLeastTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new AtLeastTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new AtLeastTimesConstraint(expected);\n\n private sealed class AtLeastTimesConstraint : OccurrenceConstraint\n {\n internal AtLeastTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"at least\";\n\n internal override bool Assert(int actual) => actual >= ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AtMost.cs", "namespace AwesomeAssertions;\n\npublic static class AtMost\n{\n public static OccurrenceConstraint Once() => new AtMostTimesConstraint(1);\n\n public static OccurrenceConstraint Twice() => new AtMostTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new AtMostTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new AtMostTimesConstraint(expected);\n\n private sealed class AtMostTimesConstraint : OccurrenceConstraint\n {\n internal AtMostTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"at most\";\n\n internal override bool Assert(int actual) => actual <= ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/MoreThan.cs", "namespace AwesomeAssertions;\n\npublic static class MoreThan\n{\n public static OccurrenceConstraint Once() => new MoreThanTimesConstraint(1);\n\n public static OccurrenceConstraint Twice() => new MoreThanTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new MoreThanTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new MoreThanTimesConstraint(expected);\n\n private sealed class MoreThanTimesConstraint : OccurrenceConstraint\n {\n internal MoreThanTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"more than\";\n\n internal override bool Assert(int actual) => actual > ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/LessThan.cs", "namespace AwesomeAssertions;\n\npublic static class LessThan\n{\n public static OccurrenceConstraint Twice() => new LessThanTimesConstraint(2);\n\n public static OccurrenceConstraint Thrice() => new LessThanTimesConstraint(3);\n\n public static OccurrenceConstraint Times(int expected) => new LessThanTimesConstraint(expected);\n\n private sealed class LessThanTimesConstraint : OccurrenceConstraint\n {\n internal LessThanTimesConstraint(int expectedCount)\n : base(expectedCount)\n {\n }\n\n internal override string Mode => \"less than\";\n\n internal override bool Assert(int actual) => actual < ExpectedCount;\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Extensions/ObjectCastingSpecs.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Extensions;\n\npublic class ObjectCastingSpecs\n{\n [Fact]\n public void When_casting_an_object_using_the_as_operator_it_should_return_the_expected_type()\n {\n // Arrange\n SomeBaseClass baseInstance = new SomeDerivedClass\n {\n DerivedProperty = \"hello\"\n };\n\n // Act\n SomeDerivedClass derivedInstance = baseInstance.As();\n\n // Assert\n derivedInstance.DerivedProperty.Should().Be(\"hello\");\n }\n\n private class SomeBaseClass;\n\n private class SomeDerivedClass : SomeBaseClass\n {\n public string DerivedProperty { get; set; }\n }\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/LargeObjectGraphBenchmarks.cs", "using System;\nusing AwesomeAssertions;\nusing AwesomeAssertions.Primitives;\nusing BenchmarkDotNet.Attributes;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\npublic class LargeObjectGraphBenchmarks\n{\n [Params(16, 18, 20, 24, 28)]\n public int N { get; set; }\n\n private Nested copy1;\n private Nested copy2;\n\n [GlobalSetup]\n public void GlobalSetup()\n {\n int objectCount = 0;\n\n copy1 = Nested.Create(N, ref objectCount);\n\n objectCount = 0;\n\n copy2 = Nested.Create(N, ref objectCount);\n\n Console.WriteLine(\"N = {0} ; Graph size: {1} objects\", N, objectCount);\n }\n\n [Benchmark]\n public AndConstraint BeEquivalentTo() =>\n copy1.Should().BeEquivalentTo(copy2, config => config.AllowingInfiniteRecursion());\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensions/OccurrenceConstraintExtensions.cs", "using System;\n\nnamespace AwesomeAssertions.Extensions;\n\n/// \n/// Provides extensions to write s with fluent syntax\n/// \npublic static class OccurrenceConstraintExtensions\n{\n /// \n /// This is the equivalent to \n /// \n /// is less than zero.\n public static OccurrenceConstraint TimesExactly(this int times)\n {\n return Exactly.Times(times);\n }\n\n /// \n /// This is the equivalent to \n /// \n /// is less than zero.\n public static OccurrenceConstraint TimesOrLess(this int times)\n {\n return AtMost.Times(times);\n }\n\n /// \n /// This is the equivalent to \n /// \n /// is less than zero.\n public static OccurrenceConstraint TimesOrMore(this int times)\n {\n return AtLeast.Times(times);\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XDocumentFormatterSpecs.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XDocumentFormatterSpecs\n{\n [Fact]\n public void When_element_has_root_element_it_should_include_it_in_the_output()\n {\n // Act\n var document = XDocument.Parse(\n @\"\n \n \n \");\n\n string result = Formatter.ToString(document);\n\n // Assert\n result.Should().Be(\"\");\n }\n\n [Fact]\n public void When_element_has_no_root_element_it_should_include_it_in_the_output()\n {\n // Act\n var document = new XDocument();\n\n string result = Formatter.ToString(document);\n\n // Assert\n result.Should().Be(\"[XML document without root element]\");\n }\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/MSpec.Specs/FrameworkSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing Machine.Specifications;\n\nnamespace MSpec.Specs;\n\n[Subject(\"FrameworkSpecs\")]\npublic class When_mspec_is_used\n{\n Because of = () => Exception = Catch.Exception(() => 0.Should().Be(1));\n\n It should_fail = () => Exception.Should().BeAssignableTo();\n\n // Don't reference the exception type explicitly like this: Exception.Should().BeAssignableTo()\n // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit)\n It should_fail_with_a_specification_exception = () => Exception.GetType().FullName.Should().Be(\"Machine.Specifications.SpecificationException\");\n\n private static Exception Exception;\n}\n"], ["/AwesomeAssertions/Tests/TestFrameworks/XUnit3Core.Specs/FrameworkSpecs.cs", "using System;\nusing System.Linq;\nusing AwesomeAssertions;\nusing Xunit;\n\nnamespace XUnit3Core.Specs;\n\npublic class FrameworkSpecs\n{\n [Fact]\n public void When_xunit3_without_xunit_assert_is_used_it_should_throw_IAssertionException_for_assertion_failures()\n {\n // Act\n Action act = () => 0.Should().Be(1);\n\n // Assert\n Exception exception = act.Should().Throw().Which;\n exception.GetType().GetInterfaces().Select(e => e.Name).Should().Contain(\"IAssertionException\");\n }\n}\n"], ["/AwesomeAssertions/Build/Configuration.cs", "using System.ComponentModel;\nusing Nuke.Common.Tooling;\n\n[TypeConverter(typeof(TypeConverter))]\npublic class Configuration : Enumeration\n{\n public static readonly Configuration Debug = new() { Value = nameof(Debug) };\n\n public static readonly Configuration CI = new() { Value = nameof(CI) };\n\n public static implicit operator string(Configuration configuration)\n {\n return configuration.Value;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/AssertionFailedException.cs", "using System;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents the default exception in case no test framework is configured.\n/// \n/// The mandatory exception message\n#pragma warning disable CA1032, RCS1194 // AssertionFailedException should never be constructed with an empty message\npublic class AssertionFailedException(string message) : Exception(message), IAssertionException\n#pragma warning restore CA1032, RCS1194\n{\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Disposable.cs", "using System;\n\nnamespace AwesomeAssertions;\n\ninternal sealed class Disposable : IDisposable\n{\n private readonly Action action;\n\n public Disposable(Action action)\n {\n this.action = action;\n }\n\n public void Dispose()\n {\n action();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/MaximumMatchingProblem.cs", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\n\nnamespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// The class defines input for the maximum matching problem.\n/// The input is a list of predicates and a list of elements.\n/// The goal of the problem is to find such mapping between predicates and elements that would maximize number of matches.\n/// A predicate can be mapped with only one element.\n/// An element can be mapped with only one predicate.\n/// \n/// The type of elements which must be matched with predicates.\ninternal class MaximumMatchingProblem\n{\n public MaximumMatchingProblem(\n IEnumerable>> predicates,\n IEnumerable elements)\n {\n Predicates.AddRange(predicates.Select((predicate, index) => new Predicate(predicate, index)));\n Elements.AddRange(elements.Select((element, index) => new Element(element, index)));\n }\n\n public List> Predicates { get; } = [];\n\n public List> Elements { get; } = [];\n\n public MaximumMatchingSolution Solve() => new MaximumMatchingSolver(this).Solve();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/IMonitor.cs", "using System;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Monitors events on a given source\n/// \npublic interface IMonitor : IDisposable\n{\n /// \n /// Gets the object that is being monitored or if the object has been GCed.\n /// \n T Subject { get; }\n\n /// \n /// Clears all recorded events from the monitor and continues monitoring.\n /// \n void Clear();\n\n /// \n /// Provides access to several assertion methods.\n /// \n EventAssertions Should();\n\n IEventRecording GetRecordingFor(string eventName);\n\n /// \n /// Gets the metadata of all the events that are currently being monitored.\n /// \n EventMetadata[] MonitoredEvents { get; }\n\n /// \n /// Gets a collection of all events that have occurred since the monitor was created or\n /// was called.\n /// \n OccurredEvent[] OccurredEvents { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/MemberExecutionTime.cs", "using System;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Specialized;\n\npublic class MemberExecutionTime : ExecutionTime\n{\n /// \n /// Initializes a new instance of the class.\n /// \n /// The object that exposes the method or property.\n /// A reference to the method or property to measure the execution time of.\n /// is .\n /// is .\n public MemberExecutionTime(T subject, Expression> action, StartTimer createTimer)\n : base(() => action.Compile()(subject), \"(\" + action.Body + \")\", createTimer)\n {\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/ITestFramework.cs", "using System.Diagnostics.CodeAnalysis;\n\nnamespace AwesomeAssertions.Execution;\n\n/// \n/// Represents an abstraction of a particular test framework such as MSTest, nUnit, etc.\n/// \npublic interface ITestFramework\n{\n /// \n /// Gets a value indicating whether the corresponding test framework is currently available.\n /// \n bool IsAvailable { get; }\n\n /// \n /// Throws a framework-specific exception to indicate a failing unit test.\n /// \n [DoesNotReturn]\n void Throw(string message);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Specialized/IExtractExceptions.cs", "using System;\nusing System.Collections.Generic;\n\nnamespace AwesomeAssertions.Specialized;\n\npublic interface IExtractExceptions\n{\n IEnumerable OfType(Exception actualException)\n where T : Exception;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/Element.cs", "namespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// Stores an element's value and index in the maximum matching problem.\n/// \n/// The type of the element value.\ninternal class Element\n{\n public Element(TValue value, int index)\n {\n Index = index;\n Value = value;\n }\n\n /// \n /// The index of the element in the maximum matching problem.\n /// \n public int Index { get; }\n\n /// \n /// The value of the element in the maximum matching problem.\n /// \n public TValue Value { get; }\n}\n"], ["/AwesomeAssertions/Tests/AssemblyA/ClassA.cs", "using AssemblyB;\n\nnamespace AssemblyA;\n\npublic class ClassA\n{\n public void DoSomething()\n {\n _ = new ClassB();\n }\n\n public ClassC ReturnClassC()\n {\n return new ClassC();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CallerIdentification/ParsingState.cs", "namespace AwesomeAssertions.CallerIdentification;\n\ninternal enum ParsingState\n{\n InProgress,\n GoToNextSymbol,\n Done\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Polyfill/SystemExtensions.cs", "#if NET47 || NETSTANDARD2_0\n\n// ReSharper disable once CheckNamespace\nnamespace System;\n\ninternal static class SystemExtensions\n{\n // https://docs.microsoft.com/en-us/dotnet/api/system.string.indexof?view=netframework-4.8#System_String_IndexOf_System_Char_\n public static int IndexOf(this string str, char c, StringComparison _) =>\n str.IndexOf(c);\n\n // https://docs.microsoft.com/en-us/dotnet/api/system.string.replace?view=netframework-4.8#System_String_Replace_System_String_System_String_\n public static string Replace(this string str, string oldValue, string newValue, StringComparison _) =>\n str.Replace(oldValue, newValue);\n\n // https://docs.microsoft.com/en-us/dotnet/api/system.string.indexof?view=netframework-4.8#System_String_IndexOf_System_String_System_StringComparison_\n public static bool Contains(this string str, string value, StringComparison comparison) =>\n str.IndexOf(value, comparison) != -1;\n\n public static bool Contains(this string str, char value, StringComparison comparison) =>\n str.IndexOf(value, comparison) != -1;\n\n // https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs,1014\n public static bool StartsWith(this string str, char value) =>\n str.Length != 0 && str[0] == value;\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Xml/XAttributeFormatterSpecs.cs", "using System.Xml.Linq;\nusing AwesomeAssertions.Formatting;\nusing Xunit;\n\nnamespace AwesomeAssertions.Specs.Xml;\n\npublic class XAttributeFormatterSpecs\n{\n [Fact]\n public void When_formatting_an_attribute_it_should_return_the_name_and_value()\n {\n // Act\n var element = XElement.Parse(@\"\");\n XAttribute attribute = element.Attribute(\"name\");\n string result = Formatter.ToString(attribute);\n\n // Assert\n result.Should().Be(@\"name=\"\"Martin\"\"\");\n }\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/TestTimer.cs", "using System;\nusing AwesomeAssertions.Common;\n\nnamespace AwesomeAssertions.Specs;\n\ninternal sealed class TestTimer : ITimer\n{\n private readonly Func getElapsed;\n\n public TestTimer(Func getElapsed)\n {\n this.getElapsed = getElapsed;\n }\n\n public TimeSpan Elapsed => getElapsed();\n\n public void Dispose()\n {\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/MaximumMatching/Predicate.cs", "using System;\nusing System.Linq.Expressions;\nusing AwesomeAssertions.Formatting;\n\nnamespace AwesomeAssertions.Collections.MaximumMatching;\n\n/// \n/// Stores a predicate's expression and index in the maximum matching problem.\n/// \n/// The type of the element values in the maximum matching problems.\ninternal class Predicate\n{\n private readonly Func compiledExpression;\n\n public Predicate(Expression> expression, int index)\n {\n Index = index;\n Expression = expression;\n compiledExpression = expression.Compile();\n }\n\n /// \n /// The index of the predicate in the maximum matching problem.\n /// \n public int Index { get; }\n\n /// \n /// The expression of the predicate.\n /// \n public Expression> Expression { get; }\n\n /// \n /// Determines whether the predicate matches the specified element.\n /// \n public bool Matches(TValue element) => compiledExpression(element);\n\n public override string ToString() => $\"Index: {Index}, Expression: {Formatter.ToString(Expression)}\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Polyfill/StringBuilderExtensions.cs", "#if NET47 || NETSTANDARD2_0 || NETSTANDARD2_1\n\nusing System.Collections.Generic;\n\n// ReSharper disable once CheckNamespace\nnamespace System.Text;\n\n/// \n/// Since net6.0 StringBuilder has additional overloads taking an AppendInterpolatedStringHandler\n/// and optionally an IFormatProvider.\n/// The overload here is polyfill for older target frameworks to avoid littering the code base with #ifs\n/// in order to silence analyzers about depending on the current culture instead of an invariant culture.\n/// \ninternal static class StringBuilderExtensions\n{\n public static StringBuilder AppendLine(this StringBuilder stringBuilder, IFormatProvider _, string value) =>\n stringBuilder.AppendLine(value);\n\n#if NET47 || NETSTANDARD2_0\n public static StringBuilder AppendJoin(this StringBuilder stringBuilder, string separator, IEnumerable values) =>\n stringBuilder.Append(string.Join(separator, values));\n#endif\n}\n\n#endif\n"], ["/AwesomeAssertions/Tests/UWP.Specs/UwpSpecs.cs", "using System;\nusing AwesomeAssertions;\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\n\nnamespace UWP.Specs;\n\n[TestClass]\npublic class UwpSpecs\n{\n [TestMethod]\n public void Determining_caller_identity_should_not_throw_for_native_programs()\n {\n // Arrange\n Action someAction = () => throw new Exception();\n\n // Act\n Action act = () => someAction.Should().NotThrow();\n\n // Assert\n act.Should().Throw();\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/ThreadSafeSequenceGenerator.cs", "using System.Threading;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Generates a sequence in a thread-safe manner.\n/// \ninternal sealed class ThreadSafeSequenceGenerator\n{\n private int sequence = -1;\n\n /// \n /// Increments the current sequence.\n /// \n public int Increment()\n {\n return Interlocked.Increment(ref sequence);\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/EventMetadata.cs", "using System;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Provides the metadata of a monitored event.\n/// \npublic class EventMetadata\n{\n /// \n /// The name of the event member on the monitored object\n /// \n public string EventName { get; }\n\n /// \n /// The type of the event handler and event args.\n /// \n public Type HandlerType { get; }\n\n public EventMetadata(string eventName, Type handlerType)\n {\n EventName = eventName;\n HandlerType = handlerType;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/ICloneable2.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// Custom version of ICloneable that works on all frameworks.\n/// \npublic interface ICloneable2\n{\n /// \n /// Creates a new object that is a copy of the current instance.\n /// \n /// \n /// A new object that is a copy of this instance.\n /// \n object Clone();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/RecordedEvent.cs", "using System;\nusing System.Diagnostics;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// This class is used to store data about an intercepted event\n/// \n[DebuggerNonUserCode]\ninternal class RecordedEvent\n{\n /// \n /// Default constructor stores the parameters the event was raised with\n /// \n public RecordedEvent(DateTime utcNow, int sequence, params object[] parameters)\n {\n Parameters = parameters;\n TimestampUtc = utcNow;\n Sequence = sequence;\n }\n\n /// \n /// The exact data and time in UTC format at which the event occurred.\n /// \n public DateTime TimestampUtc { get; }\n\n /// \n /// Parameters for the event\n /// \n public object[] Parameters { get; }\n\n /// \n /// The order in which this event was invoked on the monitored object.\n /// \n public int Sequence { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/CSharpAccessModifier.cs", "namespace AwesomeAssertions.Common;\n\npublic enum CSharpAccessModifier\n{\n Public,\n Private,\n Protected,\n Internal,\n ProtectedInternal,\n InvalidForCSharp,\n PrivateProtected,\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/TUnitFramework.cs", "namespace AwesomeAssertions.Execution;\n\ninternal class TUnitFramework() : LateBoundTestFramework(loadAssembly: true)\n{\n protected override string ExceptionFullName => \"TUnit.Assertions.Exceptions.AssertionException\";\n\n protected internal override string AssemblyName => \"TUnit.Assertions\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/XUnitTestFramework.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// Implements the xUnit (version 2 and 3) test framework adapter.\n/// \ninternal class XUnitTestFramework(string assemblyName) : LateBoundTestFramework(loadAssembly: true)\n{\n protected internal override string AssemblyName => assemblyName;\n\n protected override string ExceptionFullName => \"Xunit.Sdk.XunitException\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CustomAssertionsAttribute.cs", "using System;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Marks a class as containing extensions to Awesome Assertions that either uses the built-in assertions\n/// internally, or directly uses AssertionChain.\n/// \n[AttributeUsage(AttributeTargets.Class)]\npublic sealed class CustomAssertionsAttribute : Attribute;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CustomAssertionsAssemblyAttribute.cs", "using System;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Marks an assembly as containing extensions to Awesome Assertions that either uses the built-in assertions\n/// internally, or directly uses AssertionChain.\n/// \n[AttributeUsage(AttributeTargets.Assembly)]\npublic sealed class CustomAssertionsAssemblyAttribute : Attribute;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/CustomAssertionAttribute.cs", "using System;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Marks a method as an extension to Awesome Assertions that either uses the built-in assertions\n/// internally, or directly uses AssertionChain.\n/// \n[AttributeUsage(AttributeTargets.Method)]\n#pragma warning disable CA1813 // Avoid unsealed attributes. This type has shipped.\npublic class CustomAssertionAttribute : Attribute;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AndConstraint.cs", "using System.Diagnostics;\n\nnamespace AwesomeAssertions;\n\n[DebuggerNonUserCode]\npublic class AndConstraint\n{\n public TParent And { get; }\n\n /// \n /// Initializes a new instance of the class.\n /// \n public AndConstraint(TParent parent)\n {\n And = parent;\n }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Events/IEventRecording.cs", "using System;\nusing System.Collections.Generic;\n\nnamespace AwesomeAssertions.Events;\n\n/// \n/// Represents an (active) recording of all events that happen(ed) while monitoring an object.\n/// \npublic interface IEventRecording : IEnumerable\n{\n /// \n /// The object events are recorded from\n /// \n object EventObject { get; }\n\n /// \n /// The name of the event that's recorded\n /// \n string EventName { get; }\n\n /// \n /// The type of the event handler identified by .\n /// \n Type EventHandlerType { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ValueFormatterDetectionMode.cs", "using AwesomeAssertions.Configuration;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Defines the modes in which custom implementations of \n/// are detected as configured through .\n/// \npublic enum ValueFormatterDetectionMode\n{\n /// \n /// Detection is disabled.\n /// \n Disabled,\n\n /// \n /// Only custom value formatters exposed through the assembly set in \n /// are detected.\n /// \n Specific,\n\n /// \n /// All custom value formatters in any assembly loaded in the current AppDomain will be detected.\n /// \n Scan,\n}\n"], ["/AwesomeAssertions/Tests/Benchmarks/HasValueSemanticsBenchmarks.cs", "using System.Collections.Generic;\nusing AwesomeAssertions.Common;\nusing BenchmarkDotNet.Attributes;\n\nnamespace Benchmarks;\n\n[MemoryDiagnoser]\npublic class HasValueSemanticsBenchmarks\n{\n [Benchmark(Baseline = true)]\n public bool HasValueSemantics_ValueType() => typeof(int).HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_Object() => typeof(object).HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_OverridesEquals() => typeof(string).HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_AnonymousType() => new { }.GetType().HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_KeyValuePair() => typeof(KeyValuePair).HasValueSemantics();\n\n [Benchmark]\n public bool HasValueSemantics_ValueTuple() => typeof((int, int)).HasValueSemantics();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/FormattingContext.cs", "namespace AwesomeAssertions.Formatting;\n\n/// \n/// Provides information about the current formatting action.\n/// \npublic class FormattingContext\n{\n /// \n /// Indicates whether the formatter should use line breaks when the supports it.\n /// \n public bool UseLineBreaks { get; set; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ShortTypeValue.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Holds a which should be formatted in short notation, i.e. without any namespaces.\n/// \n/// The type to format.\ninternal sealed class ShortTypeValue(Type type)\n{\n /// \n /// The type to format.\n /// \n public Type Type { get; } = type;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/IAssertionException.cs", "namespace AwesomeAssertions.Execution;\n\n/// \n/// This is a marker interface for xUnit.net v3 to set the test failure cause as an assertion failure.\n/// See What’s New in xUnit.net v3 - Third party assertion library extension points.\n/// \ninternal interface IAssertionException;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Configuration/ConfigurationSpecsDefinition.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Configuration;\n\n// Due to tests that call the static AssertionConfiguration or AssertionEngine, we need to disable parallelization\n[CollectionDefinition(\"ConfigurationSpecs\", DisableParallelization = true)]\npublic class ConfigurationSpecsDefinition;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/AssertionConfiguration.cs", "using AwesomeAssertions.Configuration;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Provides access to the global configuration and options to customize the behavior of AwesomeAssertions.\n/// \npublic static class AssertionConfiguration\n{\n public static GlobalConfiguration Current => AssertionEngine.Configuration;\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/IntegerExtensions.cs", "namespace AwesomeAssertions.Common;\n\ninternal static class IntegerExtensions\n{\n public static string Times(this int count) => count == 1 ? \"1 time\" : $\"{count} times\";\n\n internal static bool IsConsecutiveTo(this int startNumber, int endNumber) => endNumber == (startNumber + 1);\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/NUnitTestFramework.cs", "namespace AwesomeAssertions.Execution;\n\ninternal class NUnitTestFramework : LateBoundTestFramework\n{\n protected internal override string AssemblyName => \"nunit.framework\";\n\n protected override string ExceptionFullName => \"NUnit.Framework.AssertionException\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/MSpecFramework.cs", "namespace AwesomeAssertions.Execution;\n\ninternal class MSpecFramework : LateBoundTestFramework\n{\n protected internal override string AssemblyName => \"Machine.Specifications\";\n\n protected override string ExceptionFullName => \"Machine.Specifications.SpecificationException\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Execution/MSTestFrameworkV2.cs", "namespace AwesomeAssertions.Execution;\n\ninternal class MSTestFrameworkV2 : LateBoundTestFramework\n{\n protected override string ExceptionFullName => \"Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException\";\n\n protected internal override string AssemblyName => \"Microsoft.VisualStudio.TestPlatform.TestFramework\";\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Configuration/TestFramework.cs", "namespace AwesomeAssertions.Configuration;\n\n/// \n/// The test frameworks supported by Awesome Assertions.\n/// \npublic enum TestFramework\n{\n XUnit2,\n XUnit3,\n TUnit,\n MsTest,\n NUnit,\n MSpec\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Primitives/TimeSpanCondition.cs", "namespace AwesomeAssertions.Primitives;\n\npublic enum TimeSpanCondition\n{\n MoreThan,\n AtLeast,\n Exactly,\n Within,\n LessThan\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/MaxLinesExceededException.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\n#pragma warning disable RCS1194, CA1032 // Add constructors\npublic class MaxLinesExceededException : Exception;\n#pragma warning restore CA1032, RCS1194\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedTheoryAttribute.cs", "using Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\n[XunitTestCaseDiscoverer(\"AwesomeAssertions.Specs.CultureAwareTesting.CulturedTheoryAttributeDiscoverer\",\n \"AwesomeAssertions.Specs\")]\npublic sealed class CulturedTheoryAttribute : TheoryAttribute\n{\n#pragma warning disable CA1019 // Define accessors for attribute arguments\n public CulturedTheoryAttribute(params string[] _) { }\n#pragma warning restore CA1019 // Define accessors for attribute arguments\n}\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/CultureAwareTesting/CulturedFactAttribute.cs", "using Xunit;\nusing Xunit.Sdk;\n\nnamespace AwesomeAssertions.Specs.CultureAwareTesting;\n\n[XunitTestCaseDiscoverer(\"AwesomeAssertions.Specs.CultureAwareTesting.CulturedFactAttributeDiscoverer\", \"AwesomeAssertions.Specs\")]\npublic sealed class CulturedFactAttribute : FactAttribute\n{\n#pragma warning disable CA1019 // Define accessors for attribute arguments\n public CulturedFactAttribute(params string[] _) { }\n#pragma warning restore CA1019 // Define accessors for attribute arguments\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/IClock.cs", "using System;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Represents an abstract timer that is used to make some of this library's timing dependent functionality better testable.\n/// \npublic interface IClock\n{\n /// \n /// Will block the current thread until a time delay has passed.\n /// \n /// The time span to wait before completing the returned task\n void Delay(TimeSpan timeToDelay);\n\n /// \n /// Creates a task that will complete after a time delay.\n /// \n /// The time span to wait before completing the returned task\n /// \n /// A task that represents the time delay.\n /// \n Task DelayAsync(TimeSpan delay, CancellationToken cancellationToken);\n\n /// \n /// Creates a timer to measure the time to complete some arbitrary executions.\n /// \n ITimer StartTimer();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/FluentActions.cs", "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Threading.Tasks;\nusing JetBrains.Annotations;\n\nnamespace AwesomeAssertions;\n\n/// \n/// Contains static methods to help with exception assertions on actions.\n/// \n[DebuggerNonUserCode]\npublic static class FluentActions\n{\n /// \n /// Invokes the specified action so that you can assert that it throws an exception.\n /// \n [Pure]\n public static Action Invoking(Action action) => action;\n\n /// \n /// Invokes the specified action so that you can assert that it throws an exception.\n /// \n [Pure]\n public static Func Invoking(Func func) => func;\n\n /// \n /// Invokes the specified action so that you can assert that it throws an exception.\n /// \n [Pure]\n public static Func Awaiting(Func action) => action;\n\n /// \n /// Invokes the specified action so that you can assert that it throws an exception.\n /// \n [Pure]\n public static Func> Awaiting(Func> func) => func;\n\n /// \n /// Forces enumerating a collection. Should be used to assert that a method that uses the\n /// keyword throws a particular exception.\n /// \n [Pure]\n public static Action Enumerating(Func enumerable) => enumerable.Enumerating();\n\n /// \n /// Forces enumerating a collection. Should be used to assert that a method that uses the\n /// keyword throws a particular exception.\n /// \n [Pure]\n public static Action Enumerating(Func> enumerable) => enumerable.Enumerating();\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/ITimer.cs", "using System;\n\nnamespace AwesomeAssertions.Common;\n\n/// \n/// Abstracts a stopwatch so we can control time in unit tests.\n/// \npublic interface ITimer : IDisposable\n{\n /// \n /// The time elapsed since the timer was created through .\n /// \n TimeSpan Elapsed { get; }\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Collections/SortOrder.cs", "namespace AwesomeAssertions.Collections;\n\ninternal enum SortOrder\n{\n Ascending,\n Descending\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Extensions/StringExtensions.cs", "namespace AwesomeAssertions.Extensions;\n\ninternal static class StringExtensions\n{\n public static string FirstCharToLower(this string str) =>\n#pragma warning disable CA1308\n string.Concat(str[0].ToString().ToLowerInvariant(), str[1..]);\n#pragma warning restore CA1308\n}\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Formatting/ValueFormatterAttribute.cs", "using System;\n\nnamespace AwesomeAssertions.Formatting;\n\n/// \n/// Marks a static method as a kind of for a particular type.\n/// \n[AttributeUsage(AttributeTargets.Method)]\n#pragma warning disable CA1813 // Avoid unsealed attributes. This type has shipped.\npublic class ValueFormatterAttribute : Attribute;\n"], ["/AwesomeAssertions/Src/AwesomeAssertions/Common/StartTimer.cs", "namespace AwesomeAssertions.Common;\n\n/// \n/// Factory for starting a timer on demand.\n/// \npublic delegate ITimer StartTimer();\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/UIFactsDefinition.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs;\n\n// Try to stabilize UIFact tests\n[CollectionDefinition(\"UIFacts\", DisableParallelization = true)]\npublic class UIFactsDefinition;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/Formatting/FormatterSpecsDefinition.cs", "using Xunit;\n\nnamespace AwesomeAssertions.Specs.Formatting;\n\n// Due to the tests that (temporarily) modify the active formatters collection.\n[CollectionDefinition(\"FormatterSpecs\", DisableParallelization = true)]\npublic class FormatterSpecsDefinition;\n"], ["/AwesomeAssertions/Tests/AssemblyB/ClassC.cs", "namespace AssemblyB;\n\npublic class ClassC;\n"], ["/AwesomeAssertions/Tests/AssemblyB/ClassB.cs", "namespace AssemblyB;\n\npublic class ClassB;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Specs/IsExternalInit.cs", "using System.ComponentModel;\n\n// ReSharper disable once CheckNamespace\nnamespace System.Runtime.CompilerServices;\n\n/// \n/// Reserved to be used by the compiler for tracking metadata.\n/// This class should not be used by developers in source code.\n/// \n[EditorBrowsable(EditorBrowsableState.Never)]\ninternal static class IsExternalInit;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Equivalency.Specs/IsExternalInit.cs", "using System.ComponentModel;\n\n// ReSharper disable once CheckNamespace\nnamespace System.Runtime.CompilerServices;\n\n/// \n/// Reserved to be used by the compiler for tracking metadata.\n/// This class should not be used by developers in source code.\n/// \n[EditorBrowsable(EditorBrowsableState.Never)]\ninternal static class IsExternalInit;\n"], ["/AwesomeAssertions/Tests/AwesomeAssertions.Extensibility.Specs/Usings.cs", "global using Xunit;\n"]], "task_instance_info": {"created_time": "2025-08-20 19:01:54", "created_task_model": "DeepSeek-R1", "function_skeleton": "public EquivalencyResult Handle (Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes) {}", "code_description": "This code segment functions to: Perform direct equivalence validation between two objects under non-recursive conditions and report assertion failures using contextual messaging when discrepancies are detected."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```c_sharp\n[TASK_BEGIN]\n public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expected == null || comparands.Subject == null)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (comparands.Subject.GetType() != comparands.Expected.GetType())\n {\n return EquivalencyResult.ContinueWithNext;\n }\n\n if (EqualityComparer.Default.Equals(comparands.Subject, comparands.Expected))\n {\n return EquivalencyResult.AssertionCompleted;\n }\n\n throw new AssertionFailedException($\"Expected {comparands.Expected} but found {comparands.Subject}.\");\n }\n[TASK_END]\n```", "inference_time": "2025-08-20 19-02-23"}, "editdistance_info": {"edit_distance": 33.5484, "calculate_time": "2025-08-20 19:02:23", "true_code_clean": "public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (!context.Options.IsRecursive && !context.CurrentNode.IsRoot)\n {\n AssertionChain.GetOrCreate()\n .For(context)\n .ReuseOnce();\n comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);\n return EquivalencyResult.EquivalencyProven;\n }\n return EquivalencyResult.ContinueWithNext;\n }", "predict_code_clean": "public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,\n IValidateChildNodeEquivalency valueChildNodes)\n {\n if (comparands.Expected == null || comparands.Subject == null)\n {\n return EquivalencyResult.ContinueWithNext;\n }\n if (comparands.Subject.GetType() != comparands.Expected.GetType())\n {\n return EquivalencyResult.ContinueWithNext;\n }\n if (EqualityComparer.Default.Equals(comparands.Subject, comparands.Expected))\n {\n return EquivalencyResult.AssertionCompleted;\n }\n throw new AssertionFailedException($\"Expected {comparands.Expected} but found {comparands.Subject}.\");\n }"}}