-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathProjectTreeNodeTestBase.cs
More file actions
75 lines (60 loc) · 2.08 KB
/
ProjectTreeNodeTestBase.cs
File metadata and controls
75 lines (60 loc) · 2.08 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
//-----------------------------------------------------------------------
// <copyright file="ProjectTreeNodeTestBase.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace ImmutableObjectGraph.Generation.Tests.TestSources
{
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
/// <summary>
/// A base class for testing of red and green trees.
/// </summary>
public abstract class ProjectTreeNodeTestBase : IDisposable
{
internal const string Caption = "some caption.txt";
internal const string ModifiedCaption = "some other caption.txt";
internal const string ItemType = "itemType";
internal const string ItemName = "some item name.txt";
private int nodeCounter;
internal ImmutableList<ProjectTree> Children { get; set; }
public ProjectTreeNodeTestBase()
{
this.nodeCounter = 0;
this.Children = ImmutableList.Create<ProjectTree>();
}
public void Dispose()
{
this.Cleanup();
}
protected virtual void Cleanup()
{
}
internal ProjectTree NewNode(params ProjectTree[] children)
{
this.nodeCounter++;
var tree = ProjectTree.Create(Caption + this.nodeCounter);
if (children != null)
{
tree = tree.WithChildren(children);
}
return tree;
}
internal ProjectTree NewTree(string caption, ProjectTree singleChild)
{
return this.NewTree(caption, new[] { singleChild });
}
internal ProjectTree NewTree(string caption, IEnumerable<ProjectTree> children = null)
{
var tree = ProjectTree.Create(caption);
if (children != null)
{
tree = tree.WithChildren(children);
}
return tree;
}
}
}