fluentassertions / fluentassertions/fluentassertions.analyzers
Create a refactoring for asserting exceptions properties
- Vorherrschende Sprache
- C#
- Sterne
- 131
- Forks
- 25
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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;
}
}
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.