public void ApiController_Json() { // Arrange var controller = new ConcreteApiController(); var product = new Product(); // Act var result = controller.Json(product); // Assert var jsonResult = Assert.IsType <JsonResult>(result); Assert.Same(product, jsonResult.Value); }
public void ApiController_Json_Encoding() { // Arrange var controller = new ConcreteApiController(); var product = new Product(); var settings = new JsonSerializerSettings(); // Act var result = controller.Json(product, settings, Encoding.UTF8); // Assert var jsonResult = Assert.IsType <JsonResult>(result); Assert.Same(product, jsonResult.Value); Assert.Same(Encoding.UTF8, jsonResult.ContentType.Encoding); }
public void ApiController_Json_Settings() { // Arrange var controller = new ConcreteApiController(); var product = new Product(); var settings = new JsonSerializerSettings(); // Act var result = controller.Json(product, settings); // Assert var jsonResult = Assert.IsType <JsonResult>(result); Assert.Same(product, jsonResult.Value); var formatter = Assert.IsType <JsonOutputFormatter>(jsonResult.Formatter); Assert.Same(settings, formatter.SerializerSettings); }
public void ApiController_Json_Settings_Encoding() { // Arrange var controller = new ConcreteApiController(); var product = new Product(); var settings = new JsonSerializerSettings(); // Act var result = controller.Json(product, settings, Encoding.UTF8); // Assert var objectResult = Assert.IsType <ObjectResult>(result); Assert.Same(product, objectResult.Value); var formatter = Assert.IsType <JsonOutputFormatter>(Assert.Single(objectResult.Formatters)); Assert.Same(settings, formatter.SerializerSettings); Assert.Same(Encoding.UTF8, Assert.Single(formatter.SupportedEncodings)); }
public void ApiController_Json_Encoding() { // Arrange var controller = new ConcreteApiController(); var product = new Product(); var settings = new JsonSerializerSettings(); // Act var result = controller.Json(product, settings, Encoding.UTF8); // Assert var jsonResult = Assert.IsType<JsonResult>(result); Assert.Same(product, jsonResult.Value); Assert.Same(Encoding.UTF8, jsonResult.ContentType.Encoding); }
public void ApiController_Json() { // Arrange var controller = new ConcreteApiController(); var product = new Product(); // Act var result = controller.Json(product); // Assert var jsonResult = Assert.IsType<JsonResult>(result); Assert.Same(product, jsonResult.Value); }
public void ApiController_Json_Settings_Encoding() { // Arrange var controller = new ConcreteApiController(); var product = new Product(); var settings = new JsonSerializerSettings(); // Act var result = controller.Json(product, settings, Encoding.UTF8); // Assert var jsonResult = Assert.IsType<JsonResult>(result); Assert.Same(product, jsonResult.Value); var formatter = Assert.IsType<JsonOutputFormatter>(jsonResult.Formatter); Assert.Same(settings, formatter.SerializerSettings); Assert.Same(Encoding.UTF8, Assert.Single(formatter.SupportedEncodings)); }