本文整理汇总了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
}));
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}