public void MRUTЕЕ() { // исходные данные int a = 3589; int b = 6295; int expected = 22592757; // получение значения с помощью тестируемого метода Mult Z1 = new Mult(); Z1.M1 = a; Z1.M2 = b; int actual = Z1.MRU(); // сравнение ожидаемого результата с полученным Assert.AreEqual(expected, actual); /* * Z1.ConvToMass(); * * Z1.MMU(); * * Z1.MKB_(); * Z1.MSU(); */ }
private void button16_Click(object sender, EventArgs e) { // Console.WriteLine(textBox1.Text.Substring(2)); //textBox1.Text = textBox1.Text.TrimStart(); num2 = double.Parse(textBox1.Text.Substring(2)); double Sum; double Res; double Mult; double Div; switch (operacion) { case "+": Sum = objSuma.Sumar((num1), (num2)); textBox1.Text = Sum.ToString(); break; case "-": Res = objRes.Restar((num1), (num2)); textBox1.Text = Res.ToString(); break; case "*": Mult = objMul.Multiplicar((num1), (num2)); textBox1.Text = Mult.ToString(); break; case "/": Div = objDiv.Dividir((num1), (num2)); textBox1.Text = Div.ToString(); break; } }
public MathTask Next() { _step++; MathTask t = null; do { var op = GetNextOperationType(); switch (op) { case Operation.Add: t = new Add(op, level); break; case Operation.Substract: t = new Substract(op, level); break; case Operation.Multiply: t = new Mult(op, level); break; case Operation.Divide: t = new Divide(op, level); break; case Operation.Prime: t = new Prime(op, level); break; case Operation.Perimeter: t = new Perimeter(op, level); break; } t.GenerateArgs(_step, _random); } while (hs.Contains(t.GetHashCode())); _tasks.Add(t); hs.Add(t.GetHashCode()); return(t); }
public void CalculateTest(double firstValue, double secondValue, double expected) { Mult calculator = new Mult(); var actualResult = calculator.Calculate(firstValue, secondValue); Assert.AreEqual(expected, actualResult); }
private string AddMults(Mult mult) { string res = String.Empty; bool is_seen = false; string key = mult.First; while (key != String.Empty) { if (is_seen) { res += "t"; } string val = mult.Value(key); if (val == String.Empty) { val = "\x1"; } res += LPack3(key) + LPack3(val); is_seen = true; key = mult.Order(key, 1); } if (!is_seen) { res += LPack3(String.Empty); } res += "f"; // *** Check current status *** if (this.Status == RpcMessageStatus.Error) { res = ""; } return(res); }
public int EvalInt(Vm vm) { var m = sign == "-" ? -1 : 1; var lhs = m * term.EvalInt(vm); foreach (var exprCont in cont) { IntOp intOp; if (exprCont.Op == "+") { intOp = new Add(); } else if (exprCont.Op == "-") { intOp = new Sub(); } else if (exprCont.Op == "*") { intOp = new Mult(); } else { intOp = new Div(); } var rhs = exprCont.Term.EvalInt(vm); lhs = intOp.Execute(lhs, rhs); } return(lhs); }
public void Test_StandSize2() { int[][] a = new int[2][] { new int[2] { 1, 2 }, new int[2] { 3, 4 } }; int[][] b = new int[2][] { new int[2] { 5, 6 }, new int[2] { 7, 8 } }; var res = Mult.MultStand(a, b); int[][] correctRes = new int[2][] { new int[2] { 19, 22 }, new int[2] { 43, 50 } }; Assert.IsNotNull(res); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { Assert.AreEqual(correctRes[i][j], res[i][j], "i, j: " + i.ToString() + " " + j.ToString()); } } }
public void CalculateTest(double firstArgument, double secondArgument, double result, double accracy) { var testingFunction = new Mult(); var testResult = testingFunction.Calculate(firstArgument, secondArgument); Assert.AreEqual(result, testResult, accracy); }
public void MultOpForward() { var nodeMockA = new Mock <Op <double> >(); var volA = new VolumeMock(1.0, new Shape(1)); nodeMockA.Setup(o => o.Evaluate(It.IsAny <Session <double> >())).Returns(volA); var nodeMockb = new Mock <Op <double> >(); var volB = new VolumeMock(2.0, new Shape(1)); nodeMockb.Setup(o => o.Evaluate(It.IsAny <Session <double> >())).Returns(volB); var op = new Mult <double>(nodeMockA.Object, nodeMockb.Object); using (var session = new Session <double>()) { var eval = op.Evaluate(session); Assert.IsNotNull(eval); var s = session; nodeMockA.Verify(o => o.Evaluate(s)); nodeMockb.Verify(o => o.Evaluate(s)); Assert.AreEqual(1, volA.DoMultiplyCount); } }
public RpcParameter(object arg) { if (arg == null) { this.ParameterType = RpcParameterType.Literal; this.Value = string.Empty; } else if ((arg is string) || (arg is EncryptedString) || (arg is char)) { this.ParameterType = RpcParameterType.Literal; this.Value = arg.ToString(); } else if (arg is Mult) { this.ParameterType = RpcParameterType.List; this.Value = MultValue; this.Mult = (Mult)arg; } else if (arg is string[]) { string[] arr = arg as string[]; Mult m = new Mult(); for (int i = 0; i < arr.Length; i++) { m[(i + 1).ToString()] = arr[i]; } this.ParameterType = RpcParameterType.List; this.Value = MultValue; this.Mult = m; } else { throw new ArgumentException("Invalid RPC Parameter Type: " + arg.GetType().Name); } }
static void Main(string[] args) { int x = 5; Sum s = a => a + a; Mult m = a => a * a; Console.WriteLine("({0} + {1}) ^ 2 = {2}", x, x, m(s(x))); Console.WriteLine("({0} * {1}) + this.result = {2}", x, x, s(m(x))); //imperative composition Console.WriteLine("\nImperative composition"); SumMult sm = a => { int holder = a; holder = s(a); holder = m(holder); return(holder); }; Console.WriteLine("Delegate SumMult ({0} + {1}) ^ 2 = {2}", x, x, sm(x)); //function composition Console.WriteLine("\nFunction composition"); Operation opMult = a => a * a; Operation opSum = a => a + a; Compose compose = (f1, f2, a) => f1(f2(a)); Console.WriteLine("Delegate Compose(Mult, Sum) ({0} + {1}) ^ 2 = {2}", x, x, compose(opMult, opSum, x)); Console.WriteLine("Delegate Compose(Sum, Mult) ({0} * {1}) + this.result = {2}", x, x, compose(opSum, opMult, x)); Console.ReadKey(); }
public void Visit(Mult p) { //operand are both on stack Console.WriteLine("Pop stack into a"); Console.WriteLine("Pop stack into b"); Console.WriteLine("mult a, b"); Console.WriteLine("push result of a * b onto stack"); }
public void CalculateTest() { Mult calculator = new Mult(); Assert.AreEqual(10, calculator.Calculate(5, 2)); Assert.AreEqual(100, calculator.Calculate(10, 10)); Assert.AreEqual(-5, calculator.Calculate(5, -1)); }
public OperateurTest() { val = new Numeric[2]; this.val[0] = new Numeric("6"); this.val[1] = new Numeric("2"); p = new Plus(this.val); mul = new Mult(this.val); mod = new Modulo(this.val); min = new Minus(this.val); d = new Div(this.val); }
public Memory(Register _r1, Register _r2, Mult _mult, Immediate _imm, OPSIZE _size, Segment.SEG _seg) { r1 = _r1; r2 = _r2; mult = _mult; imm = _imm; if (imm != null) { imm.isOffset = true; } size = _size; seg = _seg; }
public EvalAndViewTests() { _constExpr1 = new Const(7); _constExpr2 = new Const(2); _constExpr3 = new Const(3); _addExpr1 = new Add(_constExpr1, _constExpr2); _multExpr1 = new Mult(_constExpr1, _constExpr2); _multExpr2 = new Mult(_constExpr2, _constExpr3); _addExpr2 = new Add(_multExpr1, _multExpr2); }
public void Mult() { var a = new Const <double>(1.0, "one"); var b = new Const <double>(2.0, "two"); var op = new Mult <double>(a, b); var xml = op.ToXml(); var deserialized = SerializationExtensions.FromXml <double>(xml) as Mult <double>; Assert.IsNotNull(deserialized); Assert.AreEqual(2, deserialized.Parents.Count); Assert.AreEqual("one", (deserialized.Parents[0] as Const <double>).Name); Assert.AreEqual("two", (deserialized.Parents[1] as Const <double>).Name); }
public void Constants(string x1, string x2, double r1, double r2) { Terminal op1 = new Terminal(x1); Terminal op2 = new Terminal(x2); Mult m = new Mult(op1, op2); Div d = new Div(op1, op2); Addition a = new Addition(op1, op2); Subtraction s = new Subtraction(op1, op2); Assert.True(m.Compute(0) == r1 * r2); Assert.True(a.Compute(0) == r1 + r2); Assert.True(s.Compute(0) == r1 - r2); Assert.True(d.Compute(0) == r1 / r2); }
public void Variables(double x, double y) { Terminal op1 = new Terminal("x0"); Terminal op2 = new Terminal("x1"); Mult m = new Mult(op1, op2); Div d = new Div(op1, op2); Addition a = new Addition(op1, op2); Subtraction s = new Subtraction(op1, op2); Assert.True(m.Compute(x, y) == x * y); Assert.True(d.Compute(x, y) == x / y); Assert.True(a.Compute(x, y) == x + y); Assert.True(s.Compute(x, y) == x - y); }
/// <summary> /// This method serves UC-CALC-MUL external interface. /// </summary> /// <param name="Factors">the inputs of a arithmetic operation</param> /// <returns>the arithmetic operation result</returns> public Mult Mult(List <int> Factors) { Mult mul = new Mult(); try { mul.Product = Factors.Aggregate((total, next) => total * next);; } catch (Exception ex) { throw new DataException("Error dao Add.", ex); } return(mul); }
public void Test_StandSize1() { int[][] a = new int[1][]; a[0] = new int[1] { 2 }; int[][] b = new int[1][]; b[0] = new int[1] { 3 }; var res = Mult.MultStand(a, b); Assert.IsNotNull(res); Assert.AreEqual(6, res[0][0]); }
private void button16_Click(object sender, EventArgs e) { Op2 = double.Parse(tbxPant.Text); double Mult; double Div; double Sum; double Rest; if (Operacion == "x") { Mult = obj1.Multi(Op1, Op2); //creo la operacion si es que sale mult , lo hare analogo para todas las operaciones tbxPant.Text = Mult.ToString(); op3 = Mult; Hist.Add(Mult.ToString()); } else if (Operacion == "/") { Div = obj2.Divi(Op1, Op2); //creo la operacion si es que sale mult , lo hare analogo para todas las operaciones if (Op2 != 0) { tbxPant.Text = Div.ToString(); op3 = Div; Hist.Add(Div.ToString()); } else if (Op2 == 0) { tbxPant.Text = "match ERORR"; } } else if (Operacion == "+") { Sum = obj3.Sumar(Op1, Op2); //creo la operacion si es que sale mult , lo hare analogo para todas las operaciones tbxPant.Text = Sum.ToString(); op3 = Sum; Hist.Add(Sum.ToString()); } else if (Operacion == "-") { Rest = obj4.Restar(Op1, Op2); //creo la operacion si es que sale mult , lo hare analogo para todas las operaciones tbxPant.Text = Rest.ToString(); op3 = Rest; Hist.Add(Rest.ToString()); } }
private void Multiplicacion(object sender, EventArgs e) { Double n1, n2, Mult; n1 = Convert.ToDouble(txtNum1.Text); n2 = Convert.ToDouble(txtNum2.Text); Mult = n1 * n2; labelResultado.Text = Mult.ToString(); if (txtNum1.Text == "") { labelResultado.Text = "No hay numero 1"; } else if (txtNum2.Text == "") { labelResultado.Text = "No hay numero 2"; } }
private void BuildUnitMultiList() { foreach (var msgtype in FMT) { // get unit and mult info var fmtu = FMTU.FirstOrDefault(a => a.Key == msgtype.Key); if (fmtu.Value == null) { continue; } var units = fmtu.Value.Item1.ToCharArray().Select(a => Unit.FirstOrDefault(b => b.Key == a)); var multipliers = fmtu.Value.Item2.ToCharArray().Select(a => Mult.FirstOrDefault(b => b.Key == a)); var binfmts = msgtype.Value.Item3.ToCharArray(); var itemcount = msgtype.Value.Item4.Split(',').Length; if (binfmts.Length != itemcount) { continue; } for (var i = 0; i < itemcount; i++) { var field = msgtype.Value.Item4.Split(',')[i].Trim(); var unit = units.Skip(i).FirstOrDefault().Value; var binfmt = binfmts[i]; var multi = 1.0; double.TryParse(multipliers.Skip(i).FirstOrDefault().Value, NumberStyles.Any, CultureInfo.InvariantCulture, out multi); if (binfmt == 'c' || binfmt == 'C' || binfmt == 'e' || binfmt == 'E' || binfmt == 'L') { // these are scaled from the DF format * 100/1e7 etc // to ensure csv's continue to work we dont modify these values // 1 = no change multi = 1; } UnitMultiList.Add( new Tuple <string, string, string, double>(msgtype.Value.Item2, field, unit, multi)); } } }
//Fin para saber la operacion. //Calcular el resultado. private void ButFin_Click(object sender, EventArgs e) { //Variables de resultado Double Res; Double Sum; Double Mult; Double Div; //Segundo valor. P2 = Double.Parse(TBScreen.Text); switch (Op) { case "+": Sum = P1 + P2; TBScreen.Text = Sum.ToString(); break; case "-": Res = P1 - P2; TBScreen.Text = Res.ToString(); break; case "*": Mult = P1 * P2; TBScreen.Text = Mult.ToString(); break; case "/": Div = P1 / P2; if (Div != 0) { TBScreen.Text = Div.ToString(); } else { MessageBox.Show("No se puede dividir entre 0."); } break; } LabelEstado.Text = ""; }
public void Composed(double value) { Terminal x = new Terminal("x0"); Terminal one = new Terminal("1"); Addition a2 = new Addition(one, one); //y Mult aa = new Mult(a2, a2); //y^2 Mult xx = new Mult(x, x); //x^2 Subtraction s = new Subtraction(xx, aa); // x^2 - y^2 Addition xay = new Addition(x, a2); // x + y Subtraction xsy = new Subtraction(x, a2); // x - y Mult f = new Mult(xay, xsy); // (x + y)(x - y) Assert.True(f.Compute(value) == (value + 2) * (value - 2)); Assert.True(s.Compute(value) == (value * value) - 4); Assert.True(s.Compute(value) == f.Compute(value)); //(x + y)(x - y) == (x^2 - y^2) }
public void Test_WrongSize_NullReturned() { int sizeA = 2, sizeB = 3; int[][] a = new int[sizeA][]; for (int i = 0; i < sizeA; i++) { a[i] = new int[sizeA]; } int[][] b = new int[sizeB][]; for (int i = 0; i < sizeB; i++) { b[i] = new int[sizeB]; } var res = Mult.MultStand(a, b); Assert.IsNull(res); }
public async Task ParseMultsAsync() { HtmlWeb web = new HtmlWeb(); var actualUrl = GetActualUrl(); var parentNodeXPath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' organic')]//div[contains(concat(' ', normalize-space(@class), ' '), ' indicator')]"; var htmlDoc = web.Load(actualUrl); var nodes = htmlDoc.DocumentNode.SelectNodes(parentNodeXPath); var russianCaptionNodeXPath = ".//span[@class ='live_namerus']"; var seriesNodeXPath = ".//span[@class ='live_series']"; foreach (var node in nodes) { Mult multObject = new Mult { RussianCaption = node.SelectSingleNode(russianCaptionNodeXPath).InnerText, Series = node.SelectSingleNode(seriesNodeXPath).InnerText, UpdateDate = DateTime.Now.Date }; var existingMult = _adultMultContext.Mults.FirstOrDefault(x => x.RussianCaption == multObject.RussianCaption); if (existingMult != null) { if (multObject.Series != existingMult.Series) { existingMult.Series = multObject.Series; existingMult.IsUpdated = true; await _adultMultContext.SaveChangesAsync(); } } else { multObject.IsUpdated = true; await _adultMultContext.Mults.AddAsync(multObject); } } await _adultMultContext.SaveChangesAsync(); }
public void Test_EvenStandardEqualsVin_Random() { int n = 10; int[][] a = Program.FillMatr(n, n); int[][] b = Program.FillMatr(n, n); var resStand = Mult.MultStand(a, b); var resVin = Mult.MultVin(a, b); Assert.IsNotNull(resStand); Assert.IsNotNull(resVin); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { Assert.AreEqual(resStand[i][j], resVin[i][j], "i, j: " + i.ToString() + " " + j.ToString()); } } }
static void Main(string[] args) { Somar soma = new Somar(); Diminuir diminuir = new Diminuir(); Mult mult = new Mult(); Divide divide = new Divide(); Console.WriteLine("Calculadora básica em C#"); Console.WriteLine(""); Console.WriteLine("Escolha qual operação você vai realizar: (1) Adição, (2) Subtração, (3) Multiplicação, (4) Divisão"); int operacao = int.Parse(Console.ReadLine()); switch (operacao) { case 1: soma.Soma(); break; case 2: diminuir.Sub(); break; case 3: mult.Multi(); break; case 4: divide.Div(); break; default: Console.WriteLine("Passe somente os valores corretos"); break; } }
//CONSTRUCTORS public StatusEffect( string name, Mult multiplier ) : base( name ) { multProps.Add( multiplier ); }