Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f2aa510
disavled fixed
DirkDoes Jun 14, 2025
f17cf71
update from spreadsheet
DirkDoes Jun 14, 2025
cf8db45
some things
DirkDoes Jun 14, 2025
f565b1c
Merge branch 'dev' into task/translations--again
DirkDoes Jun 14, 2025
36e90d1
more changes
DirkDoes Jun 14, 2025
8e0b5f6
button
DirkDoes Jun 14, 2025
f233eb1
rename to state
DirkDoes Jun 14, 2025
b56f671
move bits and bobs
DirkDoes Jun 14, 2025
c915c04
move everything in the common file
DirkDoes Jun 14, 2025
f423388
rename info text to helper text
DirkDoes Jun 14, 2025
a4b681d
moved action to common
DirkDoes Jun 14, 2025
39e47cd
moved placeholders
DirkDoes Jun 14, 2025
aea2fe4
remove these online resx that somehow came back
DirkDoes Jun 14, 2025
71d2d41
rename empty text to empty content
DirkDoes Jun 14, 2025
bfd85a5
a few new keys
DirkDoes Jun 14, 2025
d67990a
messages things
DirkDoes Jun 15, 2025
7d3ee8b
did a bucn of question renaming
DirkDoes Jun 15, 2025
b77554c
checkpoint
DirkDoes Jun 15, 2025
985d64e
removed all popup instances
DirkDoes Jun 15, 2025
464ea53
add params
DirkDoes Jun 15, 2025
2c9cd35
rename to msg translation
DirkDoes Jun 15, 2025
4b720ce
remove string implicite operator
DirkDoes Jun 15, 2025
d44deb6
add message translations to this thing
DirkDoes Jun 15, 2025
39f80e1
message box showable
DirkDoes Jun 15, 2025
f413d0c
a lot more translations for the Mii
DirkDoes Jun 15, 2025
197dd52
fix failed test
DirkDoes Jun 15, 2025
67de175
things
DirkDoes Jun 15, 2025
691b23c
Mods are translated yay
DirkDoes Jun 17, 2025
7e4a13b
more popup titles
DirkDoes Jun 17, 2025
7b07200
import again
DirkDoes Jun 18, 2025
facde0b
Merge branch 'dev' into task/translations--again
DirkDoes Jun 18, 2025
869442b
fix wrong thingies
DirkDoes Jun 18, 2025
d0ba947
move translations to different page and alter subtext
DirkDoes Jun 20, 2025
5db6e3f
all the Mii attributes
DirkDoes Jun 20, 2025
9c22977
thjngs
DirkDoes Jun 20, 2025
639bdf2
small changes
DirkDoes Jun 21, 2025
50e0787
import all the changes
DirkDoes Jun 21, 2025
949d901
move around placeholders
DirkDoes Jun 21, 2025
6677d4e
last changes
DirkDoes Jun 21, 2025
4d58b2d
add tnew values
DirkDoes Jun 22, 2025
92c17aa
operation result much easier
DirkDoes Jun 23, 2025
dd5e75b
italian updatre
DirkDoes Jun 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions WheelWizard.Test/Features/GameBananaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public async Task GetModSearchResults_WithApiError_ReturnsFailure()

_apiCaller
.CallApiAsync(Arg.Any<Expression<Func<IGameBananaApi, Task<GameBananaSearchResults>>>>())
.Returns(Fail<GameBananaSearchResults>(expectedError));
.Returns(Fail(expectedError));

// Act
var result = await _service.GetModSearchResults(searchTerm, page);
Expand Down Expand Up @@ -128,9 +128,7 @@ public async Task GetModDetails_WithApiError_ReturnsFailure()
var modId = 123;
var expectedError = "API Error";

_apiCaller
.CallApiAsync(Arg.Any<Expression<Func<IGameBananaApi, Task<GameBananaModDetails>>>>())
.Returns(Fail<GameBananaModDetails>(expectedError));
_apiCaller.CallApiAsync(Arg.Any<Expression<Func<IGameBananaApi, Task<GameBananaModDetails>>>>()).Returns(Fail(expectedError));

// Act
var result = await _service.GetModDetails(modId);
Expand Down
11 changes: 4 additions & 7 deletions WheelWizard.Test/Features/MiiDbServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using NSubstitute.ExceptionExtensions;
using Testably.Abstractions;
using WheelWizard.Shared;
using WheelWizard.WiiManagement;
using WheelWizard.WiiManagement.MiiManagement;
using WheelWizard.WiiManagement.MiiManagement.Domain.Mii;

Expand Down Expand Up @@ -58,9 +57,7 @@ private OperationResult<Mii> CreateValidMii(uint id = 1, string name = "TestMii"
creatorName,
};
if (EveryResult.Any(r => r.IsFailure))
{
return Fail<Mii>(EveryResult.First(r => r.IsFailure).Error);
}
return EveryResult.First(r => r.IsFailure).Error!;

