Beispiel #1
0
        public void TestGetImageIndex_EcellObject()
        {
            EcellObject obj = null;
            int expectedInt32 = -1;
            int resultInt32 = 0;
            resultInt32 = _unitUnderTest.GetImageIndex(obj);
            Assert.AreEqual(expectedInt32, resultInt32, "GetImageIndex method returned unexpected result.");

            obj = new EcellProject("", "", "", "", new List<EcellData>());
            expectedInt32 = 0;
            resultInt32 = 0;
            resultInt32 = _unitUnderTest.GetImageIndex(obj);
            Assert.AreEqual(expectedInt32, resultInt32, "GetImageIndex method returned unexpected result.");

            obj = new EcellModel("", "", "", "", new List<EcellData>());
            expectedInt32 = 1;
            resultInt32 = 0;
            resultInt32 = _unitUnderTest.GetImageIndex(obj);
            Assert.AreEqual(expectedInt32, resultInt32, "GetImageIndex method returned unexpected result.");

            obj = new EcellSystem("", "", "", "", new List<EcellData>());
            expectedInt32 = 2;
            resultInt32 = 0;
            resultInt32 = _unitUnderTest.GetImageIndex(obj);
            Assert.AreEqual(expectedInt32, resultInt32, "GetImageIndex method returned unexpected result.");

            obj = new EcellProcess("", "", "", "", new List<EcellData>());
            expectedInt32 = 3;
            resultInt32 = 0;
            resultInt32 = _unitUnderTest.GetImageIndex(obj);
            Assert.AreEqual(expectedInt32, resultInt32, "GetImageIndex method returned unexpected result.");

            obj = new EcellVariable("", "", "", "", new List<EcellData>());
            expectedInt32 = 4;
            resultInt32 = 0;
            resultInt32 = _unitUnderTest.GetImageIndex(obj);
            Assert.AreEqual(expectedInt32, resultInt32, "GetImageIndex method returned unexpected result.");

            obj = new EcellText("", "/:Text", "", "", new List<EcellData>());
            expectedInt32 = 10;
            resultInt32 = 0;
            resultInt32 = _unitUnderTest.GetImageIndex(obj);
            Assert.AreEqual(expectedInt32, resultInt32, "GetImageIndex method returned unexpected result.");

            obj = new EcellStepper("", "", "", "", new List<EcellData>());
            expectedInt32 = 11;
            resultInt32 = 0;
            resultInt32 = _unitUnderTest.GetImageIndex(obj);
            Assert.AreEqual(expectedInt32, resultInt32, "GetImageIndex method returned unexpected result.");

            obj.Layout.Figure = "System";
            expectedInt32 = 2;
            resultInt32 = 0;
            resultInt32 = _unitUnderTest.GetImageIndex(obj);
            Assert.AreEqual(expectedInt32, resultInt32, "GetImageIndex method returned unexpected result.");
        }
Beispiel #2
0
        public void TestChangeStepperAction()
        {
            _env.DataManager.LoadProject(TestConstant.Project_Drosophila);
            Assert.AreEqual(UndoStatus.NOTHING, _env.ActionManager.UndoStatus, "UndoStatus is unexpected value.");
            EcellObject stepper = new EcellStepper("Drosophila", "ODE", "Stepper", "ODEStepper", new List<EcellData>());
            _env.DataManager.DataAdd(stepper);

            EcellObject oldStepper = stepper;
            EcellObject newStepper = stepper.Clone();

            UserAction action = new ChangeStepperAction(newStepper.Key, oldStepper.Key , newStepper, oldStepper);
            Assert.IsNotNull(action, "Constructor of type, ChangeStepperAction failed to create instance.");
            Assert.IsTrue(action.ToString().Contains("ChangeStepperAction"), "ToString is unexpected value.");
            Type type = action.GetType();
            FieldInfo info = type.GetField("m_env", BindingFlags.NonPublic | BindingFlags.Instance);
            info.SetValue(action, _env);

            action.Execute();
            action.UnExecute();
        }
Beispiel #3
0
        /// <summary>
        /// Returns the new "EcellObject" instance with initialized arguments.
        /// </summary>
        /// <param name="modelID">The model ID</param>
        /// <param name="key">The key</param>
        /// <param name="type">The type</param>
        /// <param name="classname">The class</param>
        /// <param name="data">The data</param>
        /// <returns>The new "EcellObject" instance</returns>
        public static EcellObject CreateObject(string modelID, string key,
            string type, string classname, List<EcellData> data)
        {
            //if (string.IsNullOrEmpty(modelID))
            //    throw new EcellException(string.Format(MessageResources.ErrInvalidParam, MODEL));
            if (Util.IsNGforType(type))
                throw new EcellException(string.Format(MessageResources.ErrInvalidParam, TYPE));

            EcellObject obj = null;
            if (type.Equals(MODEL))
                obj = new EcellModel(modelID, key, type, classname, data);
            else if (type.Equals(PROCESS))
                obj = new EcellProcess(modelID, key, type, classname, data);
            else if (type.Equals(VARIABLE))
                obj = new EcellVariable(modelID, key, type, classname, data);
            else if (type.Equals(SYSTEM))
                obj = new EcellSystem(modelID, key, type, classname, data);
            else if (type.Equals(TEXT))
                obj = new EcellText(modelID, key, type, classname, data);
            else if (type.Equals(STEPPER))
                obj = new EcellStepper(modelID, key, type, classname, data);
            else if (type.Equals(PROJECT))
                obj = new EcellProject(modelID, key, type, classname, data);
            return obj;
        }