You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If our Received() assertion fails, NSubstitute tries to give us some help as to what the problem might be:
71
71
72
-
73
-
NSubstitute.Exceptions.ReceivedCallsException : Expected to receive a call matching:
74
-
Add(1, 2)
75
-
Actually received no matching calls.
76
-
Received 2 non-matching calls (non-matching arguments indicated with '*' characters):
77
-
Add(1, *5*)
78
-
Add(*4*, *7*)
72
+
```
73
+
NSubstitute.Exceptions.ReceivedCallsException : Expected to receive a call matching:
74
+
Add(1, 2)
75
+
Actually received no matching calls.
76
+
Received 2 non-matching calls (non-matching arguments indicated with '*' characters):
77
+
Add(1, *5*)
78
+
Add(*4*, *7*)
79
+
```
79
80
80
81
We can also work with properties using the Returns syntax we use for methods, or just stick with plain old property setters (for read/write properties):
Copy file name to clipboardExpand all lines: docs/help/_posts/2010-01-01-getting-started.markdown
+17-13Lines changed: 17 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,17 @@ layout: post
7
7
8
8
First add the [NSubstitute NuGet package](https://nuget.org/List/Packages/NSubstitute) to your test project using [NuGet](https://docs.microsoft.com/en-us/nuget/quickstart/use-a-package) (either the command line executable, or via the package manager in your IDE).
9
9
10
-
> Install-Package NSubstitute
10
+
```sh
11
+
> Install-Package NSubstitute
12
+
```
11
13
12
14
It is optional but recommended to also install [NSubstitute.Analyzers.CSharp](https://www.nuget.org/packages/NSubstitute.Analyzers.CSharp/) for C# projects, or [NSubstitute.Analyzers.VisualBasic](https://www.nuget.org/packages/NSubstitute.Analyzers.VisualBasic/) for VB projects. NSubstitute will work without the analysers installed, but these packages will [help detect potential misuses of the NSubstitute API](/help/nsubstitute-analysers/).
So now you are staring at a blank test fixture (created with your favourite unit testing framework; for these examples we're using [NUnit](https://nunit.org/)), and are wondering where to start.
If our `Received()` assertion fails, NSubstitute tries to give us some help as to what the problem might be:
67
70
68
-
69
-
NSubstitute.Exceptions.ReceivedCallsException : Expected to receive a call matching:
70
-
Add(1, 2)
71
-
Actually received no matching calls.
72
-
Received 2 non-matching calls (non-matching arguments indicated with '*' characters):
73
-
Add(*4*, *7*)
74
-
Add(1, *5*)
71
+
```
72
+
NSubstitute.Exceptions.ReceivedCallsException : Expected to receive a call matching:
73
+
Add(1, 2)
74
+
Actually received no matching calls.
75
+
Received 2 non-matching calls (non-matching arguments indicated with '*' characters):
76
+
Add(*4*, *7*)
77
+
Add(1, *5*)
78
+
```
75
79
76
80
We can also work with properties using the `Returns` syntax we use for methods, or just stick with plain old property setters (for read/write properties):
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.
126
+
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.
0 commit comments