WixTaskTests.cs :  » Installers-Generators » WiX » Microsoft » Tools » WindowsInstallerXml » Test » Tests » Wixproj » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Installers Generators » WiX 
WiX » Microsoft » Tools » WindowsInstallerXml » Test » Tests » Wixproj » WixTaskTests.cs
//-----------------------------------------------------------------------
// <copyright file="WixTaskTests.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
//    
//    The use and distribution terms for this software are covered by the
//    Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
//    which can be found in the file CPL.TXT at the root of this distribution.
//    By using this software in any fashion, you are agreeing to be bound by
//    the terms of this license.
//    
//    You must not remove this notice, or any other, from this software.
// </copyright>
// <summary>
//      Test that that the parameters supported by Candle,
//      Light and Lit are up to date in the MSBuild task.
// </summary>
//-----------------------------------------------------------------------

namespace Microsoft.Tools.WindowsInstallerXml.Test.Tests.Wixproj{
    using System;
    using System.IO;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Microsoft.Tools.WindowsInstallerXml.Test;

    [TestClass]
    public class WixTaskTests
    {
        private static readonly string testWiXInstallerx86 = Environment.ExpandEnvironmentVariables(@"%WIX_ROOT%\test\data\Wixproj\WixTaskTests\ProductWixInstallerx86\ProductWixInstallerx86.wixproj");
        private static readonly string testWiXInstallerx64 = Environment.ExpandEnvironmentVariables(@"%WIX_ROOT%\test\data\Wixproj\WixTaskTests\ProductWixInstallerx64\ProductWixInstallerx64.wixproj");
        private static readonly string testWiXLibraryx86 = Environment.ExpandEnvironmentVariables(@"%WIX_ROOT%\test\data\Wixproj\WixTaskTests\ProductWixLibraryx86\ProductWixLibraryx86.wixproj");
        private static readonly string testWiXLibraryx64 = Environment.ExpandEnvironmentVariables(@"%WIX_ROOT%\test\data\Wixproj\WixTaskTests\ProductWixLibraryx64\ProductWixLibraryx64.wixproj");

        [TestMethod]
        [Priority(1)]
        [Description("Tests building WiX Project (candle and light tasks) with different configurations.")]
        public void BuildWiXInstaller()
        {
            // Configuration=Debug; Platform=x86;
            WixTaskTests.TestBuildWiXInstallerTasks(WixTaskTests.testWiXInstallerx86, "Build", "Debug", "x86");

            // Configuration=Release; Platform=x86;
            WixTaskTests.TestBuildWiXInstallerTasks(WixTaskTests.testWiXInstallerx86, "Build", "Release", "x86");

            // Configuration=Debug; Platform=x64;
            WixTaskTests.TestBuildWiXInstallerTasks(WixTaskTests.testWiXInstallerx64, "Build", "Debug", "x64");

            // Configuration=Releasee; Platform=x64;
            WixTaskTests.TestBuildWiXInstallerTasks(WixTaskTests.testWiXInstallerx64, "Build", "Release", "x64");
        }

        [TestMethod]
        [Priority(1)]
        [Description("Tests rebuilding WiX Project (candle and light tasks) with different configurations.")]
        public void RebuildWiXInstaller()
        {
            // Configuration=Debug; Platform=x86;
            WixTaskTests.TestBuildWiXInstallerTasks(WixTaskTests.testWiXInstallerx86, "Rebuild", "Debug", "x86");

            // Configuration=Release; Platform=x86;
            WixTaskTests.TestBuildWiXInstallerTasks(WixTaskTests.testWiXInstallerx86, "Rebuild", "Release", "x86");

            // Configuration=Debug; Platform=x64;
            WixTaskTests.TestBuildWiXInstallerTasks(WixTaskTests.testWiXInstallerx64, "Rebuild", "Debug", "x64");

            // Configuration=Release; Platform=x64;
            WixTaskTests.TestBuildWiXInstallerTasks(WixTaskTests.testWiXInstallerx64, "Rebuild", "Release", "x64");
        }

