using Elsa.Http.ContentWriters; using Xunit; namespace Elsa.Http.UnitTests.ContentWriters; /// /// Tests for the implementations. /// public class ContentFactoryTests { /// /// Tests that doesn't append charset to content type. /// [Fact] public void JsonContentFactory_ShouldNotAppendCharset() { // Arrange const string contentType = "application/json"; const string content = "{\"test\": \"value\"}"; var factory = new JsonContentFactory(); // Act var httpContent = factory.CreateHttpContent(content, contentType); // Assert Assert.Equal(contentType, httpContent.Headers.ContentType?.MediaType); Assert.Null(httpContent.Headers.ContentType?.CharSet); } /// /// Tests that doesn't append charset to content type. /// [Fact] public void XmlContentFactory_ShouldNotAppendCharset() { // Arrange const string contentType = "text/xml"; const string content = "test"; var factory = new XmlContentFactory(); // Act var httpContent = factory.CreateHttpContent(content, contentType); // Assert Assert.Equal(contentType, httpContent.Headers.ContentType?.MediaType); Assert.Null(httpContent.Headers.ContentType?.CharSet); } /// /// Tests that doesn't append charset to content type. /// [Fact] public void TextContentFactory_ShouldNotAppendCharset() { // Arrange const string contentType = "text/html"; const string content = "test"; var factory = new TextContentFactory(); // Act var httpContent = factory.CreateHttpContent(content, contentType); // Assert Assert.Equal(contentType, httpContent.Headers.ContentType?.MediaType); Assert.Null(httpContent.Headers.ContentType?.CharSet); } }