public void TransformExceedingIndex() { 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); Assert.AreEqual(Vector3.zero, subject.Result); Assert.IsFalse(transformedListenerMock.Received); // adds (3f,3f,3f) to index 0 -> adds (1f,1f,1f) to index 1 -> attempts to add (2f,2f,2f) to index 2 but is out of range so sets it at index 1 // collection result is [(3f,3f,3f), (2f,2f,2f)] subject.Collection.SetAt(Vector3.one * 3f, 0); subject.Collection.SetAt(Vector3.one, 1); Vector3 result = subject.Transform(Vector3.one * 2f, 2); Assert.AreEqual(Vector3.one, result); Assert.AreEqual(Vector3.one, subject.Result); Assert.IsTrue(transformedListenerMock.Received); }
public void TransformInactiveGameObject() { 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.SetAt(new Vector3(3f, 4f, 5f), 0); subject.Collection.CurrentIndex = 1; subject.gameObject.SetActive(false); Assert.AreEqual(Vector3.zero, subject.Result); Assert.IsFalse(transformedListenerMock.Received); Vector3 input = new Vector3(2f, 3f, 4f); Vector3 result = subject.Transform(input); Assert.AreEqual(Vector3.zero, result); Assert.AreEqual(Vector3.zero, subject.Result); Assert.IsFalse(transformedListenerMock.Received); }
public void TransformWithIndex() { UnityEventListenerMock transformedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock failedListenerMock = new UnityEventListenerMock(); subject.Transformed.AddListener(transformedListenerMock.Listen); subject.Failed.AddListener(failedListenerMock.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); Assert.IsFalse(failedListenerMock.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); Assert.IsFalse(failedListenerMock.Received); }
public void TransformPredefinedCollection() { UnityEventListenerMock transformedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock failedListenerMock = new UnityEventListenerMock(); subject.Transformed.AddListener(transformedListenerMock.Listen); subject.Failed.AddListener(failedListenerMock.Listen); Vector3ObservableList collection = containingObject.AddComponent <Vector3ObservableList>(); subject.Collection = collection; subject.Collection.Add(new Vector3(3f, 4f, 5f)); subject.Collection.Add(new Vector3(2f, 3f, 4f)); Assert.AreEqual(Vector3.zero, subject.Result); Assert.IsFalse(transformedListenerMock.Received); Assert.IsFalse(failedListenerMock.Received); Vector3 result = subject.Transform(); Vector3 expectedResult = new Vector3(6f, 12f, 20f); Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, subject.Result); Assert.IsTrue(transformedListenerMock.Received); Assert.IsFalse(failedListenerMock.Received); }
public void TransformEmptyCollection() { UnityEventListenerMock transformedListenerMock = new UnityEventListenerMock(); UnityEventListenerMock failedListenerMock = new UnityEventListenerMock(); subject.Transformed.AddListener(transformedListenerMock.Listen); subject.Failed.AddListener(failedListenerMock.Listen); Vector3ObservableList collection = containingObject.AddComponent <Vector3ObservableList>(); subject.Collection = collection; Assert.AreEqual(Vector3.zero, subject.Result); Assert.IsFalse(transformedListenerMock.Received); Assert.IsFalse(failedListenerMock.Received); Vector3 result = subject.Transform(); Assert.AreEqual(Vector3.zero, result); Assert.AreEqual(Vector3.zero, subject.Result); Assert.IsFalse(transformedListenerMock.Received); Assert.IsTrue(failedListenerMock.Received); }
protected virtual void CreateComponent(OptionType selectedOption) { GameObject componentContainer = new GameObject(componentName); if (selectedObject != null && nestInSelectedObject) { componentContainer.transform.SetParent(selectedObject.transform); } GameObject listContainer = new GameObject("ListContainer"); listContainer.transform.SetParent(componentContainer.transform); switch (selectedOption) { case OptionType.AllRule: AllRule allRule = componentContainer.AddComponent <AllRule>(); RuleContainerObservableList allList = listContainer.AddComponent <RuleContainerObservableList>(); allRule.Rules = allList; break; case OptionType.AnyRule: AnyRule anyRule = componentContainer.AddComponent <AnyRule>(); RuleContainerObservableList anyList = listContainer.AddComponent <RuleContainerObservableList>(); anyRule.Rules = anyList; break; case OptionType.AnyBehaviourEnabledRule: AnyBehaviourEnabledRule behaviourRule = componentContainer.AddComponent <AnyBehaviourEnabledRule>(); SerializableTypeBehaviourObservableList behaviourList = listContainer.AddComponent <SerializableTypeBehaviourObservableList>(); behaviourRule.BehaviourTypes = behaviourList; break; case OptionType.AnyComponentTypeRule: AnyComponentTypeRule componentRule = componentContainer.AddComponent <AnyComponentTypeRule>(); SerializableTypeComponentObservableList componentList = listContainer.AddComponent <SerializableTypeComponentObservableList>(); componentRule.ComponentTypes = componentList; break; case OptionType.AnyTagRule: AnyTagRule tagRule = componentContainer.AddComponent <AnyTagRule>(); StringObservableList tagList = listContainer.AddComponent <StringObservableList>(); tagRule.Tags = tagList; break; case OptionType.BehaviourEnabledObserver: BehaviourEnabledObserver behaviourEnabledObserver = componentContainer.AddComponent <BehaviourEnabledObserver>(); BehaviourObservableList behaviourObservableList = listContainer.AddComponent <BehaviourObservableList>(); behaviourEnabledObserver.Behaviours = behaviourObservableList; break; case OptionType.ListContainsRule: ListContainsRule listRule = componentContainer.AddComponent <ListContainsRule>(); UnityObjectObservableList listList = listContainer.AddComponent <UnityObjectObservableList>(); listRule.Objects = listList; break; case OptionType.RulesMatcher: RulesMatcher matcherRule = componentContainer.AddComponent <RulesMatcher>(); RulesMatcherElementObservableList matcherList = listContainer.AddComponent <RulesMatcherElementObservableList>(); matcherRule.Elements = matcherList; break; case OptionType.ActionRegistrar: ActionRegistrar actionRegistrar = componentContainer.AddComponent <ActionRegistrar>(); ActionRegistrarSourceObservableList registrarList = listContainer.AddComponent <ActionRegistrarSourceObservableList>(); GameObjectObservableList limitsList = listContainer.AddComponent <GameObjectObservableList>(); actionRegistrar.Sources = registrarList; actionRegistrar.SourceLimits = limitsList; break; case OptionType.AllAction: AllAction allAction = componentContainer.AddComponent <AllAction>(); ActionObservableList allActionList = listContainer.AddComponent <ActionObservableList>(); allAction.Actions = allActionList; break; case OptionType.AnyAction: AnyAction anyAction = componentContainer.AddComponent <AnyAction>(); ActionObservableList anyActionList = listContainer.AddComponent <ActionObservableList>(); anyAction.Actions = anyActionList; break; case OptionType.GameObjectsAssociationActivator: GameObjectsAssociationActivator gameObjectsAssociationActivator = componentContainer.AddComponent <GameObjectsAssociationActivator>(); GameObjectsAssociationObservableList gameObjectsAssociationList = listContainer.AddComponent <GameObjectsAssociationObservableList>(); gameObjectsAssociationActivator.Associations = gameObjectsAssociationList; break; case OptionType.GameObjectRelations: GameObjectRelations gameObjectRelations = componentContainer.AddComponent <GameObjectRelations>(); GameObjectRelationObservableList gameObjectsRelationsList = listContainer.AddComponent <GameObjectRelationObservableList>(); gameObjectRelations.Relations = gameObjectsRelationsList; break; case OptionType.GameObjectStateSwitcher: GameObjectStateSwitcher gameObjectStateSwitcher = componentContainer.AddComponent <GameObjectStateSwitcher>(); GameObjectObservableList gameObjectsList = listContainer.AddComponent <GameObjectObservableList>(); gameObjectStateSwitcher.Targets = gameObjectsList; break; case OptionType.PlatformDeviceAssociation: PlatformDeviceAssociation platformDeviceAssociation = componentContainer.AddComponent <PlatformDeviceAssociation>(); GameObjectObservableList platformGameObjectsList = listContainer.AddComponent <GameObjectObservableList>(); platformDeviceAssociation.GameObjects = platformGameObjectsList; break; case OptionType.HapticProcessor: HapticProcessor hapticProcessor = componentContainer.AddComponent <HapticProcessor>(); HapticProcessObservableList hapticList = listContainer.AddComponent <HapticProcessObservableList>(); hapticProcessor.HapticProcesses = hapticList; break; case OptionType.MeshStateModifier: MeshStateModifier meshStateModifier = componentContainer.AddComponent <MeshStateModifier>(); GameObjectMultiRelationObservableList gameObjectMultiRelationList = listContainer.AddComponent <GameObjectMultiRelationObservableList>(); meshStateModifier.MeshCollections = gameObjectMultiRelationList; break; case OptionType.MomentProcessor: MomentProcessor momentProcessor = componentContainer.AddComponent <MomentProcessor>(); MomentProcessObservableList momentProcessorList = listContainer.AddComponent <MomentProcessObservableList>(); momentProcessor.Processes = momentProcessorList; break; case OptionType.CompositeProcess: CompositeProcess compositeProcessor = componentContainer.AddComponent <CompositeProcess>(); MomentProcessObservableList compositeProcessorList = listContainer.AddComponent <MomentProcessObservableList>(); compositeProcessor.Processes = compositeProcessorList; break; case OptionType.VelocityTrackerProcessor: VelocityTrackerProcessor velocityTrackerProcessor = componentContainer.AddComponent <VelocityTrackerProcessor>(); VelocityTrackerObservableList velocityTrackerList = listContainer.AddComponent <VelocityTrackerObservableList>(); velocityTrackerProcessor.VelocityTrackers = velocityTrackerList; break; case OptionType.FloatAdder: FloatAdder floatAdder = componentContainer.AddComponent <FloatAdder>(); FloatObservableList floatList = listContainer.AddComponent <FloatObservableList>(); floatAdder.Collection = floatList; break; case OptionType.FloatMaxFinder: FloatMaxFinder floatMaxFinder = componentContainer.AddComponent <FloatMaxFinder>(); FloatObservableList floatMaxFinderList = listContainer.AddComponent <FloatObservableList>(); floatMaxFinder.Collection = floatMaxFinderList; break; case OptionType.FloatMeanFinder: FloatMeanFinder floatMeanFinder = componentContainer.AddComponent <FloatMeanFinder>(); FloatObservableList floatMeanFinderList = listContainer.AddComponent <FloatObservableList>(); floatMeanFinder.Collection = floatMeanFinderList; break; case OptionType.FloatMedianFinder: FloatMedianFinder floatMedianFinder = componentContainer.AddComponent <FloatMedianFinder>(); FloatObservableList floatMedianFinderList = listContainer.AddComponent <FloatObservableList>(); floatMedianFinder.Collection = floatMedianFinderList; break; case OptionType.FloatMinFinder: FloatMinFinder floatMinFinder = componentContainer.AddComponent <FloatMinFinder>(); FloatObservableList floatMinFinderList = listContainer.AddComponent <FloatObservableList>(); floatMinFinder.Collection = floatMinFinderList; break; case OptionType.FloatModeFinder: FloatModeFinder floatModeFinder = componentContainer.AddComponent <FloatModeFinder>(); FloatObservableList floatModeFinderList = listContainer.AddComponent <FloatObservableList>(); floatModeFinder.Collection = floatModeFinderList; break; case OptionType.FloatMultiplier: FloatMultiplier floatMultiplier = componentContainer.AddComponent <FloatMultiplier>(); FloatObservableList floatMultiplierList = listContainer.AddComponent <FloatObservableList>(); floatMultiplier.Collection = floatMultiplierList; break; case OptionType.FloatRangeFinder: FloatRangeFinder floatRangeFinder = componentContainer.AddComponent <FloatRangeFinder>(); FloatObservableList floatRangeFinderList = listContainer.AddComponent <FloatObservableList>(); floatRangeFinder.Collection = floatRangeFinderList; break; case OptionType.Vector2Multiplier: Vector2Multiplier vector2Multiplier = componentContainer.AddComponent <Vector2Multiplier>(); Vector2ObservableList vector2MultiplierList = listContainer.AddComponent <Vector2ObservableList>(); vector2Multiplier.Collection = vector2MultiplierList; break; case OptionType.Vector3Multiplier: Vector3Multiplier vector3Multiplier = componentContainer.AddComponent <Vector3Multiplier>(); Vector3ObservableList vector3MultiplierList = listContainer.AddComponent <Vector3ObservableList>(); vector3Multiplier.Collection = vector3MultiplierList; break; case OptionType.Vector3Subtractor: Vector3Subtractor vector3Subtractor = componentContainer.AddComponent <Vector3Subtractor>(); Vector3ObservableList vector3SubtractorList = listContainer.AddComponent <Vector3ObservableList>(); vector3Subtractor.Collection = vector3SubtractorList; break; } }