Exemple #1
0
        public void InvalidSaveAttribute()
        {
            Setup();

            Assert.ThrowsException <InvalidAttributeToVerException>(() =>
                                                                    IntermediateMapper.CreateIntermediateObjectInfo(typeof(InvalidSaveAttributeClass), SaveMembersMode.Properties, out var members));
        }
Exemple #2
0
        public void Properties_Unordered()
        {
            Setup();

            uint highestVersion =
                IntermediateMapper.CreateIntermediateObjectInfo(typeof(UnorderedClass), SaveMembersMode.Properties, out var members);

            Assert.AreEqual(0u, highestVersion);

            for (int i = 0; i < members.Members.Length; i++)
            {
                Assert.IsFalse(members.Members[i].IsProcessed);
                Assert.IsInstanceOfType(members.Members[i].Details.Unprocessed, typeof(PropertyInfo));

                Type expectedType = i switch
                {
                    0 => typeof(bool),
                    1 => typeof(string),
                    _ => throw new Exception("Invalid key")
                };

                Assert.AreEqual(expectedType, ((PropertyInfo)members.Members[i].Details.Unprocessed).PropertyType);
                i++;
            }
        }
Exemple #3
0
        void TestFields(bool isValueTypeParent)
        {
            var highestVersion = IntermediateMapper.CreateIntermediateObjectInfo(
                isValueTypeParent ? typeof(FieldStruct) : typeof(FieldClass), SaveMembersMode.Fields, out var members);

            Assert.AreEqual(0u, highestVersion);
            Assert.AreEqual(2, members.Members.Length);

            for (int i = 0; i < members.Members.Length; i++)
            {
                Assert.IsFalse(members.Members[i].IsProcessed);
                Assert.IsInstanceOfType(members.Members[i].Details.Unprocessed, typeof(FieldInfo));

                Type expectedType = i switch
                {
                    0 => typeof(string),
                    1 => typeof(bool),
                    _ => throw new Exception("Incorrect key")
                };

                Assert.AreEqual(expectedType, ((FieldInfo)members.Members[i].Details.Unprocessed).FieldType);
            }
        }
Exemple #4
0
        void TestProperties(bool isValueTypeParent)
        {
            var highestVersion = IntermediateMapper.CreateIntermediateObjectInfo(
                isValueTypeParent ? typeof(AllPrimitiveStruct) : typeof(AllPrimitiveClass), SaveMembersMode.Properties, out var members);

            Assert.AreEqual(0u, highestVersion);
            Assert.AreEqual(3, members.Members.Length);

            for (int i = 0; i < members.Members.Length; i++)
            {
                Assert.IsFalse(members.Members[i].IsProcessed);
                Assert.IsInstanceOfType(members.Members[i].Details.Unprocessed, typeof(PropertyInfo));

                Type expectedType = i switch
                {
                    0 => typeof(bool),
                    1 => typeof(int),
                    2 => typeof(string),
                    _ => throw new Exception("Invalid key")
                };

                Assert.AreEqual(expectedType, ((PropertyInfo)members.Members[i].Details.Unprocessed) !.PropertyType);
            }
        }
Exemple #5
0
 public override uint Initialize(InitializeInfo info)
 {
     return(IntermediateMapper.CreateIntermediateObjectInfo(info.Type, _saveMode, out _intermediateInfo));
 }