public void TestClone() { EcellLayer el; List<EcellValue> list = new List<EcellValue>(); list.Add(new EcellValue("Name")); list.Add(new EcellValue(1)); EcellValue value = new EcellValue(list); el = new EcellLayer(value); Assert.IsNotNull(el, "Constructor of type, object failed to create instance."); Assert.AreEqual("Ecell.Objects.EcellLayer", el.GetType().ToString(), "GetType method returned unexpected value."); Assert.AreEqual("Name", el.Name, "Name is unexpected value."); Assert.AreEqual(true, el.Visible, "Name is unexpected value."); Assert.AreEqual("(\"Name\", 1)", el.ToString(), "ToString method returned unexpected value."); EcellLayer el1 = el.Clone(); Assert.IsNotNull(el1, "Constructor of type, object failed to create instance."); Assert.AreEqual("Ecell.Objects.EcellLayer", el1.GetType().ToString(), "GetType method returned unexpected value."); Assert.AreEqual("Name", el1.Name, "Name is unexpected value."); Assert.AreEqual(true, el1.Visible, "Name is unexpected value."); Assert.AreEqual("(\"Name\", 1)", el1.ToString(), "ToString method returned unexpected value."); EcellLayer el2 = (EcellLayer)((ICloneable)el).Clone(); Assert.IsNotNull(el2, "Constructor of type, object failed to create instance."); Assert.AreEqual("Ecell.Objects.EcellLayer", el2.GetType().ToString(), "GetType method returned unexpected value."); Assert.AreEqual("Name", el2.Name, "Name is unexpected value."); Assert.AreEqual(true, el2.Visible, "Name is unexpected value."); Assert.AreEqual("(\"Name\", 1)", el2.ToString(), "ToString method returned unexpected value."); }
public void SetUp() { _unitUnderTest = new EcellLayer(); }
public void TearDown() { _unitUnderTest = null; }
public void TestEquals() { EcellLayer layer1 = new EcellLayer("Layer0", true); EcellLayer layer2 = new EcellLayer("Layer1", true); EcellLayer layer3 = new EcellLayer("Layer0", false); EcellLayer layer4 = new EcellLayer("Layer0", true); Assert.AreEqual(false, layer1.Equals(new object()), "Equals method returned unexpected value."); Assert.AreEqual(false, layer1.Equals(layer2), "Equals method returned unexpected value."); Assert.AreEqual(false, layer1.Equals(layer3), "Equals method returned unexpected value."); Assert.AreEqual(true, layer1.Equals(layer4), "Equals method returned unexpected value."); }
public void TestGetHashCode() { EcellLayer layer1 = new EcellLayer("Layer0", true); EcellLayer layer2 = new EcellLayer("Layer1", true); EcellLayer layer3 = new EcellLayer("Layer0", false); EcellLayer layer4 = new EcellLayer("Layer0", true); Assert.AreNotEqual(layer1.GetHashCode(), layer2.GetHashCode(), "GetHashCode method returned unexpected value."); Assert.AreNotEqual(layer1.GetHashCode(), layer3.GetHashCode(), "GetHashCode method returned unexpected value."); Assert.AreEqual(layer1.GetHashCode(), layer4.GetHashCode(), "GetHashCode method returned unexpected value."); EcellLayer layer = new EcellLayer(); Assert.AreEqual(0, layer.GetHashCode(), "GetHashCode method returned unexpected value."); }
public void TestConstructorWithParams() { EcellLayer el; el = new EcellLayer("", false); Assert.IsNotNull(el, "Constructor of type, object failed to create instance."); Assert.AreEqual("Ecell.Objects.EcellLayer", el.GetType().ToString(), "GetType method returned unexpected value."); Assert.AreEqual("", el.Name, "Name is unexpected value."); Assert.AreEqual(false, el.Visible, "Name is unexpected value."); Assert.AreEqual("(\"\", 0)", el.ToString(), "ToString method returned unexpected value."); el = new EcellLayer("Name", true); Assert.IsNotNull(el, "Constructor of type, object failed to create instance."); Assert.AreEqual("Ecell.Objects.EcellLayer", el.GetType().ToString(), "GetType method returned unexpected value."); Assert.AreEqual("Name", el.Name, "Name is unexpected value."); Assert.AreEqual(true, el.Visible, "Name is unexpected value."); Assert.AreEqual("(\"Name\", 1)", el.ToString(), "ToString method returned unexpected value."); }
public void TestConstructorWithString() { string str = null; EcellLayer el; try { el = new EcellLayer(str); Assert.Fail("Failed to check null."); } catch (EcellException) { } try { el = new EcellLayer("aaa, 0"); Assert.Fail("Failed to throw EcellException."); } catch (EcellException) { } try { el = new EcellLayer("(aaa, bbb)"); Assert.Fail("Failed to throw EcellException."); } catch (EcellException) { } str = "(\"name\", 1)"; el = new EcellLayer(str); Assert.IsNotNull(el, "Constructor of type, object failed to create instance."); Assert.AreEqual("Ecell.Objects.EcellLayer", el.GetType().ToString(), "GetType method returned unexpected value."); Assert.AreEqual("name", el.Name, "Name is unexpected value."); Assert.AreEqual(true, el.Visible, "Name is unexpected value."); Assert.AreEqual("(\"name\", 1)", el.ToString(), "ToString method returned unexpected value."); }
public void TestConstructorWithEcellValue() { EcellValue value = null; List<object> list = null; EcellLayer el; try { el = new EcellLayer(list); Assert.Fail("Failed to throw EcellException."); } catch (EcellException) { } try { el = new EcellLayer(new object()); Assert.Fail("Failed to throw EcellException."); } catch (Exception) { } try { value = new EcellValue(new EcellReference("S1", "/:S1", 0, 0)); list = (List<object>)value.Value; el = new EcellLayer(list); Assert.Fail("Failed to throw EcellException."); } catch (Exception) { } list = new List<object>(); list.Add("Name"); list.Add(1); el = new EcellLayer(list); Assert.IsNotNull(el, "Constructor of type, object failed to create instance."); Assert.AreEqual("Ecell.Objects.EcellLayer", el.GetType().ToString(), "GetType method returned unexpected value."); Assert.AreEqual("Name", el.Name, "Name is unexpected value."); Assert.AreEqual(true, el.Visible, "Name is unexpected value."); Assert.AreEqual("(\"Name\", 1)", el.ToString(), "ToString method returned unexpected value."); }
public void TestConstructor() { EcellLayer el = new EcellLayer(); Assert.IsNotNull(el, "Constructor of type, object failed to create instance."); Assert.AreEqual("Ecell.Objects.EcellLayer", el.GetType().ToString(), "GetType method returned unexpected value."); Assert.AreEqual(null, el.Name, "Name is unexpected value."); Assert.AreEqual(false, el.Visible, "Name is unexpected value."); Assert.AreEqual("(\"\", 0)", el.ToString(), "ToString method returned unexpected value."); el.Name = "Name1"; el.Visible = true; Assert.AreEqual("Name1", el.Name, "Name is unexpected value."); Assert.AreEqual(true, el.Visible, "Name is unexpected value."); Assert.AreEqual("(\"Name1\", 1)", el.ToString(), "ToString method returned unexpected value."); el.Name = "Name2"; el.Visible = false; Assert.AreEqual("Name2", el.Name, "Name is unexpected value."); Assert.AreEqual(false, el.Visible, "Name is unexpected value."); Assert.AreEqual("(\"Name2\", 0)", el.ToString(), "ToString method returned unexpected value."); }
/// <summary> /// Create a copy of this EcellValue. /// </summary> /// <returns>EcellValue</returns> public EcellLayer Clone() { EcellLayer el = new EcellLayer( this.Name, this.Visible); return el; }
/// <summary> /// Get the list of reference from string. /// </summary> /// <param name="str">string.</param> /// <returns>the list of reference.</returns> public static List<EcellLayer> ConvertFromString(string str) { List<EcellLayer> list = new List<EcellLayer>(); if (str == null || str == "") return list; string text = str.Substring(1); text = text.Substring(0, text.Length - 1); MatchCollection coll = stringParser.Matches(text); IEnumerator iter = coll.GetEnumerator(); while (iter.MoveNext()) { Match match = (Match)iter.Current; EcellLayer er = new EcellLayer(match.Groups["layer"].Value); list.Add(er); } return list; }
/// <summary> /// Get the list of layer from EcellValue "Layers". /// </summary> /// <param name="layers">VariableReferenceList.</param> /// <returns>the list of EcellReference.</returns> public static List<EcellLayer> ConvertFromEcellValue(EcellValue layers) { List<EcellLayer> list = new List<EcellLayer>(); if (layers == null || !layers.IsList) return list; List<object> layerList = (List<object>)layers.Value; if (layerList == null || layerList.Count == 0) return list; foreach (object value in layerList) { EcellLayer er = new EcellLayer(value); list.Add(er); } return list; }