Exemplo n.º 1
0
        private void TestSvcutil(string options, bool expectSuccess = true)
        {
            Assert.False(string.IsNullOrWhiteSpace(this_TestCaseName), $"{nameof(this_TestCaseName)} not initialized!");
            Assert.False(options == null, $"{nameof(options)} not initialized!");

            // this sets the current directory to the project's.
            ProcessRunner.ProcessResult processResult = this_TestCaseProject.RunSvcutil(options, expectSuccess, this_TestCaseLogger);

            _ = $"{processResult.OutputText}{Environment.NewLine}{((TestLogger)this_TestCaseLogger)}";

            ValidateTest(options, this_TestCaseProject.DirectoryPath, processResult.ExitCode, processResult.OutputText, expectSuccess);
        }
Exemplo n.º 2
0
        private string SetupProjectDependencies()
        {
            var libProjPath  = Path.Combine(this_TestGroupOutputDir, "TypesLib", "TypesLib.csproj");
            var binProjPath  = Path.Combine(this_TestGroupOutputDir, "BinLib", "BinLib.csproj");
            var assemblyPath = Path.Combine(Path.GetDirectoryName(binProjPath), "bin", "Debug", "netstandard1.3", "BinLib.dll");

            if (!File.Exists(assemblyPath))
            {
                var typeReuseProjectsPath = Path.Combine(g_TestCasesDir, "TypeReuse");

                FileUtil.CopyDirectory(typeReuseProjectsPath, this_TestGroupOutputDir);
                CreateGlobalJson(this_TestGroupOutputDir, this_TestCaseProject.SdkVersion);

                MSBuildProj binProj = MSBuildProj.FromPathAsync(binProjPath, null, CancellationToken.None).Result;
                ProcessRunner.ProcessResult result = binProj.BuildAsync(true, null, CancellationToken.None).Result;
                Assert.True(result.ExitCode == 0, result.OutputText);
            }

            Assert.True(File.Exists(binProjPath), $"{nameof(binProjPath)} not initialized!");
            Assert.True(File.Exists(libProjPath), $"{nameof(libProjPath)} not initialized!");

            this_TestCaseProject.AddDependency(ProjectDependency.FromAssembly(assemblyPath));
            this_TestCaseProject.AddDependency(ProjectDependency.FromProject(libProjPath));
            this_TestCaseProject.SaveAsync(this_TestCaseLogger, CancellationToken.None).Wait();

            ProcessRunner.ProcessResult ret = this_TestCaseProject.BuildAsync(true, this_TestCaseLogger, CancellationToken.None).Result;
            Assert.True(ret.ExitCode == 0, ret.OutputText);

            // keep the boostrapper projects in the outputs to be evaluated against baselines.
            this_TestCaseBootstrapDir = this_TestCaseOutputDir;
            Directory.CreateDirectory(Path.Combine(this_TestCaseBootstrapDir, "SvcutilBootstrapper"));

            var uri = PathHelper.GetRelativePath(Path.Combine(this_TestGroupOutputDir, "TypeReuseSvc.wsdl"), new DirectoryInfo(this_TestCaseOutputDir));

            return(uri);
        }
Exemplo n.º 3
0
        public ClassFixture()
        {
            AppInsightsTelemetryClient.IsUserOptedIn = false;

            g_RepositoryRoot = FindRepositoryRoot();

            var vsTestsRoot = GetSTestRootDir();

            g_SdkVersion = "5.0.100";
            ProcessRunner.ProcessResult procResult = ProcessRunner.TryRunAsync("dotnet", "--version", Directory.GetCurrentDirectory(), null, new CancellationToken()).ConfigureAwait(false).GetAwaiter().GetResult();

            if (procResult.ExitCode == 0)
            {
                g_SdkVersion = procResult.OutputText.Trim();
            }

            g_ServiceUrl       = "http://wcfcoresrv5.westus2.cloudapp.azure.com/wcftestservice1";
            g_TestOutputDir    = Path.Combine(g_RepositoryRoot, "artifacts", "TestOutput");
            g_TestResultsDir   = Path.Combine(g_TestOutputDir, "TestResults");
            g_TestBootstrapDir = Path.Combine(g_TestOutputDir, "TestBootstrap");
            g_TestCasesDir     = Path.Combine(vsTestsRoot, "TestCases");
            g_BaselinesDir     = Path.Combine(vsTestsRoot, "Baselines");

            Directory.CreateDirectory(g_TestOutputDir);
            Directory.CreateDirectory(g_TestResultsDir);
            Directory.CreateDirectory(g_TestBootstrapDir);
            Directory.CreateDirectory(g_TestCasesDir);
            Directory.CreateDirectory(g_BaselinesDir);

            Assert.True(Directory.Exists(g_RepositoryRoot), $"{nameof(g_RepositoryRoot)} is not initialized!");
            Assert.True(Directory.Exists(g_TestCasesDir), $"{nameof(g_TestCasesDir)} is not initialized!");
            Assert.True(Directory.Exists(g_TestResultsDir), $"{nameof(g_TestResultsDir)} is not initialized!");
            Assert.True(Directory.Exists(g_TestBootstrapDir), $"{nameof(g_TestBootstrapDir)} is not initialized!");
            Assert.True(Directory.Exists(g_TestOutputDir), $"{nameof(g_TestOutputDir)} is not initialized!");
            Assert.True(Directory.Exists(g_BaselinesDir), $"{nameof(g_BaselinesDir)} is not initialized!");

            GetSvcutilPkgVersionAndFeed();
            CreateNuGetConfig();
            CreateGlobalJson(g_TestOutputDir, g_SdkVersion);

            // force creation of common project.
            Assert.True(File.Exists(g_StarterProject.FullPath), $"{nameof(g_StarterProject)} is not initialized!");

            Assert.False(string.IsNullOrEmpty(g_SvcutilNugetFeed), $"{nameof(g_SvcutilNugetFeed)} is not initialized!");
            Assert.False(string.IsNullOrEmpty(g_SvcutilPkgVersion), $"{nameof(g_SvcutilPkgVersion)} is not initialized!");

            // copy MSBuild global props/targets file to test folder to disable build customizations for test projects.
            File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.props"), "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" />");
            File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.targets"), "<Project></Project>");

            // Uninstall the global tool and install the current version.
            var currentDirectory = Directory.GetCurrentDirectory();

            ProcessRunner.ProcessResult ret = ProcessRunner.TryRunAsync("dotnet", "tool uninstall -g dotnet-svcutil", currentDirectory, null, CancellationToken.None).Result;
            string pkgPath = Path.Combine(g_RepositoryRoot, "artifacts", "packages", buildType, "Shipping");

            if (!Directory.Exists(pkgPath) || !Directory.GetFiles(pkgPath, "dotnet-svcutil-lib*.nupkg").Any())
            {
                pkgPath = Path.Combine(g_RepositoryRoot, "artifacts", "packages", buildType, "NonShipping");
            }
            Assert.True(Directory.GetFiles(pkgPath, "dotnet-svcutil-lib.*.nupkg").Any(), $"dotnet-svcutil-lib*.nupkg not found under {pkgPath}!");
            ret = ProcessRunner.TryRunAsync("dotnet", $"tool install --global --add-source {pkgPath} dotnet-svcutil --version {g_SvcutilPkgVersion}", currentDirectory, null, CancellationToken.None).Result;
            Assert.True(ret.ExitCode == 0, "Could not install the global tool." + Environment.NewLine + ret.OutputText);
        }