Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust Identifier properties #1777

Merged
merged 2 commits into from Jan 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -230,5 +230,7 @@ public AndConstraint<TAssertions> NotHaveStatusCode(HttpStatusCode unexpected, s
private bool IsServerError() => (int)Subject.StatusCode is >= 500 and <= 599;

private bool IsClientError() => (int)Subject.StatusCode is >= 400 and <= 499;

protected override string Identifier => "HTTP response message";
}
}
1 change: 1 addition & 0 deletions Src/FluentAssertions/Primitives/ReferenceTypeAssertions.cs
Expand Up @@ -416,6 +416,7 @@ public AndConstraint<TAssertions> NotBeAssignableTo(Type type, string because =

/// <summary>
/// Returns the type of the subject the assertion applies on.
/// It should be a user-friendly name as it is included in the failure message.
/// </summary>
protected abstract string Identifier { get; }

Expand Down
2 changes: 0 additions & 2 deletions Src/FluentAssertions/Types/MethodBaseAssertions.cs
Expand Up @@ -93,8 +93,6 @@ public AndConstraint<TAssertions> NotHaveAccessModifier(CSharpAccessModifier acc
return new AndConstraint<TAssertions>((TAssertions)this);
}

protected override string Identifier => "methodBase";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MethodBaseAssertions is abstract and its two derivatives ConstructorInfoAssertions and MethodInfoAssertions overrides Identifier with "constructor" and "method", respectively.


internal static string GetParameterString(MethodBase methodBase)
{
IEnumerable<Type> parameterTypes = methodBase.GetParameters().Select(p => p.ParameterType);
Expand Down
2 changes: 2 additions & 0 deletions Src/FluentAssertions/Xml/XmlElementAssertions.cs
Expand Up @@ -165,5 +165,7 @@ public XmlElementAssertions(XmlElement xmlElement)

return new AndWhichConstraint<XmlElementAssertions, XmlElement>(this, element);
}

protected override string Identifier => "XML element";
}
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Xml/XmlNodeAssertions.cs
Expand Up @@ -80,6 +80,6 @@ public AndConstraint<TAssertions> NotBeEquivalentTo(XmlNode unexpected, string b
/// <summary>
/// Returns the type of the subject the assertion applies on.
/// </summary>
protected override string Identifier => "Xml Node";
protected override string Identifier => "XML node";
}
}
Expand Up @@ -1922,6 +1922,7 @@ namespace FluentAssertions.Primitives
where TAssertions : FluentAssertions.Primitives.HttpResponseMessageAssertions<TAssertions>
{
protected HttpResponseMessageAssertions(System.Net.Http.HttpResponseMessage value) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> BeRedirection(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeSuccessful(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveClientError(string because = "", params object[] becauseArgs) { }
Expand Down Expand Up @@ -2348,7 +2349,6 @@ namespace FluentAssertions.Types
where TAssertions : FluentAssertions.Types.MethodBaseAssertions<TSubject, TAssertions>
{
protected MethodBaseAssertions(TSubject subject) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> HaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotHaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
}
Expand Down Expand Up @@ -2645,6 +2645,7 @@ namespace FluentAssertions.Xml
public class XmlElementAssertions : FluentAssertions.Xml.XmlNodeAssertions<System.Xml.XmlElement, FluentAssertions.Xml.XmlElementAssertions>
{
public XmlElementAssertions(System.Xml.XmlElement xmlElement) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttribute(string expectedName, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttributeWithNamespace(string expectedName, string expectedNamespace, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndWhichConstraint<FluentAssertions.Xml.XmlElementAssertions, System.Xml.XmlElement> HaveElement(string expectedName, string because = "", params object[] becauseArgs) { }
Expand Down
Expand Up @@ -1922,6 +1922,7 @@ namespace FluentAssertions.Primitives
where TAssertions : FluentAssertions.Primitives.HttpResponseMessageAssertions<TAssertions>
{
protected HttpResponseMessageAssertions(System.Net.Http.HttpResponseMessage value) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> BeRedirection(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeSuccessful(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveClientError(string because = "", params object[] becauseArgs) { }
Expand Down Expand Up @@ -2350,7 +2351,6 @@ namespace FluentAssertions.Types
where TAssertions : FluentAssertions.Types.MethodBaseAssertions<TSubject, TAssertions>
{
protected MethodBaseAssertions(TSubject subject) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> HaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotHaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
}
Expand Down Expand Up @@ -2647,6 +2647,7 @@ namespace FluentAssertions.Xml
public class XmlElementAssertions : FluentAssertions.Xml.XmlNodeAssertions<System.Xml.XmlElement, FluentAssertions.Xml.XmlElementAssertions>
{
public XmlElementAssertions(System.Xml.XmlElement xmlElement) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttribute(string expectedName, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttributeWithNamespace(string expectedName, string expectedNamespace, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndWhichConstraint<FluentAssertions.Xml.XmlElementAssertions, System.Xml.XmlElement> HaveElement(string expectedName, string because = "", params object[] becauseArgs) { }
Expand Down
Expand Up @@ -1922,6 +1922,7 @@ namespace FluentAssertions.Primitives
where TAssertions : FluentAssertions.Primitives.HttpResponseMessageAssertions<TAssertions>
{
protected HttpResponseMessageAssertions(System.Net.Http.HttpResponseMessage value) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> BeRedirection(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeSuccessful(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveClientError(string because = "", params object[] becauseArgs) { }
Expand Down Expand Up @@ -2350,7 +2351,6 @@ namespace FluentAssertions.Types
where TAssertions : FluentAssertions.Types.MethodBaseAssertions<TSubject, TAssertions>
{
protected MethodBaseAssertions(TSubject subject) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> HaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotHaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
}
Expand Down Expand Up @@ -2647,6 +2647,7 @@ namespace FluentAssertions.Xml
public class XmlElementAssertions : FluentAssertions.Xml.XmlNodeAssertions<System.Xml.XmlElement, FluentAssertions.Xml.XmlElementAssertions>
{
public XmlElementAssertions(System.Xml.XmlElement xmlElement) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttribute(string expectedName, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttributeWithNamespace(string expectedName, string expectedNamespace, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndWhichConstraint<FluentAssertions.Xml.XmlElementAssertions, System.Xml.XmlElement> HaveElement(string expectedName, string because = "", params object[] becauseArgs) { }
Expand Down
Expand Up @@ -1875,6 +1875,7 @@ namespace FluentAssertions.Primitives
where TAssertions : FluentAssertions.Primitives.HttpResponseMessageAssertions<TAssertions>
{
protected HttpResponseMessageAssertions(System.Net.Http.HttpResponseMessage value) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> BeRedirection(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeSuccessful(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveClientError(string because = "", params object[] becauseArgs) { }
Expand Down Expand Up @@ -2301,7 +2302,6 @@ namespace FluentAssertions.Types
where TAssertions : FluentAssertions.Types.MethodBaseAssertions<TSubject, TAssertions>
{
protected MethodBaseAssertions(TSubject subject) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> HaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotHaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
}
Expand Down Expand Up @@ -2598,6 +2598,7 @@ namespace FluentAssertions.Xml
public class XmlElementAssertions : FluentAssertions.Xml.XmlNodeAssertions<System.Xml.XmlElement, FluentAssertions.Xml.XmlElementAssertions>
{
public XmlElementAssertions(System.Xml.XmlElement xmlElement) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttribute(string expectedName, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttributeWithNamespace(string expectedName, string expectedNamespace, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndWhichConstraint<FluentAssertions.Xml.XmlElementAssertions, System.Xml.XmlElement> HaveElement(string expectedName, string because = "", params object[] becauseArgs) { }
Expand Down
Expand Up @@ -1922,6 +1922,7 @@ namespace FluentAssertions.Primitives
where TAssertions : FluentAssertions.Primitives.HttpResponseMessageAssertions<TAssertions>
{
protected HttpResponseMessageAssertions(System.Net.Http.HttpResponseMessage value) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> BeRedirection(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeSuccessful(string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveClientError(string because = "", params object[] becauseArgs) { }
Expand Down Expand Up @@ -2350,7 +2351,6 @@ namespace FluentAssertions.Types
where TAssertions : FluentAssertions.Types.MethodBaseAssertions<TSubject, TAssertions>
{
protected MethodBaseAssertions(TSubject subject) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<TAssertions> HaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotHaveAccessModifier(FluentAssertions.Common.CSharpAccessModifier accessModifier, string because = "", params object[] becauseArgs) { }
}
Expand Down Expand Up @@ -2647,6 +2647,7 @@ namespace FluentAssertions.Xml
public class XmlElementAssertions : FluentAssertions.Xml.XmlNodeAssertions<System.Xml.XmlElement, FluentAssertions.Xml.XmlElementAssertions>
{
public XmlElementAssertions(System.Xml.XmlElement xmlElement) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttribute(string expectedName, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.Xml.XmlElementAssertions> HaveAttributeWithNamespace(string expectedName, string expectedNamespace, string expectedValue, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndWhichConstraint<FluentAssertions.Xml.XmlElementAssertions, System.Xml.XmlElement> HaveElement(string expectedName, string because = "", params object[] becauseArgs) { }
Expand Down