Reformat / cleanup
All checks were successful
NuGet Publish / build-and-pack (push) Successful in 46s
NuGet Publish / publish-to-gitea (push) Successful in 56s

This commit is contained in:
Joseph Doherty
2026-02-21 08:10:36 -05:00
parent 4c6aaa5a3f
commit a70d8befae
176 changed files with 50555 additions and 49587 deletions

View File

@@ -1,18 +1,16 @@
using ZB.MOM.WW.CBDD.Core.Storage;
using ZB.MOM.WW.CBDD.Core.Indexing;
using ZB.MOM.WW.CBDD.Bson;
using Xunit;
using ZB.MOM.WW.CBDD.Core.Storage;
namespace ZB.MOM.WW.CBDD.Tests;
public class QueryPrimitivesTests : IDisposable
{
private readonly string _testFile;
private readonly StorageEngine _storage;
private readonly BTreeIndex _index;
private readonly StorageEngine _storage;
private readonly string _testFile;
/// <summary>
/// Initializes a new instance of the <see cref="QueryPrimitivesTests"/> class.
/// Initializes a new instance of the <see cref="QueryPrimitivesTests" /> class.
/// </summary>
public QueryPrimitivesTests()
{
@@ -26,12 +24,21 @@ public class QueryPrimitivesTests : IDisposable
SeedData();
}
/// <summary>
/// Executes Dispose.
/// </summary>
public void Dispose()
{
_storage.Dispose();
File.Delete(_testFile);
}
private void SeedData()
{
// Insert keys: 10, 20, 30, 40, 50
// And strings: "A", "AB", "ABC", "B", "C"
var txnId = _storage.BeginTransaction().TransactionId;
ulong txnId = _storage.BeginTransaction().TransactionId;
Insert(10, txnId);
Insert(20, txnId);
@@ -59,7 +66,7 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes Equal_ShouldFindExactMatch.
/// Executes Equal_ShouldFindExactMatch.
/// </summary>
[Fact]
public void Equal_ShouldFindExactMatch()
@@ -72,7 +79,7 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes Equal_ShouldReturnEmpty_WhenNotFound.
/// Executes Equal_ShouldReturnEmpty_WhenNotFound.
/// </summary>
[Fact]
public void Equal_ShouldReturnEmpty_WhenNotFound()
@@ -84,13 +91,13 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes GreaterThan_ShouldReturnMatches.
/// Executes GreaterThan_ShouldReturnMatches.
/// </summary>
[Fact]
public void GreaterThan_ShouldReturnMatches()
{
var key = IndexKey.Create(30);
var result = _index.GreaterThan(key, orEqual: false, 0).ToList();
var result = _index.GreaterThan(key, false, 0).ToList();
(result.Count >= 2).ShouldBeTrue();
result[0].Key.ShouldBe(IndexKey.Create(40));
@@ -98,13 +105,13 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes GreaterThanOrEqual_ShouldReturnMatches.
/// Executes GreaterThanOrEqual_ShouldReturnMatches.
/// </summary>
[Fact]
public void GreaterThanOrEqual_ShouldReturnMatches()
{
var key = IndexKey.Create(30);
var result = _index.GreaterThan(key, orEqual: true, 0).ToList();
var result = _index.GreaterThan(key, true, 0).ToList();
(result.Count >= 3).ShouldBeTrue();
result[0].Key.ShouldBe(IndexKey.Create(30));
@@ -113,13 +120,13 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes LessThan_ShouldReturnMatches.
/// Executes LessThan_ShouldReturnMatches.
/// </summary>
[Fact]
public void LessThan_ShouldReturnMatches()
{
var key = IndexKey.Create(30);
var result = _index.LessThan(key, orEqual: false, 0).ToList();
var result = _index.LessThan(key, false, 0).ToList();
result.Count.ShouldBe(2); // 20, 10 (Order is backward?)
// LessThan yields backward?
@@ -129,14 +136,14 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes Between_ShouldReturnRange.
/// Executes Between_ShouldReturnRange.
/// </summary>
[Fact]
public void Between_ShouldReturnRange()
{
var start = IndexKey.Create(20);
var end = IndexKey.Create(40);
var result = _index.Between(start, end, startInclusive: true, endInclusive: true, 0).ToList();
var result = _index.Between(start, end, true, true, 0).ToList();
result.Count.ShouldBe(3); // 20, 30, 40
result[0].Key.ShouldBe(IndexKey.Create(20));
@@ -145,7 +152,7 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes StartsWith_ShouldReturnPrefixMatches.
/// Executes StartsWith_ShouldReturnPrefixMatches.
/// </summary>
[Fact]
public void StartsWith_ShouldReturnPrefixMatches()
@@ -158,7 +165,7 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes Like_ShouldSupportWildcards.
/// Executes Like_ShouldSupportWildcards.
/// </summary>
[Fact]
public void Like_ShouldSupportWildcards()
@@ -176,7 +183,7 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes Like_Underscore_ShouldMatchSingleChar.
/// Executes Like_Underscore_ShouldMatchSingleChar.
/// </summary>
[Fact]
public void Like_Underscore_ShouldMatchSingleChar()
@@ -188,7 +195,7 @@ public class QueryPrimitivesTests : IDisposable
}
/// <summary>
/// Executes In_ShouldReturnSpecificKeys.
/// Executes In_ShouldReturnSpecificKeys.
/// </summary>
[Fact]
public void In_ShouldReturnSpecificKeys()
@@ -201,13 +208,4 @@ public class QueryPrimitivesTests : IDisposable
result[1].Key.ShouldBe(IndexKey.Create(30));
result[2].Key.ShouldBe(IndexKey.Create(50));
}
/// <summary>
/// Executes Dispose.
/// </summary>
public void Dispose()
{
_storage.Dispose();
File.Delete(_testFile);
}
}
}