public void FillsInWithIgnored()
        {
            var data = new object[] { 1, null, null, null, null, null, null, null, null, null, 10 };

            TestConverter <NeedsFillingIn> .TryDeserialize(false, data, out var result)
            .Should().Be(true);

            result
            .Property1
            .Should().Be((int)data[0]);

            result
            .Property10
            .Should().Be((int)data[10]);

            TestConverter <NeedsFillingIn> .TryDeserialize(true, data, out result)
            .Should().Be(true);

            result
            .Property1
            .Should().Be((int)data[0]);

            result
            .Property10
            .Should().Be((int)data[10]);
        }
Exemplo n.º 2
0
        public void Ignored(string comment, params object[] deserializeInfo)
        {
            TestConverter <InvalidDeserializationTestsIgnoredAttributeBase> .TryDeserialize(false, deserializeInfo, out _)
            .Should().BeFalse(comment);

            TestConverter <InvalidDeserializationTestsIgnoredAttributeBase> .TryDeserialize(true, deserializeInfo, out _)
            .Should().BeFalse(comment);
        }
        public void NoMembers(string comment, params object[] deserializeInfo)
        {
            TestConverter <HasNoMembers> .TryDeserialize(false, deserializeInfo, out _)
            .Should().BeTrue(comment);

            TestConverter <HasNoMembers> .TryDeserialize(true, deserializeInfo, out _)
            .Should().BeTrue(comment);
        }
        public void FlattenArray(string comment, params object[] deserializeInfo)
        {
            TestConverter <DeserializationTestsFlattenArrayAttributeBase> .TryDeserialize(false, deserializeInfo, out _)
            .Should().BeTrue(comment);

            TestConverter <DeserializationTestsFlattenArrayAttributeBase> .TryDeserialize(true, deserializeInfo, out _)
            .Should().BeTrue(comment);
        }
Exemplo n.º 5
0
        private static T GetInst <T>(bool il) where T : new()
        {
            if (!TestConverter <T> .TryDeserialize(il, new object[] { SUCCESS }, out var result))
            {
                throw new TestException(nameof(GetInst) + ", " + typeof(T));
            }

            return(result);
        }
Exemplo n.º 6
0
        public static int EndsOn <T>(bool il, object[] deserialize)
            where T : new()
        {
            var position = 0;

            TestConverter <T> .TryDeserialize(il, deserialize, ref position, out _)
            .Should().Be(false, "Ensure the data being modified is corrupt.\r\nIf this happens to sometimes pass, please revise the data corruptor.");

            return(position);
        }
        public void Optional(string comment, params object[] deserializeInfo)
        {
            ((Action)(() =>
            {
                TestConverter <DeserializationTestsOptionalAttributeBase> .TryDeserialize(false, deserializeInfo, out var item)
                .Should().BeTrue($"NO IL - {comment}");

                if (deserializeInfo[0] is string str)
                {
                    item.MyReferenceType
                    .Should().Be(str);
                }

                if (deserializeInfo[1] is int intg)
                {
                    item.MyValueType
                    .Should().Be(intg);
                }
            })).Should().NotThrow("NO IL");

            ((Action)(() =>
            {
                TestConverter <DeserializationTestsOptionalAttributeBase> .TryDeserialize(true, deserializeInfo, out var item)
                .Should().BeTrue($"IL - {comment}");

                if (deserializeInfo[0] is string str)
                {
                    item.MyReferenceType
                    .Should().Be(str);
                }

                if (deserializeInfo[1] is int intg)
                {
                    item.MyValueType
                    .Should().Be(intg);
                }
            })).Should().NotThrow("IL");
        }