return Ok(
new Mii
Expand Down Expand Up @@ -348,7 +345,7 @@ public void Update_ShouldReturnFailure_WhenRepositoryUpdateFails()

// Assert
Assert.True(result.IsFailure);
Assert.Equal(repoError.Error, result.Error); // Propagate the exact error
Assert.Equal(repoError, result.Error); // Propagate the exact error
_repositoryService.Received(1).UpdateBlockByClientId(miiToUpdate.MiiId, Arg.Is<byte[]>(b => b.SequenceEqual(expectedBytes)));
}

Expand Down Expand Up @@ -426,7 +423,7 @@ public void UpdateName_ShouldReturnFailure_WhenGetByClientIdFails_NotFound()

// Assert
Assert.True(result.IsFailure);
Assert.Equal("Mii block not found or invalid.", result.Error.Message); // Error from GetByClientId
Assert.Equal("Mii block not found", result.Error.Message); // Error from GetByClientId
_repositoryService.Received(1).GetRawBlockByAvatarId(targetId);
_repositoryService.DidNotReceive().UpdateBlockByClientId(Arg.Any<uint>(), Arg.Any<byte[]>());
}
Expand Down Expand Up @@ -494,7 +491,7 @@ public void UpdateName_ShouldReturnFailure_WhenRepositoryUpdateFails()

// Assert
Assert.True(result.IsFailure);
Assert.Equal(repoError.Error, result.Error); // Error from the repository update propagated
Assert.Equal(repoError, result.Error); // Error from the repository update propagated
_repositoryService.Received(1).GetRawBlockByAvatarId(targetId);
_repositoryService.Received(1).UpdateBlockByClientId(targetId, Arg.Any<byte[]>());
}
Expand Down
6 changes: 2 additions & 4 deletions WheelWizard.Test/Features/WhWzDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task GetStatusAsync_ReturnsFailure_WhenApiCallFails()
// Arrange
var expectedError = new OperationError { Message = "API call failed" };

_apiCaller.CallApiAsync(Arg.Any<Expression<Func<IWhWzDataApi, Task<WhWzStatus>>>>()).Returns(Fail<WhWzStatus>(expectedError));
_apiCaller.CallApiAsync(Arg.Any<Expression<Func<IWhWzDataApi, Task<WhWzStatus>>>>()).Returns(expectedError);

// Act
var result = await _service.GetStatusAsync();
Expand Down Expand Up @@ -77,9 +77,7 @@ public async Task LoadBadgesAsync_ReturnsFailure_WhenApiCallFails()
// Arrange
var expectedError = new OperationError { Message = "API call failed" };

_apiCaller
.CallApiAsync(Arg.Any<Expression<Func<IWhWzDataApi, Task<Dictionary<string, BadgeVariant[]>>>>>())
.Returns(Fail<Dictionary<string, BadgeVariant[]>>(expectedError));
_apiCaller.CallApiAsync(Arg.Any<Expression<Func<IWhWzDataApi, Task<Dictionary<string, BadgeVariant[]>>>>>()).Returns(expectedError);

// Act
var result = await _service.LoadBadgesAsync();
Expand Down
1 change: 1 addition & 0 deletions WheelWizard.Test/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
global using NSubstitute;
global using static WheelWizard.Shared.OperationError;
global using static WheelWizard.Shared.OperationResult;
80 changes: 45 additions & 35 deletions WheelWizard.Test/Shared/OperationResult/OperationResultTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using WheelWizard.Shared;
using WheelWizard.Helpers;
using WheelWizard.Shared;
using WheelWizard.Shared.MessageTranslations;

namespace WheelWizard.Test.Shared.OperationResultTests;

Expand Down Expand Up @@ -52,12 +54,29 @@ public void CreateFailureResult_ShouldHaveCorrectState()
var error = new OperationError { Message = "Error message" };

// Act
var operationResult = Fail(error);
OperationResult operationResult = error;

// Assert
Assert.Equal(error, operationResult.Error);
Assert.True(operationResult.IsFailure);
Assert.False(operationResult.IsSuccess);
Assert.Null(operationResult.Error!.MessageTranslation);
}

[Fact(DisplayName = "Create failure result, should have correct state with translation")]
public void CreateFailureResult_ShouldHaveCorrectStateWithTranslation()
{
const string errorMessage = "Error message";
const MessageTranslation errorTranslation = MessageTranslation.Error_StanderdError;

// Act
OperationResult operationResult = Fail(errorMessage, errorTranslation);

// Assert
Assert.True(operationResult.IsFailure);
Assert.False(operationResult.IsSuccess);
Assert.Equal(errorMessage, operationResult.Error.Message);
Assert.Equal(errorTranslation, operationResult.Error.MessageTranslation);
}

