public void ItemSchemaTest_OptionalFieldsHaveCorrectValues() { var nativeItem = TestSchemaPass.GetNativeItemPassingWithOptionals(out var testSubstructure); ItemSchema.FitSchema <TestSchemaPass>(nativeItem, out var schematized); Assert.AreEqual(double.Parse(nativeItem.Doubles.GetO("NOT THERE")), schematized.doubleField_Defaults); Assert.AreEqual(nativeItem.Longs.GetV("NOT THERE"), schematized.longField_Defaults); Assert.AreEqual(nativeItem.Strings.GetO("NOT THERE"), schematized.stringField_Defaults); }
public void ItemSchemaTest_Depots() { ItemSchema.FitSchema <TestSchemaWithDepots>(TestSchemaWithDepots.GetNativeItem(), out var schematized); Assert.AreEqual("this is specific indeed", schematized.SomethingSpecific); Assert.AreEqual(1, schematized.Bullshit.Count); Assert.AreEqual("only a lil bullshit", schematized.Bullshit["bullshit"]); Assert.AreEqual(2, schematized.EverythingElse.Count); Assert.AreEqual("bar", schematized.EverythingElse["foo"]); Assert.AreEqual("blah", schematized.EverythingElse["blah"]); }
public void SetDataSource(OD.DataSource dataSource) { if (_dataSource != dataSource) { // this will cause the schema to get recreated _schema = null; // clear the grouping _groupByColumnViewModels = null; _dataSource = dataSource; _map = GetMap(); _featureLayer = FindFeatureLayer(_dataSource); } }
public void SetFeatureLayer(FeatureLayerHelper featureLayerHelper) { if (featureLayerHelper == null || featureLayerHelper.FeatureLayer == null) { return; } if (_featureLayerHelper == null || _featureLayerHelper.FeatureLayer != featureLayerHelper.FeatureLayer) { // this will cause the schema to get recreated _schema = null; // clear the grouping _groupByColumnViewModels = null; } _featureLayerHelper = featureLayerHelper; }
protected Item CreateNewItem(Graphic graphic) { // make sure the schema is up to date if (_schema == null) { if (_featureLayer == null) { return(null); } _schema = new ItemSchema(); Field oidField = null; foreach (Field field in _featureLayer.LayerInfo.Fields) { if (field.Type == Field.FieldType.OID) // (field.Name.ToUpper() != "OBJECTID") { oidField = field; } else { _schema.AddProperty(field); } } // add the OID field at the end if (oidField != null) { _schema.AddProperty(oidField); } } // create a new item Item item = new Item(_schema); // set item attributes if (!UpdateItem(item, graphic)) { return(null); } return(item); }
public void ItemSchemaTest_CorrectValuesAfterConversionToSchema_Inheritance() { var nativeItem = TestSchemaPass.GetNativeItemPassing(out var testSubstructure); ItemSchema.FitSchema <TestSchemaPassExtend>(nativeItem, out var schematized); Assert.AreEqual(nativeItem.Id, schematized.UniqueId); Assert.AreEqual(double.Parse(nativeItem.Doubles.GetO("dFID")), schematized.doubleField_IsDouble); Assert.AreEqual(float.Parse(nativeItem.Doubles.GetO("dFND")), schematized.doubleField_NotDouble); Assert.AreEqual(double.NaN, schematized.doubleField_Defaults); Assert.AreEqual(nativeItem.Longs.GetV("lFIL"), schematized.longField_IsLong); Assert.AreEqual((short)nativeItem.Longs.GetV("lFNL"), schematized.longField_NotLong); Assert.AreEqual(1024, schematized.longField_Defaults); Assert.AreEqual(nativeItem.Strings.GetO("sFIS"), schematized.stringField_IsString); Assert.AreEqual(nativeItem.Strings.GetO("sFNS"), (string)schematized.stringField_NotString); Assert.AreEqual("Nope.", schematized.stringField_Defaults); Assert.AreEqual(testSubstructure.AnInt, schematized.stringField_SerializedData.AnInt); Assert.AreEqual(testSubstructure.AnotherInt, schematized.stringField_SerializedData.AnotherInt); Assert.AreEqual(testSubstructure.AString, schematized.stringField_SerializedData.AString); Assert.AreEqual(nativeItem.Longs.GetV("lFWC"), schematized.longBackedField_WithConstraints); }
public void ItemSchemaTest_DateTime() { ItemSchema.FitSchema <TestSchemaWithDateTime>(TestSchemaWithDateTime.GetNativeItem(), out var schematized); Assert.AreEqual(Util.UnixEpoch, schematized.timestamp); }
public void ItemSchemaTest_DoesNotMatchSchema() { Debug.Log("Two schema matches are going to fail as part of ItemSchemaTest_DoesNotMatchSchema now. The warnings are expected."); Assert.IsFalse(ItemSchema.FitSchema <TestSchemaPass>(new Item(), out _)); Assert.IsFalse(ItemSchema.FitSchema <TestSchemaPass>(TestSchemaPass.GetNativeItemNotPassing(out _), out _)); }
public void ItemSchemaTest_MatchesSchema() { Assert.IsTrue(ItemSchema.FitSchema <TestSchemaPass>(TestSchemaPass.GetNativeItemPassing(out _), out _)); Assert.IsTrue(ItemSchema.FitSchema <TestSchemaPass>(TestSchemaPass.GetNativeItemPassingWithOptionals(out _), out _)); }