Public Access
Make meeting lifecycle stateful
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using MeetingAssistant.LaunchProfiles;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace MeetingAssistant.Tests;
|
||||
|
||||
public sealed class LaunchProfileOptionsProviderTests
|
||||
{
|
||||
[Fact]
|
||||
public void DefaultProfileUsesRootMeetingAssistantConfiguration()
|
||||
{
|
||||
var provider = CreateProvider(new Dictionary<string, string?>
|
||||
{
|
||||
["MeetingAssistant:Hotkey:Toggle"] = "Ctrl+Alt+M",
|
||||
["MeetingAssistant:Recording:TranscriptionProvider"] = "azure-speech",
|
||||
["MeetingAssistant:AzureSpeech:Language"] = "de-DE"
|
||||
});
|
||||
|
||||
var profile = provider.GetRequiredProfile(null);
|
||||
|
||||
Assert.Equal("default", profile.Name);
|
||||
Assert.Equal("Ctrl+Alt+M", profile.Options.Hotkey.Toggle);
|
||||
Assert.Equal("azure-speech", profile.Options.Recording.TranscriptionProvider);
|
||||
Assert.Equal("de-DE", profile.Options.AzureSpeech.Language);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NamedProfileMergesOverrideOntoDefaultConfiguration()
|
||||
{
|
||||
var provider = CreateProvider(new Dictionary<string, string?>
|
||||
{
|
||||
["MeetingAssistant:Hotkey:Toggle"] = "Ctrl+Alt+M",
|
||||
["MeetingAssistant:Recording:TranscriptionProvider"] = "azure-speech",
|
||||
["MeetingAssistant:AzureSpeech:Region"] = "germanywestcentral",
|
||||
["MeetingAssistant:AzureSpeech:Language"] = "de-DE",
|
||||
["MeetingAssistant:AzureSpeech:AutoDetectLanguages:0"] = "de-DE",
|
||||
["MeetingAssistant:LaunchProfiles:english:Hotkey:Toggle"] = "Ctrl+Alt+E",
|
||||
["MeetingAssistant:LaunchProfiles:english:AzureSpeech:Language"] = "en-US",
|
||||
["MeetingAssistant:LaunchProfiles:english:AzureSpeech:AutoDetectLanguages:0"] = "en-US"
|
||||
});
|
||||
|
||||
var profile = provider.GetRequiredProfile("english");
|
||||
|
||||
Assert.Equal("english", profile.Name);
|
||||
Assert.Equal("Ctrl+Alt+E", profile.Options.Hotkey.Toggle);
|
||||
Assert.Equal("azure-speech", profile.Options.Recording.TranscriptionProvider);
|
||||
Assert.Equal("germanywestcentral", profile.Options.AzureSpeech.Region);
|
||||
Assert.Equal("en-US", profile.Options.AzureSpeech.Language);
|
||||
Assert.Equal(["en-US"], profile.Options.AzureSpeech.AutoDetectLanguages);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DuplicateProfileHotkeysAreRejected()
|
||||
{
|
||||
var provider = CreateProvider(new Dictionary<string, string?>
|
||||
{
|
||||
["MeetingAssistant:Hotkey:Toggle"] = "Ctrl+Alt+M",
|
||||
["MeetingAssistant:LaunchProfiles:english:Hotkey:Toggle"] = "Ctrl+Alt+M"
|
||||
});
|
||||
|
||||
var exception = Assert.Throws<InvalidOperationException>(() => provider.GetHotkeys());
|
||||
Assert.Contains("Ctrl+Alt+M", exception.Message, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static ConfigurationLaunchProfileOptionsProvider CreateProvider(
|
||||
IReadOnlyDictionary<string, string?> values)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(values)
|
||||
.Build();
|
||||
return new ConfigurationLaunchProfileOptionsProvider(configuration);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user