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


C# SystemDiagnostics类代码示例

本文整理汇总了C#中SystemDiagnostics的典型用法代码示例。如果您正苦于以下问题:C# SystemDiagnostics类的具体用法?C# SystemDiagnostics怎么用?C# SystemDiagnostics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SystemDiagnostics类属于命名空间,在下文中一共展示了SystemDiagnostics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddEnvironmentForTest

        public void AddEnvironmentForTest()
        {
            var notifications = new List<TestCompletedNotification>();
            var builder = new Mock<IReportBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var storage = new ActiveTestStorage(diagnostics);

            var testId = 10;
            storage.Add(testId, builder.Object, notifications);

            var environment = new Mock<IActiveEnvironment>();
            {
                environment.Setup(e => e.Environment)
                    .Returns("a");
            }

            storage.AddEnvironmentForTest(testId, environment.Object);

            Assert.That(
                storage.EnvironmentsForTest(testId),
                Is.EquivalentTo(
                    new List<IActiveEnvironment>
                        {
                            environment.Object
                        }));
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:26,代码来源:ActiveTestStorageTest.cs

示例2: FileWatcherBasedPackageUploader

        /// <summary>
        /// Initializes a new instance of the <see cref="FileWatcherBasedPackageUploader"/> class.
        /// </summary>
        /// <param name="packageQueue">The object that queues packages that need to be processed.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="diagnostics">The object providing the diagnostics methods for the application.</param>
        internal FileWatcherBasedPackageUploader(
            IQueueSymbolPackages packageQueue,
            IConfiguration configuration,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => packageQueue);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => diagnostics);

                Lokad.Enforce.With<ArgumentException>(
                    configuration.HasValueFor(CoreConfigurationKeys.s_UploadPath),
                    Resources.Exceptions_Messages_MissingConfigurationValue_WithKey,
                    CoreConfigurationKeys.s_UploadPath);
            }

            m_Queue = packageQueue;
            m_Diagnostics = diagnostics;

            var uploadPath = configuration.Value<string>(CoreConfigurationKeys.s_UploadPath);
            m_Watcher = new FileSystemWatcher
            {
                Path = uploadPath,
                Filter = "*.symbols.nupkg",
                EnableRaisingEvents = false,
                NotifyFilter = NotifyFilters.FileName | NotifyFilters.CreationTime,
            };

            m_Watcher.Created += HandleFileCreated;
        }
开发者ID:pvandervelde,项目名称:nAnicitus,代码行数:36,代码来源:FileWatcherBasedPackageUploader.cs

