Exemple #1
0
        internal static bool TestCase()
        {
            #region 引用类型二进制序列化测试
            data.filedData filedData = fastCSharp.emit.random <data.filedData> .Create();

            byte[]         data         = fastCSharp.emit.indexSerializer.Serialize(filedData);
            data.filedData newFieldData = fastCSharp.emit.indexDeSerializer.DeSerialize <data.filedData>(data);
            if (!fastCSharp.emit.equals <data.filedData> .Equals(filedData, newFieldData))
            {
                return(false);
            }
            #endregion

            #region 带成员位图的引用类型二进制序列化测试
            serializeConfig.MemberMap = fastCSharp.code.memberMap <data.filedData> .NewFull();

            data         = fastCSharp.emit.indexSerializer.Serialize(filedData, serializeConfig);
            newFieldData = fastCSharp.emit.indexDeSerializer.DeSerialize <data.filedData>(data);
            if (!fastCSharp.emit.equals <data.filedData> .MemberMapEquals(filedData, newFieldData, serializeConfig.MemberMap))
            {
                return(false);
            }
            #endregion

            #region 值类型二进制序列化测试
            data.structFiledData structFiledData = fastCSharp.emit.random <data.structFiledData> .Create();

            data = fastCSharp.emit.indexSerializer.Serialize(structFiledData);
            data.structFiledData newStructFiledData = fastCSharp.emit.indexDeSerializer.DeSerialize <data.structFiledData>(data);
            if (!fastCSharp.emit.equals <data.structFiledData> .Equals(structFiledData, newStructFiledData))
            {
                return(false);
            }
            #endregion

            #region 带成员位图的值类型二进制序列化测试
            serializeConfig.MemberMap = fastCSharp.code.memberMap <data.structFiledData> .NewFull();

            data = fastCSharp.emit.indexSerializer.Serialize(structFiledData, serializeConfig);
            newStructFiledData = fastCSharp.emit.indexDeSerializer.DeSerialize <data.structFiledData>(data);
            if (!fastCSharp.emit.equals <data.structFiledData> .MemberMapEquals(structFiledData, newStructFiledData, serializeConfig.MemberMap))
            {
                return(false);
            }
            #endregion

            return(true);
        }
Exemple #2
0
        internal static bool TestCase()
        {
            #region 引用类型字段成员JSON序列化测试
            data.filedData filedData = fastCSharp.emit.random <data.filedData> .Create(randomConfig);

            string         json         = fastCSharp.emit.jsonSerializer.ToJson(filedData);
            data.filedData newFieldData = fastCSharp.emit.jsonParser.Parse <data.filedData>(json);
            if (!fastCSharp.emit.equals <data.filedData> .Equals(filedData, newFieldData))
            {
                return(false);
            }
            #endregion

            #region 带成员位图的引用类型字段成员JSON序列化测试
            jsonSerializeConfig.MemberMap = fastCSharp.code.memberMap <data.filedData> .NewFull();

            json         = fastCSharp.emit.jsonSerializer.ToJson(filedData, jsonSerializeConfig);
            newFieldData = fastCSharp.emit.jsonParser.Parse <data.filedData>(json);
            if (!fastCSharp.emit.equals <data.filedData> .MemberMapEquals(filedData, newFieldData, jsonSerializeConfig.MemberMap))
            {
                return(false);
            }
            #endregion

            #region 引用类型属性成员JSON序列化测试
            data.propertyData propertyData = fastCSharp.emit.random <data.propertyData> .Create(randomConfig);

            json = fastCSharp.emit.jsonSerializer.ToJson(propertyData);
            data.propertyData newPropertyData = fastCSharp.emit.jsonParser.Parse <data.propertyData>(json);
            if (!fastCSharp.emit.equals <data.propertyData> .Equals(propertyData, newPropertyData))
            {
                return(false);
            }
            #endregion

            #region 值类型字段成员JSON序列化测试
            data.structFiledData structFiledData = fastCSharp.emit.random <data.structFiledData> .Create(randomConfig);

            json = fastCSharp.emit.jsonSerializer.ToJson(structFiledData);
            data.structFiledData newStructFiledData = fastCSharp.emit.jsonParser.Parse <data.structFiledData>(json);
            if (!fastCSharp.emit.equals <data.structFiledData> .Equals(structFiledData, newStructFiledData))
            {
                return(false);
            }
            #endregion

            #region 带成员位图的值类型字段成员JSON序列化测试
            jsonSerializeConfig.MemberMap = fastCSharp.code.memberMap <data.structFiledData> .NewFull();

            json = fastCSharp.emit.jsonSerializer.ToJson(structFiledData, jsonSerializeConfig);
            newStructFiledData = fastCSharp.emit.jsonParser.Parse <data.structFiledData>(json);
            if (!fastCSharp.emit.equals <data.structFiledData> .MemberMapEquals(structFiledData, newStructFiledData, jsonSerializeConfig.MemberMap))
            {
                return(false);
            }
            #endregion

            #region 值类型属性成员JSON序列化测试
            data.structPropertyData structPropertyData = fastCSharp.emit.random <data.structPropertyData> .Create(randomConfig);

            json = fastCSharp.emit.jsonSerializer.ToJson(structPropertyData);
            data.structPropertyData newStructPropertyData = fastCSharp.emit.jsonParser.Parse <data.structPropertyData>(json);
            if (!fastCSharp.emit.equals <data.structPropertyData> .Equals(structPropertyData, newStructPropertyData))
            {
                return(false);
            }
            #endregion

            return(true);
        }
