Skip to content

Commit 42f1f11

Browse files
authored
test nodelist (#418)
* test nodelist * usings * nodelist ---------
1 parent 602ec5b commit 42f1f11

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using BitFaster.Caching.Lfu;
2+
using FluentAssertions;
3+
using Xunit;
4+
5+
namespace BitFaster.Caching.UnitTests.Lfu
6+
{
7+
public class LfuNodeListTests
8+
{
9+
[Fact]
10+
public void WhenPreviousNullLastReturnsNull()
11+
{
12+
var list = new LfuNodeList<int, int>();
13+
14+
list.Last.Should().BeNull();
15+
}
16+
17+
[Fact]
18+
public void WhenPreviousExistsLastReturnsPrevious()
19+
{
20+
var list = new LfuNodeList<int, int>();
21+
var node1 = new LfuNode<int, int>(1, 1);
22+
var node2 = new LfuNode<int, int>(2, 2);
23+
24+
list.AddLast(node1);
25+
list.AddLast(node2);
26+
27+
list.Last.Should().BeSameAs(node2);
28+
}
29+
30+
[Fact]
31+
public void WhenPreviousExistsNodePreviousReturnsPrevious()
32+
{
33+
var list = new LfuNodeList<int, int>();
34+
var node1 = new LfuNode<int, int>(1, 1);
35+
var node2 = new LfuNode<int, int>(2, 2);
36+
37+
list.AddLast(node1);
38+
list.AddLast(node2);
39+
40+
node2.Previous.Should().BeSameAs(node1);
41+
}
42+
43+
[Fact]
44+
public void WhenHeadNodePreviousReturnsNull()
45+
{
46+
var list = new LfuNodeList<int, int>();
47+
var node1 = new LfuNode<int, int>(1, 1);
48+
var node2 = new LfuNode<int, int>(2, 2);
49+
50+
list.AddLast(node1);
51+
list.AddLast(node2);
52+
53+
node1.Previous.Should().BeNull();
54+
}
55+
}
56+
}

BitFaster.Caching/AssemblyInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[assembly: InternalsVisibleTo("BitFaster.Caching.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f55849315b02d525d40701eee5d8eba39e6a517644e8af3fa15141eab7058e76be808e36cfee8d7e071b5aac37bd5e45c67971602680f7bfc26d8c9ebca95dd33b4e3f17a4c28b01268ee6b110ad7e2106ab8ffd1c7be3143192527ce5f639395e46ab086518e881706c6ee9eb96f0263aa34e5152cf5aecf657d463fecf62ca")]

0 commit comments

Comments
 (0)