public void MathFunctionOfSqrtReturnsCorrectValueFor2() { IExpression argument = new VariableX(); IExpression mathFun = new MathFunction(Math.Sqrt, argument); Assert.AreEqual(Math.Sqrt(2.0), mathFun.Interpret(new Context(2))); }
public void MultiplicationExpressionEvaluatesDifferenceOfComplexDecimalExpression() { // 3 / x - 7 + x / 2 IExpression three = new Constant(3); IExpression x = new VariableX(); IExpression seven = new Constant(7); IExpression two2 = new Constant(2); IExpression result = new DivideExpression(three, x); result = new SubtractionExpression(result, seven); result = new SumExpression(result, x); result = new DivideExpression(result, two2); Context c = new Context(0.5); var y = result.Interpret(c); Assert.AreEqual(-0.25, y, 1e-10); c = new Context(1.5); y = result.Interpret(c); Assert.AreEqual(-1.75, y, 1e-10); }
public void SubtractionExpressionEvaluatesDifferenceInComplexExpression() { //mnozenje djeljenje testovi, cos i sin sa metodom // 2 + x - 7 + x - 10 IExpression two = new Constant(2); IExpression x = new VariableX(); IExpression seven = new Constant(7); IExpression ten = new Constant(10); IExpression result = new SumExpression(two, x); result = new SubtractionExpression(result, seven); result = new SumExpression(result, x); result = new SubtractionExpression(result, ten); Context c = new Context(5); List <IExpression> operand = new List <IExpression>(); List <IExpression> operations = new List <IExpression>(); var y = result.Interpret(c); Assert.AreEqual(-5, y, 1e-10); c = new Context(-3); y = result.Interpret(c); Assert.AreEqual(-21, y, 1e-10); }
public void MultiplicationExpressionEvaluatesDifferenceOfComplexDecimalExpression() { // 2 * x - 7 + x * 10 IExpression two = new Constant(2); IExpression x = new VariableX(); IExpression seven = new Constant(7); IExpression ten = new Constant(10); IExpression result = new MultiplyExpression(two, x); result = new SubtractionExpression(result, seven); result = new SumExpression(result, x); result = new MultiplyExpression(result, ten); Context c = new Context(0.5); var y = result.Interpret(c); Assert.AreEqual(-55, y, 1e-10); c = new Context(1.5); y = result.Interpret(c); Assert.AreEqual(-25, y, 1e-10); }
public void SumExpressionInterpretForTwoVariablesReturnsTheirSum() { IExpression left = new VariableX(); IExpression right = new VariableX(); SumExpression sum = new SumExpression(left, right); Context context = new Context(4); Assert.AreEqual(8, sum.Interpret(context)); }
public void SumExpressionInterpretForConstantsAndVariableReturnsTheirSum() { IExpression left = new VariableX(); IExpression right = new Constant("2"); SumExpression sum = new SumExpression(left, right); Context context = new Context(3); Assert.AreEqual(5, sum.Interpret(context)); }
public IActionResult RemovePhoto(string CodliSecret) { //Budowa zmiennej sekretnej /* ID_Galeri_#Codli-Secret#_ID_Zdjęcia */ string[] array = VariableX.SplitStringByString(CodliSecret, "#Codli-Secret#"); var zdjecie = (from c in db.Zdjecia where c.ZdjeciaModelId == int.Parse(array[1]) select c).FirstOrDefault <ZdjeciaModel>(); db.Remove(zdjecie); db.SaveChanges(); return(Content("Wykonano!")); }
public void MathFunctionReturnsValueAndCalculatesTheSentenceWithUnknown3() { // 2 + atan(x) + x IExpression two = new Constant(2); string function = "ata(x)"; FunctionConverter f = new FunctionConverter(); IExpression value = new VariableX(); IExpression mathFun = new MathFunction(f.Translator(function), value); IExpression x = new VariableX(); IExpression result = new SumExpression(two, mathFun); result = new SumExpression(result, x); Context c = new Context(1); var y = result.Interpret(c); Assert.AreEqual(3.785, y, 4); }
public void MathFunctionReturnsValueAndCalculatesTheSentenceWithFunLog2() { // 2 + cos(-123) + x IExpression two = new Constant(2); string function = "cos(-123)"; FunctionConverter f = new FunctionConverter(); IExpression value = new Constant(f.getValue(function)); IExpression mathFun = new MathFunction(f.Translator(function), value); IExpression x = new VariableX(); IExpression result = new SumExpression(two, mathFun); result = new SumExpression(result, x); Context c = new Context(123); var y = result.Interpret(c); Assert.AreEqual(124.45, y, 2); }