当前位置: 首页>>代码示例>>C#>>正文


C# ITestOutputHelper.WriteLine方法代码示例

本文整理汇总了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;
        }
开发者ID:thomasgalliker,项目名称:TypeConverter,代码行数:34,代码来源:CastTestRunner.cs

示例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);
            }
        }
开发者ID:Corillian,项目名称:corefx,代码行数:25,代码来源:SendPacketsAsync.cs

示例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;
        }
开发者ID:SaladLab,项目名称:Akka.Interfaced,代码行数:56,代码来源:TestUtility.cs

示例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));
     });
 }
开发者ID:skotzko,项目名称:akka.net,代码行数:11,代码来源:Loggers.cs

示例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);
        }
开发者ID:rflechner,项目名称:TorSharp,代码行数:13,代码来源:TestEnvironment.cs

示例6: StoredProcsTests

  public StoredProcsTests(ITestOutputHelper h)
  {
 
      _db = Setup.GetConnection();
      h.WriteLine("xxxxxxxxxxx");
      Init();
  }
开发者ID:sapiens,项目名称:SqlFu,代码行数:7,代码来源:StoredProcsTests.cs

示例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;
    }
开发者ID:azeno,项目名称:Nerdbank.GitVersioning,代码行数:25,代码来源:MSBuildExtensions.cs

示例8: WebApplicationProxyFixture

        public WebApplicationProxyFixture(PrecompilerFixture fixture, ITestOutputHelper helper)
        {
            _Fixture = fixture;

              _testHelper = helper;
              _testHelper.WriteLine("Target folder: " + WebApplicationProxy.WebRootFolder);
        }
开发者ID:KathleenDollard,项目名称:WebFormsTest,代码行数:7,代码来源:WebApplicationProxyFixture.cs

示例9: MigratorFacts

        public MigratorFacts(ITestOutputHelper logHelper)
        {
            _logHelper = logHelper;
            _mockLogger = new MockLogger(logHelper);

            _logHelper.WriteLine($"Using connectionString: {_instanceString}");
        }
开发者ID:Silvenga,项目名称:Cake.EntityFramework,代码行数:7,代码来源:MigratorFacts.cs

示例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);
 }
开发者ID:ReedKimble,项目名称:corefx,代码行数:8,代码来源:HttpClientHandlerTest.cs

示例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);
     }
 }
开发者ID:Rejendo,项目名称:orleans,代码行数:11,代码来源:StreamTestUtils.cs

示例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.");
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:20,代码来源:CRASanitizeTest.cs

示例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;
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:21,代码来源:WebSocketHelper.cs

示例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());
            }
        }
开发者ID:visualeyes,项目名称:budgerigar,代码行数:12,代码来源:AssertExtensions.cs

示例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>();
        }
开发者ID:jochenz,项目名称:unit-testing-restful-services,代码行数:14,代码来源:ServerBasedTest.cs


注:本文中的ITestOutputHelper.WriteLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。