Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: introduce clickable copy to clipboard headers for all pages and a hx-tags #729

Merged
merged 19 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ DEPENDENCIES
ruby_dep (~> 1.3)

BUNDLED WITH
1.17.2
1.17.2
1 change: 1 addition & 0 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>NSubstitute: {{ page.title }}</title>
<link rel="stylesheet" href="/css/style.css" type="text/css" />
<script src="{{ base.url | prepend: site.url }}/js/scripts.js"></script>
</head>
<body>
<div id="header">
Expand Down
66 changes: 51 additions & 15 deletions docs/css/style.css
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
html { font-family: "helvetica", Helvetica, Arial }
body {
margin:0;
padding:0;
border:0;
width:100%;
min-width:600px;
margin: 0;
padding: 0;
border: 0;
width: 100%;
min-width: 600px;
}

p{
font-size:1.0em;
line-height:1.6;
p {
font-size: 1.0em;
line-height: 1.6;
}

ul {
font-size:1.0em;
line-height:1.6;
font-size: 1.0em;
line-height: 1.6;
}

h1{font-size:2.5em}
h2{font-size:2.0em}
h3{font-size:1.5em}
h1{font-size: 2.5em}
h2{font-size: 2.0em}
h3{font-size: 1.5em}

a:link { color: #365f91; text-decoration: none;}
a:visited { color: #365f91; text-decoration: none;}
Expand Down Expand Up @@ -80,7 +80,7 @@ a:active { color: #000000; text-decoration: underline;}
#post-content {
float: left;
position: relative;
width:71%;
width: 71%;
padding-left: 10px;
}

Expand Down Expand Up @@ -181,6 +181,42 @@ code {
min-height: inherit !important;
}

h1 {
margin-top: 0.5em;
margin-bottom: 0.2em;
}

h2 {
position: relative;
display: inline-block;
margin-top: 0.5em;
margin-bottom: 0.2em;
}

h3 {
position: relative;
display: inline-block;
margin-top: 0.5em;
margin-bottom: 0.2em;
}

.tooltip {
visibility: visible;
color: #365f91;
background-color: #ECF0F5;
position: absolute;
z-index: 1;
white-space: nowrap;
font-size: 0.4em;
padding: 0.6em;
margin: 0.4em auto auto 0.6em;
border-radius: 30px;
}

.tooltip-hidden {
visibility: hidden;
}

/* Pygments vs style, as generated by:
* https://github.com/richleland/pygments-css/blob/master/vs.css
*/
Expand Down Expand Up @@ -222,4 +258,4 @@ code {
.highlight .sr { color: #a31515 } /* Literal.String.Regex */
.highlight .s1 { color: #a31515 } /* Literal.String.Single */
.highlight .ss { color: #a31515 } /* Literal.String.Symbol */
/* End pygments vs style */
/* End pygments vs style */
2 changes: 1 addition & 1 deletion docs/help/_posts/2010-01-01-getting-started.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ calculator.PoweringUp += Raise.Event();
Assert.That(eventWasRaised);
```

That's pretty much all you need to get started with NSubstitute. Read on for more detailed feature descriptions, as well as for some of the less common requirements that NSubstitute supports.
That's pretty much all you need to get started with NSubstitute. Read on for more detailed feature descriptions, as well as for some of the less common requirements that NSubstitute supports.
5 changes: 1 addition & 4 deletions docs/help/_posts/2010-01-02-creating-a-substitute.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,4 @@ Assert.AreEqual("hello", func());

## Partial substitutes and test spies

When required we can also create substitutes that run real code by default, letting us replace [specific parts of a class with substitute behaviour](/help/partial-subs/).



When required we can also create substitutes that run real code by default, letting us replace [specific parts of a class with substitute behaviour](/help/partial-subs/).
3 changes: 1 addition & 2 deletions docs/help/_posts/2010-02-01-set-return-value.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ Assert.AreEqual(calculator.Mode, "HEX");


## More ways of setting return values
This covers the very basics of setting a return value, but NSubstitute can do much more. Read on for other approachs, including [matching specific arguments](/help/return-for-args), [ignoring arguments](/help/return-for-any-args), using [functions to calculate return values](/help/return-from-function) and returning [multiple results](/help/multiple-returns).

This covers the very basics of setting a return value, but NSubstitute can do much more. Read on for other approachs, including [matching specific arguments](/help/return-for-args), [ignoring arguments](/help/return-for-any-args), using [functions to calculate return values](/help/return-from-function) and returning [multiple results](/help/multiple-returns).
3 changes: 1 addition & 2 deletions docs/help/_posts/2010-02-02-return-for-args.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ Assert.AreNotEqual(345, calculator.Add(1, 2));
//Return when both args equal to 0:
calculator.Add(Arg.Is(0), Arg.Is(0)).Returns(99);
Assert.AreEqual(99, calculator.Add(0, 0));
```

```
2 changes: 1 addition & 1 deletion docs/help/_posts/2010-02-03-return-for-any-args.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ calculator.Add(default, default).ReturnsForAnyArgs(100);

The same behaviour can also be achieved using [argument matchers](/help/argument-matchers): it is simply a shortcut for replacing each argument with `Arg.Any<T>()`.

`ReturnsForAnyArgs()` has the same overloads as `Returns()`, so you can also specify multiple return values or calculated return values using this approach.
`ReturnsForAnyArgs()` has the same overloads as `Returns()`, so you can also specify multiple return values or calculated return values using this approach.
2 changes: 1 addition & 1 deletion docs/help/_posts/2010-02-03-return-from-function.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ calculator
calculator.Add(7,3);
calculator.Add(2,2);
Assert.AreEqual(counter, 2);
```
```
3 changes: 1 addition & 2 deletions docs/help/_posts/2010-02-04-multiple-returns.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ Assert.Throws<Exception>(() => { var result = calculator.Mode; });

## Configuring other calls without using up multiple returns

If a call has been configured with multiple returns values, you can configure a more specific call without using up any of these callbacks using [`.Configure()`](/help/configure/).

If a call has been configured with multiple returns values, you can configure a more specific call without using up any of these callbacks using [`.Configure()`](/help/configure/).
3 changes: 1 addition & 2 deletions docs/help/_posts/2010-02-10-replacing-return-values.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ public void SetUp() {
calculator = Substitute.For<ICalculator>();
}
```
-->

-->
3 changes: 1 addition & 2 deletions docs/help/_posts/2010-03-01-received-calls.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,4 @@ public void ShouldRaiseLowFuel(){
.Received()
.Invoke(fuelManagement, Arg.Is<LowFuelWarningEventArgs>(x => x.PercentLeft < 20));
}
```

```
4 changes: 1 addition & 3 deletions docs/help/_posts/2010-03-10-clear-received-calls.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,4 @@ runner.Run();
command.DidNotReceive().Execute();
```

`ClearReceivedCalls()` will not clear any results set up for the substitute using `Returns()`. If we need to this, we can [replace previously specified results](/help/replacing-return-values) by calling `Returns()` again.


`ClearReceivedCalls()` will not clear any results set up for the substitute using `Returns()`. If we need to this, we can [replace previously specified results](/help/replacing-return-values) by calling `Returns()` again.
2 changes: 1 addition & 1 deletion docs/help/_posts/2010-04-01-argument-matchers.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,4 @@ public void ManualArgSnapshot() {
}
```

We can then use our standard assertion library for checking the value. This approach can also be helpful for asserting on complex objects, as our assertions can be more detailed and provide more useful information than NSubstitute typically provides in these cases.
We can then use our standard assertion library for checking the value. This approach can also be helpful for asserting on complex objects, as our assertions can be more detailed and provide more useful information than NSubstitute typically provides in these cases.
3 changes: 1 addition & 2 deletions docs/help/_posts/2010-05-01-callbacks.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,4 @@ for (int i = 0; i < 5; i++)
}
Assert.That(String.Concat(calls), Is.EqualTo("123++"));
Assert.That(counter, Is.EqualTo(5));
```

```
3 changes: 1 addition & 2 deletions docs/help/_posts/2010-05-02-throwing-exceptions.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ calculator
//Both calls will now throw.
Assert.Throws<Exception>(() => calculator.Add(-1, -1));
Assert.Throws<Exception>(() => calculator.Add(-2, -2));
```

```
2 changes: 1 addition & 1 deletion docs/help/_posts/2010-05-10-configure.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ Assert.Throws<Exception>(() => calculator.Add(-2, -2));

NSubstitute will also assume we are configuring a call if we have an argument matcher in our call, such as `Arg.Is(1)` in `calculator.Add(Arg.Is(1), 2).Returns(3)`, but it is generally better to be more explicit by using `.Configure()`.

This can be particularly useful with [partial substitutes](/help/partial-subs/) to help avoid real code being executed when configuring calls that would otherwise call the base implementation.
This can be particularly useful with [partial substitutes](/help/partial-subs/) to help avoid real code being executed when configuring calls that would otherwise call the base implementation.
2 changes: 1 addition & 1 deletion docs/help/_posts/2010-06-01-raising-events.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ engine.RevvedAt += rpm => revvedAt = rpm;
engine.RevvedAt += Raise.Event<Action<int>>(123);

Assert.AreEqual(123, revvedAt);
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,4 @@ Properties and methods returning types of `String` or `Array` will automatically
var identity = Substitute.For<IIdentity>();
Assert.AreEqual(String.Empty, identity.Name);
Assert.AreEqual(0, identity.Roles().Length);
```





```
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@ Assert.AreEqual(1, counter);
lookup.TryLookup("hello", out value);
// Call does NOT match anymore, counter is still 1:
Assert.AreEqual(1, counter);
```

```
3 changes: 1 addition & 2 deletions docs/help/_posts/2010-12-01-actions-with-arguments.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,4 @@ var results = new[] {

Assert.AreEqual(3, numberOfCallsWhereFirstArgIsLessThan0); //3 of 4 calls have first arg < 0
Assert.AreEqual(results, new[] {123, 123, 123, 0}); //Last call returns 0, not 123
```

```
3 changes: 1 addition & 2 deletions docs/help/_posts/2013-01-01-received-in-order.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@ public interface ICommand {
void Run(IConnection c);
}
```
-->

-->
4 changes: 1 addition & 3 deletions docs/help/_posts/2013-02-01-partial-subs.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,4 @@ public void ShouldSendMultipleEmails() {

## Test spies

Even without substituting for specific parts of a class, the instance returned by `Substitute.ForPartsOf<T>` records all calls made to virtual members, so we can [check `Received()` calls](/help/received-calls/) made to any partial substitute.


Even without substituting for specific parts of a class, the instance returned by `Substitute.ForPartsOf<T>` records all calls made to virtual members, so we can [check `Received()` calls](/help/received-calls/) made to any partial substitute.
2 changes: 1 addition & 1 deletion docs/help/_posts/2013-03-01-return-for-all.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ public void ReturnsTakesPrecedence() {
Assert.That(sub.GetWidget(1), Is.SameAs(widget));
Assert.That(sub.GetWidget(42), Is.SameAs(otherWidget));
}
```
```
3 changes: 1 addition & 2 deletions docs/help/_posts/2013-04-01-threading.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ It is fairly standard for production code to call a substitute from multiple thr

Although this particular issue has been mitigated by work in [#452](https://github.com/nsubstitute/NSubstitute/pull/462), issue [#256](https://github.com/nsubstitute/NSubstitute/issues/256) shows the types of problems that can occur if we're not careful with threading.

To avoid this sort of problem, make sure your test has finished configuring its substitutes before exercising the production code, then make sure the production code has completed before your test asserts on `Received()` calls.

To avoid this sort of problem, make sure your test has finished configuring its substitutes before exercising the production code, then make sure the production code has completed before your test asserts on `Received()` calls.
4 changes: 1 addition & 3 deletions docs/help/_posts/2013-04-15-compat-args.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,4 @@ public void Sample() {
// Or re-write without expression tree if possible:
sub.Received().DoStuff(Arg.Any<int>());
}
```


```
2 changes: 1 addition & 1 deletion docs/help/_posts/2013-05-01-nsubstitute-analysers.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ See [NSubstitute.Analyzers documentation](https://github.com/nsubstitute/NSubsti

## Spelling

The Australian members of our team would like to point out they would have preferred to use the English spelling `NSubstitute.Analysers` for this project, but have begrudgingly agreed to use the American (mis)spelling instead. :)
The Australian members of our team would like to point out they would have preferred to use the English spelling `NSubstitute.Analysers` for this project, but have begrudgingly agreed to use the American (mis)spelling instead. :)
4 changes: 1 addition & 3 deletions docs/help/_posts/2015-01-01-how-nsub-works.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,4 @@ The final thing to notice here is that there is the potential for real logic fro
* Be careful substituting for classes!
* Where possible use interfaces instead.
* Remember NSubstitute works by inheriting from (or implementing) your original type. If you can't override a member by manually writing a sub-class, then NSubstitute won't be able to either!
* Install [NSubstitute.Analyzers](/help/nsubstitute-analysers) where ever you install NSubstitute. This will help you avoid these (and other) pitfalls.


* Install [NSubstitute.Analyzers](/help/nsubstitute-analysers) where ever you install NSubstitute. This will help you avoid these (and other) pitfalls.
20 changes: 13 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ title: A friendly substitute for .NET mocking libraries

<div id="features">
<div class="feature" markdown="1">
<h2>Simple, succinct, pleasant to use</h2>

## Simple, succinct, pleasant to use

```csharp
//Create:
Expand Down Expand Up @@ -35,8 +36,10 @@ calculator.PoweringUp += Raise.Event();
-->
</div>

<div class="feature">
<h2>Helpful exceptions</h2>
<div class="feature" markdown="1">

## Helpful exceptions

<div class="highlight">
<pre>
ReceivedCallsException : Expected to receive a call matching:
Expand All @@ -48,8 +51,10 @@ Received 2 non-matching calls (non-matching arguments indicated with '*' charact
</div>
</div>

<div class="feature">
<h2>Don't sweat the small stuff</h2>
<div class="feature" markdown="1">

## Don't sweat the small stuff

<p>Mock, stub, fake, spy, test double? Strict or loose? Nah, just substitute for the type you need!</p>
<p>NSubstitute is designed for Arrange-Act-Assert (AAA) testing, so you just need to arrange how it should work, then assert it received the calls you expected once you're done. Because you've got more important code to write than whether you need a mock or a stub.</p>
</div>
Expand All @@ -74,8 +79,9 @@ Received 2 non-matching calls (non-matching arguments indicated with '*' charact
</div>

<div class="sidebar">
<div id="why-use-it">
<h3>Another library?</h3>
<div id="why-use-it" markdown="1">

### Another library?

<p>There are already some great mocking libraries around for .NET, so why create another? We found that for all their great features, none of the existing libraries had the succinct syntax we were craving &mdash; the code required to configure test doubles quickly obscured the intention behind our tests.</p>

Expand Down
Loading