Public Access
Desktop: keep a vault-visibility failure from closing the app, and leave a crash log when anything else does
This commit is contained in:
1 parent
170caa1391
commit
37e9d74938
6 files changed
+154
-5
No files matched your search
@@ -0,0 +1,41 @@
|
||||
using DodoSSH.Client.App.Platform;
|
||||
using DodoSSH.Client.Session;
|
||||
|
||||
namespace DodoSSH.Client.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// That the application leaves a record of why it died.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// An exception nothing caught used to close the window and leave nothing at all behind. Installing the hooks
|
||||
/// here also installs them in the test process, which is harmless: they only write to this test's own
|
||||
/// directory, and only when something reaches the top.
|
||||
/// </remarks>
|
||||
public sealed class CrashLogTests : IDisposable
|
||||
{
|
||||
private readonly string directory =
|
||||
Path.Combine(Path.GetTempPath(), $"dodossh-crash-{Guid.CreateVersion7():N}");
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Directory.Exists(directory))
|
||||
{
|
||||
Directory.Delete(directory, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnExceptionThatReachesTheTop_IsWrittenToTheProfile()
|
||||
{
|
||||
var paths = new ClientPaths(directory);
|
||||
|
||||
CrashLog.Install(paths);
|
||||
CrashLog.Write("UI thread", new InvalidOperationException("the thing nobody caught"));
|
||||
|
||||
var written = File.ReadAllText(paths.CrashLogFile);
|
||||
|
||||
written.ShouldContain("UI thread");
|
||||
written.ShouldContain("the thing nobody caught");
|
||||
written.ShouldContain(nameof(InvalidOperationException));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user