public void BatchPropertyCollection() { MgPropertyCollection coll1 = new MgPropertyCollection(); MgDoubleProperty dblProp = new MgDoubleProperty("DoubleProp", 1.1111); coll1.Add(dblProp); MgPropertyCollection coll2 = new MgPropertyCollection(); MgInt32Property intProp = new MgInt32Property("IntProp", 1); coll2.Add(intProp); MgPropertyCollection coll3 = new MgPropertyCollection(); MgSingleProperty single = new MgSingleProperty("SingleProp", (float)2.2222); coll3.Add(single); MgBatchPropertyCollection coll = new MgBatchPropertyCollection(); coll.Add(coll1); coll.Add(coll2); Assert.AreEqual(2, coll.Count); Assert.AreEqual(MgPropertyType.Double, coll[0][0].GetPropertyType()); Assert.AreEqual(MgPropertyType.Int32, coll[1][0].GetPropertyType()); coll[1] = coll3; string str = ""; foreach (MgPropertyCollection c in coll) { str = str + "[" + c[0].GetName() + "]"; } Assert.AreEqual("[DoubleProp][SingleProp]", str); }
public void Execute(IPlatformFactory factory, ITestLogger logger) { MgPropertyCollection coll = new MgPropertyCollection(); MgDoubleProperty dblProp = new MgDoubleProperty("DoubleProp", 1.1111); MgInt32Property intProp = new MgInt32Property("IntProp", 1); MgDateTime dateTime = new MgDateTime(2006, 9, 21); MgDateTimeProperty dateProp = new MgDateTimeProperty("DateProp", dateTime); MgSingleProperty single = new MgSingleProperty("SingleProp", (float)2.2222); coll.Add(dblProp); coll.Add(intProp); coll.Add(dateProp); coll[2] = single; Assert.AreEqual(1.1111, (coll[0] as MgDoubleProperty).GetValue()); Assert.AreEqual(MgPropertyType.Double, coll[0].GetPropertyType()); Assert.AreEqual(MgPropertyType.Int32, coll[1].GetPropertyType()); Assert.AreEqual(MgPropertyType.Single, coll[2].GetPropertyType()); Assert.AreEqual((float)2.2222, (coll[2] as MgSingleProperty).GetValue()); Assert.AreEqual(3, coll.Count); Assert.AreEqual(MgPropertyType.Double, coll[0].GetPropertyType()); string str = ""; foreach (MgProperty prop in coll) { str = str + "[" + prop.GetName() + "]"; } Assert.AreEqual("[DoubleProp][IntProp][SingleProp]", str); }
public void Execute(IPlatformFactory factory, ITestLogger logger) { MgSingleProperty sp = new MgSingleProperty("SinglePropName", 4.251973f); Assert.AreEqual("SinglePropName", sp.Name); Assert.AreEqual(MgPropertyType.Single, sp.PropertyType); Assert.AreEqual(4.251973f, sp.Value); }
public void Execute(IPlatformFactory factory, ITestLogger logger) { MgPropertyCollection coll1 = new MgPropertyCollection(); MgDoubleProperty dblProp = new MgDoubleProperty("DoubleProp", 1.1111); coll1.Add(dblProp); MgPropertyCollection coll2 = new MgPropertyCollection(); MgInt32Property intProp = new MgInt32Property("IntProp", 1); coll2.Add(intProp); MgPropertyCollection coll3 = new MgPropertyCollection(); MgSingleProperty single = new MgSingleProperty("SingleProp", (float)2.2222); coll3.Add(single); MgBatchPropertyCollection coll = new MgBatchPropertyCollection(); coll.Add(coll1); coll.Add(coll2); Assert.AreEqual(2, coll.Count); Assert.AreEqual(MgPropertyType.Double, coll[0][0].GetPropertyType()); Assert.AreEqual(MgPropertyType.Int32, coll[1][0].GetPropertyType()); coll[1] = coll3; string str = ""; foreach (MgPropertyCollection c in coll) { str = str + "[" + c[0].GetName() + "]"; } Assert.AreEqual("[DoubleProp][SingleProp]", str); }
internal static void Populate(MgPropertyCollection props, IMutableRecord record) { for (int i = 0; i < record.FieldCount; i++) { var pt = record.GetPropertyType(i); string name = record.GetName(i); if (record.IsNull(i)) { switch (pt) { case PropertyValueType.Blob: { var propVal = new MgBlobProperty(name, null); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Boolean: { var propVal = new MgBooleanProperty(name, false); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Byte: { var propVal = new MgByteProperty(name, 0); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Clob: { var propVal = new MgClobProperty(name, null); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.DateTime: { var propVal = new MgDateTimeProperty(name, null); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Double: { var propVal = new MgDoubleProperty(name, 0.0); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Geometry: { var propVal = new MgGeometryProperty(name, null); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Int16: { var propVal = new MgInt16Property(name, 0); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Int32: { var propVal = new MgInt32Property(name, 0); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Int64: { var propVal = new MgInt64Property(name, 0L); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Single: { var propVal = new MgSingleProperty(name, 0.0f); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.String: { var propVal = new MgStringProperty(name, ""); propVal.SetNull(true); props.Add(propVal); } break; default: throw new NotSupportedException(); } } else { switch (pt) { case PropertyValueType.Blob: { var bytes = record.GetBlob(i); var br = new MgByteSource(bytes, bytes.Length); var bv = new MgBlobProperty(name, br.GetReader()); props.Add(bv); } break; case PropertyValueType.Boolean: { props.Add(new MgBooleanProperty(name, record.GetBoolean(i))); } break; case PropertyValueType.Byte: { props.Add(new MgByteProperty(name, record.GetByte(i))); } break; case PropertyValueType.Clob: { var bytes = record.GetBlob(i); var br = new MgByteSource(bytes, bytes.Length); var bv = new MgClobProperty(name, br.GetReader()); props.Add(bv); } break; case PropertyValueType.DateTime: { var dt = record.GetDateTime(i); var mdt = new MgDateTime((short)dt.Year, (short)dt.Month, (short)dt.Day, (short)dt.Hour, (short)dt.Minute, (short)dt.Second, dt.Millisecond * 1000); props.Add(new MgDateTimeProperty(name, mdt)); } break; case PropertyValueType.Double: { props.Add(new MgDoubleProperty(name, record.GetDouble(i))); } break; case PropertyValueType.Geometry: { MgByteReader agf = GeomConverter.GetAgf(record.GetGeometry(i)); props.Add(new MgGeometryProperty(name, agf)); } break; case PropertyValueType.Int16: { props.Add(new MgInt16Property(name, record.GetInt16(i))); } break; case PropertyValueType.Int32: { props.Add(new MgInt32Property(name, record.GetInt32(i))); } break; case PropertyValueType.Int64: { props.Add(new MgInt64Property(name, record.GetInt64(i))); } break; case PropertyValueType.Single: { props.Add(new MgSingleProperty(name, record.GetSingle(i))); } break; case PropertyValueType.String: { props.Add(new MgStringProperty(name, record.GetString(i))); } break; default: throw new NotSupportedException(); } } } }
public void PropertyCollection() { MgPropertyCollection coll = new MgPropertyCollection(); MgDoubleProperty dblProp = new MgDoubleProperty("DoubleProp", 1.1111); MgInt32Property intProp = new MgInt32Property("IntProp", 1); MgDateTime dateTime = new MgDateTime(2006, 9, 21); MgDateTimeProperty dateProp = new MgDateTimeProperty("DateProp", dateTime); MgSingleProperty single = new MgSingleProperty("SingleProp", (float) 2.2222); coll.Add(dblProp); coll.Add(intProp); coll.Add(dateProp); coll[2] = single; Assert.AreEqual(1.1111, (coll[0] as MgDoubleProperty).GetValue()); Assert.AreEqual(MgPropertyType.Double, coll[0].GetPropertyType()); Assert.AreEqual(MgPropertyType.Int32, coll[1].GetPropertyType()); Assert.AreEqual(MgPropertyType.Single, coll[2].GetPropertyType()); Assert.AreEqual((float) 2.2222, (coll[2] as MgSingleProperty).GetValue()); Assert.AreEqual(3, coll.Count); Assert.AreEqual(MgPropertyType.Double, coll[0].GetPropertyType()); string str = ""; foreach (MgProperty prop in coll) { str = str+"["+prop.GetName()+"]"; } Assert.AreEqual("[DoubleProp][IntProp][SingleProp]", str); }
public void SingleProperty() { MgSingleProperty sp = new MgSingleProperty("SinglePropName", (float)4.251973); Assert.AreEqual("SinglePropName", sp.Name); Assert.AreEqual(MgPropertyType.Single, sp.PropertyType); Assert.AreEqual(4.251973, sp.Value); }