@@ -120,13 +120,20 @@ var testEnvironment = new TestEnvironment<Startup, TestStartupConfigurationServi
120120#### API Test
121121Write your API test by just sending web requests using the * Test Environment* :
122122``` csharp
123- var response = testEnvironment .Client .GetAsync (" /api/data" ).Result ;
124- response .EnsureSuccessStatusCode ();
123+ [TestMethod ]
124+ public void ScenarioShouldBeOk ()
125+ {
126+ var testEnvironment = new TestEnvironment <Startup , TestStartupConfigurationService <[EF_DB_CONTEXT]>>(
127+ Path .Combine (System .AppContext .BaseDirectory , @" [PATH_TO_WEB_APP]" ));
128+
129+ var response = testEnvironment .Client .GetAsync (" /api/data" ).Result ;
130+ response .EnsureSuccessStatusCode ();
125131
126- // Test result content
127- var result = JsonConvert .DeserializeObject <Data []>(response .Content .ReadAsStringAsync ().Result );
132+ // Test result content
133+ var result = JsonConvert .DeserializeObject <Data []>(response .Content .ReadAsStringAsync ().Result );
128134
129- Assert .AreEqual (" data" , result .Data );
135+ Assert .AreEqual (" data" , result .Data );
136+ }
130137.. .
131138```
132139
@@ -138,9 +145,12 @@ You can access to the this repository using the ASP.NET Core dependency injectio
138145
139146``` csharp
140147[TestMethod ]
141- public void Mvc_GetBlogsShouldBeOk ()
148+ public void ScenarioShouldBeOk ()
142149{
143- base .TestEnvironment .Client .GetAsync (" /" ).Result .EnsureSuccessStatusCode ();
150+ var testEnvironment = new TestEnvironment <Startup , TestStartupConfigurationService <[EF_DB_CONTEXT]>>(
151+ Path .Combine (System .AppContext .BaseDirectory , @" [PATH_TO_WEB_APP]" ));
152+
153+ testEnvironment .Client .GetAsync (" /" ).Result .EnsureSuccessStatusCode ();
144154
145155 var viewModel = base .TestEnvironment
146156 .ServiceProvider
0 commit comments