public void ParsingTest() { SyntaxPipingLang context = new SyntaxPipingLangImpl(); Language.Parse(context, "method int foo ()"); var result = context.Result; Assert.IsNotNull(result); Assert.AreEqual("int", result.ResultType); Assert.AreEqual("foo", result.Name); // without return type context = new SyntaxPipingLangImpl(); Language.Parse(context, "method foo ()"); result = context.Result; Assert.IsNotNull(result); Assert.IsNull(result.ResultType); Assert.AreEqual("foo", result.Name); // without return type and name context = new SyntaxPipingLangImpl(); Language.Parse(context, "method"); result = context.Result; Assert.IsNotNull(result); Assert.IsNull(result.ResultType); Assert.IsNull(result.Name); }
public void ProgrammaticTest() { SyntaxPipingLang context = new SyntaxPipingLangImpl(); context.Result = context.Method(_ => _.StartMethod.Return("int").Name("foo")) ; var result = context.Result; Assert.IsNotNull(result); Assert.AreEqual("int", result.ResultType); Assert.AreEqual("foo", result.Name); // Without optional return type context = new SyntaxPipingLangImpl(); context.Result = context.Method(_ => _.StartMethod.Name("foo")) ; result = context.Result; Assert.IsNotNull(result); Assert.IsNull(result.ResultType); Assert.AreEqual("foo", result.Name); // Without any information (no return type and name) context = new SyntaxPipingLangImpl(); context.Result = context.Method(_ => (DoneMethod)context) ; result = context.Result; Assert.IsNotNull(result); Assert.IsNull(result.ResultType); Assert.IsNull(result.Name); }