public void Construction_DecelAxisCompMultiplierLessThanZero_ThrowsException(float decelAxisCompMultiplier)
    {
        IInertialScrollProcessConstArg arg = CreateMockConstArg();

        arg.decelerationAxisComponentMultiplier.Returns(decelAxisCompMultiplier);

        Assert.Throws(
            Is.TypeOf(typeof(System.InvalidOperationException)).And.Message.EqualTo("deceleration axis component multiplier must not be less than zero"),
            () => {
            new TestInertialScrollProcess(arg);
        }
            );
    }
    public void Construction_DecelerationNotGreaterThanZero_ThrowsException(float deceleration)
    {
        IInertialScrollProcessConstArg arg = CreateMockConstArg();

        arg.deceleration.Returns(deceleration);

        Assert.Throws(
            Is.TypeOf(typeof(System.InvalidOperationException)).And.Message.EqualTo("deceleration must be greater than zero"),
            () => {
            new TestInertialScrollProcess(arg);
        }
            );
    }
    public IInertialScrollProcessConstArg CreateMockConstArg()
    {
        IInertialScrollProcessConstArg arg = Substitute.For <IInertialScrollProcessConstArg>();

        arg.processManager.Returns(Substitute.For <IProcessManager>());
        arg.scroller.Returns(Substitute.For <IScroller>());
        arg.scrollerElement.Returns(Substitute.For <IUIElement>());
        arg.dimension.Returns(0);

        arg.initialVelocity.Returns(0f);
        arg.deceleration.Returns(.1f);
        arg.decelerationAxisComponentMultiplier.Returns(.5f);

        return(arg);
    }
 public InertialScrollProcess(
     IInertialScrollProcessConstArg arg
     ) : base(
         arg
         )
 {
     thisInitialVelocity    = arg.initialVelocity;
     thisPrevVelocity       = thisInitialVelocity;
     thisPrevLocalPosOnAxis = thisScrollerElement.GetLocalPosition()[thisDimension];
     thisDeceleration       = MakeSureDecelerationIsGreaterThanZero(arg.deceleration) * MakeSureDecelAxisCompMultiplierIsNotLessThanZero(arg.decelerationAxisComponentMultiplier);
     if (thisDeceleration == 0f || thisInitialVelocity == 0f)
     {
         thisExpireTime = 0f;
     }
     else
     {
         thisExpireTime = Mathf.Abs(thisInitialVelocity / thisDeceleration);
     }
     thisScroller.UpdateVelocity(thisInitialVelocity, thisDimension);
 }
 public TestInertialScrollProcess(IInertialScrollProcessConstArg arg) : base(arg)
 {
 }