コード例 #1
0
        private void AssertValueRoundtrip(TTarget target, TValue value)
        {
            AssertionHelper.Explain(() =>
                                    Assert.DoesNotThrow(() => SetValue(target, value)),
                                    innerFailures => new AssertionFailureBuilder(
                                        "Expected the tested 'Setter' to not throw any exception while invoked with a specific value.")
                                    .AddRawActualValue(value)
                                    .AddInnerFailures(innerFailures)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .ToAssertionFailure());

            TValue actual = default(TValue);

            AssertionHelper.Explain(() =>
                                    Assert.DoesNotThrow(() => actual = GetValue(target)),
                                    innerFailures => new AssertionFailureBuilder(
                                        "Expected the tested 'Getter' to not throw any exception while invoked to get the actual value.")
                                    .AddInnerFailures(innerFailures)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .ToAssertionFailure());

            AssertionHelper.Explain(() =>
                                    Assert.AreEqual(value, actual),
                                    innerFailures => new AssertionFailureBuilder(
                                        "Expected the 'Getter' to provide an actual value equal to the value previously assigned with the 'Setter'.")
                                    .AddRawExpectedValue(value)
                                    .AddRawActualValue(actual)
                                    .AddInnerFailures(innerFailures)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .ToAssertionFailure());
        }
コード例 #2
0
        private Test CreateClearTest()
        {
            return(new TestCase("ClearItems", () =>
            {
                AssertDistinctIntancesNotEmpty();
                var collection = GetSafeDefaultInstance();

                if (collection.Count == 0)
                {
                    // The default instance is empty: add some items.
                    foreach (var item in DistinctInstances)
                    {
                        collection.Add(item);
                    }
                }

                collection.Clear();

                AssertionHelper.Explain(() =>
                                        Assert.AreEqual(0, collection.Count),
                                        innerFailures => new AssertionFailureBuilder(
                                            "Expected the collection to be empty once the 'Clear' method was called on it.")
                                        .AddLabeledValue("Property", "Count")
                                        .AddRawLabeledValue("Expected Value", 0)
                                        .AddRawLabeledValue("Actual Value", collection.Count)
                                        .SetStackTrace(Context.GetStackTraceData())
                                        .AddInnerFailures(innerFailures)
                                        .ToAssertionFailure());
            }));
        }
コード例 #3
0
        private Test CreateSetInvalidValuesTest(string name)
        {
            return(new TestCase(name, () =>
            {
                AssertValid();
                var target = GetSafeDefaultInstance();

                Assert.Multiple(() =>
                {
                    foreach (var incompetenceClass in InvalidValues)
                    {
                        foreach (var incompetentValue in incompetenceClass)
                        {
                            AssertionHelper.Explain(() =>
                                                    Assert.Throws(incompetenceClass.ExpectedExceptionType, () => SetValue(target, incompetentValue)),
                                                    innerFailures => new AssertionFailureBuilder(
                                                        "Expected the 'Setter' to throw a specific exception while invoked with an invalid value.")
                                                    .AddRawLabeledValue("Invalid Value", incompetentValue)
                                                    .AddRawLabeledValue("Expected Exception", incompetenceClass.ExpectedExceptionType)
                                                    .AddInnerFailures(innerFailures)
                                                    .SetStackTrace(Context.GetStackTraceData())
                                                    .ToAssertionFailure());
                        }
                    }
                });
            }));
        }
コード例 #4
0
 public void Explain_should_throw_exception_when_action_argument_is_null()
 {
     AssertionHelper.Explain(null,
                             innerFailures =>
                             new AssertionFailureBuilder("Boom!")
                             .AddInnerFailures(innerFailures)
                             .ToAssertionFailure());
 }
コード例 #5
0
 /// <summary>
 /// Asserts that the collection of distinct instances specified by the user is not empty.
 /// </summary>
 protected void AssertDistinctIntancesNotEmpty()
 {
     AssertionHelper.Explain(() =>
                             Assert.GreaterThan(DistinctInstances.Instances.Count, 0),
                             innerFailures => new AssertionFailureBuilder("Expected the collection of distinct instances to be not empty.\n" +
                                                                          "Please feed the 'DistinctInstances' property of your collection contract with some valid objects.")
                             .SetStackTrace(Context.GetStackTraceData())
                             .AddInnerFailures(innerFailures)
                             .ToAssertionFailure());
 }
