public void EvaluationSucceedsWithMultipleExecutionConditions() { //Session 1 JSONObject limitations = getLimitations( new JSONObject { { "executionsRequiredCount", "2" } }, new JSONObject { { "executionsRequiredCount", "4" } }); GameEvent evnt = Evnt( "a", new object[] { "a", 10, "b", 5, "c", "c", "d", true }); EventTrigger trigger = getEventTrigger( limitations, evnt, "c".P(), "c".S(), "equal to".O()); Expect(trigger.Evaluate(evnt), Is.False); Expect(trigger.Evaluate(evnt), Is.True); Expect(trigger.Evaluate(evnt), Is.False); Expect(trigger.Evaluate(evnt), Is.True); }
public void EvaluationSucceedsOnMultipleExecutionsWithLimits() { JSONObject limitations = getLimitations( new JSONObject { { "executionsRepeat", "2" }, { "executionsRepeatLimit", "2" } }, new JSONObject { { "executionsRepeat", "3" }, { "executionsRepeatLimit", "3" } }, new JSONObject { { "executionsRepeat", "7" }, { "executionsRepeatLimit", "1" } } ); GameEvent evnt = Evnt( "a", new object[] { "a", 10, "b", 5, "c", "c", "d", true }); EventTrigger trigger = getEventTrigger( limitations, evnt, "c".P(), "c".S(), "equal to".O()); Expect(trigger.Evaluate(evnt), Is.False, "Execution 1 should not trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 2 should trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 3 should trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 4 should trigger"); Expect(trigger.Evaluate(evnt), Is.False, "Execution 5 should not trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 6 should trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 7 should trigger"); Expect(trigger.Evaluate(evnt), Is.False, "Execution 8 should not trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 9 should trigger"); Expect(trigger.Evaluate(evnt), Is.False, "Execution 10 should not trigger"); }
public void IsEvaluatedIndefinitelyByDefault() { var uut = new EventTrigger(ddna, 0, "{\"eventName\":\"a\"}".Json(), new ExecutionCountManager()); var evnt = new GameEvent("a"); for (int i = 0; i < 10; i++) { Expect(uut.Evaluate(evnt)); } }
public void EvaluationFailsWhenExecutionsLessThanRepeatCount() { JSONObject limitations = getLimitations( new JSONObject { { "executionsRepeat", "3" } }); GameEvent evnt = Evnt( "a", new object[] { "a", 10, "b", 5, "c", "c", "d", true }); EventTrigger trigger = getEventTrigger( limitations, evnt, "c".P(), "c".S(), "equal to".O()); Expect(trigger.Evaluate(evnt), Is.False); Expect(trigger.Evaluate(evnt), Is.False); }
public void IsEvaluatedUpToTheLimitNumberOfTimes() { var limit = 3; var uut = new EventTrigger( ddna, 0, ("{\"eventName\":\"a\",\"limit\":" + limit + "}").Json(), new ExecutionCountManager()); var evnt = new GameEvent("a"); for (var i = 0; i <= limit; i++) { if (i < limit) { Expect(uut.Evaluate(evnt)); } else { Expect(uut.Evaluate(evnt), Is.False); } } }
public void EvaluationSucceedsOnRepeatedExecutions() { JSONObject limitations = getLimitations( new JSONObject { { "executionsRepeat", "2" } }); GameEvent evnt = Evnt( "a", new object[] { "a", 10, "b", 5, "c", "c", "d", true }); EventTrigger trigger = getEventTrigger( limitations, evnt, "c".P(), "c".S(), "equal to".O()); Expect(trigger.Evaluate(evnt), Is.False); Expect(trigger.Evaluate(evnt), Is.True); Expect(trigger.Evaluate(evnt), Is.False); Expect(trigger.Evaluate(evnt), Is.True); }
public void EvaluationSucceedsOnRepeatedExecutionsAndRequiredExecutions() { JSONObject limitations = getLimitations( new JSONObject { { "executionsRepeat", "4" } }, new JSONObject { { "executionsRequiredCount", "3" } }, new JSONObject { { "executionsRequiredCount", "7" } } ); GameEvent evnt = Evnt( "a", new object[] { "a", 10, "b", 5, "c", "c", "d", true }); EventTrigger trigger = getEventTrigger( limitations, evnt, "c".P(), "c".S(), "equal to".O()); // succeed on 3, 4, 7, and 8 Expect(trigger.Evaluate(evnt), Is.False, "Execution 1 should not trigger"); Expect(trigger.Evaluate(evnt), Is.False, "Execution 2 should not trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 3 should trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 4 should trigger"); Expect(trigger.Evaluate(evnt), Is.False, "Execution 5 should not trigger"); Expect(trigger.Evaluate(evnt), Is.False, "Execution 6 should not trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 7 should trigger"); Expect(trigger.Evaluate(evnt), Is.True, "Execution 8 should trigger"); Expect(trigger.Evaluate(evnt), Is.False, "Execution 9 should not trigger"); Expect(trigger.Evaluate(evnt), Is.False, "Execution 10 should not trigger"); }