[Fact(DisplayName = "Implicit result from error, should have correct state")]
Expand Down Expand Up @@ -129,7 +148,7 @@ public void CreateFailureGenericResult_ShouldHaveCorrectState()
var error = new OperationError { Message = "Error message" };

// Act
var operationResult = Fail(error);
OperationResult operationResult = error;

// Assert
Assert.Equal(error, operationResult.Error);
Expand All @@ -150,6 +169,7 @@ public void ImplicitGenericResultFromError_ShouldHaveCorrectState()
Assert.Equal(error, operationResult.Error);
Assert.True(operationResult.IsFailure);
Assert.False(operationResult.IsSuccess);
Assert.Null(operationResult.Error!.MessageTranslation);
}

[Fact(DisplayName = "Implicit generic result from value, should have correct state")]
Expand All @@ -168,22 +188,6 @@ public void ImplicitGenericResultFromValue_ShouldHaveCorrectState()
Assert.Equal(value, operationResult.Value);
}

[Fact(DisplayName = "Implicit result from string, should have failed state")]
public void ImplicitResultFromString_ShouldHaveFailedState()
{
// Arrange
const string errorMessage = "Error message";

// Act
OperationResult operationResult = errorMessage;

// Assert
Assert.NotNull(operationResult.Error);
Assert.True(operationResult.IsFailure);
Assert.False(operationResult.IsSuccess);
Assert.Equal(errorMessage, operationResult.Error?.Message);
}

[Fact(DisplayName = "Implicit result from exception, should have failed state")]
public void ImplicitResultFromException_ShouldHaveFailedState()
{
Expand All @@ -198,22 +202,7 @@ public void ImplicitResultFromException_ShouldHaveFailedState()
Assert.True(operationResult.IsFailure);
Assert.False(operationResult.IsSuccess);
Assert.Equal(exception.Message, operationResult.Error?.Message);
}

[Fact(DisplayName = "Implicit generic result from string, should have correct failed state")]
public void ImplicitGenericResultFromString_ShouldHaveCorrectFailedState()
{
// Arrange
const string errorMessage = "Error message";

// Act
OperationResult<object> operationResult = errorMessage;

// Assert
Assert.NotNull(operationResult.Error);
Assert.True(operationResult.IsFailure);
Assert.False(operationResult.IsSuccess);
Assert.Equal(errorMessage, operationResult.Error?.Message);
Assert.Null(operationResult.Error!.MessageTranslation);
}

[Fact(DisplayName = "Implicit generic result from exception, should have correct failed state")]
Expand Down Expand Up @@ -278,6 +267,27 @@ public void TryCatchWithExceptionWithOverride_ShouldHaveFailedStateWithMessage()
Assert.True(result.IsFailure);
Assert.Equal(errorMessage, result.Error?.Message);
Assert.Equal(exception, result.Error?.Exception);
Assert.Null(result.Error?.MessageTranslation);
}

[Fact(DisplayName = "Try catch with exception with override, should have failed state with message and translation")]
public void TryCatchWithExceptionWithOverride_ShouldHaveFailedStateWithMessageAndTranslation()
{
// Arrange
var exception = new Exception("Error message");
const string errorMessage = "Custom error message";
const MessageTranslation errorTranslation = MessageTranslation.Error_StanderdError;

// Act
void Action() => throw exception;

var result = TryCatch(Action, errorMessage, errorTranslation);

// Assert
Assert.True(result.IsFailure);
Assert.Equal(errorMessage, result.Error?.Message);
Assert.Equal(exception, result.Error?.Exception);
Assert.Equal(errorTranslation, result.Error?.MessageTranslation);
}

