-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathSettingsManagerTest.cs
More file actions
46 lines (40 loc) · 1.23 KB
/
SettingsManagerTest.cs
File metadata and controls
46 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Coder.Desktop.App.Models;
using Coder.Desktop.App.Services;
namespace Coder.Desktop.Tests.App.Services;
[TestFixture]
public sealed class SettingsManagerTests
{
private string _tempDir = string.Empty;
private SettingsManager<CoderConnectSettings> _sut = null!;
[SetUp]
public void SetUp()
{
_tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(_tempDir);
_sut = new SettingsManager<CoderConnectSettings>(_tempDir); // inject isolated path
}
[TearDown]
public void TearDown()
{
try { Directory.Delete(_tempDir, true); } catch { /* ignore */ }
}
[Test]
public void Save_Persists()
{
var expected = true;
var settings = new CoderConnectSettings
{
Version = 1,
ConnectOnLaunch = expected
};
_sut.Write(settings).GetAwaiter().GetResult();
var actual = _sut.Read().GetAwaiter().GetResult();
Assert.That(actual.ConnectOnLaunch, Is.EqualTo(expected));
}
[Test]
public void Read_MissingKey_ReturnsDefault()
{
var actual = _sut.Read().GetAwaiter().GetResult();
Assert.That(actual.ConnectOnLaunch, Is.False);
}
}