public void TestToString() { string expectedString; string resultString; EcellValue value; EcellReference er1 = new EcellReference("S1", "Variable:/:S1", 1, 0); value = new EcellValue(er1); expectedString = er1.ToString(); resultString = value.ToString(); Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result."); value = new EcellValue(new List<object>()); expectedString = "()"; resultString = value.ToString(); Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result."); List<object> list = new List<object>(); list.Add(0.001); list.Add("Test"); value = new EcellValue(list); expectedString = "(0.001, \"Test\")"; resultString = value.ToString(); Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result."); value = new EcellValue(1); expectedString = "1"; resultString = value.ToString(); Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result."); value = new EcellValue(0.0002); expectedString = "0.0002"; resultString = value.ToString(); Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result."); value = new EcellValue("string"); expectedString = "string"; resultString = value.ToString(); Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result."); expectedString = "((\"S1\", \"Variable:/:S1\", 1, 0), (\"S2\", \"Variable:/:S2\", 1, 1))"; value = EcellValue.ConvertFromListString(expectedString); resultString = value.ToString(); Assert.AreEqual(expectedString, resultString, "CastToList method returned unexpected result."); }
/// <summary> /// Stores the "EcellObject" 4 the "Stepper". /// </summary> /// <param name="simulator">The simulator</param> /// <param name="dmm">The "DynamicModuleManager"</param> /// <param name="ecellObject">The stored "Stepper"</param> internal static void DataStored4Stepper( WrappedSimulator simulator, DMDescriptorKeeper dmm, EcellObject ecellObject) { string key = Constants.xpathStepper + Constants.delimiterColon + Constants.delimiterColon + ecellObject.Key; List<EcellData> stepperEcellDataList = new List<EcellData>(); IList<string> wrappedPolymorph = null; // // Property List // try { wrappedPolymorph = simulator.GetStepperPropertyList(ecellObject.Key); } catch (Exception ex) { Trace.WriteLine(ex.StackTrace); return; } // // Sets the class name. // if (string.IsNullOrEmpty(ecellObject.Classname)) { ecellObject.Classname = simulator.GetStepperClassName(ecellObject.Key); } // // Checks the stored "EcellData" // Dictionary<string, EcellData> storedEcellDataDic = new Dictionary<string, EcellData>(); if (ecellObject.Value != null && ecellObject.Value.Count > 0) { foreach (EcellData storedEcellData in ecellObject.Value) { storedEcellDataDic[storedEcellData.Name] = storedEcellData; stepperEcellDataList.Add(storedEcellData); } } // // Stores the "EcellData" // foreach (string name in wrappedPolymorph) { string entityPath = key + Constants.delimiterColon + name; PropertyAttributes flag = simulator.GetStepperPropertyAttributes(ecellObject.Key, name); if (!flag.Gettable) { continue; } EcellValue value = null; try { object property = simulator.GetStepperProperty(ecellObject.Key, name); value = new EcellValue(property); } catch (Exception ex) { Trace.WriteLine(ex); value = GetValueFromDMM(dmm, ecellObject.Type, ecellObject.Classname, name); } EcellData ecellData = CreateEcellData(name, value, entityPath, flag); if (storedEcellDataDic.ContainsKey(name)) { if (value.IsString && value.ToString().Equals("")) { continue; } else { stepperEcellDataList.Remove(storedEcellDataDic[name]); } } stepperEcellDataList.Add(ecellData); } ecellObject.SetEcellDatas(stepperEcellDataList); }
public void TestConstructorEcellValueEr() { // EcellReference EcellReference er = new EcellReference("S1","Variable:/:S1",1,0); EcellValue testEcellValue = new EcellValue(er); Assert.IsNotNull(testEcellValue, "Constructor of type, EcellValue failed to create instance."); Assert.IsFalse(testEcellValue.IsInt, "IsInt is not expected value."); Assert.IsFalse(testEcellValue.IsDouble, "IsDouble is not expected value."); Assert.IsTrue(testEcellValue.IsList, "IsList is not expected value."); Assert.IsFalse(testEcellValue.IsString, "IsString is not expected value."); Assert.AreEqual(EcellValueType.List, testEcellValue.Type, "Type is not expected value."); Assert.AreEqual(er.ToString(), testEcellValue.ToString(), "ToString() is not expected value."); // List EcellValue temp = new EcellValue(er); List<EcellValue> list = new List<EcellValue>(); list.Add(temp); EcellValue value = new EcellValue(list); Assert.IsNotNull(value, "Constructor of type, EcellValue failed to create instance."); Assert.IsFalse(value.IsInt, "IsInt is not expected value."); Assert.IsFalse(value.IsDouble, "IsDouble is not expected value."); Assert.IsTrue(value.IsList, "IsList is not expected value."); Assert.IsFalse(value.IsString, "IsString is not expected value."); Assert.AreEqual(EcellValueType.List, value.Type, "Type is not expected value."); }