Jahresplanimport und Ablgeich von Untis
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using LehrerApp.Desktop.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace LehrerApp.Desktop.Tests;
|
||||
|
||||
public sealed class AnnualPlanSettingsServiceTests
|
||||
{
|
||||
private const string SampleUrl = "https://example.org/export.php?type=ics&token=intern";
|
||||
|
||||
private static string TempPath()
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"lehrerapp-annualplansettingssvc-tests-{Guid.NewGuid():N}");
|
||||
Directory.CreateDirectory(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IcalUrl_WirdVerschluesseltPersistiertUndWiederGeladen()
|
||||
{
|
||||
var path = TempPath();
|
||||
var service = new AnnualPlanSettingsService(path);
|
||||
service.SetIcalUrl(SampleUrl);
|
||||
service.SetEnabled(true);
|
||||
|
||||
var raw = File.ReadAllText(Path.Combine(path, "annual-plan-settings.json"));
|
||||
var reloaded = new AnnualPlanSettingsService(path);
|
||||
|
||||
Assert.DoesNotContain("token=intern", raw);
|
||||
Assert.Equal(SampleUrl, reloaded.GetIcalUrl());
|
||||
Assert.True(reloaded.Enabled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClearIcalUrl_EntferntUrlUndDeaktiviertDenImport()
|
||||
{
|
||||
var service = new AnnualPlanSettingsService(TempPath());
|
||||
service.SetIcalUrl(SampleUrl);
|
||||
service.SetEnabled(true);
|
||||
|
||||
service.ClearIcalUrl();
|
||||
|
||||
Assert.False(service.IsConfigured);
|
||||
Assert.False(service.Enabled);
|
||||
Assert.Null(service.GetIcalUrl());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user