-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUiTestExecutionLogTests.cs
More file actions
56 lines (53 loc) · 3.06 KB
/
Copy pathUiTestExecutionLogTests.cs
File metadata and controls
56 lines (53 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using FileManager.UiTests.Infrastructure;
using NUnit.Framework;
namespace FileManager.UiTests;
[TestFixture]
internal sealed class UiTestExecutionLogTests
{
[Test]
public void Execution_log_retains_ordered_human_readable_records()
{
var outputRoot = Path.Combine(TestContext.CurrentContext.WorkDirectory,
"execution-log-contract-" + Guid.NewGuid().ToString("N"));
try
{
string transcriptPath;
var testDataRoot = Path.Combine(outputRoot, "filemanager-testdata");
var dialogTranscript = Path.Combine(testDataRoot, "ui-test-dialogs.log");
var crashDirectory = Path.Combine(testDataRoot, "appdata", "Open Salamander");
Directory.CreateDirectory(crashDirectory);
// Exercise the real writer without launching native UI so its format remains a fast source-independent contract.
using (var log = UiTestExecutionLog.Start(outputRoot, "format/test", "Fixture.format/test", "contract"))
{
transcriptPath = log.Path;
log.Record("ACTION", "first");
log.Record("WINDOW", "second\ncontrol text");
log.WatchProductDialogTranscript(dialogTranscript);
File.WriteAllText(dialogTranscript, "12:00:00.000|SHOW|caption=Example|text=Question\r\n");
// Representative text and binary artifacts verify useful crash evidence is retained before sandbox cleanup.
File.WriteAllText(Path.Combine(crashDirectory, "sample.TXT"), "example crash report");
File.WriteAllBytes(Path.Combine(crashDirectory, "sample.DMP"), [1, 2, 3]);
log.CaptureProductDiagnostics(testDataRoot);
}
var transcript = File.ReadAllText(transcriptPath);
Assert.Multiple(() =>
{
Assert.That(transcript, Does.Contain("Open Salamander UI test execution transcript"));
Assert.That(transcript, Does.Contain("000001").And.Contain("ACTION | first"));
Assert.That(transcript, Does.Contain("000002").And.Contain("WINDOW | second"));
Assert.That(transcript.IndexOf("ACTION | first", StringComparison.Ordinal),
Is.LessThan(transcript.IndexOf("WINDOW | second", StringComparison.Ordinal)));
Assert.That(transcript, Does.Contain("PRODUCT-DIALOGS | 12:00:00.000|SHOW|caption=Example|text=Question"));
Assert.That(transcript, Does.Contain("CRASH-REPORT-TEXT").And.Contain("example crash report"));
Assert.That(transcript, Does.Contain("transcript.complete"));
Assert.That(File.Exists(Path.Combine(Path.ChangeExtension(transcriptPath, null) + ".artifacts", "sample.DMP")), Is.True);
});
}
finally
{
// This GUID directory is owned exclusively by the contract test and must not accumulate across local runs.
if (Directory.Exists(outputRoot))
Directory.Delete(outputRoot, recursive: true);
}
}
}