Tests.ORecordParsingTests.TestWikiExample1Deserialization C# (CSharp) Method

TestWikiExample1Deserialization() private method

private TestWikiExample1Deserialization ( ) : void
return void
        public void TestWikiExample1Deserialization()
        {
            string raw = "Profile@nick:\"ThePresident\",follows:[],followers:[#10:5,#10:6],name:\"Barack\",surname:\"Obama\",location:#3:2,invitedBy:,salary_cloned:,salary:120.3f";

            ORecord record = new ORecord(ORecordType.Document, 0, UTF8Encoding.UTF8.GetBytes(raw));

            Assert.IsTrue(record.Class == "Profile");

            Assert.IsTrue(record.Fields["nick"].GetType() == typeof(string));
            Assert.IsTrue((string)record.Fields["nick"] == "ThePresident");

            Assert.IsTrue(record.Fields["follows"].GetType() == typeof(List<object>));

            Assert.IsTrue(record.Fields["followers"].GetType() == typeof(List<object>));
            List<object> followers = (List<object>)record.Fields["followers"];

            Assert.IsTrue(followers[0].GetType() == typeof(ORID));
            Assert.IsTrue(((ORID)followers[0]).RID == "#10:5");

            Assert.IsTrue(followers[1].GetType() == typeof(ORID));
            Assert.IsTrue(((ORID)followers[1]).RID == "#10:6");

            Assert.IsTrue(record.Fields["name"].GetType() == typeof(string));
            Assert.IsTrue((string)record.Fields["name"] == "Barack");

            Assert.IsTrue(record.Fields["surname"].GetType() == typeof(string));
            Assert.IsTrue((string)record.Fields["surname"] == "Obama");

            Assert.IsTrue(record.Fields["location"].GetType() == typeof(ORID));
            Assert.IsTrue(((ORID)record.Fields["location"]).RID == "#3:2");

            Assert.IsTrue(record.Fields["invitedBy"] == null);

            Assert.IsTrue(record.Fields["salary_cloned"] == null);

            Assert.IsTrue(record.Fields["salary"].GetType() == typeof(float));
            Assert.IsTrue((float)record.Fields["salary"] == 120.3f);
        }