-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d513828
commit 83c45bf
Showing
9 changed files
with
117 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,21 +7,12 @@ | |
|
||
namespace GZCTF.Test; | ||
|
||
public class AccountTest : IClassFixture<TestWebAppFactory> | ||
public class AccountTest(TestWebAppFactory factory) : IClassFixture<TestWebAppFactory> | ||
{ | ||
readonly TestWebAppFactory _factory; | ||
readonly ITestOutputHelper _output; | ||
|
||
public AccountTest(TestWebAppFactory factory, ITestOutputHelper output) | ||
{ | ||
_factory = factory; | ||
_output = output; | ||
} | ||
|
||
[Fact] | ||
public async Task TestCreateUser() | ||
{ | ||
using HttpClient client = _factory.CreateClient(); | ||
using HttpClient client = factory.CreateClient(); | ||
HttpResponseMessage registerResult = await client.PostAsJsonAsync("/api/account/register", | ||
new { userName = "foo", password = "foo12345", email = "[email protected]" }); | ||
Assert.Equal(HttpStatusCode.BadRequest, registerResult.StatusCode); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
using System.Linq; | ||
using GZCTF.Services.Interface; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Mvc.Testing; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.AspNetCore.Mvc.Testing; | ||
|
||
namespace GZCTF.Test; | ||
|
||
public class TestWebAppFactory : WebApplicationFactory<Program> | ||
public abstract class TestWebAppFactory : WebApplicationFactory<Program> | ||
{ | ||
static TestWebAppFactory() | ||
{ | ||
Program.IsTesting = true; | ||
} | ||
|
||
protected override void ConfigureWebHost(IWebHostBuilder builder) => | ||
builder.ConfigureServices(services => | ||
{ | ||
services.Remove(services.Single(d => d.ServiceType == typeof(IMailSender))); | ||
services.AddTransient<IMailSender, TestMailSender>(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.