fluentassertions / fluentassertions/fluentassertions.analyzers
Create a refactoring for asserting exceptions properties
- Dominant language
- C#
- Stars
- 131
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
for example:
```cs
public class MyCustomException : Exception
{
public string MyCustomProperty { get; }
public MyCustomException(string myCustomProperty)
{
MyCustomProperty = MyCustomProperty;
}
}
```
when hovering over the property `MyCustomProperty` I would like to have a suggestion to generate an assertion for that property.
The generated assertion will something like this:
```cs
public static class MyCustomExceptionExtensions
{
public static ExceptionAssertions WithMyCustomProperty(this ExceptionAssertions assertions,
string expectedMyCustomProperty, string because = "", params object[] becauseArgs) where TException : MyCustomException
{
Execute.Assertion
.ForCondition(assertions.And.MyCustomProperty.Equals(expectedMyCustomProperty))
.BecauseOf(because, becauseArgs)
.FailWith("Expected exception with MyCustomProperty {0}{reason}, but found {1}.", assertions.And.MyCustomProperty, expectedMyCustomProperty);
return assertions;
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
No files, tests, or entry points are named in the issue, so first locate the analyzer's refactoring implementations and their tests. Use the requested C# exception-property example to define the generated assertion and verify that hovering over a property offers the refactoring with the expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100