-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prep to inject test config + mahapps
- Loading branch information
Showing
7 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
src/Vetuviem.IntegrationTests/ReactiveUI/WPF/MahAppsMetroViewBindingModelGeneratorTests.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,82 @@ | ||
// Copyright (c) 2022 DPVreony and Contributors. All rights reserved. | ||
// DPVreony and Contributors licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Vetuviem.SourceGenerator.Features.ControlBindingModels; | ||
using Vetuviem.Testing; | ||
using Vetuviem.WPF.SourceGenerator; | ||
using Xunit.Abstractions; | ||
|
||
namespace Vetuviem.IntegrationTests.ReactiveUI.WPF | ||
{ | ||
/// <summary> | ||
/// Unit Tests for the ViewBinding Model Source Generator for MahApps Metro. | ||
/// </summary> | ||
public static class MahAppsMetroViewBindingModelGeneratorTests | ||
{ | ||
/// <inheritdoc /> | ||
public sealed class ExecuteMethod : BaseGeneratorTests.BaseExecuteMethod<WpfControlBindingModelSourceGenerator, ControlBindingModelGeneratorProcessor> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ExecuteMethod"/> class. | ||
/// </summary> | ||
/// <param name="output">Test Output Helper.</param> | ||
public ExecuteMethod(ITestOutputHelper output) | ||
: base(output) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override AnalyzerConfigOptionsProvider? GetAnalyzerConfigOptionsProvider() | ||
{ | ||
return null; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void AddReferenceAssemblies(IList<MetadataReference> metadataReferences) | ||
{ | ||
if (metadataReferences == null) | ||
Check warning on line 43 in src/Vetuviem.IntegrationTests/ReactiveUI/WPF/MahAppsMetroViewBindingModelGeneratorTests.cs GitHub Actions / Analyze (csharp)
Check warning on line 43 in src/Vetuviem.IntegrationTests/ReactiveUI/WPF/MahAppsMetroViewBindingModelGeneratorTests.cs GitHub Actions / Analyze (csharp)
Check warning on line 43 in src/Vetuviem.IntegrationTests/ReactiveUI/WPF/MahAppsMetroViewBindingModelGeneratorTests.cs GitHub Actions / build
Check warning on line 43 in src/Vetuviem.IntegrationTests/ReactiveUI/WPF/MahAppsMetroViewBindingModelGeneratorTests.cs GitHub Actions / build
|
||
{ | ||
throw new ArgumentNullException(nameof(metadataReferences)); | ||
} | ||
|
||
var trustedAssembliesPaths = GetPlatformAssemblyPaths(); | ||
if (trustedAssembliesPaths == null) | ||
{ | ||
return; | ||
} | ||
|
||
foreach (string trustedAssembliesPath in trustedAssembliesPaths) | ||
{ | ||
var metadataReference = MetadataReference.CreateFromFile(trustedAssembliesPath); | ||
if (metadataReference == null) | ||
{ | ||
throw new InvalidOperationException($"Failed to create metadata reference for {trustedAssembliesPath}"); | ||
} | ||
metadataReferences.Add(metadataReference); | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override Func<WpfControlBindingModelSourceGenerator> GetFactory() | ||
{ | ||
return () => new WpfControlBindingModelSourceGenerator(); | ||
} | ||
|
||
private static string[]? GetPlatformAssemblyPaths() | ||
{ | ||
if (AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES") is string trustedPlatformAssemblies) | ||
{ | ||
return trustedPlatformAssemblies.Split(Path.PathSeparator); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
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,25 @@ | ||
#if TBC | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
|
||
namespace Vetuviem.Testing | ||
{ | ||
public sealed class TestAnalyzerConfigOptionsProvider : AnalyzerConfigOptionsProvider | ||
{ | ||
public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override AnalyzerConfigOptions GlobalOptions { get; } | ||
} | ||
} | ||
#endif |