public void TestConstructorEcellDataNameValueEntityPath() { string name = null; EcellValue value = null; string entityPath = null; // null (uninitialized) EcellData data = new EcellData(name, value, entityPath); Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance."); Assert.IsNull(data.Name, "Name is not null."); Assert.IsNull(data.EntityPath, "EntityPath is not null."); Assert.IsNull(data.Value, "Value is not null."); Assert.IsTrue(data.Gettable, "Gettable is not expected value."); Assert.IsTrue(data.Loadable, "Loadable is not expected value."); Assert.IsFalse(data.Logable, "Logable is not expected value."); Assert.IsFalse(data.Logged, "Logged is not expected value."); Assert.IsTrue(data.Saveable, "Saveable is not expected value."); Assert.IsTrue(data.Settable, "Settable is not expected value."); Assert.IsFalse(data.IsInitialized(), "IsInitialized is not expected value."); name = "TestData"; entityPath = "Variable:/:V0:TestData"; // int value = new EcellValue(1); data = new EcellData(name, value, entityPath); Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance."); Assert.AreEqual(name, data.Name, "Name is not expected value."); Assert.AreEqual(entityPath, data.EntityPath, "EntityPath is not expected value."); Assert.AreEqual(value, data.Value, "Value is not expected value."); Assert.IsTrue(data.Gettable, "Gettable is not expected value."); Assert.IsTrue(data.Loadable, "Loadable is not expected value."); Assert.IsFalse(data.Logable, "Logable is not expected value."); Assert.IsFalse(data.Logged, "Logged is not expected value."); Assert.IsTrue(data.Saveable, "Saveable is not expected value."); Assert.IsTrue(data.Settable, "Settable is not expected value."); Assert.IsTrue(data.IsInitialized(), "IsInitialized is not expected value."); // double value = new EcellValue(0.001); data = new EcellData(name, value, entityPath); Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance."); Assert.AreEqual(name, data.Name, "Name is not expected value."); Assert.AreEqual(entityPath, data.EntityPath, "EntityPath is not expected value."); Assert.AreEqual(value, data.Value, "Value is not expected value."); Assert.IsTrue(data.Gettable, "Gettable is not expected value."); Assert.IsTrue(data.Loadable, "Loadable is not expected value."); Assert.IsFalse(data.Logable, "Logable is not expected value."); Assert.IsFalse(data.Logged, "Logged is not expected value."); Assert.IsTrue(data.Saveable, "Saveable is not expected value."); Assert.IsTrue(data.Settable, "Settable is not expected value."); Assert.IsTrue(data.IsInitialized(), "IsInitialized is not expected value."); // string value = new EcellValue("test"); data = new EcellData(name, value, entityPath); Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance."); Assert.AreEqual(name, data.Name, "Name is not expected value."); Assert.AreEqual(entityPath, data.EntityPath, "EntityPath is not expected value."); Assert.IsTrue(value.Equals(data.Value), "Value is not expected value."); Assert.IsTrue(data.Gettable, "Gettable is not expected value."); Assert.IsTrue(data.Loadable, "Loadable is not expected value."); Assert.IsFalse(data.Logable, "Logable is not expected value."); Assert.IsFalse(data.Logged, "Logged is not expected value."); Assert.IsTrue(data.Saveable, "Saveable is not expected value."); Assert.IsTrue(data.Settable, "Settable is not expected value."); Assert.IsFalse(data.IsInitialized(), "IsInitialized is not expected value."); // List List<EcellValue> list = new List<EcellValue>(); value = new EcellValue(list); data = new EcellData(name, value, entityPath); Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance."); Assert.AreEqual(name, data.Name, "Name is not expected value."); Assert.AreEqual(entityPath, data.EntityPath, "EntityPath is not expected value."); Assert.IsTrue(value.Equals(data.Value), "Value is not expected value."); Assert.IsTrue(data.Gettable, "Gettable is not expected value."); Assert.IsTrue(data.Loadable, "Loadable is not expected value."); Assert.IsFalse(data.Logable, "Logable is not expected value."); Assert.IsFalse(data.Logged, "Logged is not expected value."); Assert.IsTrue(data.Saveable, "Saveable is not expected value."); Assert.IsTrue(data.Settable, "Settable is not expected value."); Assert.IsFalse(data.IsInitialized(), "IsInitialized is not expected value."); }
public void TestEquals() { // Compare int. EcellValue value1 = new EcellValue(1); EcellValue value2 = value1.Clone(); Assert.IsTrue(value1.Equals(value2), "Equals method returned unexpected result."); Assert.IsTrue(value1.Equals(1), "Equals method returned unexpected result."); Assert.IsFalse(value1.Equals(1.0), "Equals method returned unexpected result."); value2 = null; Assert.IsFalse(value1.Equals(value2), "Equals method returned unexpected result."); Assert.IsFalse(value1.Equals(new object()), "Equals method returned unexpected result."); // Compare double. value1 = new EcellValue(0.01); value2 = value1.Clone(); Assert.IsTrue(value1.Equals(value2), "Equals method returned unexpected result."); Assert.IsTrue(value1.Equals(0.01), "Equals method returned unexpected result."); // Compare string. value1 = new EcellValue("test"); value2 = value1.Clone(); Assert.IsTrue(value1.Equals(value2), "Equals method returned unexpected result."); Assert.IsTrue(value1.Equals("test"), "Equals method returned unexpected result."); string str = "((\"S1\", \"Variable:/:S1\", 1, 0), (\"S2\", \"Variable:/:S2\", 1, 1))"; value1 = EcellValue.ConvertFromListString(str); value2 = value1.Clone(); Assert.AreEqual((List<object>)value1.Value, (List<object>)value2.Value, "Equals method returned unexpected result."); Assert.IsTrue(value1.Equals((List<object>)value2.Value), "Equals method returned unexpected result."); str = "((\"S1\", \"Variable:/:S1\", 1, 0), (\"S3\", \"Variable:/:S3\", 1, 1))"; value2 = EcellValue.ConvertFromListString(str); Assert.AreNotEqual((List<object>)value1.Value, (List<object>)value2.Value, "Equals method returned unexpected result."); Assert.IsFalse(value1.Equals((List<object>)value2.Value), "Equals method returned unexpected result."); str = "((\"S1\", \"Variable:/:S1\", 1, 0))"; value2 = EcellValue.ConvertFromListString(str); Assert.AreNotEqual((List<object>)value1.Value, (List<object>)value2.Value, "Equals method returned unexpected result."); Assert.IsFalse(value1.Equals((List<object>)value2.Value), "Equals method returned unexpected result."); }
public void TestGetEcellValue() { EcellSystem sys = new EcellSystem("Model", "/", "System", "System", null); EcellValue expectedEcellValue = null; EcellValue resultEcellValue = null; resultEcellValue = sys.GetEcellValue("Size"); Assert.AreSame(expectedEcellValue, resultEcellValue, "GetEcellValue method returned unexpected result."); sys.SetEcellDatas(new List<EcellData>()); resultEcellValue = sys.GetEcellValue("Size"); Assert.AreSame(expectedEcellValue, resultEcellValue, "GetEcellValue method returned unexpected result."); sys.SizeInVolume = 0.1; expectedEcellValue = new EcellValue(0.1); resultEcellValue = sys.GetEcellValue("Size"); Assert.IsTrue(expectedEcellValue.Equals(resultEcellValue), "GetEcellValue method returned unexpected result."); }