コード例 #1
0
        public void SliceEmptyList()
        {
            UnityEventListenerMock slicedMock = new UnityEventListenerMock();

            subject.Sliced.AddListener(slicedMock.Listen);
            UnityEventListenerMock remainedMock = new UnityEventListenerMock();

            subject.Remained.AddListener(remainedMock.Listen);

            List <CollisionNotifier.EventData> collisionList = new List <CollisionNotifier.EventData>();

            ActiveCollisionsContainer.EventData eventData = new ActiveCollisionsContainer.EventData().Set(collisionList);

            subject.StartIndex = 0;
            subject.Length     = 1;

            Assert.AreEqual("", ActiveCollisionsHelper.GetNamesOfActiveCollisions(eventData));

            Assert.IsFalse(slicedMock.Received);
            Assert.IsFalse(remainedMock.Received);

            ActiveCollisionsContainer.EventData remainedList;
            ActiveCollisionsContainer.EventData slicedList = subject.Slice(eventData, out remainedList);

            Assert.IsTrue(slicedMock.Received);
            Assert.IsTrue(remainedMock.Received);

            Assert.AreEqual("", ActiveCollisionsHelper.GetNamesOfActiveCollisions(slicedList));
            Assert.AreEqual("", ActiveCollisionsHelper.GetNamesOfActiveCollisions(remainedList));
        }
コード例 #2
0
        public void SliceInactiveComponent()
        {
            UnityEventListenerMock slicedMock = new UnityEventListenerMock();

            subject.Sliced.AddListener(slicedMock.Listen);
            UnityEventListenerMock remainedMock = new UnityEventListenerMock();

            subject.Remained.AddListener(remainedMock.Listen);

            List <CollisionNotifier.EventData> collisionList = new List <CollisionNotifier.EventData>();
            GameObject oneContainer;

            CollisionNotifier.EventData oneData = CollisionNotifierHelper.GetEventData(out oneContainer);
            oneContainer.name = "one";
            collisionList.Add(oneData);

            GameObject twoContainer;

            CollisionNotifier.EventData twoData = CollisionNotifierHelper.GetEventData(out twoContainer);
            twoContainer.name = "two";
            collisionList.Add(twoData);

            GameObject threeContainer;

            CollisionNotifier.EventData threeData = CollisionNotifierHelper.GetEventData(out threeContainer);
            threeContainer.name = "three";
            collisionList.Add(threeData);

            ActiveCollisionsContainer.EventData eventData = new ActiveCollisionsContainer.EventData().Set(collisionList);

            subject.StartIndex = 0;
            subject.Length     = 1;
            subject.enabled    = false;

            Assert.AreEqual("one,two,three", ActiveCollisionsHelper.GetNamesOfActiveCollisions(eventData));

            Assert.IsFalse(slicedMock.Received);
            Assert.IsFalse(remainedMock.Received);

            ActiveCollisionsContainer.EventData remainedList;
            ActiveCollisionsContainer.EventData slicedList = subject.Slice(eventData, out remainedList);

            Assert.IsFalse(slicedMock.Received);
            Assert.IsFalse(remainedMock.Received);

            Assert.AreEqual("", ActiveCollisionsHelper.GetNamesOfActiveCollisions(slicedList));
            Assert.AreEqual("one,two,three", ActiveCollisionsHelper.GetNamesOfActiveCollisions(remainedList));

            Object.DestroyImmediate(oneContainer);
            Object.DestroyImmediate(twoContainer);
            Object.DestroyImmediate(threeContainer);
        }
コード例 #3
0
        public void ReverseEmptyList()
        {
            UnityEventListenerMock reversedMock = new UnityEventListenerMock();

            subject.Reversed.AddListener(reversedMock.Listen);

            List <CollisionNotifier.EventData> collisionList = new List <CollisionNotifier.EventData>();

            ActiveCollisionsContainer.EventData eventData = new ActiveCollisionsContainer.EventData().Set(collisionList);

            Assert.AreEqual("", ActiveCollisionsHelper.GetNamesOfActiveCollisions(eventData));
            Assert.IsFalse(reversedMock.Received);

            ActiveCollisionsContainer.EventData reversedList = subject.Reverse(eventData);

            Assert.IsTrue(reversedMock.Received);
            Assert.AreEqual("", ActiveCollisionsHelper.GetNamesOfActiveCollisions(reversedList));
        }
コード例 #4
0
        public void SortInactiveGameObject()
        {
            UnityEventListenerMock sortedMock = new UnityEventListenerMock();

            subject.Sorted.AddListener(sortedMock.Listen);

            List <CollisionNotifier.EventData> collisionList = new List <CollisionNotifier.EventData>();
            GameObject oneContainer;

            CollisionNotifier.EventData oneData = CollisionNotifierHelper.GetEventData(out oneContainer, Vector3.one * 5f);
            oneContainer.name = "one";
            collisionList.Add(oneData);

            GameObject twoContainer;

            CollisionNotifier.EventData twoData = CollisionNotifierHelper.GetEventData(out twoContainer, Vector3.one * 2f);
            twoContainer.name = "two";
            collisionList.Add(twoData);

            GameObject threeContainer;

            CollisionNotifier.EventData threeData = CollisionNotifierHelper.GetEventData(out threeContainer, Vector3.one * 3f);
            threeContainer.name = "three";
            collisionList.Add(threeData);

            ActiveCollisionsContainer.EventData eventData = new ActiveCollisionsContainer.EventData().Set(collisionList);

            subject.Source = containingObject;
            subject.gameObject.SetActive(false);

            Assert.AreEqual("one,two,three", ActiveCollisionsHelper.GetNamesOfActiveCollisions(eventData));
            Assert.IsFalse(sortedMock.Received);

            ActiveCollisionsContainer.EventData sortedList = subject.Sort(eventData);

            Assert.IsFalse(sortedMock.Received);
            Assert.AreEqual("one,two,three", ActiveCollisionsHelper.GetNamesOfActiveCollisions(sortedList));

            Object.DestroyImmediate(oneContainer);
            Object.DestroyImmediate(twoContainer);
            Object.DestroyImmediate(threeContainer);
        }
