public void TestNonSerialized()
        {
            var serializer         = CreateSerializer();
            NonSerializedTest test = new NonSerializedTest();

            test.integer  = 1337;
            test.integer2 = 13;
            test.integer3 = 999;

            List <ISerializableRoot> roots = new List <ISerializableRoot>();

            roots.Add(test);
            string xml = serializer.Serialize(roots, out errors);

            FlushErrors();
            Debug.Log(xml);

            roots.Clear();
            serializer.Deserialize(new string[] { xml }, new string[] { "MEMORY" }, null, out roots, out errors);
            FlushErrors();

            Assert.AreEqual(roots.Count, 1);
            Assert.AreEqual(test, roots[0]);
            Assert.AreEqual((roots[0] as NonSerializedTest).integer2, -1);
            Assert.AreEqual((roots[0] as NonSerializedTest).integer3, -1);
        }
Beispiel #2
0
    public void CloneAttributeNonSerialized()
    {
        var input = new NonSerializedTest()
        {
            NonSerialized = 5,
            Serialized    = 10,
        };

        var output = _serializer.Clone(log, input);

        Assert.AreEqual(output.NonSerialized, 1);
        Assert.AreEqual(output.Serialized, 10);
    }
Beispiel #3
0
    public void SerializeAttributeNonSerialized()
    {
        var input = new NonSerializedTest()
        {
            NonSerialized = 5,
            Serialized    = 10,
        };

        _serializer.Save(Call, input);
        var output = _serializer.Load <NonSerializedTest>(Call);

        Assert.AreEqual(output.NonSerialized, 1);
        Assert.AreEqual(output.Serialized, 10);
    }
        public void CanIgnoreFieldsWithNonSerializedAttribute()
        {
            var expected = new NonSerializedTest()
            {
                Field1 = 235,
                Field2 = "non serialized text"
            };

            Serialize(expected);
            Reset();
            var actual = Deserialize <NonSerializedTest>();

            Assert.Equal(expected.Field1, actual.Field1);
            Assert.Null(actual.Field2);
        }