Esempio n. 1
0
        private static string GenerateTestReferencesSnippet(LoadTestInfo loadTest)
        {
            HashSet <string> uniqueAssemblies = new HashSet <string>();

            var packageInfo = loadTest.PackageInfo;

            StringBuilder snippet = new StringBuilder();

            foreach (var test in loadTest.UnitTests)
            {
                if (uniqueAssemblies.Add(test.AssemblyName))
                {
                    string refSnippet = $@"
    <Reference Include='{test.AssemblyName}'>
      <HintPath>$(MSBuildThisFileDirectory)\refs\{test.AssemblyName}</HintPath>
      <Aliases>{UnitTestInfo.GetAssemblyAlias(test.AssemblyName)}</Aliases>
    </Reference>";

                    snippet.Append(refSnippet);
                }

                foreach (var assmref in test.ReferenceInfo.ReferencedAssemblies)
                {
                    if (uniqueAssemblies.Add(assmref.Name) && packageInfo.dependencies[Path.GetFileNameWithoutExtension(assmref.Name)] == null)
                    {
                        string refSnippet = $@"
    <Reference Include='{assmref.Name}'>
      <HintPath>$(MSBuildThisFileDirectory)\refs\{assmref.Name}</HintPath>
      <Aliases>{UnitTestInfo.GetAssemblyAlias(assmref.Name)}</Aliases>
    </Reference>";

                        snippet.Append(refSnippet);
                    }
                }
            }

            string stressexecutionsnippet = $@"
    <Reference Include='stress.execution.dll'>
      <HintPath>{typeof(stress.execution.UnitTest).Assembly.Location}</HintPath>
    </Reference>";

            snippet.Append(stressexecutionsnippet);

            return(snippet.ToString());
        }
        private string ReplaceMangledAssembliesWithAliases(string str)
        {
            var remaining = str;

            string[] split;

            HashSet <string> mangledAssemblies = new HashSet <string>();

            while ((split = remaining.Split(new string[] { "```[", "]~~~" }, 3, StringSplitOptions.None)).Length == 3)
            {
                mangledAssemblies.Add(split[1]);

                remaining = split[2];
            }

            foreach (var assm in mangledAssemblies)
            {
                str = str.Replace("```[" + assm + "]~~~", UnitTestInfo.GetAssemblyAlias(assm));
            }

            return(str);
        }
Esempio n. 3
0
        private static string GenerateReferencesSnippet(LoadTestInfo loadTest)
        {
            HashSet <string> uniqueAssemblies = new HashSet <string>();

            StringBuilder snippet = new StringBuilder();

            foreach (var test in loadTest.UnitTests)
            {
                if (uniqueAssemblies.Add(test.AssemblyPath))
                {
                    string refSnippet = $@"
    <Reference Include='{test.AssemblyName}'>
      <HintPath>$(MSBuildThisFileDirectory)\refs\{test.AssemblyName}</HintPath>
      <Aliases>{UnitTestInfo.GetAssemblyAlias(test.AssemblyPath)}</Aliases>
      <NotForTests>true</NotForTests>
    </Reference>";

                    snippet.Append(refSnippet);
                }

                foreach (var assmref in test.ReferenceInfo.ReferencedAssemblies)
                {
                    if (uniqueAssemblies.Add(assmref.Path))
                    {
                        string refSnippet = $@"
    <Reference Include='{assmref.Name}'>
      <HintPath>$(MSBuildThisFileDirectory)\refs\{assmref.Name}</HintPath>
      <Aliases>{UnitTestInfo.GetAssemblyAlias(assmref.Path)}</Aliases>
      <NotForTests>true</NotForTests>
    </Reference>";

                        snippet.Append(refSnippet);
                    }
                }
            }

            return(snippet.ToString());
        }