void Do_Put_Contains_Remove_WithDelta()
        {
            try
            {
                CacheHelper.DCache.TypeRegistry.RegisterType(DeltaEx.create, 1);
            }
            catch (IllegalStateException)
            {
                //do nothng
            }
            string  cKey = m_keys[0];
            DeltaEx val  = new DeltaEx();
            IRegion <object, object> reg = CacheHelper.GetRegion <object, object>("DistRegionAck");

            reg[cKey] = (object)val;
            val.SetDelta(true);
            reg[cKey] = (object)val;

            DeltaEx val1 = new DeltaEx(0); // In this case JAVA side will throw invalid DeltaException

            reg[cKey] = (object)val1;
            val1.SetDelta(true);
            reg[cKey] = (object)val1;
            if (DeltaEx.ToDeltaCount != 2)
            {
                Util.Log("DeltaEx.ToDataCount = " + DeltaEx.ToDataCount);
                Assert.Fail(" Delta count should have been 2, is " + DeltaEx.ToDeltaCount);
            }
            if (DeltaEx.ToDataCount != 3)
            {
                Assert.Fail("Data count should have been 3, is " + DeltaEx.ToDataCount);
            }
            DeltaEx.ToDeltaCount   = 0;
            DeltaEx.ToDataCount    = 0;
            DeltaEx.FromDataCount  = 0;
            DeltaEx.FromDeltaCount = 0;

            // Try Contains with key & value that are present. Result should be true.
            KeyValuePair <object, object> myentry = new KeyValuePair <object, object>(cKey, val1);
            bool containsOpflag = reg.Contains(myentry);

            Assert.IsTrue(containsOpflag, "Result should be true as key & value are present");

            // Try Remove with key & value that are present. Result should be true.
            bool removeOpflag = reg.Remove(cKey);

            Assert.IsTrue(removeOpflag, "Result should be true as key & value are present");

            //Check Contains with removed entry. Result should be false.
            bool updatedcontainsOpflag = reg.Contains(myentry);

            Assert.IsFalse(updatedcontainsOpflag, "Result should be false as key & value are removed");
        }
Ejemplo n.º 2
0
        public Task RequestNavigateAsync(IRegion region, ReactiveViewModel navigationTarget, INavigationParameters parameters)
        {
            if (region == null)
            {
                throw new ArgumentNullException("region", "region is null.");
            }
            if (navigationTarget == null)
            {
                throw new ArgumentNullException("navigationTarget", "navigationTarget is null.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters", "parameters is null.");
            }
            if (!region.Contains(navigationTarget))
            {
                throw new ArgumentException("navigationTarget does not belong to region");
            }

            return(RequestNavigateAsyncInternal(region, navigationTarget, parameters));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the <c>next</c> step to this WalkingQueue.
        /// </summary>
        /// <param name="mob">The mob.</param>
        /// <param name="current">The current <see cref="Position"/>.</param>
        /// <param name="next">The next Position.</param>
        private void AddStep(Mob mob, Position current, Position next)
        {
            int nextX = next.X, nextY = next.Y, height = next.Height;
            int deltaX = nextX - current.X;
            int deltaY = nextY - current.Y;

            int     max    = Math.Max(Math.Abs(deltaX), Math.Abs(deltaY));
            IRegion region = _regionRepository.FromPosition(current);

            for (int count = 0; count < max; count++)
            {
                if (deltaX < 0)
                {
                    deltaX++;
                }
                else if (deltaX > 0)
                {
                    deltaX--;
                }

                if (deltaY < 0)
                {
                    deltaY++;
                }
                else if (deltaY > 0)
                {
                    deltaY--;
                }

                Position step = new Position(nextX - deltaX, nextY - deltaY, height);
                if (!region.Contains(step))
                {
                    region = _regionRepository.FromPosition(step);
                }

                mob.WalkingQueue.Points.AddToBack(step);
            }
        }