Skip to content

Commit

Permalink
Add LogMaskedAttribute_Nullify_Bool_Property test
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r committed Dec 12, 2024
1 parent e309ec1 commit 88a8732
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Destructurama.Attributed.Tests/MaskedAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -690,4 +690,33 @@ public void LogMaskedAttribute_Shows_First_NChars_And_Last_NChars_Then_Replaces_
props.ContainsKey("ShowFirstAndLastThreeAndCustomMaskInTheMiddlePreservedLengthIgnored").ShouldBeTrue();
props["ShowFirstAndLastThreeAndCustomMaskInTheMiddlePreservedLengthIgnored"].LiteralValue().ShouldBe("123_REMOVED_321");
}

[Test]
public void LogMaskedAttribute_Nullify_Bool_Property()
{
var customized = new CustomizedMaskedLogs2
{
Enabled1 = true,
Enabled2 = true,
};

var evt = DelegatingSink.Execute(customized);

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

props.ContainsKey("Enabled1").ShouldBeTrue();
props["Enabled1"].LiteralValue().ShouldBe(true);

props.ContainsKey("Enabled2").ShouldBeTrue();
props["Enabled2"].LiteralValue().ShouldBeNull();
}

private class CustomizedMaskedLogs2
{
public bool Enabled1 { get; set; }

[LogMasked]
public bool Enabled2 { get; set; }
}
}

0 comments on commit 88a8732

Please sign in to comment.