[Fact(DisplayName = "Generic try catch without exception, should have correct success state")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public async Task CheckForUpdatesAsync()
return;

var latestVersion = SemVersion.Parse(latestRelease.TagName.TrimStart('v'), SemVersionStyles.Any);
var popupExtraText = Humanizer.ReplaceDynamic(Phrases.PopupText_NewVersionWhWz, latestVersion, CurrentVersion)!;
var popupExtraText = Humanizer.ReplaceDynamic(Phrases.Question_NewVersionWhWz_Extra, latestVersion, CurrentVersion)!;

var shouldUpdate = false;
await Dispatcher.UIThread.InvokeAsync(async () =>
{
shouldUpdate = await new YesNoWindow()
.SetButtonText(Common.Action_Update, Common.Action_MaybeLater)
.SetMainText(Phrases.PopupText_WhWzUpdateAvailable)
.SetMainText(Phrases.Question_NewVersionWhWz_Title)
.SetExtraText(popupExtraText)
.AwaitAnswer();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public async Task<OperationResult> ExecuteUpdateAsync(string downloadUrl)
{
var currentExecutablePath = Environment.ProcessPath;
if (currentExecutablePath is null)
return Phrases.PopupText_UnableUpdateWhWz_ReasonLocation;
return Fail(Phrases.MessageWarning_UnableUpdateWhWz_Extra_ReasonLocation);

var currentExecutableName = fileSystem.Path.GetFileName(currentExecutablePath);
var currentFolder = fileSystem.Path.GetDirectoryName(currentExecutablePath);

if (currentFolder is null)
return Phrases.PopupText_UnableUpdateWhWz_ReasonLocation;
return Fail(Phrases.MessageWarning_UnableUpdateWhWz_Extra_ReasonLocation);

// Download the new executable to a temporary file.
var newFilePath = fileSystem.Path.Combine(currentFolder, currentExecutableName + "_new");
Expand All @@ -44,8 +44,8 @@ public async Task<OperationResult> ExecuteUpdateAsync(string downloadUrl)
await DownloadHelper.DownloadToLocationAsync(
downloadUrl,
newFilePath,
Phrases.PopupText_UpdateWhWz,
Phrases.PopupText_LatestWhWzGithub,
Phrases.Progress_UpdateWhWz,
Phrases.Progress_LatestWhWzGithub,
ForceGivenFilePath: true
);

Expand All @@ -66,7 +66,7 @@ private OperationResult CreateAndRunShellScript(string currentFilePath, string n
{
var currentFolder = fileSystem.Path.GetDirectoryName(currentFilePath);
if (currentFolder is null)
return Phrases.PopupText_UnableUpdateWhWz_ReasonLocation;
return Fail(Phrases.MessageWarning_UnableUpdateWhWz_Extra_ReasonLocation);

var scriptFilePath = fileSystem.Path.Combine(currentFolder, "update.sh");
var originalFileName = fileSystem.Path.GetFileName(currentFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public async Task<OperationResult> ExecuteUpdateAsync(string downloadUrl)

// Otherwise, ask if the user wants to restart as admin.
var restartAsAdmin = await new YesNoWindow()
.SetMainText(Phrases.PopupText_UpdateAdmin)
.SetExtraText(Phrases.PopupText_UpdateAdminExplained)
.SetMainText(Phrases.Question_UpdateAdmin_Title)
.SetExtraText(Phrases.Question_UpdateAdmin_Extra)
.AwaitAnswer();

if (!restartAsAdmin)
Expand All @@ -50,7 +50,7 @@ private static OperationResult RestartAsAdmin()
Process.Start(startInfo);
Environment.Exit(0);
},
errorMessage: Phrases.PopupText_RestartAdminFail
errorMessage: Phrases.MessageError_RestartAdminFail_Extra
);
}

Expand All @@ -68,13 +68,13 @@ private async Task<OperationResult> UpdateAsync(string downloadUrl)
{
var currentExecutablePath = Environment.ProcessPath;
if (currentExecutablePath is null)
return Phrases.PopupText_UnableUpdateWhWz_ReasonLocation;
return Fail(Phrases.MessageWarning_UnableUpdateWhWz_Extra_ReasonLocation);

var currentExecutableName = fileSystem.Path.GetFileNameWithoutExtension(currentExecutablePath);
var currentFolder = fileSystem.Path.GetDirectoryName(currentExecutablePath);

if (currentFolder is null)
return Phrases.PopupText_UnableUpdateWhWz_ReasonLocation;
return Fail(Phrases.MessageWarning_UnableUpdateWhWz_Extra_ReasonLocation);

// Download new executable to a temporary file.
var newFilePath = fileSystem.Path.Combine(currentFolder, currentExecutableName + "_new.exe");
Expand All @@ -84,8 +84,8 @@ private async Task<OperationResult> UpdateAsync(string downloadUrl)
await DownloadHelper.DownloadToLocationAsync(
downloadUrl,
newFilePath,
Phrases.PopupText_UpdateWhWz,
Phrases.PopupText_LatestWhWzGithub,
Phrases.Progress_UpdateWhWz,
Phrases.Progress_LatestWhWzGithub,
ForceGivenFilePath: true
);

Expand All @@ -106,7 +106,7 @@ private OperationResult CreateAndRunPowerShellScript(string currentFilePath, str
{
var currentFolder = fileSystem.Path.GetDirectoryName(currentFilePath);
if (currentFolder is null)
return Phrases.PopupText_UnableUpdateWhWz_ReasonLocation;
return Fail(Phrases.MessageWarning_UnableUpdateWhWz_Extra_ReasonLocation);

var scriptFilePath = fileSystem.Path.Combine(currentFolder, "update.ps1");
var originalFileName = fileSystem.Path.GetFileName(currentFilePath);
Expand Down
Loading
Loading