forked from litedb-org/LiteDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DropCollection_Tests.cs
50 lines (42 loc) · 1.36 KB
/
DropCollection_Tests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Linq;
using FluentAssertions;
using Xunit;
namespace LiteDB.Tests.Engine
{
public class DropCollection_Tests
{
[Fact]
public void DropCollection()
{
using (var file = new TempFile())
using (var db = new LiteDatabase(file.Filename))
{
db.GetCollectionNames().Should().NotContain("col");
var col = db.GetCollection("col");
col.Insert(new BsonDocument {["a"] = 1});
db.GetCollectionNames().Should().Contain("col");
db.DropCollection("col");
db.GetCollectionNames().Should().NotContain("col");
}
}
[Fact]
public void InsertDropCollection()
{
using (var file = new TempFile())
{
using (var db = new LiteDatabase(file.Filename))
{
var col = db.GetCollection("test");
col.Insert(new BsonDocument { ["_id"] = 1 });
db.DropCollection("test");
db.Rebuild();
}
using (var db = new LiteDatabase(file.Filename))
{
var col = db.GetCollection("test");
col.Insert(new BsonDocument { ["_id"] = 1 });
}
}
}
}
}