public void InvalidRemove() { UnityEventListenerMock firstStartedMock = new UnityEventListenerMock(); UnityEventListenerMock countChangedMock = new UnityEventListenerMock(); UnityEventListenerMock contentsChangedMock = new UnityEventListenerMock(); UnityEventListenerMock allStoppedMock = new UnityEventListenerMock(); subject.FirstStarted.AddListener(firstStartedMock.Listen); subject.CountChanged.AddListener(countChangedMock.Listen); subject.ContentsChanged.AddListener(contentsChangedMock.Listen); subject.AllStopped.AddListener(allStoppedMock.Listen); GameObject oneContainer; CollisionNotifier.EventData oneData = CollisionNotifierHelper.GetEventData(out oneContainer); Assert.IsFalse(firstStartedMock.Received); Assert.IsFalse(countChangedMock.Received); Assert.IsFalse(contentsChangedMock.Received); Assert.IsFalse(allStoppedMock.Received); firstStartedMock.Reset(); countChangedMock.Reset(); contentsChangedMock.Reset(); allStoppedMock.Reset(); Assert.AreEqual(0, subject.Elements.Count); subject.Remove(oneData); Assert.AreEqual(0, subject.Elements.Count); Assert.IsFalse(firstStartedMock.Received); Assert.IsFalse(countChangedMock.Received); Assert.IsFalse(contentsChangedMock.Received); Assert.IsFalse(allStoppedMock.Received); Object.DestroyImmediate(oneContainer); }
public void RemoveElementInactiveComponent() { UnityEventListenerMock becameEmptyMock = new UnityEventListenerMock(); UnityEventListenerMock becamePopulatedMock = new UnityEventListenerMock(); subject.BecameEmpty.AddListener(becameEmptyMock.Listen); subject.BecamePopulated.AddListener(becamePopulatedMock.Listen); GameObject elementOne = new GameObject(); GameObject elementTwo = new GameObject(); subject.AddElement(elementOne); subject.AddElement(elementTwo); becameEmptyMock.Reset(); becamePopulatedMock.Reset(); subject.enabled = false; Assert.IsNotEmpty(subject.Elements); subject.RemoveElement(elementTwo); Assert.IsNotEmpty(subject.Elements); Assert.IsFalse(becameEmptyMock.Received); Assert.IsFalse(becamePopulatedMock.Received); becameEmptyMock.Reset(); becamePopulatedMock.Reset(); subject.RemoveElement(elementOne); Assert.IsNotEmpty(subject.Elements); Assert.IsFalse(becameEmptyMock.Received); Assert.IsFalse(becamePopulatedMock.Received); Object.DestroyImmediate(elementOne); Object.DestroyImmediate(elementTwo); }
public void RegisterUnregisterOnConsumerContainer() { UnityEventListenerMock registeredMock = new UnityEventListenerMock(); UnityEventListenerMock unregisteredMock = new UnityEventListenerMock(); subject.Registered.AddListener(registeredMock.Listen); subject.Unregistered.AddListener(unregisteredMock.Listen); GameObject containerOne = new GameObject(); GameObject containerTwo = new GameObject(); ActiveCollisionConsumerMock oneConsumerA = containerOne.AddComponent <ActiveCollisionConsumerMock>(); ActiveCollisionConsumerMock oneConsumerB = containerOne.AddComponent <ActiveCollisionConsumerMock>(); ActiveCollisionConsumerMock twoConsumer = containerTwo.AddComponent <ActiveCollisionConsumerMock>(); oneConsumerA.SetConsumerContainer(containerOne); oneConsumerB.SetConsumerContainer(containerOne); twoConsumer.SetConsumerContainer(containerTwo); subject.Register(oneConsumerA, null); subject.Register(oneConsumerB, null); subject.Register(twoConsumer, null); Assert.IsFalse(unregisteredMock.Received); Assert.AreEqual(3, subject.RegisteredConsumers.Count); registeredMock.Reset(); unregisteredMock.Reset(); subject.UnregisterConsumersOnContainer(containerOne); Assert.IsFalse(registeredMock.Received); Assert.IsTrue(unregisteredMock.Received); Assert.AreEqual(1, subject.RegisteredConsumers.Count); Object.DestroyImmediate(containerOne); Object.DestroyImmediate(containerTwo); }
public void ActivatedNotEmittedOnNotAllTrue() { MockAction actionA = containingObject.AddComponent <MockAction>(); MockAction actionB = containingObject.AddComponent <MockAction>(); actionA.SetIsActivated(false); actionB.SetIsActivated(false); subject.actions.Add(actionA); subject.actions.Add(actionB); UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); subject.Activated.AddListener(activatedListenerMock.Listen); subject.Deactivated.AddListener(deactivatedListenerMock.Listen); subject.ValueChanged.AddListener(changedListenerMock.Listen); Assert.IsFalse(activatedListenerMock.Received); Assert.IsFalse(deactivatedListenerMock.Received); Assert.IsFalse(changedListenerMock.Received); subject.ManualUpdate(); Assert.IsFalse(activatedListenerMock.Received); Assert.IsFalse(deactivatedListenerMock.Received); Assert.IsFalse(changedListenerMock.Received); actionA.SetIsActivated(true); actionB.SetIsActivated(false); subject.ManualUpdate(); Assert.IsFalse(activatedListenerMock.Received); Assert.IsFalse(deactivatedListenerMock.Received); Assert.IsFalse(changedListenerMock.Received); }
public IEnumerator CastPointsInvalidTargetPoint() { UnityEventListenerMock castResultsChangedMock = new UnityEventListenerMock(); subject.ResultsChanged.AddListener(castResultsChangedMock.Listen); subject.Origin = subject.gameObject; validSurface.transform.position = Vector3.forward * 5f; validSurface.AddComponent <RuleStub>(); NegationRule negationRule = validSurface.AddComponent <NegationRule>(); Vector3RuleStub pointRule = validSurface.AddComponent <Vector3RuleStub>(); yield return(null); negationRule.Rule = new RuleContainer { Interface = pointRule }; subject.TargetPointValidity = new RuleContainer { Interface = negationRule }; Vector3 expectedStart = Vector3.zero; Vector3 expectedEnd = validSurface.transform.position - (Vector3.forward * (validSurface.transform.localScale.z / 2f)); pointRule.toMatch = expectedEnd; subject.ManualOnEnable(); Physics.Simulate(Time.fixedDeltaTime); subject.Process(); Assert.AreEqual(expectedStart, subject.Points[0]); Assert.AreEqual(expectedEnd, subject.Points[1]); Assert.AreEqual(validSurface.transform, subject.TargetHit.Value.transform); Assert.IsFalse(subject.IsTargetHitValid); Assert.IsTrue(castResultsChangedMock.Received); }
public void SetAt() { UnityEventListenerMock addedMock = new UnityEventListenerMock(); UnityEventListenerMock removedMock = new UnityEventListenerMock(); subject.Added.AddListener(addedMock.Listen); subject.Removed.AddListener(removedMock.Listen); GameObject elementOne = new GameObject("One"); GameObject elementTwo = new GameObject("Two"); GameObject elementThree = new GameObject("Three"); GameObject elementFour = new GameObject("Four"); subject.Add(elementOne); subject.Add(elementTwo); subject.Add(elementThree); addedMock.Reset(); removedMock.Reset(); Assert.AreEqual(elementOne, subject.NonSubscribableElements[0]); Assert.AreEqual(elementTwo, subject.NonSubscribableElements[1]); Assert.AreEqual(elementThree, subject.NonSubscribableElements[2]); subject.SetAt(elementFour, 1); Assert.AreEqual(elementOne, subject.NonSubscribableElements[0]); Assert.AreEqual(elementFour, subject.NonSubscribableElements[1]); Assert.AreEqual(elementThree, subject.NonSubscribableElements[2]); Assert.IsTrue(addedMock.Received); Assert.IsTrue(removedMock.Received); Object.DestroyImmediate(elementOne); Object.DestroyImmediate(elementTwo); Object.DestroyImmediate(elementThree); Object.DestroyImmediate(elementFour); }
public void SetUniqueAtCurrentIndex() { UnityEventListenerMock addedMock = new UnityEventListenerMock(); UnityEventListenerMock removedMock = new UnityEventListenerMock(); subject.Added.AddListener(addedMock.Listen); subject.Removed.AddListener(removedMock.Listen); subject.CurrentIndex = 1; GameObject elementOne = new GameObject(); GameObject elementTwo = new GameObject(); GameObject elementThree = new GameObject(); subject.Add(elementOne); subject.Add(elementTwo); subject.Add(elementThree); addedMock.Reset(); removedMock.Reset(); Assert.AreEqual(elementOne, subject.NonSubscribableElements[0]); Assert.AreEqual(elementTwo, subject.NonSubscribableElements[1]); Assert.AreEqual(elementThree, subject.NonSubscribableElements[2]); subject.SetUniqueAtCurrentIndex(elementOne); Assert.AreEqual(elementOne, subject.NonSubscribableElements[0]); Assert.AreEqual(elementTwo, subject.NonSubscribableElements[1]); Assert.AreEqual(elementThree, subject.NonSubscribableElements[2]); Assert.IsFalse(addedMock.Received); Assert.IsFalse(removedMock.Received); Object.DestroyImmediate(elementOne); Object.DestroyImmediate(elementTwo); Object.DestroyImmediate(elementThree); }
public void DecreaseCount() { UnityEventListenerMock elementAddedMock = new UnityEventListenerMock(); UnityEventListenerMock elementRemovedMock = new UnityEventListenerMock(); subject.ElementAdded.AddListener(elementAddedMock.Listen); subject.ElementRemoved.AddListener(elementRemovedMock.Listen); GameObject elementOne = new GameObject(); subject.IncreaseCount(elementOne); subject.IncreaseCount(elementOne); elementAddedMock.Reset(); elementRemovedMock.Reset(); Assert.IsFalse(elementAddedMock.Received); Assert.IsFalse(elementRemovedMock.Received); Assert.AreEqual(2, subject.GetCount(elementOne)); subject.DecreaseCount(elementOne); Assert.IsFalse(elementAddedMock.Received); Assert.IsFalse(elementRemovedMock.Received); Assert.AreEqual(1, subject.GetCount(elementOne)); elementAddedMock.Reset(); elementRemovedMock.Reset(); subject.DecreaseCount(elementOne); Assert.IsFalse(elementAddedMock.Received); Assert.IsTrue(elementRemovedMock.Received); Assert.AreEqual(0, subject.GetCount(elementOne)); Assert.IsFalse(subject.ElementsCounter.ContainsKey(elementOne)); Object.DestroyImmediate(elementOne); }
public void ProcessNoTarget() { UnityEventListenerMock thresholdExceededMock = new UnityEventListenerMock(); UnityEventListenerMock thresholdResumedMock = new UnityEventListenerMock(); subject.ThresholdExceeded.AddListener(thresholdExceededMock.Listen); subject.ThresholdResumed.AddListener(thresholdResumedMock.Listen); GameObject source = new GameObject(); subject.Source = source; subject.DistanceThreshold = 0.5f; subject.Process(); Assert.IsFalse(thresholdExceededMock.Received); Assert.IsFalse(thresholdResumedMock.Received); Assert.IsFalse(subject.Exceeding); Assert.AreEqual(Vector3.zero, subject.Difference); Assert.AreEqual(0f, subject.Distance); Object.DestroyImmediate(source); }
public void AddColorOverlay() { UnityEventListenerMock colorOverlayAddedMock = new UnityEventListenerMock(); subject.Added.AddListener(colorOverlayAddedMock.Listen); subject.AddColorOverlay(); Assert.IsTrue(colorOverlayAddedMock.Received); colorOverlayAddedMock.Reset(); subject.AddColorOverlay(); //Shouldn't be true if it's called with the same parameters and the color matches the existing target color Assert.IsFalse(colorOverlayAddedMock.Received); colorOverlayAddedMock.Reset(); subject.OverlayColor = Color.red; subject.AddColorOverlay(); Assert.IsTrue(colorOverlayAddedMock.Received); Assert.AreEqual("{ Color = RGBA(1.000, 0.000, 0.000, 1.000) }", subject.GetEventData().ToString()); }
public void PushInactiveComponent() { UnityEventListenerMock elementOnePushedMock = new UnityEventListenerMock(); UnityEventListenerMock elementOnePoppedMock = new UnityEventListenerMock(); UnityEventListenerMock elementOneForcePoppedMock = new UnityEventListenerMock(); GameObjectObservableStack.GameObjectElementEvents eventsOne = new GameObjectObservableStack.GameObjectElementEvents(); eventsOne.Pushed.AddListener(elementOnePushedMock.Listen); eventsOne.Popped.AddListener(elementOnePoppedMock.Listen); eventsOne.ForcePopped.AddListener(elementOneForcePoppedMock.Listen); GameObject objectOne = new GameObject(); subject.elementEvents.Add(eventsOne); subject.enabled = false; subject.Push(objectOne); Assert.IsFalse(elementOnePushedMock.Received); Assert.IsFalse(elementOnePoppedMock.Received); Assert.IsFalse(elementOneForcePoppedMock.Received); Object.DestroyImmediate(objectOne); }
public IEnumerator ExtractNoCollisionData() { UnityEventListenerMock extractedMock = new UnityEventListenerMock(); subject.Extracted.AddListener(extractedMock.Listen); yield return(null); GameObject blocker = RaycastHitHelper.CreateBlocker(); blocker.SetActive(false); RaycastHit hitData = RaycastHitHelper.GetRaycastHit(blocker); subject.Source = hitData; Assert.IsFalse(extractedMock.Received); Assert.IsFalse(subject.Result.HasValue); subject.Extract(); Assert.IsFalse(extractedMock.Received); Assert.IsFalse(subject.Result.HasValue); }
public void TransformInactiveComponent() { UnityEventListenerMock transformedListenerMock = new UnityEventListenerMock(); subject.Transformed.AddListener(transformedListenerMock.Listen); subject.collection = new List <float>() { 0f, 0f }; subject.enabled = false; Assert.AreEqual(0f, subject.Result); Assert.IsFalse(transformedListenerMock.Received); subject.SetIndex(0); subject.Transform(1f); subject.SetIndex(1); float result = subject.Transform(2f); Assert.AreEqual(0f, result); Assert.AreEqual(0f, subject.Result); Assert.IsFalse(transformedListenerMock.Received); }
public void Extract() { GameObject source = new GameObject(); UnityEventListenerMock extractedMock = new UnityEventListenerMock(); subject.Extracted.AddListener(extractedMock.Listen); ObjectFollower.EventData eventData = new ObjectFollower.EventData { EventTargetOffset = source }; Assert.IsFalse(extractedMock.Received); Assert.IsNull(subject.Result); subject.Extract(eventData); Assert.IsTrue(extractedMock.Received); Assert.AreEqual(subject.Result, source); Object.DestroyImmediate(source); }
public void TransformInactiveComponent() { UnityEventListenerMock transformedListenerMock = new UnityEventListenerMock(); subject.Transformed.AddListener(transformedListenerMock.Listen); FloatObservableList collection = containingObject.AddComponent <FloatObservableList>(); subject.Collection = collection; subject.Collection.Add(0f); subject.Collection.Add(0f); subject.enabled = false; Assert.AreEqual(0f, subject.Result); Assert.IsFalse(transformedListenerMock.Received); subject.Collection.SetAt(1f, 0); float result = subject.Transform(3f, 1); Assert.AreEqual(0f, result); Assert.AreEqual(0f, subject.Result); Assert.IsFalse(transformedListenerMock.Received); }
public void ExtractInactiveComponent() { UnityEventListenerMock extractedMock = new UnityEventListenerMock(); subject.Extracted.AddListener(extractedMock.Listen); SurfaceData surfaceData = new SurfaceData(); subject.Source = surfaceData; subject.enabled = false; Assert.IsFalse(extractedMock.Received); Assert.IsFalse(subject.Result.HasValue); RaycastHit hitData = GetRayCastData(); hitData.point = Vector3.one; surfaceData.CollisionData = hitData; subject.Extract(); Assert.IsFalse(extractedMock.Received); Assert.IsFalse(subject.Result.HasValue); }
public void CastPointsValidTarget() { UnityEventListenerMock castResultsChangedMock = new UnityEventListenerMock(); subject.ResultsChanged.AddListener(castResultsChangedMock.Listen); subject.Origin = subject.gameObject; validSurface.transform.position = Vector3.forward * 5f; subject.ManualOnEnable(); Physics.Simulate(Time.fixedDeltaTime); subject.Process(); Vector3 expectedStart = Vector3.zero; Vector3 expectedEnd = validSurface.transform.position - (Vector3.forward * (validSurface.transform.localScale.z / 2f)); Assert.AreEqual(expectedStart, subject.Points[0]); Assert.AreEqual(expectedEnd, subject.Points[1]); Assert.AreEqual(validSurface.transform, subject.TargetHit.Value.transform); Assert.IsTrue(subject.IsTargetHitValid); Assert.IsTrue(castResultsChangedMock.Received); Assert.AreEqual("{ HitData = { barycentricCoordinate = (1.0, 0.0, 0.0) | Collider = Cube (UnityEngine.BoxCollider) | Distance = 4.5 | Lightmap Coord = (0.0, 0.0) | Normal = (0.0, 0.0, -1.0) | Point = (0.0, 0.0, 4.5) | Rigidbody = [null] | Texture Coord = (0.0, 0.0) | Texture Coord2 = (0.0, 0.0) | Transform = Cube (UnityEngine.Transform) | Triangle Index = -1 } | IsValid = True }", subject.GetEventData().ToString()); }
public IEnumerator SetAtOrAddIfEmptyCollection() { UnityEventListenerMock addedMock = new UnityEventListenerMock(); UnityEventListenerMock removedMock = new UnityEventListenerMock(); subject.Added.AddListener(addedMock.Listen); subject.Removed.AddListener(removedMock.Listen); GameObject elementOne = new GameObject("One"); yield return(null); Assert.AreEqual(0, subject.NonSubscribableElements.Count); subject.SetAtOrAddIfEmpty(elementOne, 1); Assert.AreEqual(elementOne, subject.NonSubscribableElements[0]); Assert.IsTrue(addedMock.Received); Assert.IsFalse(removedMock.Received); Object.DestroyImmediate(elementOne); }
public void TransformWithIndex() { UnityEventListenerMock transformedListenerMock = new UnityEventListenerMock(); subject.Transformed.AddListener(transformedListenerMock.Listen); Vector3ObservableList collection = containingObject.AddComponent <Vector3ObservableList>(); subject.Collection = collection; subject.Collection.Add(Vector3.zero); subject.Collection.Add(Vector3.zero); subject.Collection.Add(Vector3.zero); Assert.AreEqual(Vector3.zero, subject.Result); Assert.IsFalse(transformedListenerMock.Received); subject.Collection.SetAt(Vector3.one * 3f, 0); subject.Collection.SetAt(Vector3.one, 1); Vector3 result = subject.Transform(Vector3.one, 2); Assert.AreEqual(Vector3.one, result); Assert.AreEqual(Vector3.one, subject.Result); Assert.IsTrue(transformedListenerMock.Received); }
public void Extract() { UnityEventListenerMock extractedMock = new UnityEventListenerMock(); subject.Extracted.AddListener(extractedMock.Listen); Collider collider = new GameObject().AddComponent <BoxCollider>(); CollisionNotifier.EventData eventData = new CollisionNotifier.EventData { ColliderData = collider }; Assert.IsNull(subject.Result); Assert.IsFalse(extractedMock.Received); subject.Extract(eventData); Assert.AreEqual(collider.gameObject, subject.Result); Assert.IsTrue(extractedMock.Received); Object.DestroyImmediate(collider.gameObject); }
public IEnumerator Yielded() { UnityEventListenerMock yieldedMock = new UnityEventListenerMock(); UnityEventListenerMock cancelledMock = new UnityEventListenerMock(); subject.Yielded.AddListener(yieldedMock.Listen); subject.Cancelled.AddListener(cancelledMock.Listen); yield return(null); Assert.IsFalse(yieldedMock.Received); Assert.IsFalse(cancelledMock.Received); subject.Begin(); while (subject.IsRunning) { yield return(null); } Assert.IsTrue(yieldedMock.Received); Assert.IsFalse(cancelledMock.Received); }
public void ChangedEmitted() { UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); subject.ValueChanged.AddListener(changedListenerMock.Listen); Assert.IsFalse(changedListenerMock.Received); subject.Receive(new Vector2(0.1f, 0.1f)); Assert.IsTrue(changedListenerMock.Received); changedListenerMock.Reset(); Assert.IsFalse(changedListenerMock.Received); subject.Receive(new Vector2(0.1f, 0.1f)); Assert.IsFalse(changedListenerMock.Received); changedListenerMock.Reset(); Assert.IsFalse(changedListenerMock.Received); subject.Receive(new Vector2(0.2f, 0.2f)); Assert.IsTrue(changedListenerMock.Received); }
public void ExtractInactiveGameObject() { UnityEventListenerMock extractedMock = new UnityEventListenerMock(); subject.Extracted.AddListener(extractedMock.Listen); SurfaceData surfaceData = new SurfaceData(); subject.Source = surfaceData; subject.gameObject.SetActive(false); Assert.IsFalse(extractedMock.Received); Assert.IsNull(subject.Result); RaycastHit hitData = GetRayCastData(); hitData.point = Vector3.one; surfaceData.CollisionData = hitData; subject.Extract(); Assert.IsFalse(extractedMock.Received); Assert.IsNull(subject.Result); }
public void ExtractNoCollisionData() { UnityEventListenerMock extractedMock = new UnityEventListenerMock(); subject.Extracted.AddListener(extractedMock.Listen); GameObject blocker = RaycastHitHelper.CreateBlocker(); Rigidbody target = blocker.AddComponent <Rigidbody>(); blocker.SetActive(false); RaycastHit hitData = RaycastHitHelper.GetRaycastHit(blocker); subject.Source = hitData; Assert.IsFalse(extractedMock.Received); Assert.IsNull(subject.Result); subject.Extract(); Assert.IsFalse(extractedMock.Received); Assert.IsNull(subject.Result); Object.DestroyImmediate(containingObject); }
public void ConsumeInactiveComponent() { UnityEventListenerMock consumedMock = new UnityEventListenerMock(); UnityEventListenerMock clearedMock = new UnityEventListenerMock(); subject.Consumed.AddListener(consumedMock.Listen); subject.Cleared.AddListener(clearedMock.Listen); GameObject publisherObject = new GameObject(); ActiveCollisionPublisher.PayloadData publisher = new ActiveCollisionPublisher.PayloadData(); publisher.SourceContainer = publisherObject; subject.enabled = false; subject.Consume(publisher, null); Assert.IsFalse(consumedMock.Received); Assert.IsFalse(clearedMock.Received); Assert.IsNull(subject.PublisherSource); Object.DestroyImmediate(publisherObject); }
public void Process() { UnityEventListenerMock extractedListenerMock = new UnityEventListenerMock(); subject.Extracted.AddListener(extractedListenerMock.Listen); subject.Source = containingObject; subject.UseLocal = true; subject.Process(); Assert.AreEqual(Vector3.one, subject.LastExtractedValue); Assert.IsTrue(extractedListenerMock.Received); containingObject.transform.localScale = Vector3.one * 2f; extractedListenerMock.Reset(); Assert.IsFalse(extractedListenerMock.Received); subject.Process(); Assert.AreEqual(Vector3.one * 2f, subject.LastExtractedValue); Assert.IsTrue(extractedListenerMock.Received); }
public void DeactivatedEmitted() { subject.SetIsActivated(true); subject.SetValue(Vector2.one); UnityEventListenerMock activatedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock deactivatedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock changedListenerMock = new UnityEventListenerMock(); subject.Activated.AddListener(activatedListenerMock.Listen); subject.Deactivated.AddListener(deactivatedListenerMock.Listen); subject.ValueChanged.AddListener(changedListenerMock.Listen); Assert.IsFalse(activatedListenerMock.Received); Assert.IsFalse(deactivatedListenerMock.Received); Assert.IsFalse(changedListenerMock.Received); subject.Receive(Vector2.zero); Assert.IsFalse(activatedListenerMock.Received); Assert.IsTrue(deactivatedListenerMock.Received); Assert.IsTrue(changedListenerMock.Received); }
public void ContainsNotFoundInactiveComponent() { UnityEventListenerMock elementFoundMock = new UnityEventListenerMock(); UnityEventListenerMock elementNotFoundMock = new UnityEventListenerMock(); subject.ElementFound.AddListener(elementFoundMock.Listen); subject.ElementNotFound.AddListener(elementNotFoundMock.Listen); GameObject elementOne = new GameObject(); GameObject elementTwo = new GameObject(); subject.AddElement(elementTwo); elementFoundMock.Reset(); elementNotFoundMock.Reset(); subject.enabled = false; Assert.IsFalse(subject.Contains(elementOne)); Assert.IsFalse(elementNotFoundMock.Received); Assert.IsFalse(elementFoundMock.Received); Object.DestroyImmediate(elementOne); Object.DestroyImmediate(elementTwo); }
public void Transform() { UnityEventListenerMock transformedListenerMock = new UnityEventListenerMock(); subject.Transformed.AddListener(transformedListenerMock.Listen); FloatObservableList collection = containingObject.AddComponent <FloatObservableList>(); subject.Collection = collection; subject.Collection.Add(0f); subject.Collection.Add(0f); subject.Collection.SetAt(2f, 0); Assert.AreEqual(0f, subject.Result); Assert.IsFalse(transformedListenerMock.Received); subject.Collection.CurrentIndex = 1; float result = subject.Transform(2f); Assert.AreEqual(4f, result); Assert.AreEqual(4f, subject.Result); Assert.IsTrue(transformedListenerMock.Received); }
public void ExtractInactiveGameObject() { UnityEventListenerMock extractedMock = new UnityEventListenerMock(); subject.Extracted.AddListener(extractedMock.Listen); GameObject publisherSource = new GameObject(); GameObject publisherChild = new GameObject(); publisherChild.transform.SetParent(publisherSource.transform); ActiveCollisionPublisher publisher = publisherChild.AddComponent <ActiveCollisionPublisher>(); publisher.sourceContainer = publisherSource; Assert.IsNull(subject.SourceContainer); Assert.IsFalse(extractedMock.Received); subject.gameObject.SetActive(false); subject.Extract(publisher); Assert.IsNull(subject.SourceContainer); Assert.IsFalse(extractedMock.Received); }