Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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);
        }