|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.NET.Build.Tests
{
public class GenerateResourceTests : SdkTest
{
public GenerateResourceTests(ITestOutputHelper log) : base(log)
{
}
[WindowsOnlyTheory]
[InlineData(ToolsetInfo.CurrentTargetFramework, true)]
public void DependentUponTest(string targetFramework, bool isExe)
{
var testProject = new TestProject
{
Name = "HelloWorld",
TargetFrameworks = targetFramework,
IsExe = isExe,
SourceFiles =
{
["Program.cs"] = @"
using System;
namespace SomeNamespace
{
public static class SomeClass
{
public static void Main(string[] args)
{
var resourceManager = new global::System.Resources.ResourceManager(""SomeNamespace.SomeClass"", typeof(SomeClass).Assembly);
Console.WriteLine(resourceManager.GetString(""SomeString""));
}
}
}
",
},
EmbeddedResources =
{
["Program.resx"] = @"
<root>
<data name=""SomeString"" xml:space=""preserve"">
<value>Hello world from a resource!</value>
</data>
</root>
",
}
};
var testAsset = _testAssetsManager
.CreateTestProject(testProject, identifier: targetFramework + isExe);
var buildCommand = new BuildCommand(testAsset);
buildCommand
.Execute()
.Should()
.Pass();
var outputDirectory = buildCommand.GetOutputDirectory(targetFramework);
var runCommand = new RunExeCommand(Log, Path.Combine(outputDirectory.FullName, "HelloWorld.exe"));
runCommand
.Execute()
.Should()
.Pass()
.And.HaveStdOutContaining("Hello world from a resource!");
}
}
}
|