Tests.ORecordParsingTests.TestBooleanDeserialization C# (CSharp) Method

TestBooleanDeserialization() private method

private TestBooleanDeserialization ( ) : void
return void
        public void TestBooleanDeserialization()
        {
            string raw = "singleT:true,singleF:false,embedded:(singleT:true,singleF:false),array:[true,false]";

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

            Assert.IsTrue(record.Fields["singleT"].GetType() == typeof(bool));
            Assert.IsTrue((bool)record.Fields["singleT"] == true);

            Assert.IsTrue(record.Fields["singleF"].GetType() == typeof(bool));
            Assert.IsTrue((bool)record.Fields["singleF"] == false);

            Dictionary<string, object> embedded = (Dictionary<string, object>)record.Fields["embedded"];

            Assert.IsTrue(embedded["singleT"].GetType() == typeof(bool));
            Assert.IsTrue((bool)embedded["singleT"] == true);

            Assert.IsTrue(embedded["singleF"].GetType() == typeof(bool));
            Assert.IsTrue((bool)embedded["singleF"] == false);

            List<object> array = (List<object>)record.Fields["array"];

            Assert.IsTrue(array.First().GetType() == typeof(bool));
            Assert.IsTrue((bool)array.First() == true);

            Assert.IsTrue(array.Last().GetType() == typeof(bool));
            Assert.IsTrue((bool)array.Last() == false);
        }