Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r committed Jan 29, 2024
1 parent b70a4c0 commit c0c2812
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Destructurama.Attributed.Tests/ReplacedAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public class CustomizedRegexLogs
/// </summary>
[LogReplaced(REGEX_WITH_VERTICAL_BARS, "***|$2|****")]
public string? RegexReplaceFirstThird { get; set; }

/// <summary>
/// LogReplaced works only for string properties.
/// </summary>
[LogReplaced("does not matter", "does not matter")]
public int RegexReplaceForInt { get; set; }
}

[TestFixture]
Expand Down Expand Up @@ -134,4 +140,20 @@ public void LogReplacedAttribute_Replaces_First_And_Third()
props.ContainsKey("RegexReplaceThird").ShouldBeTrue();
props["RegexReplaceThird"].LiteralValue().ShouldBe("123|456|***");
}

[Test]
public void LogReplacedAttribute_Should_Work_Only_For_String_Properties()
{
var customized = new CustomizedRegexLogs
{
RegexReplaceForInt = 42,
};

var evt = DelegatingSink.Execute(customized);

var sv = (StructureValue)evt.Properties["Customized"];
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

props.ContainsKey("RegexReplaceForInt").ShouldBeFalse();
}
}

1 comment on commit c0c2812

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: c0c2812 Previous: b70a4c0 Ratio
Benchmarks.AttributedBenchmarks.LogAsScalar 302.612510571113 ns (± 0.4603434793538416) 224.7885764280955 ns (± 1.017388086203832) 1.35

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.