コード例 #6
0
 private void AssertCopyToNotThrowException(Action action, string failureMessage)
 {
     AssertionHelper.Explain(() =>
                             Assert.DoesNotThrow(() => action()),
                             innerFailures => new AssertionFailureBuilder(failureMessage)
                             .AddLabeledValue("Method", "CopyTo")
                             .SetStackTrace(Context.GetStackTraceData())
                             .AddInnerFailures(innerFailures)
                             .ToAssertionFailure());
 }
コード例 #7
0
 private void AssertCopyToThrowException(Action action, string failureMessage, string label, object value)
 {
     AssertionHelper.Explain(() =>
                             Assert.Throws <Exception>(() => action()),
                             innerFailures => new AssertionFailureBuilder(
                                 "Expected the method to throw an exception " + failureMessage)
                             .AddLabeledValue("Method", "CopyTo")
                             .AddRawLabeledValue(label, value)
                             .SetStackTrace(Context.GetStackTraceData())
                             .AddInnerFailures(innerFailures)
                             .ToAssertionFailure());
 }
コード例 #8
0
        private void AssertValid()
        {
            Assert.Multiple(() =>
            {
                if (PropertyName == null)
                {
                    AssertionHelper.Explain(() =>
                    {
                        Assert.IsNotNull(Setter);
                        Assert.IsNotNull(Getter);
                    },
                                            innerFailures => new AssertionFailureBuilder("Expected the 'Setter' and the 'Getter' properties to be not " +
                                                                                         "null when the name of the tested property is not specified. Please specify a valid action that assigns " +
                                                                                         "the given value to the target object and a valid function that returns the current value from the target " +
                                                                                         "object, or specify the name of the tested property.")
                                            .AddInnerFailures(innerFailures)
                                            .SetStackTrace(Context.GetStackTraceData())
                                            .ToAssertionFailure());
                }
                else
                {
                    AssertionHelper.Explain(() =>
                    {
                        Assert.IsNull(Setter);
                        Assert.IsNull(Getter);
                    },
                                            innerFailures => new AssertionFailureBuilder("Expected the 'Setter' and the 'Getter' properties to be " +
                                                                                         "null when the name of the tested property is specified.")
                                            .AddInnerFailures(innerFailures)
                                            .SetStackTrace(Context.GetStackTraceData())
                                            .ToAssertionFailure());

                    AssertionHelper.Explain(() =>
                                            Assert.IsNotNull(GetProperty()),
                                            innerFailures => new AssertionFailureBuilder("Expected the tested property to be found. " +
                                                                                         "Only instance public (or internal) properties can be tested.")
                                            .AddRawLabeledValue("Tested Type", typeof(TTarget))
                                            .AddLabeledValue("Searched Property Name", PropertyName)
                                            .AddInnerFailures(innerFailures)
                                            .SetStackTrace(Context.GetStackTraceData())
                                            .ToAssertionFailure());
                }

                AssertionHelper.Explain(() =>
                                        Assert.IsNotEmpty(ValidValues),
                                        innerFailures => new AssertionFailureBuilder("Expected collection of valid value instances to be not empty.")
                                        .SetMessage("Please feed the collection of valid values with '{0}' instances.", typeof(TValue))
                                        .AddInnerFailures(innerFailures)
                                        .SetStackTrace(Context.GetStackTraceData())
                                        .ToAssertionFailure());
            });
        }
コード例 #9
0
 protected void AssertContained(TItem item, string failureMessage)
 {
     AssertionHelper.Explain(() =>
                             Assert.Contains(collection, item),
                             innerFailures => new AssertionFailureBuilder(failureMessage)
                             .AddRawLabeledValue("Just Added Item", item)
                             .AddLabeledValue("Method Called", "Contains")
                             .AddRawLabeledValue("Expected Returned Value", true)
                             .AddRawLabeledValue("Actual Returned Value", false)
                             .SetStackTrace(context.GetStackTraceData())
                             .AddInnerFailures(innerFailures)
                             .ToAssertionFailure());
 }
