|
| 1 | +// Copyright (c) Toni Solarin-Sodara |
| 2 | +// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 | + |
| 4 | +using System.Collections.Generic; |
| 5 | +using System.IO; |
| 6 | +using System.Linq; |
| 7 | +using Coverlet.Core.Abstractions; |
| 8 | +using Coverlet.Core.Instrumentation; |
| 9 | +using Coverlet.Tests.Xunit.Extensions; |
| 10 | +using Microsoft.Extensions.DependencyModel; |
| 11 | +using Moq; |
| 12 | +using Xunit; |
| 13 | + |
| 14 | +namespace Coverlet.Integration.Tests |
| 15 | +{ |
| 16 | + public class WpfResolverTests : BaseTest |
| 17 | + { |
| 18 | + [ConditionalFact] |
| 19 | + [SkipOnOS(OS.Linux, "WPF only runs on Windows")] |
| 20 | + [SkipOnOS(OS.MacOS, "WPF only runs on Windows")] |
| 21 | + public void TestInstrument_NetCoreSharedFrameworkResolver() |
| 22 | + { |
| 23 | + string wpfProjectPath = "../../../../coverlet.tests.projectsample.wpf6"; |
| 24 | + Assert.True(DotnetCli($"build \"{wpfProjectPath}\"", out string output, out string error)); |
| 25 | + string assemblyLocation = Directory.GetFiles($"{wpfProjectPath}/bin", "coverlet.tests.projectsample.wpf6.dll", SearchOption.AllDirectories).First(); |
| 26 | + |
| 27 | + var mockLogger = new Mock<ILogger>(); |
| 28 | + var resolver = new NetCoreSharedFrameworkResolver(assemblyLocation, mockLogger.Object); |
| 29 | + var compilationLibrary = new CompilationLibrary( |
| 30 | + "package", |
| 31 | + "System.Drawing", |
| 32 | + "0.0.0.0", |
| 33 | + "sha512-not-relevant", |
| 34 | + Enumerable.Empty<string>(), |
| 35 | + Enumerable.Empty<Dependency>(), |
| 36 | + true); |
| 37 | + |
| 38 | + var assemblies = new List<string>(); |
| 39 | + Assert.True(resolver.TryResolveAssemblyPaths(compilationLibrary, assemblies), |
| 40 | + "sample assembly shall be resolved"); |
| 41 | + Assert.NotEmpty(assemblies); |
| 42 | + } |
| 43 | + } |
| 44 | +} |
0 commit comments