        [TestMethod]
        [Priority(2)]
        [Description("Tests cleaning WiX Project (candle and light tasks) with different configurations.")]
        public void CleanWiXInstaller()
        {
            // Configuration=Debug; Platform=x86;
            WixTaskTests.TestCleanWiXInstaller(WixTaskTests.testWiXInstallerx86, "Debug", "x86");

            // Configuration=Release; Platform=x86;
            WixTaskTests.TestCleanWiXInstaller(WixTaskTests.testWiXInstallerx86, "Release", "x86");

            // Configuration=Debug; Platform=x64;
            WixTaskTests.TestCleanWiXInstaller(WixTaskTests.testWiXInstallerx64, "Debug", "x64");

            // Configuration=Release; Platform=x64;
            WixTaskTests.TestCleanWiXInstaller(WixTaskTests.testWiXInstallerx64, "Release", "x64");
        }

        [TestMethod]
        [Priority(1)]
        [Description("Tests building WiX Library Project (candle and lit tasks) with different configurations.")]
        public void BuildWiXLibrary()
        {
            // Configuration=Debug; Platform=x86;
            WixTaskTests.TestBuildWiXLibraryTasks(WixTaskTests.testWiXLibraryx86, "Build", "Debug", "x86");

            // Configuration=Release; Platform=x86;
            WixTaskTests.TestBuildWiXLibraryTasks(WixTaskTests.testWiXLibraryx86, "Build", "Release", "x86");

            // Configuration=Debug; Platform=x64;
            WixTaskTests.TestBuildWiXLibraryTasks(WixTaskTests.testWiXLibraryx64, "Build", "Debug", "x64");

            // Configuration=Release; Platform=x64;
            WixTaskTests.TestBuildWiXLibraryTasks(WixTaskTests.testWiXLibraryx64, "Build", "Release", "x64");
        }

        [TestMethod]
        [Priority(1)]
        [Description("Tests rebuilding WiX Library Project (candle and lit tasks) with different configurations.")]
        public void RebuildWiXLibrary()
        {
            // Configuration=Debug; Platform=x86;
            WixTaskTests.TestBuildWiXLibraryTasks(WixTaskTests.testWiXLibraryx86, "Rebuild", "Debug", "x86");

            // Configuration=Release; Platform=x86;
            WixTaskTests.TestBuildWiXLibraryTasks(WixTaskTests.testWiXLibraryx86, "Rebuild", "Release", "x86");

            // Configuration=Debug; Platform=x64;
            WixTaskTests.TestBuildWiXLibraryTasks(WixTaskTests.testWiXLibraryx64, "Rebuild", "Debug", "x64");

            // Configuration=Release; Platform=x64;
            WixTaskTests.TestBuildWiXLibraryTasks(WixTaskTests.testWiXLibraryx64, "Rebuild", "Release", "x64");
        }

        [TestMethod]
        [Priority(2)]
        [Description("Tests cleaning WiX Library Project (candle and lit tasks) with different configurations.")]
        public void CleanWiXLibrary()
        {
            // Configuration=Debug; Platform=x86;
            WixTaskTests.TestCleanWiXLibrary(WixTaskTests.testWiXLibraryx86, "Debug", "x86");

            // Configuration=Release; Platform=x86;
            WixTaskTests.TestCleanWiXLibrary(WixTaskTests.testWiXLibraryx86, "Release", "x86");

            // Configuration=Debug; Platform=x64;
            WixTaskTests.TestCleanWiXLibrary(WixTaskTests.testWiXLibraryx64, "Debug", "x64");

            // Configuration=Release; Platform=x64;
            WixTaskTests.TestCleanWiXLibrary(WixTaskTests.testWiXLibraryx64, "Release", "x64");
        }

        /// <summary>
        /// Runs the MSBuild for a WiX Project passing build parameters and verifies that subtasks were ran correctly
        /// </summary>
        /// <param name="wixProjectFile">Path to the WiX Project to be build</param>
        /// <param name="target">Target parameter</param>
        /// <param name="configuration">Configuration parameter</param>
        /// <param name="architecture">Architecture parameter</param>
        /// <returns>The WixprojMSBuild object that was run</returns>
        private static WixprojMSBuild TestBuildWiXInstallerTasks(string wixProjectFile, string target, string configuration, string architecture)
        {
            // Initialize build parameters
            WixprojMSBuild wixprojMSBuild = new WixprojMSBuild();
            wixprojMSBuild.ProjectFile = wixProjectFile;
            wixprojMSBuild.Targets.Add(target);
            wixprojMSBuild.Properties.Add("Platform", architecture);
            wixprojMSBuild.Properties.Add("Configuration", configuration);
            wixprojMSBuild.OutputRootDirectory = Builder.GetUniqueFileName();
            wixprojMSBuild.Run();

            // Assert that the compilation ran correct and without errors
            wixprojMSBuild.AssertTaskExists("Candle");
            wixprojMSBuild.AssertNotExistsTaskSubstring("Candle", "error", true);
            wixprojMSBuild.AssertNotExistsTaskSubstring("Candle", "warning", true);
            wixprojMSBuild.AssertTaskSubstring("Candle", string.Format("-arch {0}", architecture));

            // Assert that the linking ran correct and without errors
            wixprojMSBuild.AssertTaskExists("Light");
            wixprojMSBuild.AssertNotExistsTaskSubstring("Light", "error", true);
            wixprojMSBuild.AssertNotExistsTaskSubstring("Light", "warning", true);

            return wixprojMSBuild;
        }

