Skip to content

Commit e5a08e6

Browse files
committed
Added coverlet.tests.projectsample.wpf6 with integration test
1 parent d9b9431 commit e5a08e6

File tree

8 files changed

+88
-1
lines changed

8 files changed

+88
-1
lines changed

coverlet.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.tests.projectsampl
6464
EndProject
6565
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.tests.projectsample.aspnet6.tests", "test\coverlet.tests.projectsample.aspnet6.tests\coverlet.tests.projectsample.aspnet6.tests.csproj", "{8EC065A4-7700-45E6-8B90-0182E3649DEA}"
6666
EndProject
67+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.tests.projectsample.wpf6", "test\coverlet.tests.projectsample.wpf6\coverlet.tests.projectsample.wpf6.csproj", "{988A5FF0-4326-4F5B-9F05-CB165543A555}"
68+
EndProject
6769
Global
6870
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6971
Debug|Any CPU = Debug|Any CPU
@@ -146,6 +148,10 @@ Global
146148
{8EC065A4-7700-45E6-8B90-0182E3649DEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
147149
{8EC065A4-7700-45E6-8B90-0182E3649DEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
148150
{8EC065A4-7700-45E6-8B90-0182E3649DEA}.Release|Any CPU.Build.0 = Release|Any CPU
151+
{988A5FF0-4326-4F5B-9F05-CB165543A555}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
152+
{988A5FF0-4326-4F5B-9F05-CB165543A555}.Debug|Any CPU.Build.0 = Debug|Any CPU
153+
{988A5FF0-4326-4F5B-9F05-CB165543A555}.Release|Any CPU.ActiveCfg = Release|Any CPU
154+
{988A5FF0-4326-4F5B-9F05-CB165543A555}.Release|Any CPU.Build.0 = Release|Any CPU
149155
EndGlobalSection
150156
GlobalSection(SolutionProperties) = preSolution
151157
HideSolutionNode = FALSE
@@ -171,6 +177,7 @@ Global
171177
{C9B7DC34-3E04-4F20-AED4-73791AF8020D} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
172178
{1C3CA3F8-DF8C-433F-8A56-69102D2BBDF6} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
173179
{8EC065A4-7700-45E6-8B90-0182E3649DEA} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
180+
{988A5FF0-4326-4F5B-9F05-CB165543A555} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
174181
EndGlobalSection
175182
GlobalSection(ExtensibilityGlobals) = postSolution
176183
SolutionGuid = {9CA57C02-97B0-4C38-A027-EA61E8741F10}

src/coverlet.core/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
[assembly: InternalsVisibleTo("coverlet.collector.tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ed0ed6af9693182615b8dcadc83c918b8d36312f86cefc69539d67d4189cd1b89420e7c3871802ffef7f5ca7816c68ad856c77bf7c230cc07824d96aa5d1237eebd30e246b9a14e22695fb26b40c800f74ea96619092cbd3a5d430d6c003fc7a82e8ccd1e315b935105d9232fe9e99e8d7ff54bba6f191959338d4a3169df9b3")]
1515
[assembly: InternalsVisibleTo("coverlet.integration.tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010001d24efbe9cbc2dc49b7a3d2ae34ca37cfb69b4f450acd768a22ce5cd021c8a38ae7dc68b2809a1ac606ad531b578f192a5690b2986990cbda4dd84ec65a3a4c1c36f6d7bb18f08592b93091535eaee2f0c8e48763ed7f190db2008e1f9e0facd5c0df5aaab74febd3430e09a428a72e5e6b88357f92d78e47512d46ebdc3cbb")]
1616
[assembly: InternalsVisibleTo("coverlet.tests.projectsample.aspnet6.tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100757cf9291d78a82e5bb58a827a3c46c2f959318327ad30d1b52e918321ffbd847fb21565b8576d2a3a24562a93e86c77a298b564a0f1b98f63d7a1441a3a8bcc206da3ed09d5dacc76e122a109a9d3ac608e21a054d667a2bae98510a1f0f653c0e6f58f42b4b3934f6012f5ec4a09b3dfd3e14d437ede1424bdb722aead64ad")]
17+
[assembly: InternalsVisibleTo("coverlet.tests.projectsample.wpf6.tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100757cf9291d78a82e5bb58a827a3c46c2f959318327ad30d1b52e918321ffbd847fb21565b8576d2a3a24562a93e86c77a298b564a0f1b98f63d7a1441a3a8bcc206da3ed09d5dacc76e122a109a9d3ac608e21a054d667a2bae98510a1f0f653c0e6f58f42b4b3934f6012f5ec4a09b3dfd3e14d437ede1424bdb722aead64ad")]
1718

1819
// Needed to mock internal type https://github.com/Moq/moq4/wiki/Quickstart#advanced-features
1920
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
}

test/coverlet.integration.tests/coverlet.integration.tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" />
11+
<PackageReference Include="Moq" />
1112
<PackageReference Include="NuGet.Packaging" />
1213
<PackageReference Include="xunit" />
1314
<PackageReference Include="xunit.runner.visualstudio" />

test/coverlet.tests.projectsample.aspnet6.tests/ResolverTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public void TestInstrument_NetCoreSharedFrameworkResolver()
3030
true);
3131

3232
var assemblies = new List<string>();
33-
Assert.True(resolver.TryResolveAssemblyPaths(compilationLibrary, assemblies));
33+
Assert.True(resolver.TryResolveAssemblyPaths(compilationLibrary, assemblies),
34+
"sample assembly shall be resolved");
3435
Assert.NotEmpty(assemblies);
3536
}
3637
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
namespace coverlet.tests.projectsample.wpf6;
5+
6+
public static class Program
7+
{
8+
public static void Main() { }
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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.Windows.Controls;
5+
6+
namespace coverlet.tests.projectsample.wpf6
7+
{
8+
public class TestClass
9+
{
10+
public UserControl? Control { get; set; }
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net6.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<UseWpf>true</UseWpf>
8+
<IsTestProject>false</IsTestProject>
9+
<EnableWindowsTargeting>true</EnableWindowsTargeting>
10+
</PropertyGroup>
11+
12+
</Project>

0 commit comments

Comments
 (0)