|
| 1 | +// Copyright (c) .NET Foundation and contributors. All rights reserved. |
| 2 | +// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 | + |
| 4 | +using System.IO; |
| 5 | +using Microsoft.NET.TestFramework; |
| 6 | +using Microsoft.NET.TestFramework.Assertions; |
| 7 | +using Microsoft.NET.TestFramework.Commands; |
| 8 | +using Xunit; |
| 9 | +using System.Linq; |
| 10 | +using FluentAssertions; |
| 11 | +using System.Xml.Linq; |
| 12 | +using System.Collections.Generic; |
| 13 | +using System; |
| 14 | +using Xunit.Abstractions; |
| 15 | +using Microsoft.NET.TestFramework.ProjectConstruction; |
| 16 | + |
| 17 | +namespace Microsoft.NET.Build.Tests |
| 18 | +{ |
| 19 | + public class GivenThatWeWantToUseContentFiles : SdkTest |
| 20 | + { |
| 21 | + public GivenThatWeWantToUseContentFiles(ITestOutputHelper log) : base(log) |
| 22 | + { |
| 23 | + } |
| 24 | + |
| 25 | + |
| 26 | + [Fact] |
| 27 | + public void It_handles_content_files_correctly() |
| 28 | + { |
| 29 | + const string targetFramework = "netcoreapp2.0"; |
| 30 | + |
| 31 | + var project = new TestProject |
| 32 | + { |
| 33 | + Name = "ContentFiles", |
| 34 | + IsExe = true, |
| 35 | + TargetFrameworks = targetFramework, |
| 36 | + IsSdkProject = true, |
| 37 | + PackageReferences = { new TestPackageReference("ContentFilesExample", "1.0.2") }, |
| 38 | + }; |
| 39 | + |
| 40 | + project.SourceFiles[project.Name + ".cs"] = |
| 41 | +$@" |
| 42 | +using System; |
| 43 | +
|
| 44 | +namespace {project.Name} |
| 45 | +{{ |
| 46 | + static class Program |
| 47 | + {{ |
| 48 | + static void Main() |
| 49 | + {{ |
| 50 | + Console.WriteLine(ExampleReader.GetDataText()); |
| 51 | + }} |
| 52 | + }} |
| 53 | +}}"; |
| 54 | + |
| 55 | + var asset = _testAssetsManager |
| 56 | + .CreateTestProject(project) |
| 57 | + .Restore(Log, project.Name); |
| 58 | + |
| 59 | + var cmd = new BuildCommand(Log, Path.Combine(asset.Path, project.Name)); |
| 60 | + cmd.Execute().Should().Pass(); |
| 61 | + |
| 62 | + cmd.GetOutputDirectory(targetFramework) |
| 63 | + .Should() |
| 64 | + .OnlyHaveFiles( |
| 65 | + new[] |
| 66 | + { |
| 67 | + "ContentFiles.deps.json", |
| 68 | + "ContentFiles.dll", |
| 69 | + "ContentFiles.pdb", |
| 70 | + "ContentFiles.runtimeconfig.dev.json", |
| 71 | + "ContentFiles.runtimeconfig.json", |
| 72 | + "tools/run.cmd", |
| 73 | + "tools/run.sh", |
| 74 | + } |
| 75 | + ); |
| 76 | + } |
| 77 | + } |
| 78 | +} |
0 commit comments