本文整理汇总了C#中Tests.Options类的典型用法代码示例。如果您正苦于以下问题:C# Options类的具体用法?C# Options怎么用?C# Options使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Options类属于Tests命名空间,在下文中一共展示了Options类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: EndTestInternal
private void EndTestInternal(Options options)
{
Assert.IsNotNull(this.testAsyncResults, "Begin part of the test not selected");
IAsyncResult asyncResult;
if (!this.testAsyncResults.TryGetValue(options.TestName, out asyncResult))
Assert.Fail("Begin part of the test not run");
this.testAsyncResults.Remove(options.TestName);
Assert.IsTrue(asyncResult.AsyncWaitHandle.WaitOne(SingleTestMaxWait), "Test timed out");
Exception exceptionThrown;
string dataReceived;
this.actionDelegate.EndInvoke(out exceptionThrown, out dataReceived, asyncResult);
Console.WriteLine();
Console.WriteLine("This test case was performed {0}synchronously", asyncResult.CompletedSynchronously ? "" : "a");
Console.WriteLine();
Console.Write(dataReceived);
if (exceptionThrown != null)
throw exceptionThrown;
}
开发者ID:nbulp,项目名称:CodeContracts,代码行数:24,代码来源:AsyncTestDriver.cs
示例17: ActionAsIsolated
private void ActionAsIsolated(Options options, out Exception exceptionThrown, out string dataReceived)
{
using (var stringWriter = new StringWriter())
{
var output = new Output(String.Format("Isolated::{0}", options.TestName), stringWriter);
exceptionThrown = null;
try
{
this.action(options, output);
}
catch (Exception e)
{
exceptionThrown = e;
}
dataReceived = stringWriter.ToString();
}
}
开发者ID:nbulp,项目名称:CodeContracts,代码行数:17,代码来源:AsyncTestDriver.cs
示例18: GrabTestOptions
private Options GrabTestOptions(string testGroupName)
{
var options = new Options(testGroupName, TestContext);
CurrentGroupInfo = options.Group;
return options;
}
开发者ID:nbulp,项目名称:CodeContracts,代码行数:6,代码来源:Tests.cs
示例19: SkipForCCI2
private static bool SkipForCCI2(Options options) { return options.SkipForCCI2; }
开发者ID:GitTorre,项目名称:CodeContracts,代码行数:1,代码来源:TestDriver.cs
示例20: RewriteFrameworkDlls40
public void RewriteFrameworkDlls40()
{
var options = new Options(this.TestContext);
var framework = @".NetFramework\v4.0";
options.ContractFramework = framework;
var dllpath = FrameworkBinariesToRewritePath + framework;
options.BuildFramework = options.MakeAbsolute(dllpath);
var extrareferencedir = options.MakeAbsolute(TestDriver.ReferenceDirRoot);
options.LibPaths.Add(extrareferencedir);
options.FoxtrotOptions = options.FoxtrotOptions + " /verbose:4";
options.UseContractReferenceAssemblies = false;
if (File.Exists(options.MakeAbsolute(Path.Combine(dllpath, options.SourceFile))))
{
TestDriver.RewriteBinary(options, dllpath);
}
}
开发者ID:gitter-badger,项目名称:CodeContracts,代码行数:16,代码来源:RewriterTests.cs
注:本文中的Tests.Options类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论