Skip to content

Commit

Permalink
Merge pull request #1656 from eNeRGy164/markdown-linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyrup committed Aug 20, 2021
2 parents 5573eaf + d6ea6c1 commit a977427
Show file tree
Hide file tree
Showing 21 changed files with 202 additions and 134 deletions.
8 changes: 8 additions & 0 deletions docs/.markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
default: true

MD013:
false

MD024:
# Only check sibling headings
siblings_only: true
13 changes: 7 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# How to contribute
# How to contribute

The Fluent Assertions [landing page](https://fluentassertions.com) is using Jekyll and Github Pages.

## How to Build this Site

### Prerequisites

* Ruby 2.4.x (note: 2.5 and higher may fail due to the `ffi` ruby lib only supporting < 2.5). An easy way to install is to use `choco install ruby --version 2.4.3.1`
* The `bundler` gem (`gem install bundler`). If you receive SSL-related errors while running `gem install`, try running `refreshenv` first.
* Ruby 2.4.x (note: 2.5 and higher may fail due to the `ffi` ruby lib only supporting < 2.5).
* An easy way to install is to use `choco install ruby --version 2.4.3.1`.
* Or use the **Ruby+Devkit installer** from [RubyInstaller for Windows](https://rubyinstaller.org/downloads/archives/).
* The `bundler` gem (`gem install bundler`). If you receive SSL-related errors while running `gem install`, try running `refreshenv` first.

### Building

* Clone this repository
* `cd` into the `root/docs` directory of the repository
* Install the Ruby Devkit using `ridk install` followed by option 3.
* Run `bundle install`.
* Run `bundle exec jekyll serve`. To have it monitor your working directory for changes, add the `--incremental` option.
* Run `bundle install`.
* Run `bundle exec jekyll serve`. To have it monitor your working directory for changes, add the `--incremental` option.

## Troubleshooting

* Do you receive an error around `jekyll-remote-theme` and `libcurl`? See [this issue on the pages-gem repo](https://github.com/github/pages-gem/issues/526).
* Do you receive an error `Liquid Exception: SSL_connect returned=1 errno=0 state=error: certificate verify failed`? Check out [this solution in the Jekyll repo.](https://github.com/jekyll/jekyll/issues/3985#issuecomment-294266874)
*
30 changes: 17 additions & 13 deletions docs/_pages/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For instance, only test a single condition per test case. If you don't, and the

That’s why we designed Fluent Assertions to help you in this area. Not only by using clearly named assertion methods, but also by making sure the failure message provides as much information as possible. Consider this example:

```c#
```csharp
string accountNumber = "1234567890";
accountNumber.Should().Be("0987654321");
```
Expand All @@ -28,7 +28,7 @@ This will be reported as:

The fact that both strings are displayed on a separate line is not a coincidence and happens if any of them is longer than 8 characters. However, if that's not enough, all assertion methods take an optional explanation (the because) that supports formatting placeholders similar to String.Format which you can use to enrich the failure message. For instance, the assertion

```c#
```csharp
var numbers = new[] { 1, 2, 3 };
numbers.Should().Contain(item => item > 3, "at least {0} item should be larger than 3", 1);
```
Expand All @@ -42,26 +42,30 @@ will fail with:
Fluent Assertions cross-compiles to .NET Framework 4.7, as well as .NET Core 2.1 and 3.0, .NET Standard 2.0 and 2.1.

Because of that Fluent Assertions supports the following minimum platforms.
* .NET Core 2.1 and 3.0
* .NET Framework 4.7 and later
* Mono 5.4, Xamarin.iOS 10.14, Xamarin.Mac 3.8 and Xamarin.Android 8.0
* Universal Windows Platform 10.0.16299 and later

* .NET Core 2.1 and 3.0
* .NET Framework 4.7 and later
* Mono 5.4, Xamarin.iOS 10.14, Xamarin.Mac 3.8 and Xamarin.Android 8.0
* Universal Windows Platform 10.0.16299 and later

Fluent Assertions supports the following unit test frameworks:

* [MSTest V2](https://github.com/Microsoft/testfx) (Visual Studio 2017, Visual Studio 2019)
* [NUnit](http://www.nunit.org/)
* [XUnit2](https://github.com/xunit/xunit/releases)
* [NSpec](http://nspec.org/)
* [MSpec](https://github.com/machine/machine.specifications)
* [MSTest V2](https://github.com/Microsoft/testfx) (Visual Studio 2017, Visual Studio 2019)
* [NUnit](http://www.nunit.org/)
* [XUnit2](https://github.com/xunit/xunit/releases)
* [NSpec](http://nspec.org/)
* [MSpec](https://github.com/machine/machine.specifications)

## Coding by Example

## Coding by Example ##
As you may have noticed, the purpose of this open-source project is to not only be the best assertion framework in the .NET realm, but to also demonstrate high-quality code.
We heavily practice Test Driven Development and one of the promises TDD makes is that unit tests can be treated as your API's documentation.
So although you are free to go through the many examples here, please consider to analyze the many [unit tests](https://github.com/fluentassertions/fluentassertions/tree/master/Tests/Shared.Specs).

## Who is behind this project
My name is [Dennis Doomen](https://twitter.com/ddoomen) and I work for [Aviva Solutions](https://www.avivasolutions.nl/) in The Netherlands. I maintain a [blog](https://www.continuousimprover.com/) on my everlasting quest for knowledge that significantly improves the way you build your key systems in an agile world. Fluent Assertions is one of those aspects of that. Since 2018, [Jonas Nyrup](https://github.com/jnyrup) has joined to project and help bring it forward.

My name is [Dennis Doomen](https://twitter.com/ddoomen) and I work for [Aviva Solutions](https://www.avivasolutions.nl/) in The Netherlands. I maintain a [blog](https://www.continuousimprover.com/) on my everlasting quest for knowledge that significantly improves the way you build your key systems in an agile world. Fluent Assertions is one of those aspects of that. Since 2018, [Jonas Nyrup](https://github.com/jnyrup) has joined to project and help bring it forward.

## Versioning

The version numbers of Fluent Assertions releases comply to the [Semantic Versioning](http://semver.org/) scheme. In other words, release 1.4.0 only adds backwards-compatible functionality and bug fixes compared to 1.3.0. Release 1.4.1 should only include bug fixes. And if we ever introduce breaking changes, the number increased to 2.0.0.
2 changes: 1 addition & 1 deletion docs/_pages/assemblies.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You also have access to methods to assert an assembly does or does not reference
These are typically used to enforce layers within an application, such as for example, asserting the web layer does not reference the data layer.
To assert the references, use the the following syntax:

```csharp
```csharp
assembly.Should().Reference(otherAssembly);
assembly.Should().NotReference(otherAssembly);
```
6 changes: 3 additions & 3 deletions docs/_pages/basicassertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ someObject.Should().BeOfType<Exception>()
.Which.Message.Should().Be("Other Message");
```

To assert that two objects are equal (through their implementation of `Object.Equals`), use
To assert that two objects are equal (through their implementation of `Object.Equals`), use

```csharp
string otherObject = "whatever";
theObject.Should().Be(otherObject, "because they have the same values");
theObject.Should().NotBe(otherObject);
```

If you want to make sure two objects are not just functionally equal but refer to the exact same object in memory, use the following two methods.

```csharp
Expand Down Expand Up @@ -75,4 +75,4 @@ Internally, `BeBinarySerializable` uses the [Object graph comparison](objectgrap
```csharp
theObject.Should().BeBinarySerializable<MyClass>(
options => options.Excluding(s => s.SomeNonSerializableProperty));
```
```
5 changes: 5 additions & 0 deletions docs/_pages/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ collection.Should().NotBeInDescendingOrder(x => x.SomeProperty);
```

When asserting on a projection of a collection the failure message will be less descriptive as it only knows about the projected value and not object containing that property.

```csharp
collection.Select(x => x.SomeProperty).Should().OnlyHaveUniqueItems();
```

Therefore we offer two overloads that takes an expression to select the property.

```csharp
collection.Should().OnlyHaveUniqueItems(x => x.SomeProperty);
collection.Should().NotContainNulls(x => x.SomeProperty);
Expand All @@ -156,6 +158,7 @@ persistedCustomers.Should().EndWith(customers, (c1, c2) => c1.Name == c2.Name);
```

You can also perform assertions on all elements of a collection:

```csharp
IEnumerable<BaseType> collection = new BaseType[] { new DerivedType() };

Expand All @@ -165,6 +168,7 @@ collection.Should().AllBeEquivalentTo(referenceObject);
```

In case if you need to perform individual assertions on all elements of a collection, you can assert each element separately in the following manner:

```csharp
var collection = new []
{
Expand All @@ -187,6 +191,7 @@ collection.Should().SatisfyRespectively(
```

If you need to perform individual assertions on all elements of a collection without setting expectation about the order of elements:

```csharp
var collection = new []
{
Expand Down
2 changes: 1 addition & 1 deletion docs/_pages/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ actual.Should().BeEquivalentTo(expected, options => options.AllowingMismatchedTy

Apart from the default check for matching types, whether a `DataSet`, `DataTable` or `DataRow` is a vanilla object or an instance of a custom subtype is irrelevant for the purposes of comparison.

## Examples:
## Examples

Asserting that a `DataTable` has certain columns:

Expand Down
4 changes: 2 additions & 2 deletions docs/_pages/datetimespans.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar:
nav: "sidebar"
---

## Dates and times ##
## Dates and times

For asserting a `DateTime` or a `DateTimeOffset` against various constraints, Fluent Assertions offers a bunch of methods that, provided that you use the extension methods for representing dates and times, really help to keep your assertions readable.

Expand Down Expand Up @@ -94,7 +94,7 @@ theDatetime.Should().NotBeCloseTo(2.March(2010), 1.Hours());

This can be particularly useful if your database truncates date/time values.

## TimeSpans ##
## TimeSpans

Fluent Assertions also support a few dedicated methods that apply to (nullable) `TimeSpan` instances directly:

Expand Down
4 changes: 2 additions & 2 deletions docs/_pages/enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar:
nav: "sidebar"
---

## Enums ##
## Enums

Fluent Assertions have several ways to compare enums.

Expand Down Expand Up @@ -41,4 +41,4 @@ Lastly, if you want to verify than an enum has a specific integral value, you ca
```csharp
MyEnum.One.Should().HaveValue(1);
MyEnum.One.Should().NotHaveValue(2);
```
```
23 changes: 11 additions & 12 deletions docs/_pages/eventmonitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ using var monitoredSubject = subject.Monitor();

subject.Foo();
monitoredSubject.Should().Raise("NameChangedEvent");

```

Notice that Fluent Assertions will keep monitoring the `subject` for as long as the `using` block lasts.
Expand All @@ -33,7 +32,7 @@ monitoredSubject
`WithSender()` will verify that all occurrences of the event had their `sender` argument set to the specified object.
`WithArgs()` just verifies that at least one occurrence had a matching `EventArgs` object. Both will return an `IEventRecording` representing only the events that match the constraint.

This means that event monitoring only works for events that comply with the standard two-argument `sender`/`args` .NET pattern.
This means that event monitoring only works for events that comply with the standard two-argument `sender`/`args` .NET pattern.

Since verifying for `PropertyChanged` events is so common, we've included a specialized shortcut to the example above:

Expand Down Expand Up @@ -75,18 +74,18 @@ monitor.Should().Raise("SomeEvent");
The `IMonitor` interface returned by `Monitor()` exposes a method named `GetRecordingFor` as well as the properties `MonitoredEvents` and `OccurredEvents` that you can use to directly interact with the monitor, e.g. to create your own extensions. For example:

```csharp
var eventSource = new ClassThatRaisesEventsItself();
var eventSource = new ClassThatRaisesEventsItself();

using IMonitor monitor = eventSource.Monitor<IEventRaisingInterface>();
using IMonitor monitor = eventSource.Monitor<IEventRaisingInterface>();

EventMetadata[] metadata = monitor.MonitoredEvents;
EventMetadata[] metadata = monitor.MonitoredEvents;

metadata.Should().BeEquivalentTo(new[]
metadata.Should().BeEquivalentTo(new[]
{
new
{
new
{
EventName = nameof(IEventRaisingInterface.InterfaceEvent),
HandlerType = typeof(EventHandler)
}
});
EventName = nameof(IEventRaisingInterface.InterfaceEvent),
HandlerType = typeof(EventHandler)
}
});
```
3 changes: 2 additions & 1 deletion docs/_pages/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ act.Should().NotThrow<InvalidOperationException>();
```

Sometimes you may want to retry an assertion until it either succeeds or a given time elapses. For instance, you could be testing a network service which should become available after a certain time, say, 10 seconds:

```csharp
Action act = () => service.IsReady().Should().BeTrue();
act.Should().NotThrowAfter(10.Seconds(), 100.Milliseconds());
```
The second argument of `NotThrowAfter` specifies the time that should pass before `act` is executed again after an execution which threw an exception.

The second argument of `NotThrowAfter` specifies the time that should pass before `act` is executed again after an execution which threw an exception.

If the method you are testing returns an `IEnumerable` or `IEnumerable<T>` and it uses the `yield` keyword to construct that collection, just calling the method will not cause the effect you expected because the real work is not done until you actually iterate over that collection. You can use the `Enumerating()` extension method to force enumerating the collection like this.

Expand Down
5 changes: 4 additions & 1 deletion docs/_pages/executiontime.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sidebar:
---

## Members and Actions

Fluent Assertions also provides a method to assert that the execution time of particular method or action does not exceed a predefined value.
To verify the execution time of a method, use the following syntax:

Expand Down Expand Up @@ -38,7 +39,8 @@ someAction.ExecutionTime().Should().BeLessOrEqualTo(200.Milliseconds());
```

The supported assertions on `ExecutionTime()` are a subset of those found for `TimeSpan`s, namely:
```

```csharp
someAction.ExecutionTime().Should().BeLessOrEqualTo(200.Milliseconds());
someAction.ExecutionTime().Should().BeLessThan(200.Milliseconds());
someAction.ExecutionTime().Should().BeGreaterThan(100.Milliseconds());
Expand All @@ -47,6 +49,7 @@ someAction.ExecutionTime().Should().BeCloseTo(150.Milliseconds(), 50.Millisecond
```

## Tasks

If you're dealing with a `Task`, you can also assert that it completed within a specified period of time:

```csharp
Expand Down

0 comments on commit a977427

Please sign in to comment.