示例#1
0
 public void DeleteByMultipleId() {
     var ids = new[] {"123", "456"};
     var conn = new Mocks.MSolrConnection();
     var xml = string.Format("<delete><id>{0}</id><id>{1}</id></delete>", ids[0], ids[1]);
     conn.post = conn.post.Args("/update", xml);
     var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, null, null), null);
     cmd.Execute(conn);
     Assert.AreEqual(1, conn.post.Calls);
 }
示例#2
0
		public void DeleteById() {
			const string id = "123123";
		    var conn = new Mocks.MSolrConnection();
		    conn.post = conn.post
		        .Args("/update", string.Format("<delete><id>{0}</id></delete>", id));
            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(new[] { id }, null, null), null);
            cmd.Execute(conn);
            Assert.AreEqual(1, conn.post.Calls);
        }
示例#3
0
 public void DeleteByMultipleId()
 {
     var ids = new[] {"123", "456"};
     var mocks = new MockRepository();
     var conn = mocks.StrictMock<ISolrConnection>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(conn.Post("/update", string.Format("<delete><id>{0}</id><id>{1}</id></delete>", ids[0], ids[1]))).Repeat.Once().Return("");
     }).Verify(delegate {
         var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, null, null));
         cmd.Execute(conn);
     });
 }
示例#4
0
 public void DeleteById()
 {
     const string id = "123123";
     var mocks = new MockRepository();
     var conn = mocks.CreateMock<ISolrConnection>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(conn.Post("/update", string.Format("<delete><id>{0}</id></delete>", id))).Repeat.Once().Return("");
     }).Verify(delegate {
         var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(new[] {id}, null));
         cmd.Execute(conn);
     });
 }
示例#5
0
		public void DeleteByQuery() {
            const string queryString = "someQuery";
		    var q = new SolrQuery(queryString);
            var xml = string.Format("<delete><query>{0}</query></delete>", queryString);

		    var conn = new Mocks.MSolrConnection();
		    conn.post = conn.post.Args("/update", xml);

		    var querySerializer = new Mocks.MSolrQuerySerializer();
		    querySerializer.serialize += _ => queryString;

            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(null, q, querySerializer), null);
            cmd.Execute(conn);

            Assert.AreEqual(1, conn.post.Calls);
		}
示例#6
0
        public void DeleteByIdAndQuery()
        {
            var ids = new[] { "123", "456" };
            const string queryString = "someQuery";
            var xml = string.Format("<delete><id>{0}</id><id>{1}</id><query>{2}</query></delete>", ids[0], ids[1], queryString);
            var conn = new Mocks.MSolrConnection();
            conn.post = conn.post.Args("/update", xml);

            var q = new SolrQuery(queryString);
            var querySerializer = new Mocks.MSolrQuerySerializer();
            querySerializer.serialize += _ => queryString;

            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, q, querySerializer));
            cmd.Execute(conn);

            Assert.AreEqual(1, conn.post.Calls);
        }
示例#7
0
 public void DeleteByIdAndQuery()
 {
     var ids = new[] { "123", "456" };
     var mocks = new MockRepository();
     var conn = mocks.CreateMock<ISolrConnection>();
     var q = mocks.CreateMock<ISolrQuery>();
     With.Mocks(mocks).Expecting(delegate
     {
         const string queryString = "someQuery";
         Expect.Call(q.Query).Repeat.Once().Return(queryString);
         Expect.Call(conn.Post("/update", string.Format("<delete><id>{0}</id><id>{1}</id><query>{2}</query></delete>", ids[0], ids[1], queryString))).Repeat.Once().
             Return("");
     }).Verify(delegate
     {
         var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, q));
         cmd.Execute(conn);
     });
 }
示例#8
0
 public void DeleteByQuery()
 {
     var mocks = new MockRepository();
     var conn = mocks.StrictMock<ISolrConnection>();
     var q = mocks.StrictMock<ISolrQuery>();
     var querySerializer = mocks.StrictMock<ISolrQuerySerializer>();
     With.Mocks(mocks).Expecting(delegate {
         const string queryString = "someQuery";
         Expect.On(conn)
             .Call(conn.Post("/update", string.Format("<delete><query>{0}</query></delete>", queryString)))
             .Repeat.Once()
             .Return("");
         Expect.On(querySerializer)
             .Call(querySerializer.Serialize(null))
             .IgnoreArguments()
             .Return(queryString);
     }).Verify(delegate {
         var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(null, q, querySerializer));
         cmd.Execute(conn);
     });
 }
示例#9
0
 public void DeleteFromCommittedAndFromPending()
 {
     const string id = "123123";
     var mocks = new MockRepository();
     var conn = mocks.StrictMock<ISolrConnection>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.On(conn).Call(conn.Post("/update", string.Format("<delete fromPending=\"false\" fromCommitted=\"false\"><id>{0}</id></delete>", id)))
             .Repeat.Once()
             .Return("");
     }).Verify(delegate {
         var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(new[] { id }, null, null)) {
             FromCommitted = false,
             FromPending = false
         };
         cmd.Execute(conn);
     });
 }
示例#10
0
        public void DeleteFromCommittedAndFromPending()
        {
            const string id = "123123";

            var conn = new Mocks.MSolrConnection();
            var xml = string.Format("<delete fromPending=\"false\" fromCommitted=\"false\"><id>{0}</id></delete>", id);
            conn.post = conn.post.Args("/update", xml);

            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(new[] { id }, null, null), null)
            {
                FromCommitted = false,
                FromPending = false
            };
            cmd.Execute(conn);

            Assert.AreEqual(1, conn.post.Calls);
        }
示例#11
0
 public void ByQuery(ISolrQuery q)
 {
     var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(null, q, GetQuerySerializer()));
     cmd.Execute(connection);
 }
示例#12
0
 public void ByIds(IEnumerable<string> ids)
 {
     var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, null, GetQuerySerializer()));
     cmd.Execute(connection);
 }
示例#13
0
 public void ById(string id)
 {
     var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(new[] { id }, null, GetQuerySerializer()));
     cmd.Execute(connection);
 }
示例#14
0
 public void ByQuery(ISolrQuery q)
 {
     var cmd = new DeleteCommand(new DeleteByQueryParam(q));
     cmd.Execute(connection);
 }
示例#15
0
 public void ByIds(IEnumerable<string> ids)
 {
     var cmd = new DeleteCommand(new DeleteByMultipleIdParam(ids));
     cmd.Execute(connection);
 }
示例#16
0
 public void ById(string id)
 {
     var cmd = new DeleteCommand(new DeleteByMultipleIdParam(new[] {id}));
     cmd.Execute(connection);
 }