Skip to content

Commit

Permalink
test nodelist (#418)
Browse files Browse the repository at this point in the history
* test nodelist

* usings

* nodelist

---------
  • Loading branch information
bitfaster authored Oct 15, 2023
1 parent 602ec5b commit 42f1f11
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
56 changes: 56 additions & 0 deletions BitFaster.Caching.UnitTests/Lfu/LfuNodeListTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using BitFaster.Caching.Lfu;
using FluentAssertions;
using Xunit;

namespace BitFaster.Caching.UnitTests.Lfu
{
public class LfuNodeListTests
{
[Fact]
public void WhenPreviousNullLastReturnsNull()
{
var list = new LfuNodeList<int, int>();

list.Last.Should().BeNull();
}

[Fact]
public void WhenPreviousExistsLastReturnsPrevious()
{
var list = new LfuNodeList<int, int>();
var node1 = new LfuNode<int, int>(1, 1);
var node2 = new LfuNode<int, int>(2, 2);

list.AddLast(node1);
list.AddLast(node2);

list.Last.Should().BeSameAs(node2);
}

[Fact]
public void WhenPreviousExistsNodePreviousReturnsPrevious()
{
var list = new LfuNodeList<int, int>();
var node1 = new LfuNode<int, int>(1, 1);
var node2 = new LfuNode<int, int>(2, 2);

list.AddLast(node1);
list.AddLast(node2);

node2.Previous.Should().BeSameAs(node1);
}

[Fact]
public void WhenHeadNodePreviousReturnsNull()
{
var list = new LfuNodeList<int, int>();
var node1 = new LfuNode<int, int>(1, 1);
var node2 = new LfuNode<int, int>(2, 2);

list.AddLast(node1);
list.AddLast(node2);

node1.Previous.Should().BeNull();
}
}
}
3 changes: 3 additions & 0 deletions BitFaster.Caching/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("BitFaster.Caching.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f55849315b02d525d40701eee5d8eba39e6a517644e8af3fa15141eab7058e76be808e36cfee8d7e071b5aac37bd5e45c67971602680f7bfc26d8c9ebca95dd33b4e3f17a4c28b01268ee6b110ad7e2106ab8ffd1c7be3143192527ce5f639395e46ab086518e881706c6ee9eb96f0263aa34e5152cf5aecf657d463fecf62ca")]

0 comments on commit 42f1f11

Please sign in to comment.