示例#1
0
        public void ValueFellBelowTest()
        {
            ScalarStub      value = new ScalarStub();
            ValueSpy <bool> spy   = new ValueSpy <bool>(value.FellBelow(2.0f));

            value.Update(2.5f);

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

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

            spy.WaitFrame();
            spy.AssertWasUpdatedTo(false);

            value.Update(2.5f);
            spy.WaitFrame();
            spy.AssertNothingHappened();
        }
示例#2
0
        public void CombineTriggersToAxisTest()
        {
            TriggerStub      positive = new TriggerStub("positive");
            TriggerStub      negative = new TriggerStub("negative");
            ValueSpy <float> spy      = new ValueSpy <float>(Combine.TriggersToAxis(positive, negative));

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

            positive.Update(true);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(1);

            negative.Update(true);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(0);

            positive.Update(false);
            spy.WaitFrame();
            spy.AssertWasUpdatedTo(-1);

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