示例#1
0
            public override bool Equals(object obj)
            {
                if (object.ReferenceEquals(obj, null) || !(obj is EnumConversionTestClass))
                {
                    return(false);
                }
                EnumConversionTestClass other = (EnumConversionTestClass)obj;

                if (enumList.Count != other.enumList.Count || enumArray.Length != other.enumArray.Length)
                {
                    return(false);
                }

                for (int i = 0; i < enumList.Count; i++)
                {
                    if (enumList[i] != other.enumList[i])
                    {
                        return(false);
                    }
                }
                for (int i = 0; i < enumArray.Length; i++)
                {
                    if (enumArray[i] != other.enumArray[i])
                    {
                        return(false);
                    }
                }
                if (enumValue != other.enumValue || optEnumValue != other.optEnumValue)
                {
                    return(false);
                }

                return(true);
            }
示例#2
0
        void EnumConversionTest_Deserialize()
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj;
            expectedObj.enumList = new List<testRegion>() { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;
            expectedObj.optEnumValue = null;

            string inputJson = "{\"enumList\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumArray\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumValue\":" + ((int)testRegion.Australia) + "}";
            actualObj = SimpleJson.DeserializeObject<EnumConversionTestClass>(inputJson, Util.ApiSerializerStrategy);
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }
示例#3
0
        void EnumConversionTest_Deserialize()
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj = new EnumConversionTestClass();

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;

            string inputJson = "{\"enumList\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumArray\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumValue\":" + ((int)testRegion.Australia) + "}";

            JsonConvert.PopulateObject(inputJson, actualObj, Util.JsonSettings);
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }
示例#4
0
        void EnumConversionTest_Deserialize()
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj;

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray    = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue    = testRegion.Australia;
            expectedObj.optEnumValue = null;

            string inputJson = "{\"enumList\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumArray\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumValue\":" + ((int)testRegion.Australia) + "}";

            actualObj = SimpleJson.DeserializeObject <EnumConversionTestClass>(inputJson, Util.ApiSerializerStrategy);
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }
示例#5
0
        void EnumConversionTest_OptionalEnum()
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass();
            expectedObj.enumList = new List<testRegion>() { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;
            expectedObj.optEnumValue = null;

            var actualJson = SimpleJson.SerializeObject(expectedObj, Util.ApiSerializerStrategy);
            var actualObj = SimpleJson.DeserializeObject<EnumConversionTestClass>(actualJson, Util.ApiSerializerStrategy);
            UUnitAssert.ObjEquals(expectedObj, actualObj);

            expectedObj.optEnumValue = testRegion.Brazil;
            actualJson = SimpleJson.SerializeObject(expectedObj, Util.ApiSerializerStrategy);
            actualObj = SimpleJson.DeserializeObject<EnumConversionTestClass>(actualJson, Util.ApiSerializerStrategy);
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }
示例#6
0
        public void EnumConversionTest_Deserialize(UUnitTestContext testContext)
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj;

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray    = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue    = testRegion.Australia;
            expectedObj.optEnumValue = null;

            var inputJson = "{\"enumList\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumArray\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumValue\":" + ((int)testRegion.Australia) + "}";

            actualObj = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <EnumConversionTestClass>(inputJson);
            testContext.ObjEquals(expectedObj, actualObj);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#7
0
        public void EnumConversionTest_Deserialize(UUnitTestContext testContext)
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj;

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray    = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue    = testRegion.Australia;
            expectedObj.optEnumValue = null;

            string inputJson = "{\"enumList\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumArray\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumValue\":" + ((int)testRegion.Australia) + "}";

            actualObj = JsonWrapper.DeserializeObject <EnumConversionTestClass>(inputJson, PlayFabUtil.ApiSerializerStrategy);
            testContext.ObjEquals(expectedObj, actualObj);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#8
