Example #1
0
        public void WithoutSignTest()
        {
            ScalarStub       original = new ScalarStub("value");
            ValueSpy <float> spy      = new ValueSpy <float>(original.WithoutSign);

            original.Update(-2);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(2.0f);
        }
Example #2
0
        public void ValueOverTest()
        {
            ScalarStub      value = new ScalarStub();
            ValueSpy <bool> spy   = new ValueSpy <bool>(value.IsOver(2.0f));

            spy.WaitFrame();
            spy.AssertNothingHappened();

            value.Update(2.5f);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(true);

            spy.WaitFrame();
            spy.AssertNothingHappened();

            value.Update(1.5f);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(false);
        }
Example #3
0
        public void OperatorMinusTest()
        {
            ScalarStub       a   = new ScalarStub("a");
            ScalarStub       b   = new ScalarStub("b");
            ValueSpy <float> spy = new ValueSpy <float>(a - b);

            spy.WaitFrame();
            spy.AssertNothingHappened();

            a.Update(3);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(3);

            spy.WaitFrame();
            spy.AssertNothingHappened();

            b.Update(2);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(1);
        }
Example #4
0
        public void CombineScalarsToVectorTest()
        {
            ScalarStub         x   = new ScalarStub("x");
            ScalarStub         y   = new ScalarStub("y");
            ValueSpy <Vector2> spy = new ValueSpy <Vector2>(Combine.ScalarsToVector(x, y));

            spy.WaitFrame();
            spy.AssertNothingHappened();

            x.Update(0.5f);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(new Vector2(0.5f, 0));

            spy.WaitFrame();
            spy.AssertNothingHappened();

            y.Update(-1);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(new Vector2(0.5f, -1));
        }