public void SerializationTest() { var tc = new testClass { Active = true, Guid = Guid.NewGuid(), LastModifiedBy = Guid.NewGuid(), LastModifiedDateTime = DateTime.Now, ParentGuid = Guid.NewGuid(), PersistedDateTime = DateTime.Now, VersionGuid = Guid.NewGuid(), VersionTimeStamp = DateHelper.GetCurrentTimeStamp() }; TGSerializedObject tg = tc.GetTGSerializedObject(); var newTc = TGSerializedObject.GetTGSerializable <testClass>(tg); Assert.AreEqual(tc.Active, newTc.Active); Assert.AreEqual(tc.Guid, newTc.Guid); Assert.AreEqual(tc.LastModifiedBy, newTc.LastModifiedBy); Assert.AreEqual(tc.LastModifiedDateTime, newTc.LastModifiedDateTime); Assert.AreEqual(tc.ParentGuid, newTc.ParentGuid); Assert.AreEqual(tc.PersistedDateTime, newTc.PersistedDateTime); Assert.AreEqual(tc.VersionGuid, newTc.VersionGuid); Assert.LessOrEqual(tc.VersionTimeStamp, newTc.VersionTimeStamp); }
public override void LoadFromTGSerializedObject(TGSerializedObject _tgs) { base.LoadFromTGSerializedObject(_tgs); OriginalTagUserGuid = _tgs.GetGuid("OriginalTagUserGuid"); OriginalTagDateTime = _tgs.GetDateTime("OriginalTagDateTime"); Position = _tgs.GetGeoPoint("Position"); CreationDateTime = _tgs.GetDateTime("CreationDateTime"); PrimaryImageGuid = _tgs.GetNullableGuid("PrimaryImageGuid"); OriginalReviewerUserGuid = _tgs.GetNullableGuid("OriginalReviewerUserGuid"); LastReviewerUserGuid = _tgs.GetNullableGuid("LastReviewerUserGuid"); string temp = _tgs.GetString("Properties"); if (temp != null) { Properties = TGSerializedObject.GetTGSerializable <Properties>(temp); } }
public void SerializeTest() { GeoPoint pos = new GeoPoint(-100, 45); Hydrant hydrant = new Hydrant { Active = true, CreationDateTime = DateTime.Now, Guid = Guid.NewGuid(), LastModifiedBy = Guid.NewGuid(), LastModifiedDateTime = DateTime.Now, LastReviewerUserGuid = Guid.NewGuid(), OriginalReviewerUserGuid = Guid.NewGuid(), OriginalTagDateTime = DateTime.Now, OriginalTagUserGuid = Guid.NewGuid(), PersistedDateTime = DateTime.Now, Position = pos, PrimaryImageGuid = Guid.NewGuid() }; TGSerializedObject tgs = hydrant.GetTGSerializedObject(); Hydrant newHydrant = TGSerializedObject.GetTGSerializable <Hydrant>(tgs); Assert.AreEqual(hydrant.Active, newHydrant.Active); Assert.AreEqual(hydrant.CreationDateTime, newHydrant.CreationDateTime); Assert.AreEqual(hydrant.LastModifiedBy, newHydrant.LastModifiedBy); Assert.AreEqual(hydrant.LastModifiedDateTime, newHydrant.LastModifiedDateTime); Assert.AreEqual(hydrant.Guid, newHydrant.Guid); Assert.AreEqual(hydrant.LastReviewerUserGuid, newHydrant.LastReviewerUserGuid); Assert.AreEqual(hydrant.OriginalReviewerUserGuid, newHydrant.OriginalReviewerUserGuid); Assert.AreEqual(hydrant.OriginalTagDateTime, newHydrant.OriginalTagDateTime); Assert.AreEqual(hydrant.OriginalTagUserGuid, newHydrant.OriginalTagUserGuid); Assert.AreEqual(hydrant.PersistedDateTime, newHydrant.PersistedDateTime); Assert.AreEqual(hydrant.PrimaryImageGuid, newHydrant.PrimaryImageGuid); Assert.IsNotNull(newHydrant.Position); Assert.AreEqual(hydrant.Position.X, newHydrant.Position.X); Assert.AreEqual(hydrant.Position.Y, newHydrant.Position.Y); }
public override void LoadFromTGSerializedObject(TGSerializedObject _tgs) { base.LoadFromTGSerializedObject(_tgs); UserGuid = _tgs.GetGuid("UserGuid"); DeviceDateTime = _tgs.GetDateTime("DeviceDateTime"); Position = _tgs.GetGeoPoint("TagPosition"); TagType = _tgs.GetString("TagType"); ImageGuid = _tgs.GetNullableGuid("ImageGuid"); ExternalIdentifier = _tgs.GetString("ExternalIdentifier"); ExternalSource = _tgs.GetString("ExternalSource"); HydrantGuid = _tgs.GetNullableGuid("HydrantGuid"); string temp = _tgs.GetString("Properties"); if (temp != null) { Properties = TGSerializedObject.GetTGSerializable <Properties>(temp); } Status = _tgs.GetString("Status"); }
public static T Get <T>(BsonDocument _document) where T : AbstractTGObject, new() { if (_document != null) { TGSerializedObject tso = new TGSerializedObject(); foreach (string name in _document.Names) { if (!name.Equals("_id")) { BsonValue val = _document[name]; TGSerializedProperty serializedProperty = new TGSerializedProperty(name, val.ToString()); tso.Properties.Add(name, serializedProperty); } } return(TGSerializedObject.GetTGSerializable <T>(tso)); } return(default(T)); }
public void SerializeTest() { GeoPoint pos = new GeoPoint(-100, 45); Tag tag = new Tag { Active = true, DeviceDateTime = DateTime.Now.ToUniversalTime(), ExternalIdentifier = Guid.NewGuid().ToString(), ExternalSource = "TestSource", Guid = Guid.NewGuid(), HydrantGuid = Guid.NewGuid(), Position = pos, TagType = TagTypes.ExistingHydrant, Status = TagStatus.Pending, ImageGuid = Guid.NewGuid() }; TGSerializedObject tgs = tag.GetTGSerializedObject(); Tag newTag = TGSerializedObject.GetTGSerializable <Tag>(tgs); Assert.AreEqual(tag.Active, newTag.Active); Assert.AreEqual(tag.DeviceDateTime, newTag.DeviceDateTime); Assert.AreEqual(tag.ExternalIdentifier, newTag.ExternalIdentifier); Assert.AreEqual(tag.ExternalSource, newTag.ExternalSource); Assert.AreEqual(tag.Guid, newTag.Guid); Assert.AreEqual(tag.HydrantGuid, newTag.HydrantGuid); Assert.AreEqual(tag.ImageGuid, newTag.ImageGuid); Assert.AreEqual(tag.UserGuid, newTag.UserGuid); Assert.AreEqual(tag.TagType, newTag.TagType); Assert.AreEqual(tag.Status, newTag.Status); Assert.IsNotNull(newTag.Position); Assert.AreEqual(tag.Position.X, newTag.Position.X); Assert.AreEqual(tag.Position.Y, newTag.Position.Y); }