Exemple #1
0
        public void TestSharedMapBlocks()
        {
            var path = new DirectoryInfo(Path.Combine(RootDirectory.FullName, "API_SharedMapBlocks"));
            var mgr  = new Manager(path, Manager.DefaultOptions);
            var db   = mgr.GetDatabase("db");

            db.Open();
            db.SetFilter("phil", (r, p) => true);
            db.SetValidation("val", (p1, p2) => true);

            var view = db.GetView("view");
            var ok   = view.SetMapReduce((p1, p2) => { return; }, (a, b, c) => { return(null); }, "1");

            Assert.IsNotNull(ok, "Couldn't set map/reduce");

            var map        = view.Map;
            var reduce     = view.Reduce;
            var filter     = db.GetFilter("phil");
            var validation = db.GetValidation("val");
            var result     = mgr.RunAsync((database) =>
            {
                Assert.IsNotNull(database);
                var serverView = database.GetExistingView("view");
                Assert.IsNotNull(serverView);
                Assert.AreEqual(database.GetFilter("phil"), filter);
                Assert.AreEqual(database.GetValidation("val"), validation);
                Assert.AreEqual(serverView.Map, map);
                Assert.AreEqual(serverView.Reduce, reduce);
            }, db);

            result.Wait(TimeSpan.FromSeconds(5));
            // blocks until async task has run
            db.Close();
            mgr.Close();
        }
        public void TestSharedMapBlocks()
        {
            var path = new DirectoryInfo(Path.Combine(RootDirectory.FullName, "API_SharedMapBlocks"));
            var mgr = new Manager(path, Manager.DefaultOptions);
            var db = mgr.GetDatabase("db");

            db.Open();
            db.SetFilter("phil", (r, p) => true);
            db.SetValidation("val", (p1, p2) => true);

            var view = db.GetView("view");
            var ok = view.SetMapReduce((p1, p2)=>{ return; }, (a, b, c) => { return null; }, "1");

            Assert.IsNotNull(ok, "Couldn't set map/reduce");

            var map = view.Map;
            var reduce = view.Reduce;
            var filter = db.GetFilter("phil");
            var validation = db.GetValidation("val");
            var result = mgr.RunAsync("db", (database)=>
                {
                    Assert.IsNotNull(database);
                    var serverView = database.GetExistingView("view");
                    Assert.IsNotNull(serverView);
                    Assert.AreEqual(database.GetFilter("phil"), filter);
                    Assert.AreEqual(database.GetValidation("val"), validation);
                    Assert.AreEqual(serverView.Map, map);
                    Assert.AreEqual(serverView.Reduce, reduce);
                    return true;
                });
            result.Wait(TimeSpan.FromSeconds(5));
            // blocks until async task has run
            db.Close();
            mgr.Close();
        }
Exemple #3
0
		/// <summary>
		/// Make sure that a database's map/reduce functions are shared with the shadow database instance
		/// running in the background server.
		/// </summary>
		/// <remarks>
		/// Make sure that a database's map/reduce functions are shared with the shadow database instance
		/// running in the background server.
		/// </remarks>
		/// <exception cref="System.Exception"></exception>
		public virtual void TestSharedMapBlocks()
		{
			Manager mgr = new Manager(new FilePath(GetRootDirectory(), "API_SharedMapBlocks")
				, Manager.DefaultOptions);
			Database db = mgr.GetDatabase("db");
			db.Open();
			db.SetFilter("phil", new _ReplicationFilter_931());
			db.SetValidation("val", new _Validator_938());
			View view = db.GetView("view");
			bool ok = view.SetMapReduce(new _Mapper_945(), new _Reducer_950(), "1");
			NUnit.Framework.Assert.IsNotNull("Couldn't set map/reduce", ok);
			Mapper map = view.GetMap();
			Reducer reduce = view.GetReduce();
			ReplicationFilter filter = db.GetFilter("phil");
			Validator validation = db.GetValidation("val");
			Future result = mgr.RunAsync("db", new _AsyncTask_965(filter, validation, map, reduce
				));
			result.Get();
			// blocks until async task has run
			db.Close();
			mgr.Close();
		}