From bc8276d1a3f0dd558cbb4a5ed3e0d9f6f8cb0810 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Sun, 28 Jan 2024 10:47:30 +0300 Subject: [PATCH] Add test for set-only property --- .../AttributedDestructuringTests.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs b/src/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs index 24ad002..bbd1bcc 100644 --- a/src/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs +++ b/src/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs @@ -15,13 +15,23 @@ public void Throwing_Accessor_Should_Be_Handled() var evt = DelegatingSink.Execute(customized); - // Verify var sv = (StructureValue)evt.Properties["Customized"]; sv.Properties.Count.ShouldBe(1); sv.Properties[0].Name.ShouldBe("BadProperty"); sv.Properties[0].Value.ShouldBeOfType().Value.ShouldBe("***"); } + [Test] + public void Only_Settable_Accessor_Should_Be_Handled() + { + var customized = new ClassWithOnlySetters(); + + var evt = DelegatingSink.Execute(customized); + + var sv = (StructureValue)evt.Properties["Customized"]; + sv.Properties.Count.ShouldBe(0); + } + [Test] public void AttributesAreConsultedWhenDestructuring() { @@ -63,6 +73,15 @@ public class ClassWithThrowingAccessor public string? BadProperty => throw new FormatException("oops"); } + public class ClassWithOnlySetters + { + [LogMasked] + public string? Name { set { } } + + [LogAsScalar] + public Struct1 Struct1 { set { } } + } + [LogAsScalar] public class ImmutableScalar {