public async Task <JObject> CreateAccountAsync(RegisterUserDto dto)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = _proxyOAuthUri;

                var request = new HttpRequestMessage(HttpMethod.Post, "/api/account/register")
                {
                    Content = dto.ObjToHttpContent()
                };

                var response = await client.SendAsync(request, HttpCompletionOption.ResponseContentRead);

                if (response.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    throw new BadRequestException(response.StatusCode.ToString(), new string[] { response.ReasonPhrase });
                }

                var content = await response.Content.ReadAsStringAsync();

                var payload = JObject.Parse(content);

                return(payload);
            }
        }
Esempio n. 2
0
        public async Task FailingRegister()
        {
            var dto = new RegisterUserDto
            {
                UserName = "******",
                Email    = "*****@*****.**",
                Password = "******",
                Role     = "User"
            };

            var request = new HttpRequestMessage(HttpMethod.Post, "/api/account/register-user")
            {
                Content = dto.ObjToHttpContent()
            };

            var response = await XClient.SendAsync(request, HttpCompletionOption.ResponseContentRead);

            var content = await response.Content.ReadAsStringAsync();

            var payload = content.JsonToObj <ApiResultOk>();

            Assert.NotEqual("Ok", payload.Message);
        }