Skip to content

Commit

Permalink
Added test coverage for classes with multiple generic arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Aug 4, 2023
1 parent acaf51d commit ba4393b
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion Schema Tests/binary/generator/GenericGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace schema.binary.text {
internal class GenericGeneratorTests {
[Test]
public void TestGenericStructure() {
public void Test1GenericArgumentClass() {
BinarySchemaTestUtil.AssertGenerated(@"
using schema.binary;
Expand Down Expand Up @@ -38,6 +38,46 @@ public void Write(ISubEndianBinaryWriter ew) {
");
}

[Test]
public void Test2GenericArgumentClass() {
BinarySchemaTestUtil.AssertGenerated(@"
using schema.binary;
namespace foo.bar {
[BinarySchema]
public partial class GenericWrapper<T1, T2> : IBinaryConvertible
where T1 : IBinaryConvertible, new(),
where T2 : IBinaryConvertible, new(){
public T1 Data1 { get; } = new();
public T2 Data2 { get; } = new();
}
}",
@"using System;
using System.IO;
namespace foo.bar {
public partial class GenericWrapper<T1, T2> {
public void Read(IEndianBinaryReader er) {
this.Data1.Read(er);
this.Data2.Read(er);
}
}
}
",
@"using System;
using System.IO;
namespace foo.bar {
public partial class GenericWrapper<T1, T2> {
public void Write(ISubEndianBinaryWriter ew) {
this.Data1.Write(ew);
this.Data2.Write(ew);
}
}
}
");
}

[Test]
public void TestGenericStructureArray() {
BinarySchemaTestUtil.AssertGenerated(@"
Expand Down

0 comments on commit ba4393b

Please sign in to comment.