-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
169 lines (145 loc) · 6.59 KB
/
Copy pathindex.html
File metadata and controls
169 lines (145 loc) · 6.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>A friendly substitute for .NET mocking libraries | NSubstitute </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="A friendly substitute for .NET mocking libraries | NSubstitute ">
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="public/docfx.min.css">
<link rel="stylesheet" href="public/main.css">
<meta name="docfx:navrel" content="toc.html">
<meta name="docfx:tocrel" content="toc.html">
<meta name="docfx:rel" content="">
<meta name="docfx:docurl" content="https://github.com/nsubstitute/NSubstitute/blob/main/docs/index.md/#L1">
<meta name="loc:inThisArticle" content="In this article">
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
<meta name="loc:searchNoResults" content="No results for "{query}"">
<meta name="loc:tocFilter" content="Filter by title">
<meta name="loc:nextArticle" content="Next">
<meta name="loc:prevArticle" content="Previous">
<meta name="loc:themeLight" content="Light">
<meta name="loc:themeDark" content="Dark">
<meta name="loc:themeAuto" content="Auto">
<meta name="loc:changeTheme" content="Change theme">
<meta name="loc:copy" content="Copy">
<meta name="loc:downloadPdf" content="Download PDF">
<script type="module" src="./public/docfx.min.js"></script>
<script>
const theme = localStorage.getItem('theme') || 'auto'
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
</script>
</head>
<body class="tex2jax_ignore" data-layout="landing" data-yaml-mime="">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
<div class="container-xxl flex-nowrap">
<a class="navbar-brand" href="index.html">
<img id="logo" class="svg" src="images/nsubstitute-32x32.png" alt="NSubstitute">
NSubstitute
</a>
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
<i class="bi bi-three-dots"></i>
</button>
<div class="collapse navbar-collapse" id="navpanel">
<div id="navbar">
<form class="search" role="search" id="search">
<i class="bi bi-search"></i>
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
</form>
</div>
</div>
</div>
</nav>
</header>
<main class="container-xxl">
<div class="content">
<div class="actionbar">
<nav id="breadcrumb"></nav>
</div>
<article data-uid="">
<div id="downloads" class="sidebar download">
<h1 id="welcome-to-nsubstitute">Welcome to NSubstitute</h1>
<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.</p>
<ul>
<li class="nuget">
<a href="https://nuget.org/List/Packages/NSubstitute">Install via NuGet:</a> <code>Install-Package NSubstitute</code>
</li>
<li class="nuget"><a href="/help/nsubstitute-analysers">Optional analysers for C#:</a>
<code>Install-Package NSubstitute.<wbr>Analyzers.<wbr>CSharp</code>
</li>
<li class="nuget"><a href="/help/nsubstitute-analysers">Optional analysers for VB:</a>
<code>Install-Package NSubstitute.<wbr>Analyzers.<wbr>VisualBasic</code>
</li>
<li class="github">
<a href="https://github.com/nsubstitute/nsubstitute">Source</a>
</li>
</ul>
</div>
<div id="features">
<div class="feature" markdown="1">
<h2 id="simple-succinct-pleasant-to-use">Simple, succinct, pleasant to use</h2>
<pre><code class="lang-csharp">//Create:
var calculator = Substitute.For<ICalculator>();
//Set a return value:
calculator.Add(1, 2).Returns(3);
Assert.That(calculator.Add(1, 2), Is.EqualTo(3));
//Check received calls:
calculator.Received().Add(1, Arg.Any<int>());
calculator.DidNotReceive().Add(2, 2);
//Raise events
calculator.PoweringUp += Raise.Event();
</code></pre>
<!--
```requiredcode
public interface ICalculator
{
int Add(int a, int b);
string Mode { get; set; }
event EventHandler PoweringUp;
}
```
-->
</div>
<div class="feature" markdown="1">
<h2 id="helpful-exceptions">Helpful exceptions</h2>
<div class="highlight">
<pre><code class="lang-text">ReceivedCallsException : Expected to receive a call matching:
Add(1, 2)
Actually received no matching calls.
Received 2 non-matching calls (non-matching arguments indicated with '*' characters):
Add(*4*, *7*)
Add(1, *5*)
</code></pre>
</div>
</div>
</div>
<div class="sidebar">
<div id="why-use-it" markdown="1">
<h3 id="another-library">Another library?</h3>
<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 — the code required to configure test doubles quickly obscured the intention behind our tests.</p>
<p>We've attempted to make the most frequently required operations obvious and easy to use, keeping less usual scenarios discoverable and accessible, and all the while maintaining as much natural language as possible.</p>
<p>Perfect for those new to testing, and for others who would just like to to get their tests written with less noise and fewer lambdas.</p>
</div>
</div>
</article>
<div class="contribution d-print-none">
<a href="https://github.com/nsubstitute/NSubstitute/blob/main/docs/index.md/#L1" class="edit-link">Edit this page</a>
</div>
<div class="next-article d-print-none border-top" id="nextArticle"></div>
</div>
<div class="affix">
<nav id="affix"></nav>
</div>
</main>
<div class="container-xxl search-results" id="search-results"></div>
<footer class="border-top text-secondary">
<div class="container-xxl">
<div class="flex-fill">
<span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
</div>
</div>
</footer>
</body>
</html>