Exemplo n.º 1
0
        public void NullObjectAndInteractiveMode()
        {
            MgaProject project    = null;
            MgaFCO     currentObj = null;
            MgaFCOs    fcos       = null;

            MgaObject  obj  = null;
            MgaObjects objs = null;


            IMgaComponentEx interpreter = GetInterpreterByProgID(ProgID);

            Assert.Throws <ArgumentNullException>(() => { interpreter.Initialize(project); });
            Assert.Throws <NotImplementedException>(() => { interpreter.ObjectsInvokeEx(project, obj, objs, 128); });
            Assert.Throws <ArgumentNullException>(() => { interpreter.InvokeEx(project, currentObj, fcos, 128); });

            Assert.True(File.Exists(this.mgaFile), "Project file does not exist.");
            string ProjectConnStr = "MGA=" + Path.GetFullPath(this.mgaFile);

            project = new MgaProject();
            project.OpenEx(ProjectConnStr, "CyPhyML", null);
            try
            {
                // project is set, but fcos are not
                Assert.DoesNotThrow(() => { interpreter.Initialize(project); });
                Assert.Throws <ArgumentNullException>(() => { interpreter.InvokeEx(project, currentObj, fcos, 128); });

                // fcos are set
                fcos = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs"));
                Assert.DoesNotThrow(() => { interpreter.InvokeEx(project, currentObj, fcos, 128); });
                Assert.True(interpreter.InteractiveMode == false, "Interactive is not set correctly. (128) silent mode");
                Assert.DoesNotThrow(() => { interpreter.InvokeEx(project, currentObj, fcos, 16); });
                Assert.True(interpreter.InteractiveMode == true, "Interactive is not set correctly. (16)");
            }
            finally
            {
                project.Close(true);
            }
        }