//[ExpectedException(typeof (SolrNetException))] public void DeleteDocumentWithoutUniqueKey_ShouldThrow() { var mapper = new MReadOnlyMappingManager(); mapper.getUniqueKey += t => { Assert.Equal(typeof(TestDocumentWithoutUniqueKey), t); return(null); }; var ops = new SolrServer <TestDocumentWithoutUniqueKey>(null, mapper, null); Assert.Throws <SolrNetException>(() => ops.Delete(new TestDocumentWithoutUniqueKey())); Assert.Equal(1, mapper.getUniqueKey.Calls); }
public void DeleteDocumentWithoutUniqueKey_ShouldThrow() { var mocks = new MockRepository(); var basicServer = mocks.StrictMock <ISolrBasicOperations <TestDocumentWithoutUniqueKey> >(); var mapper = mocks.StrictMock <IReadOnlyMappingManager>(); var validationManager = mocks.StrictMock <IMappingValidator>(); With.Mocks(mocks) .Expecting(() => { Expect.On(mapper) .Call(mapper.GetUniqueKey(typeof(TestDocumentWithoutUniqueKey))) .Return(null); }).Verify(() => { var ops = new SolrServer <TestDocumentWithoutUniqueKey>(basicServer, mapper, validationManager); ops.Delete(new TestDocumentWithoutUniqueKey()); }); }
public void DeleteDocumentWithUniqueKey() { var mapper = new MReadOnlyMappingManager(); mapper.getUniqueKey += t => { Assert.AreEqual(typeof(TestDocumentWithUniqueKey), t); return(new SolrFieldModel( property: typeof(TestDocumentWithUniqueKey).GetProperty("id"), fieldName: "id")); }; var basicServer = new MSolrBasicOperations <TestDocumentWithUniqueKey>(); basicServer.delete &= x => x.Stub(); var ops = new SolrServer <TestDocumentWithUniqueKey>(basicServer, mapper, null); ops.Delete(new TestDocumentWithUniqueKey()); Assert.AreEqual(1, mapper.getUniqueKey.Calls); }
public void DeleteByMultipleId() { var connection = new MSolrConnection(); connection.post += (url, content) => { Assert.AreEqual("/update", url); Assert.AreEqual("<delete><id>0</id><id>0</id></delete>", content); return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml")); }; var headerParser = new MSolrHeaderResponseParser(); headerParser.parse += _ => null; var basic = new SolrBasicServer <TestDocumentWithUniqueKey>(connection, null, null, null, headerParser, null, null, null); var ops = new SolrServer <TestDocumentWithUniqueKey>(basic, new AttributesMappingManager(), null); ops.Delete(new[] { new TestDocumentWithUniqueKey(), new TestDocumentWithUniqueKey(), }); Assert.AreEqual(1, connection.post.Calls); }
public void DeleteDocumentWithUniqueKey() { var mocks = new MockRepository(); var basicServer = mocks.StrictMock<ISolrBasicOperations<TestDocumentWithUniqueKey>>(); var mapper = mocks.StrictMock<IReadOnlyMappingManager>(); var validationManager = mocks.StrictMock<IMappingValidator>(); With.Mocks(mocks) .Expecting(() => { Expect.On(basicServer) .Call(basicServer.Delete(new[] {"0"}, null)) .IgnoreArguments() .Return(new ResponseHeader()); Expect.On(mapper) .Call(mapper.GetUniqueKey(typeof (TestDocumentWithUniqueKey))) .Return(new SolrFieldModel { Property = typeof(TestDocumentWithUniqueKey).GetProperty("id"), FieldName = "id" }); }) .Verify(delegate { var ops = new SolrServer<TestDocumentWithUniqueKey>(basicServer, mapper, validationManager); ops.Delete(new TestDocumentWithUniqueKey()); }); }
public void DeleteDocumentWithoutUniqueKey_ShouldThrow() { var mocks = new MockRepository(); var basicServer = mocks.StrictMock<ISolrBasicOperations<TestDocumentWithoutUniqueKey>>(); var mapper = mocks.StrictMock<IReadOnlyMappingManager>(); var validationManager = mocks.StrictMock<IMappingValidator>(); With.Mocks(mocks) .Expecting(() => { Expect.On(mapper) .Call(mapper.GetUniqueKey(typeof (TestDocumentWithoutUniqueKey))) .Return(null); }).Verify(() => { var ops = new SolrServer<TestDocumentWithoutUniqueKey>(basicServer, mapper, validationManager); ops.Delete(new TestDocumentWithoutUniqueKey()); }); }
public void DeleteByMultipleId() { var mocks = new MockRepository(); var connection = mocks.StrictMock<ISolrConnection>(); var headerParser = mocks.StrictMock<ISolrHeaderResponseParser>(); var executer = mocks.StrictMock<ISolrQueryExecuter<TestDocumentWithUniqueKey>>(); var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<TestDocumentWithUniqueKey>>(); var validationManager = mocks.StrictMock<IMappingValidator>(); With.Mocks(mocks) .Expecting(() => { Expect.On(connection) .Call(connection.Post("/update", "<delete><id>0</id><id>0</id></delete>")) .Repeat.Once() .Return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml")); Expect.On(headerParser) .Call(headerParser.Parse(null)) .IgnoreArguments() .Return(new ResponseHeader()); }) .Verify(() => { var basic = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, docSerializer, null, headerParser, null, null, null); var ops = new SolrServer<TestDocumentWithUniqueKey>(basic, new AttributesMappingManager(), validationManager); ops.Delete(new[] { new TestDocumentWithUniqueKey(), new TestDocumentWithUniqueKey(), }); }); }
public void DeleteDocumentWithUniqueKey() { var mocks = new MockRepository(); var basicServer = mocks.CreateMock<ISolrBasicOperations<TestDocumentWithUniqueKey>>(); var mapper = mocks.CreateMock<IReadOnlyMappingManager>(); With.Mocks(mocks) .Expecting(() => { Expect.Call(basicServer.Send(null)) .IgnoreArguments() .Repeat.Once() .Return(""); Expect.Call(mapper.GetUniqueKey(typeof (TestDocumentWithUniqueKey))) .Return(new KeyValuePair<PropertyInfo, string>(typeof (TestDocumentWithUniqueKey).GetProperty("id"), "id")); }) .Verify(delegate { var ops = new SolrServer<TestDocumentWithUniqueKey>(basicServer, mapper); ops.Delete(new TestDocumentWithUniqueKey()); }); }
public void DeleteDocumentWithoutUniqueKey_ShouldThrow() { var mocks = new MockRepository(); var basicServer = mocks.CreateMock<ISolrBasicOperations<TestDocumentWithoutUniqueKey>>(); var mapper = mocks.CreateMock<IReadOnlyMappingManager>(); With.Mocks(mocks) .Expecting(() => { Expect.Call(mapper.GetUniqueKey(typeof (TestDocumentWithoutUniqueKey))) .Throw(new NoUniqueKeyException(typeof(TestDocumentWithoutUniqueKey))); }).Verify(() => { var ops = new SolrServer<TestDocumentWithoutUniqueKey>(basicServer, mapper); ops.Delete(new TestDocumentWithoutUniqueKey()); }); }
public void DeleteByMultipleId() { var mocks = new MockRepository(); var connection = mocks.CreateMock<ISolrConnection>(); var executer = mocks.CreateMock<ISolrQueryExecuter<TestDocumentWithUniqueKey>>(); var docSerializer = mocks.CreateMock<ISolrDocumentSerializer<TestDocumentWithUniqueKey>>(); With.Mocks(mocks) .Expecting(() => Expect.Call(connection.Post("/update", "<delete><id>0</id><id>0</id></delete>")) .Repeat.Once() .Return(null)) .Verify(delegate { var basic = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, docSerializer); var ops = new SolrServer<TestDocumentWithUniqueKey>(basic, new AttributesMappingManager()); ops.Delete(new[] { new TestDocumentWithUniqueKey(), new TestDocumentWithUniqueKey(), }); }); }
public void DeleteDocumentWithUniqueKey() { var mapper = new MReadOnlyMappingManager(); mapper.getUniqueKey += t => { Assert.AreEqual(typeof(TestDocumentWithUniqueKey), t); return new SolrFieldModel { Property = typeof (TestDocumentWithUniqueKey).GetProperty("id"), FieldName = "id", }; }; var basicServer = new MSolrBasicOperations<TestDocumentWithUniqueKey>(); basicServer.delete &= x => x.Stub(); var ops = new SolrServer<TestDocumentWithUniqueKey>(basicServer, mapper, null); ops.Delete(new TestDocumentWithUniqueKey()); Assert.AreEqual(1, mapper.getUniqueKey.Calls); }
public void DeleteDocumentWithoutUniqueKey_ShouldThrow() { var mapper = new MReadOnlyMappingManager(); mapper.getUniqueKey += t => { Assert.AreEqual(typeof(TestDocumentWithoutUniqueKey), t); return null; }; var ops = new SolrServer<TestDocumentWithoutUniqueKey>(null, mapper, null); ops.Delete(new TestDocumentWithoutUniqueKey()); Assert.AreEqual(1, mapper.getUniqueKey.Calls); }
public void DeleteByMultipleId() { var connection = new MSolrConnection(); connection.post += (url, content) => { Assert.AreEqual("/update", url); Assert.AreEqual("<delete><id>0</id><id>0</id></delete>", content); return EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml"); }; var headerParser = new MSolrHeaderResponseParser(); headerParser.parse += _ => null; var basic = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, null, null, null, headerParser, null, null, null); var ops = new SolrServer<TestDocumentWithUniqueKey>(basic, new AttributesMappingManager(), null); ops.Delete(new[] { new TestDocumentWithUniqueKey(), new TestDocumentWithUniqueKey(), }); Assert.AreEqual(1, connection.post.Calls); }