-
Notifications
You must be signed in to change notification settings - Fork 50
/
SettingsTests.cs
168 lines (150 loc) · 7.57 KB
/
SettingsTests.cs
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
using FluentAssertions;
using KeePass.App.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace KeeTrayTOTP.Tests
{
[TestClass]
public class SettingsTests
{
private readonly Settings sut = new Settings(new AceCustomConfig());
[TestMethod]
public void AutoTypeEnable_GetAndSetChangeCorrectField()
{
sut.AutoTypeEnable.Should().BeTrue("because that is the default value");
sut.AutoTypeEnable = !sut.AutoTypeEnable;
sut.AutoTypeEnable.Should().BeFalse("because the setting was changed to a non-default value");
sut.Reset();
sut.AutoTypeEnable.Should().BeTrue("because settings are reset");
}
[TestMethod]
public void AutoTypeFieldName_GetAndSetChangeCorrectField()
{
sut.AutoTypeFieldName.Should().Be("TOTP", "because that is the default value");
sut.AutoTypeFieldName = "xxxx";
sut.AutoTypeFieldName.Should().Be("xxxx", "because the setting was changed to a non-default value");
sut.Reset();
sut.AutoTypeFieldName.Should().Be("TOTP", "because settings are reset");
}
[TestMethod]
public void EntryContextCopyVisible_GetAndSetChangeCorrectField()
{
sut.EntryContextCopyVisible.Should().BeTrue("because that is the default value");
sut.EntryContextCopyVisible = !sut.EntryContextCopyVisible;
sut.EntryContextCopyVisible.Should().BeFalse("because the setting was changed to a non-default value");
sut.Reset();
sut.EntryContextCopyVisible.Should().BeTrue("because settings are reset");
}
[TestMethod]
public void EntryContextSetupVisible_GetAndSetChangeCorrectField()
{
sut.EntryContextSetupVisible.Should().BeTrue("because that is the default value");
sut.EntryContextSetupVisible = !sut.EntryContextSetupVisible;
sut.EntryContextSetupVisible.Should().BeFalse("because the setting was changed to a non-default value");
sut.Reset();
sut.EntryContextSetupVisible.Should().BeTrue("because settings are reset");
}
[TestMethod]
public void EntryListRefreshRate_GetReturnsDefault()
{
sut.EntryListRefreshRate.Should().Be(300, "because that is the default value");
}
[TestMethod]
public void FirstInstallShown_GetAndSetChangeCorrectField()
{
sut.FirstInstallShown.Should().BeFalse("because that is the default value");
sut.FirstInstallShown = !sut.FirstInstallShown;
sut.FirstInstallShown.Should().BeTrue("because the setting was changed to a non-default value");
}
[TestMethod]
public void LegacyTrayMenuProviderEnable_GetAndSetChangeCorrectField()
{
sut.LegacyTrayMenuProviderEnable.Should().BeFalse("because that is the default value");
sut.LegacyTrayMenuProviderEnable = !sut.FirstInstallShown;
sut.LegacyTrayMenuProviderEnable.Should().BeTrue("because the setting was changed to a non-default value");
sut.Reset();
sut.LegacyTrayMenuProviderEnable.Should().BeFalse("because settings are reset");
}
[TestMethod]
public void NotifyContextVisible_GetAndSetChangeCorrectField()
{
sut.NotifyContextVisible.Should().BeTrue("because that is the default value");
sut.NotifyContextVisible = !sut.NotifyContextVisible;
sut.NotifyContextVisible.Should().BeFalse("because the setting was changed to a non-default value");
sut.Reset();
sut.NotifyContextVisible.Should().BeTrue("because settings are reset");
}
[TestMethod]
public void TimeCorrectionEnable_GetAndSetChangeCorrectField()
{
sut.TimeCorrectionEnable.Should().BeFalse("because that is the default value");
sut.TimeCorrectionEnable = !sut.TimeCorrectionEnable;
sut.TimeCorrectionEnable.Should().BeTrue("because the setting was changed to a non-default value");
sut.Reset();
sut.TimeCorrectionEnable.Should().BeFalse("because settings are reset");
}
[TestMethod]
public void TimeCorrectionList_GetAndSetChangeCorrectField()
{
sut.TimeCorrectionList.Should().HaveCount(0, "because that is the default value");
sut.TimeCorrectionList = new [] { "Url1", "Url2", "Url3"};
sut.TimeCorrectionList.Should().BeEquivalentTo(new[] { "Url1", "Url2", "Url3" });
}
[TestMethod]
public void TimeCorrectionRefreshTime_GetAndSetChangeCorrectField()
{
sut.TimeCorrectionRefreshTime.Should().Be(60, "because that is the default value");
sut.TimeCorrectionRefreshTime += 100;
sut.TimeCorrectionRefreshTime.Should().Be(160, "because the setting was changed to a non-default value");
sut.Reset();
sut.TimeCorrectionRefreshTime.Should().Be(60, "because settings are reset");
}
[TestMethod]
public void TOTPColumnCopyEnable_GetAndSetChangeCorrectField()
{
sut.TOTPColumnCopyEnable.Should().BeTrue("because that is the default value");
sut.TOTPColumnCopyEnable = !sut.TOTPColumnCopyEnable;
sut.TOTPColumnCopyEnable.Should().BeFalse("because the setting was changed to a non-default value");
sut.Reset();
sut.TOTPColumnCopyEnable.Should().BeTrue("because settings are reset");
}
[TestMethod]
public void TOTPColumnTimerVisible_GetAndSetChangeCorrectField()
{
sut.TOTPColumnTimerVisible.Should().BeTrue("because that is the default value");
sut.TOTPColumnTimerVisible = !sut.TOTPColumnTimerVisible;
sut.TOTPColumnTimerVisible.Should().BeFalse("because the setting was changed to a non-default value");
sut.Reset();
sut.TOTPColumnTimerVisible.Should().BeTrue("because settings are reset");
}
[TestMethod]
public void TOTPSeedStringName_GetAndSetChangeCorrectField()
{
sut.TOTPSeedStringName.Should().Be("TOTP Seed", "because that is the default value");
sut.TOTPSeedStringName = "SeedSeedSeed";
sut.TOTPSeedStringName.Should().Be("SeedSeedSeed", "because the setting was changed to a non-default value");
sut.Reset();
sut.TOTPSeedStringName.Should().Be("TOTP Seed", "because settings are reset");
}
[TestMethod]
public void TOTPSettingsStringName_GetAndSetChangeCorrectField()
{
sut.TOTPSettingsStringName.Should().Be("TOTP Settings", "because that is the default value");
sut.TOTPSettingsStringName = "SettingsSettingsSettings";
sut.TOTPSettingsStringName.Should().Be("SettingsSettingsSettings", "because the setting was changed to a non-default value");
sut.Reset();
sut.TOTPSettingsStringName.Should().Be("TOTP Settings", "because settings are reset");
}
[TestMethod]
public void TrimTextLength_GetReturnsDefault()
{
sut.TrimTextLength.Should().Be(25, "because that is the default value");
}
[TestMethod]
public void TrimTrayText_GetAndSetChangeCorrectField()
{
sut.TrimTrayText.Should().BeFalse("because that is the default value");
sut.TrimTrayText = !sut.TrimTrayText;
sut.TrimTrayText.Should().BeTrue("because the setting was changed to a non-default value");
}
}
}