public void ExecuteTest2() { var exp = new Del(new Add(new Add(new Mul(new Number(2), new Variable("x1")), new Pow(new Variable("x2"), new Number(2))), new Pow(new Variable("x3"), new Number(3)))); exp.Differentiator = new Differentiator(); exp.Simplifier = new Simplifier(); var expected = new Vector(new IExpression[] { new Number(2), new Mul(new Number(2), new Variable("x2")), new Mul(new Number(3), new Pow(new Variable("x3"), new Number(2))) }); Assert.Equal(expected, exp.Execute()); }
public void ExecuteTest2() { var exp = new Del(new Add(new Add(new Mul(new Number(2), new Variable("x1")), new Pow(new Variable("x2"), new Number(2))), new Pow(new Variable("x3"), new Number(3)))); exp.Differentiator = new Differentiator(); exp.Simplifier = new Simplifier(); var expected = new Vector(new IExpression[] { new Number(2), new Mul(new Number(2), new Variable("x2")), new Mul(new Number(3), new Pow(new Variable("x3"), new Number(2))) }); Assert.Equal(expected, exp.Execute()); }
public void ExecuteTest1() { var exp = new Add( new Add(new Mul(new Number(2), Variable.X), new Pow(new Variable("y"), new Number(2))), new Pow(new Variable("z"), new Number(3)) ); var del = new Del(new Differentiator(), new Simplifier(), exp); var expected = new Vector(new IExpression[] { new Number(2), new Mul(new Number(2), new Variable("y")), new Mul(new Number(3), new Pow(new Variable("z"), new Number(2))) }); Assert.Equal(expected, del.Execute()); }
public void DeleteTestsFromImmediateMode(int?start, bool hasComma, int?end, bool throwsException) { var mockProgramRepository = new Mock <IProgramRepository>(); var tokens = new List <IToken>(); if (start.HasValue) { tokens.Add(new Token(start.Value.ToString())); } if (hasComma) { tokens.Add(new Token(",", TokenClass.Seperator, TokenType.Comma)); } if (end.HasValue) { tokens.Add(new Token(end.Value.ToString())); } var runEnvironment = new RunEnvironment { CurrentLine = new ProgramLine(null, tokens) }; var sut = new Del(runEnvironment, mockProgramRepository.Object); var exceptionThrown = false; try { sut.Execute(); mockProgramRepository.Verify(mpr => mpr.DeleteProgramLines(start.Value, end.Value)); } catch (ClassicBasic.Interpreter.Exceptions.SyntaxErrorException) { exceptionThrown = true; } Assert.AreEqual(throwsException, exceptionThrown); }