예제 #1
0
        public void MinusOverload_SubtractFromListTwoOverlaps_CountIs3()
        {
            //arrange
            ScratchList <int> testList1 = new ScratchList <int>();
            ScratchList <int> testList2 = new ScratchList <int>();
            int actual;
            int expected = 3;

            testList1.Add(3);
            testList1.Add(8);
            testList1.Add(4);
            testList1.Add(8);
            testList1.Add(8);
            testList2.Add(12);
            testList2.Add(8);
            testList2.Add(8);
            testList2.Add(57);

            //act
            ScratchList <int> diffList = testList1 - testList2;

            actual = diffList.Count;
            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void Remove_RemoveIntAtIndex2_ValueNoLongerInList()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            bool actual;
            bool expected = false;

            testList.Add(2);
            testList.Add(33);
            testList.Add(7);
            testList.Add(12);

            //act
            testList.Remove(testList[2]);
            if (testList[0] == 7 || testList[1] == 7 || testList[2] == 7)
            {
                actual = true;
            }
            else
            {
                actual = false;
            }

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void Zip_Zip2SmallvBigLists_Index7Is7()
        {
            //arrange
            ScratchList <int> list1 = new ScratchList <int>();
            ScratchList <int> list2 = new ScratchList <int>();
            int actual;
            int expected = 6;

            list1.Add(0);
            list1.Add(2);
            list1.Add(4);
            list2.Add(1);
            list2.Add(3);
            list2.Add(5);
            list2.Add(6);
            list2.Add(7);
            list2.Add(8);

            //act
            ScratchList <int> zippedList = list1.Zip(list1, list2);

            actual = zippedList[6];

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #4
0
        public static Mobile Acquire(Predicate <Mobile> validator)
        {
            Mobile player = World.Player;

            if (player != null)
            {
                using (ScratchList <Mobile> scratchList = new ScratchList <Mobile>())
                {
                    List <Mobile>       mobileList          = scratchList.Value;
                    bool                isBola              = false;
                    int                 range               = Engine.ServerFeatures.AOS ? 11 : 12;
                    ServerTargetHandler serverTargetHandler = TargetManager.Active as ServerTargetHandler;
                    if (serverTargetHandler != null && serverTargetHandler.Action == TargetAction.Bola)
                    {
                        isBola = true;
                        range  = 8;
                    }
                    foreach (Mobile mobile in World.Mobiles.Values)
                    {
                        if (mobile.Visible && !mobile.Player && (!mobile.IsDead && TargetManager.IsAcquirable(player, mobile, isBola)) && (player.InRange((IPoint2D)mobile, range) && Map.LineOfSight(player, mobile) && (validator == null || validator(mobile))))
                        {
                            mobileList.Add(mobile);
                        }
                    }
                    if (mobileList.Count > 0)
                    {
                        mobileList.Sort(TargetSorter.Comparer);
                        return(mobileList[0]);
                    }
                }
            }
            return((Mobile)null);
        }
예제 #5
0
    static void DoIt()
    {
        ScratchList list = AssetDatabase.LoadAssetAtPath <ScratchList>("Assets/Scripts/Editor/Tools/ScratchList.asset");

        Selection.activeObject = list;

        //EditorUtility.SetDirty(list);
    }
예제 #6
0
        public void Add_1PositiveInt_Count1()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();

            int item1    = 34;
            int expected = 1;
            int actual;

            //act
            testList.Add(item1);
            actual = testList.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #7
0
        public void ToString_Add3DoublesToList_OutputIs2337()
        {
            //arrange
            ScratchList <double> testList = new ScratchList <double>();
            string actual;
            string expected = "2337";

            testList.Add(2);
            testList.Add(33);
            testList.Add(7);

            //act
            actual = testList.ToString();

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #8
0
        public void Add_2PositiveInt_ValueAtProperIndex()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int item1    = 34;
            int item2    = 13;
            int expected = 13;
            int actual;

            //act
            testList.Add(item1);
            testList.Add(item2);
            actual = testList[1];

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #9
0
        public void ToString_Add3StringsToList_OutputIsSeeSpotRun()
        {
            //arrange
            ScratchList <string> testList = new ScratchList <string>();
            string actual;
            string expected = "SeeSpotRun";

            testList.Add("See");
            testList.Add("Spot");
            testList.Add("Run");

            //act
            actual = testList.ToString();

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #10
0
        public void Add_5PositiveInt_CountIs5()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int expected = 5;
            int actual;

            //act
            testList.Add(2);
            testList.Add(33);
            testList.Add(7);
            testList.Add(12);
            testList.Add(3);
            actual = testList.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #11
0
        public void Add_5PositiveInt_ItemAtIndex2Is7()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int expected = 7;
            int actual;

            //act
            testList.Add(2);
            testList.Add(33);
            testList.Add(7);
            testList.Add(12);
            testList.Add(3);
            actual = testList[2];

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #12
0
        public void Add_5PositiveInt_CapacityIncreasto8()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int expected = 8;
            int actual;

            //act
            testList.Add(2);
            testList.Add(33);
            testList.Add(7);
            testList.Add(12);
            testList.Add(3);
            actual = testList.Capacity;

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #13
0
        public void Remove_Remove1of3ints_countis2()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int actual;
            int expected = 2;

            testList.Add(2);
            testList.Add(33);
            testList.Add(7);

            //act
            testList.Remove(33);
            actual = testList.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #14
0
        public void Remove_RemoveIntAtIndex2_IntAtIndex3IsNowAtIndex2()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int actual;
            int expected = 12;

            testList.Add(2);
            testList.Add(33);
            testList.Add(7);
            testList.Add(12);

            //act
            testList.Remove(testList[2]);
            actual = testList[2];

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #15
0
        public void Remove_Remove4thof5Ints_Index4ValueNowAtIndex3()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int actual;
            int expected = 3;

            testList.Add(2);
            testList.Add(33);
            testList.Add(7);
            testList.Add(12);
            testList.Add(3);

            //act
            testList.Remove(12);
            actual = testList[3];

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #16
0
        public void Remove_UserInputNotInList_ListRemainsUnchanged()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int actual;
            int expected = 6;

            testList.Add(2);
            testList.Add(33);
            testList.Add(7);
            testList.Add(12);
            testList.Add(7);
            testList.Add(3);

            //act
            testList.Remove(5);
            actual = testList.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #17
0
        public void Remove_RemoveRepeatedValue_OnlyEarliestIncidentOfThatValueIsRemoved()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int actual;
            int expected = 7;

            testList.Add(2);
            testList.Add(33);
            testList.Add(7);
            testList.Add(12);
            testList.Add(7);
            testList.Add(3);

            //act
            testList.Remove(7);
            actual = testList[3];

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #18
0
        public void Remove_RemoveRepeatedValue_CountDecreaseBy1()
        {
            //arrange
            ScratchList <int> testList = new ScratchList <int>();
            int actual;
            int expected = 5;

            testList.Add(2);
            testList.Add(33);
            testList.Add(7);
            testList.Add(12);
            testList.Add(7);
            testList.Add(3);

            //act
            testList.Remove(7);
            actual = testList.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #19
0
        public void PlusOverload_AddListOf2IntsAndListOf3Ints_ValueIndex4Is57()
        {
            //arrange
            ScratchList <int> testList1 = new ScratchList <int>();
            ScratchList <int> testList2 = new ScratchList <int>();
            int actual;
            int expected = 57;

            testList1.Add(3);
            testList1.Add(4);
            testList2.Add(8);
            testList2.Add(12);
            testList2.Add(57);

            //act
            ScratchList <int> sumList = testList1 + testList2;

            actual = sumList[4];

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #20
0
        public void PlusOverload_AddListOf3IntsAndListOf2Ints_Capacityis8()
        {
            //arrange
            ScratchList <int> testList1 = new ScratchList <int>();
            ScratchList <int> testList2 = new ScratchList <int>();
            int actual;
            int expected = 8;

            testList1.Add(3);
            testList1.Add(4);
            testList1.Add(8);
            testList2.Add(12);
            testList2.Add(57);

            //act
            ScratchList <int> sumList = testList1 + testList2;

            actual = sumList.Capacity;

            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #21
0
        public void Zip_Zip2EqualSizedLists_Countis6()
        {
            //arrange
            ScratchList <int> list1 = new ScratchList <int>();
            ScratchList <int> list2 = new ScratchList <int>();
            int actual;
            int expected = 6;

            list1.Add(0);
            list1.Add(2);
            list1.Add(4);
            list2.Add(1);
            list2.Add(3);
            list2.Add(5);

            //act
            ScratchList <int> zippedList = list1.Zip(list1, list2);

            actual = zippedList.Count;
            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #22
0
        public void MinusOverload_SubtractFromListWithRepeatedValue_ValueAtIndex2Is8()
        {
            //arrange
            ScratchList <int> testList1 = new ScratchList <int>();
            ScratchList <int> testList2 = new ScratchList <int>();
            int actual;
            int expected = 8;

            testList1.Add(3);
            testList1.Add(8);
            testList1.Add(4);
            testList1.Add(8);
            testList2.Add(12);
            testList2.Add(8);
            testList2.Add(57);

            //act
            ScratchList <int> diffList = testList1 - testList2;

            actual = diffList[2];
            //assert
            Assert.AreEqual(expected, actual);
        }
예제 #23
0
        public void MinusOverload_SubtractFromListOneOverlap_Index2ValueIs5()
        {
            //arrange
            ScratchList <int> testList1 = new ScratchList <int>();
            ScratchList <int> testList2 = new ScratchList <int>();
            int actual;
            int expected = 5;

            testList1.Add(3);
            testList1.Add(8);
            testList1.Add(4);
            testList1.Add(5);
            testList2.Add(8);
            testList2.Add(12);
            testList2.Add(57);

            //act
            ScratchList <int> diffList = testList1 - testList2;

            actual = diffList[2];

            //assert
            Assert.AreEqual(expected, actual);
        }