-
Notifications
You must be signed in to change notification settings - Fork 414
Expand file tree
/
Copy pathPackageContentTests.cs
More file actions
73 lines (62 loc) · 2.68 KB
/
PackageContentTests.cs
File metadata and controls
73 lines (62 loc) · 2.68 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// 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.md file in the project root for more information.
using System.IO.Compression;
using Microsoft.VisualStudio.Utilities;
using VerifyTests;
using VerifyXunit;
namespace Microsoft.VisualStudio.Setup
{
[UsesVerify]
public sealed class PackageContentTests
{
// These files are only added as part of signing.
private const string DigitalSignature = "package/services/digital-signature";
private const string SettingsRegistrationFileSuffix = "registration.json";
private const string Rels = "_rels/.rels";
[Fact]
public Task ProjectSystem()
{
IEnumerable<string> files = GetPackageContents("ProjectSystem.vsix");
VerifierSettings.ScrubLinesContaining(DigitalSignature, Rels, SettingsRegistrationFileSuffix);
return Verifier.Verify(files);
}
[Fact]
public Task VisualStudioEditorsSetup()
{
IEnumerable<string> files = GetPackageContents("VisualStudioEditorsSetup.vsix");
VerifierSettings.ScrubLinesContaining(DigitalSignature, Rels, SettingsRegistrationFileSuffix);
return Verifier.Verify(files);
}
[Fact]
public Task CommonFiles()
{
IEnumerable<string> files = GetPackageContents("Microsoft.VisualStudio.ProjectSystem.Managed.CommonFiles.vsix");
VerifierSettings.ScrubLinesContaining(DigitalSignature);
VerifierSettings.ScrubLinesContaining(SettingsRegistrationFileSuffix);
// manifest.json is the last line for non-signed builds.
// It will not contain a comma in this situation, so we need special logic for that.
VerifierSettings.ScrubLinesWithReplace(s => s.EndsWith("manifest.json") ? " manifest.json," : s);
return Verifier.Verify(files);
}
private static IEnumerable<string> GetPackageContents(string vsixName)
{
var rootPath = RepoUtil.FindRepoRootPath();
#if DEBUG
var config = "Debug";
#elif RELEASE
var config = "Release";
#else
#error Unexpected configuration
#endif
// D:\repos\project-system\artifacts\Debug\VSSetup\Insertion\ProjectSystem.vsix
var vsixPath = Path.Combine(
rootPath,
"artifacts",
config,
"VSSetup",
"Insertion",
vsixName);
using var archive = ZipFile.OpenRead(vsixPath);
return archive.Entries.Select(entry => entry.FullName).OrderBy(fn => fn);
}
}
}