public void CalculateFunction_Interpreter_ResultMustBeSumOfNumber() { var command = "calc Linear(2)"; var builder = new Dictionary <string, Func <ICommandBuilder> >() { [@"^calc \w+\((-?\d+(,\d+)?)\)$"] = () => new CalculateFunctionBuilderStab() }; var storage = new FunctionsStorageStab(); var interpreter = new Interpreter(storage, builder); storage.AddFunction("Linear", new LinearFunctionStab(2.3, 3)); var result = interpreter.SearchMatches(command); Assert.Multiple( () => { Assert.AreEqual(result.Message, "9,9"); Assert.IsTrue(result.Identifier); }); }
public void NotImplementedStorageMethod_Interpreter_ResultMustBeExeption() { var command = "del Linear"; var message = "Метод или операция не реализована.Void DeleteFunction(System.String)"; var builder = new Dictionary <string, Func <ICommandBuilder> >() { [@"^del \w+$"] = () => new DeleteFunctionBuilderStab() }; var storage = new FunctionsStorageStab(); var interpreter = new Interpreter(storage, builder); storage.AddFunction("Linear", new LinearFunctionStab(3, 2)); var result = interpreter.SearchMatches(command); Assert.Multiple( () => { Assert.AreEqual(result.Message, message); Assert.IsFalse(result.Identifier); } ); }