public void GetAverageVelocity_Various(Vector2[] velocityStack, Vector2 expectedVelocity) { IPointerDownInputStateConstArg arg = CreateMockArg(); TestAbsPointerDownInputState state = new TestAbsPointerDownInputState(arg); state.SetVelocityStack_Test(velocityStack); Assert.That(state.GetAvarageVelocity_Test(), Is.EqualTo(expectedVelocity)); }
IPointerDownInputStateConstArg CreateMockArg() { IPointerDownInputStateConstArg arg = Substitute.For <IPointerDownInputStateConstArg>(); arg.engine.Returns(Substitute.For <IUIAdaptorInputStateEngine>()); arg.uiManager.Returns(Substitute.For <IUIManager>()); arg.velocityStackSize.Returns(3); return(arg); }
public AbsPointerDownInputState( IPointerDownInputStateConstArg arg ) : base( arg ) { thisUIM = arg.uiManager; thisVelocityStackSize = arg.velocityStackSize; thisVelocityStack = new Vector2[thisVelocityStackSize]; }
public void PushVelocityStack_UpdatesVelocityStack(Vector2[] addedVelocity, Vector2[] expectedStack) { IPointerDownInputStateConstArg arg = CreateMockArg(); TestAbsPointerDownInputState state = new TestAbsPointerDownInputState(arg); foreach (Vector2 velocity in addedVelocity) { state.PushVelocityStack_Test(velocity); } Assert.That(state.GetVelocityStack_Test(), Is.EqualTo(expectedStack)); }
public void OnEnter_ClearsVelocityStack() { IPointerDownInputStateConstArg arg = CreateMockArg(); TestAbsPointerDownInputState state = new TestAbsPointerDownInputState(arg); state.AddVelocityToStack_Test(new Vector2(10f, 10f), 0); state.AddVelocityToStack_Test(new Vector2(10f, 10f), 1); state.AddVelocityToStack_Test(new Vector2(10f, 10f), 2); state.OnEnter(); Assert.That(state.GetVelocityStack_Test(), Is.EqualTo(new Vector2[arg.velocityStackSize])); }
public void OnPointerDown_ThrowsException() { IPointerDownInputStateConstArg arg = CreateMockArg(); TestAbsPointerDownInputState state = new TestAbsPointerDownInputState(arg); Assert.Throws( Is.TypeOf(typeof(System.InvalidOperationException)). And.Message.EqualTo("OnPointerDown should not be called while pointer is already held down"), () => { state.OnPointerDown(Substitute.For <ICustomEventData>()); } ); }
public AbsPointerDownInputState( IPointerDownInputStateConstArg arg ) : base( arg ) { thisUIM = arg.uiManager; thisVelocityStackSize = arg.velocityStackSize; thisVelocityStack = new Vector2[thisVelocityStackSize]; // thisSwipeDistanceThreshold = arg.swipeDistanceThreshold; // thisSwipeVelocityThreshold = arg.swipeVelocityThreshold; }
public void VelocityIsOverSwipeThreshold_VelocityNotLessThanThreshold_ReturnsTrue( Vector2 velocity, float threshold, bool expected ) { IPointerDownInputStateConstArg arg = CreateMockArg(); arg.engine.GetSwipeVelocityThreshold().Returns(threshold); TestAbsPointerDownInputState state = new TestAbsPointerDownInputState(arg); bool actual = state.VelocityIsOverSwipeThreshold_Test(velocity); Assert.That(actual, Is.EqualTo(expected)); }
public TestAbsPointerDownInputState(IPointerDownInputStateConstArg arg) : base(arg) { }