public void HtmlFormattableString_UsesCurrentCulture()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("{0:D}", DateTime.Parse("01/02/2015"));

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("HtmlEncode[[Sonntag, 1. Februar 2015]]", result);
        }
Example #2
0
        public void HtmlFormattableString_WithFormatStringComponent()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("0x{0:X}", 50);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("0xHtmlEncode[[32]]", result);
        }
Example #3
0
        public void HtmlFormattableString_UsesCurrentCulture()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("{0:D}", DateTime.Parse("01/02/2015"));

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("HtmlEncode[[Sonntag, 1. Februar 2015]]", result);
        }
        public void HtmlFormattableString_EmptyArgsAndCulture()
        {
            // Arrange
            var formattableString = new HtmlFormattableString(CultureInfo.CurrentCulture, "Hello, World!");

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("Hello, World!", result);
        }
Example #5
0
        public void HtmlFormattableString_EmptyArgsAndCulture()
        {
            // Arrange
            var formattableString = new HtmlFormattableString(CultureInfo.CurrentCulture, "Hello, World!");

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("Hello, World!", result);
        }
Example #6
0
        public void HtmlFormattableString_WithHtmlEncodedString()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("{0}!", new HtmlEncodedString("First"));

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("First!", result);
        }
Example #7
0
        public void HtmlFormattableString_UsesPassedInCulture()
        {
            // Arrange
            var culture           = new CultureInfo("fr-FR");
            var formattableString = new HtmlFormattableString(culture, "{0} in french!", 1.21);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("HtmlEncode[[1,21]] in french!", result);
        }
        public void HtmlFormattableString_UsesPassedInCulture()
        {
            // Arrange
            var culture = new CultureInfo("fr-FR");
            var formattableString = new HtmlFormattableString(culture, "{0} in french!", 1.21);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("HtmlEncode[[1,21]] in french!", result);
        }
Example #9
0
        public void HtmlFormattableString_WithAlignmentComponent()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("{0, -25} World!", "Hello");

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal(
                "HtmlEncode[[Hello]]       World!", result);
        }
        public void HtmlFormattableString_MultipleArguments()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("{0} {1} {2} {3}!", "First", "Second", "Third", "Fourth");

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal(
                "HtmlEncode[[First]] HtmlEncode[[Second]] HtmlEncode[[Third]] HtmlEncode[[Fourth]]!",
                result);
        }
Example #11
0
        public void HtmlFormattableString_MultipleArguments()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("{0} {1} {2} {3}!", "First", "Second", "Third", "Fourth");

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal(
                "HtmlEncode[[First]] HtmlEncode[[Second]] HtmlEncode[[Third]] HtmlEncode[[Fourth]]!",
                result);
        }
Example #12
0
        public void HtmlFormattableString_With3Arguments()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("0x{0:X} - {1} equivalent for {2}.", 50, "hex", 50);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal(
                "0xHtmlEncode[[32]] - HtmlEncode[[hex]] equivalent for HtmlEncode[[50]].",
                result);
        }
Example #13
0
        public void HtmlFormattableString_WithMultipleHtmlContentArguments()
        {
            // Arrange
            var formattableString = new HtmlFormattableString(
                "Happy {0}, {1}!",
                new HtmlEncodedString("Birthday"),
                new HtmlContentBuilder().Append("Billy"));

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("Happy Birthday, HtmlEncode[[Billy]]!", result);
        }
Example #14
0
        public void HtmlFormattableString_WithOtherIHtmlContent()
        {
            // Arrange
            var builder = new HtmlContentBuilder();

            builder.Append("First");

            var formattableString = new HtmlFormattableString("{0}!", builder);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("HtmlEncode[[First]]!", result);
        }
Example #15
0
        public void HtmlFormattableString_WithCulture()
        {
            // Arrange
            var formattableString = new HtmlFormattableString(
                CultureInfo.InvariantCulture,
                "Numbers in InvariantCulture - {0, -5:N} {1} {2} {3}!",
                1.1,
                2.98,
                145.82,
                32.86);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal(
                "Numbers in InvariantCulture - HtmlEncode[[1.10]] HtmlEncode[[2.98]] " +
                "HtmlEncode[[145.82]] HtmlEncode[[32.86]]!",
                result);
        }
        public void HtmlFormattableString_WithAlignmentComponent()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("{0, -25} World!", "Hello");

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal(
                "HtmlEncode[[Hello]]       World!", result);
        }
        public void HtmlFormattableString_WithFormatStringComponent()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("0x{0:X}", 50);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("0xHtmlEncode[[32]]", result);
        }
        public void HtmlFormattableString_WithHtmlString_AndOffset()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("{0, 20}!", new HtmlString("First"));

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("               First!", result);
        }
        public void HtmlFormattableString_WithMultipleHtmlContentArguments()
        {
            // Arrange
            var formattableString = new HtmlFormattableString(
                "Happy {0}, {1}!",
                new HtmlString("Birthday"),
                new HtmlContentBuilder().Append("Billy"));

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("Happy Birthday, HtmlEncode[[Billy]]!", result);
        }
        public void HtmlFormattableString_WithOtherIHtmlContent()
        {
            // Arrange
            var builder = new HtmlContentBuilder();
            builder.Append("First");

            var formattableString = new HtmlFormattableString("{0}!", builder);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("HtmlEncode[[First]]!", result);
        }
        public void HtmlFormattableString_With3Arguments()
        {
            // Arrange
            var formattableString = new HtmlFormattableString("0x{0:X} - {1} equivalent for {2}.", 50, "hex", 50);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal(
                "0xHtmlEncode[[32]] - HtmlEncode[[hex]] equivalent for HtmlEncode[[50]].",
                result);
        }
        public void HtmlFormattableString_WithCulture()
        {
            // Arrange
            var formattableString = new HtmlFormattableString(
                CultureInfo.InvariantCulture,
                "Numbers in InvariantCulture - {0, -5:N} {1} {2} {3}!",
                1.1,
                2.98,
                145.82,
                32.86);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal(
                "Numbers in InvariantCulture - HtmlEncode[[1.10]] HtmlEncode[[2.98]] " +
                    "HtmlEncode[[145.82]] HtmlEncode[[32.86]]!",
                result);
        }