A context in which a set of variables and a set of calculations are in effect
Exemplo n.º 1
0
        protected override void Given()
        {
            _variables = new[] { new Variable("Grasp", "Test", typeof(int)), new Variable("Grasp", "Test2", typeof(int)) };

            _calculations = new[]
            {
                new Calculation(new Variable("Grasp", "TestOutput", typeof(int)), Expression.Constant(0)),
                new Calculation(new Variable("Grasp", "Test2Output", typeof(int)), Expression.Constant(1))
            };

            _schema = new GraspSchema(_variables, _calculations);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a runtime with the specified schema, calculator, and bindings
        /// </summary>
        /// <param name="schema">The schema which defines the variables and calculations in effect for this runtime</param>
        /// <param name="calculator">The calculator which applies the specified schema's calculations to this runtime</param>
        /// <param name="bindings">The initial states of the variables in this runtime</param>
        public GraspRuntime(GraspSchema schema, ICalculator calculator, IEnumerable<VariableBinding> bindings)
        {
            Contract.Requires(schema != null);
            Contract.Requires(calculator != null);
            Contract.Requires(bindings != null);

            // TODO: Ensure that all bound variables exist in schema

            Schema = schema;
            Calculator = calculator;

            _bindingsByVariable = bindings.ToDictionary(binding => binding.Variable);
        }
Exemplo n.º 3
0
 protected override void When()
 {
     _schema = new GraspSchema(_variables, _calculations);
 }