-
Notifications
You must be signed in to change notification settings - Fork 462
Expand file tree
/
Copy pathHasKeeShareGroupsTests.cs
More file actions
73 lines (67 loc) · 2.42 KB
/
HasKeeShareGroupsTests.cs
File metadata and controls
73 lines (67 loc) · 2.42 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
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
using KeePassLib;
using keepass2android;
namespace KeeShare.Tests
{
public class HasKeeShareGroupsTests
{
[Fact]
public void HasKeeShareGroups_WithNoGroups_ReturnsFalse()
{
var root = new PwGroup();
bool result = keepass2android.KeeShare.HasKeeShareGroups(root);
Assert.False(result);
}
[Fact]
public void HasKeeShareGroups_WithKeeShareActiveTrue_ReturnsTrue()
{
var root = new PwGroup();
root.CustomData.Set("KeeShare.Active", "true");
bool result = keepass2android.KeeShare.HasKeeShareGroups(root);
Assert.True(result);
}
[Fact]
public void HasKeeShareGroups_WithKeeShareActiveFalse_ReturnsFalse()
{
var root = new PwGroup();
root.CustomData.Set("KeeShare.Active", "false");
bool result = keepass2android.KeeShare.HasKeeShareGroups(root);
Assert.False(result);
}
[Fact]
public void HasKeeShareGroups_WithNestedKeeShareGroup_ReturnsTrue()
{
var root = new PwGroup();
var child1 = new PwGroup();
var child2 = new PwGroup();
child2.CustomData.Set("KeeShare.Active", "true");
child1.AddGroup(child2, true);
root.AddGroup(child1, true);
bool result = keepass2android.KeeShare.HasKeeShareGroups(root);
Assert.True(result);
}
[Fact]
public void HasKeeShareGroups_WithMultipleNonKeeShareGroups_ReturnsFalse()
{
var root = new PwGroup();
root.AddGroup(new PwGroup(), true);
root.AddGroup(new PwGroup(), true);
root.AddGroup(new PwGroup(), true);
bool result = keepass2android.KeeShare.HasKeeShareGroups(root);
Assert.False(result);
}
[Fact]
public void HasKeeShareGroups_WithDeeplyNestedKeeShareGroup_ReturnsTrue()
{
var root = new PwGroup();
var level1 = new PwGroup();
var level2 = new PwGroup();
var level3 = new PwGroup();
level3.CustomData.Set("KeeShare.Active", "true");
level2.AddGroup(level3, true);
level1.AddGroup(level2, true);
root.AddGroup(level1, true);
bool result = keepass2android.KeeShare.HasKeeShareGroups(root);
Assert.True(result);
}
}
}