Ich bin einige Integrationstests ausgeführt und ich möchte einen "falschen" Benutzer in meiner ASPNETUsers
Tabelle erstellen.Erstellen "gefälschte" Benutzer in meinem ASPNETUsers Tabelle
Ich versuche, das folgende ohne Glück zu tun. So
Ich habe das Setup wie folgt: -
[SetUp]
public void Setup()
{
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
var projectPath = Path.GetFullPath(Path.Combine(basePath, "../../../../SportsStore2.Tests"));
var server = new TestServer(Utils.GetHostBuilder(new string[] { })
.UseContentRoot(projectPath)
.UseEnvironment("Development")
.UseStartup<Startup>());
_client = server.CreateClient();
}
und dann das Insert ist wie folgt: -
var registerViewModel = new RegisterViewModel
{
Email = "[email protected]",
ConfirmPassword = "testing12345?",
Password = "testing12345?"
};
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var postResponseASPNETUser = await _client.PostAsJsonAsync("http://localhost:49406/Account/Register", registerViewModel);
var createdASPNETUser = await postResponseASPNETUser.Content.ReadAsStringAsync();
Allerdings erhalte ich eine 400-Antwort, Bad Request.
Irgendwelche Ideen, was ich falsch mache?
Vielen Dank für Ihre Hilfe und Zeit.
Enthält die Antwort nicht mehr Details als nach Bad Request? –
Nun, das ist, was ich bekomme: - \t \t RequestMessage \t {Methode: POST, RequestUri: 'http: // localhost: 49406/Konto/Register', Version: 1.1, Inhalt: System.Net.Http.ObjectContent' 1 [SportsStore2.API.Models.AccountViewModels.RegisterViewModel], Header: { Akzeptieren: application/json Host: localhost: 49406 Content-Type: application/json; charset = utf-8 }} \t System.Net.Http.HttpRequestMessage – Johann
nichts, das jedoch herausragt – Johann