(refactor): review namespaces
This commit is contained in:
parent
e5898dbfe7
commit
fa1e270882
@ -10,15 +10,15 @@ using MaksIT.MongoDB.Linq.Utilities;
|
||||
using MaksIT.MongoDB.Linq.Tests.Mock;
|
||||
|
||||
|
||||
namespace MaksIT.MongoDB.Tests {
|
||||
namespace MaksIT.MongoDB.Tests;
|
||||
|
||||
// Sample DTO class for testing
|
||||
public class TestableDocumentDto : DtoDocumentBase<Guid> {
|
||||
// Sample DTO class for testing
|
||||
public class TestableDocumentDto : DtoDocumentBase<Guid> {
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
// Generalized Testable class to simulate MongoDB operations using an in-memory list
|
||||
public class TestableCollectionDataProvider : BaseCollectionDataProviderBase<TestableCollectionDataProvider, TestableDocumentDto, Guid> {
|
||||
// Generalized Testable class to simulate MongoDB operations using an in-memory list
|
||||
public class TestableCollectionDataProvider : BaseCollectionDataProviderBase<TestableCollectionDataProvider, TestableDocumentDto, Guid> {
|
||||
private readonly List<TestableDocumentDto> _inMemoryCollection;
|
||||
|
||||
public TestableCollectionDataProvider(ILogger<TestableCollectionDataProvider> logger)
|
||||
@ -138,14 +138,14 @@ namespace MaksIT.MongoDB.Tests {
|
||||
public IQueryable<TestableDocumentDto> GetInMemoryCollection() {
|
||||
return _inMemoryCollection.AsQueryable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class TestableCollectionDataProviderTests {
|
||||
public class TestableCollectionDataProviderTests {
|
||||
private readonly TestableCollectionDataProvider _dataProvider;
|
||||
|
||||
public TestableCollectionDataProviderTests() {
|
||||
@ -341,10 +341,4 @@ namespace MaksIT.MongoDB.Tests {
|
||||
Assert.Contains(queryResult, doc => doc.Name == "Document 1");
|
||||
Assert.Contains(queryResult, doc => doc.Name == "Document 2");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Mock {
|
||||
internal class MongoAsyncCursorMock<T>(List<T> documents) : IAsyncCursor<T> {
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Mock;
|
||||
internal class MongoAsyncCursorMock<T>(List<T> documents) : IAsyncCursor<T> {
|
||||
|
||||
public IEnumerable<T> Current => documents;
|
||||
|
||||
@ -16,5 +17,4 @@ namespace MaksIT.MongoDB.Linq.Tests.Mock {
|
||||
public void Dispose() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
using MongoDB.Driver;
|
||||
using MongoDB.Driver.Core.Clusters;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Mock {
|
||||
internal class MongoClientMock : IMongoClient {
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Mock;
|
||||
internal class MongoClientMock : IMongoClient {
|
||||
|
||||
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
|
||||
@ -159,5 +159,4 @@ namespace MaksIT.MongoDB.Linq.Tests.Mock {
|
||||
#endregion
|
||||
|
||||
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,9 @@
|
||||
using MongoDB.Driver;
|
||||
using MongoDB.Driver.Search;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Mock {
|
||||
internal class MongoCollectionMock<TDocument> : IMongoCollection<TDocument> {
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Mock;
|
||||
|
||||
internal class MongoCollectionMock<TDocument> : IMongoCollection<TDocument> {
|
||||
|
||||
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
@ -405,5 +406,5 @@ namespace MaksIT.MongoDB.Linq.Tests.Mock {
|
||||
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Mock {
|
||||
internal class MongoDatabaseMock : IMongoDatabase {
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Mock;
|
||||
|
||||
internal class MongoDatabaseMock : IMongoDatabase {
|
||||
|
||||
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
|
||||
@ -217,5 +219,4 @@ namespace MaksIT.MongoDB.Linq.Tests.Mock {
|
||||
#endregion
|
||||
|
||||
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,10 @@ using MongoDB.Driver;
|
||||
using MongoDB.Driver.Core.Bindings;
|
||||
using MongoDB.Driver.Core.Clusters;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests {
|
||||
internal class MongoSessionMock : IClientSessionHandle {
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests;
|
||||
|
||||
internal class MongoSessionMock : IClientSessionHandle {
|
||||
|
||||
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
|
||||
@ -89,5 +91,4 @@ namespace MaksIT.MongoDB.Linq.Tests {
|
||||
#endregion
|
||||
|
||||
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
}
|
||||
}
|
||||
@ -3,8 +3,10 @@
|
||||
using MaksIT.Results;
|
||||
using MaksIT.MongoDB.Linq.Tests.Mock;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests {
|
||||
public class MongoSessionManagerTests {
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests;
|
||||
|
||||
public class MongoSessionManagerTests {
|
||||
|
||||
private readonly MongoSessionManager _sessionManager;
|
||||
private readonly ILogger<MongoSessionManager> _logger;
|
||||
@ -62,5 +64,4 @@ namespace MaksIT.MongoDB.Linq.Tests {
|
||||
// Assert
|
||||
Assert.False(result.IsSuccess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
using MaksIT.MongoDB.Linq.Utilities;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Utilities {
|
||||
public class CombGuidGeneratorTests {
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Tests.Utilities;
|
||||
|
||||
public class CombGuidGeneratorTests {
|
||||
[Fact]
|
||||
public void CreateCombGuid_WithCurrentTimestamp_ShouldGenerateGuid() {
|
||||
// Act
|
||||
@ -77,5 +79,4 @@ namespace MaksIT.MongoDB.Linq.Tests.Utilities {
|
||||
var exception = Record.Exception(() => CombGuidGenerator.ExtractTimestamp(invalidGuid));
|
||||
Assert.Null(exception); // Adjusted expectation based on behavior of `ExtractTimestamp` with a regular GUID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,8 +7,9 @@ using MaksIT.Core.Abstractions.Dto;
|
||||
using MaksIT.Results;
|
||||
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Abstractions {
|
||||
public abstract class BaseCollectionDataProviderBase<T, TDtoDocument, TDtoKey> : DataProviderBase<T>
|
||||
namespace MaksIT.MongoDB.Linq.Abstractions;
|
||||
|
||||
public abstract class BaseCollectionDataProviderBase<T, TDtoDocument, TDtoKey> : DataProviderBase<T>
|
||||
where TDtoDocument : DtoDocumentBase<TDtoKey> {
|
||||
|
||||
protected readonly IMongoCollection<TDtoDocument> Collection;
|
||||
@ -236,5 +237,5 @@ namespace MaksIT.MongoDB.Linq.Abstractions {
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,9 +7,10 @@ using MongoDB.Driver;
|
||||
using MaksIT.Results;
|
||||
using MaksIT.Core.Abstractions.Dto;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Abstractions {
|
||||
|
||||
public abstract class CollectionDataProviderBase<T, TDtoDocument, TDtoKey> : BaseCollectionDataProviderBase<T, TDtoDocument, TDtoKey>
|
||||
namespace MaksIT.MongoDB.Linq.Abstractions;
|
||||
|
||||
public abstract class CollectionDataProviderBase<T, TDtoDocument, TDtoKey> : BaseCollectionDataProviderBase<T, TDtoDocument, TDtoKey>
|
||||
where TDtoDocument : DtoDocumentBase<TDtoKey> {
|
||||
|
||||
protected CollectionDataProviderBase(
|
||||
@ -122,5 +123,4 @@ namespace MaksIT.MongoDB.Linq.Abstractions {
|
||||
protected Result DeleteManyWithPredicate(Expression<Func<TDtoDocument, bool>> predicate, IClientSessionHandle? session) =>
|
||||
DeleteManyWithPredicateAsync(predicate, session).Result;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Abstractions {
|
||||
public abstract class DataProviderBase<T> {
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Abstractions;
|
||||
|
||||
public abstract class DataProviderBase<T> {
|
||||
protected readonly ILogger<T> Logger;
|
||||
protected readonly IMongoDatabase Database;
|
||||
private readonly IMongoClient _client;
|
||||
@ -15,5 +17,4 @@ namespace MaksIT.MongoDB.Linq.Abstractions {
|
||||
_client = client;
|
||||
Database = _client.GetDatabase(databaseName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>MaksIT.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||
<RootNamespace>$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||
|
||||
<!-- NuGet package metadata -->
|
||||
<PackageId>MaksIT.MongoDB.Linq</PackageId>
|
||||
<Version>1.1.1</Version>
|
||||
<Version>1.1.2</Version>
|
||||
<Authors>Maksym Sadovnychyy</Authors>
|
||||
<Company>MAKS-IT</Company>
|
||||
<Product>MaksIT.MongoDB.Linq</Product>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
|
||||
|
||||
namespace MaksIT.MongoDB.Linq {
|
||||
public class DisposableMongoSession : IDisposable {
|
||||
|
||||
@ -4,7 +4,7 @@ using MongoDB.Bson.Serialization;
|
||||
using MongoDB.Bson.Serialization.Serializers;
|
||||
|
||||
|
||||
namespace MaksIT.MaksIT.MongoDB.Linq.Serializers;
|
||||
namespace MaksIT.MongoDB.Linq.Serializers;
|
||||
|
||||
public class GuidKeyDictionarySerializer<TValue> : SerializerBase<Dictionary<Guid, TValue>> {
|
||||
public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, Dictionary<Guid, TValue> value) {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Buffers.Binary;
|
||||
|
||||
namespace MaksIT.MongoDB.Linq.Utilities {
|
||||
public static class CombGuidGenerator {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user