Ejemplo n.º 1
0
 public void ExecuteBasic() {
     var conn = new MSolrConnection();
     conn.post += (url, content) => {
         Assert.AreEqual("/update", url);
         Assert.AreEqual("<optimize />", content);
         Console.WriteLine(content);
         return null;
     };
     var cmd = new OptimizeCommand();
     cmd.Execute(conn);
     Assert.AreEqual(1, conn.post.Calls);
 }
Ejemplo n.º 2
0
 public void ExecuteWithBasicOptions() {
     var conn = new MSolrConnection();
     conn.post += (url, content) => {
         Assert.AreEqual("/update", url);
         Assert.AreEqual("<optimize waitSearcher=\"true\" waitFlush=\"true\" />", content);
         Console.WriteLine(content);
         return null;
     };
     var cmd = new OptimizeCommand {
         WaitFlush = true,
         WaitSearcher = true
     };
     cmd.Execute(conn);
     Assert.AreEqual(1, conn.post.Calls);
 }
Ejemplo n.º 3
0
        public void ExecuteBasic()
        {
            var mocks = new MockRepository();
            var conn = mocks.StrictMock<ISolrConnection>();

            With.Mocks(mocks).Expecting(() =>
            {
                conn.Post("/update","<optimize />");
                LastCall.On(conn).Repeat.Once().Do(new Writer(delegate(string ignored, string s)
                {
                    Console.WriteLine(s);
                    return null;
                }));
            }).Verify(() =>
            {
                var cmd = new OptimizeCommand();
                cmd.Execute(conn);
            });
        }
Ejemplo n.º 4
0
        public void ExecuteWithAllOptions()
        {
            var mocks = new MockRepository();
            var conn = mocks.StrictMock<ISolrConnection>();

            With.Mocks(mocks).Expecting(() =>
            {
                conn.Post("/update", "<optimize waitSearcher=\"true\" waitFlush=\"true\" expungeDeletes=\"true\" maxSegments=\"2\" />");
                LastCall.On(conn).Repeat.Once().Do(new Writer(delegate(string ignored, string s)
                {
                    Console.WriteLine(s);
                    return null;
                }));
            }).Verify(() =>
            {
                var cmd = new OptimizeCommand();
                cmd.MaxSegments = 2;
                cmd.ExpungeDeletes = true;
                cmd.WaitFlush = true;
                cmd.WaitSearcher = true;
                cmd.Execute(conn);
            });
        }