// Copyright (C) 2025 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 using System; using System.IO; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Build.Construction; namespace QtVsTools.Test.QtMsBuild.Build { [TestClass] public class Test_LateBinding { [TestMethod] public void Concept() { using var temp = new TempProject(); temp.Create(@" $(X) The quick brown fox $(X) jumped over the lazy dog. @(Eval->'%(X)') jumped over the lazy dog. The sleek gray wolf ".Trim()); var project = MsBuild.Evaluate(temp.ProjectPath); Assert.AreEqual( project.ExpandString("$(X)"), "The sleek gray wolf"); Assert.AreEqual( project.ExpandString("$(Y)"), "The quick brown fox jumped over the lazy dog."); Assert.AreEqual( project.ExpandString("$(Z)"), "The sleek gray wolf jumped over the lazy dog."); } [TestMethod] public void QtDeployDir() { using TempProject temp = new(); temp.Clone($@"{Properties.SolutionDir}Tests\ProjectFormats\304\QtProjectV304.vcxproj"); var project = MsBuild.Evaluate(temp.ProjectPath, ("Platform", "x64")); Assert.AreEqual( project.ExpandString("$(QtDeployDir)"), project.ExpandString("$(OutDir)"), ignoreCase: true); using TempProject temp2 = new(); temp2.Clone(temp.ProjectPath); var xml = ProjectRootElement.Open(temp2.ProjectPath); var props = xml.AddPropertyGroup(); props.AddProperty("OutDir", @$"{temp2.ProjectDir}\out\"); xml.Save(); project = MsBuild.Evaluate(temp2.ProjectPath, ("Platform", "x64")); Assert.AreEqual( project.ExpandString("$(QtDeployDir)"), project.ExpandString("$(OutDir)"), ignoreCase: true); } } }