        /// <summary>
        /// Runs the MSBuild for a WiX Library Project passing build parameters and verifies that subtasks were ran correctly
        /// </summary>
        /// <param name="wixProjectFile">Path to the WiX Project to be build</param>
        /// <param name="target">Target parameter</param>
        /// <param name="configuration">Configuration parameter</param>
        /// <param name="architecture">Architecture parameter</param>
        /// <returns>The WixprojMSBuild object that was run</returns>
        private static WixprojMSBuild TestBuildWiXLibraryTasks(string wixProjectFile, string target, string configuration, string architecture)
        {
            // Initialize build parameters
            WixprojMSBuild wixprojMSBuild = new WixprojMSBuild();
            wixprojMSBuild.ProjectFile = wixProjectFile;
            wixprojMSBuild.Targets.Add(target);
            wixprojMSBuild.Properties.Add("Platform", architecture);
            wixprojMSBuild.Properties.Add("Configuration", configuration);
            wixprojMSBuild.OutputRootDirectory = Builder.GetUniqueFileName();
            wixprojMSBuild.Run();

            // Assert that the compilation ran correct and without errors
            wixprojMSBuild.AssertTaskExists("Candle");
            wixprojMSBuild.AssertNotExistsTaskSubstring("Candle", "error", true);
            wixprojMSBuild.AssertNotExistsTaskSubstring("Candle", "warning", true);
            wixprojMSBuild.AssertTaskSubstring("Candle", string.Format("-arch {0}", architecture));

            // Assert that the linking ran correct and without errors
            wixprojMSBuild.AssertTaskExists("Lit");
            wixprojMSBuild.AssertNotExistsTaskSubstring("Lit", "error", true);
            wixprojMSBuild.AssertNotExistsTaskSubstring("Lit", "warning", true);

            return wixprojMSBuild;
        }

        /// <summary>
        /// Runs MSBuild for a WiX Project with target parameter 'Clean' for particular configuration and architecture and verifies that subtasks were ran correctly
        /// </summary>
        /// <param name="wixProjectFile">Path to the WiX Project to be build</param>
        /// <param name="configuration">Configuration parameter</param>
        /// <param name="architecture">Architecture parameter</param>
        private static void TestCleanWiXInstaller(string wixProjectFile, string configuration, string architecture)
        {
            WixprojMSBuild wixprojMSBuild = WixTaskTests.TestBuildWiXInstallerTasks(wixProjectFile, "Build", configuration, architecture);

            wixprojMSBuild.OtherArguments = string.Format("/t:Clean /p:Configuration={0};Platform={1}", configuration, architecture);
            wixprojMSBuild.Run();
        }

        /// <summary>
        /// Runs MSBuild for a WiX Library Project with target parameter 'Clean' for particular configuration and architecture and verifies that subtasks were ran correctly
        /// </summary>
        /// <param name="wixProjectFile">Path to the WiX Project to be build</param>
        /// <param name="configuration">Configuration parameter</param>
        /// <param name="architecture">Architecture parameter</param>
        private static void TestCleanWiXLibrary(string wixProjectFile, string configuration, string architecture)
        {
            WixprojMSBuild wixprojMSBuild = WixTaskTests.TestBuildWiXLibraryTasks(wixProjectFile, "Build", configuration, architecture);

            wixprojMSBuild.OtherArguments = string.Format("/t:Clean /p:Configuration={0};Platform={1}", configuration, architecture);
            wixprojMSBuild.Run();
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.