-
Notifications
You must be signed in to change notification settings - Fork 294
/
Copy pathSinglyLinkedList_Tests.cs
44 lines (36 loc) · 1.1 KB
/
SinglyLinkedList_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
using System.Linq;
using Advanced.Algorithms.DataStructures;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Advanced.Algorithms.Tests.DataStructures
{
[TestClass]
public class SinglyLinkedListTests
{
/// <summary>
/// singly linked list tests
/// </summary>
[TestMethod]
public void SinglyLinkedList_Test()
{
var list = new SinglyLinkedList<string>();
list.InsertFirst("a");
list.InsertLast("b");
list.InsertFirst("c");
list.InsertLast("d");
//{c,a,b,c}
Assert.AreEqual(list.Count(), 4);
Assert.AreEqual(list.Head.Data, "c");
list.Delete("c");
//{a,b,c}
Assert.AreEqual(list.Count(), 3);
Assert.AreEqual(list.Head.Data, "a");
//{b}
list.DeleteFirst();
list.DeleteLast();
Assert.AreEqual(list.Count(), 1);
Assert.AreEqual(list.Head.Data, "b");
list.Delete("b");
Assert.AreEqual(list.Count(), 0);
}
}
}