Skip to content

Commit c33bafe

Browse files
jmdjmd
jmd
authored and
jmd
committed
update test (need to add ALLOT OF TESTS)
1 parent c747c37 commit c33bafe

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

src/DotJEM.Json.Index2.Test/JsonIndexTest.cs

+31-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace DotJEM.Json.Index2.Test;
1313
public class JsonIndexTest
1414
{
1515
[Test]
16-
public async Task SayHello_ReturnsHello()
16+
public async Task Create_AddsDocument()
1717
{
1818
IJsonIndex index = new JsonIndexBuilder("myIndex")
1919
.UsingMemmoryStorage()
@@ -22,16 +22,41 @@ public async Task SayHello_ReturnsHello()
2222
.Build();
2323

2424
IJsonIndexWriter writer = index.CreateWriter();
25-
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type="CAR" }));
26-
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type="CAR" }));
27-
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type="CAR" }));
28-
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type="CAR" }));
29-
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type="CAR" }));
25+
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" }));
26+
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" }));
27+
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" }));
28+
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" }));
29+
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" }));
3030
writer.Commit();
3131

3232
IJsonIndexSearcher? searcher = index.CreateSearcher();
3333
int count = searcher.Search(new TermQuery(new Term("type", "car"))).Count();
3434
//int count = searcher.Search(new MatchAllDocsQuery()).Count();
3535
Assert.AreEqual(5, count);
3636
}
37+
[Test]
38+
public async Task SayHello_ReturnsHello()
39+
{
40+
IJsonIndex index = new JsonIndexBuilder("myIndex")
41+
.UsingMemmoryStorage()
42+
.WithAnalyzer(cfg => new StandardAnalyzer(cfg.Version))
43+
.WithFieldResolver(new FieldResolver("uuid", "type"))
44+
.Build();
45+
46+
IJsonIndexWriter writer = index.CreateWriter();
47+
Guid uuid = Guid.NewGuid();
48+
writer.Update(JObject.FromObject(new { uuid, type = "CAR" }));
49+
writer.Update(JObject.FromObject(new { uuid, type = "CAR" }));
50+
writer.Update(JObject.FromObject(new { uuid, type = "CAR" }));
51+
writer.Update(JObject.FromObject(new { uuid, type = "CAR" }));
52+
writer.Update(JObject.FromObject(new { uuid, type = "CAR" }));
53+
writer.Commit();
54+
55+
56+
57+
IJsonIndexSearcher? searcher = index.CreateSearcher();
58+
//int count = searcher.Search(new TermQuery(new Term("type", "car"))).Count();
59+
int count = searcher.Search(new MatchAllDocsQuery()).Count();
60+
Assert.AreEqual(1, count);
61+
}
3762
}

0 commit comments

Comments
 (0)