Merge branch 'fix/app-fixes': localized error toasts, plural counts, archive and import view-model fixes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
303 files changed
+968
-2234
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Titano.App.Shell;
|
||||
using Titano.Core.Archiving;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Protocol;
|
||||
using Titano.Protocol.Client;
|
||||
using Titano.Testing;
|
||||
|
||||
namespace Titano.App.Tests.Infrastructure;
|
||||
|
||||
/// <summary>An error toast says what happened in one localized sentence; framework and OS messages stay in the log.</summary>
|
||||
public sealed class ErrorTextTests
|
||||
{
|
||||
public ErrorTextTests() => Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
|
||||
[Test]
|
||||
public void AServerFailureIsTheServersSentenceOrThatItDoesNotAnswer()
|
||||
{
|
||||
const string Unreachable = "The server does not answer; check the address and the network.";
|
||||
Assert.Equal("The server is out of disk space.",
|
||||
ErrorText.ForServer(new TitanoApiException(HttpStatusCode.InsufficientStorage, new ApiError("insufficient_storage", "The server is out of disk space.", null))));
|
||||
Assert.Equal(Unreachable, ErrorText.ForServer(new HttpRequestException("No such host is known. (nas.local:8443)")));
|
||||
Assert.Equal(Unreachable, ErrorText.ForServer(new TaskCanceledException("A task was canceled.")));
|
||||
Assert.Equal(Unreachable, ErrorText.ForServer(new IOException("The response ended prematurely.")));
|
||||
Assert.Equal(Unreachable, ErrorText.ForServer(new AggregateException(new HttpRequestException("Connection refused"))));
|
||||
Assert.Equal("The certificate was not trusted, so nothing was sent.", ErrorText.ForServer(new UntrustedCertificateException("AB:CD")));
|
||||
// Failures that already carry a catalog sentence keep it.
|
||||
Assert.Equal(@"The archive D:\Shoots is offline.", ErrorText.ForServer(new ArchiveOfflineException(@"D:\Shoots", ArchiveAvailability.Offline)));
|
||||
Assert.Equal("Something went wrong.", ErrorText.ForServer(new InvalidOperationException("Sequence contains no elements")));
|
||||
Assert.Equal("Something went wrong.", ErrorText.ForServer(new TitanoApiException(HttpStatusCode.BadGateway, new ApiError("bad_gateway", " ", null))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AnyOtherFailureNeverShowsTheFrameworkText()
|
||||
{
|
||||
Assert.Equal("Something went wrong.", ErrorText.For(new HttpRequestException("No such host is known.")));
|
||||
Assert.Equal("Something went wrong.", ErrorText.For(new IOException(@"Access to the path 'D:\Archive' is denied.")));
|
||||
Assert.Equal(@"The archive D:\Shoots is read-only.", ErrorText.For(new ArchiveOfflineException(@"D:\Shoots", ArchiveAvailability.ReadOnly)));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user