public async Task CreateAccount() { string user = "******"; string password = "******"; var youmail = YouMailTestService.PrivateService; if (await youmail.AccountExistsAsync(user)) { try { var newService = new YouMailService(user, password, null, YouMailTestService.UserAgent); await newService.DeleteAccountAsync(); } catch (YouMailException) { Assert.Fail("Failed to delete old existing account"); } } await youmail.CreateAccountAsync(user, password, "Test", "Account", string.Format(_defaultEmail, user)); { // Reset the service in case we already had logged in with old credentials var newService = new YouMailService(user, password, null, YouMailTestService.UserAgent); await newService.DeleteAccountAsync(); // This should fail the second time bool failed = false; try { await newService.DeleteAccountAsync(); } catch (YouMailException e) { // Either the account doesn't exist, or the user isn't authenticated anymore if (e.StatusCode == HttpStatusCode.NotFound || e.StatusCode == HttpStatusCode.Forbidden) { failed = true; } } Assert.IsTrue(failed); } }