Quantcast
Channel: Fluent Assertions
Viewing all articles
Browse latest Browse all 1402

Commented Issue: Building error message throws exception [11789]

$
0
0
Hi

We have an assertion like this

result.Should().BeSameAs(FindFileResult.NotFound)

that fails.

When FluentAssertions build the error message, it dumps the values of all properties. In our case this is a problem because one property throws an exception:

public class FindFileResult
{
public static readonly FindFileResult NotFound = new FindFileResult(null, false);

private readonly string filePath;

public FindFileResult(string filePath, bool found)
{
this.filePath = filePath;
this.Found = found;
}

public bool Found { get; private set; }

public string AbsoluteFilePath
{
get
{
if (!this.Found)
{
throw new InvalidOperationException("Path is not available when it is not found");
}

return this.filePath;
}
}
}

It would be nice if FluentAssertions would just ignore properties that result in an exception and continue with the next.

Cheers
Urs
Comments: Associated with changeset 73253.

Viewing all articles
Browse latest Browse all 1402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>