added support for records
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace InterfaceGenerator.Tests
|
||||
{
|
||||
public class RecordInterfaceGenerationTests
|
||||
{
|
||||
private readonly ITestRecord _sut;
|
||||
|
||||
public RecordInterfaceGenerationTests()
|
||||
{
|
||||
_sut = new TestRecord(420);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RecordProperty_IsGenerated()
|
||||
{
|
||||
var prop = typeof(ITestRecord)
|
||||
.GetProperty(nameof(TestRecord.RecordProperty));
|
||||
|
||||
prop.Should().NotBeNull();
|
||||
|
||||
prop.GetMethod.Should().NotBeNull();
|
||||
prop.SetMethod.Should().NotBeNull();
|
||||
prop.SetMethod.ReturnParameter.GetRequiredCustomModifiers().Should().Contain(typeof(IsExternalInit));
|
||||
|
||||
_sut.RecordProperty.Should().Be(420);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RecordMethod_IsGenerated()
|
||||
{
|
||||
var method = typeof(ITestRecord).GetMethod(
|
||||
nameof(TestRecord.RecordMethod));
|
||||
|
||||
method.Should().NotBeNull();
|
||||
method.ReturnType.Should().Be(typeof(void));
|
||||
|
||||
var parameters = method.GetParameters();
|
||||
parameters.Should().BeEmpty();
|
||||
|
||||
_sut.RecordMethod();
|
||||
}
|
||||
}
|
||||
|
||||
[GenerateAutoInterface]
|
||||
internal record TestRecord(int RecordProperty) : ITestRecord
|
||||
{
|
||||
public void RecordMethod()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user