-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathCSharpCodeGen.cs
48 lines (42 loc) · 1.57 KB
/
CSharpCodeGen.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.ML.Runtime.RunTests;
using Microsoft.ML.TestFramework;
using System.IO;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.ML.Tests
{
public class CSharpCodeGen : BaseTestBaseline
{
public CSharpCodeGen(ITestOutputHelper output) : base(output)
{
}
[Fact(Skip = "Execute this test if you want to regenerate CSharpApi file")]
public void RegenerateCSharpApi()
{
var basePath = GetDataPath("../../src/Microsoft.ML/CSharpApi.cs");
Runtime.Tools.Maml.Main(new[] { $"? generator=cs{{csFilename={basePath}}}" });
}
[Fact]
public void TestGeneratedCSharpAPI()
{
var dataPath = GetOutputPath("Api.cs");
Runtime.Tools.Maml.Main(new[] { $"? generator=cs{{csFilename={dataPath}}}" });
var basePath = GetDataPath("../../src/Microsoft.ML/CSharpApi.cs");
using (StreamReader baseline = OpenReader(basePath))
using (StreamReader result = OpenReader(dataPath))
{
for (; ; )
{
string line1 = baseline.ReadLine();
string line2 = result.ReadLine();
if (line1 == null && line2 == null)
break;
Assert.Equal(line1, line2);
}
}
}
}
}