forked from litedb-org/LiteDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request litedb-org#2552 from Joy-less/fix-2534
Fix litedb-org#2534
- Loading branch information
Showing
4 changed files
with
153 additions
and
160 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace LiteDB.Tests.Engine; | ||
|
||
public class Recursion_Tests | ||
{ | ||
[Fact] | ||
public void UpdateInFindAll() | ||
{ | ||
Test(collection => | ||
{ | ||
foreach (BsonDocument document in collection.FindAll()) | ||
{ | ||
collection.Update(document); | ||
} | ||
}); | ||
} | ||
[Fact] | ||
public void InsertDeleteInFindAll() | ||
{ | ||
Test(collection => | ||
{ | ||
foreach (BsonDocument document in collection.FindAll()) | ||
{ | ||
BsonValue id = collection.Insert(new BsonDocument()); | ||
collection.Delete(id); | ||
} | ||
}); | ||
} | ||
[Fact] | ||
public void QueryInFindAll() | ||
{ | ||
Test(collection => | ||
{ | ||
foreach (BsonDocument document in collection.FindAll()) | ||
{ | ||
collection.Query().Count(); | ||
} | ||
}); | ||
} | ||
|
||
private void Test(Action<ILiteCollection<BsonDocument>> action) | ||
{ | ||
using LiteDatabase database = new(new ConnectionString() | ||
{ | ||
Filename = "Demo.db", | ||
Connection = ConnectionType.Shared, | ||
}); | ||
|
||
ILiteCollection<BsonDocument> accounts = database.GetCollection("Recursion"); | ||
|
||
if (accounts.Count() < 3) | ||
{ | ||
accounts.Insert(new BsonDocument()); | ||
accounts.Insert(new BsonDocument()); | ||
accounts.Insert(new BsonDocument()); | ||
} | ||
action(accounts); | ||
} | ||
} |
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,30 @@ | ||
using Xunit; | ||
|
||
namespace LiteDB.Tests.Issues; | ||
|
||
public class Issue2534_Tests | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
using LiteDatabase database = new(new ConnectionString() | ||
{ | ||
Filename = "Demo.db", | ||
Connection = ConnectionType.Shared, | ||
}); | ||
|
||
ILiteCollection<BsonDocument> accounts = database.GetCollection("Issue2534"); | ||
|
||
if (accounts.Count() < 3) | ||
{ | ||
accounts.Insert(new BsonDocument()); | ||
accounts.Insert(new BsonDocument()); | ||
accounts.Insert(new BsonDocument()); | ||
} | ||
|
||
foreach (BsonDocument document in accounts.FindAll()) | ||
{ | ||
accounts.Update(document); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.