示例3: CreateWithEmptyInstallDirectory

        public void CreateWithEmptyInstallDirectory()
        {
            RetrieveFileDataForTestStep testFileLocation = index => @"c:\a\b";
            UploadReportFilesForTestStep uploader = (index, upload) => { };

            var fileSystem = new System.IO.Abstractions.TestingHelpers.MockFileSystem(
                new Dictionary<string, System.IO.Abstractions.TestingHelpers.MockFileData>
                    {
                        { @"c:\d\e\f.ps1", new System.IO.Abstractions.TestingHelpers.MockFileData("throw 'FAIL'") }
                    });

            var sectionBuilder = new Mock<ITestSectionBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var installer = new XCopyDeployTestStepProcessor(
               testFileLocation,
               uploader,
               diagnostics,
               fileSystem,
               sectionBuilder.Object);

            var data = new XCopyTestStep
                {
                    pk_TestStepId = 1,
                    Order = 2,
                    Destination = @"c:\d\e",
                };

            var result = installer.Process(data, new List<InputParameter>());
            Assert.AreEqual(TestExecutionState.Passed, result);
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:30,代码来源:XCopyDeployTestStepProcessorTest.cs

示例4: InstallWithPowershellFile

        public void InstallWithPowershellFile()
        {
            RetrieveFileDataForTestStep testFileLocation = index => @"c:\a\b";
            UploadReportFilesForTestStep uploader = (index, upload) => { };

            var fileSystem = new MockFileSystem(
                new Dictionary<string, MockFileData>
                    {
                        { @"c:\a\b\c.ps1", new MockFileData("Out-Host -InputObject 'hello word'") }
                    });

            var sectionBuilder = new Mock<ITestSectionBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var installer = new ScriptExecuteTestStepProcessor(
               testFileLocation,
               uploader,
               diagnostics,
               fileSystem,
               sectionBuilder.Object);

            var data = new ScriptExecuteTestStep
            {
                pk_TestStepId = 1,
                Order = 2,
                ScriptLanguage = ScriptLanguage.Powershell,
            };

            var result = installer.Process(data, new List<InputParameter>());
            Assert.AreEqual(TestExecutionState.Passed, result);
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:30,代码来源:ScriptExecuteTestStepProcessorTest.cs

示例5: RegisterNotification

        public void RegisterNotification()
        {
            NotificationName notification = null;
            Action<INotificationArguments> action = null;

            var service = new Mock<IUserInterfaceService>();
            {
                service.Setup(s => s.RegisterNotification(It.IsAny<NotificationName>(), It.IsAny<Action<INotificationArguments>>()))
                    .Callback<NotificationName, Action<INotificationArguments>>(
                        (n, o) =>
                            {
                                notification = n;
                                action = o;
                            });
            }

            var notificationNames = new Mock<INotificationNameConstants>();
            {
                notificationNames.Setup(n => n.SystemShuttingDown)
                    .Returns(new NotificationName("a"));
            }

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var facade = new ApplicationFacade(service.Object, notificationNames.Object, systemDiagnostics);

            var name = new NotificationName("bla");
            Action<INotificationArguments> callback = o => { };
            facade.RegisterNotification(name, callback);

            Assert.AreSame(name, notification);
            Assert.AreSame(callback, action);
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:32,代码来源:ApplicationFacadeTest.cs

示例6: Add

        public void Add()
        {
            var notifications = new List<TestCompletedNotification>
                {
                    new FileBasedTestCompletedNotification("b"),
                };

            var report = new Mock<IReport>();
            var builder = new Mock<IReportBuilder>();
            {
                builder.Setup(b => b.Build())
                    .Returns(report.Object);
            }

            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var storage = new ActiveTestStorage(diagnostics);

            var testId = 10;
            storage.Add(testId, builder.Object, notifications);

            Assert.That(
                storage.NotificationsFor(testId),
                Is.EquivalentTo(notifications));
            Assert.AreSame(report.Object, storage.ReportFor(testId));
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:25,代码来源:ActiveTestStorageTest.cs

示例7: CreateStorageDirectory

        private static void CreateStorageDirectory(IFileSystem fileSystem, string storageDirectory, SystemDiagnostics diagnostics)
        {
            if (fileSystem.Directory.Exists(storageDirectory))
            {
                diagnostics.Log(
                    LevelToLog.Info,
                    ExecutorConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.Log_Messages_RemovingStorageDirectory_WithDirectory,
                        storageDirectory));

                fileSystem.Directory.Delete(storageDirectory, true);
            }

            if (!fileSystem.Directory.Exists(storageDirectory))
            {
                diagnostics.Log(
                    LevelToLog.Debug,
                    ExecutorConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.Log_Messages_CreatingStorageDirectory_WithDirectory,
                        storageDirectory));

                fileSystem.Directory.CreateDirectory(storageDirectory);
            }
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:28,代码来源:Program.cs

示例8: NucleiBasedTraceWriter

        /// <summary>
        /// Initializes a new instance of the <see cref="NucleiBasedTraceWriter"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public NucleiBasedTraceWriter(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:15,代码来源:NucleiBasedTraceWriter.cs

示例9: PrismToDiagnosticsLogger

        /// <summary>
        /// Initializes a new instance of the <see cref="PrismToDiagnosticsLogger"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public PrismToDiagnosticsLogger(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:15,代码来源:PrismToDiagnosticsLogger.cs

示例10: KernelService

        /// <summary>
        /// Initializes a new instance of the <see cref="KernelService"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        protected KernelService(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:15,代码来源:KernelService.cs

示例11: LogReporter

        /// <summary>
        /// Initializes a new instance of the <see cref="LogReporter"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public LogReporter(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:15,代码来源:LogReporter.cs

示例12: ActiveTestStorage

        /// <summary>
        /// Initializes a new instance of the <see cref="ActiveTestStorage"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public ActiveTestStorage(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:15,代码来源:ActiveTestStorage.cs

示例13: LogForwardingPipe

        /// <summary>
        /// Initializes a new instance of the <see cref="LogForwardingPipe"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public LogForwardingPipe(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:15,代码来源:LogForwardingPipe.cs

示例14: WhiteLogRedirector

        /// <summary>
        /// Initializes a new instance of the <see cref="WhiteLogRedirector"/> class.
        /// </summary>
        /// <param name="name">The name for the logger.</param>
        /// <param name="level">The default log level.</param>
        /// <param name="diagnostics">The object that provides the logging for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public WhiteLogRedirector(string name, LoggerLevel level, SystemDiagnostics diagnostics)
            : base(name, level)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:18,代码来源:WhiteLogRedirector.cs

示例15: FeedbackIconView

        /// <summary>
        /// Initializes a new instance of the <see cref="FeedbackIconView"/> class.
        /// </summary>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public FeedbackIconView(SystemDiagnostics systemDiagnostics)
            : this()
        {
            {
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Diagnostics = systemDiagnostics;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:16,代码来源:FeedbackIconView.xaml.cs


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