public async Task JsonOutputFormatter_ReturnsIndentedJson() { // Arrange var user = new FormatterWebSite.User() { Id = 1, Alias = "john", description = "This is long so we can test large objects " + new string('a', 1024 * 65), Designation = "Administrator", Name = "John Williams" }; var serializerSettings = JsonSerializerSettingsProvider.CreateSerializerSettings(); serializerSettings.Formatting = Formatting.Indented; var expectedBody = JsonConvert.SerializeObject(user, serializerSettings); // Act var response = await Client.GetAsync("http://localhost/JsonFormatter/ReturnsIndentedJson"); // Assert await response.AssertStatusCodeAsync(HttpStatusCode.OK); var actualBody = await response.Content.ReadAsStringAsync(); Assert.Equal(expectedBody, actualBody); }
public async Task JsonOutputFormatter_ReturnsIndentedJson() { // Arrange var user = new FormatterWebSite.User() { Id = 1, Alias = "john", description = "Administrator", Designation = "Administrator", Name = "John Williams" }; var serializerSettings = new JsonSerializerSettings(); serializerSettings.Formatting = Formatting.Indented; var expectedBody = JsonConvert.SerializeObject(user, serializerSettings); // Act var response = await Client.GetAsync("http://localhost/JsonFormatter/ReturnsIndentedJson"); // Assert var actualBody = await response.Content.ReadAsStringAsync(); Assert.Equal(expectedBody, actualBody); }
public async Task JsonOutputFormatter_ReturnsIndentedJson() { // Arrange var user = new FormatterWebSite.User() { Id = 1, Alias = "john", description = "Administrator", Designation = "Administrator", Name = "John Williams" }; var serializerSettings = new JsonSerializerSettings(); serializerSettings.Formatting = Formatting.Indented; var expectedBody = JsonConvert.SerializeObject(user, serializerSettings); var server = TestHelper.CreateServer(_app, SiteName, _configureServices); var client = server.CreateClient(); // Act var response = await client.GetAsync("http://localhost/JsonFormatter/ReturnsIndentedJson"); // Assert var actualBody = await response.Content.ReadAsStringAsync(); Assert.Equal(expectedBody, actualBody); }