Skip to content

Commit

Permalink
Fixed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrostruk committed Jan 28, 2025
1 parent 6971ceb commit b652d54
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class AzureCosmosDBNoSQLKernelBuilderExtensionsTests
public void AddVectorStoreRegistersClass()
{
// Arrange
this._kernelBuilder.Services.AddSingleton<Database>(Mock.Of<Database>());
this._kernelBuilder.Services.AddSingleton<Database>(Mock.Of<Database>(MockBehavior.Loose));

// Act
this._kernelBuilder.AddAzureCosmosDBNoSQLVectorStore();
Expand Down Expand Up @@ -55,7 +55,7 @@ public void AddVectorStoreWithConnectionStringRegistersClass()
public void AddVectorStoreRecordCollectionRegistersClass()
{
// Arrange
this._kernelBuilder.Services.AddSingleton<Database>(Mock.Of<Database>());
this._kernelBuilder.Services.AddSingleton<Database>(Mock.Of<Database>(MockBehavior.Loose));

// Act
this._kernelBuilder.AddAzureCosmosDBNoSQLVectorStoreRecordCollection<TestRecord>("testcollection");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class AzureCosmosDBNoSQLServiceCollectionExtensionsTests
public void AddVectorStoreRegistersClass()
{
// Arrange
this._serviceCollection.AddSingleton<Database>(Mock.Of<Database>());
this._serviceCollection.AddSingleton<Database>(Mock.Of<Database>(MockBehavior.Loose));

// Act
this._serviceCollection.AddAzureCosmosDBNoSQLVectorStore();
Expand Down Expand Up @@ -56,7 +56,7 @@ public void AddVectorStoreWithConnectionStringRegistersClass()
public void AddVectorStoreRecordCollectionRegistersClass()
{
// Arrange
this._serviceCollection.AddSingleton<Database>(Mock.Of<Database>());
this._serviceCollection.AddSingleton<Database>(Mock.Of<Database>(MockBehavior.Loose));

// Act
this._serviceCollection.AddAzureCosmosDBNoSQLVectorStoreRecordCollection<TestRecord>("testcollection");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace SemanticKernel.Connectors.AzureCosmosDBNoSQL.UnitTests;
/// </summary>
public sealed class AzureCosmosDBNoSQLVectorStoreRecordCollectionTests
{
private readonly Mock<Database> _mockDatabase = new();
private readonly Mock<Container> _mockContainer = new();
private readonly Mock<Database> _mockDatabase = new(MockBehavior.Loose);
private readonly Mock<Container> _mockContainer = new(MockBehavior.Loose);

public AzureCosmosDBNoSQLVectorStoreRecordCollectionTests()
{
Expand Down Expand Up @@ -74,12 +74,12 @@ public void ConstructorWithImperativeModelInitializesCollection()
public async Task CollectionExistsReturnsValidResultAsync(List<string> collections, string collectionName, bool expectedResult)
{
// Arrange
var mockFeedResponse = new Mock<FeedResponse<string>>();
var mockFeedResponse = new Mock<FeedResponse<string>>(MockBehavior.Loose);
mockFeedResponse
.Setup(l => l.Resource)
.Returns(collections);

var mockFeedIterator = new Mock<FeedIterator<string>>();
var mockFeedIterator = new Mock<FeedIterator<string>>(MockBehavior.Loose);
mockFeedIterator
.SetupSequence(l => l.HasMoreResults)
.Returns(true)
Expand Down Expand Up @@ -194,7 +194,7 @@ public async Task CreateCollectionIfNotExistsInvokesValidMethodsAsync(List<strin
// Arrange
const string CollectionName = "collection";

var mockFeedResponse = new Mock<FeedResponse<string>>();
var mockFeedResponse = new Mock<FeedResponse<string>>(MockBehavior.Loose);
mockFeedResponse
.Setup(l => l.Resource)
.Returns(collections);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace SemanticKernel.Connectors.AzureCosmosDBNoSQL.UnitTests;
/// </summary>
public sealed class AzureCosmosDBNoSQLVectorStoreTests
{
private readonly Mock<Database> _mockDatabase = new();
private readonly Mock<Database> _mockDatabase = new(MockBehavior.Loose);

[Fact]
public void GetCollectionWithNotSupportedKeyThrowsException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal static ReadOnlyMemory<byte> GetTestResponseBytes(string fileName)
/// <param name="httpResponseMessage">Message to return for mocked <see cref="HttpClientHandler"/>.</param>
internal static HttpClientHandler GetHttpClientHandlerMock(HttpResponseMessage httpResponseMessage)
{
var httpClientHandler = new Mock<HttpClientHandler>();
var httpClientHandler = new Mock<HttpClientHandler>(MockBehavior.Loose);

httpClientHandler
.Protected()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public QdrantMemoryBuilderExtensionsTests()
public async Task QdrantMemoryStoreShouldBeProperlyInitializedAsync()
{
// Arrange
var embeddingGenerationMock = Mock.Of<ITextEmbeddingGenerationService>();
var embeddingGenerationMock = Mock.Of<ITextEmbeddingGenerationService>(MockBehavior.Loose);

this._httpClient.BaseAddress = new Uri("https://fake-random-qdrant-host");
this._messageHandlerStub.ResponseToReturn.Content = new StringContent("""{"result":{"collections":[]}}""", Encoding.UTF8, MediaTypeNames.Application.Json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ public class QdrantMemoryStoreTests
private readonly ReadOnlyMemory<float> _embedding = new float[] { 1, 1, 1 };
private readonly ReadOnlyMemory<float> _embedding2 = new float[] { 2, 2, 2 };
private readonly ReadOnlyMemory<float> _embedding3 = new float[] { 3, 3, 3 };
private readonly Mock<ILoggerFactory> _mockLoggerFactory = new();
private readonly Mock<ILoggerFactory> _mockLoggerFactory = new(MockBehavior.Loose);

public QdrantMemoryStoreTests()
{
this._mockLoggerFactory
.Setup(f => f.CreateLogger(It.IsAny<string>()))
.Returns(new Mock<ILogger>().Object);
.Returns(new Mock<ILogger>(MockBehavior.Loose).Object);
}

[Fact]
public async Task ItCreatesNewCollectionAsync()
{
// Arrange
var mockQdrantClient = new Mock<IQdrantVectorDbClient>();
var mockQdrantClient = new Mock<IQdrantVectorDbClient>(MockBehavior.Loose);
mockQdrantClient
.Setup<Task<bool>>(x => x.DoesCollectionExistAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(false);
Expand All @@ -67,7 +67,7 @@ public async Task ItCreatesNewCollectionAsync()
public async Task ItWillNotOverwriteExistingCollectionAsync()
{
// Arrange
var mockQdrantClient = new Mock<IQdrantVectorDbClient>();
var mockQdrantClient = new Mock<IQdrantVectorDbClient>(MockBehavior.Loose);
mockQdrantClient
.Setup<Task<bool>>(x => x.DoesCollectionExistAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(true);
Expand All @@ -90,7 +90,7 @@ public async Task ItWillNotOverwriteExistingCollectionAsync()
public async Task ItListsCollectionsAsync()
{
// Arrange
var mockQdrantClient = new Mock<IQdrantVectorDbClient>();
var mockQdrantClient = new Mock<IQdrantVectorDbClient>(MockBehavior.Loose);
mockQdrantClient
.Setup<IAsyncEnumerable<string>>(x => x.ListCollectionsAsync(It.IsAny<CancellationToken>()))
.Returns((new string[] { "test1", "test2" }).ToAsyncEnumerable());
Expand All @@ -111,7 +111,7 @@ public async Task ItListsCollectionsAsync()
public async Task ItDeletesCollectionAsync()
{
// Arrange
var mockQdrantClient = new Mock<IQdrantVectorDbClient>();
var mockQdrantClient = new Mock<IQdrantVectorDbClient>(MockBehavior.Loose);
mockQdrantClient
.Setup<Task>(x => x.DeleteCollectionAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()));
mockQdrantClient
Expand All @@ -137,7 +137,7 @@ public async Task ItThrowsIfUpsertRequestFailsAsync()
description: this._description,
embedding: this._embedding);

var mockQdrantClient = new Mock<IQdrantVectorDbClient>();
var mockQdrantClient = new Mock<IQdrantVectorDbClient>(MockBehavior.Loose);
mockQdrantClient
.Setup<Task<bool>>(x => x.DoesCollectionExistAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class QdrantMemoryStoreTests2
private readonly ReadOnlyMemory<float> _embedding = new float[] { 1, 1, 1 };
private readonly ReadOnlyMemory<float> _embedding2 = new float[] { 2, 2, 2 };
private readonly ReadOnlyMemory<float> _embedding3 = new float[] { 3, 3, 3 };
private readonly Mock<ILoggerFactory> _mockLogger = new();
private readonly Mock<ILoggerFactory> _mockLogger = new(MockBehavior.Loose);

[Fact]
public async Task GetAsyncCallsDoNotRequestVectorsUnlessSpecifiedAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class QdrantMemoryStoreTests3
private readonly string _text = "text";
private readonly string _description = "description";
private readonly ReadOnlyMemory<float> _embedding = new float[] { 1, 1, 1 };
private readonly Mock<ILoggerFactory> _mockLoggerFactory = new();
private readonly Mock<ILoggerFactory> _mockLoggerFactory = new(MockBehavior.Loose);

[Fact]
public async Task GetNearestMatchesAsyncCallsDoNotReturnVectorsUnlessSpecifiedAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public RedisHashSetVectorStoreRecordCollectionTests()
{
this._redisDatabaseMock = new Mock<IDatabase>(MockBehavior.Strict);

var batchMock = new Mock<IBatch>();
var batchMock = new Mock<IBatch>(MockBehavior.Loose);
this._redisDatabaseMock.Setup(x => x.CreateBatch(It.IsAny<object>())).Returns(batchMock.Object);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public RedisKernelBuilderExtensionsTests()
public void AddVectorStoreRegistersClass()
{
// Arrange.
this._kernelBuilder.Services.AddSingleton<IDatabase>(Mock.Of<IDatabase>());
this._kernelBuilder.Services.AddSingleton<IDatabase>(Mock.Of<IDatabase>(MockBehavior.Loose));

// Act.
this._kernelBuilder.AddRedisVectorStore();
Expand All @@ -39,7 +39,7 @@ public void AddVectorStoreRegistersClass()
public void AddRedisHashSetVectorStoreRecordCollectionRegistersClass()
{
// Arrange.
this._kernelBuilder.Services.AddSingleton<IDatabase>(Mock.Of<IDatabase>());
this._kernelBuilder.Services.AddSingleton<IDatabase>(Mock.Of<IDatabase>(MockBehavior.Loose));

// Act.
this._kernelBuilder.AddRedisHashSetVectorStoreRecordCollection<TestRecord>("testCollection");
Expand All @@ -52,7 +52,7 @@ public void AddRedisHashSetVectorStoreRecordCollectionRegistersClass()
public void AddRedisJsonVectorStoreRecordCollectionRegistersClass()
{
// Arrange.
this._kernelBuilder.Services.AddSingleton<IDatabase>(Mock.Of<IDatabase>());
this._kernelBuilder.Services.AddSingleton<IDatabase>(Mock.Of<IDatabase>(MockBehavior.Loose));

// Act.
this._kernelBuilder.AddRedisJsonVectorStoreRecordCollection<TestRecord>("testCollection");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class RedisMemoryStoreTests

public RedisMemoryStoreTests()
{
this._mockDatabase = new Mock<IDatabase>();
this._mockDatabase = new Mock<IDatabase>(MockBehavior.Loose);
this._collections = [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public RedisServiceCollectionExtensionsTests()
public void AddVectorStoreRegistersClass()
{
// Arrange.
this._serviceCollection.AddSingleton<IDatabase>(Mock.Of<IDatabase>());
this._serviceCollection.AddSingleton<IDatabase>(Mock.Of<IDatabase>(MockBehavior.Loose));

// Act.
this._serviceCollection.AddRedisVectorStore();
Expand All @@ -39,7 +39,7 @@ public void AddVectorStoreRegistersClass()
public void AddRedisHashSetVectorStoreRecordCollectionRegistersClass()
{
// Arrange.
this._serviceCollection.AddSingleton<IDatabase>(Mock.Of<IDatabase>());
this._serviceCollection.AddSingleton<IDatabase>(Mock.Of<IDatabase>(MockBehavior.Loose));

// Act.
this._serviceCollection.AddRedisHashSetVectorStoreRecordCollection<TestRecord>("testCollection");
Expand All @@ -52,7 +52,7 @@ public void AddRedisHashSetVectorStoreRecordCollectionRegistersClass()
public void AddRedisJsonVectorStoreRecordCollectionRegistersClass()
{
// Arrange.
this._serviceCollection.AddSingleton<IDatabase>(Mock.Of<IDatabase>());
this._serviceCollection.AddSingleton<IDatabase>(Mock.Of<IDatabase>(MockBehavior.Loose));

// Act.
this._serviceCollection.AddRedisJsonVectorStoreRecordCollection<TestRecord>("testCollection");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public RedisVectorStoreTests()
{
this._redisDatabaseMock = new Mock<IDatabase>(MockBehavior.Strict);

var batchMock = new Mock<IBatch>();
var batchMock = new Mock<IBatch>(MockBehavior.Loose);
this._redisDatabaseMock.Setup(x => x.CreateBatch(It.IsAny<object>())).Returns(batchMock.Object);
}

Expand Down

0 comments on commit b652d54

Please sign in to comment.