2026-09-27 16:26:52 +02:00
using AIStudio.Tools.RAG ;
using AIStudio.Tools.Services ;
namespace AIStudio.Tests.Tools ;
/// <summary>
/// Checks who hears about what kept a search from covering a local data source.
/// </summary>
/// <remarks>
/// With Semantic Search, the model writes the query, not the user. A warning that the message was
/// too long to search with would then blame the user for a query they never wrote, while the model,
/// which could search with a shorter one, would learn nothing. Problems of the data source itself
/// stay with the user either way, since nobody else can fix a missing embedding provider.
/// </remarks>
[TestFixture]
public sealed class RetrievalGapTests
{
[Test]
public void AQueryTheModelWroteIsNotTheUsersProblem ()
{
2026-10-04 12:26:26 +02:00
Assert . That ( LocalIndexSearchService . IsForTheUser ( RetrievalGap . QUERY_NOT_SEARCHABLE , queryWrittenByUser : false ), Is . False , "The model learns about it from the page and can search with a shorter query." );
2026-09-27 16:26:52 +02:00
}
[Test]
public void AMessageTheUserWroteIsTheirsToShorten ()
{
2026-10-04 12:26:26 +02:00
Assert . That ( LocalIndexSearchService . IsForTheUser ( RetrievalGap . QUERY_NOT_SEARCHABLE , queryWrittenByUser : true ), Is . True );
2026-09-27 16:26:52 +02:00
}
[TestCase(RetrievalGap.NOT_SEARCHED, false)]
[TestCase(RetrievalGap.NOT_SEARCHED, true)]
[TestCase(RetrievalGap.PARTLY_SEARCHED, false)]
[TestCase(RetrievalGap.PARTLY_SEARCHED, true)]
public void ProblemsOfTheDataSourceAreAlwaysForTheUser ( RetrievalGap gap , bool queryWrittenByUser )
{
2026-10-04 12:26:26 +02:00
Assert . That ( LocalIndexSearchService . IsForTheUser ( gap , queryWrittenByUser ), Is . True , "Only the user can fix an index or an embedding provider." );
2026-09-27 16:26:52 +02:00
}
}