CoreIntegrationTests refactored and passing.

This commit is contained in:
alexandre-spieser
2018-02-10 18:16:14 +00:00
parent 9fc74fc28e
commit 40ff874cf6
29 changed files with 2061 additions and 1353 deletions
@@ -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()