// Copyright (c) Microsoft. All rights reserved.
// TODO: Reimplement these as integration tests, #10464
#if DISABLED
using System;
using System.Data.Common;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.VectorData;
using Microsoft.SemanticKernel.Connectors.Sqlite;
using Moq;
using Xunit;
namespace SemanticKernel.Connectors.Sqlite.UnitTests;
///
/// Unit tests for class.
///
public sealed class SqliteVectorStoreTests
{
[Fact]
public void GetCollectionWithNotSupportedKeyThrowsException()
{
// Arrange
var sut = new SqliteVectorStore(Mock.Of());
// Act & Assert
Assert.Throws(() => sut.GetCollection>("collection"));
}
[Fact]
public void GetCollectionWithSupportedKeyReturnsCollection()
{
// Arrange
var sut = new SqliteVectorStore(Mock.Of());
// Act
var collectionWithNumericKey = sut.GetCollection>("collection1");
var collectionWithStringKey = sut.GetCollection>("collection2");
// Assert
Assert.NotNull(collectionWithNumericKey);
Assert.NotNull(collectionWithStringKey);
}
[Fact]
public async Task ListCollectionNamesReturnsCollectionNamesAsync()
{
// Arrange
var mockReader = new Mock();
mockReader
.SetupSequence(l => l.ReadAsync(It.IsAny()))
.ReturnsAsync(true)
.ReturnsAsync(true)
.ReturnsAsync(false);
mockReader
.SetupSequence(l => l.GetString(It.IsAny()))
.Returns("collection1")
.Returns("collection2");
using var fakeCommand = new FakeDbCommand(mockReader.Object);
using var fakeConnection = new FakeDBConnection(fakeCommand);
var sut = new SqliteVectorStore(fakeConnection);
// Act
var collections = await sut.ListCollectionNamesAsync().ToListAsync();
// Assert
Assert.Contains("collection1", collections);
Assert.Contains("collection2", collections);
}
}
#endif