-
Notifications
You must be signed in to change notification settings - Fork 292
/
CircularQueue_Tests.cs
58 lines (44 loc) · 1.74 KB
/
CircularQueue_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
54
55
56
57
58
using Advanced.Algorithms.Distributed;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Advanced.Algorithms.Tests
{
[TestClass]
public class CircularQueueTests
{
[TestMethod]
public void CircularQueue_Test()
{
var queue = new CircularQueue<int>(7);
Assert.AreEqual(0, queue.Enqueue(1));
Assert.AreEqual(0, queue.Enqueue(2));
Assert.AreEqual(0, queue.Enqueue(3));
Assert.AreEqual(0, queue.Enqueue(4));
Assert.AreEqual(0, queue.Enqueue(5));
Assert.AreEqual(0, queue.Enqueue(6));
Assert.AreEqual(0, queue.Enqueue(7));
Assert.AreEqual(1, queue.Enqueue(8));
Assert.AreEqual(2, queue.Enqueue(9));
Assert.AreEqual(queue.Count, 7);
Assert.AreEqual(3, queue.Dequeue());
Assert.AreEqual(queue.Count, 6);
Assert.AreEqual(queue.Dequeue(), 4);
Assert.AreEqual(queue.Count, 5);
Assert.AreEqual(queue.Dequeue(), 5);
Assert.AreEqual(queue.Count, 4);
Assert.AreEqual(queue.Dequeue(), 6);
Assert.AreEqual(queue.Count, 3);
Assert.AreEqual(queue.Dequeue(), 7);
Assert.AreEqual(queue.Count, 2);
Assert.AreEqual(queue.Dequeue(), 8);
Assert.AreEqual(queue.Count, 1);
Assert.AreEqual(queue.Dequeue(), 9);
Assert.AreEqual(queue.Count, 0);
Assert.AreEqual(0, queue.Enqueue(1));
Assert.AreEqual(0, queue.Enqueue(2));
Assert.AreEqual(queue.Count, 2);
Assert.AreEqual(1, queue.Dequeue());
Assert.AreEqual(queue.Count, 1);
Assert.AreEqual(queue.Dequeue(), 2);
}
}
}