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


C# ITestOutputHelper.?.WriteLine方法代码示例

本文整理汇总了C#中ITestOutputHelper.?.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# ITestOutputHelper.?.WriteLine方法的具体用法?C# ITestOutputHelper.?.WriteLine怎么用?C# ITestOutputHelper.?.WriteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITestOutputHelper的用法示例。


在下文中一共展示了ITestOutputHelper.?.WriteLine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: ExecuteAsync

        /// <summary>
        /// Builds a project.
        /// </summary>
        /// <param name="projectPath">The absolute path to the project.</param>
        /// <param name="targetsToBuild">The targets to build. If not specified, the project's default target will be invoked.</param>
        /// <param name="properties">The optional global properties to pass to the project. May come from the <see cref="MSBuild.Properties"/> static class.</param>
        /// <returns>A task whose result is the result of the build.</returns>
        public static async Task<BuildResultAndLogs> ExecuteAsync(string projectPath, string[] targetsToBuild = null, IDictionary<string, string> properties = null, ITestOutputHelper testLogger = null)
        {
            targetsToBuild = targetsToBuild ?? new string[0];

            var logger = new EventLogger();
            var logLines = new List<string>();
            var parameters = new BuildParameters
            {
                Loggers = new List<ILogger>
                {
                    new ConsoleLogger(LoggerVerbosity.Detailed, logLines.Add, null, null),
                    new ConsoleLogger(LoggerVerbosity.Minimal, v => testLogger?.WriteLine(v.TrimEnd()), null, null),
                    logger,
                },
            };

            BuildResult result;
            using (var buildManager = new BuildManager())
            {
                buildManager.BeginBuild(parameters);
                try
                {
                    var requestData = new BuildRequestData(projectPath, properties ?? Properties.Default, null, targetsToBuild, null);
                    var submission = buildManager.PendBuildRequest(requestData);
                    result = await submission.ExecuteAsync();
                }
                finally
                {
                    buildManager.EndBuild();
                }
            }

            return new BuildResultAndLogs(result, logger.LogEvents, logLines);
        }
开发者ID:NN---,项目名称:nuproj,代码行数:41,代码来源:MSBuild.cs

示例3: Create

        public static MockEnvironment Create(ITestOutputHelper output, Action<LumberjackClientSettings> settingsModifier = null, bool socketPending = false)
        {
            var clientSettings = new LumberjackClientSettings
            {
                Host = "localhost",
                Port = 5000,
                SendBufferSize = 1024,
                ReceiveBufferSize = 1024,
            };
            settingsModifier?.Invoke(clientSettings);

            var env = new MockEnvironment();
            env.Client = new LumberjackClient(clientSettings);
            env.Socket = new MockSocket();
            if (socketPending)
            {
                env.Socket.ConnectPending = true;
                env.Socket.SendPending = true;
                env.Socket.ReceivePending = true;
            }
            env.Server = env.Socket.Server;
            env.Server.Output = output;
            env.Client._socketFactory = () => env.Socket;
            env.Client._writeTrace = m => output?.WriteLine(m);
            return env;
        }
开发者ID:SaladLab,项目名称:LumberjackClient,代码行数:26,代码来源:MockEnvironment.cs

示例4: BuildToolsPackages

        private void BuildToolsPackages(ITestOutputHelper logger)
        {
            if (_toolsBuilt)
            {
                return;
            }

            Reporter.Output.WriteLine("Re-building tools packages...".Bold().Black());
            var start = new DateTime(2015, 1, 1);
            var seconds = (long)(DateTime.UtcNow - start).TotalSeconds;
            var suffix = "t" + seconds.ToString("x").PadLeft(9, (char)'0');
            var toolsProject = JsonConvert.DeserializeAnonymousType(
                File.ReadAllText(
                    Path.Combine(_solutionDir, "src", "Microsoft.EntityFrameworkCore.Tools", Constants.ProjectFileName)),
                new { version = "" });
            _toolVersion = toolsProject.version.Replace("*", suffix);
            _toolsBuilt = true;
            
            foreach (var pkg in PackagesToBuild)
            {
                logger?.WriteLine($"Building {pkg} version {_toolVersion}");
                Reporter.Output.WriteLine($"Re-building {pkg}".Bold().Black());

                // Workaround https://github.com/dotnet/cli/issues/3424
                AssertCommand.Pass(
                    new BuildCommand(
                        Path.Combine(_solutionDir, "src", pkg, Constants.ProjectFileName),
                        logger)
                        .Execute());

                // TODO can remove when https://github.com/NuGet/Home/issues/2469 is available
                AssertCommand.Pass(
                    new PackCommand(
                        Path.Combine(_solutionDir, "src", pkg, Constants.ProjectFileName),
                        _localArtifacts,
                        logger)
                        .Execute($"--version-suffix {suffix} --no-build"));
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:39,代码来源:DotNetEfFixture.cs

示例5: ExecuteAsync

        /// <summary>
        /// Builds a project.
        /// </summary>
        /// <param name="projectInstance">The project to build.</param>
        /// <param name="targetsToBuild">The targets to build. If not specified, the project's default target will be invoked.</param>
        /// <returns>A task whose result is the result of the build.</returns>
        public static async Task<BuildResultAndLogs> ExecuteAsync(ProjectInstance projectInstance, ITestOutputHelper testLogger = null, params string[] targetsToBuild)
        {
            targetsToBuild = (targetsToBuild == null || targetsToBuild.Length == 0) ? projectInstance.DefaultTargets.ToArray() : targetsToBuild;

            var logger = new EventLogger();
            var logLines = new List<string>();
            var parameters = new BuildParameters
            {
                Loggers = new List<ILogger>
                {
                    new ConsoleLogger(LoggerVerbosity.Detailed, logLines.Add, null, null),
                    new ConsoleLogger(LoggerVerbosity.Minimal, v => testLogger?.WriteLine(v.TrimEnd()), null, null),
                    logger,
                },
            };

            BuildResult result;
            using (var buildManager = new BuildManager())
            {
                buildManager.BeginBuild(parameters);
                try
                {
                    var brdFlags = BuildRequestDataFlags.ProvideProjectStateAfterBuild;
                    var requestData = new BuildRequestData(projectInstance, targetsToBuild, null, brdFlags);
                    var submission = buildManager.PendBuildRequest(requestData);
                    result = await submission.ExecuteAsync();
                }
                finally
                {
                    buildManager.EndBuild();
                }
            }

            return new BuildResultAndLogs(result, logger.LogEvents, logLines);
        }
开发者ID:kovalikp,项目名称:nuproj,代码行数:41,代码来源:MSBuild.cs


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