This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
157 additions
and
8 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
KoeBook.Core/Contracts/Services/ISoundGenerationSelectorService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace KoeBook.Core.Contracts.Services; | ||
|
||
public interface ISoundGenerationSelectorService | ||
{ | ||
public SoundModel[] Models { get; } | ||
|
||
public ValueTask InitializeAsync(CancellationToken cancellationToken); | ||
} | ||
|
||
public record SoundModel(string name, string[] styles); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using KoeBook.Core.Contracts.Services; | ||
using KoeBook.Core.Models; | ||
|
||
namespace KoeBook.Core.Helpers; | ||
|
||
public static class IDisplayStateChangeEx | ||
{ | ||
public static DisplayStateChanging ResetProgress( | ||
this IDisplayStateChangeService service, | ||
BookProperties bookProperties, | ||
GenerationState state, | ||
int maximum) | ||
{ | ||
service.UpdateProgress(bookProperties, 0, maximum); | ||
service.UpdateState(bookProperties, state); | ||
return new(service, bookProperties, maximum); | ||
} | ||
|
||
public class DisplayStateChanging(IDisplayStateChangeService displayStateChangeService, BookProperties bookProperties, int maximum) | ||
{ | ||
private readonly IDisplayStateChangeService _displayStateChangeService = displayStateChangeService; | ||
|
||
private readonly BookProperties _bookProperties = bookProperties; | ||
|
||
private readonly int _maximum = maximum; | ||
|
||
public void UpdateProgress(int progress) | ||
{ | ||
_displayStateChangeService.UpdateProgress(_bookProperties, progress, _maximum); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace KoeBook.Models; | ||
|
||
internal class MockOptions | ||
{ | ||
public bool? IAnalyzerService { get; set; } | ||
|
||
public bool? IEpubGenerateService { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using KoeBook.Core.Contracts.Services; | ||
using KoeBook.Core.Helpers; | ||
using KoeBook.Core.Models; | ||
|
||
namespace KoeBook.Services.CoreMocks; | ||
|
||
public class AnalyzerServiceMock(IDisplayStateChangeService stateService) : IAnalyzerService | ||
{ | ||
private readonly IDisplayStateChangeService _stateService = stateService; | ||
|
||
public async ValueTask<BookScripts> AnalyzeAsync(BookProperties bookProperties, CancellationToken cancellationToken) | ||
{ | ||
var stateChanging = _stateService.ResetProgress(bookProperties, GenerationState.Downloading, 300); | ||
await Task.Delay(5000, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(30); | ||
await Task.Delay(500, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(100); | ||
await Task.Delay(500, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(300); | ||
|
||
stateChanging = _stateService.ResetProgress(bookProperties, GenerationState.Downloading, 400); | ||
await Task.Delay(500, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(240); | ||
await Task.Delay(500, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(400); | ||
|
||
var characterMapping = new Dictionary<string, string>() | ||
{ | ||
["Hoge"] = "男性1", | ||
["Fuga"] = "女性1", | ||
["Narration"] = "ナレーション (男性)", | ||
}; | ||
return new(bookProperties, new(characterMapping)) | ||
{ | ||
ScriptLines = [ | ||
new("a", "読み上げテキスト1", "Hoge", "Angry"), | ||
new("b", "読み上げテキスト2", "Fuga", "Sad"), | ||
new("c", "読み上げテキスト3", "Narration", "Narration"), | ||
], | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using KoeBook.Core.Contracts.Services; | ||
using KoeBook.Core.Helpers; | ||
using KoeBook.Core.Models; | ||
|
||
namespace KoeBook.Services.CoreMocks; | ||
|
||
public class EpubGenerateServiceMock(IDisplayStateChangeService displayStateChangeService) : IEpubGenerateService | ||
{ | ||
private readonly IDisplayStateChangeService _displayStateChangeService = displayStateChangeService; | ||
|
||
public async ValueTask<string> GenerateEpubAsync(BookScripts bookScripts, string tempDirectory, CancellationToken cancellationToken) | ||
{ | ||
var stateChanging = _displayStateChangeService.ResetProgress(bookScripts.BookProperties, GenerationState.SoundProducing, 4000); | ||
await Task.Delay(200, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(200); | ||
await Task.Delay(2000, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(2000); | ||
await Task.Delay(1000, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(3000); | ||
await Task.Delay(200, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(4000); | ||
|
||
stateChanging = _displayStateChangeService.ResetProgress(bookScripts.BookProperties, GenerationState.Publishing, 200); | ||
await Task.Delay(1000, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(50); | ||
await Task.Delay(1000, cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(120); | ||
var resultPath = Path.Combine(tempDirectory, "mock.epub"); | ||
await File.WriteAllTextAsync(resultPath, "sample", cancellationToken).ConfigureAwait(false); | ||
stateChanging.UpdateProgress(200); | ||
return resultPath; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
{ | ||
{ | ||
"LocalSettingsOptions": { | ||
"ApplicationDataFolder": "KoeBook/ApplicationData", | ||
"LocalSettingsFile": "LocalSettings.json" | ||
"ApplicationDataFolder": "KoeBook/ApplicationData", | ||
"LocalSettingsFile": "LocalSettings.json" | ||
}, | ||
"MockOptions": { | ||
"IAnalyzerService": true, | ||
"IEpubGenerateService": true | ||
} | ||
} |