forked from SolrNet/SolrNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptimizeCommandTests.cs
60 lines (56 loc) · 1.94 KB
/
OptimizeCommandTests.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
51
52
53
54
55
56
57
58
59
60
using System;
using MbUnit.Framework;
using SolrNet.Commands;
using SolrNet.Tests.Mocks;
namespace SolrNet.Tests {
[TestFixture]
public class OptimizeCommandTests {
[Test]
public void ExecuteBasic() {
var conn = new MSolrConnection();
conn.post += (url, content) => {
Assert.AreEqual("/update", url);
Assert.AreEqual("<optimize />", content);
Console.WriteLine(content);
return null;
};
var cmd = new OptimizeCommand();
cmd.Execute(conn);
Assert.AreEqual(1, conn.post.Calls);
}
[Test]
public void ExecuteWithBasicOptions() {
var conn = new MSolrConnection();
conn.post += (url, content) => {
Assert.AreEqual("/update", url);
Assert.AreEqual("<optimize waitSearcher=\"true\" waitFlush=\"true\" />", content);
Console.WriteLine(content);
return null;
};
var cmd = new OptimizeCommand {
WaitFlush = true,
WaitSearcher = true
};
cmd.Execute(conn);
Assert.AreEqual(1, conn.post.Calls);
}
[Test]
public void ExecuteWithAllOptions() {
var conn = new MSolrConnection();
conn.post += (url, content) => {
Assert.AreEqual("/update", url);
Assert.AreEqual("<optimize waitSearcher=\"true\" waitFlush=\"true\" expungeDeletes=\"true\" maxSegments=\"2\" />", content);
Console.WriteLine(content);
return null;
};
var cmd = new OptimizeCommand {
MaxSegments = 2,
ExpungeDeletes = true,
WaitFlush = true,
WaitSearcher = true
};
cmd.Execute(conn);
Assert.AreEqual(1, conn.post.Calls);
}
}
}