-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccountTest.cs
59 lines (48 loc) · 1.3 KB
/
AccountTest.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
using System;
using CsCheck;
using NUnit.Framework;
namespace Finance.Accounting.Test;
public class AccountTest
{
[Test]
public void Parent()
{
var accountGen =
from branch in Gen.String.Array.Nonempty
select new Account(branch);
accountGen.Sample(account =>
{
var parent = account.Parent;
Assert.That(parent, Is.Not.EqualTo(account));
Assert.That(account.IsUnder(parent));
});
}
[Test]
public void RootParent()
{
var root = new Account();
Assert.That(root.Depth, Is.EqualTo(0));
var parent = root.Parent;
Assert.That(parent, Is.EqualTo(root));
}
[Test]
public void Equality()
{
Gen.String[0, 5].Array.Sample(branch =>
{
Assert.That(branch, Is.All.Not.Null);
var left = new Account(branch);
var right = new Account(branch);
Assert.That(left, Is.EqualTo(right));
});
}
[Test]
public void DepthIsNotNegative()
{
Gen.String.Array[0, 5].Sample(branch =>
{
var account = new Account(branch);
Assert.That(account.Depth, Is.EqualTo(branch.Length));
});
}
}