public void PerformConditionalAsyncFunction_WithFailedCondition_ShouldPerformDefaultFunction() { VerifyAsync(async() => { int count = 0; IGateContext gateContext = new GateContext(new UnitTestGatedRequest(), new BasicMachineInformation(), new DefaultExperimentContext()); await gateContext.PerformConditionalFunction( () => false, new GatedAsyncFunc <int>( Gates.GetGate("ActiveGate1"), () => { count = 1; return(Task.FromResult(count)); }), new GatedAsyncFunc <int>( () => { count = 2; return(Task.FromResult(count)); })); Assert.Equal(count, 2); }); }
public void PerformConditionalFunction_WithFailedCondition_ShouldPerformDefaultFunction() { int count = 0; IGateContext gateContext = new GateContext(new UnitTestGatedRequest(), new BasicMachineInformation(), new DefaultExperimentContext()); gateContext.PerformConditionalFunction( () => { return(false); }, new GatedFunc <int>( Gates.GetGate("ActiveGate1"), () => { count += 1; return(count); }), new GatedFunc <int>( () => { count += 2; return(count); })); Assert.Equal(count, 2); }
public void PerformConditionalAsyncFunction_NonValidGates_ShouldNotPerformAnyGatedFunction() { VerifyAsync(async() => { int count = 0; IGateContext gateContext = new GateContext(new UnitTestGatedRequest(), new BasicMachineInformation(), new DefaultExperimentContext()); await gateContext.PerformConditionalFunction( () => true, new GatedAsyncFunc <int>( Gates.GetGate("InactiveGate1"), () => { count += 1; return(Task.FromResult(count)); }), new GatedAsyncFunc <int>( Gates.GetGate("InactiveGate2"), () => { count += 2; return(Task.FromResult(count)); })); Assert.Equal(count, 0); }); }
public void PerformConditionalFunction_NonValidGates_ShouldNotPerformAnyGatedFunction() { int count = 0; IGateContext gateContext = new GateContext(new UnitTestGatedRequest(), new BasicMachineInformation(), new DefaultExperimentContext()); gateContext.PerformConditionalFunction( () => { return(true); }, new GatedFunc <int>( Gates.GetGate("InactiveGate1"), () => { count += 1; return(count); }), new GatedFunc <int>( Gates.GetGate("InactiveGate2"), () => { count += 2; return(count); })); Assert.Equal(count, 0); }