-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirEntryTests.cs
More file actions
95 lines (85 loc) · 2.87 KB
/
Copy pathDirEntryTests.cs
File metadata and controls
95 lines (85 loc) · 2.87 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using XISOSharp.DataStructures;
namespace XISOSharp.Tests;
/// <summary>
/// Tests for the <see cref="DirEntry"/> data structure, verifying default values,
/// field assignment, sibling linking, and parent chain relationships.
/// </summary>
public class DirEntryTests
{
/// <summary>
/// Verifies that a newly constructed <see cref="DirEntry"/> has expected default
/// values for all fields.
/// </summary>
[Fact]
public void New_DirEntry_HasDefaults()
{
DirEntry entry = new();
Assert.Null(entry.Left);
Assert.Null(entry.Parent);
Assert.Null(entry.AvlNode);
Assert.Equal("", entry.Filename);
Assert.Equal((ushort)0, entry.ROffset);
Assert.Equal((byte)0, entry.Attributes);
Assert.Equal((byte)0, entry.FilenameLength);
Assert.Equal(0u, entry.FileSize);
Assert.Equal(0u, entry.StartSector);
}
/// <summary>
/// Verifies that all <see cref="DirEntry"/> fields can be individually set
/// and retain their assigned values.
/// </summary>
[Fact]
public void DirEntry_FieldsCanBeSet()
{
DirEntry left = new();
DirEntry parent = new();
AvlNode avlNode = new();
DirEntry entry = new()
{
Left = left,
Parent = parent,
AvlNode = avlNode,
Filename = "test.xbe",
ROffset = 0x800,
Attributes = 0x01,
FilenameLength = 8,
FileSize = 1024,
StartSector = 5
};
Assert.Same(left, entry.Left);
Assert.Same(parent, entry.Parent);
Assert.Same(avlNode, entry.AvlNode);
Assert.Equal("test.xbe", entry.Filename);
Assert.Equal((ushort)0x800, entry.ROffset);
Assert.Equal((byte)0x01, entry.Attributes);
Assert.Equal((byte)8, entry.FilenameLength);
Assert.Equal(1024u, entry.FileSize);
Assert.Equal(5u, entry.StartSector);
}
/// <summary>
/// Verifies that <see cref="DirEntry"/> instances can be linked through the
/// <see cref="DirEntry.Left"/> property to form a sibling chain.
/// </summary>
[Fact]
public void DirEntry_LinkedLeftSiblings()
{
DirEntry a = new() { Filename = "a" };
DirEntry b = new() { Filename = "b", Left = a };
DirEntry c = new() { Filename = "c", Left = b };
Assert.Same(b, c.Left);
Assert.Same(a, c.Left.Left);
}
/// <summary>
/// Verifies that <see cref="DirEntry"/> instances can be linked through the
/// <see cref="DirEntry.Parent"/> property to form a parent-child hierarchy.
/// </summary>
[Fact]
public void DirEntry_ParentChain()
{
DirEntry leaf = new() { Filename = "leaf" };
DirEntry dir = new() { Filename = "dir" };
leaf.Parent = dir;
Assert.Same(dir, leaf.Parent);
Assert.Null(dir.Parent);
}
}