コード例 #10
0
ファイル: ListHandler.cs プロジェクト: citizenmatt/gallio
        private void AssertIndexOfMissingItem(TItem item)
        {
            int result = List.IndexOf(item);

            AssertionHelper.Explain(() =>
                                    Assert.LessThan(result, 0),
                                    innerFailures => new AssertionFailureBuilder(
                                        "Expected the method to return a negative value indicating that a missing item is not present in the list.")
                                    .AddLabeledValue("Method", "IndexOf")
                                    .AddRawLabeledValue("Actual Result", result)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }
コード例 #11
0
 protected void AssertAddItemOk(TItem item, string failureMessage)
 {
     AssertionHelper.Explain(() =>
                             Assert.DoesNotThrow(() =>
     {
         collection.Add(item);
         CountTrack++;
     }),
                             innerFailures => new AssertionFailureBuilder(
                                 failureMessage + "\nAn exception was thrown while none was expected.")
                             .SetStackTrace(context.GetStackTraceData())
                             .AddInnerFailures(innerFailures)
                             .ToAssertionFailure());
 }
コード例 #12
0
ファイル: ListHandler.cs プロジェクト: citizenmatt/gallio
        private void AssertIndexOfPresentItem(TItem item)
        {
            int result = List.IndexOf(item);

            AssertionHelper.Explain(() =>
                                    Assert.GreaterThanOrEqualTo(result, 0),
                                    innerFailures => new AssertionFailureBuilder(
                                        "Expected the method to return zero or a positive value indicating that an item was found in the list.")
                                    .AddLabeledValue("Method", "IndexOf")
                                    .AddRawLabeledValue("Actual Result", result)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }
コード例 #13
0
ファイル: ListHandler.cs プロジェクト: citizenmatt/gallio
 private void AssertInsertItemOk(int index, TItem item, string failureMessage)
 {
     AssertionHelper.Explain(() =>
                             Assert.DoesNotThrow(() =>
     {
         List.Insert(index, item);
         CountTrack++;
     }),
                             innerFailures => new AssertionFailureBuilder(
                                 failureMessage + "\nAn exception was thrown while none was expected.")
                             .SetStackTrace(Context.GetStackTraceData())
                             .AddInnerFailures(innerFailures)
                             .ToAssertionFailure());
 }
コード例 #14
0
        protected void AssertCount(string failureMessage)
        {
            int actual = collection.Count;

            AssertionHelper.Explain(() =>
                                    Assert.AreEqual(CountTrack, actual),
                                    innerFailures => new AssertionFailureBuilder(failureMessage)
                                    .AddLabeledValue("Property", "Count")
                                    .AddRawLabeledValue("Expected Value", CountTrack)
                                    .AddRawLabeledValue("Actual Value", actual)
                                    .SetStackTrace(context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }
コード例 #15
0
ファイル: AbstractContract.cs プロジェクト: kuzeygh/mbunit-v3
        /// <summary>
        /// Verifies that the specified method info object is not null, indicating that the
        /// method exists, otherwise raises an assertion failure and describes the expected method signature.
        /// </summary>
        /// <param name="method">The method, or null if missing.</param>
        /// <param name="methodSignature">The expected method signature for diagnostic output.</param>
        /// <param name="failsIfNotExists">Thrown a assertion failure exception if the method does not exist.</param>
        /// <returns>True if the method exists; otherwise false.</returns>
        protected static bool MethodExists(MethodInfo method, string methodSignature, bool failsIfNotExists)
        {
            if (failsIfNotExists)
            {
                AssertionHelper.Explain(() =>
                                        Assert.IsNotNull(method),
                                        innerFailures => new AssertionFailureBuilder("Expected a method to exist.")
                                        .AddLabeledValue("Expected Method", methodSignature)
                                        .AddInnerFailures(innerFailures)
                                        .ToAssertionFailure());
            }

            return(method != null);
        }
コード例 #16
0
 protected void AssertAddItemFails(TItem item, string failureMessage)
 {
     AssertionHelper.Explain(() =>
                             Assert.Throws <Exception>(() => // Any type of exception will make it!
     {
         collection.Add(item);
         CountTrack++;
     }),
                             innerFailures => new AssertionFailureBuilder(
                                 failureMessage + "\nNo exception was thrown while one was expected.")
                             .AddLabeledValue("Expected Exception Type", "Any")
                             .SetStackTrace(context.GetStackTraceData())
                             .AddInnerFailures(innerFailures)
                             .ToAssertionFailure());
 }
コード例 #17
0
        public void Explain_should_return_empty_result_when_no_failures_have_occured()
        {
            AssertionFailure[] failures = AssertionHelper.Eval(() =>
            {
                AssertionHelper.Explain(() =>
                {
                    // No failing assertion.
                }, innerFailures =>
                                        new AssertionFailureBuilder("Ugh?")
                                        .AddInnerFailures(innerFailures)
                                        .ToAssertionFailure());
            });

            Assert.IsEmpty(failures);
        }
コード例 #18
0
ファイル: ListHandler.cs プロジェクト: citizenmatt/gallio
 private void AssertInsertItemFails(int index, TItem item, string failureMessage)
 {
     AssertionHelper.Explain(() =>
                             Assert.Throws <Exception>(() =>
     {
         List.Insert(index, item);
         CountTrack++;
     }),
                             innerFailures => new AssertionFailureBuilder(
                                 failureMessage + "\nNo exception was thrown while one was expected.")
                             .AddLabeledValue("Expected Exception Type", "Any")
                             .SetStackTrace(Context.GetStackTraceData())
                             .AddInnerFailures(innerFailures)
                             .ToAssertionFailure());
 }
コード例 #19
0
        /// <summary>
        /// Returns safely a default instance of the tested type.
        /// </summary>
        /// <remarks>
        /// <para>
        /// An assertion failure is generated if the instance cannot be created.
        /// </para>
        /// </remarks>
        /// <returns>A new instance of the tested type as specified in the contract.</returns>
        /// <exception cref="AssertionFailureException">Thrown if the instance cannot be generated.</exception>
        protected TCollection GetSafeDefaultInstance()
        {
            TCollection target = default(TCollection);

            AssertionHelper.Explain(() =>
                                    Assert.DoesNotThrow(() => target = DefaultInstance()),
                                    innerFailures => new AssertionFailureBuilder(
                                        "Cannot instantiate a default instance of the tested type.")
                                    .SetMessage("Please feed the contract property 'DefaultInstance' with a valid instance of type '{0}'.", typeof(TCollection))
                                    .AddInnerFailures(innerFailures)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .ToAssertionFailure());

            return(target);
        }
コード例 #20
0
ファイル: ListHandler.cs プロジェクト: citizenmatt/gallio
        public void DoActionAtInvalidIndex(Func <TList, int> getInvalidIndex, Action <TList, int> action, string actionName)
        {
            int invalidIndex = getInvalidIndex(List);

            AssertionHelper.Explain(() =>
                                    Assert.Throws <ArgumentOutOfRangeException>(() => action(List, invalidIndex)),
                                    innerFailures => new AssertionFailureBuilder(
                                        "Expected a method of the list to throw an particular exception when called with a invalid argument.")
                                    .AddLabeledValue("Method", actionName)
                                    .AddLabeledValue("Invalid Argument Name", "index")
                                    .AddRawLabeledValue("Invalid Argument Value", invalidIndex)
                                    .AddRawLabeledValue("Expected Exception", typeof(ArgumentOutOfRangeException))
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }
コード例 #21
0
        private void VerifyComparison <TResult>(ComparisonSpecifications <TResult> spec, ComparerDelegate <TResult> comparer, MethodInfo methodInfo, InstancePair pair)
        {
            string actual   = spec.FormatResult(comparer(pair.First, pair.Second));
            string expected = spec.FormatResult(spec.AdjustExpectedEquivalence(pair.Equivalence));

            AssertionHelper.Explain(() =>
                                    Assert.AreEqual(expected, actual),
                                    innerFailures => new AssertionFailureBuilder("The comparison between left and right values did not produce the expected result.")
                                    .AddRawLabeledValue("Left Value", pair.First)
                                    .AddRawLabeledValue("Right Value", pair.Second)
                                    .AddRawLabeledValue("Expected Result", expected)
                                    .AddRawLabeledValue("Actual Result", actual)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }
コード例 #22
0
        private void VerifyHashCodeOfEquivalentInstances(object first, object second)
        {
            int firstHashCode  = first.GetHashCode();
            int secondHashCode = second.GetHashCode();

            AssertionHelper.Explain(() =>
                                    Assert.AreEqual(firstHashCode, secondHashCode),
                                    innerFailures => new AssertionFailureBuilder(
                                        "Expected the hash codes of two values within the same equivalence class to be equal.")
                                    .AddRawLabeledValue("First Value", first)
                                    .AddRawLabeledValue("First Hash Code", firstHashCode)
                                    .AddRawLabeledValue("Second Value", second)
                                    .AddRawLabeledValue("Second Hash Code", secondHashCode)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }
コード例 #23
0
        private void VerifyEquality(EqualitySpecifications spec, BinaryCompareDelegate comparer, MethodInfo methodInfo, InstancePair pair)
        {
            bool actual   = comparer(pair.First, pair.Second);
            bool expected = !(pair.AreEquivalent ^ spec.ExpectedEquality);

            AssertionHelper.Explain(() =>
                                    Assert.AreEqual(expected, actual),
                                    innerFailures => new AssertionFailureBuilder(
                                        "The equality comparison between left and right values did not produce the expected result.")
                                    .AddRawLabeledValue("Left Value", pair.First)
                                    .AddRawLabeledValue("Right Value", pair.Second)
                                    .AddRawLabeledValue("Expected Result", expected)
                                    .AddRawLabeledValue("Actual Result", actual)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }
コード例 #24
0
        /// <summary>
        /// Creates a test which runs an action over the collection with
        /// a null argument. The test expects that an exception be thrown.
        /// </summary>
        /// <param name="methodName">The name of the tested method.</param>
        /// <param name="invoke">The action to evaluate.</param>
        /// <returns></returns>
        protected Test CreateNullArgumentTest(string methodName, Action <TCollection> invoke)
        {
            return(new TestCase(String.Format("{0}NullArgument", methodName), () =>
            {
                var collection = GetSafeDefaultInstance();

                AssertionHelper.Explain(() =>
                                        Assert.Throws <ArgumentNullException>(() => invoke(collection)),
                                        innerFailures => new AssertionFailureBuilder(
                                            "Expected a method to throw an exception when called with a null argument.")
                                        .AddLabeledValue("Method", methodName)
                                        .AddRawLabeledValue("Expected Exception", typeof(ArgumentNullException))
                                        .SetStackTrace(Context.GetStackTraceData())
                                        .AddInnerFailures(innerFailures)
                                        .ToAssertionFailure());
            }));
        }
コード例 #25
0
        private Test CreateVerifyReadOnlyPropertyTest()
        {
            return(new TestCase("VerifyReadOnlyProperty", () =>
            {
                var collection = GetSafeDefaultInstance();

                AssertionHelper.Explain(() =>
                                        Assert.AreEqual(IsReadOnly, collection.IsReadOnly),
                                        innerFailures => new AssertionFailureBuilder(
                                            "Expected the read-only property of the collection to return a specific value.")
                                        .AddLabeledValue("Property", "IsReadOnly")
                                        .AddRawLabeledValue("Expected Value", IsReadOnly)
                                        .AddRawLabeledValue("Actual Value", collection.IsReadOnly)
                                        .SetStackTrace(Context.GetStackTraceData())
                                        .AddInnerFailures(innerFailures)
                                        .ToAssertionFailure());
            }));
        }
コード例 #26
0
        private Test CreateSerializationConstructorTest(string name)
        {
            return(new TestCase(name, () =>
            {
                var constructor = typeof(TException).GetConstructor(
                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null,
                    new[] { typeof(SerializationInfo), typeof(StreamingContext) }, null);

                AssertionHelper.Explain(() =>
                                        Assert.IsNotNull(constructor),
                                        innerFailures => new AssertionFailureBuilder(
                                            "Expected the exception type to have a serialization constructor with signature .ctor(SerializationInfo, StreamingContext).")
                                        .AddRawLabeledValue("Exception Type", typeof(TException))
                                        .SetStackTrace(Context.GetStackTraceData())
                                        .AddInnerFailures(innerFailures)
                                        .ToAssertionFailure());
            }));
        }
コード例 #27
0
        public void Explain_should_decorate_an_inner_assertion_failure()
        {
            AssertionFailure[] failures = AssertionHelper.Eval(() =>
            {
                AssertionHelper.Explain(() =>
                {
                    Assert.Fail("Inner reason");
                }, innerFailures =>
                                        new AssertionFailureBuilder("Outer reason")
                                        .AddInnerFailures(innerFailures)
                                        .ToAssertionFailure());
            });

            Assert.Count(1, failures);
            Assert.AreEqual("Outer reason", failures[0].Description);
            Assert.Count(1, failures[0].InnerFailures);
            Assert.AreEqual("Inner reason", failures[0].InnerFailures[0].Message);
        }
コード例 #28
0
        public void Explain_should_decorate_several_inner_assertion_failures()
        {
            AssertionFailure[] failures = AssertionHelper.Eval(() =>
            {
                AssertionHelper.Explain(() =>
                {
                    Assert.Fail("Inner reason #1");
                    Assert.Fail("Inner reason #2");
                }, AssertionFailureBehavior.CaptureAndContinue, innerFailures =>
                                        new AssertionFailureBuilder("Outer reason")
                                        .AddInnerFailures(innerFailures)
                                        .ToAssertionFailure());
            });

            Assert.Count(1, failures);
            Assert.AreEqual("Outer reason", failures[0].Description);
            Assert.Count(2, failures[0].InnerFailures);
            Assert.AreEqual("Inner reason #1", failures[0].InnerFailures[0].Message);
            Assert.AreEqual("Inner reason #2", failures[0].InnerFailures[1].Message);
        }
コード例 #29
0
        protected void AssertRemoveItem(TItem item, bool expectedResult, string failureMessage)
        {
            bool actualResult = collection.Remove(item);

            if (actualResult)
            {
                CountTrack--;
            }

            AssertionHelper.Explain(() =>
                                    Assert.AreEqual(expectedResult, actualResult),
                                    innerFailures => new AssertionFailureBuilder(failureMessage)
                                    .AddRawLabeledValue("Item", item)
                                    .AddLabeledValue("Method", "Remove")
                                    .AddRawLabeledValue("Expected Returned Value", expectedResult)
                                    .AddRawLabeledValue("Actual Returned Value", actualResult)
                                    .SetStackTrace(context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }
コード例 #30
0
        /// <summary>
        /// Creates a test that invokes an action over the collection, which
        /// is supposed to not be supported. The test expects that an exception be thrown.
        /// </summary>
        /// <param name="methodName">The name of the tested method.</param>
        /// <param name="invoke">The action to evaluate.</param>
        /// <returns></returns>
        protected Test CreateNotSupportedWriteTest(string methodName, Action <TCollection, TItem> invoke)
        {
            return(new TestCase(String.Format("{0}ShouldThrowException", methodName), () =>
            {
                AssertDistinctIntancesNotEmpty();

                foreach (var item in DistinctInstances)
                {
                    var collection = GetSafeDefaultInstance();

                    AssertionHelper.Explain(() =>
                                            Assert.Throws <Exception>(() => invoke(collection, item)),
                                            innerFailures => new AssertionFailureBuilder(
                                                "Expected a method of the read-only collection to throw an exception when called.")
                                            .AddLabeledValue("Method", methodName)
                                            .SetStackTrace(Context.GetStackTraceData())
                                            .AddInnerFailures(innerFailures)
                                            .ToAssertionFailure());
                }
            }));
        }