-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
7,108 additions
and
1,158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using IntegrationTests.Infrastructure; | ||
using MongoDB.Bson.Serialization.Attributes; | ||
using MongoDbGenericRepository.Models; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace IntegrationTests | ||
{ | ||
public class CreateTestsPartitionedTKeyDocument : IDocument<Guid>, IPartitionedDocument | ||
{ | ||
[BsonId] | ||
public Guid Id { get; set; } | ||
public int Version { get; set; } | ||
public CreateTestsPartitionedTKeyDocument() | ||
{ | ||
Id = Guid.NewGuid(); | ||
Version = 2; | ||
PartitionKey = "TestPartitionKey"; | ||
} | ||
public string PartitionKey { get; set; } | ||
public string SomeContent { get; set; } | ||
} | ||
|
||
public class CreatePartitionedTKeyTests : BaseMongoDbRepositoryTests<CreateTestsPartitionedTKeyDocument> | ||
{ | ||
[Test] | ||
public void PartitionedAddOne() | ||
{ | ||
// Arrange | ||
var document = new CreateTestsPartitionedTKeyDocument(); | ||
// Act | ||
SUT.AddOne<CreateTestsPartitionedTKeyDocument, Guid>(document); | ||
// Assert | ||
long count = SUT.Count<CreateTestsPartitionedTKeyDocument, Guid>(e => e.Id == document.Id, PartitionKey); | ||
Assert.AreEqual(1, count); | ||
} | ||
|
||
[Test] | ||
public async Task PartitionedAddOneAsync() | ||
{ | ||
// Arrange | ||
var document = new CreateTestsPartitionedTKeyDocument(); | ||
// Act | ||
await SUT.AddOneAsync<CreateTestsPartitionedTKeyDocument, Guid>(document); | ||
// Assert | ||
long count = SUT.Count<CreateTestsPartitionedTKeyDocument, Guid>(e => e.Id == document.Id, PartitionKey); | ||
Assert.AreEqual(1, count); | ||
} | ||
|
||
[Test] | ||
public void PartitionedAddMany() | ||
{ | ||
// Arrange | ||
var documents = new List<CreateTestsPartitionedTKeyDocument> { new CreateTestsPartitionedTKeyDocument(), new CreateTestsPartitionedTKeyDocument() }; | ||
// Act | ||
SUT.AddMany<CreateTestsPartitionedTKeyDocument, Guid>(documents); | ||
// Assert | ||
long count = SUT.Count<CreateTestsPartitionedTKeyDocument, Guid>(e => e.Id == documents[0].Id || e.Id == documents[1].Id, PartitionKey); | ||
Assert.AreEqual(2, count); | ||
} | ||
|
||
[Test] | ||
public async Task PartitionedAddManyAsync() | ||
{ | ||
// Arrange | ||
var documents = new List<CreateTestsPartitionedTKeyDocument> { new CreateTestsPartitionedTKeyDocument(), new CreateTestsPartitionedTKeyDocument() }; | ||
// Act | ||
await SUT.AddManyAsync<CreateTestsPartitionedTKeyDocument, Guid>(documents); | ||
// Assert | ||
long count = SUT.Count<CreateTestsPartitionedTKeyDocument, Guid>(e => e.Id == documents[0].Id || e.Id == documents[1].Id, PartitionKey); | ||
Assert.AreEqual(2, count); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using IntegrationTests.Infrastructure; | ||
using MongoDB.Bson.Serialization.Attributes; | ||
using MongoDbGenericRepository.Models; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace IntegrationTests | ||
{ | ||
public class CreateTestsTKeyDocument : IDocument<Guid> | ||
{ | ||
[BsonId] | ||
public Guid Id { get; set; } | ||
public int Version { get; set; } | ||
public CreateTestsTKeyDocument() | ||
{ | ||
Id = Guid.NewGuid(); | ||
Version = 2; | ||
} | ||
public string SomeContent { get; set; } | ||
} | ||
|
||
[TestFixture] | ||
public class CreateTKeyTests : BaseMongoDbRepositoryTests<CreateTestsTKeyDocument> | ||
{ | ||
[Test] | ||
public void TKeyAddOne() | ||
{ | ||
// Arrange | ||
var document = new CreateTestsTKeyDocument(); | ||
// Act | ||
SUT.AddOne<CreateTestsTKeyDocument, Guid>(document); | ||
// Assert | ||
long count = SUT.Count<CreateTestsTKeyDocument, Guid>(e => e.Id == document.Id); | ||
Assert.AreEqual(1, count); | ||
} | ||
|
||
[Test] | ||
public async Task TKeyAddOneAsync() | ||
{ | ||
// Arrange | ||
var document = new CreateTestsTKeyDocument(); | ||
// Act | ||
await SUT.AddOneAsync<CreateTestsTKeyDocument, Guid>(document); | ||
// Assert | ||
long count = SUT.Count<CreateTestsTKeyDocument, Guid>(e => e.Id == document.Id); | ||
Assert.AreEqual(1, count); | ||
} | ||
|
||
[Test] | ||
public void TKeyAddMany() | ||
{ | ||
// Arrange | ||
var documents = new List<CreateTestsTKeyDocument> { new CreateTestsTKeyDocument(), new CreateTestsTKeyDocument() }; | ||
// Act | ||
SUT.AddMany<CreateTestsTKeyDocument, Guid>(documents); | ||
// Assert | ||
long count = SUT.Count<CreateTestsTKeyDocument, Guid>(e => e.Id == documents[0].Id || e.Id == documents[1].Id); | ||
Assert.AreEqual(2, count); | ||
} | ||
|
||
[Test] | ||
public async Task TKeyAddManyAsync() | ||
{ | ||
// Arrange | ||
var documents = new List<CreateTestsTKeyDocument> { new CreateTestsTKeyDocument(), new CreateTestsTKeyDocument() }; | ||
// Act | ||
await SUT.AddManyAsync<CreateTestsTKeyDocument, Guid>(documents); | ||
// Assert | ||
long count = SUT.Count<CreateTestsTKeyDocument, Guid>(e => e.Id == documents[0].Id || e.Id == documents[1].Id); | ||
Assert.AreEqual(2, count); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
using IntegrationTests.Infrastructure; | ||
using MongoDB.Bson.Serialization.Attributes; | ||
using MongoDbGenericRepository.Models; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace IntegrationTests | ||
{ | ||
public class DeleteTestsPartitionedTKeyDocument : IPartitionedDocument, IDocument<Guid> | ||
{ | ||
[BsonId] | ||
public Guid Id { get; set; } | ||
public int Version { get; set; } | ||
public DeleteTestsPartitionedTKeyDocument() | ||
{ | ||
Id = Guid.NewGuid(); | ||
Version = 2; | ||
PartitionKey = "TestPartitionKey"; | ||
} | ||
public string PartitionKey { get; set; } | ||
public string SomeContent { get; set; } | ||
} | ||
|
||
public class DeletePartitionedTKeyTests : BaseMongoDbRepositoryTests<DeleteTestsPartitionedTKeyDocument> | ||
{ | ||
[Test] | ||
public void PartitionedDeleteOne() | ||
{ | ||
// Arrange | ||
var document = CreateTestDocument(); | ||
SUT.AddOne<DeleteTestsPartitionedTKeyDocument, Guid>(document); | ||
// Act | ||
var result = SUT.DeleteOne<DeleteTestsPartitionedTKeyDocument, Guid>(document); | ||
// Assert | ||
Assert.AreEqual(1, result); | ||
Assert.IsFalse(SUT.Any<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.Id == document.Id, PartitionKey)); | ||
} | ||
|
||
[Test] | ||
public void PartitionedDeleteOneLinq() | ||
{ | ||
// Arrange | ||
var document = CreateTestDocument(); | ||
SUT.AddOne<DeleteTestsPartitionedTKeyDocument, Guid>(document); | ||
// Act | ||
var result = SUT.DeleteOne<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.Id == document.Id, PartitionKey); | ||
// Assert | ||
Assert.AreEqual(1, result); | ||
Assert.IsFalse(SUT.Any<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.Id == document.Id, PartitionKey)); | ||
} | ||
|
||
[Test] | ||
public async Task PartitionedDeleteOneAsync() | ||
{ | ||
// Arrange | ||
var document = CreateTestDocument(); | ||
SUT.AddOne<DeleteTestsPartitionedTKeyDocument, Guid>(document); | ||
// Act | ||
var result = await SUT.DeleteOneAsync<DeleteTestsPartitionedTKeyDocument, Guid>(document); | ||
// Assert | ||
Assert.AreEqual(1, result); | ||
Assert.IsFalse(SUT.Any<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.Id == document.Id, PartitionKey)); | ||
} | ||
|
||
[Test] | ||
public async Task PartitionedDeleteOneAsyncLinq() | ||
{ | ||
// Arrange | ||
var document = CreateTestDocument(); | ||
SUT.AddOne<DeleteTestsPartitionedTKeyDocument, Guid>(document); | ||
// Act | ||
var result = await SUT.DeleteOneAsync<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.Id == document.Id, PartitionKey); | ||
// Assert | ||
Assert.AreEqual(1, result); | ||
Assert.IsFalse(SUT.Any<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.Id == document.Id, PartitionKey)); | ||
} | ||
|
||
[Test] | ||
public async Task PartitionedDeleteManyAsyncLinq() | ||
{ | ||
// Arrange | ||
var documents = CreateTestDocuments(5); | ||
documents.ForEach(e => e.SomeContent = "DeleteManyAsyncLinqContent"); | ||
SUT.AddMany<DeleteTestsPartitionedTKeyDocument, Guid>(documents); | ||
// Act | ||
var result = await SUT.DeleteManyAsync<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.SomeContent == "DeleteManyAsyncLinqContent", PartitionKey); | ||
// Assert | ||
Assert.AreEqual(5, result); | ||
Assert.IsFalse(SUT.Any<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.SomeContent == "DeleteManyAsyncLinqContent", PartitionKey)); | ||
} | ||
|
||
[Test] | ||
public async Task PartitionedDeleteManyAsync() | ||
{ | ||
// Arrange | ||
var documents = CreateTestDocuments(5); | ||
documents.ForEach(e => e.SomeContent = "DeleteManyAsyncLinqContent"); | ||
SUT.AddMany<DeleteTestsPartitionedTKeyDocument, Guid>(documents); | ||
// Act | ||
var result = await SUT.DeleteManyAsync<DeleteTestsPartitionedTKeyDocument, Guid>(documents); | ||
// Assert | ||
Assert.AreEqual(5, result); | ||
Assert.IsFalse(SUT.Any<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.SomeContent == "DeleteManyAsyncLinqContent", PartitionKey)); | ||
} | ||
|
||
[Test] | ||
public void PartitionedDeleteManyLinq() | ||
{ | ||
// Arrange | ||
var content = "DeleteManyLinqContent"; | ||
var documents = CreateTestDocuments(5); | ||
documents.ForEach(e => e.SomeContent = content); | ||
SUT.AddMany<DeleteTestsPartitionedTKeyDocument, Guid>(documents); | ||
// Act | ||
var result = SUT.DeleteMany<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.SomeContent == content, PartitionKey); | ||
// Assert | ||
Assert.AreEqual(5, result); | ||
Assert.IsFalse(SUT.Any<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.SomeContent == content, PartitionKey)); | ||
} | ||
|
||
[Test] | ||
public void PartitionedDeleteMany() | ||
{ | ||
// Arrange | ||
var content = "DeleteManyContent"; | ||
var documents = CreateTestDocuments(5); | ||
documents.ForEach(e => e.SomeContent = content); | ||
SUT.AddMany<DeleteTestsPartitionedTKeyDocument, Guid>(documents); | ||
// Act | ||
var result = SUT.DeleteMany<DeleteTestsPartitionedTKeyDocument, Guid>(documents); | ||
// Assert | ||
Assert.AreEqual(5, result); | ||
Assert.IsFalse(SUT.Any<DeleteTestsPartitionedTKeyDocument, Guid>(e => e.SomeContent == content, PartitionKey)); | ||
} | ||
} | ||
} |
Oops, something went wrong.