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
@@ -95,8 +95,42 @@ This section describes at a high level how to create a unit test project.
95
95
}
96
96
```
97
97
98
+
Or, for an NUnit project, you might use the following code.
99
+
100
+
```csharp
101
+
usingusingNUnit.Framework;
102
+
usingSystem.IO;
103
+
usingSystem;
104
+
105
+
namespaceHelloWorldTests
106
+
{
107
+
[TestClass]
108
+
publicclassTests
109
+
{
110
+
privateconststringExpected="Hello World!";
111
+
112
+
[SetUp]
113
+
publicvoidSetup()
114
+
{
115
+
}
116
+
[Test]
117
+
publicvoidTestMethod1()
118
+
{
119
+
using (varsw=newStringWriter())
120
+
{
121
+
Console.SetOut(sw);
122
+
HelloWorldCore.Program.Main();
123
+
124
+
varresult=sw.ToString().Trim();
125
+
Assert.AreEqual(Expected, result);
126
+
}
127
+
}
128
+
}
129
+
}
130
+
```
131
+
98
132
> [!TIP]
99
-
> For a more detailed walkthrough of creating unit tests, see [Create and run unit tests for managed code](walkthrough-creating-and-running-unit-tests-for-managed-code.md).
133
+
> For more details about creating unit tests, see [Create and run unit tests for managed code](walkthrough-creating-and-running-unit-tests-for-managed-code.md).
0 commit comments