upgrade tests project to .net6
This commit is contained in:
@@ -2,70 +2,69 @@ using System.Runtime.CompilerServices;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace InterfaceGenerator.Tests
|
||||
namespace InterfaceGenerator.Tests;
|
||||
|
||||
public class RecordInterfaceGenerationTests
|
||||
{
|
||||
public class RecordInterfaceGenerationTests
|
||||
private readonly ITestRecord _sut;
|
||||
|
||||
public 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();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deconstruct_IsGenerated()
|
||||
{
|
||||
var method = typeof(ITestRecord).GetMethod(
|
||||
nameof(TestRecord.Deconstruct));
|
||||
|
||||
method.Should().NotBeNull();
|
||||
method!.ReturnType.Should().Be(typeof(void));
|
||||
|
||||
var parameters = method.GetParameters();
|
||||
parameters.Length.Should().Be(1);
|
||||
|
||||
var parameter = parameters[0];
|
||||
parameter.ParameterType.Should().Be(typeof(int).MakeByRefType());
|
||||
parameter.IsOut.Should().BeTrue();
|
||||
}
|
||||
_sut = new TestRecord(420);
|
||||
}
|
||||
|
||||
[GenerateAutoInterface]
|
||||
internal record TestRecord(int RecordProperty) : ITestRecord
|
||||
[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();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deconstruct_IsGenerated()
|
||||
{
|
||||
var method = typeof(ITestRecord).GetMethod(
|
||||
nameof(TestRecord.Deconstruct));
|
||||
|
||||
method.Should().NotBeNull();
|
||||
method!.ReturnType.Should().Be(typeof(void));
|
||||
|
||||
var parameters = method.GetParameters();
|
||||
parameters.Length.Should().Be(1);
|
||||
|
||||
var parameter = parameters[0];
|
||||
parameter.ParameterType.Should().Be(typeof(int).MakeByRefType());
|
||||
parameter.IsOut.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
|
||||
[GenerateAutoInterface]
|
||||
internal record TestRecord(int RecordProperty) : ITestRecord
|
||||
{
|
||||
public void RecordMethod()
|
||||
{
|
||||
public void RecordMethod()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user