Exemple #1
0
        public async Task Create_User()
        {
            using (var client = new TestClientProvider().Client)
            {
                var user = new User()
                {
                    firstName    = "John",
                    middleName   = "Allen",
                    lastName     = "Smith",
                    phoneNumber  = "123-456-7890",
                    emailAddress = "*****@*****.**"
                };

                var response = await client.PostAsync("user"
                                                      , new StringContent(
                                                          JsonConvert.SerializeObject(user),
                                                          Encoding.UTF8,
                                                          "application/json"));

                response.EnsureSuccessStatusCode();

                response.StatusCode.Should().Be(HttpStatusCode.OK);

                string resp = await response.Content.ReadAsStringAsync();

                var resultUser = JsonConvert.DeserializeObject <User>(resp);
                Assert.NotNull(resultUser.id);
                Assert.Equal(resultUser.emailAddress, user.emailAddress);
            }
        }
Exemple #2
0
        public async Task Create_Duplicate_Email()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.PostAsync("user",
                                                      new StringContent(
                                                          JsonConvert.SerializeObject(new User()
                {
                    firstName = "Julie",
                    middleName = "Marie",
                    lastName = "Jeffries",
                    phoneNumber = "123-456-7890",
                    emailAddress = "*****@*****.**"
                }),
                                                          Encoding.UTF8,
                                                          "application/json"));

                response.StatusCode.Should().Be(HttpStatusCode.Conflict);
            }
        }
Exemple #3
0
        public async Task Create_User_Invalid_Email()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.PostAsync("user",
                                                      new StringContent(
                                                          JsonConvert.SerializeObject(new User()
                {
                    firstName = "Bruce",
                    middleName = "James",
                    lastName = "White",
                    phoneNumber = "123-456-7890",
                    emailAddress = "bruce.james"
                }),
                                                          Encoding.UTF8,
                                                          "application/json"));

                response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
            }
        }