The issue is that the below test method works perfectly fine while debugging the code but does not work while running it.
Below test method determines whether the fetch of records is successful or not.
[Fact(DisplayName = "Fetch list of Refund Batch by Status")]
public async Task Can_Query_RefundBatch_By_Status()
{
Store.ExecuteIndex(new RefundBatchByStatus());
SetUpRefundBatches();
var refundBatches = await Repo.FindAllByStatusAsync(BatchStatus.New);
refundBatches.Count.ShouldBe(2);
refundBatches[0].RefundRequests.Count.ShouldBe(5);
refundBatches[1].RefundRequests.Count.ShouldBe(5);
}
Below is the SetUpRefundBatches() method
private void SetUpRefundBatches() {
var session = Store.OpenSession();
foreach (var refundBatch in Factory.RefundBatch.CreateRefundBatchesData())
{
session.Store(refundBatch);
}
session.SaveChanges();
}
Below is the FindAllByStatusAsync method
public async Task<List<RefundBatch>> FindAllByStatusAsync(params BatchStatus[] status)
{
using var session = Store.OpenAsyncSession();
return await session
.Query<RefundBatch, RefundBatchByStatus>()
.ToAsyncDocumentQuery()
.WhereIn(d => d.Status, status, exact: true)
.ToListAsync();
}
Below is the RefundBatchByStatus index class.
public class RefundBatchByStatus : AbstractIndexCreationTask<RefundBatch>
{
public RefundBatchByStatus()
{
Map = docs => from doc in docs select new { doc.Status };
Indexes.Add(x => x.Status, FieldIndexing.Exact);
}
}
Please let me know if more stuff is required from my end to support this question.