public void GivenAPropertyNameWithFormatting_WhenRendering_ThenSubstituteWithFormattedValue() { // Arrange var substitutionRenderer = new SubstitutionRenderer("Value:D5", new Template(new TemplateParser())); var consoleProxy = new TestProxy(); // Act substitutionRenderer.Render(consoleProxy, new { Value = 1 }, CultureInfo.CurrentUICulture); // Assert Assert.Equal("00001", consoleProxy.ToString()); }
public void GivenANestedPropertyName_WhenRendering_ThenSubstituteWithValue() { // Arrange var substitutionRenderer = new SubstitutionRenderer("Value.Length", new Template(new TemplateParser())); var consoleProxy = new TestProxy(); // Act substitutionRenderer.Render(consoleProxy, new { Value = "This is the value" }, CultureInfo.CurrentUICulture); // Assert Assert.Equal("17", consoleProxy.ToString()); }
public void GivenANullValue_WhenSubstituting_ThenReplaceWithEmptyString() { // Arrange var substitutionRenderer = new SubstitutionRenderer("Value", new Template(new TemplateParser())); var consoleProxy = new TestProxy(); // Act substitutionRenderer.Render(consoleProxy, new { Value = (string)null }, CultureInfo.CurrentUICulture); // Assert Assert.Equal(consoleProxy.ToString(), string.Empty); }
public void GivenASimplePropertyNameWithWrongCasing_WhenRendering_ThenSubstituteWithEmptyString() { // Arrange var substitutionRenderer = new SubstitutionRenderer("value", new Template(new TemplateParser())); var consoleProxy = new TestProxy(); // Act substitutionRenderer.Render(consoleProxy, new { Value = "This is the value" }, CultureInfo.CurrentUICulture); // Assert Assert.Equal(string.Empty, consoleProxy.ToString()); }