Exemple #3
0
        internal static bool TestCase()
        {
            #region 引用类型二进制序列化测试(Emit模式)
            data.filedData filedData = fastCSharp.emit.random <data.filedData> .Create();

            byte[]         data         = fastCSharp.emit.dataSerializer.Serialize(filedData);
            data.filedData newFieldData = fastCSharp.emit.dataDeSerializer.DeSerialize <data.filedData>(data);
            if (!fastCSharp.emit.equals <data.filedData> .Equals(filedData, newFieldData))
            {
                return(false);
            }
            #endregion

            #region 带成员位图的引用类型二进制序列化测试(Emit模式)
            serializeConfig.MemberMap = fastCSharp.code.memberMap <data.filedData> .NewFull();

            data         = fastCSharp.emit.dataSerializer.Serialize(filedData, serializeConfig);
            newFieldData = fastCSharp.emit.dataDeSerializer.DeSerialize <data.filedData>(data);
            if (!fastCSharp.emit.equals <data.filedData> .MemberMapEquals(filedData, newFieldData, serializeConfig.MemberMap))
            {
                return(false);
            }
            #endregion

            #region 值类型二进制序列化测试(Emit模式)
            data.structFiledData structFiledData = fastCSharp.emit.random <data.structFiledData> .Create();

            data = fastCSharp.emit.dataSerializer.Serialize(structFiledData);
            data.structFiledData newStructFiledData = fastCSharp.emit.dataDeSerializer.DeSerialize <data.structFiledData>(data);
            if (!fastCSharp.emit.equals <data.structFiledData> .Equals(structFiledData, newStructFiledData))
            {
                return(false);
            }
            #endregion

            #region 带成员位图的值类型二进制序列化测试(Emit模式)
            serializeConfig.MemberMap = fastCSharp.code.memberMap <data.structFiledData> .NewFull();

            data = fastCSharp.emit.dataSerializer.Serialize(structFiledData, serializeConfig);
            newStructFiledData = fastCSharp.emit.dataDeSerializer.DeSerialize <data.structFiledData>(data);
            if (!fastCSharp.emit.equals <data.structFiledData> .MemberMapEquals(structFiledData, newStructFiledData, serializeConfig.MemberMap))
            {
                return(false);
            }
            #endregion

#if NotFastCSharpCode
#else
            #region 二进制序列化测试(代码生成模式)
            filedDataSerialize filedDataSerialize = fastCSharp.emit.random <filedDataSerialize> .Create();

            data = filedDataSerialize.Serialize();
            filedDataSerialize newFiledDataSerialize = new filedDataSerialize();
            newFiledDataSerialize.DeSerialize(data);
            if (!fastCSharp.emit.equals <filedDataSerialize> .Equals(filedDataSerialize, newFiledDataSerialize))
            {
                return(false);
            }
            #endregion
#endif
            return(true);
        }