本文整理汇总了C#中ITestOutputHelper.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# ITestOutputHelper.WriteLine方法的具体用法?C# ITestOutputHelper.WriteLine怎么用?C# ITestOutputHelper.WriteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITestOutputHelper
的用法示例。
在下文中一共展示了ITestOutputHelper.WriteLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AreEqual
internal static bool AreEqual(ITestOutputHelper testOutputHelper, Type sourceType, Type targetType, CastResult compilerResult, CastResult castResult, CastFlag expectedCastFlag)
{
if (compilerResult.IsSuccessful == true && castResult.IsSuccessful == false)
{
// Let's assert the details if the compiler generates a successful result
// but the CastTo method does not the same.
var castFlagsAreEqual = compilerResult.CastFlag == castResult.CastFlag || castResult.CastFlag == CastFlag.Implicit;
if (!castFlagsAreEqual)
{
testOutputHelper.WriteLine("CastFlags of conversion between {0} and {1} are not equal." + Environment.NewLine +
"Expected CastFlag: {2}" + Environment.NewLine +
"Resulted CastFlag: {3}" + Environment.NewLine,
sourceType.GetFormattedName(),
targetType.GetFormattedName(),
expectedCastFlag,
castResult.CastFlag);
return false;
}
var valuesAreNotEqual = compilerResult.CastFlag == castResult.CastFlag && !Equals(compilerResult.Value, castResult.Value);
if (valuesAreNotEqual)
{
testOutputHelper.WriteLine("Result of {0} conversion between {1} and {2} are not equal.",
expectedCastFlag == CastFlag.Implicit ? "implicit" : "explicit",
sourceType.GetFormattedName(),
targetType.GetFormattedName());
return false;
}
}
return true;
}
示例2: SendPacketsAsync
public SendPacketsAsync(ITestOutputHelper output)
{
_log = TestLogging.GetInstance();
byte[] buffer = new byte[s_testFileSize];
for (int i = 0; i < s_testFileSize; i++)
{
buffer[i] = (byte)(i % 255);
}
try
{
_log.WriteLine("Creating file {0} with size: {1}", TestFileName, s_testFileSize);
using (FileStream fs = new FileStream(TestFileName, FileMode.CreateNew))
{
fs.Write(buffer, 0, buffer.Length);
}
}
catch (IOException)
{
// Test payload file already exists.
_log.WriteLine("Payload file exists: {0}", TestFileName);
}
}
示例3: Generate
public static CSharpCompilation Generate(Options options, Type[] types, ITestOutputHelper output = null)
{
// generate code from types
var generator = new EntryCodeGenerator(options);
generator.GenerateCode(types);
var code = generator.CodeWriter.ToString();
if (output != null)
{
var typeInfo = string.Join(", ", types.Select(t => t.Name));
output.WriteLine($"***** Generated Code({typeInfo}) *****");
output.WriteLine(code);
output.WriteLine("");
}
// compile generated code
output?.WriteLine($"***** Compile Code *****");
var parseOption = new CSharpParseOptions(LanguageVersion.CSharp6, DocumentationMode.Parse, SourceCodeKind.Regular);
var syntaxTrees = new[] { CSharpSyntaxTree.ParseText(code, parseOption, "Generated.cs") };
var references = new[] { typeof(object), typeof(IInterfacedActor), typeof(InterfacedActor), typeof(IActorRef), typeof(IGreeter) }
.Select(t => MetadataReference.CreateFromFile(t.Assembly.Location));
var compilation = CSharpCompilation.Create(
"Generated.dll",
syntaxTrees: syntaxTrees,
references: references,
options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
using (var ms = new MemoryStream())
{
var result = compilation.Emit(ms);
if (!result.Success)
{
var failures = result.Diagnostics.Where(diagnostic =>
diagnostic.IsWarningAsError ||
diagnostic.Severity == DiagnosticSeverity.Error);
foreach (var diagnostic in failures)
{
var line = diagnostic.Location.GetLineSpan();
output?.WriteLine("{0}({1}): {2} {3}",
line.Path,
line.StartLinePosition.Line + 1,
diagnostic.Id,
diagnostic.GetMessage());
}
}
Assert.True(result.Success, "Build error!");
}
return compilation;
}
示例4: TestOutputLogger
public TestOutputLogger(ITestOutputHelper output)
{
Receive<Debug>(e => output.WriteLine(e.ToString()));
Receive<Info>(e => output.WriteLine(e.ToString()));
Receive<Warning>(e => output.WriteLine(e.ToString()));
Receive<Error>(e => output.WriteLine(e.ToString()));
Receive<InitializeLogger>(e =>
{
e.LoggingBus.Subscribe(Self, typeof (LogEvent));
});
}
示例5: Initialize
public static TestEnvironment Initialize(ITestOutputHelper output)
{
var guid = Guid.NewGuid().ToString();
var baseDirectory = Path.Combine(Path.GetTempPath(), "Knapcode.TorSharp.Tests", guid);
output.WriteLine($"Initializing test environment in base directory: {baseDirectory}");
var ports = ReservedPorts.Reserve(3);
output.WriteLine($"Reserved ports: {string.Join(", ", ports.Ports)}");
Directory.CreateDirectory(baseDirectory);
return new TestEnvironment(output, guid, baseDirectory, ports);
}
示例6: StoredProcsTests
public StoredProcsTests(ITestOutputHelper h)
{
_db = Setup.GetConnection();
h.WriteLine("xxxxxxxxxxx");
Init();
}
示例7: BuildAsync
internal static async Task<BuildResult> BuildAsync(this BuildManager buildManager, ITestOutputHelper logger, ProjectCollection projectCollection, ProjectRootElement project, string target, IDictionary<string, string> globalProperties = null, LoggerVerbosity logVerbosity = LoggerVerbosity.Detailed, ILogger[] additionalLoggers = null)
{
Requires.NotNull(buildManager, nameof(buildManager));
Requires.NotNull(projectCollection, nameof(projectCollection));
Requires.NotNull(project, nameof(project));
globalProperties = globalProperties ?? new Dictionary<string, string>();
var projectInstance = new ProjectInstance(project, globalProperties, null, projectCollection);
var brd = new BuildRequestData(projectInstance, new[] { target }, null, BuildRequestDataFlags.ProvideProjectStateAfterBuild);
var parameters = new BuildParameters(projectCollection);
var loggers = new List<ILogger>();
loggers.Add(new ConsoleLogger(logVerbosity, s => logger.WriteLine(s.TrimEnd('\r', '\n')), null, null));
loggers.AddRange(additionalLoggers);
parameters.Loggers = loggers.ToArray();
buildManager.BeginBuild(parameters);
var result = await buildManager.BuildAsync(brd);
buildManager.EndBuild();
return result;
}
示例8: WebApplicationProxyFixture
public WebApplicationProxyFixture(PrecompilerFixture fixture, ITestOutputHelper helper)
{
_Fixture = fixture;
_testHelper = helper;
_testHelper.WriteLine("Target folder: " + WebApplicationProxy.WebRootFolder);
}
示例9: MigratorFacts
public MigratorFacts(ITestOutputHelper logHelper)
{
_logHelper = logHelper;
_mockLogger = new MockLogger(logHelper);
_logHelper.WriteLine($"Using connectionString: {_instanceString}");
}
示例10: AssertSuccessfulGetResponse
private static async Task AssertSuccessfulGetResponse(HttpResponseMessage response, Uri uri, ITestOutputHelper output)
{
Assert.Equal<HttpStatusCode>(HttpStatusCode.OK, response.StatusCode);
Assert.Equal<string>("OK", response.ReasonPhrase);
string responseContent = await response.Content.ReadAsStringAsync();
Assert.True(TestHelper.JsonMessageContainsKeyValue(responseContent, "url", uri.AbsoluteUri));
output.WriteLine(responseContent);
}
示例11: Assert_AreEqual
internal static void Assert_AreEqual(ITestOutputHelper output, int expected, int actual, string msg, params object[] args)
{
// expected == -1 means don't care / don't assert check value.
string prefix = expected == -1 ? "Not-checked" : actual == expected ? "True" : "FALSE";
string fmtMsg = String.Format("--> {0}: ", prefix) + String.Format(msg, args);
output.WriteLine(fmtMsg);
if (expected != -1)
{
Assert.Equal(expected, actual);
}
}
示例12: Verify
private static void Verify(ITestOutputHelper testOutputHelper, string assemblyName, string frameworkPath)
{
var path = Path.Combine(@"..\..\..\..\Microsoft.Research\Contracts\bin\Debug", frameworkPath);
string originalPath = Path.Combine(@"..\..\..\..\Microsoft.Research\Imported\ReferenceAssemblies", frameworkPath, assemblyName + ".dll");
StringWriter stringWriter = new StringWriter();
var checker = new CRASanitizer.Checker(stringWriter);
var contractAssemblyName = assemblyName + ".Contracts.dll";
testOutputHelper.WriteLine("Checking {1} {0} for errors...", assemblyName, frameworkPath);
testOutputHelper.WriteLine(" Contract Path: {0}", Path.GetFullPath(Path.Combine(path, contractAssemblyName)));
testOutputHelper.WriteLine(" Original Path: {0}", Path.GetFullPath(originalPath));
var errors = checker.CheckSurface(Path.Combine(path, contractAssemblyName), originalPath);
testOutputHelper.WriteLine(stringWriter.ToString());
Assert.Equal(0, errors);
testOutputHelper.WriteLine("... done.");
}
示例13: GetConnectedWebSocket
public static async Task<ClientWebSocket> GetConnectedWebSocket(
Uri server,
int timeOutMilliseconds,
ITestOutputHelper output)
{
var cws = new ClientWebSocket();
var cts = new CancellationTokenSource(timeOutMilliseconds);
output.WriteLine("GetConnectedWebSocket: ConnectAsync starting.");
Task taskConnect = cws.ConnectAsync(server, cts.Token);
Assert.True(
(cws.State == WebSocketState.None) ||
(cws.State == WebSocketState.Connecting) ||
(cws.State == WebSocketState.Open),
"State immediately after ConnectAsync incorrect: " + cws.State);
await taskConnect;
output.WriteLine("GetConnectedWebSocket: ConnectAsync done.");
Assert.Equal(WebSocketState.Open, cws.State);
return cws;
}
示例14: AssertBudget
public static void AssertBudget(this PerformanceBudgetResult result, decimal minDurationMsToThrowOver = 0.01M, decimal minBudgetMsToThrowUnder = 1.0M, ITestOutputHelper outputHelper = null)
{
if (outputHelper != null) {
outputHelper.WriteLine(result.GetDetailedOutput());
}
if (result.IsOver && result.OverBudgetPercentage.Value > 25 && result.DurationMilliseconds > minDurationMsToThrowOver) {
Assert.False(true, result.GetResultMessage());
} else if (!result.IsOver && result.UnderBudgetPercentage.Value > 50 && result.BudgetMilliseconds > minBudgetMsToThrowUnder) {
Assert.False(true, result.GetResultMessage());
}
}
示例15: ServerBasedTest
protected ServerBasedTest(ITestOutputHelper output, Options options)
{
this.output = output;
this.options = options;
if (options.VerboseLogging)
Assertions.WriteOutput = message => output.WriteLine("Assertions: " + message);
ConfigureTestDependencies(testContainer);
Notifications = testContainer.Resolve<FakeNotifications>();
ProductCatalog = testContainer.Use<ProductCatalogMocking>();
ProductCatalog.SimulateDelays = options.SimulateDelays;
shoppingCartStore = testContainer.Resolve<InProcessShoppingCartStore>();
}