public void Insert_OnFullList_ReturnsFalse()
        {
            var list   = new FixedList <int>(2);
            var result = false;

            result = list.Insert(10);
            result = list.Insert(100);
            result = list.Insert(20);

            var firstIndex = list.FindIndex(100);

            //Last append should return false as
            Assert.IsTrue(result == false);
            Assert.IsTrue(list.CurrentSize == list.MaxSize);

            //first item in list should be at index 0
            Assert.IsTrue(firstIndex == 0);
        }
        public void IsEmpty_ReturnsFalse()
        {
            var list = new FixedList <int>();

            list.Insert(10);
            var isEmpty = list.IsEmpty();

            Assert.IsTrue(isEmpty == false);
            Assert.IsTrue(list.CurrentSize == 1);
        }
示例#3
0
        protected void onLeaderMoveStarted(MapObject sender, MoveEventArgs args)
        {
            lastSpots.Insert(0, args.Position);
            targetSpots[Members.Count] = args.Target;

            // switch spot with member/s if he/they is/are standing at the target
            Members.Where(m => m.Position.ToPoint().Equals(args.Target))
            .ToList().ForEach(m => m.move(
                                  args.Position.X - (int)m.Position.X,
                                  args.Position.Y - (int)m.Position.Y,
                                  (x, y, mo) => null));

            // movement is smother if updated immediatley after event call
            Members.ForEach(member => toFormation(member));
        }
        public void FindIndex_ItemFound_ReturnsIndexOfFoundItem()
        {
            var list = new FixedList <int>();

            list.Append(10);
            list.Append(100);
            list.Insert(45);
            list.InsertAfter(45, 60);
            list.InsertBefore(60, 85);

            //85 should be the second item
            var foundItem = list.FindIndex(85);

            Assert.IsTrue(foundItem == 1);
        }
        public void Insert_ReturnsTrue()
        {
            var list   = new FixedList <int>();
            var result = list.Insert(10);

            var firstItem = list.FindIndex(10);


            //Check to see if the size is 1
            Assert.IsTrue(list.CurrentSize == 1);

            //Result should be true
            Assert.IsTrue(result == true);

            //first Item should be at index 0
            Assert.IsTrue(firstItem == 0);
        }