Example #1
0
        public static void SerializeTest()
        {
            var target = new CommonEventStrArgList
            {
                ReferenceFlg = 0x01
            };
            var clone = DeepCloner.DeepClone(target);

            Assert.IsTrue(clone.Equals(target));
        }
Example #2
0
        public void ReferenceFlgSetTest(bool[] strFlgs, byte flg)
        {
            var instance = new CommonEventStrArgList {
                ReferenceFlg = flg
            };

            for (var i = 0; i < 4; i++)
            {
                Assert.AreEqual(instance[i].InstanceIntOrStrType, strFlgs[i] ? IntOrStrType.Str : IntOrStrType.Int);
            }
        }
Example #3
0
        public static void AccessorTest(int index, object value)
        {
            IntOrStr obj;

            switch (value)
            {
            case int i:
                obj = i;
                break;

            case string s:
                obj = s;
                break;

            default:
                Assert.Fail();
                return;
            }

            var instance = new CommonEventStrArgList {
                [index] = obj
            };

            for (var idx = 0; idx < 4; idx++)
            {
                if (idx != index)
                {
                    continue;
                }

                var resultInstance = instance[index];
                switch (value)
                {
                case int i2:
                    Assert.AreEqual(resultInstance.InstanceIntOrStrType, IntOrStrType.Int);
                    Assert.AreEqual(resultInstance.ToInt(), i2);
                    break;

                case string s2:
                    Assert.AreEqual(resultInstance.InstanceIntOrStrType, IntOrStrType.Str);
                    Assert.AreEqual(resultInstance.ToStr(), s2);
                    break;

                default:
                    Assert.Fail();
                    break;
                }
            }
        }
Example #4
0
        public void ReferenceFlgGetTest(bool[] strFlgs, byte answer)
        {
            var instance = new CommonEventStrArgList();

            for (var i = 0; i < 4; i++)
            {
                if (strFlgs[i])
                {
                    instance[i] = "test";
                }
                else
                {
                    instance[i] = 10;
                }
            }
            Assert.AreEqual(instance.ReferenceFlg, answer);
        }