Skip to content

Commit 82c9eaa

Browse files
Johny404Jan Vícha
and
Jan Vícha
authored
Added unit test for listing with advanced enumerator param and in key value (#148)
Co-authored-by: Jan Vícha <[email protected]>
1 parent 125e79c commit 82c9eaa

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

BTDBTest/ObjectDbTableInKeyValueTest.cs

+57
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,61 @@ public void InvalidDataTest()
227227
Assert.Equal("PrimaryKey Name cannot be after InKeyValue Age",
228228
Assert.Throws<BTDBException>(() => tr.GetRelation<IInvalidDataTable>()).Message);
229229
}
230+
231+
232+
public class ListData
233+
{
234+
[PrimaryKey(1)]
235+
public uint Id { get; set; }
236+
[PrimaryKey(2)]
237+
public uint QueueStamp { get; set; }
238+
[PrimaryKey(3, InKeyValue = true)]
239+
public bool IsProcessed { get; set; }
240+
}
241+
242+
public interface IListDataTable : IRelation<ListData>
243+
{
244+
IEnumerable<ListData> ListById(uint id, AdvancedEnumeratorParam<uint> queueStampParam);
245+
}
246+
247+
[Fact]
248+
public void ListingWithAdvancedEnumeratorParam()
249+
{
250+
FillListingData();
251+
252+
using var tr = _db.StartTransaction();
253+
var t = tr.GetRelation<IListDataTable>();
254+
Assert.Equal(2, t.ListById(1, new(EnumerationOrder.Ascending, 2, KeyProposition.Excluded, uint.MaxValue, KeyProposition.Included)).Count());
255+
}
256+
257+
void FillListingData()
258+
{
259+
using var tr = _db.StartTransaction();
260+
var t = tr.GetRelation<IListDataTable>();
261+
t.Upsert(new ListData()
262+
{
263+
Id = 1,
264+
QueueStamp = 1,
265+
IsProcessed = true
266+
});
267+
t.Upsert(new ListData()
268+
{
269+
Id = 1,
270+
QueueStamp = 2,
271+
IsProcessed = true
272+
});
273+
t.Upsert(new ListData()
274+
{
275+
Id = 1,
276+
QueueStamp = 3,
277+
IsProcessed = false
278+
});
279+
t.Upsert(new ListData()
280+
{
281+
Id = 1,
282+
QueueStamp = 4,
283+
IsProcessed = false
284+
});
285+
tr.Commit();
286+
}
230287
}

0 commit comments

Comments
 (0)