public async Task AddDocuments() { MeilisearchDotnet.Types.EnqueuedUpdate q = await index.AddDocuments <DocTest>(docs); await index.WaitForPendingUpdate(q.UpdateId); List <DocTest> result = await index.GetDocuments <List <DocTest> >(); result.Sort(delegate(DocTest a, DocTest b) { return(string.Compare(a.Id, b.Id)); }); Assert.Equal(JsonSerializer.Serialize(docs), JsonSerializer.Serialize(result)); DocTest newDoc = new DocTest { Id = "10", Date = new DateTime(2020, 1, 1), Ndouble = 3.4, Nint = 4, SubDocTest = new SubDocTest[] { new SubDocTest { str = "abcd" }, new SubDocTest { str = "efgh" } } }; docs.Add(newDoc); docs.Sort(delegate(DocTest a, DocTest b) { return(string.Compare(a.Id, b.Id)); }); q = await index.AddDocuments <DocTest>(new List <DocTest> { newDoc }); await index.WaitForPendingUpdate(q.UpdateId); result = await index.GetDocuments <List <DocTest> >(); result.Sort(delegate(DocTest a, DocTest b) { return(string.Compare(a.Id, b.Id)); }); Assert.Equal(JsonSerializer.Serialize(docs), JsonSerializer.Serialize(result)); }
public async Task UpdateDocuments() { List <DocTest> newDocs = new List <DocTest> { new DocTest { Id = "0", Date = DateTime.MinValue, Ndouble = 5, Nint = 3, SubDocTest = new SubDocTest[] { new SubDocTest { str = "abcd" }, new SubDocTest { str = "efgh" } } }, new DocTest { Id = "1", Date = DateTime.MinValue, Ndouble = 0.4, Nint = 42, SubDocTest = new SubDocTest[] { new SubDocTest { str = "dcba" } } }, new DocTest { Id = "2", Date = DateTime.MinValue, Ndouble = 0.55555, Nint = 4, SubDocTest = new SubDocTest[] { new SubDocTest { str = "deadbeef" }, new SubDocTest { str = "coucou" }, new SubDocTest { str = "a" } } }, new DocTest { Id = "3", Date = DateTime.MinValue, Ndouble = 0.42, Nint = 7, SubDocTest = new SubDocTest[] { new SubDocTest { str = "coucou" } } }, new DocTest { Id = "4", Date = DateTime.MinValue, Ndouble = 0.001, Nint = 9, SubDocTest = new SubDocTest[] { new SubDocTest { str = "kekekeke" }, new SubDocTest { str = "kero" } } }, new DocTest { Id = "5", Date = DateTime.MinValue, Ndouble = 3.8, Nint = 2, SubDocTest = new SubDocTest[] { new SubDocTest { str = "abcd" }, new SubDocTest { str = "efgh" } } }, new DocTest { Id = "6", Date = DateTime.MinValue, Ndouble = 1.0, Nint = 3333333, SubDocTest = new SubDocTest[] { new SubDocTest { str = "abcd" }, new SubDocTest { str = "efgh" } } }, new DocTest { Id = "7", Date = DateTime.MinValue, Ndouble = 4.8, Nint = 0, SubDocTest = new SubDocTest[] { new SubDocTest { str = "abcd" }, new SubDocTest { str = "e=e&e %" } } }, new DocTest { Id = "8", Date = new DateTime(2077, 1, 1), Ndouble = 3.4, Nint = 4, SubDocTest = new SubDocTest[] { new SubDocTest { str = "covfefe" }, new SubDocTest { str = "efgh" } } } }; DocTest oneDoc = new DocTest { Id = "9a", Date = new DateTime(2021, 1, 1), Ndouble = 2020.1, Nint = 4, SubDocTest = null }; MeilisearchDotnet.Types.EnqueuedUpdate q = await index.AddDocuments <DocTest>(docs); await index.WaitForPendingUpdate(q.UpdateId); q = await index.UpdateDocuments(newDocs); await index.WaitForPendingUpdate(q.UpdateId); newDocs.Add(oneDoc); newDocs.Sort(delegate(DocTest a, DocTest b) { return(string.Compare(a.Id, b.Id)); }); List <DocTest> result = await index.GetDocuments <List <DocTest> >(); result.Sort(delegate(DocTest a, DocTest b) { return(string.Compare(a.Id, b.Id)); }); Assert.Equal(JsonSerializer.Serialize(newDocs), JsonSerializer.Serialize(result)); }