當前位置: 首頁>>代碼示例>>C#>>正文


C# Tests.Options類代碼示例

本文整理匯總了C#中Tests.Options的典型用法代碼示例。如果您正苦於以下問題:C# Options類的具體用法?C# Options怎麽用?C# Options使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Options類屬於Tests命名空間,在下文中一共展示了Options類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BeginTestInternal

    private void BeginTestInternal(Options options)
    {
      try
      {
        if (this.testAsyncResults == null)
          this.testAsyncResults = new Dictionary<string, IAsyncResult>();

        if (this.waitHandles == null)
          this.waitHandles = new WaitHandle[this.maxWaitHandles];

        var index = nbWaitHandles;
        if (index == waitHandles.Length)
        {
          index = WaitHandle.WaitAny(waitHandles, waitHandles.Length * SingleTestMaxWait);
          Assert.AreNotEqual(index, WaitHandle.WaitTimeout, "Previous tests timed out");
          this.nbWaitHandles--;
        }

        Exception dummyOutException;
        string dummyOutString;
        var asyncResult = this.actionDelegate.BeginInvoke(options, out dummyOutException, out dummyOutString, null, null);
        this.testAsyncResults.Add(options.TestName, asyncResult);
        this.waitHandles[index] = asyncResult.AsyncWaitHandle;
        this.nbWaitHandles++;

        Console.WriteLine(this.BeginMessage);
      }
      catch (Exception e)
      {
        Console.WriteLine("EXCEPTION: {0}", e.Message);
        Assert.Fail("Exception caught");
      }
    }
開發者ID:nbulp,項目名稱:CodeContracts,代碼行數:33,代碼來源:AsyncTestDriver.cs

示例2: BeginTestInternal

        private void BeginTestInternal(Options options)
        {
            try
            {
                if (testAsyncResults == null)
                    testAsyncResults = new Dictionary<string, IAsyncResult>();

                if (waitHandles == null)
                    waitHandles = new WaitHandle[maxWaitHandles];

                var index = nbWaitHandles;
                if (index == waitHandles.Length)
                {
                    index = WaitHandle.WaitAny(waitHandles, waitHandles.Length * SingleTestMaxWait);
                    Assert.NotEqual(index, WaitHandle.WaitTimeout);
                    nbWaitHandles--;
                }

                Exception dummyOutException;
                string dummyOutString;
                var asyncResult = actionDelegate.BeginInvoke(options, out dummyOutException, out dummyOutString, null, null);
                testAsyncResults.Add(options.TestName, asyncResult);
                waitHandles[index] = asyncResult.AsyncWaitHandle;
                nbWaitHandles++;

                testOutputHelper.WriteLine(this.BeginMessage);
            }
            catch (Exception e)
            {
                testOutputHelper.WriteLine("EXCEPTION: {0}", e.Message);
                Assert.True(false, "Exception caught");
            }
        }
開發者ID:a780201,項目名稱:CodeContracts,代碼行數:33,代碼來源:AsyncTestDriver.cs

示例3: Rewrite

    internal static string Rewrite(string absoluteSourceDir, string absoluteBinary, Options options)
    {
      var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
      var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
      var absoluteSourcedir = Path.GetDirectoryName(absoluteBinary);
      var absoluteSource = absoluteBinary;
      var libPathsString = FormLibPaths(absoluteSourceDir, contractreferencedir, options);

      var targetName = options.TestName + ".rw" + Path.GetExtension(absoluteBinary);
      var binDir = options.UseBinDir ? Path.Combine(Path.Combine(absoluteSourcedir, "bin"), options.BuildFramework) : absoluteSourcedir;
      var targetfile = Path.Combine(binDir, targetName);
      Console.WriteLine("Rewriting '{0}' to '{1}'", absoluteBinary, targetfile);
      if (!Directory.Exists(binDir))
      {
        Directory.CreateDirectory(binDir);
      }
      var exitCode = RunProcess(binDir, options.MakeAbsolute(FoxtrotExe),
        String.Format("/out:{0} -nobox -libpaths:{3} -libpaths:{4} {5} {1} {2}", targetfile, options.FoxtrotOptions, absoluteSource, referencedir, contractreferencedir, libPathsString),
        options.TestName);
      if (exitCode != 0)
      {
        return null;
      }
      else
      {
        if (options.UseBinDir)
        {
          File.Copy(targetfile, Path.Combine(absoluteSourcedir, targetName), true);
          return Path.Combine(absoluteSourcedir, targetName);
        }
      }
      return targetfile;
    }
開發者ID:asvishnyakov,項目名稱:CodeContracts,代碼行數:33,代碼來源:TestDriver.cs

示例4: WriteRSPFile

 private static void WriteRSPFile(string dir, Options options, string args)
 {
     using (var file = new StreamWriter(Path.Combine(dir, options.TestName + ".rsp")))
     {
         file.WriteLine(args);
         file.Close();
     }
 }
