Menu

Tree [27f69f] default tip /
 History

Read Only access


File Date Author Commit
 Thunder.FluentAssertions.Extensions 2022-09-22 Thunder Thunder [27f69f] Initial commit - includes That and GenericShoul...
 Thunder.FluentAssertions.Extensions.Tests 2022-09-22 Thunder Thunder [27f69f] Initial commit - includes That and GenericShoul...
 .hgignore 2022-09-22 Thunder Thunder [27f69f] Initial commit - includes That and GenericShoul...
 README.MD 2022-09-22 Thunder Thunder [27f69f] Initial commit - includes That and GenericShoul...
 Thunder.FluentAssertations.Extensions.sln 2022-09-22 Thunder Thunder [27f69f] Initial commit - includes That and GenericShoul...

Read Me

# Thunder.FluentAssertions.Extensions
Extends FluentAssertion to have some more basic helpers.

Project Site: https://sourceforge.net/projects/thunder-webview-linux/
Source Code: https://sourceforge.net/projects/thunder-webview-linux/code
Nuget: https://www.nuget.org/packages/Thunder.FluentAssertions.Extensions/


## GenericShould

Added a `GenericShould` "overload" for `Should`. This allows the original value to be exposed via `Which` after usage. e.g.

```csharp
//base FluentAssertion library:
((Sut) sut.Should().NotBeNull().Subject).PropertyOnSut.Should().Be("value");

//with GenericShould instead of Should
sut.GenericShould().NotBeDefault()
    .Which.PropertyOnSut.Should().Be("value")
```

This was named `GenericShould` so as to not interfere with non-generic, specific `Should` methods, e.g. Collections, Exceptions, etc. This discussion can be seen on this [Github issue](https://github.com/fluentassertions/fluentassertions/issues/198).


## That

Added a `That` extension method on AndWhichAssertions which allows daisy chaining calls on properties, in place of `and` or `which`:

```csharp
//base FluentAssertions - there's no way back to the SUT once you go into the Property, and requires restarting the chain
sut.Should().NotBeNull();
sut.Property1.Should().Be("value");
sut.Property2.Should().Be("value");

//with That extension method
//this can continue indefinitely, or continue with an And or Which.
sut.Should().BeAssignableTo<SUT>()
    .That( x => x.Property1.Should().Be("value1"))
    .That( x => x.Property2.Should().Be("value2"));
    
//when paired with GenericShould():
sut.GenericShould().NotBeDefault()
    .That( x => x.Property1.Should().Be("value1"))
    .That( x => x.Property2.Should().Be("value2"));

//this also permits nesting, as desired:
sut.Should().BeAssignableTo<SUT>()
    .That( x =>
     {
        x.NestedModel.Should().BeAssignableTo<NestedSUT>()
            .That( nested => nested.NestedProperty.Should().Be("value")
     }));
```
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.