public async Task ExecuteActionWithValidModelReturnsContent()
        {
            using (var server = this.CreateServer())
            {
                var model = new ValidateModelAttributeFixtureModel() { Name = "test" };

                var response = await server.Client.PostAsJsonAsync(this.rootRoute, model);

                Assert.Equal(HttpStatusCode.OK, response.StatusCode);

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

                Assert.Contains(model.Name, responseContent);
            }
        }
        public async Task ExecuteActionWithInvalidModelReturnsModelState()
        {
            using (var server = this.CreateServer())
            {
                var model = new ValidateModelAttributeFixtureModel() { Name = string.Empty };

                var response = await server.Client.PostAsJsonAsync(this.rootRoute, model);

                Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);

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

                Assert.Contains("The name cannot be empty", responseContent);
            }
        }
Ejemplo n.º 3
0
        public async Task ExecuteActionWithValidModelReturnsContent()
        {
            using (var server = this.CreateServer())
            {
                var model = new ValidateModelAttributeFixtureModel()
                {
                    Name = "test"
                };

                var response = await server.Client.PostAsJsonAsync(this.rootRoute, model);

                Assert.Equal(HttpStatusCode.OK, response.StatusCode);

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

                Assert.Contains(model.Name, responseContent);
            }
        }
Ejemplo n.º 4
0
        public async Task ExecuteActionWithInvalidModelReturnsModelState()
        {
            using (var server = this.CreateServer())
            {
                var model = new ValidateModelAttributeFixtureModel()
                {
                    Name = string.Empty
                };

                var response = await server.Client.PostAsJsonAsync(this.rootRoute, model);

                Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);

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

                Assert.Contains("The name cannot be empty", responseContent);
            }
        }
Ejemplo n.º 5
0
 public string Post(ValidateModelAttributeFixtureModel model)
 {
     return(model.Name);
 }
 public string Post(ValidateModelAttributeFixtureModel model)
 {
     return model.Name;
 }