開發者ID:GitTorre,項目名稱:CodeContracts,代碼行數:8,代碼來源:TestDriver.cs

示例5: ExtractorFailures

 public void ExtractorFailures()
 {
     var options = new Options(this.TestContext);
     options.ContractFramework = @".NetFramework\v4.0";
     options.BuildFramework = @".NetFramework\v4.0";
     options.FoxtrotOptions = options.FoxtrotOptions + " /nologo /verbose:4 /iw:-";
     TestDriver.BuildExtractExpectFailureOrWarnings(options);
 }
開發者ID:Yatajga,項目名稱:CodeContracts,代碼行數:8,代碼來源:ExtractorTest.cs

示例6: AsyncTestsWithDotNet45

 public void AsyncTestsWithDotNet45()
 {
     var options = new Options(this.TestContext);
     options.FoxtrotOptions = options.FoxtrotOptions + String.Format(" /throwonfailure /rw:{0}.exe,TestInfrastructure.RewriterMethods", Path.GetFileNameWithoutExtension(options.TestName));
     options.BuildFramework = @".NETFramework\v4.5";
     options.ContractFramework = @".NETFramework\v4.0";
     options.UseTestHarness = true;
     TestDriver.BuildRewriteRun(options);
 }
開發者ID:yaakov-h,項目名稱:CodeContracts,代碼行數:9,代碼來源:RewriterTests.cs

示例7: Rewrite

    internal static object Rewrite(string absoluteSourceDir, string absoluteBinary, Options options, bool alwaysCapture = false)
    {
      string referencedir;
      if (Path.IsPathRooted(options.ReferencesFramework))
      {
        referencedir = options.ReferencesFramework;
      }
      else
      {
        referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.ReferencesFramework));
      }
      var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
      var absoluteSourcedir = Path.GetDirectoryName(absoluteBinary);
      var absoluteSource = absoluteBinary;
      var libPathsString = FormLibPaths(absoluteSourceDir, contractreferencedir, options);

      var targetName = options.TestName + ".rw" + Path.GetExtension(absoluteBinary);
      var binDir = options.UseBinDir ? Path.Combine(Path.Combine(absoluteSourcedir, "bin"), options.BuildFramework) : absoluteSourcedir;
      var targetfile = Path.Combine(binDir, targetName);
      Console.WriteLine("Rewriting '{0}' to '{1}'", absoluteBinary, targetfile);
      if (!Directory.Exists(binDir))
      {
        Directory.CreateDirectory(binDir);
      }
      var optionString = String.Format("/out:{0} -nobox -libpaths:{3} {4} {1} {2}", targetfile, options.FoxtrotOptions, absoluteSource, referencedir, libPathsString);
      if (absoluteBinary.EndsWith("mscorlib.dll"))
        optionString = String.Format("/platform:{0} {1}", absoluteBinary, optionString);
      var capture = RunProcessAndCapture(binDir, options.GetFullExecutablePath(FoxtrotExe), optionString, options.TestName);
      if (capture.ExitCode != 0)
      {
        if (options.MustSucceed)
        {
          Assert.AreEqual(0, capture.ExitCode, "{0} returned an errorcode of {1}.", FoxtrotExe, capture.ExitCode);
        }
        return capture;
      }
      else
      {
        if (alwaysCapture) return capture;

        if (options.UseBinDir)
        {
          var fileName = Path.Combine(absoluteSourcedir, targetName);
          if (File.Exists(fileName))
          {
            try
            {
              File.SetAttributes(fileName, FileAttributes.Normal);
            }
            catch { }
          }
          File.Copy(targetfile, fileName, true);
          return fileName;
        }
      }
      return targetfile;
    }
開發者ID:gitter-badger,項目名稱:CodeContracts,代碼行數:57,代碼來源:TestDriver.cs

示例8: RewriteAndVerify

 internal static string RewriteAndVerify(string sourceDir, string binary, Options options)
 {
   if (!Path.IsPathRooted(sourceDir)) { sourceDir = options.MakeAbsolute(sourceDir); }
   if (!Path.IsPathRooted(binary)) { binary = options.MakeAbsolute(binary); }
   string target = Rewrite(sourceDir, binary, options);
   if (target != null)
   {
     PEVerify(target, options);
   }
   return target;
 }
開發者ID:asvishnyakov,項目名稱:CodeContracts,代碼行數:11,代碼來源:TestDriver.cs

示例9: PEVerify

    internal static int PEVerify(string assemblyFile, Options options)
    {
      var peVerifyPath = options.MakeAbsolute(Path.Combine(ToolsRoot, String.Format(@"{0}\peverify.exe", options.BuildFramework)));
      assemblyFile = options.MakeAbsolute(assemblyFile);
      var path = Path.GetDirectoryName(assemblyFile);
      var file = Path.GetFileName(assemblyFile);
      if (file == "mscorlib.dll") return -1; // peverify returns 0 for mscorlib without verifying.

      var exitCode = RunProcess(path, peVerifyPath, "/unique \"" + file + "\"", "repro");
      return exitCode;
    }
