blob: 59360c09f9909d17139dbebe2ba30109e79d0b89 (
plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// 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 file in the project root for more information.
using System;
using Xunit;
using Microsoft.DotNet.Cli.Build.Framework;
using BundleTests.Helpers;
using Microsoft.DotNet.CoreSetup.Test;
namespace AppHost.Bundle.Tests
{
public class BundledAppWithSubDirs : IClassFixture<BundledAppWithSubDirs.SharedTestState>
{
private SharedTestState sharedTestState;
public BundledAppWithSubDirs(SharedTestState fixture)
{
sharedTestState = fixture;
}
private void RunTheApp(string path)
{
Command.Create(path)
.CaptureStdErr()
.CaptureStdOut()
.Execute()
.Should()
.Pass()
.And
.HaveStdOutContaining("Wow! We now say hello to the big world and you.");
}
[Fact]
public void Bundled_Framework_dependent_App_Run_Succeeds()
{
var fixture = sharedTestState.TestFrameworkDependentFixture.Copy();
var singleFile = BundleHelper.BundleApp(fixture);
// Run the bundled app (extract files)
RunTheApp(singleFile);
// Run the bundled app again (reuse extracted files)
RunTheApp(singleFile);
}
[Fact]
public void Bundled_Self_Contained_App_Run_Succeeds()
{
var fixture = sharedTestState.TestSelfContainedFixture.Copy();
var singleFile = BundleHelper.BundleApp(fixture);
// Run the bundled app (extract files)
RunTheApp(singleFile);
// Run the bundled app again (reuse extracted files)
RunTheApp(singleFile);
}
[Fact]
public void Bundled_With_Empty_File_Succeeds()
{
var fixture = sharedTestState.TestAppWithEmptyFileFixture.Copy();
var singleFile = BundleHelper.BundleApp(fixture);
// Run the app
RunTheApp(singleFile);
}
public class SharedTestState : IDisposable
{
public TestProjectFixture TestFrameworkDependentFixture { get; set; }
public TestProjectFixture TestSelfContainedFixture { get; set; }
public TestProjectFixture TestAppWithEmptyFileFixture { get; set; }
public RepoDirectoriesProvider RepoDirectories { get; set; }
public SharedTestState()
{
RepoDirectories = new RepoDirectoriesProvider();
TestFrameworkDependentFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestFrameworkDependentFixture);
TestFrameworkDependentFixture
.EnsureRestoredForRid(TestFrameworkDependentFixture.CurrentRid, RepoDirectories.CorehostPackages)
.PublishProject(runtime: TestFrameworkDependentFixture.CurrentRid,
outputDirectory: BundleHelper.GetPublishPath(TestFrameworkDependentFixture));
TestSelfContainedFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestSelfContainedFixture);
TestSelfContainedFixture
.EnsureRestoredForRid(TestSelfContainedFixture.CurrentRid, RepoDirectories.CorehostPackages)
.PublishProject(runtime: TestSelfContainedFixture.CurrentRid,
outputDirectory: BundleHelper.GetPublishPath(TestSelfContainedFixture));
TestAppWithEmptyFileFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestAppWithEmptyFileFixture);
BundleHelper.AddEmptyContentToApp(TestAppWithEmptyFileFixture);
TestAppWithEmptyFileFixture
.EnsureRestoredForRid(TestAppWithEmptyFileFixture.CurrentRid, RepoDirectories.CorehostPackages)
.PublishProject(runtime: TestAppWithEmptyFileFixture.CurrentRid,
outputDirectory: BundleHelper.GetPublishPath(TestAppWithEmptyFileFixture));
}
public void Dispose()
{
TestFrameworkDependentFixture.Dispose();
TestSelfContainedFixture.Dispose();
TestAppWithEmptyFileFixture.Dispose();
}
}
}
}
|