CoreIntegrationTests refactored and passing.
This commit is contained in:
@@ -11,57 +11,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace IntegrationTests.Infrastructure
|
||||
{
|
||||
public class TestDoc<TKey> : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
[BsonId]
|
||||
public TKey Id { get; set; }
|
||||
public int Version { get; set; }
|
||||
|
||||
public TestDoc()
|
||||
{
|
||||
InitializeFields();
|
||||
Version = 2;
|
||||
Nested = new Nested
|
||||
{
|
||||
SomeDate = DateTime.UtcNow
|
||||
};
|
||||
Children = new List<Child>();
|
||||
}
|
||||
|
||||
public string SomeContent { get; set; }
|
||||
|
||||
public Nested Nested { get; set; }
|
||||
|
||||
public List<Child> Children { get; set; }
|
||||
|
||||
public TId Init<TId>()
|
||||
{
|
||||
var idTypeName = typeof(TKey).Name;
|
||||
switch (idTypeName)
|
||||
{
|
||||
case "Guid":
|
||||
return (TId)(object)Guid.NewGuid();
|
||||
case "Int16":
|
||||
return (TId)(object)GlobalVariables.Random.Next(1, short.MaxValue);
|
||||
case "Int32":
|
||||
return (TId)(object)GlobalVariables.Random.Next(1, int.MaxValue);
|
||||
case "Int64":
|
||||
return (TId)(object)(GlobalVariables.Random.NextLong(1, long.MaxValue));
|
||||
case "String":
|
||||
return (TId)(object)Guid.NewGuid().ToString();
|
||||
default:
|
||||
throw new NotSupportedException($"{idTypeName} is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeFields()
|
||||
{
|
||||
Id = Init<TKey>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[TestFixture]
|
||||
public abstract class MongoDbTKeyDocumentTestBase<T, TKey>
|
||||
where T: TestDoc<TKey>, new()
|
||||
|
||||
Reference in New Issue
Block a user