added tests for index handler
This commit is contained in:
@@ -1,16 +1,30 @@
|
||||
using MongoDB.Bson;
|
||||
using System;
|
||||
using MongoDB.Bson.Serialization;
|
||||
using MongoDB.Driver;
|
||||
using MongoDbGenericRepository.Models;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace CoreUnitTests.Infrastructure;
|
||||
|
||||
public static class IndexExtensions
|
||||
{
|
||||
public static bool EqualToJson<TDocument>(this IndexKeysDefinition<TDocument> keys, string json, ITestOutputHelper output)
|
||||
{
|
||||
var indexModelRendered = RenderIndexModelKeys(keys);
|
||||
var result = indexModelRendered.Equals(json, StringComparison.Ordinal);
|
||||
if (!result && output != null)
|
||||
{
|
||||
output.WriteLine($"Expected: {json}");
|
||||
output.WriteLine($"Actual: {indexModelRendered}");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool EqualToJson<TDocument>(this IndexKeysDefinition<TDocument> keys, string json)
|
||||
{
|
||||
var indexModelRendered = RenderIndexModelKeys(keys);
|
||||
return indexModelRendered.Equals(json, System.StringComparison.Ordinal);
|
||||
return indexModelRendered.Equals(json, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static bool EqualTo(this IndexCreationOptions x, CreateIndexOptions y) =>
|
||||
@@ -28,7 +42,7 @@ public static class IndexExtensions
|
||||
x.Background == y.Background &&
|
||||
x.Version == y.Version;
|
||||
|
||||
public static bool EqualTo(this CreateIndexOptions x, IndexCreationOptions y) =>
|
||||
public static bool EqualTo(this CreateIndexOptions x, IndexCreationOptions y) =>
|
||||
x.Unique == y.Unique &&
|
||||
x.TextIndexVersion == y.TextIndexVersion &&
|
||||
x.SphereIndexVersion == y.SphereIndexVersion &&
|
||||
@@ -52,6 +66,4 @@ public static class IndexExtensions
|
||||
var result = indexModelRendered.ToString();
|
||||
return result.Replace(" ", "");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user