public void ManagerConverter_FindMethodCalls()
        {
            string script =
                "using System" + Environment.NewLine +
                "namespace Models" + Environment.NewLine +
                "{" + Environment.NewLine +
                "    public class Script : Model" + Environment.NewLine +
                "    {" + Environment.NewLine +
                "        [Link] SoluteManager mySolutes1;" + Environment.NewLine +
                "        [Link] " +
                "        SoluteManager mySolutes2;" + Environment.NewLine +
                "        Fertiliser fert;" + Environment.NewLine +
                "        private void OnSimulationCommencing(object sender, EventArgs e)" + Environment.NewLine +
                "        {" + Environment.NewLine +
                "            mySolutes1.Add(arg1, arg2);" + Environment.NewLine +
                "            mySolutes2.Add (arg3,arg4);" + Environment.NewLine +
                "            fake.Add (arg3,arg4);" + Environment.NewLine +
                "            fert.Add (arg3,arg4);" + Environment.NewLine +
                "        }" + Environment.NewLine +
                "    }" + Environment.NewLine +
                "}" + Environment.NewLine;

            ManagerConverter converter = new ManagerConverter();

            converter.Read(script);
            List <MethodCall> methods = converter.FindMethodCalls("SoluteManager", "Add");

            Assert.AreEqual(methods.Count, 2);
            Assert.AreEqual(methods[0].InstanceName, "mySolutes1");
            Assert.AreEqual(methods[0].MethodName, "Add");
            Assert.AreEqual(methods[0].Arguments, new string[] { "arg1", "arg2" });
            Assert.AreEqual(methods[1].InstanceName, "mySolutes2");
            Assert.AreEqual(methods[1].MethodName, "Add");
            Assert.AreEqual(methods[1].Arguments, new string[] { "arg3", "arg4" });
        }
        public void ManagerConverter_SetMethodCall()
        {
            string script =
                "using System" + Environment.NewLine +
                "namespace Models" + Environment.NewLine +
                "{" + Environment.NewLine +
                "    public class Script : Model" + Environment.NewLine +
                "    {" + Environment.NewLine +
                "        [Link] SoluteManager mySolutes1;" + Environment.NewLine +
                "        private void OnSimulationCommencing(object sender, EventArgs e)" + Environment.NewLine +
                "        {" + Environment.NewLine +
                "            mySolutes1.Add(arg1, arg2);" + Environment.NewLine +
                "        }" + Environment.NewLine +
                "    }" + Environment.NewLine +
                "}" + Environment.NewLine;

            ManagerConverter converter = new ManagerConverter();

            converter.Read(script);

            MethodCall method = new MethodCall();

            method.LineIndex    = 8;
            method.InstanceName = "mySolutes1";
            method.MethodName   = "Add2";
            method.Arguments    = new List <string>();
            method.Arguments.Add("10");

            converter.SetMethodCall(method);

            // Make sure we can't find old one.
            Assert.AreEqual(converter.FindMethodCalls("SoluteManager", "Add").Count, 0);

            // Make sure we find new one.
            var foundMethod = converter.FindMethodCalls("SoluteManager", "Add2")[0];

            Assert.AreEqual(foundMethod.LineIndex, 8);
            Assert.AreEqual(foundMethod.InstanceName, "mySolutes1");
            Assert.AreEqual(foundMethod.MethodName, "Add2");
            Assert.AreEqual(foundMethod.Arguments, new string[] { "10" });
        }