-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9479d2
commit 7b24324
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/ClangSharp.PInvokeGenerator.UnitTests/OptionsTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace ClangSharp.UnitTests; | ||
|
||
public sealed class OptionsTest : PInvokeGeneratorTest | ||
{ | ||
[Test] | ||
public Task WithUsings() | ||
{ | ||
var inputContents = @"struct StructA {}; | ||
namespace NS | ||
{ | ||
struct StructB {}; | ||
struct StructC {}; | ||
} | ||
struct StructD {}; | ||
"; | ||
var expectedOutputContents = @"using ForStar; | ||
using ForStructA1; | ||
using ForStructA2; | ||
using ForStructBWithDoubleColon; | ||
using ForStructCWithDot; | ||
namespace ClangSharp.Test | ||
{ | ||
public partial struct StructA | ||
{ | ||
} | ||
public partial struct StructB | ||
{ | ||
} | ||
public partial struct StructC | ||
{ | ||
} | ||
public partial struct StructD | ||
{ | ||
} | ||
} | ||
"; | ||
var withUsings = new Dictionary<string, IReadOnlyList<string>> { | ||
["StructA"] = ["ForStructA1", "ForStructA2"], | ||
["*"] = ["ForStar"], | ||
["NS::StructB"] = ["ForStructBWithDoubleColon"], | ||
["NS.StructC"] = ["ForStructCWithDot"], | ||
["DoesNotExist"] = ["ErrorShouldNotBeInOutput"], | ||
}; | ||
|
||
return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withUsings); | ||
} | ||
} |