-
Notifications
You must be signed in to change notification settings - Fork 292
/
Tree_Tests.cs
53 lines (41 loc) · 1.37 KB
/
Tree_Tests.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
using System.Linq;
using Advanced.Algorithms.DataStructures;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Advanced.Algorithms.Tests.DataStructures
{
[TestClass]
public class TreeTests
{
/// <summary>
/// A tree test
/// </summary>
[TestMethod]
public void Tree_Test()
{
var tree = new Tree<int>();
Assert.AreEqual(tree.GetHeight(), -1);
tree.Insert(0, 0);
Assert.AreEqual(tree.GetHeight(), 0);
tree.Insert(0, 1);
Assert.AreEqual(tree.GetHeight(), 1);
tree.Insert(1, 2);
Assert.AreEqual(tree.GetHeight(), 2);
//IEnumerable test using linq count()
Assert.AreEqual(tree.Count, tree.Count());
tree.Delete(1);
Assert.AreEqual(tree.GetHeight(), 1);
tree.Delete(2);
Assert.AreEqual(tree.GetHeight(), 0);
tree.Delete(0);
Assert.AreEqual(tree.GetHeight(), -1);
tree.Insert(0, 0);
Assert.AreEqual(tree.GetHeight(), 0);
tree.Insert(0, 1);
Assert.AreEqual(tree.GetHeight(), 1);
tree.Insert(1, 2);
Assert.AreEqual(tree.GetHeight(), 2);
//IEnumerable test using linq count()
Assert.AreEqual(tree.Count, tree.Count());
}
}
}