public void AndTest() { TriggerStub triggerA = new TriggerStub("A"); TriggerStub triggerB = new TriggerStub("B"); TriggerInput combined = triggerA.And(triggerB); Assert.That(combined.ToString(), Is.EqualTo("A+B")); ValueSpy <bool> spy = new ValueSpy <bool>(combined); triggerA.Update(true); spy.WaitFrame(); spy.AssertNothingHappened(); triggerA.Update(false); triggerB.Update(true); spy.WaitFrame(); spy.AssertNothingHappened(); triggerA.Update(true); spy.WaitFrame(); spy.AssertWasUpdatedTo(true); triggerA.Update(false); spy.WaitFrame(); spy.AssertWasUpdatedTo(false); triggerB.Update(false); spy.WaitFrame(); spy.AssertNothingHappened(); }
public void AsScalarTest() { TriggerStub trigger = new TriggerStub(); ValueSpy <float> spy = new ValueSpy <float>(trigger.AsScalar); spy.WaitFrame(); spy.AssertNothingHappened(); trigger.Update(true); spy.WaitFrame(); spy.AssertWasUpdatedTo(1); spy.WaitFrame(); spy.AssertNothingHappened(); trigger.Update(false); spy.WaitFrame(); spy.AssertWasUpdatedTo(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(); }