Skip to content

Commit

Permalink
fix np
Browse files Browse the repository at this point in the history
  • Loading branch information
forsthug committed Aug 27, 2024
1 parent 5e3686a commit 2aa1815
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ public async Task<int> CountAsync()
public async Task<ftQueueItem> GetLastQueueItemAsync()
{
var result = _tableClient.QueryAsync<TableEntity>(select: new string[] { "PartitionKey", "RowKey" });
var lastEntity = await result.FirstAsync();
var lastEntity = await result.FirstOrDefaultAsync();

if (lastEntity == null)
{
return null;
}

return MapToStorageEntity(await _tableClient.GetEntityAsync<TableEntity>(lastEntity.PartitionKey, lastEntity.RowKey));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public async Task GetLastQueueItem_ShouldReturnLastQueueItem()
last.ftQueueItemId.Should().Be(entries.Last().ftQueueItemId);
}

[Fact]
public async Task GetLastQueueItem_NoEntries_ShouldNull()
{
var entries = new List<ftQueueItem>();
var sut = await CreateRepository(entries);

var last = await sut.GetLastQueueItemAsync();
last.Should().BeNull();
}

[Fact]
public async Task GetAsync_ShouldReturnAllEntriesThatExistInRepository()
{
Expand Down

0 comments on commit 2aa1815

Please sign in to comment.