Skip to content

Commit

Permalink
adds test for #282
Browse files Browse the repository at this point in the history
Behavior was already correct most likely fixed by the refactoring that introduced PropertyGenerator type
  • Loading branch information
adrianoc committed Jun 19, 2024
1 parent e3fa515 commit 2b21387
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Cecilifier.Core.Tests/Tests/Unit/PropertySpecificTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using NUnit.Framework;

namespace Cecilifier.Core.Tests.Tests.Unit;

[TestFixture]
public class PropertySpecificTests : CecilifierUnitTestBase
{
[Test]
public void AccessorAccessibility_IsRespected()
{
var code = """
class Foo
{
public int Value
{
private get => 1;
set { }
}
}
""";

var result = RunCecilifier(code);
var cecilifiedCode = result.GeneratedCode.ReadToEnd();

Assert.That(cecilifiedCode, Does.Match("""
//Getter
\s+var m_get_\d+ = new MethodDefinition\("get_Value", MethodAttributes.Private.+, .+TypeSystem.Int32\);
"""));

Assert.That(cecilifiedCode, Does.Match("""
// Setter
\s+var l_set_\d+ = new MethodDefinition\("set_Value", MethodAttributes.Public.+, .+TypeSystem.Void\);
"""));
}
}

0 comments on commit 2b21387

Please sign in to comment.