開發者ID:asvishnyakov,項目名稱:CodeContracts,代碼行數:11,代碼來源:TestDriver.cs

示例10: BeginTest

    // We have no control on the order of the tests, so we make sure
    // to always call Begin before End

    public void BeginTest(Options options)
    {
      if (this.skipTest(options))
        return;

      this.beginTestsProcessed = true;

      if (this.orderReversed)
        this.EndTestInternal(options);
      else
        this.BeginTestInternal(options);
    }
開發者ID:nbulp,項目名稱:CodeContracts,代碼行數:15,代碼來源:AsyncTestDriver.cs

示例11: BuildAndAnalyze1Slicing

 public static void BuildAndAnalyze1Slicing(ITestOutputHelper testOutputHelper, Options options)
 {
     var output = Output.ConsoleOutputFor(testOutputHelper, options.TestName);
     try
     {
         BuildAndAnalyze1Slicing(options, output.Item1);
     }
     finally
     {
         testOutputHelper.WriteLine(output.Item2.ToString());
     }
 }
開發者ID:a780201,項目名稱:CodeContracts,代碼行數:12,代碼來源:TestDriver.cs

示例12: Clousot1Slicing

 internal static void Clousot1Slicing(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
 {
     var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
     var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
     var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
     var absoluteSource = absoluteBinary;
     var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
     var args = String.Format("{0} -cci1 /regression /define:cci1only;clousot1 -framework:{4} -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString, options.Framework);
     if (options.Fast || System.Diagnostics.Debugger.IsAttached)
     {
         output.WriteLine("Calling NewCCI2Driver.Main with: {0}", args);
         // Use output to avoid Clousot from closing the Console
         Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.NewCCI2Driver.Main(args.Split(' '), output));
     }
     else
         RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2SlicingExe), args, output);
 }
開發者ID:GitTorre,項目名稱:CodeContracts,代碼行數:17,代碼來源:TestDriver.cs

示例13: BuildAndAnalyze

        public static void BuildAndAnalyze(ITestOutputHelper testOutputHelper, Options options)
        {
            var output = Output.ConsoleOutputFor(testOutputHelper, options.TestName);

            try
            {
                string absoluteSourceDir;
                var target = Build(options, "/d:CLOUSOT1", output.Item1, out absoluteSourceDir);
                if (target != null)
                {
                    Clousot(absoluteSourceDir, target, options, output.Item1);
                }
            }
            finally
            {
                testOutputHelper.WriteLine(output.Item2.ToString());
            }
        }
開發者ID:a780201,項目名稱:CodeContracts,代碼行數:18,代碼來源:TestDriver.cs

示例14: Clousot

        internal static void Clousot(string absoluteSourceDir, string absoluteBinary, Options options, string testName, int testindex, Output output)
        {
            var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
            var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
            var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
            var absoluteSource = absoluteBinary;
            var libPathsString = FormLibPaths(contractreferencedir, options);
            var args = string.Format("{0} /regression /define:cci1only;clousot1 -framework:{4} -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString, options.Framework);

            WriteRSPFile(absoluteBinaryDir, testName, args);
            
            if (options.Fast || Debugger.IsAttached)
            {
                output.WriteLine("Calling CCI1Driver.Main with: {0}", args);
                // Use output to avoid Clousot from closing the Console
                Assert.Equal(0, Microsoft.Research.CodeAnalysis.CCI1Driver.Main(args.Split(' '), output));
            }
            else
            {
                RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(ClousotExe), args, output, testName);
            }
        }
開發者ID:asvishnyakov,項目名稱:CodeContracts,代碼行數:22,代碼來源:TestDriver.cs

示例15: Test

 [Ignore()] // Old Roslyn bits are not compatible with CCRewrite. Test (and old binaries) should be removed in the next iteration.
 public void BuildRewriteRunFromSourcesRoslynV45()
 {
   var options = new Options(this.TestContext);
   options.IsLegacyRoslyn = true;
   options.FoxtrotOptions = options.FoxtrotOptions + String.Format(" /throwonfailure /rw:{0}.exe,TestInfrastructure.RewriterMethods", Path.GetFileNameWithoutExtension(options.TestName));
   options.BuildFramework = @"Roslyn\v4.5";
   options.ReferencesFramework = @".NetFramework\v4.5";
   options.ContractFramework = @".NETFramework\v4.0";
   options.UseTestHarness = true;
   TestDriver.BuildRewriteRun(options);
 }
開發者ID:nbulp,項目名稱:CodeContracts,代碼行數:12,代碼來源:RewriterTests.cs


注:本文中的Tests.Options類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。