Esempio n. 1
0
        public Task <string> AddRequestAsync(string doc)
        {
            var addFunction = new AddFunction();

            addFunction.Doc = doc;
            return(ContractHandler.SendRequestAsync(addFunction));
        }
Esempio n. 2
0
        public Task <TransactionReceipt> AddRequestAndWaitForReceiptAsync(string doc, CancellationTokenSource cancellationToken = null)
        {
            var addFunction = new AddFunction();

            addFunction.Doc = doc;

            return(ContractHandler.SendRequestAndWaitForReceiptAsync(addFunction, cancellationToken));
        }
Esempio n. 3
0
        private static void DelegateExample()
        {
            Calculator calc = new Calculator();

            AddFunction func = calc.Add;

            Console.WriteLine(func.Invoke(1, 2));
        }
Esempio n. 4
0
        private void editFunctionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddFunction addFunction = new AddFunction();

            addFunction.InitializeFunction = functionList.FunctionList.Current as Function;
            addFunction.IsEditFunction     = true;
            addFunction.IsValidated        = true;
            addFunction.DataSource         = functionList.FunctionList;
            addFunction.FunctionOK        += this.addFunction_FunctionOK;
            addFunction.ShowDialog(sender as IWin32Window);
        }
Esempio n. 5
0
        private void addFunctionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddFunction addFunction = new AddFunction();

            addFunction.IsValidated         = true;
            addFunction.DataSource          = functionList.FunctionList;
            addFunction.BackGroundAxisColor = SettingsForm.BackGroundColor;
            addFunction.FunctionOK         += addFunction_FunctionOK;

            addFunction.ShowDialog(sender as IWin32Window);
        }
Esempio n. 6
0
 /// <summary>
 /// Выбор пользователем метода сложения по ключу <see = cref "choice"/>
 /// </summary>
 /// <param name="choice">Ключ, по которому выбирается нужная версия функции сложения</param>
 void ChoseFunc(char choice)
 {
     if (keyMapper.ContainsKey(choice))
     {
         Add = keyMapper[choice];
     }
     else
     {
         Add = null;
     }
 }
Esempio n. 7
0
        public void SuccessfullySetFunctionInfo()
        {
            var function = new AddFunction();

            Assert.NotNull(function.FunctionInfo);
            Assert.Equal("Add", function.FunctionInfo.Name);
            Assert.Equal(new Version("1.0.0"), function.FunctionInfo.Version);
            Assert.Equal("Add numbers.", function.FunctionInfo.Description);
            Assert.Collection(function.FunctionInfo.Tags,
                              i => Assert.Equal("algebra", i),
                              i => Assert.Equal("add", i));
        }
        public void FailToAddASingleNumber()
        {
            var function = new AddFunction();

            Assert.Throws <ArgumentException>(() =>
            {
                var inputs = function.GetInputs();

                inputs[0].Value = new [] { 1 };

                var result = function.Calculate(inputs);
            });
        }
Esempio n. 9
0
        public void Calculator_Works()
        {
            //Arrange
            AddFunction addFunction = new AddFunction();

            addFunction.ValueA = 50;
            addFunction.ValueB = 40;

            //Act
            var result = this._sut.Calculate(addFunction);

            //Assert
            result.Should().Be(90);
        }
 private static void _test<T>(AddFunction<T> addFunction, Collection<T> toAdd)
 {
     UniqueCollection<T> uniqueCollection = new UniqueCollection<T>();
     try
     {
         addFunction(uniqueCollection, toAdd);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     finally
     {
         uniqueCollection.Print();
     }
 }
Esempio n. 11
0
        public void TestDelimiterFunction()
        {
            ValueFunction function = new AddFunction();
            ValueDelimiter delim = new ValueDelimiter(">", DelimiterType.AsArray, function);
            List<DelimiterNode> nodes = new List<DelimiterNode>();
            nodes.Add(ToNode("3"));
            nodes.Add(ToNode("6"));
            nodes.Add(ToNode("9"));
            DelimiterList list = new DelimiterList(delim, nodes, 0, "<", "3 6 9", null);
            DelimiterNodeList nodelist = new DelimiterNodeList(list);

            IScope scope = new TestScope();
            INodeRequestor values = new TestValueNodeRequestor(nodelist);

            Value result = EvalNode.Do(nodelist, scope, values, null);
            Assert.AreEqual(18, result.AsInt);
        }
        public void SuccessfullyAddNumbers()
        {
            var function = new AddFunction();

            var inputs = function.GetInputs();

            Assert.Single(inputs);

            inputs[0].Value = new [] { 1, 2, 3 };

            var result = function.Calculate(inputs);

            Assert.NotNull(result);
            Assert.Collection(result,
                              i =>
            {
                Assert.Equal(typeof(double), i.Value.GetType());
                Assert.Equal(6, TypeConverter.ToObject <int>(i.Value));
            });
        }
Esempio n. 13
0
 public Task <TransactionReceipt> AddRequestAndWaitForReceiptAsync(AddFunction addFunction, CancellationTokenSource cancellationToken = null)
 {
     return(ContractHandler.SendRequestAndWaitForReceiptAsync(addFunction, cancellationToken));
 }
Esempio n. 14
0
 public Task <string> AddRequestAsync(AddFunction addFunction)
 {
     return(ContractHandler.SendRequestAsync(addFunction));
 }
Esempio n. 15
0
 public void SetAddFunction(AddFunction addFunc)
 {
     this.addFunc = addFunc;
 }
Esempio n. 16
0
 public override void ToFunction(out Function function)
 {
     _left.ToFunction(out var leftF);
     _right.ToFunction(out var rightF);
     function = new AddFunction(leftF, rightF);
 }