コード例 #5
0
        public void SortEmptyList()
        {
            UnityEventListenerMock sortedMock = new UnityEventListenerMock();

            subject.Sorted.AddListener(sortedMock.Listen);

            List <CollisionNotifier.EventData> collisionList = new List <CollisionNotifier.EventData>();

            ActiveCollisionsContainer.EventData eventData = new ActiveCollisionsContainer.EventData().Set(collisionList);

            subject.Source = containingObject;

            Assert.AreEqual("", ActiveCollisionsHelper.GetNamesOfActiveCollisions(eventData));
            Assert.IsFalse(sortedMock.Received);

            ActiveCollisionsContainer.EventData sortedList = subject.Sort(eventData);

            Assert.IsTrue(sortedMock.Received);
            Assert.AreEqual("", ActiveCollisionsHelper.GetNamesOfActiveCollisions(sortedList));
        }
コード例 #6
0
        public void Reverse()
        {
            UnityEventListenerMock reversedMock = new UnityEventListenerMock();

            subject.Reversed.AddListener(reversedMock.Listen);

            List <CollisionNotifier.EventData> collisionList = new List <CollisionNotifier.EventData>();
            GameObject oneContainer;

            CollisionNotifier.EventData oneData = CollisionNotifierHelper.GetEventData(out oneContainer);
            oneContainer.name = "one";
            collisionList.Add(oneData);

            GameObject twoContainer;

            CollisionNotifier.EventData twoData = CollisionNotifierHelper.GetEventData(out twoContainer);
            twoContainer.name = "two";
            collisionList.Add(twoData);

            GameObject threeContainer;

            CollisionNotifier.EventData threeData = CollisionNotifierHelper.GetEventData(out threeContainer);
            threeContainer.name = "three";
            collisionList.Add(threeData);

            ActiveCollisionsContainer.EventData eventData = new ActiveCollisionsContainer.EventData().Set(collisionList);

            Assert.AreEqual("one,two,three", ActiveCollisionsHelper.GetNamesOfActiveCollisions(eventData));
            Assert.IsFalse(reversedMock.Received);

            ActiveCollisionsContainer.EventData reversedList = subject.Reverse(eventData);

            Assert.IsTrue(reversedMock.Received);
            Assert.AreEqual("three,two,one", ActiveCollisionsHelper.GetNamesOfActiveCollisions(reversedList));

            Object.DestroyImmediate(oneContainer);
            Object.DestroyImmediate(twoContainer);
            Object.DestroyImmediate(threeContainer);
        }
コード例 #7
0
        public void LengthIsZero()
        {
            UnityEventListenerMock slicedMock = new UnityEventListenerMock();

            subject.Sliced.AddListener(slicedMock.Listen);
            UnityEventListenerMock remainedMock = new UnityEventListenerMock();

            subject.Remained.AddListener(remainedMock.Listen);

            List <CollisionNotifier.EventData> collisionList = new List <CollisionNotifier.EventData>();
            GameObject oneContainer;

            CollisionNotifier.EventData oneData = CollisionNotifierHelper.GetEventData(out oneContainer);
            oneContainer.name = "one";
            collisionList.Add(oneData);

            GameObject twoContainer;

            CollisionNotifier.EventData twoData = CollisionNotifierHelper.GetEventData(out twoContainer);
            twoContainer.name = "two";
            collisionList.Add(twoData);

            GameObject threeContainer;

            CollisionNotifier.EventData threeData = CollisionNotifierHelper.GetEventData(out threeContainer);
            threeContainer.name = "three";
            collisionList.Add(threeData);

            GameObject fourContainer;

            CollisionNotifier.EventData fourData = CollisionNotifierHelper.GetEventData(out fourContainer);
            fourContainer.name = "four";
            collisionList.Add(fourData);

            GameObject fiveContainer;

            CollisionNotifier.EventData fiveData = CollisionNotifierHelper.GetEventData(out fiveContainer);
            fiveContainer.name = "five";
            collisionList.Add(fiveData);

            GameObject sixContainer;

            CollisionNotifier.EventData sixData = CollisionNotifierHelper.GetEventData(out sixContainer);
            sixContainer.name = "six";
            collisionList.Add(sixData);

            ActiveCollisionsContainer.EventData eventData = new ActiveCollisionsContainer.EventData().Set(collisionList);

            subject.StartIndex = 0;
            subject.Length     = 0;

            ActiveCollisionsContainer.EventData remainedList;
            ActiveCollisionsContainer.EventData slicedList = subject.Slice(eventData, out remainedList);

            Assert.IsTrue(slicedMock.Received);
            Assert.IsTrue(remainedMock.Received);

            Assert.AreEqual("", ActiveCollisionsHelper.GetNamesOfActiveCollisions(slicedList));
            Assert.AreEqual("one,two,three,four,five,six", ActiveCollisionsHelper.GetNamesOfActiveCollisions(remainedList));

            Object.DestroyImmediate(oneContainer);
            Object.DestroyImmediate(twoContainer);
            Object.DestroyImmediate(threeContainer);
            Object.DestroyImmediate(fourContainer);
            Object.DestroyImmediate(fiveContainer);
            Object.DestroyImmediate(sixContainer);
        }