forked from ravendb/ravendb
/
RavenDB_556.cs
71 lines (59 loc) · 1.76 KB
/
RavenDB_556.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
61
62
63
64
65
66
67
68
69
70
71
namespace Raven.Tests.Issues
{
using System.Linq;
using Raven.Abstractions.Data;
using Raven.Client.Document;
using Xunit;
public class RavenDB_556 : RemoteClientTest
{
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string MiddleName { get; set; }
}
[Fact]
public void IndexEntryFieldShouldNotContainNullValues()
{
using (var server = GetNewServer())
{
using (var docStore = new DocumentStore { Url = "http://localhost:8079" }.Initialize())
{
using (var session = docStore.OpenSession())
{
session.Store(new Person { FirstName = "John", MiddleName = null, LastName = null });
session.Store(new Person { FirstName = "William", MiddleName = "Edgard", LastName = "Smith" });
session.Store(new Person { FirstName = "Paul", MiddleName = null, LastName = "Smith" });
session.SaveChanges();
}
using (var session = docStore.OpenSession())
{
session.Query<Person>()
.Customize(x => x.WaitForNonStaleResults())
.Where(x => x.FirstName == "John" || x.FirstName == "Paul")
.ToList();
var indexes = session
.Advanced
.DocumentStore
.DatabaseCommands
.GetIndexNames(0, 100);
var newIndexes = indexes
.Where(x => x.StartsWith("Temp"));
Assert.Equal(1, newIndexes.Count());
var queryResult = session
.Advanced
.DocumentStore
.DatabaseCommands
.Query(newIndexes.First(), new IndexQuery(), null, false, true);
foreach (var result in queryResult.Results)
{
var q = result["FirstName"].ToString();
Assert.NotNull(q);
Assert.True(new[] { "john", "william", "paul" }.Contains(q));
}
}
}
}
}
}
}