private void AddToIndexTest(bool isValid = true) { var mockedBulkResponse = new Mock <BulkResponse>(); mockedBulkResponse. Setup(mockedResponse => mockedResponse.IsValid). Returns(isValid); mockedClient. Setup(mockedClient => mockedClient.Bulk(It.IsAny <BulkDescriptor>())). Returns(mockedBulkResponse.Object); var elasticIndex = new PeopleIndex("test5", mockedClient.Object); elasticIndex.AddToIndex(new List <Person> { new Person { Age = 26, EyeColor = "color", Name = "fname lname", PersonGender = true, Company = "Comp", Email = "*****@*****.**", Phone = "+982 55( 555)15", Address = "address add ress 45788", About = "this is about", RegistrationDate = "2015/02/16 11:11:31", Location = "-21.208613,-148.208613" } }); }
//todo: mocking indices.Create seems to be impossible, try to find a way around this issue. private void CreateIndexTest(bool isValid = true) { var mockedCreateresponse = new Mock <CreateIndexResponse>(); mockedCreateresponse. Setup(response => response.IsValid). Returns(isValid); var mockedIndices = new Mock <IndicesNamespace>(); mockedIndices. Setup(indices => indices.Create(It.IsAny <string>(), It.IsAny <Func <CreateIndexDescriptor, ICreateIndexRequest> >())). Returns(mockedCreateresponse.Object); mockedClient. Setup(mockedClient => mockedClient.Indices). Returns(mockedIndices.Object); var index = new PeopleIndex("test3", mockedClient.Object); index.CreateIndex(); }