0
        void EnumConversionTest()
        {
            string expectedJson, actualJson;
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj = new EnumConversionTestClass();

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;

            expectedJson = "{\"enumList\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumArray\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumValue\":\"Australia\"}";

            JsonConvert.PopulateObject(expectedJson, actualObj, Util.JsonSettings);
            actualJson = JsonConvert.SerializeObject(actualObj, Util.JsonFormatting, Util.JsonSettings);

            UUnitAssert.Equals(expectedJson.Replace(" ", "").Replace("\n", ""), actualJson.Replace(" ", "").Replace("\n", ""));
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }
示例#9
0
        void EnumConversionTest_Serialize()
        {
            string expectedJson, actualJson;
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj;

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray    = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue    = testRegion.Australia;
            expectedObj.optEnumValue = null;

            expectedJson = "{\"enumList\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumArray\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumValue\":\"Australia\",\"optEnumValue\":null}";

            actualObj  = SimpleJson.DeserializeObject <EnumConversionTestClass>(expectedJson, Util.ApiSerializerStrategy);
            actualJson = SimpleJson.SerializeObject(actualObj, Util.ApiSerializerStrategy);

            UUnitAssert.StringEquals(expectedJson.Replace(" ", "").Replace("\n", ""), actualJson.Replace(" ", "").Replace("\n", ""));
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }
示例#10
0
        public void EnumConversionTest_Serialize(UUnitTestContext testContext)
        {
            string expectedJson, actualJson;
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj;

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray    = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue    = testRegion.Australia;
            expectedObj.optEnumValue = null;

            expectedJson = "{\"enumList\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumArray\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumValue\":\"Australia\",\"optEnumValue\":null}";

            actualObj  = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <EnumConversionTestClass>(expectedJson);
            actualJson = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).SerializeObject(actualObj);

            testContext.StringEquals(expectedJson.Replace(" ", "").Replace("\n", ""), actualJson.Replace(" ", "").Replace("\n", ""));
            testContext.ObjEquals(expectedObj, actualObj);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#11
0
        void EnumConversionTest_OptionalEnum()
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass();

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray    = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue    = testRegion.Australia;
            expectedObj.optEnumValue = null;

            var actualJson = SimpleJson.SerializeObject(expectedObj, Util.ApiSerializerStrategy);
            var actualObj  = SimpleJson.DeserializeObject <EnumConversionTestClass>(actualJson, Util.ApiSerializerStrategy);

            UUnitAssert.ObjEquals(expectedObj, actualObj);

            expectedObj.optEnumValue = testRegion.Brazil;
            actualJson = SimpleJson.SerializeObject(expectedObj, Util.ApiSerializerStrategy);
            actualObj  = SimpleJson.DeserializeObject <EnumConversionTestClass>(actualJson, Util.ApiSerializerStrategy);
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }
示例#12
0
        public void EnumConversionTest_OptionalEnum(UUnitTestContext testContext)
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass();

            expectedObj.enumList = new List <testRegion>()
            {
                testRegion.USEast, testRegion.USCentral, testRegion.Japan
            };
            expectedObj.enumArray    = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue    = testRegion.Australia;
            expectedObj.optEnumValue = null;

            var actualJson = JsonWrapper.SerializeObject(expectedObj, PlayFabUtil.ApiSerializerStrategy);
            var actualObj  = JsonWrapper.DeserializeObject <EnumConversionTestClass>(actualJson, PlayFabUtil.ApiSerializerStrategy);

            testContext.ObjEquals(expectedObj, actualObj);

            expectedObj.optEnumValue = testRegion.Brazil;
            actualJson = JsonWrapper.SerializeObject(expectedObj, PlayFabUtil.ApiSerializerStrategy);
            actualObj  = JsonWrapper.DeserializeObject <EnumConversionTestClass>(actualJson, PlayFabUtil.ApiSerializerStrategy);
            testContext.ObjEquals(expectedObj, actualObj);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#13
0
        public void EnumConversionTest_OptionalEnum(UUnitTestContext testContext)
        {
            var expectedObj = new EnumConversionTestClass
            {
                enumList = new List <testRegion>()
                {
                    testRegion.USEast, testRegion.USCentral, testRegion.Japan
                },
                enumArray    = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan },
                enumValue    = testRegion.Australia,
                optEnumValue = null,
            };

            var actualJson = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).SerializeObject(expectedObj);
            var actualObj  = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <EnumConversionTestClass>(actualJson);

            testContext.ObjEquals(expectedObj, actualObj);

            expectedObj.optEnumValue = testRegion.Brazil;
            actualJson = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).SerializeObject(expectedObj);
            actualObj  = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <EnumConversionTestClass>(actualJson);
            testContext.ObjEquals(expectedObj, actualObj);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#14
