Skip to content

Commit d28c8af

Browse files
committed
added test for TS interface inheritance when TS interfaces are CS classes
1 parent a60b556 commit d28c8af

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace TypeGen.IntegrationTest.TsInterfaceInheritance.Entities;
2+
3+
public class Base
4+
{
5+
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace TypeGen.IntegrationTest.TsInterfaceInheritance.Entities;
2+
3+
public class Sub : Base
4+
{
5+
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* This is a TypeGen auto-generated file.
3+
* Any changes made to this file can be lost when this file is regenerated.
4+
*/
5+
6+
import { Base } from "./base";
7+
8+
export interface Sub extends Base {
9+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Threading.Tasks;
2+
using TypeGen.Core.Generator;
3+
using TypeGen.Core.SpecGeneration;
4+
using TypeGen.IntegrationTest.TestingUtils;
5+
using TypeGen.IntegrationTest.TsInterfaceInheritance.Entities;
6+
using Xunit;
7+
8+
namespace TypeGen.IntegrationTest.TsInterfaceInheritance;
9+
10+
public class TsInterfaceInheritanceTest : GenerationTestBase
11+
{
12+
[Fact]
13+
public async Task cs_classes_which_are_ts_interfaces_should_respect_ts_interface_inheritance()
14+
{
15+
var type = typeof(Sub);
16+
const string expectedLocation = "TypeGen.IntegrationTest.TsInterfaceInheritance.Expected.sub.ts";
17+
var generationSpec = new TsInterfaceInheritanceGenerationSpec();
18+
var generatorOptions = new GeneratorOptions();
19+
20+
await TestGenerationSpec(type, expectedLocation, generationSpec, generatorOptions);
21+
}
22+
23+
private class TsInterfaceInheritanceGenerationSpec : GenerationSpec
24+
{
25+
public TsInterfaceInheritanceGenerationSpec()
26+
{
27+
AddInterface<Base>();
28+
AddInterface<Sub>();
29+
}
30+
}
31+
}

src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
<EmbeddedResource Include="NullableTranslation\Expected\nullable-class.ts" />
114114
<EmbeddedResource Include="StructImplementsInterfaces\Expected\implements-interfaces.ts" />
115115
<EmbeddedResource Include="TsClassExtendsTsInterface\Expected\ts-class.ts" />
116+
<EmbeddedResource Include="TsInterfaceInheritance\Expected\sub.ts" />
116117
<EmbeddedResource Include="UseDefaultExportBreaksInterfaceInheritance\Expected\product-dto.ts" />
117118
</ItemGroup>
118119

0 commit comments

Comments
 (0)