Skip to content

Commit 9a9e493

Browse files
committed
Added a unit test for fetching documents using multiple Ids
1 parent 7e20f04 commit 9a9e493

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/Meilisearch.Tests/DocumentTests.cs

+26
Original file line numberDiff line numberDiff line change
@@ -758,5 +758,31 @@ public async Task DeleteAllExistingDocuments()
758758
var docs = await index.GetDocumentsAsync<Movie>();
759759
docs.Results.Should().BeEmpty();
760760
}
761+
762+
[Fact]
763+
public async Task CanFetchMultipleDocumentsByIds()
764+
{
765+
var indexUID = nameof(CanFetchMultipleDocumentsByIds);
766+
var index = _client.Index(indexUID);
767+
768+
var documents = new[]
769+
{
770+
new Movie { Id = "1", Name = "The Matrix" },
771+
new Movie { Id = "2", Name = "Inception" },
772+
new Movie { Id = "3", Name = "Arrival" }
773+
};
774+
775+
var task = await index.AddDocumentsAsync(documents);
776+
await index.WaitForTaskAsync(task.TaskUid);
777+
778+
// Fetch by IDs
779+
var idsToFetch = new List<string> { "1", "3" };
780+
var fetched = await index.GetDocumentsAsync<Movie>(idsToFetch);
781+
var resultDocs = fetched.Results.ToList();
782+
783+
Assert.Equal(2, resultDocs.Count);
784+
Assert.Contains(resultDocs, d => d.Id == "1" && d.Name == "The Matrix");
785+
Assert.Contains(resultDocs, d => d.Id == "3" && d.Name == "Arrival");
786+
}
761787
}
762788
}

0 commit comments

Comments
 (0)