public void Constant_Reference_Clamps() { var clamped = new FloatVariableReferenceClamped(); var first = new FloatVariableReference(); var second = new FloatVariableReference(); first.Type = ReferenceType.Constant; second.Type = ReferenceType.Constant; Clamped_Reference_Clamps(first, second, clamped); }
private void Clamped_Reference_Clamps(FloatVariableReference first, FloatVariableReference second, FloatVariableReferenceClamped clamped) { first.Value = 0; second.Value = 20; clamped.Min = first; clamped.Max = second; Assert.AreEqual(first.Value, clamped.Value); clamped.Value = 50; Assert.AreEqual(second.Value, clamped.Value); }
public void Shared_Reference_Clamps() { var clamped = new FloatVariableReferenceClamped(); var firstVariable = ScriptableObject.CreateInstance(typeof(FloatVariable)) as FloatVariable; var secondVariable = ScriptableObject.CreateInstance(typeof(FloatVariable)) as FloatVariable; var first = new FloatVariableReference(); var second = new FloatVariableReference(); first.Variable = firstVariable; second.Variable = secondVariable; first.Type = ReferenceType.Shared; second.Type = ReferenceType.Shared; Clamped_Reference_Clamps(first, second, clamped); }
public void Instanced_Reference_Clamps() { var clamped = new FloatVariableReferenceClamped(); var firstVariable = ScriptableObject.CreateInstance(typeof(FloatVariable)) as FloatVariable; var secondVariable = ScriptableObject.CreateInstance(typeof(FloatVariable)) as FloatVariable; var first = new FloatVariableReference(); var second = new FloatVariableReference(); var gameObject = new GameObject(); var instancedVariableOwner = gameObject.AddComponent <InstanceOwner>(); first.Connection = instancedVariableOwner; second.Connection = instancedVariableOwner; first.Variable = firstVariable; second.Variable = secondVariable; first.Type = ReferenceType.Instanced; second.Type = ReferenceType.Instanced; Clamped_Reference_Clamps(first, second, clamped); }