forked from fluentassertions/fluentassertions
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e57658
commit e462619
Showing
12 changed files
with
137 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Reflection; | ||
|
||
namespace FluentAssertions.Formatting; | ||
|
||
public class MethodInfoFormatter : IValueFormatter | ||
{ | ||
/// <summary> | ||
/// Indicates whether the current <see cref="IValueFormatter"/> can handle the specified <paramref name="value"/>. | ||
/// </summary> | ||
/// <param name="value">The value for which to create a <see cref="string"/>.</param> | ||
/// <returns> | ||
/// <see langword="true"/> if the current <see cref="IValueFormatter"/> can handle the specified value; otherwise, <see langword="false"/>. | ||
/// </returns> | ||
public bool CanHandle(object value) | ||
{ | ||
return value is MethodInfo; | ||
} | ||
|
||
public void Format(object value, FormattedObjectGraph formattedGraph, FormattingContext context, FormatChild formatChild) | ||
{ | ||
var method = (MethodInfo)value; | ||
if (method is null) | ||
{ | ||
formattedGraph.AddFragment("<null>"); | ||
} | ||
else | ||
{ | ||
formattedGraph.AddFragment($"{method}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.