Skip to content

Commit

Permalink
Merge pull request #1839 from eNeRGy164/strike
Browse files Browse the repository at this point in the history
Improve code coverage and fix some test mutations
  • Loading branch information
jnyrup committed Mar 14, 2022
2 parents 6a4ee57 + b146a4a commit f4c4ab3
Show file tree
Hide file tree
Showing 19 changed files with 2,190 additions and 1,963 deletions.
8 changes: 4 additions & 4 deletions Src/FluentAssertions/Xml/XDocumentAssertions.cs
Expand Up @@ -132,7 +132,7 @@ public AndConstraint<XDocumentAssertions> NotBeEquivalentTo(XDocument unexpected
params object[] becauseArgs)
{
Guard.ThrowIfArgumentIsNull(expected, nameof(expected),
"Cannot assert the document has a root element if the element name is <null>*");
"Cannot assert the document has a root element if the expected name is <null>*");

return HaveRoot(XNamespace.None + expected, because, becauseArgs);
}
Expand All @@ -157,7 +157,7 @@ public AndConstraint<XDocumentAssertions> NotBeEquivalentTo(XDocument unexpected
}

Guard.ThrowIfArgumentIsNull(expected, nameof(expected),
"Cannot assert the document has a root element if the element name is <null>*");
"Cannot assert the document has a root element if the expected name is <null>*");

XElement root = Subject.Root;

Expand Down Expand Up @@ -189,7 +189,7 @@ public AndConstraint<XDocumentAssertions> NotBeEquivalentTo(XDocument unexpected
params object[] becauseArgs)
{
Guard.ThrowIfArgumentIsNull(expected, nameof(expected),
"Cannot assert the document has an element if the element name is <null>*");
"Cannot assert the document has an element if the expected name is <null>*");

return HaveElement(XNamespace.None + expected, because, becauseArgs);
}
Expand Down Expand Up @@ -217,7 +217,7 @@ public AndConstraint<XDocumentAssertions> NotBeEquivalentTo(XDocument unexpected
}

Guard.ThrowIfArgumentIsNull(expected, nameof(expected),
"Cannot assert the document has an element if the element name is <null>*");
"Cannot assert the document has an element if the expected name is <null>*");

Execute.Assertion
.ForCondition(Subject.Root is not null)
Expand Down
3 changes: 1 addition & 2 deletions Src/FluentAssertions/Xml/XmlNodeFormatter.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Xml;
using System.Xml;
using FluentAssertions.Common;
using FluentAssertions.Formatting;

Expand Down
Expand Up @@ -13,8 +13,6 @@ namespace FluentAssertions.Specs.Collections
/// </content>
public partial class CollectionAssertionSpecs
{
#region Contain Single

[Fact]
public void When_injecting_a_null_predicate_into_ContainSingle_it_should_throw()
{
Expand Down Expand Up @@ -272,6 +270,22 @@ public void When_collection_is_IEnumerable_it_should_be_evaluated_only_once()
act.Should().NotThrow();
}

#endregion
[Fact]
public void When_an_assertion_fails_on_ContainSingle_succeeding_message_should_be_included()
{
// Act
Action act = () =>
{
using var _ = new AssertionScope();
var values = new List<int>();
values.Should().ContainSingle();
values.Should().ContainSingle();
};

// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected*to contain a single item, but the collection is empty*" +
"Expected*to contain a single item, but the collection is empty*");
}
}
}
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using FluentAssertions.Execution;
using Xunit;
using Xunit.Sdk;

Expand Down Expand Up @@ -1570,6 +1571,24 @@ public void When_a_dictionary_checks_a_list_of_keys_not_to_be_present_it_will_ho
// Assert
act.Should().Throw<XunitException>();
}

[Fact]
public void When_an_assertion_fails_on_ContainKey_succeeding_message_should_be_included()
{
// Act
Action act = () =>
{
using var _ = new AssertionScope();
var values = new Dictionary<int, int>();
values.Should().ContainKey(0);
values.Should().ContainKey(1);
};

// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected*to contain key 0*Expected*to contain key 1*");
}

#endregion

#region ContainValue
Expand Down

0 comments on commit f4c4ab3

Please sign in to comment.