0
        void EnumConversionTest()
        {
            string expectedJson, actualJson;
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj = new EnumConversionTestClass();
            expectedObj.enumList = new List<testRegion>() { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;

            expectedJson = "{\"enumList\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumArray\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumValue\":\"Australia\"}";

            JsonConvert.PopulateObject(expectedJson, actualObj, Util.JsonSettings);
            actualJson = JsonConvert.SerializeObject(actualObj, Util.JsonFormatting, Util.JsonSettings);

            UUnitAssert.Equals(expectedJson.Replace(" ", "").Replace("\n", ""), actualJson.Replace(" ", "").Replace("\n", ""));
            UUnitAssert.Equals(expectedObj, actualObj);
        }
示例#15
0
        void EnumConversionTest_Serialize()
        {
            string expectedJson, actualJson;
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj;
            expectedObj.enumList = new List<testRegion>() { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;
            expectedObj.optEnumValue = null;

            expectedJson = "{\"enumList\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumArray\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumValue\":\"Australia\",\"optEnumValue\":null}";

            actualObj = SimpleJson.DeserializeObject<EnumConversionTestClass>(expectedJson, Util.ApiSerializerStrategy);
            actualJson = SimpleJson.SerializeObject(actualObj, Util.ApiSerializerStrategy);

            UUnitAssert.StringEquals(expectedJson.Replace(" ", "").Replace("\n", ""), actualJson.Replace(" ", "").Replace("\n", ""));
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }
示例#16
0
        public void EnumConversionTest_Serialize(UUnitTestContext testContext)
        {
            string expectedJson, actualJson;
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj;
            expectedObj.enumList = new List<testRegion>() { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;
            expectedObj.optEnumValue = null;

            expectedJson = "{\"enumList\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumArray\":[\"USEast\",\"USCentral\",\"Japan\"],\"enumValue\":\"Australia\",\"optEnumValue\":null}";

            actualObj = JsonWrapper.DeserializeObject<EnumConversionTestClass>(expectedJson, PlayFabUtil.ApiSerializerStrategy);
            actualJson = JsonWrapper.SerializeObject(actualObj, PlayFabUtil.ApiSerializerStrategy);

            testContext.StringEquals(expectedJson.Replace(" ", "").Replace("\n", ""), actualJson.Replace(" ", "").Replace("\n", ""));
            testContext.ObjEquals(expectedObj, actualObj);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#17
0
        public void EnumConversionTest_Deserialize(UUnitTestContext testContext)
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj;
            expectedObj.enumList = new List<testRegion>() { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;
            expectedObj.optEnumValue = null;

            string inputJson = "{\"enumList\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumArray\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumValue\":" + ((int)testRegion.Australia) + "}";
            actualObj = JsonWrapper.DeserializeObject<EnumConversionTestClass>(inputJson, PlayFabUtil.ApiSerializerStrategy);
            testContext.ObjEquals(expectedObj, actualObj);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#18
0
        public void EnumConversionTest_OptionalEnum(UUnitTestContext testContext)
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass();
            expectedObj.enumList = new List<testRegion>() { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;
            expectedObj.optEnumValue = null;

            var actualJson = JsonWrapper.SerializeObject(expectedObj, PlayFabUtil.ApiSerializerStrategy);
            var actualObj = JsonWrapper.DeserializeObject<EnumConversionTestClass>(actualJson, PlayFabUtil.ApiSerializerStrategy);
            testContext.ObjEquals(expectedObj, actualObj);

            expectedObj.optEnumValue = testRegion.Brazil;
            actualJson = JsonWrapper.SerializeObject(expectedObj, PlayFabUtil.ApiSerializerStrategy);
            actualObj = JsonWrapper.DeserializeObject<EnumConversionTestClass>(actualJson, PlayFabUtil.ApiSerializerStrategy);
            testContext.ObjEquals(expectedObj, actualObj);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#19
0
        void EnumConversionTest_Deserialize()
        {
            EnumConversionTestClass expectedObj = new EnumConversionTestClass(), actualObj = new EnumConversionTestClass();
            expectedObj.enumList = new List<testRegion>() { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumArray = new testRegion[] { testRegion.USEast, testRegion.USCentral, testRegion.Japan };
            expectedObj.enumValue = testRegion.Australia;

            string inputJson = "{\"enumList\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumArray\":[" + ((int)testRegion.USEast) + "," + ((int)testRegion.USCentral) + "," + ((int)testRegion.Japan) + "],\"enumValue\":" + ((int)testRegion.Australia) + "}";
            JsonConvert.PopulateObject(inputJson, actualObj, Util.JsonSettings);
            UUnitAssert.ObjEquals(expectedObj, actualObj);
        }