コード例 #1
0
        public void executes_argumentExpressions_in_order()
        {
            var function            = new FunctionWithParameters();
            var argumentExpressions = new Dictionary <string, IExpression>
            {
                [nameof(FunctionWithParameters.Parameter2)] = new ConstantExpression <string>(),
                [nameof(FunctionWithParameters.Parameter1)] = new ConstantExpression <int>()
            };

            var expressionExecutor = Substitute.For <IExpressionExecutor>();
            var executionOrder     = new List <int>();

            expressionExecutor.Execute(argumentExpressions[nameof(FunctionWithParameters.Parameter1)])
            .Returns(_ =>
            {
                executionOrder.Add(0);
                return(0);
            });

            expressionExecutor.Execute(argumentExpressions[nameof(FunctionWithParameters.Parameter2)])
            .Returns(_ =>
            {
                executionOrder.Add(1);
                return(null);
            });

            Act(function, argumentExpressions, expressionExecutor);

            executionOrder.Should().Equal(0, 1);
        }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: androidZ200/Graphics
 public void DeleteFunc(FunctionWithParameters <double> key)
 {
     lock (drawinglock)
         functions.Remove(key);
     UpdateParametrs();
     UpdateComboBox();
 }
コード例 #3
0
ファイル: FormMain.cs プロジェクト: androidZ200/Graphics
 private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex == 0)
     {
         FunctionWithParameters <double> f = new FunctionWithParameters <double>(new NaN <double>());
         lock (drawinglock)
             functions.Add(f, "");
         FormFunc form = new FormFunc(new KeyValuePair <FunctionWithParameters <double>, string>(f, ""), builder, this);
         form.Show();
     }
     else if (comboBox1.SelectedIndex < functions.Count + 1)
     {
         var enumer = functions.GetEnumerator();
         for (int i = 0; i < comboBox1.SelectedIndex; i++)
         {
             enumer.MoveNext();
         }
         FormFunc form = new FormFunc(enumer.Current, builder, this);
         form.Show();
     }
     else
     {
         int       i    = comboBox1.SelectedIndex - functions.Count - 1;
         FormParam form = new FormParam(this, parametrs.ElementAt(i));
         form.Show();
     }
 }
コード例 #4
0
ファイル: FormMain.cs プロジェクト: androidZ200/Graphics
 public void ChangetFunc(FunctionWithParameters <double> key, KeyValuePair <FunctionWithParameters <double>, string> newFunc)
 {
     lock (drawinglock)
     {
         functions.Remove(key);
         functions.Add(newFunc.Key, newFunc.Value);
     }
     UpdateParametrs();
     UpdateComboBox();
 }
コード例 #5
0
        public void function_with_parameters___passes_function_with_filled_parameters_to_functionExecutor(int argument1Value, string argument2Value)
        {
            var function            = new FunctionWithParameters();
            var argumentExpressions = new Dictionary <string, IExpression>
            {
                [nameof(FunctionWithParameters.Parameter1)] = new ConstantExpression <int>(),
                [nameof(FunctionWithParameters.Parameter2)] = new ConstantExpression <string>()
            };

            var expressionExecutor = Substitute.For <IExpressionExecutor>();

            expressionExecutor.Execute(argumentExpressions[nameof(FunctionWithParameters.Parameter1)])
            .Returns(argument1Value);

            expressionExecutor.Execute(argumentExpressions[nameof(FunctionWithParameters.Parameter2)])
            .Returns(argument2Value);

            Act(function, argumentExpressions, expressionExecutor);

            function.Parameter1.Should().Be(argument1Value);
            function.Parameter2.Should().Be(argument2Value);
        }