Beispiel #1
0
        public void MissingRef()
        {
            // Turn it into null.

            string serialized = @"
                <Record>
                  <recordFormatVersion>1</recordFormatVersion>
                  <data>
                    <recordable ref=""ref00000"" />
                  </data>
                </Record>";

            Recorder.PrimitivesContainer deserialized = null;
            ExpectErrors(() => deserialized = Dec.Recorder.Read <Recorder.PrimitivesContainer>(serialized));

            Assert.IsNull(deserialized.recordable);
        }
Beispiel #2
0
        public void NullRef()
        {
            // This is weird and not OK. I've chosen to prioritize the null over the ref, on the theory that there are a lot of ways that broken files can turn into null anyway.

            string serialized = @"
                <Record>
                  <recordFormatVersion>1</recordFormatVersion>
                  <refs>
                    <Ref id=""ref00000"" class=""DecTest.Recorder.PrimitivesRecordable"" />
                  </refs>
                  <data>
                    <recordable ref=""ref00000"" null=""true""/>
                  </data>
                </Record>";

            Recorder.PrimitivesContainer deserialized = null;
            ExpectErrors(() => deserialized = Dec.Recorder.Read <Recorder.PrimitivesContainer>(serialized));

            Assert.IsNull(deserialized.recordable);
        }
Beispiel #3
0
        public void ExtraAttributeRef()
        {
            // Just ignore the extra attribute.

            string serialized = @"
                <Record>
                  <recordFormatVersion>1</recordFormatVersion>
                  <refs>
                    <Ref id=""ref00000"" class=""DecTest.Recorder.PrimitivesRecordable"">
                        <intValue>42</intValue>
                    </Ref>
                  </refs>
                  <data>
                    <recordable ref=""ref00000"" garbage=""yup"" />
                  </data>
                </Record>";

            Recorder.PrimitivesContainer deserialized = null;
            ExpectErrors(() => deserialized = Dec.Recorder.Read <Recorder.PrimitivesContainer>(serialized));

            Assert.AreEqual(42, deserialized.recordable.intValue);
        }