Created
October 13, 2012 20:49
-
-
Save adamralph/3886106 to your computer and use it in GitHub Desktop.
xBehave.net re-write for bwatts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RuntimeFeature | |
{ | |
[Scenario] | |
public void ApplyDependentCalculation() | |
{ | |
int _left1; | |
int _right1; | |
int _left2; | |
Variable _outputVariable1; | |
Variable _outputVariable2; | |
GraspRuntime _runtime; | |
"Given (fill in something sensible here)" | |
.Given(() => | |
{ | |
_left1 = 1; | |
_right1 = 2; | |
_left2 = 10; | |
_outputVariable1 = new Variable("Grasp", "Output1", typeof(int)); | |
_outputVariable2 = new Variable("Grasp", "Output2", typeof(int)); | |
var calculation1 = new Calculation(_outputVariable1, Expression.Add(Expression.Constant(_left1), Expression.Constant(_right1))); | |
var calculation2 = new Calculation(_outputVariable2, Expression.Add(Expression.Constant(_left2), Variable.Expression(_outputVariable1))); | |
var schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { calculation1, calculation2 }); | |
var executable = schema.Compile(); | |
_runtime = executable.GetRuntime(A.Fake<IRuntimeSnapshot>()); | |
}; | |
"When applying calculations" | |
.When(() => _runtime.ApplyCalculations()); | |
"Then the output variable is set to the correct value" | |
.Then(() => Assert.That(_runtime.GetVariableValue(_outputVariable1), Is.EqualTo(_left1 + _right1))); | |
} | |
"And the output variable 2 is set to the correct value" | |
.And(() => | |
{ | |
var outputVariable1Value = (int) _runtime.GetVariableValue(_outputVariable1); | |
Assert.That(_runtime.GetVariableValue(_outputVariable2), Is.EqualTo(_left2 + outputVariable1Value)); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment